soc.2010.detachablepurple: 3f28122a: Wrapped purple_account_set_status_list()...
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Wed Jul 28 13:45:58 EDT 2010
----------------------------------------------------------------------
Revision: 3f28122ab72c0abfc900f9db9ec6dc7a95f61c42
Parent: 93fa93324af2ea007fc27631b1c76994ed975b6a
Author: gillux at soc.pidgin.im
Date: 07/23/10 09:53:01
Branch: im.pidgin.soc.2010.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/3f28122ab72c0abfc900f9db9ec6dc7a95f61c42
Changelog:
Wrapped purple_account_set_status_list() for dbus.
Changes against parent 93fa93324af2ea007fc27631b1c76994ed975b6a
patched libpurple/account-dbus.c
patched libpurple/account-dbus.h
patched libpurple/account.c
patched libpurple/dbus-prototypes/account.xml
-------------- next part --------------
============================================================
--- libpurple/account.c 62c655775858ba8e88da28acbf902e724abad66b
+++ libpurple/account.c 47528e5e13598bd9f50b8d603713d0391a8dc305
@@ -1640,6 +1640,10 @@ purple_account_set_status_list(PurpleAcc
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
g_return_if_fail(status_id != NULL);
+ /* Handle remote mode case */
+ if (purple_core_is_remote_mode())
+ return purple_account_set_status_list_RPC(account, status_id, active, attrs);
+
status = purple_account_get_status(account, status_id);
if (status == NULL)
{
============================================================
--- libpurple/account-dbus.c 745ddc86e143928062895589c1929046bc185b06
+++ libpurple/account-dbus.c b3e17ce50a5971eb6c10314192eaf55ac96b8444
@@ -80,3 +80,92 @@ DBUS_purple_account_register(PurpleAccou
purple_account_register(account);
return TRUE;
}
+
+void
+purple_account_set_status_list_RPC(PurpleAccount *account, const char *status_id, gboolean active, GList *attrs)
+{
+ DBusGProxy* proxy;
+ GError *error = NULL;
+ GPtrArray *attrs_array;
+ GValue *attr;
+ GValue *attr_new;
+ gchar* id;
+ GValue *id_val;
+ PurpleStatus *status;
+
+ /* Get the cached status_id of this account */
+ status = purple_account_get_status(account, status_id);
+ g_return_if_fail(status != NULL);
+
+ /* The attrs format is a an alternating string,pointer GList.
+ * The type of the pointer depends on the string.
+ * We convert this to a GPtrArray of GValues.
+ */
+ attrs_array = g_ptr_array_new();
+ while (attrs) {
+ /* Get a copy of the attribute id */
+ id_val = g_new0(GValue, 1);
+ g_value_init(id_val, G_TYPE_STRING);
+ id = attrs->data;
+ g_value_set_string(id_val, id);
+
+ /* Get a copy of the attribute value */
+ attrs = attrs->next;
+ attr = purple_status_get_attr_value(status, attrs->data);
+ if (!attr) {
+ attrs = attrs->next;
+ continue;
+ }
+ attr_new = g_new0(GValue, 1);
+ g_value_copy(attr, attr_new);
+
+ /* Append the attribute id and value */
+ g_ptr_array_add(attrs_array, id_val);
+ g_ptr_array_add(attrs_array, attr_new);
+
+ attrs = attrs->next;
+ }
+
+ /* Execute the remote call */
+ proxy = purple_object_get_dbus_obj_proxy(PURPLE_OBJECT(account));
+ if (!im_pidgin_purple_account_set_status_list(proxy, status_id, active, attrs_array, &error))
+ PURPLE_RPC_FAILED(purple_account_register, error);
+
+ g_ptr_array_foreach(attrs_array, (GFunc)g_free, NULL);
+ g_ptr_array_free(attrs_array, TRUE);
+}
+
+gboolean
+DBUS_purple_account_set_status_list(PurpleAccount *account, char *status_id, gboolean active, GPtrArray *attrs, GError **error)
+{
+ GList *attrs_list = NULL;
+ GValue *val;
+ gpointer pval;
+ int i;
+
+ /* Convert the GPtrArray into an alternating string,pointer GList */
+ for (i = 0; i < attrs->len; i++) {
+ if (i%2) {
+ attrs_list = g_list_append(attrs_list, attrs->pdata[i]);
+ } else {
+ val = attrs->pdata[i];
+ switch (G_VALUE_TYPE(val)) {
+ case G_TYPE_STRING:
+ pval = g_strdup(g_value_get_string(val));
+ break;
+ case G_TYPE_INT:
+ pval = (gpointer)g_value_get_int(val);
+ break;
+ case G_TYPE_BOOLEAN:
+ pval = (gpointer)g_value_get_boolean(val);
+ break;
+ default:
+ pval = NULL;
+ }
+ attrs_list = g_list_append(attrs_list, pval);
+ }
+ }
+
+ purple_account_set_status_list(account, status_id, active, attrs_list);
+ return TRUE;
+}
============================================================
--- libpurple/account-dbus.h 15a6f34c2c44bf008af6e661dc2ab0df1e3e8d20
+++ libpurple/account-dbus.h 36cd1d5aabad98d13551c72745e62496c5d7506c
@@ -26,10 +26,21 @@ gboolean DBUS_purple_account_register(Pu
*/
gboolean DBUS_purple_account_register(PurpleAccount *account, GError** error);
+/**
+ * Client side purple_account_set_status_list() wrapper.
+ */
+void purple_account_set_status_list_RPC(PurpleAccount *account, const char *status_id, gboolean active, GList *attrs);
+
+/**
+ * Server side purple_account_set_status_list() wrapper.
+ */
+gboolean DBUS_purple_account_set_status_list(PurpleAccount *account, char *status_id, gboolean active, GPtrArray* attrs, GError** error);
+
#else /* !HAVE_DBUS */
#define purple_account_new_RPC(username, protocol_id) (NULL)
#define purple_account_connect_RPC(account) ((void)0)
#define purple_account_register_RPC(account) ((void)0)
+#define purple_account_set_status_list_RPC(acc, status, active, attr) ((void)0)
#endif /* HAVE_DBUS */
============================================================
--- libpurple/dbus-prototypes/account.xml 99b3d524faea16d27b83713e510d198e1a5cf390
+++ libpurple/dbus-prototypes/account.xml d8375ed33082a33ea1ccbe044281f73ac9f0463e
@@ -12,6 +12,11 @@
<method name="Connect" />
<method name="Register" />
+ <method name="SetStatusList">
+ <arg type="s" name="status_id" direction="in" />
+ <arg type="b" name="active" direction="in" />
+ <arg type="av" name="attributes" direction="in" />
+ </method>
<signal name="DBusNotify">
<arg type="s" name="property-name" />
More information about the Commits
mailing list