soc.2010.detachablepurple: 521fe071: Added wrapping of the PurpleAccountUiOps...
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Thu Jul 29 02:01:51 EDT 2010
----------------------------------------------------------------------
Revision: 521fe0716a490b33dc1297531739c869b18a9cf1
Parent: f479234c8d87be5449e4cc788d696fb329cca3f8
Author: gillux at soc.pidgin.im
Date: 07/28/10 22:50:53
Branch: im.pidgin.soc.2010.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/521fe0716a490b33dc1297531739c869b18a9cf1
Changelog:
Added wrapping of the PurpleAccountUiOps.notify_added callback. When the
daemon triggers this callback, it sends a dbus signal. On the receiption
of this signal, all the clients execute their local notify_added uiop.
Changes against parent f479234c8d87be5449e4cc788d696fb329cca3f8
patched libpurple/account-dbus.c
patched libpurple/dbus-prototypes/account.xml
patched libpurple/marshallers.list
patched purpled/purpled-account.c
-------------- next part --------------
============================================================
--- libpurple/marshallers.list f26599578dcc98d6210da239fffa03e963e84727
+++ libpurple/marshallers.list 86443fec003cf3f07a14b76e9fba8fcd344ec674
@@ -16,3 +16,5 @@ VOID:UINT64,BOXED
VOID:STRING,BOXED
# Marshaller for the RunCallback dbus signal
VOID:UINT64,BOXED
+# Marshaller for the NotifyAdded dbus signal
+VOID:STRING,STRING,STRING,STRING
============================================================
--- libpurple/account-dbus.c f41c2d48c7eab774d490ff6e5108daa9c6dd1563
+++ libpurple/account-dbus.c 8d1bf7ff44269047975f030a7df74210b1dd04cc
@@ -10,7 +10,20 @@
#include "dbus-callback.h"
#include "dbus-constructor-client.h"
#include "dbus-maybe.h"
+#include "marshallers.h"
+/**
+ * Callback, called when we receive a dbus "NotifyAdded" signal.
+ */
+static void
+notify_added_cb(DBusGProxy *proxy, const char *remote_user, const char *id,
+ const char *alias, const char *message, gpointer data)
+{
+ PurpleAccount* account = PURPLE_ACCOUNT(
+ purple_dbus_get_gobject_by_path(dbus_g_proxy_get_path(proxy)));
+ purple_account_notify_added(account, remote_user, id, alias, message);
+}
+
static char*
build_dbus_path(const char *username, const char *protocol_id)
{
@@ -34,18 +47,48 @@ purple_account_class_dbus_init(void)
/* Install method introspection data */
purple_object_type_install_dbus_infos(PURPLE_TYPE_ACCOUNT,
&dbus_glib_DBUS_purple_account_object_info);
+
+ g_signal_new("notify_added",
+ PURPLE_TYPE_ACCOUNT,
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ purple_smarshal_VOID__STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING);
}
+ /* In remote mode we need to register the marshallers
+ * we will use to receive the signals sent by the daemon */
+ else if (purple_core_is_remote_mode()) {
+ /* Marshaller for the NotifyAdded dbus signals */
+ dbus_g_object_register_marshaller(
+ purple_smarshal_VOID__STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+
+ }
}
void
purple_account_dbus_init(PurpleAccount *account, const char *username, const char *protocol_id)
{
char* dbus_path;
+ DBusGProxy* proxy;
dbus_path = build_dbus_path(username, protocol_id);
purple_object_install_dbus_infos(PURPLE_OBJECT(account),
DBUS_ACCOUNT_INTERFACE, dbus_path);
g_free(dbus_path);
+
+ if (purple_core_is_remote_mode() || purple_core_is_mirror_mode()) {
+ /* For clients connect our wrapper sighandlers */
+ proxy = purple_object_get_dbus_obj_proxy(PURPLE_OBJECT(account));
+ dbus_g_proxy_add_signal(proxy, "NotifyAdded", G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(proxy, "NotifyAdded",
+ G_CALLBACK(notify_added_cb),
+ account, NULL);
+ }
}
PurpleAccount*
============================================================
--- libpurple/dbus-prototypes/account.xml 824fc048d086d381fce9722e645c1f811da50b0b
+++ libpurple/dbus-prototypes/account.xml 6211067ecea56e3249ef0c92eb20c3d362e58e03
@@ -27,5 +27,11 @@
<arg type="s" name="property-name" />
<arg type="v" name="property-value" />
</signal>
+ <signal name="NotifyAdded">
+ <arg type="s" name="remote_user" />
+ <arg type="s" name="id" />
+ <arg type="s" name="alias" />
+ <arg type="s" name="message" />
+ </signal>
</interface>
</node>
============================================================
--- purpled/purpled-account.c 4bc8492fb6f45f7da8786ba54c5248ce7db35a8a
+++ purpled/purpled-account.c 482342ff474e799ccfa2e41eb29fc44129cb0448
@@ -23,9 +23,22 @@
#include "account.h"
#include "purpled-account.h"
+/**
+ * PurpleAccountUiOps.notify_added daemon callback.
+ * This sends the NotifyAdded dbus signal.
+ */
+static void
+purpled_account_notify_added(PurpleAccount *account, const char *remote_user,
+ const char *id, const char *alias,
+ const char *message)
+{
+ g_signal_emit_by_name(account, "notify_added",
+ remote_user, id, alias, message);
+}
+
static PurpleAccountUiOps purpled_account_ui_ops =
{
- NULL, /* notify_added */
+ purpled_account_notify_added, /* notify_added */
NULL, /* status_changed */
NULL, /* request_add */
NULL, /* request_authorize */
More information about the Commits
mailing list