summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2008-11-08 16:13:00 +0000
committerRichard Hughes <richard@hughsie.com>2008-11-08 16:13:00 +0000
commit7382bcc1686bce63ad3b7a5c3770ebc6c90802fe (patch)
treece87752f68a41d09b3900f3027a78fe9a016a416 /src
parentba8eecf2b454f266561970209eeda9b71fdc33f7 (diff)
trivial: add a resolution parameter to GetHistory rather than just guessing a number on the server
Diffstat (limited to 'src')
-rw-r--r--src/dkp-device.c4
-rw-r--r--src/dkp-device.h1
-rw-r--r--src/dkp-history.c21
-rw-r--r--src/dkp-history.h3
-rw-r--r--src/org.freedesktop.DeviceKit.Power.Device.xml8
5 files changed, 25 insertions, 12 deletions
diff --git a/src/dkp-device.c b/src/dkp-device.c
index 5aafbd2..bd46221 100644
--- a/src/dkp-device.c
+++ b/src/dkp-device.c
@@ -396,7 +396,7 @@ out:
* dkp_device_get_history:
**/
gboolean
-dkp_device_get_history (DkpDevice *device, const gchar *type_string, guint timespan, DBusGMethodInvocation *context)
+dkp_device_get_history (DkpDevice *device, const gchar *type_string, guint timespan, guint resolution, DBusGMethodInvocation *context)
{
GError *error;
EggObjList *array = NULL;
@@ -428,7 +428,7 @@ dkp_device_get_history (DkpDevice *device, const gchar *type_string, guint times
/* something recognised */
if (type != DKP_HISTORY_TYPE_UNKNOWN)
- array = dkp_history_get_data (device->priv->history, type, timespan);
+ array = dkp_history_get_data (device->priv->history, type, timespan, resolution);
/* maybe the device doesn't have any history */
if (array == NULL) {
diff --git a/src/dkp-device.h b/src/dkp-device.h
index d4d1d12..5af4d97 100644
--- a/src/dkp-device.h
+++ b/src/dkp-device.h
@@ -97,6 +97,7 @@ gboolean dkp_device_refresh (DkpDevice *device,
gboolean dkp_device_get_history (DkpDevice *device,
const gchar *type,
guint timespan,
+ guint resolution,
DBusGMethodInvocation *context);
gboolean dkp_device_get_statistics (DkpDevice *device,
const gchar *type,
diff --git a/src/dkp-history.c b/src/dkp-history.c
index 05ffcb8..1e556c7 100644
--- a/src/dkp-history.c
+++ b/src/dkp-history.c
@@ -39,7 +39,6 @@ static void dkp_history_finalize (GObject *object);
#define DKP_HISTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_HISTORY, DkpHistoryPrivate))
#define DKP_HISTORY_SAVE_INTERVAL 5 /* seconds */
-#define DKP_HISTORY_MAX_RESOLUTION 150
struct DkpHistoryPrivate
{
@@ -207,7 +206,6 @@ dkp_history_copy_array_timespan (const EggObjList *array, guint timespan)
guint i;
const DkpHistoryObj *obj;
EggObjList *array_new;
- EggObjList *array_resolution;
guint start;
/* no data */
@@ -227,20 +225,17 @@ dkp_history_copy_array_timespan (const EggObjList *array, guint timespan)
egg_obj_list_add (array_new, (const gpointer) obj);
}
- /* only add a certain number of points */
- array_resolution = dkp_history_array_limit_resolution (array_new, DKP_HISTORY_MAX_RESOLUTION);
- g_object_unref (array_new);
-
- return array_resolution;
+ return array_new;
}
/**
* dkp_history_get_data:
**/
EggObjList *
-dkp_history_get_data (DkpHistory *history, DkpHistoryType type, guint timespan)
+dkp_history_get_data (DkpHistory *history, DkpHistoryType type, guint timespan, guint resolution)
{
EggObjList *array;
+ EggObjList *array_resolution;
const EggObjList *array_data = NULL;
g_return_val_if_fail (DKP_IS_HISTORY (history), NULL);
@@ -261,8 +256,16 @@ dkp_history_get_data (DkpHistory *history, DkpHistoryType type, guint timespan)
if (array_data == NULL)
return NULL;
+ /* only return a certain time */
array = dkp_history_copy_array_timespan (array_data, timespan);
- return array;
+ if (array == NULL)
+ return NULL;
+
+ /* only add a certain number of points */
+ array_resolution = dkp_history_array_limit_resolution (array, resolution);
+ g_object_unref (array);
+
+ return array_resolution;
}
/**
diff --git a/src/dkp-history.h b/src/dkp-history.h
index 9b7ba62..72a9399 100644
--- a/src/dkp-history.h
+++ b/src/dkp-history.h
@@ -64,7 +64,8 @@ GType dkp_history_get_type (void) G_GNUC_CONST;
DkpHistory *dkp_history_new (void);
EggObjList *dkp_history_get_data (DkpHistory *history,
DkpHistoryType type,
- guint timespan);
+ guint timespan,
+ guint resolution);
EggObjList *dkp_history_get_profile_data (DkpHistory *history,
gboolean charging);
gboolean dkp_history_set_id (DkpHistory *history,
diff --git a/src/org.freedesktop.DeviceKit.Power.Device.xml b/src/org.freedesktop.DeviceKit.Power.Device.xml
index a2d2c16..8148665 100644
--- a/src/org.freedesktop.DeviceKit.Power.Device.xml
+++ b/src/org.freedesktop.DeviceKit.Power.Device.xml
@@ -58,6 +58,14 @@
<arg name="timespan" direction="in" type="u">
<doc:doc><doc:summary>The amount of data to return in seconds, or 0 for all.</doc:summary></doc:doc>
</arg>
+ <arg name="resolution" direction="in" type="u">
+ <doc:doc>
+ <doc:summary>
+ The approximate number of points to return.
+ A higher resolution is more accurate, at the expense of plotting speed.
+ </doc:summary>
+ </doc:doc>
+ </arg>
<arg name="data" direction="out" type="a(uds)">
<doc:doc><doc:summary>
The history data for the power device, if the device supports history.