gnome-power-manager r3082 - in trunk: . libdevkit-power src
- From: rhughes svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-power-manager r3082 - in trunk: . libdevkit-power src
- Date: Sat, 8 Nov 2008 16:33:43 +0000 (UTC)
Author: rhughes
Date: Sat Nov 8 16:33:43 2008
New Revision: 3082
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=3082&view=rev
Log:
2008-11-08 Richard Hughes <richard hughsie com>
* libdevkit-power/dkp-client-device.c:
(dkp_client_device_print_history), (dkp_client_device_get_history),
(dkp_client_device_get_statistics):
* libdevkit-power/dkp-client-device.h:
* libdevkit-power/dkp-object.c: (dkp_object_clear_internal),
(dkp_object_collect_props), (dkp_object_copy), (dkp_object_equal),
(dkp_object_print), (dkp_object_diff), (dkp_object_get_id):
* libdevkit-power/dkp-object.h:
* src/gpm-statistics.c: (gpm_update_info_page_history):
Update to the latest DeviceKit-power client library.
Modified:
trunk/ChangeLog
trunk/libdevkit-power/dkp-client-device.c
trunk/libdevkit-power/dkp-client-device.h
trunk/libdevkit-power/dkp-object.c
trunk/libdevkit-power/dkp-object.h
trunk/src/gpm-backlight.c
trunk/src/gpm-statistics.c
Modified: trunk/libdevkit-power/dkp-client-device.c
==============================================================================
--- trunk/libdevkit-power/dkp-client-device.c (original)
+++ trunk/libdevkit-power/dkp-client-device.c Sat Nov 8 16:33:43 2008
@@ -206,7 +206,7 @@
gboolean ret = FALSE;
/* get a fair chunk of data */
- array = dkp_client_device_get_history (device, type, 120);
+ array = dkp_client_device_get_history (device, type, 120, 10);
if (array == NULL)
goto out;
@@ -270,7 +270,7 @@
* Returns an array of %DkpHistoryObj's
**/
EggObjList *
-dkp_client_device_get_history (const DkpClientDevice *device, const gchar *type, guint timespec)
+dkp_client_device_get_history (const DkpClientDevice *device, const gchar *type, guint timespec, guint resolution)
{
GError *error = NULL;
GType g_type_gvalue_array;
@@ -283,6 +283,7 @@
gboolean ret;
g_return_val_if_fail (DKP_IS_CLIENT_DEVICE (device), FALSE);
+ g_return_val_if_fail (device->priv->proxy_device != NULL, FALSE);
g_type_gvalue_array = dbus_g_type_get_collection ("GPtrArray",
dbus_g_type_get_struct("GValueArray",
@@ -295,6 +296,7 @@
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, &gvalue_ptr_array,
G_TYPE_INVALID);
@@ -359,6 +361,7 @@
gboolean ret;
g_return_val_if_fail (DKP_IS_CLIENT_DEVICE (device), FALSE);
+ g_return_val_if_fail (device->priv->proxy_device != NULL, FALSE);
g_type_gvalue_array = dbus_g_type_get_collection ("GPtrArray",
dbus_g_type_get_struct("GValueArray",
Modified: trunk/libdevkit-power/dkp-client-device.h
==============================================================================
--- trunk/libdevkit-power/dkp-client-device.h (original)
+++ trunk/libdevkit-power/dkp-client-device.h Sat Nov 8 16:33:43 2008
@@ -65,7 +65,8 @@
gboolean dkp_client_device_refresh (DkpClientDevice *device);
EggObjList *dkp_client_device_get_history (const DkpClientDevice *device,
const gchar *type,
- guint timespec);
+ guint timespec,
+ guint resolution);
EggObjList *dkp_client_device_get_statistics (const DkpClientDevice *device,
const gchar *type);
Modified: trunk/libdevkit-power/dkp-object.c
==============================================================================
--- trunk/libdevkit-power/dkp-object.c (original)
+++ trunk/libdevkit-power/dkp-object.c Sat Nov 8 16:33:43 2008
@@ -36,14 +36,15 @@
{
obj->type = DKP_DEVICE_TYPE_UNKNOWN;
obj->update_time = 0;
- obj->energy = -1;
- obj->energy_full = -1;
- obj->energy_full_design = -1;
- obj->energy_rate = -1;
- obj->percentage = -1;
- obj->capacity = -1;
- obj->time_to_empty = -1;
- obj->time_to_full = -1;
+ obj->energy = 0;
+ obj->energy_full = 0;
+ obj->energy_full_design = 0;
+ obj->energy_rate = 0;
+ obj->voltage = 0;
+ obj->percentage = 0;
+ obj->capacity = 0;
+ obj->time_to_empty = 0;
+ obj->time_to_full = 0;
obj->state = DKP_DEVICE_STATE_UNKNOWN;
obj->technology = DKP_DEVICE_TECHNOLGY_UNKNOWN;
obj->vendor = NULL;
@@ -94,6 +95,8 @@
obj->energy_full_design = g_value_get_double (value);
else if (egg_strequal (key, "energy-rate"))
obj->energy_rate = g_value_get_double (value);
+ else if (egg_strequal (key, "voltage"))
+ obj->voltage = g_value_get_double (value);
else if (egg_strequal (key, "time-to-full"))
obj->time_to_full = g_value_get_int64 (value);
else if (egg_strequal (key, "time-to-empty"))
@@ -144,6 +147,7 @@
obj->energy_full = cobj->energy_full;
obj->energy_full_design = cobj->energy_full_design;
obj->energy_rate = cobj->energy_rate;
+ obj->voltage = cobj->voltage;
obj->percentage = cobj->percentage;
obj->capacity = cobj->capacity;
obj->time_to_empty = cobj->time_to_empty;
@@ -175,6 +179,7 @@
obj1->energy == obj2->energy &&
obj1->energy_full == obj2->energy_full &&
obj1->energy_full_design == obj2->energy_full_design &&
+ obj1->voltage == obj2->voltage &&
obj1->energy_rate == obj2->energy_rate &&
obj1->percentage == obj2->percentage &&
obj1->has_history == obj2->has_history &&
@@ -279,6 +284,10 @@
if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
obj->type == DKP_DEVICE_TYPE_MONITOR)
g_print (" energy-rate: %g W\n", obj->energy_rate);
+ if (obj->type == DKP_DEVICE_TYPE_UPS ||
+ obj->type == DKP_DEVICE_TYPE_BATTERY ||
+ obj->type == DKP_DEVICE_TYPE_MONITOR)
+ g_print (" voltage: %g V\n", obj->voltage);
if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
obj->type == DKP_DEVICE_TYPE_UPS) {
if (obj->time_to_full >= 0) {
@@ -376,6 +385,12 @@
if (old->energy_rate != obj->energy_rate)
g_print (" energy-rate: %g -> %g W\n",
old->energy_rate, obj->energy_rate);
+ if (obj->type == DKP_DEVICE_TYPE_UPS ||
+ obj->type == DKP_DEVICE_TYPE_BATTERY ||
+ obj->type == DKP_DEVICE_TYPE_MONITOR)
+ if (old->voltage != obj->voltage)
+ g_print (" voltage: %g -> %g V\n",
+ old->voltage, obj->voltage);
if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
obj->type == DKP_DEVICE_TYPE_UPS) {
if (old->time_to_full != obj->time_to_full) {
@@ -477,47 +492,52 @@
GString *string;
gchar *id = NULL;
- /* only valid for devices supplying the system */
- if (!obj->power_supply)
- return id;
-
- /* only valid for batteries */
- if (obj->type != DKP_DEVICE_TYPE_BATTERY)
- return id;
-
- /* we don't have an ID if we are not present */
- if (!obj->is_present)
- return id;
-
- string = g_string_new ("");
-
- /* in an ideal world, model-capacity-serial */
- if (obj->model != NULL && strlen (obj->model) > 2) {
- g_string_append (string, obj->model);
- g_string_append_c (string, '-');
- }
- if (obj->energy_full_design > 0) {
- g_string_append_printf (string, "%i", (guint) obj->energy_full_design);
- g_string_append_c (string, '-');
- }
- if (obj->serial != NULL && strlen (obj->serial) > 2) {
- g_string_append (string, obj->serial);
- g_string_append_c (string, '-');
- }
+ /* line power */
+ if (obj->type == DKP_DEVICE_TYPE_LINE_POWER) {
+ goto out;
+
+ /* batteries */
+ } else if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
+ /* we don't have an ID if we are not present */
+ if (!obj->is_present)
+ goto out;
+
+ string = g_string_new ("");
+
+ /* in an ideal world, model-capacity-serial */
+ if (obj->model != NULL && strlen (obj->model) > 2) {
+ g_string_append (string, obj->model);
+ g_string_append_c (string, '-');
+ }
+ if (obj->energy_full_design > 0) {
+ g_string_append_printf (string, "%i", (guint) obj->energy_full_design);
+ g_string_append_c (string, '-');
+ }
+ if (obj->serial != NULL && strlen (obj->serial) > 2) {
+ g_string_append (string, obj->serial);
+ g_string_append_c (string, '-');
+ }
+
+ /* make sure we are sane */
+ if (string->len == 0) {
+ /* just use something generic */
+ g_string_append (string, "generic_id");
+ } else {
+ /* remove trailing '-' */
+ g_string_set_size (string, string->len - 1);
+ }
+
+ /* the id may have invalid chars that need to be replaced */
+ id = g_string_free (string, FALSE);
- /* make sure we are sane */
- if (string->len == 0) {
- /* just use something generic */
- g_string_append (string, "generic_id");
} else {
- /* remove trailing '-' */
- g_string_set_size (string, string->len - 1);
+ /* generic fallback */
+ id = g_strdup_printf ("%s-%s-%s", obj->vendor, obj->model, obj->serial);
}
- /* the id may have invalid chars that need to be replaced */
- id = g_string_free (string, FALSE);
- g_strdelimit (id, "\\\t\"' /", '_');
+ g_strdelimit (id, "\\\t\"?' /", '_');
+out:
return id;
}
Modified: trunk/libdevkit-power/dkp-object.h
==============================================================================
--- trunk/libdevkit-power/dkp-object.h (original)
+++ trunk/libdevkit-power/dkp-object.h Sat Nov 8 16:33:43 2008
@@ -47,6 +47,7 @@
gdouble energy_full; /* Watt Hours */
gdouble energy_full_design; /* Watt Hours */
gdouble energy_rate; /* Watts */
+ gdouble voltage; /* Volts */
gint64 time_to_empty; /* seconds */
gint64 time_to_full; /* seconds */
gdouble percentage; /* percent */
Modified: trunk/src/gpm-backlight.c
==============================================================================
--- trunk/src/gpm-backlight.c (original)
+++ trunk/src/gpm-backlight.c Sat Nov 8 16:33:43 2008
@@ -67,7 +67,7 @@
GpmAcAdapter *ac_adapter;
GpmBrightness *brightness;
GpmButton *button;
- GConfClient *conf;
+ GConfClient *conf;
GpmFeedback *feedback;
GpmControl *control;
GpmDpms *dpms;
Modified: trunk/src/gpm-statistics.c
==============================================================================
--- trunk/src/gpm-statistics.c (original)
+++ trunk/src/gpm-statistics.c Sat Nov 8 16:33:43 2008
@@ -365,7 +365,7 @@
else
gpm_graph_widget_set_type_y (GPM_GRAPH_WIDGET (widget), GPM_GRAPH_WIDGET_TYPE_TIME);
- array = dkp_client_device_get_history (device, history_type, history_time);
+ array = dkp_client_device_get_history (device, history_type, history_time, 150);
if (array == NULL) {
gtk_widget_hide (widget);
goto out;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]