soc.2009.telepathy: 152b882d: Allow sending to chatrooms
sttwister at soc.pidgin.im
sttwister at soc.pidgin.im
Thu Jul 9 14:00:37 EDT 2009
-----------------------------------------------------------------
Revision: 152b882dcc9934f5d1510598433dd8b04e8666d3
Ancestor: c0029c6f3c8cf6f9878e69aa91c76dca6b5a621d
Author: sttwister at soc.pidgin.im
Date: 2009-07-09T13:46:43
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/152b882dcc9934f5d1510598433dd8b04e8666d3
Modified files:
libpurple/protocols/telepathy/telepathy.c
libpurple/protocols/telepathy/telepathy_channel_text.c
libpurple/protocols/telepathy/telepathy_channel_text.h
ChangeLog:
Allow sending to chatrooms
-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c b656e33b1b8c71302d3ad5224538ab11cadede77
+++ libpurple/protocols/telepathy/telepathy.c 746ea1b9fb4496d958b873a6ce52236c227fa2a7
@@ -576,6 +576,50 @@ telepathy_join_chat (PurpleConnection *g
map, ensure_channel_cb, data, NULL, NULL);
}
+static int
+telepathy_chat_send (PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags)
+{
+ telepathy_connection *data = purple_connection_get_protocol_data(gc);
+
+ telepathy_room_channel *tp_channel = g_hash_table_lookup(
+ data->room_Channels, (gpointer)(TpHandle)id);
+
+ TpChannel *channel;
+
+ char *stripped_message;
+
+ if (tp_channel == NULL)
+ {
+ purple_debug_error("telepathy", "No telepathy_room_channel struct cached"
+ " for %d\n", id);
+ return 0;
+ }
+
+ channel = tp_channel->channel;
+
+ if (channel == NULL)
+ {
+ purple_debug_error("telepathy", "No TpChannel proxy cached for %d\n", id);
+ return 0;
+ }
+
+ /* strip HTML */
+ stripped_message = purple_markup_strip_html(message);
+
+ purple_debug_info("telepathy", "Sending \"%s\" (stripped: \"%s\") to %s\n",
+ message, stripped_message, tp_channel_get_identifier(channel));
+
+ tp_cli_channel_type_text_call_send(channel, -1,
+ TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, stripped_message,
+ chat_send_cb, data, NULL, NULL);
+
+ g_free(stripped_message);
+
+ serv_got_chat_in(gc, id, purple_account_get_username(data->acct), flags,
+ message, time(NULL));
+ return 1;
+}
+
static void
telepathy_set_buddy_icon (PurpleConnection *gc, PurpleStoredImage *img)
{
@@ -665,7 +709,7 @@ static PurplePluginProtocolInfo telepath
NULL, /* chat_invite */
NULL, /* chat_leave */
NULL, /* chat_whisper */
- NULL, /* chat_send */
+ telepathy_chat_send, /* chat_send */
NULL, /* keepalive */
NULL, /* register_user */
NULL, /* get_cb_info */
============================================================
--- libpurple/protocols/telepathy/telepathy_channel_text.c d1c55dc11097918d08eb08f5d2781d351d39d2b4
+++ libpurple/protocols/telepathy/telepathy_channel_text.c 3e02a9b2a18630f78858627c999314beb38fea8c
@@ -277,7 +277,7 @@ chat_send_error_cb (TpChannel *proxy,
purple_debug_error("telepathy", "SendError: %s\n", error_reason);
}
-static void
+void
chat_send_cb (TpChannel *proxy,
const GError *error,
gpointer user_data,
@@ -333,7 +333,8 @@ handle_room_text_channel (TpChannel *cha
*/
if (tp_channel == NULL)
{
- purple_debug_info("telepathy", "Saving TpChannel proxy for \"%s\" chatroom\n", who);
+ purple_debug_info("telepathy", "Saving TpChannel proxy for \"%s\" chatroom (%u)\n",
+ who, handle);
tp_channel = g_new0(telepathy_room_channel, 1);
g_hash_table_insert(data->room_Channels, (gpointer)handle, tp_channel);
============================================================
--- libpurple/protocols/telepathy/telepathy_channel_text.h 23b174dc2096870f8197fcd37cd129f869956170
+++ libpurple/protocols/telepathy/telepathy_channel_text.h 54c0597dc6a238cd1e1dc39aeb2ae5a811a28ef0
@@ -52,6 +52,12 @@ void
destroy_text_channel(telepathy_text_channel *tp_channel);
void
+chat_send_cb (TpChannel *proxy,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object);
+
+void
write_message_to_conversation (const gchar *from,
guint timestamp,
const gchar *msg,
More information about the Commits
mailing list