pidgin.mxit: 7610ff6a: A few changes to the Profile.
andrew.victor at mxit.com
andrew.victor at mxit.com
Mon Jul 19 05:55:42 EDT 2010
----------------------------------------------------------------------
Revision: 7610ff6a39a92054f6f9d73ecf77ee244d1e41f9
Parent: a0b750ce94176646224e0e91c7f521d1a866f744
Author: andrew.victor at mxit.com
Date: 07/19/10 04:39:45
Branch: im.pidgin.pidgin.mxit
URL: http://d.pidgin.im/viewmtn/revision/info/7610ff6a39a92054f6f9d73ecf77ee244d1e41f9
Changelog:
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.
Changes against parent a0b750ce94176646224e0e91c7f521d1a866f744
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 124224391d5cf7a01ae4abd409022ee8e41e4694
+++ libpurple/protocols/mxit/actions.c e93df55e922389cbd5a9aebb820f3ed45410a6f8
@@ -113,26 +113,26 @@ out:
/* 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 @@ out:
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 @@ out:
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 @@ out:
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 @@ out:
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 @@ out:
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 @@ static void mxit_cb_action_profile( Purp
/* 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 );
============================================================
--- libpurple/protocols/mxit/mxit.c 3b38418b69f625ac76b62d9785a96b82c1b70743
+++ libpurple/protocols/mxit/mxit.c db00bf196734698de66743ba6477d6482a3b4739
@@ -559,7 +559,8 @@ 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_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 @@ static GHashTable* mxit_get_text_table(
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 @@ static PurplePluginProtocolInfo proto_in
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] */
============================================================
--- libpurple/protocols/mxit/profile.c 0bfa75e5781533d06df731d90cfc6c89f51ce60a
+++ libpurple/protocols/mxit/profile.c 57a46991d5f97cb9cfb019378b274f552bcc4682
@@ -101,6 +101,23 @@ gboolean validateDate( const char* bday
/*------------------------------------------------------------------------
+ * 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 @@ void mxit_show_profile( struct MXitSessi
/* 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 ) );
============================================================
--- libpurple/protocols/mxit/profile.h 71f371b77af75f04bb8f29ecc2d95b16e297e129
+++ libpurple/protocols/mxit/profile.h c6c1ab2a4bb1658bffb653259c5b6917e19e9fd9
@@ -44,6 +44,8 @@ struct MXitProfile {
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 */
};
============================================================
--- libpurple/protocols/mxit/protocol.c 5743ef03d27d58e0b74a46e93b287b4f76b2a4f1
+++ libpurple/protocols/mxit/protocol.c 11c23dcf4da9ed943c782ac31e139c3958f1ff4c
@@ -1284,7 +1284,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_MOBILENR, CP_PROFILE_FLAGS };
purple_account_set_int( session->acc, MXIT_CONFIG_STATE, MXIT_STATE_LOGIN );
@@ -1670,6 +1670,14 @@ static void mxit_parse_cmd_extprofile( s
/* 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 );
============================================================
--- libpurple/protocols/mxit/protocol.h c9f8d1f6f7edb363d06d614410ace8c8e255105e
+++ libpurple/protocols/mxit/protocol.h 56f6ec5a9df7dc63f6fec96b7365d88a0323716f
@@ -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
More information about the Commits
mailing list