From 41962a4d3081964c28a49199b92967de140116b7 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 4 Feb 2010 18:10:42 -0800 Subject: [PATCH] =?UTF-8?q?finish=20the=20DeviceKit-power=20=E2=86=92=20upower=20transition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide the missing include/code files for libupower-glib instead of using compat #defines (which does not have any effect for linking, i. e. libupower consumers would still need to link to libdevkit-power-gobject). Port the remaining tools and code to use libupower-glib. ATTENTION: This is incomplete and fails to build due to conflicting ../libupower-glib/up-device.h and src/up-device.h! --- devkit-power-gobject/Makefile.am | 8 -- devkit-power-gobject/dkp-enum.h | 44 -------- devkit-power-gobject/dkp-history-obj.h | 9 -- devkit-power-gobject/dkp-stats-obj.h | 4 - devkit-power-gobject/up-client.h | 1 - devkit-power-gobject/up-device.h | 1 - devkit-power-gobject/up-enum.h | 1 - devkit-power-gobject/up-history-obj.h | 1 - devkit-power-gobject/up-qos-obj.h | 1 - devkit-power-gobject/up-stats-obj.h | 1 - devkit-power-gobject/up-wakeups-obj.h | 57 ----------- devkit-power-gobject/up-wakeups.h | 1 - libupower-glib/Makefile.am | 8 ++ libupower-glib/up-history-obj.c | 171 ++++++++++++++++++++++++++++++++ libupower-glib/up-history-obj.h | 55 ++++++++++ libupower-glib/up-qos-obj.c | 105 +++++++++++++++++++ libupower-glib/up-qos-obj.h | 55 ++++++++++ libupower-glib/up-stats-obj.c | 119 ++++++++++++++++++++++ libupower-glib/up-stats-obj.h | 50 +++++++++ libupower-glib/up-wakeups-obj.c | 103 +++++++++++++++++++ libupower-glib/up-wakeups-obj.h | 53 ++++++++++ src/Makefile.am | 9 +- src/dummy/Makefile.am | 2 +- src/freebsd/Makefile.am | 2 +- src/freebsd/up-device-supply.c | 2 +- src/linux/Makefile.am | 2 +- src/linux/up-device-csr.c | 2 +- src/linux/up-device-hid.c | 2 +- src/linux/up-device-supply.c | 4 +- src/linux/up-device-wup.c | 2 +- src/linux/up-input.c | 2 +- src/up-backend.h | 2 +- src/up-daemon.h | 2 +- src/up-device-list.h | 2 +- src/up-device.c | 3 +- src/up-history.h | 2 +- src/up-main.c | 4 +- src/up-qos.c | 22 ++-- tools/Makefile.am | 7 +- tools/up-tool.c | 104 ++++++++++---------- 40 files changed, 808 insertions(+), 217 deletions(-) delete mode 120000 devkit-power-gobject/up-client.h delete mode 120000 devkit-power-gobject/up-device.h delete mode 120000 devkit-power-gobject/up-enum.h delete mode 120000 devkit-power-gobject/up-history-obj.h delete mode 120000 devkit-power-gobject/up-qos-obj.h delete mode 120000 devkit-power-gobject/up-stats-obj.h delete mode 100644 devkit-power-gobject/up-wakeups-obj.h delete mode 120000 devkit-power-gobject/up-wakeups.h create mode 100644 libupower-glib/up-history-obj.c create mode 100644 libupower-glib/up-history-obj.h create mode 100644 libupower-glib/up-qos-obj.c create mode 100644 libupower-glib/up-qos-obj.h create mode 100644 libupower-glib/up-stats-obj.c create mode 100644 libupower-glib/up-stats-obj.h create mode 100644 libupower-glib/up-wakeups-obj.c create mode 100644 libupower-glib/up-wakeups-obj.h diff --git a/devkit-power-gobject/Makefile.am b/devkit-power-gobject/Makefile.am index c21b9a4..53eddc3 100644 --- a/devkit-power-gobject/Makefile.am +++ b/devkit-power-gobject/Makefile.am @@ -65,14 +65,6 @@ libdevkit_power_gobject_la_CFLAGS = \ $(NULL) EXTRA_DIST = \ - up-client.h \ - up-device.h \ - up-enum.h \ - up-history-obj.h \ - up-qos-obj.h \ - up-stats-obj.h \ - up-wakeups-obj.h \ - up-wakeups.h \ dkp-version.h.in CLEANFILES = $(BUILT_SOURCES) diff --git a/devkit-power-gobject/dkp-enum.h b/devkit-power-gobject/dkp-enum.h index 0f370a1..90b70ce 100644 --- a/devkit-power-gobject/dkp-enum.h +++ b/devkit-power-gobject/dkp-enum.h @@ -72,50 +72,6 @@ typedef enum { DKP_QOS_TYPE_LAST } DkpQosType; -/* compat */ -typedef DkpDeviceType UpDeviceKind; -typedef DkpDeviceState UpDeviceState; -typedef DkpDeviceTechnology UpDeviceTechnology; -typedef DkpQosType UpQosType; -#define up_device_kind_to_text dkp_device_type_to_text -#define up_device_state_to_text dkp_device_state_to_text -#define up_device_technology_to_text dkp_device_technology_to_text -#define up_qos_type_to_text dkp_qos_type_to_text -#define up_device_kind_from_text dkp_device_type_from_text -#define up_device_state_from_text dkp_device_state_from_text -#define up_device_technology_from_text dkp_device_technology_from_text -#define up_qos_type_from_text dkp_qos_type_from_text -#define UP_DEVICE_KIND_UNKNOWN DKP_DEVICE_TYPE_UNKNOWN -#define UP_DEVICE_KIND_LINE_POWER DKP_DEVICE_TYPE_LINE_POWER -#define UP_DEVICE_KIND_BATTERY DKP_DEVICE_TYPE_BATTERY -#define UP_DEVICE_KIND_UPS DKP_DEVICE_TYPE_UPS -#define UP_DEVICE_KIND_MONITOR DKP_DEVICE_TYPE_MONITOR -#define UP_DEVICE_KIND_MOUSE DKP_DEVICE_TYPE_MOUSE -#define UP_DEVICE_KIND_KEYBOARD DKP_DEVICE_TYPE_KEYBOARD -#define UP_DEVICE_KIND_PDA DKP_DEVICE_TYPE_PDA -#define UP_DEVICE_KIND_PHONE DKP_DEVICE_TYPE_PHONE -#define UP_DEVICE_KIND_LAST DKP_DEVICE_TYPE_LAST -#define UP_DEVICE_STATE_UNKNOWN DKP_DEVICE_STATE_UNKNOWN -#define UP_DEVICE_STATE_CHARGING DKP_DEVICE_STATE_CHARGING -#define UP_DEVICE_STATE_DISCHARGING DKP_DEVICE_STATE_DISCHARGING -#define UP_DEVICE_STATE_EMPTY DKP_DEVICE_STATE_EMPTY -#define UP_DEVICE_STATE_FULLY_CHARGED DKP_DEVICE_STATE_FULLY_CHARGED -#define UP_DEVICE_STATE_PENDING_CHARGE DKP_DEVICE_STATE_PENDING_CHARGE -#define UP_DEVICE_STATE_PENDING_DISCHARGE DKP_DEVICE_STATE_PENDING_DISCHARGE -#define UP_DEVICE_STATE_LAST DKP_DEVICE_STATE_LAST -#define UP_DEVICE_TECHNOLOGY_UNKNOWN DKP_DEVICE_TECHNOLOGY_UNKNOWN -#define UP_DEVICE_TECHNOLOGY_LITHIUM_ION DKP_DEVICE_TECHNOLOGY_LITHIUM_ION -#define UP_DEVICE_TECHNOLOGY_LITHIUM_POLYMER DKP_DEVICE_TECHNOLOGY_LITHIUM_POLYMER -#define UP_DEVICE_TECHNOLOGY_LITHIUM_IRON_PHOSPHATE DKP_DEVICE_TECHNOLOGY_LITHIUM_IRON_PHOSPHATE -#define UP_DEVICE_TECHNOLOGY_LEAD_ACID DKP_DEVICE_TECHNOLOGY_LEAD_ACID -#define UP_DEVICE_TECHNOLOGY_NICKEL_CADMIUM DKP_DEVICE_TECHNOLOGY_NICKEL_CADMIUM -#define UP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE DKP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE -#define UP_DEVICE_TECHNOLOGY_LAST DKP_DEVICE_TECHNOLOGY_LAST -#define UP_QOS_KIND_UNKNOWN DKP_QOS_TYPE_UNKNOWN -#define UP_QOS_KIND_NETWORK DKP_QOS_TYPE_NETWORK -#define UP_QOS_KIND_CPU_DMA DKP_QOS_TYPE_CPU_DMA -#define UP_QOS_KIND_LAST DKP_QOS_TYPE_LAST - const gchar *dkp_device_type_to_text (DkpDeviceType type_enum); const gchar *dkp_device_state_to_text (DkpDeviceState state_enum); const gchar *dkp_device_technology_to_text (DkpDeviceTechnology technology_enum); diff --git a/devkit-power-gobject/dkp-history-obj.h b/devkit-power-gobject/dkp-history-obj.h index ad7a90f..ff8a8f2 100644 --- a/devkit-power-gobject/dkp-history-obj.h +++ b/devkit-power-gobject/dkp-history-obj.h @@ -37,15 +37,6 @@ typedef struct DkpDeviceState state; } DkpHistoryObj; -/* compat */ -typedef DkpHistoryObj UpHistoryObj; -#define up_history_obj_new dkp_history_obj_new -#define up_history_obj_create dkp_history_obj_create -#define up_history_obj_copy dkp_history_obj_copy -#define up_history_obj_free dkp_history_obj_free -#define up_history_obj_from_string dkp_history_obj_from_string -#define up_history_obj_to_string dkp_history_obj_to_string - DkpHistoryObj *dkp_history_obj_new (void); gboolean dkp_history_obj_clear (DkpHistoryObj *obj); void dkp_history_obj_free (DkpHistoryObj *obj); diff --git a/devkit-power-gobject/dkp-stats-obj.h b/devkit-power-gobject/dkp-stats-obj.h index 9555712..f37d7da 100644 --- a/devkit-power-gobject/dkp-stats-obj.h +++ b/devkit-power-gobject/dkp-stats-obj.h @@ -36,10 +36,6 @@ typedef struct gdouble accuracy; } DkpStatsObj; -typedef DkpStatsObj UpStatsObj; - -#define up_stats_obj_create dkp_stats_obj_create - DkpStatsObj *dkp_stats_obj_new (void); gboolean dkp_stats_obj_free (DkpStatsObj *obj); DkpStatsObj *dkp_stats_obj_copy (const DkpStatsObj *cobj); diff --git a/devkit-power-gobject/up-client.h b/devkit-power-gobject/up-client.h deleted file mode 120000 index 92b51d0..0000000 --- a/devkit-power-gobject/up-client.h +++ /dev/null @@ -1 +0,0 @@ -dkp-client.h \ No newline at end of file diff --git a/devkit-power-gobject/up-device.h b/devkit-power-gobject/up-device.h deleted file mode 120000 index 3234769..0000000 --- a/devkit-power-gobject/up-device.h +++ /dev/null @@ -1 +0,0 @@ -dkp-device.h \ No newline at end of file diff --git a/devkit-power-gobject/up-enum.h b/devkit-power-gobject/up-enum.h deleted file mode 120000 index 7732128..0000000 --- a/devkit-power-gobject/up-enum.h +++ /dev/null @@ -1 +0,0 @@ -dkp-enum.h \ No newline at end of file diff --git a/devkit-power-gobject/up-history-obj.h b/devkit-power-gobject/up-history-obj.h deleted file mode 120000 index b686e24..0000000 --- a/devkit-power-gobject/up-history-obj.h +++ /dev/null @@ -1 +0,0 @@ -dkp-history-obj.h \ No newline at end of file diff --git a/devkit-power-gobject/up-qos-obj.h b/devkit-power-gobject/up-qos-obj.h deleted file mode 120000 index d44eeaf..0000000 --- a/devkit-power-gobject/up-qos-obj.h +++ /dev/null @@ -1 +0,0 @@ -dkp-qos-obj.h \ No newline at end of file diff --git a/devkit-power-gobject/up-stats-obj.h b/devkit-power-gobject/up-stats-obj.h deleted file mode 120000 index 1b8d1fb..0000000 --- a/devkit-power-gobject/up-stats-obj.h +++ /dev/null @@ -1 +0,0 @@ -dkp-stats-obj.h \ No newline at end of file diff --git a/devkit-power-gobject/up-wakeups-obj.h b/devkit-power-gobject/up-wakeups-obj.h deleted file mode 100644 index 0119950..0000000 --- a/devkit-power-gobject/up-wakeups-obj.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2009 Richard Hughes - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#if !defined (__UPOWER_H_INSIDE__) && !defined (UP_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef __DKP_WAKEUPS_OBJ_H__ -#define __DKP_WAKEUPS_OBJ_H__ - -#include -#include - -G_BEGIN_DECLS - -typedef struct -{ - gboolean is_userspace; - guint id; - guint old; - gfloat value; - gchar *cmdline; - gchar *details; -} DkpWakeupsObj; - -typedef DkpWakeupsObj UpWakeupsObj; -#define up_wakeups_obj_free dkp_wakeups_obj_free -#define up_wakeups_obj_new dkp_wakeups_obj_new - -DkpWakeupsObj *dkp_wakeups_obj_new (void); -void dkp_wakeups_obj_free (DkpWakeupsObj *obj); -DkpWakeupsObj *dkp_wakeups_obj_copy (const DkpWakeupsObj *cobj); -gboolean dkp_wakeups_obj_print (const DkpWakeupsObj *obj); -gboolean dkp_wakeups_obj_equal (const DkpWakeupsObj *obj1, - const DkpWakeupsObj *obj2); - -G_END_DECLS - -#endif /* __DKP_WAKEUPS_OBJ_H__ */ - diff --git a/devkit-power-gobject/up-wakeups.h b/devkit-power-gobject/up-wakeups.h deleted file mode 120000 index 66a8fcb..0000000 --- a/devkit-power-gobject/up-wakeups.h +++ /dev/null @@ -1 +0,0 @@ -dkp-wakeups.h \ No newline at end of file diff --git a/libupower-glib/Makefile.am b/libupower-glib/Makefile.am index b1e0890..fab65df 100644 --- a/libupower-glib/Makefile.am +++ b/libupower-glib/Makefile.am @@ -23,18 +23,26 @@ libupower_glib_include_HEADERS = \ up-types.h \ up-device.h \ up-qos-item.h \ + up-qos-obj.h \ up-wakeup-item.h \ + up-wakeups-obj.h \ up-stats-item.h \ + up-stats-obj.h \ up-history-item.h \ + up-history-obj.h \ up-client.h libupower_glib_la_SOURCES = \ up-types.c \ up-client.c \ up-qos-item.c \ + up-qos-obj.c \ up-wakeup-item.c \ + up-wakeups-obj.c \ up-stats-item.c \ + up-stats-obj.c \ up-history-item.c \ + up-history-obj.c \ up-device.c libupower_glib_la_LIBADD = \ diff --git a/libupower-glib/up-history-obj.c b/libupower-glib/up-history-obj.c new file mode 100644 index 0000000..e0067b1 --- /dev/null +++ b/libupower-glib/up-history-obj.c @@ -0,0 +1,171 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2008 Richard Hughes + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include +#include +#include +#include + +#include "up-types.h" +#include "up-history-obj.h" + +/** + * up_history_obj_clear_internal: + **/ +static void +up_history_obj_clear_internal (UpHistoryObj *obj) +{ + obj->time = 0; + obj->value = 0.0f; + obj->state = 0; +} + +/** + * up_history_obj_copy: + **/ +UpHistoryObj * +up_history_obj_copy (const UpHistoryObj *cobj) +{ + UpHistoryObj *obj; + obj = g_new0 (UpHistoryObj, 1); + obj->time = cobj->time; + obj->value = cobj->value; + obj->state = cobj->state; + return obj; +} + +/** + * up_history_obj_equal: + **/ +gboolean +up_history_obj_equal (const UpHistoryObj *obj1, const UpHistoryObj *obj2) +{ + if (obj1->time == obj2->time && + obj1->value == obj2->value && + obj1->state == obj2->state) + return TRUE; + return FALSE; +} + +/** + * up_history_obj_print: + **/ +gboolean +up_history_obj_print (const UpHistoryObj *obj) +{ + g_print ("%i\t%.3f\t%s", obj->time, obj->value, up_device_state_to_string (obj->state)); + return TRUE; +} + +/** + * up_history_obj_new: + **/ +UpHistoryObj * +up_history_obj_new (void) +{ + UpHistoryObj *obj; + obj = g_new0 (UpHistoryObj, 1); + up_history_obj_clear_internal (obj); + return obj; +} + +/** + * up_history_obj_clear: + **/ +gboolean +up_history_obj_clear (UpHistoryObj *obj) +{ + if (obj == NULL) + return FALSE; + up_history_obj_free (obj); + up_history_obj_clear_internal (obj); + return TRUE; +} + +/** + * up_history_obj_free: + **/ +void +up_history_obj_free (UpHistoryObj *obj) +{ + if (obj == NULL) + return; + g_free (obj); +} + +/** + * up_history_obj_create: + **/ +UpHistoryObj * +up_history_obj_create (gdouble value, UpDeviceState state) +{ + UpHistoryObj *obj; + GTimeVal timeval; + + g_get_current_time (&timeval); + obj = up_history_obj_new (); + obj->time = timeval.tv_sec; + obj->value = value; + obj->state = state; + return obj; +} + +/** + * up_history_obj_from_string: + **/ +UpHistoryObj * +up_history_obj_from_string (const gchar *text) +{ + UpHistoryObj *obj = NULL; + gchar **parts = NULL; + guint length; + + if (text == NULL) + goto out; + + /* split by tab */ + parts = g_strsplit (text, "\t", 0); + length = g_strv_length (parts); + if (length != 3) { + g_warning ("invalid string: '%s'", text); + goto out; + } + + /* parse and create */ + obj = up_history_obj_new (); + obj->time = atoi (parts[0]); + obj->value = atof (parts[1]); + obj->state = up_device_state_from_string (parts[2]); +out: + g_strfreev (parts); + return obj; +} + +/** + * up_history_obj_to_string: + **/ +gchar * +up_history_obj_to_string (const UpHistoryObj *obj) +{ + if (obj == NULL) + return NULL; + return g_strdup_printf ("%i\t%.3f\t%s", obj->time, obj->value, up_device_state_to_string (obj->state)); +} + diff --git a/libupower-glib/up-history-obj.h b/libupower-glib/up-history-obj.h new file mode 100644 index 0000000..149c32a --- /dev/null +++ b/libupower-glib/up-history-obj.h @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2008 Richard Hughes + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#if !defined (__UPOWER_H_INSIDE__) && !defined (UP_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __UP_HISTORY_OBJ_H__ +#define __UP_HISTORY_OBJ_H__ + +#include +#include + +G_BEGIN_DECLS + +typedef struct +{ + guint time; + gdouble value; + UpDeviceState state; +} UpHistoryObj; + +UpHistoryObj *up_history_obj_new (void); +gboolean up_history_obj_clear (UpHistoryObj *obj); +void up_history_obj_free (UpHistoryObj *obj); +UpHistoryObj *up_history_obj_copy (const UpHistoryObj *cobj); +gboolean up_history_obj_print (const UpHistoryObj *obj); +UpHistoryObj *up_history_obj_create (gdouble value, + UpDeviceState state); +gboolean up_history_obj_equal (const UpHistoryObj *obj1, + const UpHistoryObj *obj2); +UpHistoryObj *up_history_obj_from_string (const gchar *text); +gchar *up_history_obj_to_string (const UpHistoryObj *obj); + +G_END_DECLS + +#endif /* __UP_HISTORY_OBJ_H__ */ + diff --git a/libupower-glib/up-qos-obj.c b/libupower-glib/up-qos-obj.c new file mode 100644 index 0000000..9c4309a --- /dev/null +++ b/libupower-glib/up-qos-obj.c @@ -0,0 +1,105 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2009 Richard Hughes + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include +#include +#include +#include + +#include "up-types.h" +#include "up-qos-obj.h" + +/** + * up_qos_obj_clear_internal: + **/ +static void +up_qos_obj_clear_internal (UpQosObj *obj) +{ + obj->uid = 0; + obj->pid = 0; + obj->sender = NULL; /* only used in the daemon */ + obj->cmdline = NULL; + obj->cookie = 0; + obj->timespec = 0; + obj->persistent = FALSE; + obj->type = UP_QOS_KIND_UNKNOWN; + obj->value = 0; +} + +/** + * up_qos_obj_copy: + **/ +UpQosObj * +up_qos_obj_copy (const UpQosObj *cobj) +{ + UpQosObj *obj; + obj = g_new0 (UpQosObj, 1); + obj->cookie = cobj->cookie; + return obj; +} + +/** + * up_qos_obj_equal: + **/ +gboolean +up_qos_obj_equal (const UpQosObj *obj1, const UpQosObj *obj2) +{ + if (obj1->cookie == obj2->cookie) + return TRUE; + return FALSE; +} + +/** + * up_qos_obj_print: + **/ +gboolean +up_qos_obj_print (const UpQosObj *obj) +{ + g_print ("cookie:%i\n", obj->cookie); + return TRUE; +} + +/** + * up_qos_obj_new: + **/ +UpQosObj * +up_qos_obj_new (void) +{ + UpQosObj *obj; + obj = g_new0 (UpQosObj, 1); + up_qos_obj_clear_internal (obj); + return obj; +} + +/** + * up_qos_obj_free: + **/ +void +up_qos_obj_free (UpQosObj *obj) +{ + if (obj == NULL) + return; + g_free (obj->cmdline); + g_free (obj->sender); + g_free (obj); + return; +} + + diff --git a/libupower-glib/up-qos-obj.h b/libupower-glib/up-qos-obj.h new file mode 100644 index 0000000..89ad659 --- /dev/null +++ b/libupower-glib/up-qos-obj.h @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2009 Richard Hughes + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#if !defined (__UPOWER_H_INSIDE__) && !defined (UP_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __DKP_QOS_OBJ_H__ +#define __DKP_QOS_OBJ_H__ + +#include +#include + +G_BEGIN_DECLS + +typedef struct +{ + guint uid; + guint pid; + gchar *sender; /* only used in the daemon */ + gchar *cmdline; + guint cookie; + guint64 timespec; + gboolean persistent; + UpQosKind type; + gint value; +} UpQosObj; + +UpQosObj *up_qos_obj_new (void); +void up_qos_obj_free (UpQosObj *obj); +UpQosObj *up_qos_obj_copy (const UpQosObj *cobj); +gboolean up_qos_obj_print (const UpQosObj *obj); +gboolean up_qos_obj_equal (const UpQosObj *obj1, const UpQosObj *obj2); + +G_END_DECLS + +#endif /* __DKP_QOS_OBJ_H__ */ + diff --git a/libupower-glib/up-stats-obj.c b/libupower-glib/up-stats-obj.c new file mode 100644 index 0000000..f236497 --- /dev/null +++ b/libupower-glib/up-stats-obj.c @@ -0,0 +1,119 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2008 Richard Hughes + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include +#include +#include +#include + +#include "up-stats-obj.h" + +/** + * up_stats_obj_copy: + **/ +UpStatsObj * +up_stats_obj_copy (const UpStatsObj *cobj) +{ + UpStatsObj *obj; + obj = g_new0 (UpStatsObj, 1); + obj->value = cobj->value; + obj->accuracy = cobj->accuracy; + return obj; +} + +/** + * up_stats_obj_new: + **/ +UpStatsObj * +up_stats_obj_new (void) +{ + UpStatsObj *obj; + obj = g_new0 (UpStatsObj, 1); + obj->value = 0.0f; + obj->accuracy = 0; + return obj; +} + +/** + * up_stats_obj_free: + **/ +gboolean +up_stats_obj_free (UpStatsObj *obj) +{ + if (obj == NULL) + return FALSE; + g_free (obj); + return TRUE; +} + +/** + * up_stats_obj_create: + **/ +UpStatsObj * +up_stats_obj_create (gdouble value, gdouble accuracy) +{ + UpStatsObj *obj; + obj = up_stats_obj_new (); + obj->value = value; + obj->accuracy = accuracy; + return obj; +} + +/** + * up_stats_obj_from_string: + **/ +UpStatsObj * +up_stats_obj_from_string (const gchar *text) +{ + UpStatsObj *obj = NULL; + gchar **parts = NULL; + guint length; + + if (text == NULL) + goto out; + + /* split by tab */ + parts = g_strsplit (text, "\t", 0); + length = g_strv_length (parts); + if (length != 2) { + g_warning ("invalid string: '%s'", text); + goto out; + } + + /* parse and create */ + obj = up_stats_obj_new (); + obj->value = atoi (parts[0]); + obj->accuracy = atof (parts[1]); +out: + g_strfreev (parts); + return obj; +} + +/** + * up_stats_obj_to_string: + **/ +gchar * +up_stats_obj_to_string (const UpStatsObj *obj) +{ + if (obj == NULL) + return NULL; + return g_strdup_printf ("%.2f\t%.2f", obj->value, obj->accuracy); +} + diff --git a/libupower-glib/up-stats-obj.h b/libupower-glib/up-stats-obj.h new file mode 100644 index 0000000..d04e3ed --- /dev/null +++ b/libupower-glib/up-stats-obj.h @@ -0,0 +1,50 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2008 Richard Hughes + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#if !defined (__UPOWER_H_INSIDE__) && !defined (UP_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __UP_STATS_OBJ_H__ +#define __UP_STATS_OBJ_H__ + +#include +#include + +G_BEGIN_DECLS + +typedef struct +{ + gdouble value; + gdouble accuracy; +} UpStatsObj; + +UpStatsObj *up_stats_obj_new (void); +gboolean up_stats_obj_free (UpStatsObj *obj); +UpStatsObj *up_stats_obj_copy (const UpStatsObj *cobj); +UpStatsObj *up_stats_obj_create (gdouble value, + gdouble accuracy); +UpStatsObj *up_stats_obj_from_string (const gchar *text); +gchar *up_stats_obj_to_string (const UpStatsObj *obj); + +G_END_DECLS + +#endif /* __UP_STATS_OBJ_H__ */ + diff --git a/libupower-glib/up-wakeups-obj.c b/libupower-glib/up-wakeups-obj.c new file mode 100644 index 0000000..f6a5164 --- /dev/null +++ b/libupower-glib/up-wakeups-obj.c @@ -0,0 +1,103 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2009 Richard Hughes + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include +#include +#include +#include + +#include "up-types.h" +#include "up-wakeups-obj.h" + +/** + * up_wakeups_obj_clear_internal: + **/ +static void +up_wakeups_obj_clear_internal (UpWakeupsObj *obj) +{ + obj->id = 0; + obj->old = 0; + obj->value = 0.0f; + obj->is_userspace = FALSE; + obj->cmdline = NULL; + obj->details = NULL; +} + +/** + * up_wakeups_obj_copy: + **/ +UpWakeupsObj * +up_wakeups_obj_copy (const UpWakeupsObj *cobj) +{ + UpWakeupsObj *obj; + obj = g_new0 (UpWakeupsObj, 1); + obj->id = cobj->id; + obj->value = cobj->value; + obj->is_userspace = cobj->is_userspace; + return obj; +} + +/** + * up_wakeups_obj_equal: + **/ +gboolean +up_wakeups_obj_equal (const UpWakeupsObj *obj1, const UpWakeupsObj *obj2) +{ + if (obj1->id == obj2->id) + return TRUE; + return FALSE; +} + +/** + * up_wakeups_obj_print: + **/ +gboolean +up_wakeups_obj_print (const UpWakeupsObj *obj) +{ + g_print ("userspace:%i id:%i, interrupts:%.1f, cmdline:%s, details:%s\n", obj->is_userspace, obj->id, obj->value, obj->cmdline, obj->details); + return TRUE; +} + +/** + * up_wakeups_obj_new: + **/ +UpWakeupsObj * +up_wakeups_obj_new (void) +{ + UpWakeupsObj *obj; + obj = g_new0 (UpWakeupsObj, 1); + up_wakeups_obj_clear_internal (obj); + return obj; +} + +/** + * up_wakeups_obj_free: + **/ +void +up_wakeups_obj_free (UpWakeupsObj *obj) +{ + if (obj == NULL) + return; + g_free (obj->cmdline); + g_free (obj->details); + g_free (obj); + return; +} + diff --git a/libupower-glib/up-wakeups-obj.h b/libupower-glib/up-wakeups-obj.h new file mode 100644 index 0000000..3f2103e --- /dev/null +++ b/libupower-glib/up-wakeups-obj.h @@ -0,0 +1,53 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2009 Richard Hughes + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#if !defined (__UPOWER_H_INSIDE__) && !defined (UP_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __UP_WAKEUPS_OBJ_H__ +#define __UP_WAKEUPS_OBJ_H__ + +#include +#include + +G_BEGIN_DECLS + +typedef struct +{ + gboolean is_userspace; + guint id; + guint old; + gfloat value; + gchar *cmdline; + gchar *details; +} UpWakeupsObj; + +UpWakeupsObj *up_wakeups_obj_new (void); +void up_wakeups_obj_free (UpWakeupsObj *obj); +UpWakeupsObj *up_wakeups_obj_copy (const UpWakeupsObj *cobj); +gboolean up_wakeups_obj_print (const UpWakeupsObj *obj); +gboolean up_wakeups_obj_equal (const UpWakeupsObj *obj1, + const UpWakeupsObj *obj2); + +G_END_DECLS + +#endif /* __UP_WAKEUPS_OBJ_H__ */ + diff --git a/src/Makefile.am b/src/Makefile.am index ea5a8c3..5ae6ca5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,7 +20,6 @@ INCLUDES = \ -DEGG_LOGGING="\"UP_LOGGING\"" \ -DEGG_CONSOLE="\"UP_CONSOLE\"" \ -I$(top_srcdir)/libupower-glib \ - -I$(top_srcdir)/devkit-power-gobject \ -I$(top_srcdir) \ $(GIO_CFLAGS) \ $(DBUS_GLIB_CFLAGS) \ @@ -28,7 +27,7 @@ INCLUDES = \ $(POLKIT_CFLAGS) \ $(GLIB_CFLAGS) -DEVKIT_POWER_LIBS = $(top_builddir)/devkit-power-gobject/libdevkit-power-gobject.la +UPOWER_LIBS = $(top_builddir)/libupower-glib/libupower-glib.la BUILT_SOURCES = \ up-daemon-glue.h \ @@ -107,14 +106,14 @@ endif if BACKEND_TYPE_FREEBSD upowerd_LDADD += \ freebsd/libupshared.la \ - $(DEVKIT_POWER_LIBS) + $(UPOWER_LIBS) endif if BACKEND_TYPE_LINUX upowerd_LDADD += \ linux/libupshared.la \ $(GUDEV_LIBS) \ - $(DEVKIT_POWER_LIBS) + $(UPOWER_LIBS) endif upowerd_CFLAGS = \ @@ -155,7 +154,7 @@ up_self_test_LDADD = \ $(GLIB_LIBS) \ $(GIO_CFLAGS) \ $(SELFTEST_LIBS) \ - $(DEVKIT_POWER_LIBS) \ + $(UPOWER_LIBS) \ $(POLKIT_LIBS) up_self_test_CFLAGS = -DEGG_TEST $(AM_CFLAGS) $(WARNINGFLAGS_C) diff --git a/src/dummy/Makefile.am b/src/dummy/Makefile.am index ef1742b..0541c03 100644 --- a/src/dummy/Makefile.am +++ b/src/dummy/Makefile.am @@ -8,7 +8,7 @@ INCLUDES = \ -DEGG_CONSOLE="\"UP_CONSOLE\"" \ -DUP_COMPILATION \ -DEGG_TEST \ - -I$(top_srcdir)/devkit-power-gobject \ + -I$(top_srcdir)/libupower-glib \ $(DBUS_GLIB_CFLAGS) \ $(POLKIT_CFLAGS) \ $(GLIB_CFLAGS) diff --git a/src/freebsd/Makefile.am b/src/freebsd/Makefile.am index 85f792f..f407afc 100644 --- a/src/freebsd/Makefile.am +++ b/src/freebsd/Makefile.am @@ -7,7 +7,7 @@ INCLUDES = \ -DEGG_LOGGING="\"UP_LOGGING\"" \ -DEGG_CONSOLE="\"UP_CONSOLE\"" \ -DUP_COMPILATION \ - -I$(top_srcdir)/devkit-power-gobject \ + -I$(top_srcdir)/libupower-glib \ $(DBUS_GLIB_CFLAGS) \ $(POLKIT_CFLAGS) \ $(GLIB_CFLAGS) diff --git a/src/freebsd/up-device-supply.c b/src/freebsd/up-device-supply.c index de14cdd..d3c2872 100644 --- a/src/freebsd/up-device-supply.c +++ b/src/freebsd/up-device-supply.c @@ -42,7 +42,7 @@ #include "egg-debug.h" -#include "up-enum.h" +#include "up-types.h" #include "up-device-supply.h" #define UP_ACPIDEV "/dev/acpi" diff --git a/src/linux/Makefile.am b/src/linux/Makefile.am index 79b3187..e233d35 100644 --- a/src/linux/Makefile.am +++ b/src/linux/Makefile.am @@ -8,7 +8,7 @@ INCLUDES = \ -DEGG_CONSOLE="\"UP_CONSOLE\"" \ -DUP_COMPILATION \ -DG_UDEV_API_IS_SUBJECT_TO_CHANGE \ - -I$(top_srcdir)/devkit-power-gobject \ + -I$(top_srcdir)/libupower-glib \ $(GIO_CFLAGS) \ $(DBUS_GLIB_CFLAGS) \ $(GUDEV_CFLAGS) \ diff --git a/src/linux/up-device-csr.c b/src/linux/up-device-csr.c index 209cd6d..3853258 100644 --- a/src/linux/up-device-csr.c +++ b/src/linux/up-device-csr.c @@ -37,7 +37,7 @@ #include "sysfs-utils.h" #include "egg-debug.h" -#include "up-enum.h" +#include "up-types.h" #include "up-device-csr.h" #define UP_DEVICE_CSR_REFRESH_TIMEOUT 30L diff --git a/src/linux/up-device-hid.c b/src/linux/up-device-hid.c index 2c18134..98ef795 100644 --- a/src/linux/up-device-hid.c +++ b/src/linux/up-device-hid.c @@ -50,7 +50,7 @@ #include "sysfs-utils.h" #include "egg-debug.h" -#include "up-enum.h" +#include "up-types.h" #include "up-device-hid.h" #define UP_DEVICE_HID_REFRESH_TIMEOUT 30l diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c index 821dff4..bb0c75e 100644 --- a/src/linux/up-device-supply.c +++ b/src/linux/up-device-supply.c @@ -36,7 +36,7 @@ #include "sysfs-utils.h" #include "egg-debug.h" -#include "up-enum.h" +#include "up-types.h" #include "up-device-supply.h" #define UP_DEVICE_SUPPLY_REFRESH_TIMEOUT 30 /* seconds */ @@ -626,7 +626,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply) /* print what we did */ egg_debug ("guessing battery state '%s' using global on-battery:%i", - up_device_state_to_text (state), on_battery); + up_device_state_to_string (state), on_battery); g_object_unref (daemon); } diff --git a/src/linux/up-device-wup.c b/src/linux/up-device-wup.c index b8a180a..4f00634 100644 --- a/src/linux/up-device-wup.c +++ b/src/linux/up-device-wup.c @@ -44,7 +44,7 @@ #include "sysfs-utils.h" #include "egg-debug.h" -#include "up-enum.h" +#include "up-types.h" #include "up-device-wup.h" #define UP_DEVICE_WUP_REFRESH_TIMEOUT 10 /* seconds */ diff --git a/src/linux/up-input.c b/src/linux/up-input.c index ab886db..2cd6ec8 100644 --- a/src/linux/up-input.c +++ b/src/linux/up-input.c @@ -42,7 +42,7 @@ #include "sysfs-utils.h" #include "egg-debug.h" -#include "up-enum.h" +#include "up-types.h" #include "up-daemon.h" #include "up-input.h" #include "up-daemon.h" diff --git a/src/up-backend.h b/src/up-backend.h index 0b3523e..c2d3fcc 100644 --- a/src/up-backend.h +++ b/src/up-backend.h @@ -24,7 +24,7 @@ #include -#include "up-enum.h" +#include "up-types.h" #include "up-device.h" #include "up-daemon.h" diff --git a/src/up-daemon.h b/src/up-daemon.h index b5169cb..9361ae8 100644 --- a/src/up-daemon.h +++ b/src/up-daemon.h @@ -25,7 +25,7 @@ #include #include -#include "up-enum.h" +#include "up-types.h" #include "up-device-list.h" G_BEGIN_DECLS diff --git a/src/up-device-list.h b/src/up-device-list.h index 8f1da9c..709c893 100644 --- a/src/up-device-list.h +++ b/src/up-device-list.h @@ -24,7 +24,7 @@ #include -#include "up-enum.h" +#include "up-types.h" G_BEGIN_DECLS diff --git a/src/up-device.c b/src/up-device.c index 5ace215..6576b76 100644 --- a/src/up-device.c +++ b/src/up-device.c @@ -41,6 +41,7 @@ #include "up-stats-obj.h" #include "up-marshal.h" #include "up-device-glue.h" +#include "up-types.h" struct UpDevicePrivate { @@ -795,7 +796,7 @@ up_device_compute_object_path (UpDevice *device) const gchar *type; guint i; - type = up_device_kind_to_text (device->priv->type); + type = up_device_kind_to_string (device->priv->type); native_path = device->priv->native_path; basename = g_path_get_basename (native_path); id = g_strjoin ("_", type, basename, NULL); diff --git a/src/up-history.h b/src/up-history.h index d18dae3..f29879a 100644 --- a/src/up-history.h +++ b/src/up-history.h @@ -24,7 +24,7 @@ #include -#include "up-enum.h" +#include "up-types.h" G_BEGIN_DECLS diff --git a/src/up-main.c b/src/up-main.c index 1e221d4..af045d7 100644 --- a/src/up-main.c +++ b/src/up-main.c @@ -42,7 +42,7 @@ #include "up-qos.h" #include "up-wakeups.h" -#define DEVKIT_POWER_SERVICE_NAME "org.freedesktop.UPower" +#define UPOWER_SERVICE_NAME "org.freedesktop.UPower" static GMainLoop *loop = NULL; /** @@ -169,7 +169,7 @@ main (gint argc, gchar **argv) } /* aquire name */ - ret = up_main_acquire_name_on_proxy (bus_proxy, DEVKIT_POWER_SERVICE_NAME); + ret = up_main_acquire_name_on_proxy (bus_proxy, UPOWER_SERVICE_NAME); if (!ret) { egg_warning ("Could not acquire name; bailing out"); goto out; diff --git a/src/up-qos.c b/src/up-qos.c index e6a5b0d..dfd027f 100644 --- a/src/up-qos.c +++ b/src/up-qos.c @@ -121,7 +121,7 @@ up_qos_generate_cookie (UpQos *qos) * up_qos_get_lowest: **/ static gint -up_qos_get_lowest (UpQos *qos, UpQosType type) +up_qos_get_lowest (UpQos *qos, UpQosKind type) { guint i; gint lowest = G_MAXINT; @@ -153,7 +153,7 @@ up_qos_get_lowest (UpQos *qos, UpQosType type) * up_qos_latency_write: **/ static gboolean -up_qos_latency_write (UpQos *qos, UpQosType type, gint value) +up_qos_latency_write (UpQos *qos, UpQosKind type, gint value) { gchar *text = NULL; gint retval; @@ -187,7 +187,7 @@ out: * up_qos_latency_perhaps_changed: **/ static gboolean -up_qos_latency_perhaps_changed (UpQos *qos, UpQosType type) +up_qos_latency_perhaps_changed (UpQos *qos, UpQosKind type) { gint lowest; gint *last; @@ -206,7 +206,7 @@ up_qos_latency_perhaps_changed (UpQos *qos, UpQosType type) up_qos_latency_write (qos, type, lowest); /* emit signal */ - g_signal_emit (qos, signals [LATENCY_CHANGED], 0, up_qos_type_to_text (type), lowest); + g_signal_emit (qos, signals [LATENCY_CHANGED], 0, up_qos_kind_to_string (type), lowest); *last = lowest; return TRUE; } @@ -252,10 +252,10 @@ up_qos_request_latency (UpQos *qos, const gchar *type_text, gint value, gboolean gint pid; PolkitSubject *subject = NULL; gboolean retval; - UpQosType type; + UpQosKind type; /* get correct data */ - type = up_qos_type_from_text (type_text); + type = up_qos_kind_from_string (type_text); if (type == UP_QOS_KIND_UNKNOWN) { error = g_error_new (UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, "type invalid: %s", type_text); dbus_g_method_return_error (context, error); @@ -407,10 +407,10 @@ out: gboolean up_qos_get_latency (UpQos *qos, const gchar *type_text, gint *value, GError **error) { - UpQosType type; + UpQosKind type; /* get correct data */ - type = up_qos_type_from_text (type_text); + type = up_qos_kind_from_string (type_text); if (type == UP_QOS_KIND_UNKNOWN) { g_set_error (error, UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, "type invalid: %s", type_text); return FALSE; @@ -427,11 +427,11 @@ up_qos_get_latency (UpQos *qos, const gchar *type_text, gint *value, GError **er void up_qos_set_minimum_latency (UpQos *qos, const gchar *type_text, gint value, DBusGMethodInvocation *context) { - UpQosType type; + UpQosKind type; GError *error; /* type valid? */ - type = up_qos_type_from_text (type_text); + type = up_qos_kind_from_string (type_text); if (type == UP_QOS_KIND_UNKNOWN) { error = g_error_new (UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, "type invalid: %s", type_text); dbus_g_method_return_error (context, error); @@ -471,7 +471,7 @@ up_qos_get_latency_requests (UpQos *qos, GPtrArray **requests, GError **error) 3, obj->cmdline, 4, 0, //obj->timespec, 5, obj->persistent, - 6, up_qos_type_to_text (obj->type), + 6, up_qos_kind_to_string (obj->type), 7, obj->value, G_MAXUINT); g_ptr_array_add (*requests, g_value_get_boxed (&elem)); diff --git a/tools/Makefile.am b/tools/Makefile.am index 58fcc0a..8d3443e 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -7,12 +7,13 @@ INCLUDES = \ -DEGG_LOGGING="\"DKP_LOGGING\"" \ -DEGG_CONSOLE="\"DKP_CONSOLE\"" \ -I$(top_srcdir) \ - -I$(top_srcdir)/devkit-power-gobject \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/libupower-glib \ $(DBUS_GLIB_CFLAGS) \ $(POLKIT_DBUS_CFLAGS) \ $(GLIB_CFLAGS) -DEVKIT_POWER_LIBS = $(top_builddir)/devkit-power-gobject/libdevkit-power-gobject.la +UPOWER_LIBS = $(top_builddir)/libupower-glib/libupower-glib.la bin_PROGRAMS = upower @@ -27,7 +28,7 @@ upower_CPPFLAGS = \ upower_LDADD = \ $(DBUS_GLIB_LIBS) \ - $(DEVKIT_POWER_LIBS) \ + $(UPOWER_LIBS) \ $(POLKIT_DBUS_LIBS) install-exec-hook: diff --git a/tools/up-tool.c b/tools/up-tool.c index 162a7bc..297710f 100644 --- a/tools/up-tool.c +++ b/tools/up-tool.c @@ -40,10 +40,10 @@ static GMainLoop *loop; static gboolean opt_monitor_detail = FALSE; /** - * dkp_tool_get_timestamp: + * up_tool_get_timestamp: **/ static gchar * -dkp_tool_get_timestamp (void) +up_tool_get_timestamp (void) { gchar *str_time; gchar *timestamp; @@ -62,57 +62,57 @@ dkp_tool_get_timestamp (void) } /** - * dkp_tool_device_added_cb: + * up_tool_device_added_cb: **/ static void -dkp_tool_device_added_cb (DkpClient *client, const DkpDevice *device, gpointer user_data) +up_tool_device_added_cb (UpClient *client, const UpDevice *device, gpointer user_data) { gchar *timestamp; - timestamp = dkp_tool_get_timestamp (); - g_print ("[%s]\tdevice added: %s\n", timestamp, dkp_device_get_object_path (device)); + timestamp = up_tool_get_timestamp (); + g_print ("[%s]\tdevice added: %s\n", timestamp, up_device_get_object_path (device)); if (opt_monitor_detail) { - dkp_device_print (device); + up_device_print (device); g_print ("\n"); } g_free (timestamp); } /** - * dkp_tool_device_changed_cb: + * up_tool_device_changed_cb: **/ static void -dkp_tool_device_changed_cb (DkpClient *client, const DkpDevice *device, gpointer user_data) +up_tool_device_changed_cb (UpClient *client, const UpDevice *device, gpointer user_data) { gchar *timestamp; - timestamp = dkp_tool_get_timestamp (); - g_print ("[%s]\tdevice changed: %s\n", timestamp, dkp_device_get_object_path (device)); + timestamp = up_tool_get_timestamp (); + g_print ("[%s]\tdevice changed: %s\n", timestamp, up_device_get_object_path (device)); if (opt_monitor_detail) { /* TODO: would be nice to just show the diff */ - dkp_device_print (device); + up_device_print (device); g_print ("\n"); } g_free (timestamp); } /** - * dkp_tool_device_removed_cb: + * up_tool_device_removed_cb: **/ static void -dkp_tool_device_removed_cb (DkpClient *client, const DkpDevice *device, gpointer user_data) +up_tool_device_removed_cb (UpClient *client, const UpDevice *device, gpointer user_data) { gchar *timestamp; - timestamp = dkp_tool_get_timestamp (); - g_print ("[%s]\tdevice removed: %s\n", timestamp, dkp_device_get_object_path (device)); + timestamp = up_tool_get_timestamp (); + g_print ("[%s]\tdevice removed: %s\n", timestamp, up_device_get_object_path (device)); if (opt_monitor_detail) g_print ("\n"); g_free (timestamp); } /** - * dkp_client_print: + * up_client_print: **/ static void -dkp_client_print (DkpClient *client) +up_client_print (UpClient *client) { gchar *daemon_version; gboolean can_suspend; @@ -144,33 +144,33 @@ dkp_client_print (DkpClient *client) } /** - * dkp_tool_changed_cb: + * up_tool_changed_cb: **/ static void -dkp_tool_changed_cb (DkpClient *client, gpointer user_data) +up_tool_changed_cb (UpClient *client, gpointer user_data) { gchar *timestamp; - timestamp = dkp_tool_get_timestamp (); + timestamp = up_tool_get_timestamp (); g_print ("[%s]\tdaemon changed:\n", timestamp); if (opt_monitor_detail) { - dkp_client_print (client); + up_client_print (client); g_print ("\n"); } g_free (timestamp); } /** - * dkp_tool_do_monitor: + * up_tool_do_monitor: **/ static gboolean -dkp_tool_do_monitor (DkpClient *client) +up_tool_do_monitor (UpClient *client) { g_print ("Monitoring activity from the power daemon. Press Ctrl+C to cancel.\n"); - g_signal_connect (client, "device-added", G_CALLBACK (dkp_tool_device_added_cb), NULL); - g_signal_connect (client, "device-removed", G_CALLBACK (dkp_tool_device_removed_cb), NULL); - g_signal_connect (client, "device-changed", G_CALLBACK (dkp_tool_device_changed_cb), NULL); - g_signal_connect (client, "changed", G_CALLBACK (dkp_tool_changed_cb), NULL); + g_signal_connect (client, "device-added", G_CALLBACK (up_tool_device_added_cb), NULL); + g_signal_connect (client, "device-removed", G_CALLBACK (up_tool_device_removed_cb), NULL); + g_signal_connect (client, "device-changed", G_CALLBACK (up_tool_device_changed_cb), NULL); + g_signal_connect (client, "changed", G_CALLBACK (up_tool_changed_cb), NULL); g_main_loop_run (loop); @@ -178,42 +178,42 @@ dkp_tool_do_monitor (DkpClient *client) } /** - * dkp_tool_show_wakeups: + * up_tool_show_wakeups: **/ static gboolean -dkp_tool_show_wakeups (void) +up_tool_show_wakeups (void) { guint i; gboolean ret; - DkpWakeups *wakeups; - DkpWakeupsObj *obj; + UpWakeups *wakeups; + UpWakeupsObj *obj; guint total; GPtrArray *array; /* create new object */ - wakeups = dkp_wakeups_new (); + wakeups = up_wakeups_new (); /* do we have support? */ - ret = dkp_wakeups_has_capability (wakeups); + ret = up_wakeups_has_capability (wakeups); if (!ret) { g_print ("No wakeup capability\n"); goto out; } /* get total */ - total = dkp_wakeups_get_total (wakeups, NULL); + total = up_wakeups_get_total (wakeups, NULL); g_print ("Total wakeups per minute: %i\n", total); /* get data */ - array = dkp_wakeups_get_data (wakeups, NULL); + array = up_wakeups_get_data (wakeups, NULL); if (array == NULL) goto out; g_print ("Wakeup sources:\n"); for (i=0; ilen; i++) { obj = g_ptr_array_index (array, i); - dkp_wakeups_obj_print (obj); + up_wakeups_obj_print (obj); } - g_ptr_array_foreach (array, (GFunc) dkp_wakeups_obj_free, NULL); + g_ptr_array_foreach (array, (GFunc) up_wakeups_obj_free, NULL); g_ptr_array_free (array, TRUE); out: g_object_unref (wakeups); @@ -238,8 +238,8 @@ main (int argc, char **argv) gboolean ret; GError *error = NULL; - DkpClient *client; - DkpDevice *device; + UpClient *client; + UpDevice *device; const GOptionEntry entries[] = { { "enumerate", 'e', 0, G_OPTION_ARG_NONE, &opt_enumerate, _("Enumerate objects paths for devices"), NULL }, @@ -261,7 +261,7 @@ main (int argc, char **argv) g_option_context_free (context); loop = g_main_loop_new (NULL, FALSE); - client = dkp_client_new (); + client = up_client_new (); if (opt_version) { gchar *daemon_version; @@ -278,25 +278,25 @@ main (int argc, char **argv) /* wakeups */ if (opt_wakeups) { - dkp_tool_show_wakeups (); + up_tool_show_wakeups (); retval = EXIT_SUCCESS; goto out; } if (opt_enumerate || opt_dump) { GPtrArray *devices; - devices = dkp_client_enumerate_devices (client, &error); + devices = up_client_enumerate_devices (client, &error); if (devices == NULL) { egg_warning ("failed to enumerate: %s", error->message); goto out; } for (i=0; i < devices->len; i++) { - device = (DkpDevice*) g_ptr_array_index (devices, i); + device = (UpDevice*) g_ptr_array_index (devices, i); if (opt_enumerate) { - g_print ("%s\n", dkp_device_get_object_path (device)); + g_print ("%s\n", up_device_get_object_path (device)); } else { - g_print ("Device: %s\n", dkp_device_get_object_path (device)); - dkp_device_print (device); + g_print ("Device: %s\n", up_device_get_object_path (device)); + up_device_print (device); g_print ("\n"); } } @@ -304,27 +304,27 @@ main (int argc, char **argv) g_ptr_array_free (devices, TRUE); if (opt_dump) { g_print ("Daemon:\n"); - dkp_client_print (client); + up_client_print (client); } retval = EXIT_SUCCESS; goto out; } if (opt_monitor || opt_monitor_detail) { - if (!dkp_tool_do_monitor (client)) + if (!up_tool_do_monitor (client)) goto out; retval = EXIT_SUCCESS; goto out; } if (opt_show_info != NULL) { - device = dkp_device_new (); - ret = dkp_device_set_object_path (device, opt_show_info, &error); + device = up_device_new (); + ret = up_device_set_object_path (device, opt_show_info, &error); if (!ret) { g_print ("failed to set path: %s\n", error->message); g_error_free (error); } else { - dkp_device_print (device); + up_device_print (device); } g_object_unref (device); retval = EXIT_SUCCESS; -- 1.6.5