cpw.gillux.detachablepurple: 0a195618: Changed a bit the way D-Bus path names a...
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Sat May 12 16:56:34 EDT 2012
----------------------------------------------------------------------
Revision: 0a19561803f0e8e752e0bd2483e6c0bf5fbe8560
Parent: 07f0e0ec1ed2da362be7357f264ff57bcd6203f0
Author: gillux at soc.pidgin.im
Date: 05/12/12 15:06:43
Branch: im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/0a19561803f0e8e752e0bd2483e6c0bf5fbe8560
Changelog:
Changed a bit the way D-Bus path names are created.
We now use a generic builder function pointer that should only be set
if the caller will be able to garantee that the built name is unique.
That is, only either by the daemon, or if it's a well-known name,
by both dameon and clients. Also updated PurpleAccount's D-Bus code
accordingly.
Changes against parent 07f0e0ec1ed2da362be7357f264ff57bcd6203f0
patched libpurple/dbus/account.c
patched libpurple/pobject.c
patched libpurple/pobject.h
-------------- next part --------------
============================================================
--- libpurple/pobject.c ad7cfee7e7f9d42ed8f80d50321cfc1522171afe
+++ libpurple/pobject.c f1a8ae4bbe481db28ab2daaabc1a15ec020fc67b
@@ -357,9 +357,15 @@ purple_object_get_dbus_path(PurpleObject
purple_object_get_dbus_path(PurpleObject *pobj)
{
PurpleObjectPrivate *priv;
+ PurpleObjectClass *pclass;
g_return_val_if_fail(pobj, NULL);
priv = PURPLE_OBJECT_GET_PRIVATE(pobj);
+ pclass = PURPLE_OBJECT_GET_CLASS(pobj);
+ if (!priv->dbus_path && pclass->build_dbus_path(pobj)) {
+ /* Let's try to build it. */
+ priv->dbus_path = pclass->build_dbus_path(pobj);
+ }
return priv->dbus_path;
}
@@ -370,6 +376,8 @@ purple_object_set_dbus_path(PurpleObject
g_return_if_fail(pobj);
priv = PURPLE_OBJECT_GET_PRIVATE(pobj);
+ if (priv->dbus_path)
+ g_free(priv->dbus_path);
priv->dbus_path = g_strdup(path);
}
============================================================
--- libpurple/pobject.h 5c7421881f7042fdbaca50ff27ccc43642053e9a
+++ libpurple/pobject.h db2fc77c9104e0024011a7242c64ebe97d26b21e
@@ -59,7 +59,11 @@ struct _PurpleObjectClass
GData *dbus_callbacks;
/* The C structure based representation of the XML DBus interface. */
GDBusInterfaceInfo *dbus_ifaceinfo;
- void (*_purple_reserved[1])(void);
+ /* Build a unique dbus path name for the object. Only the deamon can
+ garantee the uniqueness of a name, thus this function should only
+ be set in daemon mode, or possibly in client mode for well-known
+ names. */
+ char* (*build_dbus_path)(PurpleObject *object);
#else
void (*_purple_reserved[4])(void);
#endif
============================================================
--- libpurple/dbus/account.c 0be4ad0224369872ba2209f06fdf16142336f63b
+++ libpurple/dbus/account.c 4396fba10b79ffbacbdcac11afcd85b9dbec3f62
@@ -142,11 +142,17 @@ static char*
}
static char*
-purple_account_build_dbus_path(const char *username, const char *protocol_id)
+purple_account_build_dbus_path(PurpleObject *object)
{
+ PurpleAccount *account;
+ const char *username, *protocol_id;
gchar *id;
gchar *id2;
+ account = PURPLE_ACCOUNT(object);
+ username = purple_account_get_username(account);
+ protocol_id = purple_account_get_protocol_id(account);
+
id = g_strjoin("/", protocol_id, username, NULL);
id2 = purple_dbus_sanitize_dbus_path(id);
g_free(id);
@@ -161,8 +167,10 @@ purple_account_class_dbus_init(PurpleAcc
purple_account_class_dbus_init(PurpleAccountClass *klass)
{
PurpleObjectClass *pobjclass = PURPLE_OBJECT_CLASS(klass);
+
+ pobjclass->dbus_ifaceinfo = &purple_account_interface_info;
if (purple_core_is_daemon_mode()) {
- pobjclass->dbus_ifaceinfo = &purple_account_interface_info;
+ pobjclass->build_dbus_path = purple_account_build_dbus_path;
purple_object_bind_dbus_callback(pobjclass, "Connect",
(GCallback)purple_account_connect);
purple_object_bind_dbus_callback(pobjclass, "Disconnect",
@@ -215,15 +223,10 @@ void
}
void
-purple_account_dbus_init(PurpleAccount *account, const char *username, const char *protocol_id)
+purple_account_dbus_init(PurpleAccount *account)
{
- char* dbus_path;
DBusGProxy* proxy;
- dbus_path = purple_account_build_dbus_path(username, protocol_id);
- purple_object_set_dbus_path(PURPLE_OBJECT(account), dbus_path);
- g_free(dbus_path);
-
purple_dbus_connect_object(account);
purple_object_dbus_bind_notify(PURPLE_OBJECT(account));
More information about the Commits
mailing list