/pidgin/main: 8feb2763abe9: MXit: Add support for the Relationsh...
Andrew Victor
andrew.victor at mxit.com
Tue Dec 18 08:54:13 EST 2012
Changeset: 8feb2763abe97f3fbc01246222f0676e70767dab
Author: Andrew Victor <andrew.victor at mxit.com>
Date: 2012-12-18 15:53 +0200
Branch: release-2.x.y
URL: http://hg.pidgin.im/pidgin/main/rev/8feb2763abe9
Description:
MXit: Add support for the Relationship Status profile attribute.
diffstat:
ChangeLog | 1 +
libpurple/protocols/mxit/actions.c | 25 +++++++++++++++++++++++++
libpurple/protocols/mxit/mxit.c | 2 +-
libpurple/protocols/mxit/profile.c | 36 ++++++++++++++++++++++++++++++++++++
libpurple/protocols/mxit/profile.h | 14 ++++++++++++++
libpurple/protocols/mxit/protocol.c | 6 +++++-
libpurple/protocols/mxit/protocol.h | 2 ++
7 files changed, 84 insertions(+), 2 deletions(-)
diffs (201 lines):
diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -36,6 +36,7 @@ version 2.10.7:
* Display farewell messages in a different colour to distinguish
them from normal messages.
* Add support for typing notification.
+ * Add support for the Relationship Status profile attribute.
Yahoo!:
* Fix a double-free in profile/picture loading code. (Mihai Serban)
diff --git a/libpurple/protocols/mxit/actions.c b/libpurple/protocols/mxit/actions.c
--- a/libpurple/protocols/mxit/actions.c
+++ b/libpurple/protocols/mxit/actions.c
@@ -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 );
}
diff --git a/libpurple/protocols/mxit/mxit.c b/libpurple/protocols/mxit/mxit.c
--- a/libpurple/protocols/mxit/mxit.c
+++ b/libpurple/protocols/mxit/mxit.c
@@ -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 );
diff --git a/libpurple/protocols/mxit/profile.c b/libpurple/protocols/mxit/profile.c
--- a/libpurple/protocols/mxit/profile.c
+++ b/libpurple/protocols/mxit/profile.c
@@ -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 ) {
diff --git a/libpurple/protocols/mxit/profile.h b/libpurple/protocols/mxit/profile.h
--- a/libpurple/protocols/mxit/profile.h
+++ b/libpurple/protocols/mxit/profile.h
@@ -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 @@ struct MXitProfile {
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 );
diff --git a/libpurple/protocols/mxit/protocol.c b/libpurple/protocols/mxit/protocol.c
--- a/libpurple/protocols/mxit/protocol.c
+++ b/libpurple/protocols/mxit/protocol.c
@@ -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 );
diff --git a/libpurple/protocols/mxit/protocol.h b/libpurple/protocols/mxit/protocol.h
--- a/libpurple/protocols/mxit/protocol.h
+++ b/libpurple/protocols/mxit/protocol.h
@@ -205,9 +205,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