gnome-power-manager r3330 - in trunk: . libdevkit-power



Author: rhughes
Date: Thu Mar  5 14:56:46 2009
New Revision: 3330
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=3330&view=rev

Log:
2009-03-05  Richard Hughes  <richard hughsie com>

* libdevkit-power/dkp-device.c: (dkp_device_get_history):
Fix the battery history when using a new DeviceKit-power.


Modified:
   trunk/ChangeLog
   trunk/libdevkit-power/dkp-device.c

Modified: trunk/libdevkit-power/dkp-device.c
==============================================================================
--- trunk/libdevkit-power/dkp-device.c	(original)
+++ trunk/libdevkit-power/dkp-device.c	Thu Mar  5 14:56:46 2009
@@ -273,7 +273,8 @@
 dkp_device_get_history (const DkpDevice *device, const gchar *type, guint timespec, guint resolution)
 {
 	GError *error = NULL;
-	GType g_type_gvalue_array;
+	GType g_type_gvalue_array_old;
+	GType g_type_gvalue_array_new;
 	GPtrArray *gvalue_ptr_array = NULL;
 	GValueArray *gva;
 	GValue *gv;
@@ -285,12 +286,18 @@
 	g_return_val_if_fail (DKP_IS_DEVICE (device), NULL);
 	g_return_val_if_fail (device->priv->proxy_device != NULL, NULL);
 
-	g_type_gvalue_array = dbus_g_type_get_collection ("GPtrArray",
+	g_type_gvalue_array_old = dbus_g_type_get_collection ("GPtrArray",
 					dbus_g_type_get_struct("GValueArray",
 						G_TYPE_UINT,
 						G_TYPE_DOUBLE,
 						G_TYPE_STRING,
 						G_TYPE_INVALID));
+	g_type_gvalue_array_new = dbus_g_type_get_collection ("GPtrArray",
+					dbus_g_type_get_struct("GValueArray",
+						G_TYPE_UINT,
+						G_TYPE_DOUBLE,
+						G_TYPE_UINT,
+						G_TYPE_INVALID));
 
 	/* get compound data */
 	ret = dbus_g_proxy_call (device->priv->proxy_device, "GetHistory", &error,
@@ -298,8 +305,23 @@
 				 G_TYPE_UINT, timespec,
 				 G_TYPE_UINT, resolution,
 				 G_TYPE_INVALID,
-				 g_type_gvalue_array, &gvalue_ptr_array,
+				 g_type_gvalue_array_new, &gvalue_ptr_array,
 				 G_TYPE_INVALID);
+
+	/* this failed, try with the old daemon */
+	if (!ret && error->code == 16) {
+		egg_warning ("falling back to old daemon type");
+		g_clear_error (&error);
+		ret = dbus_g_proxy_call (device->priv->proxy_device, "GetHistory", &error,
+					 G_TYPE_STRING, type,
+					 G_TYPE_UINT, timespec,
+					 G_TYPE_UINT, resolution,
+					 G_TYPE_INVALID,
+					 g_type_gvalue_array_old, &gvalue_ptr_array,
+					 G_TYPE_INVALID);
+	}
+
+	/* we failed */
 	if (!ret) {
 		egg_debug ("GetHistory(%s,%i) on %s failed: %s", type, timespec,
 			   device->priv->object_path, error->message);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]