cpw.gillux.detachablepurple: 487b38f6: Rewritten the RequestClosed signal loop ...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Fri May 25 15:46:53 EDT 2012


----------------------------------------------------------------------
Revision: 487b38f61bd9dcd0bfc19e9b64eca81f76a327ea
Parent:   33d90c0682a2b9eed811d7ea05923d8fa7f029e2
Author:   gillux at soc.pidgin.im
Date:     05/25/12 15:28:07
Branch:   im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/487b38f61bd9dcd0bfc19e9b64eca81f76a327ea

Changelog: 

Rewritten the RequestClosed signal loop prevention system.
Before we used the mirror mode trick but as we want to get
rid of this hack, here is another solution.

Changes against parent 33d90c0682a2b9eed811d7ea05923d8fa7f029e2

  patched  libpurple/account.c
  patched  libpurple/dbus/account.c
  patched  libpurple/dbus/callback.c

-------------- next part --------------
============================================================
--- libpurple/account.c	02584aa90dda4e19a93526ff8e745b31946f94c4
+++ libpurple/account.c	a57ad6c857eee8bb67e5b59ba5939e04c621c7a1
@@ -1091,8 +1091,6 @@ purple_account_request_close_info(Purple
 		request_id = purple_callback_get_req_id(info->ui_handle);
 		if (request_id)
 			purple_callback_run_request_RPC(request_id, 0);
-		else
-			purple_debug_error("dbus", "Couldn't inform the daemon about the closing of an account request from which the request id is unknown\n");
 	}
 
 	purple_account_request_info_unref(info);
============================================================
--- libpurple/dbus/account.c	082c90678016ed701210660e4c0bc9bb6d509604
+++ libpurple/dbus/account.c	dcf932ca61be7a5916531b52b0fba93d1e3ba2b9
@@ -62,24 +62,6 @@ request_remote_client_deny_cb(void *user
 }
 
 /**
- * A wrapper for purple_account_request_close() used in request_authorize_cb().
- * We need to run this function not in remote mode, otherwise it also runs
- * the dbus method RunRequest(request_id, 0) to inform the daemon we closed
- * this request. It's a non-sense since this we are calling
- * purple_account_request_close() because we received a RequestClosed dbus
- * signal, which means the request is already handled.
- */
-static void
-purple_account_local_request_close(void *ui_handle)
-{
-	PurpleRunningMode mode;
-	mode = purple_core_get_running_mode();
-	purple_core_set_running_mode(PURPLE_RUN_MIRROR_MODE);
-	purple_account_request_close(ui_handle);
-	purple_core_set_running_mode(mode);
-}
-
-/**
  * Callback, called when we receive a dbus "RequestAuthorize" signal.
  */
 static void
@@ -107,7 +89,7 @@ request_authorize_cb(PurpleAccount* acco
 	         * (with the RequestClosed dbus signal), then it will be
 	         * automatically and properly closed */
 	        close_req = g_cclosure_new(
-	                        G_CALLBACK(purple_account_local_request_close),
+	                        G_CALLBACK(purple_account_request_close),
 	                        h, NULL);
 	        g_closure_set_marshal(close_req, purple_nullmarshaller);
 	        purple_callback_register_req_id(request_id, close_req, h);
============================================================
--- libpurple/dbus/callback.c	ae5d7c6e00062f77a1ac25a3e8066d0ba2a2f302
+++ libpurple/dbus/callback.c	8ed8383726cfc5cdab93308448357391a77418fc
@@ -391,6 +391,7 @@ purple_callback_close_client_req(guint r
 	PurpleDBusCallback* handler = purple_dbus_callback_get_instance();
 	PurpleDBusClientPendingRequest *req;
 	void *key = GINT_TO_POINTER(request_id);
+	GClosure *close;
 
 	g_return_if_fail(handler != NULL);
 	g_return_if_fail(handler->client_reqs != NULL);
@@ -400,10 +401,15 @@ purple_callback_close_client_req(guint r
 	if (!req)
 		return;
 
-	g_closure_invoke(req->close, NULL, 0, NULL, NULL);
-
-	/* Forget about this closed pending request */
+	/* We want to run the local closing request function while not
+	 * triggering a "RunRequest" D-Bus signal. So we first drop the request
+	 * so that it will not be able to run it again. Yet, we still need the
+	 * closing callback so we ref it before dropping the request. */
+	close = req->close;
+	g_closure_ref(close);
 	g_hash_table_remove(handler->client_reqs, key);
+	g_closure_invoke(close, NULL, 0, NULL, NULL);
+	g_closure_unref(close);
 }
 
 /**


More information about the Commits mailing list