soc.2009.telepathy: 5bdf03b3: Include a message when making an invitat...

sttwister at soc.pidgin.im sttwister at soc.pidgin.im
Tue Jul 14 17:35:22 EDT 2009


-----------------------------------------------------------------
Revision: 5bdf03b3bf73f48c3caaf85774829fa5192d7b6b
Ancestor: 1e9623ac58cee465d2f4353c09e9a554e198831b
Author: sttwister at soc.pidgin.im
Date: 2009-07-14T21:33:10
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/5bdf03b3bf73f48c3caaf85774829fa5192d7b6b

Modified files:
        libpurple/protocols/telepathy/telepathy.c
        libpurple/protocols/telepathy/telepathy_channel_text.h

ChangeLog: 

Include a message when making an invitation

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c	2076c9a37d300a5b18bcd7ed373130da3f5414a1
+++ libpurple/protocols/telepathy/telepathy.c	230b03cb2f465888bb27b32651ad1052215a45d5
@@ -586,27 +586,34 @@ invite_contact_to_chatroom_cb (TpConnect
                                gpointer user_data,
                                GObject *weak_object)
 {
-	telepathy_room_channel *tp_channel = user_data;
+	telepathy_chat_invitation *invitation = user_data;
+	telepathy_room_channel *tp_channel = invitation->tp_channel;
 	GArray *arr;
 
 	if (error != NULL)
 	{
 		purple_debug_error("telepathy", "Error while requesting handle for inviting"
 				" contact to chatroom: %s\n", error->message);
+		g_free(invitation->msg);
 		return;
 	}
 
 	arr = g_array_new(0, 0, sizeof(TpHandle));
 
+	/* Send the invitation by calling AddMembers with the handle. If the contact
+	 * accepts it, he will just join the chat, nothing more we need to do.
+	 */
 	g_array_append_val(arr, handles[0]);
 
 	tp_cli_channel_interface_group_call_add_members(tp_channel->channel, -1,
-			arr, NULL,
+			arr, invitation->msg,
 			NULL, NULL,
 			NULL, NULL);
 
 	g_array_free(arr, TRUE);
 
+	g_free(invitation->msg);
+
 }
 
 static void
@@ -619,19 +626,25 @@ telepathy_chat_invite (PurpleConnection 
 
 	gchar const *ids[] = { who, NULL };
 
+	telepathy_chat_invitation *invitation;
+
 	if (tp_channel == NULL)
 	{
 		purple_debug_error("telepathy", "No telepathy_room_channel struct cached"
 				" for %d\n", id);
 		return;
 	}
-
+	
 	purple_debug_info("telepathy", "Inviting %s to chatroom\n", who);
 
+	invitation = g_new(telepathy_chat_invitation, 1);
+	invitation->tp_channel = tp_channel;
+	invitation->msg = g_strdup(message);
+
+	/* Request a handle that will be passed to AddMembers for this group */
 	tp_connection_request_handles(data->connection, -1,
 			TP_HANDLE_TYPE_CONTACT, ids,
-			invite_contact_to_chatroom_cb, tp_channel,
-			NULL, NULL);
+			invite_contact_to_chatroom_cb, invitation, g_free, NULL);
 }
 
 static void
============================================================
--- libpurple/protocols/telepathy/telepathy_channel_text.h	f7fb17d3825bb6e3fb9fdd753f8ffe78b2282b9e
+++ libpurple/protocols/telepathy/telepathy_channel_text.h	7e8a8c93605497685bd8b7e913ceb0eddbaa1124
@@ -42,6 +42,13 @@ typedef struct
 
 typedef struct
 {
+	telepathy_room_channel *tp_channel;
+	gchar *msg;
+
+} telepathy_chat_invitation;
+
+typedef struct
+{
 	GList *pending_Messages;
 	TpChannel *channel;
 


More information about the Commits mailing list