/dev/twasilczyk/imgupload: cb8995eb4a73: Imgupload: hook convers...

Tomasz Wasilczyk twasilczyk at pidgin.im
Mon May 19 05:05:09 EDT 2014


Changeset: cb8995eb4a73fc58b2203a725eef13d999e604af
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-05-19 11:04 +0200
Branch:	 default
URL: https://hg.pidgin.im/dev/twasilczyk/imgupload/rev/cb8995eb4a73

Description:

Imgupload: hook conversations too

diffstat:

 pidgin/plugins/imgupload.c |  44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diffs (68 lines):

diff --git a/pidgin/plugins/imgupload.c b/pidgin/plugins/imgupload.c
--- a/pidgin/plugins/imgupload.c
+++ b/pidgin/plugins/imgupload.c
@@ -48,6 +48,38 @@ imgup_conn_is_hooked(PurpleConnection *g
  ******************************************************************************/
 
 static void
+imgup_conv_init(PurpleConversation *conv)
+{
+	PurpleConnection *gc;
+
+	gc = purple_conversation_get_connection(conv);
+	if (!gc)
+		return;
+	if (!imgup_conn_is_hooked(gc))
+		return;
+
+	purple_conversation_set_features(conv,
+		purple_conversation_get_features(conv) &
+		~PURPLE_CONNECTION_FLAG_NO_IMAGES);
+}
+
+static void
+imgup_conv_uninit(PurpleConversation *conv)
+{
+	PurpleConnection *gc;
+
+	gc = purple_conversation_get_connection(conv);
+	if (!gc)
+		return;
+	if (!imgup_conn_is_hooked(gc))
+		return;
+
+	purple_conversation_set_features(conv,
+		purple_conversation_get_features(conv) |
+		PURPLE_CONNECTION_FLAG_NO_IMAGES);
+}
+
+static void
 imgup_conn_init(PurpleConnection *gc)
 {
 	PurpleConnectionFlags flags;
@@ -86,6 +118,12 @@ imgup_plugin_load(PurplePlugin *plugin)
 		imgup_conn_init(gc);
 	}
 
+	it = purple_conversations_get_all();
+	for (; it; it = g_list_next(it)) {
+		PurpleConversation *conv = it->data;
+		imgup_conv_init(conv);
+	}
+
 	return TRUE;
 }
 
@@ -94,6 +132,12 @@ imgup_plugin_unload(PurplePlugin *plugin
 {
 	GList *it;
 
+	it = purple_conversations_get_all();
+	for (; it; it = g_list_next(it)) {
+		PurpleConversation *conv = it->data;
+		imgup_conv_uninit(conv);
+	}
+
 	it = purple_connections_get_all();
 	for (; it; it = g_list_next(it)) {
 		PurpleConnection *gc = it->data;



More information about the Commits mailing list