soc.2010.detachablepurple: 23f15b7d: Added a way to remotely set a gobject pr...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Wed Jul 7 01:41:28 EDT 2010


----------------------------------------------------------------------
Revision: 23f15b7ddce26e8eca7918063212903bb72d97de
Parent:   f8011786acd7a3034965089ddd11c8416e0ed6c8
Author:   gillux at soc.pidgin.im
Date:     07/07/10 01:27:35
Branch:   im.pidgin.soc.2010.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/23f15b7ddce26e8eca7918063212903bb72d97de

Changelog: 

Added a way to remotely set a gobject property over dbus, and adapted
purple_set_password() to make it use this new feature.

Changes against parent f8011786acd7a3034965089ddd11c8416e0ed6c8

  patched  libpurple/account.c
  patched  libpurple/dbus-server.c
  patched  libpurple/dbus-server.h

-------------- next part --------------
============================================================
--- libpurple/account.c	e10213966f5607f8def98edc878d7fb05b3b5a87
+++ libpurple/account.c	807e7e17f396f6e1135609c9c2231e5476e6bd76
@@ -611,6 +611,8 @@ static void purple_account_init(GTypeIns
 	priv->system_log = NULL;
 
 	account->perm_deny = PURPLE_PRIVACY_ALLOW_ALL;
+
+	purple_object_set_dbus_obj_interface(PURPLE_OBJECT(account), DBUS_ACCOUNT_INTERFACE);
 }
 
 /* GObject destructor function */
@@ -1433,24 +1435,12 @@ purple_account_set_password(PurpleAccoun
 {
 	PurpleAccountPrivate *priv;
 #ifdef HAVE_DBUS
-	DBusGProxy *proxy;
-	GError *error = NULL;
 	GValue prop = {0, };
 
 	if (purple_core_get_remote_mode()) {
 		g_value_init(&prop, G_TYPE_STRING);
 		g_value_set_string(&prop, password);
-		proxy = purple_object_get_dbus_props_proxy(PURPLE_OBJECT(account));
-		if (!dbus_g_proxy_call(proxy, "Set", &error,
-							/* input parameters */
-							G_TYPE_STRING, DBUS_ACCOUNT_INTERFACE,
-							G_TYPE_STRING, "password",
-							G_TYPE_VALUE, &prop,
-							G_TYPE_INVALID,
-							/* output parameters */
-							G_TYPE_INVALID)) {
-			PURPLE_RPC_FAILED(purple_account_set_password, error);
-		}
+		purple_dbus_remotely_set_obj_prop(PURPLE_OBJECT(account), "password", &prop);
 		g_value_unset(&prop);
 		return;
 	}
============================================================
--- libpurple/dbus-server.c	d350d5f71d70186edfc3745fe403b7d847cdffc8
+++ libpurple/dbus-server.c	ae30eb387736304a08d29bc76f9967cf29b5a279
@@ -413,6 +413,29 @@ error:
 	return NULL;
 }
 
+gboolean
+purple_dbus_remotely_set_obj_prop(PurpleObject* pobj, const char* prop_name,
+				GValue* prop_value)
+{
+	DBusGProxy *proxy;
+	GError *error = NULL;
+
+	proxy = purple_object_get_dbus_props_proxy(pobj);
+	if (!dbus_g_proxy_call(proxy, "Set", &error,
+			/* input parameters */
+			G_TYPE_STRING, purple_object_get_dbus_obj_interface(pobj),
+			G_TYPE_STRING, prop_name,
+			G_TYPE_VALUE,  prop_value,
+			G_TYPE_INVALID,
+			/* output parameters */
+			G_TYPE_INVALID)) {
+		purple_debug_error("dbus", "Failed to remotely set the `%s' property of the dbus object %s: %s", prop_name, purple_object_get_dbus_path(pobj), error->message);
+		return FALSE;
+        } else {
+		return TRUE;
+	}
+}
+
 /**************************************************************/
 /* DBus bindings ...                                          */
 /**************************************************************/
============================================================
--- libpurple/dbus-server.h	b3d30a7bc5ae8a2c2d5e00747d74c0337592bad4
+++ libpurple/dbus-server.h	9be6b34b7edf64e4eb757649473df49b198e83eb
@@ -190,7 +190,20 @@ void purple_dbus_uninit(void);
 void purple_dbus_uninit(void);
 
 /**
+ * A convenience function that remotely sets the given property of
+ * a remote gobject.
+ *
+ * @param pobj The PURPLE_OBJECT(PurpleStuff) object you want to alter.
+ * @param prop_name The property name.
+ * @param prop_value The value you want to set.
+ *
+ * @return TRUE if the property as been succesfully set. FALSE if not, and in
+ * this case an error message have been printed.
+ */
+gboolean purple_dbus_remotely_set_obj_prop(PurpleObject* pobj, const char* prop_name, GValue* prop_value);
 
+/**
+
  Macro #DBUS_EXPORT expands to nothing.  It is used to indicate to the
  dbus-analyze-functions.py script that the given function should be
  available to other applications through DBUS.  If


More information about the Commits mailing list