changeset 32080:08dccf527457

Adding contacts normally and via search-results works slightly differently in MXit. The 'Invite' button on the search-results window pops-up the standard "Add Buddy" window, and so the prpl doesn't know what type of invite to perform. To get around this problem for now, we'll encode this in the search-results userId and the prpl can detect this and perform the right type of invite.
author andrew.victor@mxit.com
date Tue, 03 May 2011 20:29:59 +0000
parents 64da22357346
children 36a569ed9cdb bb4eaf8e70d6
files libpurple/protocols/mxit/profile.c libpurple/protocols/mxit/roster.c
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/mxit/profile.c	Mon May 02 11:00:39 2011 +0000
+++ b/libpurple/protocols/mxit/profile.c	Tue May 03 20:29:59 2011 +0000
@@ -292,9 +292,10 @@
 	while (entries != NULL) {
 		struct MXitProfile* profile	= ( struct MXitProfile *) entries->data;
 		GList*	row;
+		gchar* tmp = purple_base64_encode( (unsigned char *) profile->userid, strlen( profile->userid ) );
 
 		/* column values */
-		row = g_list_append( NULL, g_strdup( profile->userid ) );
+		row = g_list_append( NULL, g_strdup_printf( "#%s", tmp ) );
 		row = g_list_append( row, g_strdup( profile->nickname ) );
 		row = g_list_append( row, g_strdup( profile->male ? "Male" : "Female" ) );
 		row = g_list_append( row, g_strdup_printf( "%i", calculateAge( profile->birthday ) ) );
@@ -302,6 +303,8 @@
 
 		purple_notify_searchresults_row_add( results, row );
 		entries = g_list_next( entries );
+
+		g_free( tmp );
 	}
 
 	/* button */
--- a/libpurple/protocols/mxit/roster.c	Mon May 02 11:00:39 2011 +0000
+++ b/libpurple/protocols/mxit/roster.c	Tue May 03 20:29:59 2011 +0000
@@ -747,7 +747,14 @@
 		 * you accept an invite.  so in that case the user is already
 		 * in our blist and ready to be chatted to.
 		 */
-		mxit_send_invite( session, buddy_name, TRUE, buddy_alias, group_name, message );
+
+		if ( buddy_name[0] == '#' ) {
+			gchar *tmp = (gchar*) purple_base64_decode( buddy_name + 1, NULL );
+			mxit_send_invite( session, tmp, FALSE, buddy_alias, group_name, message );
+			g_free( tmp );
+		}
+		else
+			mxit_send_invite( session, buddy_name, TRUE, buddy_alias, group_name, message );
 	}
 	else {
 		purple_debug_info( MXIT_PLUGIN_ID, "mxit_add_buddy (scenario 2) (list:%i)\n", g_slist_length( list ) );