# HG changeset patch # User andrew.victor@mxit.com # Date 1279528785 0 # Node ID 08d9cdac2b3c5963b8d512dd53e0ab8fb825da13 # Parent 8816f2c9ae43d4966ed5ce0971bde1fc889a9596 A few changes to the Profile. For the user's profile we now also request the 'flags' attribute. The DoB-Locked flag indicates if the user is allowed to change their date-of-birth. If it it locked, make the DoB field read-only. For your buddies profile, request the 'lastseen' attribute. For offline contacts we now show on the profile page when last they were online. diff -r 8816f2c9ae43 -r 08d9cdac2b3c libpurple/protocols/mxit/actions.c --- a/libpurple/protocols/mxit/actions.c Fri Jul 16 12:15:28 2010 +0000 +++ b/libpurple/protocols/mxit/actions.c Mon Jul 19 08:39:45 2010 +0000 @@ -113,26 +113,26 @@ /* update name */ g_strlcpy( profile->nickname, name, sizeof( profile->nickname ) ); - g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FULLNAME, CP_PROF_TYPE_UTF8, profile->nickname ); + g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FULLNAME, CP_PROFILE_TYPE_UTF8, profile->nickname ); g_string_append( attributes, attrib ); acount++; /* update hidden */ field = purple_request_fields_get_field( fields, "hidden" ); profile->hidden = purple_request_field_bool_get_value( field ); - g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_HIDENUMBER, CP_PROF_TYPE_BOOL, ( profile->hidden ) ? "1" : "0" ); + g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_HIDENUMBER, CP_PROFILE_TYPE_BOOL, ( profile->hidden ) ? "1" : "0" ); g_string_append( attributes, attrib ); acount++; /* update birthday */ strcpy( profile->birthday, bday ); - g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_BIRTHDATE, CP_PROF_TYPE_UTF8, profile->birthday ); + g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_BIRTHDATE, CP_PROFILE_TYPE_UTF8, profile->birthday ); g_string_append( attributes, attrib ); acount++; /* update gender */ profile->male = ( purple_request_fields_get_choice( fields, "male" ) != 0 ); - g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_GENDER, CP_PROF_TYPE_BOOL, ( profile->male ) ? "1" : "0" ); + g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_GENDER, CP_PROFILE_TYPE_BOOL, ( profile->male ) ? "1" : "0" ); g_string_append( attributes, attrib ); acount++; @@ -142,7 +142,7 @@ profile->title[0] = '\0'; else strcpy( profile->title, name ); - g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_TITLE, CP_PROF_TYPE_UTF8, profile->title ); + g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_TITLE, CP_PROFILE_TYPE_UTF8, profile->title ); g_string_append( attributes, attrib ); acount++; @@ -152,7 +152,7 @@ profile->firstname[0] = '\0'; else strcpy( profile->firstname, name ); - g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FIRSTNAME, CP_PROF_TYPE_UTF8, profile->firstname ); + g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FIRSTNAME, CP_PROFILE_TYPE_UTF8, profile->firstname ); g_string_append( attributes, attrib ); acount++; @@ -162,7 +162,7 @@ profile->lastname[0] = '\0'; else strcpy( profile->lastname, name ); - g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_LASTNAME, CP_PROF_TYPE_UTF8, profile->lastname ); + g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_LASTNAME, CP_PROFILE_TYPE_UTF8, profile->lastname ); g_string_append( attributes, attrib ); acount++; @@ -172,7 +172,7 @@ profile->email[0] = '\0'; else strcpy( profile->email, name ); - g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_EMAIL, CP_PROF_TYPE_UTF8, profile->email ); + g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_EMAIL, CP_PROFILE_TYPE_UTF8, profile->email ); g_string_append( attributes, attrib ); acount++; @@ -182,7 +182,7 @@ profile->mobilenr[0] = '\0'; else strcpy( profile->mobilenr, name ); - g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_MOBILENR, CP_PROF_TYPE_UTF8, profile->mobilenr ); + g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_MOBILENR, CP_PROFILE_TYPE_UTF8, profile->mobilenr ); g_string_append( attributes, attrib ); acount++; @@ -249,6 +249,8 @@ /* 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 ); /* gender */ field = purple_request_field_choice_new( "male", _( "Gender" ), ( profile->male ) ? 1 : 0 ); diff -r 8816f2c9ae43 -r 08d9cdac2b3c libpurple/protocols/mxit/mxit.c --- a/libpurple/protocols/mxit/mxit.c Fri Jul 16 12:15:28 2010 +0000 +++ b/libpurple/protocols/mxit/mxit.c Mon Jul 19 08:39:45 2010 +0000 @@ -559,7 +559,8 @@ { 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_FIRSTNAME, CP_PROFILE_LASTNAME, CP_PROFILE_REGCOUNTRY, CP_PROFILE_LASTSEEN, + CP_PROFILE_STATUS, CP_PROFILE_AVATAR }; purple_debug_info( MXIT_PLUGIN_ID, "mxit_get_info: '%s'\n", who ); @@ -583,6 +584,29 @@ return table; } + +/*------------------------------------------------------------------------ + * Buddy list menu. + * + * @param node The entry in the buddy list. + */ +static GList* mxit_blist_menu( PurpleBlistNode *node ) +{ + PurpleBuddy* buddy; + struct contact* contact; + GList* m = NULL; + + if ( !PURPLE_BLIST_NODE_IS_BUDDY( node ) ) + return NULL; + + buddy = (PurpleBuddy *) node; + contact = purple_buddy_get_protocol_data( buddy ); + if ( !contact ) + return NULL; + + return m; +} + /*========================================================================================================================*/ static PurplePluginProtocolInfo proto_info = { @@ -602,7 +626,7 @@ mxit_status_text, /* status_text */ mxit_tooltip, /* tooltip_text */ mxit_status_types, /* status types [roster.c] */ - NULL, /* blist_node_menu */ + mxit_blist_menu, /* blist_node_menu */ mxit_chat_info, /* chat_info [multimx.c] */ NULL, /* chat_info_defaults */ mxit_login, /* login [login.c] */ diff -r 8816f2c9ae43 -r 08d9cdac2b3c libpurple/protocols/mxit/profile.c --- a/libpurple/protocols/mxit/profile.c Fri Jul 16 12:15:28 2010 +0000 +++ b/libpurple/protocols/mxit/profile.c Mon Jul 19 08:39:45 2010 +0000 @@ -101,6 +101,23 @@ /*------------------------------------------------------------------------ + * Returns timestamp field in date & time format (DD-MM-YYYY HH:MM:SS) + * + * @param msecs The timestamps (milliseconds since epoch) + * @return Date & Time in a display'able format. + */ +static const char* datetime( int64_t msecs ) +{ + time_t secs = msecs / 1000; + + struct tm t; + localtime_r( &secs, &t ); + + return purple_utf8_strftime( "%d-%m-%Y %H:%M:%S", &t ); +} + + +/*------------------------------------------------------------------------ * Display the profile information. * * @param session The MXit session object @@ -138,6 +155,10 @@ /* presence */ purple_notify_user_info_add_pair( info, _( "Status" ), mxit_convert_presence_to_name( contact->presence ) ); + /* last online */ + if ( contact->presence == MXIT_PRESENCE_OFFLINE ) + purple_notify_user_info_add_pair( info, _( "Last Online" ), ( profile->lastonline == 0 ) ? _( "Unknown" ) : datetime( profile->lastonline ) ); + /* mood */ if ( contact->mood != MXIT_MOOD_NONE ) purple_notify_user_info_add_pair( info, _( "Mood" ), mxit_convert_mood_to_name( contact->mood ) ); diff -r 8816f2c9ae43 -r 08d9cdac2b3c libpurple/protocols/mxit/profile.h --- a/libpurple/protocols/mxit/profile.h Fri Jul 16 12:15:28 2010 +0000 +++ b/libpurple/protocols/mxit/profile.h Mon Jul 19 08:39:45 2010 +0000 @@ -44,6 +44,8 @@ char email[64]; /* user's email address */ char mobilenr[21]; /* user's mobile number */ char regcountry[3]; /* user's registered country code */ + int64_t flags; /* user's profile flags */ + int64_t lastonline; /* user's last-online timestamp */ gboolean hidden; /* set if the user's msisdn should remain hidden */ }; diff -r 8816f2c9ae43 -r 08d9cdac2b3c libpurple/protocols/mxit/protocol.c --- a/libpurple/protocols/mxit/protocol.c Fri Jul 16 12:15:28 2010 +0000 +++ b/libpurple/protocols/mxit/protocol.c Mon Jul 19 08:39:45 2010 +0000 @@ -1284,7 +1284,7 @@ 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_MOBILENR, CP_PROFILE_FLAGS }; purple_account_set_int( session->acc, MXIT_CONFIG_STATE, MXIT_STATE_LOGIN ); @@ -1670,6 +1670,14 @@ /* registered country */ g_strlcpy( profile->regcountry, fvalue, sizeof( profile->regcountry ) ); } + else if ( strcmp( CP_PROFILE_FLAGS, fname ) == 0 ) { + /* profile flags */ + profile->flags = strtoll( fvalue, NULL, 10 ); + } + else if ( strcmp( CP_PROFILE_LASTSEEN, fname ) == 0 ) { + /* last seen online */ + profile->lastonline = strtoll( fvalue, NULL, 10 ); + } else { /* invalid profile attribute */ purple_debug_error( MXIT_PLUGIN_ID, "Invalid profile attribute received '%s' \n", fname ); diff -r 8816f2c9ae43 -r 08d9cdac2b3c libpurple/protocols/mxit/protocol.h --- a/libpurple/protocols/mxit/protocol.h Fri Jul 16 12:15:28 2010 +0000 +++ b/libpurple/protocols/mxit/protocol.h Mon Jul 19 08:39:45 2010 +0000 @@ -190,13 +190,17 @@ #define CP_PROFILE_EMAIL "email" /* Email address (UTF8 String) */ #define CP_PROFILE_MOBILENR "mobilenumber" /* Mobile Number (UTF8 String) */ #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 */ /* extended profile field types */ -#define CP_PROF_TYPE_BOOL 0x02 /* boolean profile attribute type */ -#define CP_PROF_TYPE_INT 0x05 /* integer profile attribute type */ -#define CP_PROF_TYPE_UTF8 0x0A /* UTF8 string profile attribute type */ -#define CP_PROF_TYPE_DATE 0x0B /* date-time profile attribute type */ +#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 */ +/* profile flags */ +#define CP_PROF_DOBLOCKED 0x40 /* date-of-birth cannot be changed */ /* define this to enable protocol debugging (very verbose logging) */ #define DEBUG_PROTOCOL