cpw.gillux.detachablepurple: 944d91bd: Added a PurpleObjectCreated D-Bus signal...
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Mon May 14 23:27:02 EDT 2012
----------------------------------------------------------------------
Revision: 944d91bdb851f8af3885717e43b44c61f94ed47b
Parent: 88769daaa0620a7450b76b7e27dadc5cb085cff4
Author: gillux at soc.pidgin.im
Date: 05/14/12 23:10:57
Branch: im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/944d91bdb851f8af3885717e43b44c61f94ed47b
Changelog:
Added a PurpleObjectCreated D-Bus signal to inform all the clients
about the creation of any PurpleObject on the daemon. This replaces
the old PurpleConnectionCreated D-Bus signal in a more generic way.
Also updated PurpleAccount to make it annouce any new PurpleAccount.
Changes against parent 88769daaa0620a7450b76b7e27dadc5cb085cff4
patched libpurple/dbus/account.c
patched libpurple/dbus/constructor.c
patched libpurple/dbus/constructor.h
patched libpurple/dbus/constructor.xml
-------------- next part --------------
============================================================
--- libpurple/dbus/account.c 00036b22a68b26e91005d5929a2cb31cfce9901f
+++ libpurple/dbus/account.c 0b31e38876073e802e06958d587bf878b393351f
@@ -176,6 +176,8 @@ purple_account_dbus_init(gpointer object
purple_object_dbus_bind_notify(pobject);
if (purple_core_is_daemon_mode()) {
+ /* Tell the clients about this new account. */
+ purple_constructor_announce_pobject_creation(pobject);
} else if (purple_core_is_remote_mode()) {
/* This will add our new account
* in the account list of accountlist.c. */
============================================================
--- libpurple/dbus/constructor.c 494adff3f813b0b9009436838743d74f186f67cf
+++ libpurple/dbus/constructor.c abb5e85566fecd8e643ecac864da048341895ff3
@@ -62,6 +62,7 @@ static GVariant* purple_constructor_get_
G_DEFINE_TYPE(PurpleConstructor, purple_constructor, PURPLE_TYPE_OBJECT)
static GVariant* purple_constructor_get_all_accounts(void);
+static void purple_constructor_pobj_created(PurpleObject *constructor, const char *type, const char *dbus_path, GVariant *props);
static char*
purple_constructor_build_dbus_path(PurpleObject *object)
@@ -69,24 +70,6 @@ purple_constructor_build_dbus_path(Purpl
return g_strdup(DBUS_CONSTRUCTOR_PATH);
}
-/**
- * Callback called when we receive a dbus "PurpleConnectionCreated" signal.
- */
-static void
-purple_connection_created_cb(DBusGProxy *proxy, const char* account, gboolean regist, const char *password, gpointer data)
-{
- GObject *account_obj;
- PurpleRunningMode mode;
-
- account_obj = purple_dbus_get_gobject_by_path(account);
- g_return_if_fail(account_obj != NULL);
-
- mode = purple_core_get_running_mode();
- purple_core_set_running_mode(PURPLE_RUN_MIRROR_MODE);
- purple_connection_new(PURPLE_ACCOUNT(account_obj), regist, password);
- purple_core_set_running_mode(mode);
-}
-
static void purple_constructor_init(PurpleConstructor* obj) {
}
@@ -101,21 +84,11 @@ static void purple_constructor_class_ini
if (purple_core_is_daemon_mode()) {
purple_object_bind_dbus_callback(pobjclass, "GetAllAccounts",
(GCallback)purple_constructor_get_all_accounts);
- /**
- * Add dbus stuff to this gobject.
- */
- g_signal_new("purple_connection_created", PURPLE_TYPE_CONSTRUCTOR,
- G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- purple_smarshal_VOID__STRING_BOOLEAN_STRING,
- G_TYPE_NONE, 3,
- G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING);
}
else if (purple_core_is_remote_mode()) {
- /* Marshaller for the PurpleConnectionCreated dbus signals */
- dbus_g_object_register_marshaller(
- purple_smarshal_VOID__STRING_BOOLEAN_STRING,
- G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN,
- G_TYPE_STRING, G_TYPE_INVALID);
+ /* D-Bus signal handlers. */
+ purple_object_bind_dbus_callback(pobjclass, "PurpleObjectCreated",
+ (GCallback)purple_constructor_pobj_created);
}
}
@@ -349,3 +322,38 @@ purple_accounts_get_all_RPC(void)
{
purple_constructor_load_all_pobj("GetAllAccounts", "PurpleAccount");
}
+
+void
+purple_constructor_announce_pobject_creation(PurpleObject *pobj)
+{
+ PurpleConstructor *con = purple_constructor_get_instance();
+ GVariant *params;
+
+ params = g_variant_new("(so at a(sv))",
+ G_OBJECT_TYPE_NAME(pobj),
+ purple_object_get_dbus_path(pobj),
+ pack_pobject_properties(pobj));
+ purple_object_emit_dbus_signal(PURPLE_OBJECT(con), "PurpleObjectCreated",
+ params, NULL);
+}
+
+/* "PurpleObjectCreated" signal handler. */
+static void
+purple_constructor_pobj_created(PurpleObject *constructor, const gchar *type,
+ const gchar *dbus_path, GVariant *props)
+{
+ gpointer *obj;
+
+ /* If we are the one who created this object, we already have it. */
+ if (purple_dbus_get_gobject_by_path(dbus_path))
+ return;
+
+ obj = purple_constructor_new_proxy_object(type, props);
+ g_variant_unref(props);
+
+ purple_object_set_dbus_path(PURPLE_OBJECT(obj), dbus_path);
+ g_free((gchar*)dbus_path);
+
+ purple_object_dbus_init(obj);
+ purple_object_set_synchronized(PURPLE_OBJECT(obj), TRUE);
+}
============================================================
--- libpurple/dbus/constructor.h d58cfee1624947caa643b1f4436ca0c58996101b
+++ libpurple/dbus/constructor.h ca7b46db648855449c7eb77db758ca0ee202b1e1
@@ -58,6 +58,15 @@ PurpleConstructor* purple_constructor_ge
PurpleConstructor* purple_constructor_get_instance(void);
/**
+ * Sends a "PurpleObjectCreated" D-Bus signal that announce the creation
+ * of the object pobj. The object must be properly initialized, with a
+ * dbus path name set.
+ *
+ * @param pobj The PurpleObject you want to tell the clients about.
+ */
+void purple_constructor_announce_pobject_creation(PurpleObject *pobj);
+
+/**
* What's get actually called when you call NewAccount over dbus.
*/
gboolean DBUS_purple_constructor_new_account(PurpleConstructor *con, gchar* username, gchar* protocol_id, gchar **account_path, GError** error);
============================================================
--- libpurple/dbus/constructor.xml cc0ef12d7ab746dee94647f3630be6b242af8ff5
+++ libpurple/dbus/constructor.xml a11c53991c0d5f02557d6867e866e5b93f6b55cb
@@ -11,10 +11,10 @@
<arg type="a(oa(sv))" name="accounts" direction="out" />
</method>
- <signal name="PurpleConnectionCreated">
- <arg type="o" name="account" />
- <arg type="b" name="regist" />
- <arg type="s" name="password" />
+ <signal name="PurpleObjectCreated">
+ <arg type="s" name="type" />
+ <arg type="o" name="path" />
+ <arg type="a(sv)" name="properties" />
</signal>
</interface>
</node>
More information about the Commits
mailing list