pidgin.mxit.2.x.y: d25eeb24: Add support for the Relationship Status ...

andrew.victor at mxit.com andrew.victor at mxit.com
Tue Feb 21 16:21:07 EST 2012


----------------------------------------------------------------------
Revision: d25eeb2478130585b2bc301214a1683a1e81ca5e
Parent:   2cca525615a367389b1639a5246fbe6d451150c4
Author:   andrew.victor at mxit.com
Date:     02/21/12 16:18:50
Branch:   im.pidgin.pidgin.mxit.2.x.y
URL: http://d.pidgin.im/viewmtn/revision/info/d25eeb2478130585b2bc301214a1683a1e81ca5e

Changelog: 

Add support for the Relationship Status profile attribute.


Changes against parent 2cca525615a367389b1639a5246fbe6d451150c4

  patched  libpurple/protocols/mxit/actions.c
  patched  libpurple/protocols/mxit/mxit.c
  patched  libpurple/protocols/mxit/profile.c
  patched  libpurple/protocols/mxit/profile.h
  patched  libpurple/protocols/mxit/protocol.c
  patched  libpurple/protocols/mxit/protocol.h

-------------- next part --------------
============================================================
--- libpurple/protocols/mxit/actions.c	cdd0c52cbda316495e002c2741983adcbf92c00b
+++ libpurple/protocols/mxit/actions.c	0b5cfde46f3e47ac1b24097a683370cbdd2131df
@@ -48,6 +48,7 @@ static void mxit_profile_cb( PurpleConne
 	const char*				name	= NULL;
 	const char*				bday	= NULL;
 	const char*				err		= NULL;
+	GList*					entry	= NULL;
 
 	purple_debug_info( MXIT_PLUGIN_ID, "mxit_profile_cb\n" );
 
@@ -173,6 +174,14 @@ out:
 		g_string_append( attributes, attrib );
 		acount++;
 
+		/* relationship status */
+		field = purple_request_fields_get_field( fields, "relationship" );
+		entry = g_list_first( purple_request_field_list_get_selected( field ) );
+		profile->relationship = atoi( purple_request_field_list_get_data( field, entry->data ) );
+		g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%i", CP_PROFILE_RELATIONSHIP, CP_PROFILE_TYPE_SHORT, profile->relationship );
+		g_string_append( attributes, attrib );
+		acount++;
+
 		/* update flags */
 		field = purple_request_fields_get_field( fields, "searchable" );
 		if ( purple_request_field_bool_get_value( field ) )		/* is searchable -> clear not-searchable flag */
@@ -260,6 +269,22 @@ static void mxit_profile_action( PurpleP
 		field = purple_request_field_string_new( "whereami", _( "Where I Live" ), profile->whereami, FALSE);
 		purple_request_field_group_add_field( public_group, field );
 
+		/* relationship status */
+		field = purple_request_field_list_new( "relationship", _( "Relationship Status" ) );
+		purple_request_field_list_set_multi_select( field, FALSE );
+		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_UNKNOWN ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_UNKNOWN ) );
+		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_DONTSAY ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_DONTSAY ) );
+		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_SINGLE ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_SINGLE ) );
+		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_INVOLVED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_INVOLVED ) );
+		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_ENGAGED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_ENGAGED ) );
+		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_MARRIED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_MARRIED ) );
+		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_COMPLICATED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_COMPLICATED ) );
+		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_WIDOWED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_WIDOWED ) );
+		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_SEPARATED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_SEPARATED ) );
+		purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_DIVORCED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_DIVORCED ) );
+		purple_request_field_list_add_selected( field, mxit_relationship_to_name( profile->relationship ) );
+		purple_request_field_group_add_field( public_group, field );
+
 		purple_request_fields_add_group( fields, public_group );
 	}
 
============================================================
--- libpurple/protocols/mxit/mxit.c	b660deeda7df58796113402de0bcf3d4465d11c2
+++ libpurple/protocols/mxit/mxit.c	f24690745eaa2c8659ae556d3ac0d02d39c346c6
@@ -565,7 +565,7 @@ static void mxit_get_info( PurpleConnect
 	struct MXitSession*		session			= (struct MXitSession*) gc->proto_data;
 	const char*				profilelist[]	= { CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_FULLNAME,
 												CP_PROFILE_FIRSTNAME, CP_PROFILE_LASTNAME, CP_PROFILE_REGCOUNTRY, CP_PROFILE_LASTSEEN,
-												CP_PROFILE_STATUS, CP_PROFILE_AVATAR, CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME };
+												CP_PROFILE_STATUS, CP_PROFILE_AVATAR, CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME, CP_PROFILE_RELATIONSHIP };
 
 	purple_debug_info( MXIT_PLUGIN_ID, "mxit_get_info: '%s'\n", who );
 
============================================================
--- libpurple/protocols/mxit/profile.c	ccfd30e7e5da09e35101d56835b08f301bb655a7
+++ libpurple/protocols/mxit/profile.c	57a30c01891a6d3da5bf7b661734250ec9c687d6
@@ -35,6 +35,40 @@
 
 
 /*------------------------------------------------------------------------
+ * Return the MXit Relationship status as a string.
+ *
+ * @param id		The Relationship status value (see profile.h)
+ * @return			The relationship status as a text string.
+ */
+const char* mxit_relationship_to_name( short id )
+{
+	switch ( id ) {
+		case MXIT_RELATIONSHIP_UNKNOWN :
+			return _( "Unknown" );
+		case MXIT_RELATIONSHIP_DONTSAY :
+			return _( "Don't want to say" );
+		case MXIT_RELATIONSHIP_SINGLE :
+			return _( "Single" );
+		case MXIT_RELATIONSHIP_INVOLVED :
+			return _( "In a relationship" );
+		case MXIT_RELATIONSHIP_ENGAGED :
+			return _( "Engaged" );
+		case MXIT_RELATIONSHIP_MARRIED :
+			return _( "Married" );
+		case MXIT_RELATIONSHIP_COMPLICATED :
+			return _( "It's complicated" );
+		case MXIT_RELATIONSHIP_WIDOWED :
+			return _( "Widowed" );
+		case MXIT_RELATIONSHIP_SEPARATED :
+			return _( "Separated" );
+		case MXIT_RELATIONSHIP_DIVORCED :
+			return _( "Divorced" );
+		default :
+			return "";
+	}
+}
+
+/*------------------------------------------------------------------------
  * Returns true if it is a valid date.
  *
  * @param bday		Date-of-Birth string (YYYY-MM-DD)
@@ -193,6 +227,8 @@ void mxit_show_profile( struct MXitSessi
 	if ( strlen( profile->whereami ) > 0 )
 		purple_notify_user_info_add_pair( info, _( "Where I Live" ), profile->whereami );
 
+	purple_notify_user_info_add_pair_plaintext( info, _( "Relationship Status" ), mxit_relationship_to_name( profile->relationship ) );
+
 	purple_notify_user_info_add_section_break( info );
 
 	if ( contact ) {
============================================================
--- libpurple/protocols/mxit/profile.h	acfd17f2ccf5284e49ccccaa762a73c551f92f84
+++ libpurple/protocols/mxit/profile.h	b2a29f1112ec2ba4c882e1bbb820e4d0c4cd1280
@@ -29,6 +29,18 @@
 #include	<glib.h>
 
 
+/* MXit relationship status types */
+#define MXIT_RELATIONSHIP_UNKNOWN		0
+#define MXIT_RELATIONSHIP_DONTSAY		1
+#define MXIT_RELATIONSHIP_SINGLE		2
+#define MXIT_RELATIONSHIP_INVOLVED		3
+#define MXIT_RELATIONSHIP_ENGAGED		4
+#define MXIT_RELATIONSHIP_MARRIED		5
+#define MXIT_RELATIONSHIP_COMPLICATED	6
+#define MXIT_RELATIONSHIP_WIDOWED		7
+#define MXIT_RELATIONSHIP_SEPARATED		8
+#define MXIT_RELATIONSHIP_DIVORCED		9
+
 struct MXitProfile {
 	/* required */
 	char		loginname[64];						/* name user uses to log into MXit with (aka 'mxitid') */
@@ -47,6 +59,7 @@ struct MXitProfile {
 	char		regcountry[3];						/* user's registered country code */
 	char		whereami[51];						/* where am I / where I live */
 	char		aboutme[513];						/* about me */
+	int			relationship;						/* relationship status */
 
 	int			flags;								/* user's profile flags */
 	gint64		lastonline;							/* user's last-online timestamp */
@@ -56,6 +69,7 @@ void mxit_show_search_results( struct MX
 struct MXitSession;
 void mxit_show_profile( struct MXitSession* session, const char* username, struct MXitProfile* profile );
 void mxit_show_search_results( struct MXitSession* session, int searchType, int maxResults, GList* entries );
+const char* mxit_relationship_to_name( short id );
 
 gboolean validateDate( const char* bday );
 
============================================================
--- libpurple/protocols/mxit/protocol.c	148f05b7484e2298528c3d37abf76360e1c7115a
+++ libpurple/protocols/mxit/protocol.c	b4ffb7953a851cdcc6a626ef34f7c0d4a813c24d
@@ -1450,7 +1450,7 @@ static void mxit_parse_cmd_login( struct
 	const char*		statusmsg;
 	const char*		profilelist[] = { CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_HIDENUMBER, CP_PROFILE_FULLNAME,
 									CP_PROFILE_TITLE, CP_PROFILE_FIRSTNAME, CP_PROFILE_LASTNAME, CP_PROFILE_EMAIL,
-									CP_PROFILE_MOBILENR, CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME, CP_PROFILE_FLAGS };
+									CP_PROFILE_MOBILENR, CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME, CP_PROFILE_RELATIONSHIP, CP_PROFILE_FLAGS };
 
 	purple_account_set_int( session->acc, MXIT_CONFIG_STATE, MXIT_STATE_LOGIN );
 
@@ -1866,6 +1866,10 @@ static void mxit_parse_cmd_extprofile( s
 			/* about me */
 			g_strlcpy( profile->aboutme, fvalue, sizeof( profile->aboutme ) );
 		}
+		else if ( strcmp( CP_PROFILE_RELATIONSHIP, fname ) == 0) {
+			/* relatinship status */
+			profile->relationship = strtol( fvalue, NULL, 10 );
+		}
 		else {
 			/* invalid profile attribute */
 			purple_debug_error( MXIT_PLUGIN_ID, "Invalid profile attribute received '%s' \n", fname );
============================================================
--- libpurple/protocols/mxit/protocol.h	cd86cea741fc786d0fd9969fb8a49b69ac44a52d
+++ libpurple/protocols/mxit/protocol.h	08e87fa4e6551005858077c0d0e8cc4b2863b5a3
@@ -195,9 +195,11 @@
 #define		CP_PROFILE_LASTSEEN		"lastseen"				/* Last-Online timestamp */
 #define		CP_PROFILE_WHEREAMI		"whereami"				/* Where am I / Where I live */
 #define		CP_PROFILE_ABOUTME		"aboutme"				/* About me */
+#define		CP_PROFILE_RELATIONSHIP	"relationship"			/* Relationship Status */
 
 /* extended profile field types */
 #define		CP_PROFILE_TYPE_BOOL	0x02					/* boolean (0 or 1) */
+#define		CP_PROFILE_TYPE_SHORT	0x04					/* short (16-bit) */
 #define		CP_PROFILE_TYPE_INT		0x05					/* integer (32-bit) */
 #define		CP_PROFILE_TYPE_LONG	0x06					/* long (64-bit) */
 #define		CP_PROFILE_TYPE_UTF8	0x0A					/* UTF8 string */


More information about the Commits mailing list