summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2009-04-22 16:55:24 +0100
committerRichard Hughes <richard@hughsie.com>2009-04-22 16:55:24 +0100
commit67c36ceff0486d473b58b4e02fa89557f5826396 (patch)
tree43e38d43c51eb8124189a72949fa639effdc99a2 /tools
parentc97698adf9919841ead815e4780f9bf1b4aa6de0 (diff)
downloadupower-67c36ceff0486d473b58b4e02fa89557f5826396.tar.gz
Add a has-capability to the org.freedesktop.DeviceKit.Power.Wakeups interface so clients can tell if the wakeups functionality can be supported
Diffstat (limited to 'tools')
-rw-r--r--tools/dkp-tool.c61
1 files changed, 44 insertions, 17 deletions
diff --git a/tools/dkp-tool.c b/tools/dkp-tool.c
index 753354a..15723f0 100644
--- a/tools/dkp-tool.c
+++ b/tools/dkp-tool.c
@@ -120,6 +120,49 @@ dkp_tool_do_monitor (DkpClient *client)
}
/**
+ * dkp_tool_show_wakeups:
+ **/
+static gboolean
+dkp_tool_show_wakeups (void)
+{
+ guint i;
+ gboolean ret;
+ DkpWakeups *wakeups;
+ DkpWakeupsObj *obj;
+ guint total;
+ GPtrArray *array;
+
+ /* create new object */
+ wakeups = dkp_wakeups_new ();
+
+ /* do we have support? */
+ ret = dkp_wakeups_has_capability (wakeups);
+ if (!ret) {
+ g_print ("No wakeup capability\n");
+ goto out;
+ }
+
+ /* get total */
+ total = dkp_wakeups_get_total (wakeups, NULL);
+ g_print ("Total wakeups per minute: %i\n", total);
+
+ /* get data */
+ array = dkp_wakeups_get_data (wakeups, NULL);
+ if (array == NULL)
+ goto out;
+ g_print ("Wakeup sources:\n");
+ for (i=0; i<array->len; i++) {
+ obj = g_ptr_array_index (array, i);
+ dkp_wakeups_obj_print (obj);
+ }
+ g_ptr_array_foreach (array, (GFunc) dkp_wakeups_obj_free, NULL);
+ g_ptr_array_free (array, TRUE);
+out:
+ g_object_unref (wakeups);
+ return ret;
+}
+
+/**
* main:
**/
int
@@ -174,23 +217,7 @@ main (int argc, char **argv)
}
if (opt_wakeups) {
- DkpWakeups *wakeups;
- DkpWakeupsObj *obj;
- guint total;
- GPtrArray *array;
- wakeups = dkp_wakeups_new ();
- total = dkp_wakeups_get_total (wakeups, NULL);
- g_print ("Total wakeups per minute: %i\n", total);
- array = dkp_wakeups_get_data (wakeups, NULL);
- if (array == NULL)
- goto out;
- g_print ("Wakeup sources:\n");
- for (i=0; i<array->len; i++) {
- obj = g_ptr_array_index (array, i);
- dkp_wakeups_obj_print (obj);
- }
- g_ptr_array_foreach (array, (GFunc) dkp_wakeups_obj_free, NULL);
- g_ptr_array_free (array, TRUE);
+ dkp_tool_show_wakeups ();
} else if (opt_enumerate || opt_dump) {
GPtrArray *devices;
devices = dkp_client_enumerate_devices (client, &error);