/dev/twasilczyk/imgupload: c568fcefdb82: Imgupload: hook newly c...

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


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

Description:

Imgupload: hook newly created connections

diffstat:

 libpurple/connection.c     |   3 ++-
 pidgin/plugins/imgupload.c |  22 ++++++++++++++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)

diffs (63 lines):

diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -266,7 +266,8 @@ purple_connection_set_flags(PurpleConnec
 
 	priv->flags = flags;
 
-	g_object_notify_by_pspec(G_OBJECT(gc), properties[PROP_FLAGS]);
+	if (!priv->is_finalizing)
+		g_object_notify_by_pspec(G_OBJECT(gc), properties[PROP_FLAGS]);
 }
 
 void
diff --git a/pidgin/plugins/imgupload.c b/pidgin/plugins/imgupload.c
--- a/pidgin/plugins/imgupload.c
+++ b/pidgin/plugins/imgupload.c
@@ -61,6 +61,8 @@ imgup_conv_init(PurpleConversation *conv
 	purple_conversation_set_features(conv,
 		purple_conversation_get_features(conv) &
 		~PURPLE_CONNECTION_FLAG_NO_IMAGES);
+
+	g_object_set_data(G_OBJECT(conv), "imgupload-set", GINT_TO_POINTER(TRUE));
 }
 
 static void
@@ -69,14 +71,19 @@ imgup_conv_uninit(PurpleConversation *co
 	PurpleConnection *gc;
 
 	gc = purple_conversation_get_connection(conv);
-	if (!gc)
-		return;
-	if (!imgup_conn_is_hooked(gc))
-		return;
+	if (gc) {
+		if (!imgup_conn_is_hooked(gc))
+			return;
+	} else {
+		if (!g_object_get_data(G_OBJECT(conv), "imgupload-set"))
+			return;
+	}
 
 	purple_conversation_set_features(conv,
 		purple_conversation_get_features(conv) |
 		PURPLE_CONNECTION_FLAG_NO_IMAGES);
+
+	g_object_set_data(G_OBJECT(conv), "imgupload-set", NULL);
 }
 
 static void
@@ -124,6 +131,13 @@ imgup_plugin_load(PurplePlugin *plugin)
 		imgup_conv_init(conv);
 	}
 
+	purple_signal_connect(purple_connections_get_handle(),
+		"signed-on", plugin,
+		PURPLE_CALLBACK(imgup_conn_init), NULL);
+	purple_signal_connect(purple_connections_get_handle(),
+		"signing-off", plugin,
+		PURPLE_CALLBACK(imgup_conn_uninit), NULL);
+
 	return TRUE;
 }
 



More information about the Commits mailing list