diff libpurple/protocols/mxit/roster.c @ 31500:80bbed4cb649

* extended the profile information shown for pending invites - avatar image - status message - invite image
author pieter.loubser@mxit.com
date Fri, 01 Apr 2011 13:50:10 +0000
parents aa74632c869d
children 2e4ac25df4ba
line wrap: on
line diff
--- a/libpurple/protocols/mxit/roster.c	Thu Mar 31 20:15:18 2011 +0000
+++ b/libpurple/protocols/mxit/roster.c	Fri Apr 01 13:50:10 2011 +0000
@@ -564,8 +564,8 @@
 		buddy = g_slist_nth_data( list, i );
 
 		if ( !purple_buddy_get_protocol_data( buddy ) ) {
-			const gchar *alias = purple_buddy_get_alias( buddy );
-			const gchar *name = purple_buddy_get_name( buddy );
+			const gchar* alias = purple_buddy_get_alias( buddy );
+			const gchar* name = purple_buddy_get_name( buddy );
 
 			/* this buddy should be removed, because we did not receive him in our roster update from MXit */
 			purple_debug_info( MXIT_PLUGIN_ID, "Removed 'old' buddy from the blist '%s' (%s)\n", alias, name );
@@ -592,9 +592,16 @@
 	/* send a allow subscription packet to MXit */
 	mxit_send_allow_sub( invite->session, invite->contact->username, invite->contact->alias );
 
+	/* remove the invite from our internal invites list */
+	invite->session->invites = g_list_remove( invite->session->invites, invite->contact );
+
 	/* freeup invite object */
 	if ( invite->contact->msg )
 		g_free( invite->contact->msg );
+	if ( invite->contact->statusMsg )
+		g_free( invite->contact->statusMsg );
+	if ( invite->contact->profile )
+		g_free( invite->contact->profile );
 	g_free( invite->contact );
 	g_free( invite );
 }
@@ -614,9 +621,16 @@
 	/* send a deny subscription packet to MXit */
 	mxit_send_deny_sub( invite->session, invite->contact->username );
 
+	/* remove the invite from our internal invites list */
+	invite->session->invites = g_list_remove( invite->session->invites, invite->contact );
+
 	/* freeup invite object */
 	if ( invite->contact->msg )
 		g_free( invite->contact->msg );
+	if ( invite->contact->statusMsg )
+		g_free( invite->contact->statusMsg );
+	if ( invite->contact->profile )
+		g_free( invite->contact->profile );
 	g_free( invite->contact );
 	g_free( invite );
 }
@@ -639,12 +653,42 @@
 	invite->session = session;
 	invite->contact = contact;
 
+	/* add the invite to our internal invites list */
+	invite->session->invites = g_list_append( invite->session->invites, invite->contact );
+
 	/* (reference: "libpurple/account.h") */
 	purple_account_request_authorization( session->acc, contact->username, NULL, contact->alias, contact->msg, FALSE, mxit_cb_buddy_auth, mxit_cb_buddy_deny, invite );
 }
 
 
 /*------------------------------------------------------------------------
+ * Return the contact object for a mxit invite
+ *
+ *  @param session		The MXit session object
+ *  @param username		The username of the contact
+ *  @return				The contact object for the inviting user
+ */
+struct contact* get_mxit_invite_contact( struct MXitSession* session, const char* username )
+{
+	struct contact*		con		= NULL;
+	struct contact*		match	= NULL;
+	int					i;
+
+	/* run through all the invites and try and find the match */
+	for ( i = 0; i < g_list_length( session->invites ); i++ ) {
+		con = g_list_nth_data( session->invites, i );
+		if ( strcmp( con->username, username ) == 0 ) {
+			/* invite found */
+			match = con;
+			break;
+		}
+	}
+
+	return match;
+}
+
+
+/*------------------------------------------------------------------------
  * Return TRUE if this is a MXit Chatroom contact.
  *
  *  @param session		The MXit session object