diff options
Diffstat (limited to 'libdevkit-power')
-rw-r--r-- | libdevkit-power/dkp-client-device.c | 3 | ||||
-rw-r--r-- | libdevkit-power/dkp-object.c | 20 | ||||
-rw-r--r-- | libdevkit-power/dkp-object.h | 2 | ||||
-rw-r--r-- | libdevkit-power/dkp-stats-obj.c | 4 | ||||
-rw-r--r-- | libdevkit-power/dkp-stats-obj.h | 2 |
5 files changed, 27 insertions, 4 deletions
diff --git a/libdevkit-power/dkp-client-device.c b/libdevkit-power/dkp-client-device.c index c500c9c..ab0512d 100644 --- a/libdevkit-power/dkp-client-device.c +++ b/libdevkit-power/dkp-client-device.c @@ -387,6 +387,8 @@ dkp_client_device_get_statistics (const DkpClientDevice *device, const gchar *ty array = egg_obj_list_new (); egg_obj_list_set_copy (array, (EggObjListCopyFunc) dkp_stats_obj_copy); egg_obj_list_set_free (array, (EggObjListFreeFunc) dkp_stats_obj_free); + egg_obj_list_set_to_string (array, (EggObjListToStringFunc) dkp_stats_obj_to_string); + egg_obj_list_set_from_string (array, (EggObjListFromStringFunc) dkp_stats_obj_from_string); for (i=0; i<gvalue_ptr_array->len; i++) { gva = (GValueArray *) g_ptr_array_index (gvalue_ptr_array, i); @@ -404,7 +406,6 @@ dkp_client_device_get_statistics (const DkpClientDevice *device, const gchar *ty dkp_stats_obj_free (obj); g_value_array_free (gva); } - out: if (gvalue_ptr_array != NULL) g_ptr_array_free (gvalue_ptr_array, TRUE); diff --git a/libdevkit-power/dkp-object.c b/libdevkit-power/dkp-object.c index 8a85598..6b09a56 100644 --- a/libdevkit-power/dkp-object.c +++ b/libdevkit-power/dkp-object.c @@ -54,6 +54,8 @@ dkp_object_clear_internal (DkpObject *obj) obj->is_present = FALSE; obj->power_supply = FALSE; obj->is_rechargeable = FALSE; + obj->has_history = FALSE; + obj->has_statistics = FALSE; } /** @@ -78,6 +80,10 @@ dkp_object_collect_props (const char *key, const GValue *value, DkpObject *obj) obj->type = dkp_device_type_from_text (g_value_get_string (value)); else if (egg_strequal (key, "online")) obj->online = g_value_get_boolean (value); + else if (egg_strequal (key, "has-history")) + obj->has_history = g_value_get_boolean (value); + else if (egg_strequal (key, "has-statistics")) + obj->has_statistics = g_value_get_boolean (value); else if (egg_strequal (key, "energy")) obj->energy = g_value_get_double (value); else if (egg_strequal (key, "energy-empty")) @@ -152,6 +158,8 @@ dkp_object_copy (const DkpObject *cobj) obj->is_present = cobj->is_present; obj->power_supply = cobj->power_supply; obj->is_rechargeable = cobj->is_rechargeable; + obj->has_history = cobj->has_history; + obj->has_statistics = cobj->has_statistics; return obj; } @@ -169,6 +177,8 @@ dkp_object_equal (const DkpObject *obj1, const DkpObject *obj2) obj1->energy_full_design == obj2->energy_full_design && obj1->energy_rate == obj2->energy_rate && obj1->percentage == obj2->percentage && + obj1->has_history == obj2->has_history && + obj1->has_statistics == obj2->has_statistics && obj1->capacity == obj2->capacity && obj1->time_to_empty == obj2->time_to_empty && obj1->time_to_full == obj2->time_to_full && @@ -243,6 +253,8 @@ dkp_object_print (const DkpObject *obj) g_print (" serial: %s\n", obj->serial); g_print (" power supply: %s\n", dkp_object_bool_to_text (obj->power_supply)); g_print (" updated: %s (%d seconds ago)\n", time_buf, (int) (time (NULL) - obj->update_time)); + g_print (" has history: %s\n", dkp_object_bool_to_text (obj->has_history)); + g_print (" has statistics: %s\n", dkp_object_bool_to_text (obj->has_statistics)); g_print (" %s\n", dkp_device_type_to_text (obj->type)); if (obj->type == DKP_DEVICE_TYPE_BATTERY || @@ -311,6 +323,14 @@ dkp_object_diff (const DkpObject *old, const DkpObject *obj) g_print (" model: %s -> %s\n", old->model, obj->model); if (!egg_strequal (obj->serial, old->serial)) g_print (" serial: %s -> %s\n", old->serial, obj->serial); + if (obj->has_history != old->has_history) + g_print (" has history: %s -> %s\n", + dkp_object_bool_to_text (old->has_history), + dkp_object_bool_to_text (obj->has_history)); + if (obj->has_statistics != old->has_statistics) + g_print (" has statistics: %s -> %s\n", + dkp_object_bool_to_text (old->has_statistics), + dkp_object_bool_to_text (obj->has_statistics)); g_print (" %s\n", dkp_device_type_to_text (obj->type)); if (obj->type == DKP_DEVICE_TYPE_BATTERY || diff --git a/libdevkit-power/dkp-object.h b/libdevkit-power/dkp-object.h index f479ac6..1261e57 100644 --- a/libdevkit-power/dkp-object.h +++ b/libdevkit-power/dkp-object.h @@ -36,6 +36,8 @@ typedef struct { gboolean online; gboolean is_present; gboolean is_rechargeable; + gboolean has_history; + gboolean has_statistics; DkpDeviceType type; DkpDeviceState state; DkpDeviceTechnology technology; diff --git a/libdevkit-power/dkp-stats-obj.c b/libdevkit-power/dkp-stats-obj.c index 9b76a84..dbb3841 100644 --- a/libdevkit-power/dkp-stats-obj.c +++ b/libdevkit-power/dkp-stats-obj.c @@ -68,12 +68,12 @@ dkp_stats_obj_free (DkpStatsObj *obj) * dkp_stats_obj_create: **/ DkpStatsObj * -dkp_stats_obj_create (gdouble value, gdouble state) +dkp_stats_obj_create (gdouble value, gdouble accuracy) { DkpStatsObj *obj; obj = dkp_stats_obj_new (); obj->value = value; - obj->accuracy = state; + obj->accuracy = accuracy; return obj; } diff --git a/libdevkit-power/dkp-stats-obj.h b/libdevkit-power/dkp-stats-obj.h index 42ba951..f29c09a 100644 --- a/libdevkit-power/dkp-stats-obj.h +++ b/libdevkit-power/dkp-stats-obj.h @@ -36,7 +36,7 @@ DkpStatsObj *dkp_stats_obj_new (void); gboolean dkp_stats_obj_free (DkpStatsObj *obj); DkpStatsObj *dkp_stats_obj_copy (const DkpStatsObj *cobj); DkpStatsObj *dkp_stats_obj_create (gdouble value, - gdouble state); + gdouble accuracy); DkpStatsObj *dkp_stats_obj_from_string (const gchar *text); gchar *dkp_stats_obj_to_string (const DkpStatsObj *obj); |