/srv/mercurial-server/detachablepurple: afa1a104b20f: Updated Pu...
Gilles Bedel
gillux at cpw.pidgin.im
Fri Jun 15 22:01:38 EDT 2012
Changeset: afa1a104b20f241fed8b8c974e9254fd58d51d48
Author: Gilles Bedel <gillux at cpw.pidgin.im>
Date: 2012-05-15 03:21 +0000
Branch: cpw.gillux.detachablepurple
URL: http://hg.pidgin.im/srv/mercurial-server/detachablepurple/rev/afa1a104b20f
Description:
Updated PurpleConnection for to the new gdbus-based API.
diffstat:
libpurple/connection.c | 38 +++++++++++++++++++++-----------------
libpurple/dbus/connection.c | 44 +++++++++++++++++++++++---------------------
libpurple/dbus/connection.h | 7 +------
3 files changed, 45 insertions(+), 44 deletions(-)
diffs (181 lines):
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -227,15 +227,13 @@
gc = g_object_new(PURPLE_TYPE_CONNECTION, "account", account, NULL);
PURPLE_DBUS_REGISTER_POINTER(gc, PurpleConnection);
- purple_connection_dbus_init(gc, account, regist, password);
priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
priv->password = g_strdup(password);
- /* In mirror mode we don't want to sign on. */
- if (purple_core_is_mirror_mode())
- return;
+ /* D-Bus-related initialization. */
+ purple_object_dbus_init(gc);
g_signal_emit(G_OBJECT(gc), signals[SIG_SIGNING_ON], 0);
@@ -354,10 +352,11 @@
PurpleConnectionPrivate *priv;
- /* We shouldn't get there in remote mode, connection state should
- * only be set by the prpls. */
- if(purple_core_is_remote_mode())
- g_return_if_reached();
+ /* In remote mode, the only situation where we may set this property
+ * is when the object is initializing. */
+ if (purple_core_is_remote_mode()
+ && purple_object_get_synchronized(PURPLE_OBJECT(gc)))
+ g_return_if_reached();
g_return_if_fail(PURPLE_IS_CONNECTION(gc));
priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
@@ -367,6 +366,9 @@
priv->state = state;
+ /* In remote mode we only need to keep track of the state value. */
+ if (purple_core_is_remote_mode())
+ return;
#if 0
ops = purple_connections_get_ui_ops();
@@ -450,10 +452,11 @@
{
PurpleConnectionPrivate *priv;
- /* We shouldn't get there in remote mode, connection flags should
- * only be set by the prpls. */
- if(purple_core_is_remote_mode())
- g_return_if_reached();
+ /* In remote mode, the only situation where we may set this property
+ * is when the object is initializing. */
+ if (purple_core_is_remote_mode()
+ && purple_object_get_synchronized(PURPLE_OBJECT(gc)))
+ g_return_if_reached();
g_return_if_fail(PURPLE_IS_CONNECTION(gc));
priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
@@ -465,10 +468,11 @@
{
PurpleConnectionPrivate *priv;
- /* We shouldn't get there in remote mode, the account should
- * only be set on the daemon. */
- if(purple_core_is_remote_mode())
- g_return_if_reached();
+ /* In remote mode, the only situation where we may set this property
+ * is when the object is initializing. */
+ if (purple_core_is_remote_mode()
+ && purple_object_get_synchronized(PURPLE_OBJECT(gc)))
+ g_return_if_reached();
g_return_if_fail(account != NULL);
priv = PURPLE_CONNECTION_GET_PRIVATE(gc);
@@ -1092,7 +1096,7 @@
0);
/* Install dbus stuff */
- purple_connection_class_dbus_init();
+ purple_connection_class_dbus_init(klass);
}
/******************************************************************************
diff --git a/libpurple/dbus/connection.c b/libpurple/dbus/connection.c
--- a/libpurple/dbus/connection.c
+++ b/libpurple/dbus/connection.c
@@ -22,16 +22,17 @@
#include "internal.h"
#include "core.h"
#include "dbus/connection.h"
-#include "dbus/connection-client.h"
-#include "dbus/connection-server.h"
+#include "dbus/connection.xml.h"
#include "dbus/constructor.h"
#include "dbus-server.h"
#include "dbus-purple.h"
#include "pobject.h"
static char*
-purple_connection_build_dbus_path(PurpleAccount *account)
+purple_connection_build_dbus_path(PurpleObject *pobject)
{
+ PurpleConnection *gc = PURPLE_CONNECTION(pobject);
+ PurpleAccount *account = purple_connection_get_account(gc);
const char *proto;
const char *username;
gchar *path;
@@ -46,32 +47,33 @@
return path_valid;
}
-void
-purple_connection_class_dbus_init(void)
+static void
+purple_connection_dbus_init(gpointer object)
{
+ PurpleConnection *gc = PURPLE_CONNECTION(object);
+ PurpleObject *pobject = PURPLE_OBJECT(gc);
+
+ /* Publish/listen for the object on the bus. */
+ purple_dbus_connect_object(gc);
+ /* Keep the properties synchronized between client and daemon. */
+ purple_object_dbus_bind_notify(pobject);
+
if (purple_core_is_daemon_mode()) {
- /* Install method introspection data */
- purple_object_type_install_dbus_infos(PURPLE_TYPE_CONNECTION,
- &dbus_glib_DBUS_purple_connection_object_info);
+ /* Tell the clients about this new account. */
+ purple_constructor_announce_pobject_creation(pobject);
}
}
void
-purple_connection_dbus_init(PurpleConnection *gc, PurpleAccount *account, gboolean regist, const char *password)
+purple_connection_class_dbus_init(PurpleConnectionClass *klass)
{
- char* dbus_path;
+ PurpleObjectClass *pobjclass = PURPLE_OBJECT_CLASS(klass);
- dbus_path = purple_connection_build_dbus_path(account);
- purple_object_install_dbus_infos(PURPLE_OBJECT(gc),
- DBUS_CONNECTION_INTERFACE, dbus_path);
- g_free(dbus_path);
-
+ pobjclass->dbus_ifaceinfo = &purple_connection_interface_info;
+ pobjclass->dbus_init = purple_connection_dbus_init;
if (purple_core_is_daemon_mode()) {
- /* Inform the clients we have a new PurpleConnection. */
- g_signal_emit_by_name(
- G_OBJECT(purple_constructor_get_instance()),
- "purple_connection_created",
- purple_object_get_dbus_path(PURPLE_OBJECT(account)),
- regist, password);
+ /* Only the daemon shall build path names,
+ * and may give them to the clients. */
+ pobjclass->build_dbus_path = purple_connection_build_dbus_path;
}
}
diff --git a/libpurple/dbus/connection.h b/libpurple/dbus/connection.h
--- a/libpurple/dbus/connection.h
+++ b/libpurple/dbus/connection.h
@@ -28,12 +28,7 @@
/**
* Initialize the dbus data of the connection class.
*/
-void purple_connection_class_dbus_init(void);
-
-/**
- * Initialize the dbus data of a new connection.
- */
-void purple_connection_dbus_init(PurpleConnection *gc, PurpleAccount *account, gboolean regist, const char *password);
+void purple_connection_class_dbus_init(PurpleConnectionClass *klass);
G_END_DECLS
More information about the Commits
mailing list