soc.2009.telepathy: 1e9623ac: Implemented chatroom invitation
sttwister at soc.pidgin.im
sttwister at soc.pidgin.im
Tue Jul 14 17:00:44 EDT 2009
-----------------------------------------------------------------
Revision: 1e9623ac58cee465d2f4353c09e9a554e198831b
Ancestor: dcf7728e1cc271c163831e5dff5b76a3a5b0aaeb
Author: sttwister at soc.pidgin.im
Date: 2009-07-14T20:55:00
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/1e9623ac58cee465d2f4353c09e9a554e198831b
Modified files:
libpurple/protocols/telepathy/telepathy.c
ChangeLog:
Implemented chatroom invitation
-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c bba6d13b052935f13424bbc8bb44d958f2ea2fec
+++ libpurple/protocols/telepathy/telepathy.c 2076c9a37d300a5b18bcd7ed373130da3f5414a1
@@ -577,6 +577,64 @@ static void
}
static void
+invite_contact_to_chatroom_cb (TpConnection *connection,
+ TpHandleType handle_type,
+ guint n_handles,
+ const TpHandle *handles,
+ const gchar * const *ids,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ telepathy_room_channel *tp_channel = user_data;
+ GArray *arr;
+
+ if (error != NULL)
+ {
+ purple_debug_error("telepathy", "Error while requesting handle for inviting"
+ " contact to chatroom: %s\n", error->message);
+ return;
+ }
+
+ arr = g_array_new(0, 0, sizeof(TpHandle));
+
+ g_array_append_val(arr, handles[0]);
+
+ tp_cli_channel_interface_group_call_add_members(tp_channel->channel, -1,
+ arr, NULL,
+ NULL, NULL,
+ NULL, NULL);
+
+ g_array_free(arr, TRUE);
+
+}
+
+static void
+telepathy_chat_invite (PurpleConnection *gc, int id, const char *message, const char *who)
+{
+ telepathy_connection *data = purple_connection_get_protocol_data(gc);
+
+ telepathy_room_channel *tp_channel = g_hash_table_lookup(
+ data->room_Channels, (gpointer)(TpHandle)id);
+
+ gchar const *ids[] = { who, NULL };
+
+ 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);
+
+ tp_connection_request_handles(data->connection, -1,
+ TP_HANDLE_TYPE_CONTACT, ids,
+ invite_contact_to_chatroom_cb, tp_channel,
+ NULL, NULL);
+}
+
+static void
telepathy_chat_leave (PurpleConnection *gc, int id)
{
telepathy_connection *data = purple_connection_get_protocol_data(gc);
@@ -584,6 +642,13 @@ telepathy_chat_leave (PurpleConnection *
telepathy_room_channel *tp_channel = g_hash_table_lookup(
data->room_Channels, (gpointer)(TpHandle)id);
+ if (tp_channel == NULL)
+ {
+ purple_debug_error("telepathy", "No telepathy_room_channel struct cached"
+ " for %d\n", id);
+ return;
+ }
+
tp_cli_channel_call_close(tp_channel->channel, -1, NULL, NULL, NULL, NULL);
}
@@ -717,7 +782,7 @@ static PurplePluginProtocolInfo telepath
telepathy_join_chat, /* join_chat */
NULL, /* reject_chat */
NULL, /* get_chat_name */
- NULL, /* chat_invite */
+ telepathy_chat_invite, /* chat_invite */
telepathy_chat_leave, /* chat_leave */
NULL, /* chat_whisper */
telepathy_chat_send, /* chat_send */
More information about the Commits
mailing list