pidgin.mxit: 606f2ef9: Extensions to the user profile.
andrew.victor at mxit.com
andrew.victor at mxit.com
Tue Mar 22 18:01:01 EDT 2011
----------------------------------------------------------------------
Revision: 606f2ef9cbbd7db1b9b2a88886084e4a175d9269
Parent: 18fa56675cdd6066f41dd02e736ca759458adbb3
Author: andrew.victor at mxit.com
Date: 03/22/11 17:56:30
Branch: im.pidgin.pidgin.mxit
URL: http://d.pidgin.im/viewmtn/revision/info/606f2ef9cbbd7db1b9b2a88886084e4a175d9269
Changelog:
Extensions to the user profile.
Changes against parent 18fa56675cdd6066f41dd02e736ca759458adbb3
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 8ade1c5f24bda59ab6c1481af7f3a6782f7c7f0e
+++ libpurple/protocols/mxit/actions.c 0d64af2a4105cbd29d550102f49b5a3ccf1d4f92
@@ -186,6 +186,43 @@ out:
g_string_append( attributes, attrib );
acount++;
+#if 0
+ /* update about me */
+ name = purple_request_fields_get_string( fields, "aboutme" );
+ if ( !name )
+ profile->aboutme[0] = '\0';
+ else
+ g_strlcpy( profile->aboutme, name, sizeof( profile->aboutme ) );
+ g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_ABOUTME, CP_PROFILE_TYPE_UTF8, profile->aboutme );
+ g_string_append( attributes, attrib );
+ acount++;
+
+ /* update where am i */
+ name = purple_request_fields_get_string( fields, "whereami" );
+ if ( !name)
+ profile->whereami[0] = '\0';
+ else
+ g_strlcpy( profile->whereami, name, sizeof( profile->whereami ) );
+ g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_WHEREAMI, CP_PROFILE_TYPE_UTF8, profile->whereami );
+ g_string_append( attributes, attrib );
+ acount++;
+#endif
+
+ /* update flags */
+ field = purple_request_fields_get_field( fields, "searchable" );
+ if ( purple_request_field_bool_get_value( field ) ) /* is searchable -> clear not-searchable flag */
+ profile->flags &= ~CP_PROF_NOT_SEARCHABLE;
+ else
+ profile->flags |= CP_PROF_NOT_SEARCHABLE;
+ field = purple_request_fields_get_field( fields, "suggestable" );
+ if ( purple_request_field_bool_get_value( field ) ) /* is suggestable -> clear not-suggestable flag */
+ profile->flags &= ~CP_PROF_NOT_SUGGESTABLE;
+ else
+ profile->flags |= CP_PROF_NOT_SUGGESTABLE;
+ g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%i", CP_PROFILE_FLAGS, CP_PROFILE_TYPE_LONG, profile->flags);
+ g_string_append( attributes, attrib );
+ acount++;
+
/* send the profile update to MXit */
mxit_send_extprofile_update( session, session->encpwd, acount, attributes->str );
g_string_free( attributes, TRUE );
@@ -209,7 +246,6 @@ static void mxit_cb_action_profile( Purp
struct MXitProfile* profile = session->profile;
PurpleRequestFields* fields = NULL;
- PurpleRequestFieldGroup* group = NULL;
PurpleRequestField* field = NULL;
purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_action_profile\n" );
@@ -222,66 +258,93 @@ static void mxit_cb_action_profile( Purp
}
fields = purple_request_fields_new();
- group = purple_request_field_group_new( NULL );
- purple_request_fields_add_group( fields, group );
-#if 0
- /* UID (read-only) */
- if ( session->uid ) {
- field = purple_request_field_string_new( "mxitid", _( "Your UID" ), session->uid, FALSE );
- purple_request_field_string_set_editable( field, FALSE );
- purple_request_field_group_add_field( group, field );
+ /* Security information - PIN, etc */
+ {
+ PurpleRequestFieldGroup* security_group = purple_request_field_group_new( "PIN" );
+
+ /* pin */
+ field = purple_request_field_string_new( "pin", _( "PIN" ), session->acc->password, FALSE );
+ purple_request_field_string_set_masked( field, TRUE );
+ purple_request_field_group_add_field( security_group, field );
+
+ field = purple_request_field_string_new( "pin2", _( "Verify PIN" ), session->acc->password, FALSE );
+ purple_request_field_string_set_masked( field, TRUE );
+ purple_request_field_group_add_field( security_group, field );
+
+ purple_request_fields_add_group( fields, security_group );
}
-#endif
- /* pin */
- field = purple_request_field_string_new( "pin", _( "PIN" ), session->acc->password, FALSE );
- purple_request_field_string_set_masked( field, TRUE );
- purple_request_field_group_add_field( group, field );
- field = purple_request_field_string_new( "pin2", _( "Verify PIN" ), session->acc->password, FALSE );
- purple_request_field_string_set_masked( field, TRUE );
- purple_request_field_group_add_field( group, field );
+ /* Public information - what other users can see */
+ {
+ PurpleRequestFieldGroup* public_group = purple_request_field_group_new( "Public information" );
- /* display name */
- field = purple_request_field_string_new( "name", _( "Display Name" ), profile->nickname, FALSE );
- purple_request_field_group_add_field( group, field );
+ /* display name */
+ field = purple_request_field_string_new( "name", _( "Display Name" ), profile->nickname, FALSE );
+ purple_request_field_group_add_field( public_group, field );
- /* birthday */
- field = purple_request_field_string_new( "bday", _( "Birthday" ), profile->birthday, FALSE );
- purple_request_field_group_add_field( group, field );
- if ( profile->flags & CP_PROF_DOBLOCKED )
- purple_request_field_string_set_editable( field, FALSE );
+ /* birthday */
+ field = purple_request_field_string_new( "bday", _( "Birthday" ), profile->birthday, FALSE );
+ purple_request_field_group_add_field( public_group, field );
+ if ( profile->flags & CP_PROF_DOBLOCKED )
+ purple_request_field_string_set_editable( field, FALSE );
- /* gender */
- field = purple_request_field_choice_new( "male", _( "Gender" ), ( profile->male ) ? 1 : 0 );
- purple_request_field_choice_add( field, _( "Female" ) ); /* 0 */
- purple_request_field_choice_add( field, _( "Male" ) ); /* 1 */
- purple_request_field_group_add_field( group, field );
+ /* gender */
+ field = purple_request_field_choice_new( "male", _( "Gender" ), ( profile->male ) ? 1 : 0 );
+ purple_request_field_choice_add( field, _( "Female" ) ); /* 0 */
+ purple_request_field_choice_add( field, _( "Male" ) ); /* 1 */
+ purple_request_field_group_add_field( public_group, field );
- /* hidden */
- field = purple_request_field_bool_new( "hidden", _( "Hide my number" ), profile->hidden );
- purple_request_field_group_add_field( group, field );
+ /* first name */
+ field = purple_request_field_string_new( "firstname", _( "First Name" ), profile->firstname, FALSE );
+ purple_request_field_group_add_field( public_group, field );
- /* title */
- field = purple_request_field_string_new( "title", _( "Title" ), profile->title, FALSE );
- purple_request_field_group_add_field( group, field );
+ /* last name */
+ field = purple_request_field_string_new( "lastname", _( "Last Name" ), profile->lastname, FALSE );
+ purple_request_field_group_add_field( public_group, field );
- /* first name */
- field = purple_request_field_string_new( "firstname", _( "First Name" ), profile->firstname, FALSE );
- purple_request_field_group_add_field( group, field );
+ /* about me */
+ field = purple_request_field_string_new( "aboutme", _( "About Me" ), profile->aboutme, FALSE);
+ purple_request_field_group_add_field( public_group, field );
- /* last name */
- field = purple_request_field_string_new( "lastname", _( "Last Name" ), profile->lastname, FALSE );
- purple_request_field_group_add_field( group, field );
+ /* where I live */
+ field = purple_request_field_string_new( "whereami", _( "Where I Live" ), profile->whereami, FALSE);
+ purple_request_field_group_add_field( public_group, field );
- /* email */
- field = purple_request_field_string_new( "email", _( "Email" ), profile->email, FALSE );
- purple_request_field_group_add_field( group, field );
+ purple_request_fields_add_group( fields, public_group );
+ }
- /* mobile number */
- field = purple_request_field_string_new( "mobilenumber", _( "Mobile Number" ), profile->mobilenr, FALSE );
- purple_request_field_group_add_field( group, field );
+ /* Private information - what only MXit can see */
+ {
+ PurpleRequestFieldGroup* private_group = purple_request_field_group_new( "Private information" );
+ /* title */
+ field = purple_request_field_string_new( "title", _( "Title" ), profile->title, FALSE );
+ purple_request_field_group_add_field( private_group, field );
+
+ /* email */
+ field = purple_request_field_string_new( "email", _( "Email" ), profile->email, FALSE );
+ purple_request_field_group_add_field( private_group, field );
+
+ /* mobile number */
+ field = purple_request_field_string_new( "mobilenumber", _( "Mobile Number" ), profile->mobilenr, FALSE );
+ purple_request_field_group_add_field( private_group, field );
+
+ /* hidden number */
+ field = purple_request_field_bool_new( "hidden", _( "Hide my number" ), profile->hidden );
+ purple_request_field_group_add_field( private_group, field );
+
+ /* is searchable */
+ field = purple_request_field_bool_new( "searchable", _( "Can be searched" ), ( ( profile->flags & CP_PROF_NOT_SEARCHABLE ) == 0) );
+ purple_request_field_group_add_field( private_group, field );
+
+ /* is suggestable */
+ field = purple_request_field_bool_new( "suggestable", _( "Can be suggested" ), ( ( profile->flags & CP_PROF_NOT_SUGGESTABLE ) == 0 ) );
+ purple_request_field_group_add_field( private_group, field );
+
+ purple_request_fields_add_group( fields, private_group );
+ }
+
/* (reference: "libpurple/request.h") */
purple_request_fields( gc, _( "Profile" ), _( "Update your Profile" ), _( "Here you can update your MXit profile" ), fields, _( "Set" ),
G_CALLBACK( mxit_cb_set_profile ), _( "Cancel" ), NULL, purple_connection_get_account( gc ), NULL, NULL, gc );
@@ -314,7 +377,7 @@ static void mxit_cb_action_about( Purple
{
char version[256];
- g_snprintf( version, sizeof( version ),
+ g_snprintf( version, sizeof( version ),
"MXit Client Protocol v%i.%i\n\n"
"Author:\nPieter Loubser\n\n"
"Contributors:\nAndrew Victor\n\n"
============================================================
--- libpurple/protocols/mxit/mxit.c bfe2251f633169336ff035801c7e1288ed39f861
+++ libpurple/protocols/mxit/mxit.c 4d59ad8656ff2e1afd030e1b36109bee7dee7fbf
@@ -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_STATUS, CP_PROFILE_AVATAR, CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME };
purple_debug_info( MXIT_PLUGIN_ID, "mxit_get_info: '%s'\n", who );
============================================================
--- libpurple/protocols/mxit/profile.c fc9bef9d9f59005ee7fae5b668415ed6c96a8f46
+++ libpurple/protocols/mxit/profile.c 7d2d55260ebeb9ab58fce70d71f682c5a0b9995e
@@ -146,6 +146,11 @@ void mxit_show_profile( struct MXitSessi
purple_notify_user_info_add_pair( info, _( "Last Name" ), profile->lastname );
purple_notify_user_info_add_pair( info, _( "Country" ), profile->regcountry );
+ if ( strlen( profile->aboutme ) > 0 )
+ purple_notify_user_info_add_pair( info, _( "About Me" ), profile->aboutme );
+ if ( strlen( profile->whereami ) > 0 )
+ purple_notify_user_info_add_pair( info, _( "Where I Live" ), profile->whereami );
+
purple_notify_user_info_add_section_break( info );
if ( contact ) {
============================================================
--- libpurple/protocols/mxit/profile.h 983365e386e44a7ee1844ad8566ff8ccb71b535a
+++ libpurple/protocols/mxit/profile.h 7ac0da05f0680992ea0bb21208acfe1f4e8ed33c
@@ -32,21 +32,23 @@ struct MXitProfile {
struct MXitProfile {
/* required */
char loginname[64]; /* name user uses to log into MXit with (aka 'mxitid') */
- char nickname[64]; /* user's own display name (aka 'nickname', aka 'fullname', aka 'alias') in MXit */
+ char nickname[51]; /* user's own display name (aka 'nickname', aka 'fullname', aka 'alias') in MXit */
char birthday[16]; /* user's birthday "YYYY-MM-DD" */
gboolean male; /* true if the user's gender is male (otherwise female) */
char pin[16]; /* user's password */
/* optional */
- char title[32]; /* user's title */
- char firstname[64]; /* user's first name */
- char lastname[64]; /* user's last name (aka 'surname') */
+ char title[21]; /* user's title */
+ char firstname[51]; /* user's first name */
+ char lastname[51]; /* user's last name (aka 'surname') */
char email[64]; /* user's email address */
char mobilenr[21]; /* user's mobile number */
char regcountry[3]; /* user's registered country code */
- gint64 flags; /* user's profile flags */
- gint64 lastonline; /* user's last-online timestamp */
+ char whereami[51]; /* where am I / where I live */
+ char aboutme[513]; /* about me */
+ int flags; /* user's profile flags */
+ gint64 lastonline; /* user's last-online timestamp */
gboolean hidden; /* set if the user's msisdn should remain hidden */
};
============================================================
--- libpurple/protocols/mxit/protocol.c 7fa0f5d313660b490abcc14c675bcd7fe8290da5
+++ libpurple/protocols/mxit/protocol.c 0aa136a229f869fce1827430d0408556dd59c52d
@@ -844,7 +844,7 @@ void mxit_send_extprofile_request( struc
* @param session The MXit session object
* @param password The new password to be used for logging in (optional)
* @param nr_attrib The number of attributes
- * @param attributes String containing the attributes and settings seperated by '0x01'
+ * @param attributes String containing the attribute-name, attribute-type and value (seperated by '\01')
*/
void mxit_send_extprofile_update( struct MXitSession* session, const char* password, unsigned int nr_attrib, const char* attributes )
{
@@ -853,7 +853,7 @@ void mxit_send_extprofile_update( struct
int datalen;
unsigned int i;
- parts = g_strsplit( attributes, "\01", ( MXIT_MAX_ATTRIBS * 3 ) );
+ parts = g_strsplit( attributes, "\01", 1 + ( nr_attrib * 3 ) );
/* convert the packet to a byte stream */
datalen = snprintf( data, sizeof( data ),
@@ -1442,7 +1442,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_FLAGS };
+ CP_PROFILE_MOBILENR, CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME, CP_PROFILE_FLAGS };
purple_account_set_int( session->acc, MXIT_CONFIG_STATE, MXIT_STATE_LOGIN );
@@ -1851,6 +1851,14 @@ static void mxit_parse_cmd_extprofile( s
/* last seen online */
profile->lastonline = strtoll( fvalue, NULL, 10 );
}
+ else if ( strcmp( CP_PROFILE_WHEREAMI, fname ) == 0 ) {
+ /* where am I */
+ g_strlcpy( profile->whereami, fvalue, sizeof( profile->whereami ) );
+ }
+ else if ( strcmp( CP_PROFILE_ABOUTME, fname ) == 0) {
+ /* about me */
+ g_strlcpy( profile->aboutme, fvalue, sizeof( profile->aboutme ) );
+ }
else {
/* invalid profile attribute */
purple_debug_error( MXIT_PLUGIN_ID, "Invalid profile attribute received '%s' \n", fname );
============================================================
--- libpurple/protocols/mxit/protocol.h 3d16d012a2b4a30107ee1723437981f693aebd59
+++ libpurple/protocols/mxit/protocol.h 2eb1d3ce0e2ef0c0c28b55c0ce88e38bd1719634
@@ -110,7 +110,6 @@
/* Client settings */
#define MAX_QUEUE_SIZE ( 1 << 5 ) /* tx queue size (32 packets) */
#define MXIT_POPUP_WIN_NAME "MXit Notification" /* popup window name */
-#define MXIT_MAX_ATTRIBS 10 /* maximum profile attributes supported */
#define MXIT_DEFAULT_LOCALE "en" /* default locale setting */
#define MXIT_DEFAULT_LOC "planetpurple" /* the default location for registration */
@@ -194,14 +193,19 @@
#define CP_PROFILE_REGCOUNTRY "registeredcountry" /* Registered Country Code (UTF8 String) */
#define CP_PROFILE_FLAGS "flags" /* Profile flags (Bitset) */
#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 */
/* extended profile field types */
-#define CP_PROFILE_TYPE_BOOL 0x02 /* boolean profile attribute type */
-#define CP_PROFILE_TYPE_INT 0x05 /* integer profile attribute type */
-#define CP_PROFILE_TYPE_UTF8 0x0A /* UTF8 string profile attribute type */
-#define CP_PROFILE_TYPE_DATE 0x0B /* date-time profile attribute type */
+#define CP_PROFILE_TYPE_BOOL 0x02 /* boolean (0 or 1) */
+#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 */
+#define CP_PROFILE_TYPE_DATE 0x0B /* date-time (ISO 8601 format) */
/* profile flags */
+#define CP_PROF_NOT_SEARCHABLE 0x02 /* user cannot be searched for */
+#define CP_PROF_NOT_SUGGESTABLE 0x08 /* user cannot be suggested as friend */
#define CP_PROF_DOBLOCKED 0x40 /* date-of-birth cannot be changed */
/* suggestion types */
More information about the Commits
mailing list