summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2010-01-18 12:49:30 +0000
committerRichard Hughes <richard@hughsie.com>2010-01-18 12:49:30 +0000
commit25e51c96136c45632091a7b240f8935ce1d239ce (patch)
tree85d17e0631078617488d2b626575003f80bd7686
parentd2550b4c7854e970719b07b48ecdb61af9c01b6f (diff)
downloadupower-25e51c96136c45632091a7b240f8935ce1d239ce.tar.gz
trivial: DkpDevice -> UpDevice (no ABI or API break)
-rw-r--r--devkit-power-gobject/dkp-enum.h13
-rw-r--r--src/Makefile.am2
-rw-r--r--src/dummy/up-backend.c12
-rw-r--r--src/freebsd/up-backend.c34
-rw-r--r--src/freebsd/up-device-supply.c148
-rw-r--r--src/freebsd/up-device-supply.h34
-rw-r--r--src/linux/up-backend.c52
-rw-r--r--src/linux/up-device-csr.c88
-rw-r--r--src/linux/up-device-csr.h34
-rw-r--r--src/linux/up-device-hid.c218
-rw-r--r--src/linux/up-device-hid.h34
-rw-r--r--src/linux/up-device-supply.c230
-rw-r--r--src/linux/up-device-supply.h34
-rw-r--r--src/linux/up-device-wup.c156
-rw-r--r--src/linux/up-device-wup.h34
-rw-r--r--src/up-backend.h6
-rw-r--r--src/up-daemon.c86
-rw-r--r--src/up-daemon.h4
-rw-r--r--src/up-device-list.c98
-rw-r--r--src/up-device-list.h44
-rw-r--r--src/up-device.c250
-rw-r--r--src/up-device.h80
-rw-r--r--src/up-history.c6
-rw-r--r--src/up-history.h2
-rw-r--r--src/up-self-test.c4
25 files changed, 858 insertions, 845 deletions
diff --git a/devkit-power-gobject/dkp-enum.h b/devkit-power-gobject/dkp-enum.h
index ce6fbab..7421cad 100644
--- a/devkit-power-gobject/dkp-enum.h
+++ b/devkit-power-gobject/dkp-enum.h
@@ -72,6 +72,19 @@ typedef enum {
DKP_QOS_TYPE_LAST
} DkpQosType;
+/* compat */
+typedef DkpDeviceType UpDeviceType;
+typedef DkpDeviceState UpDeviceState;
+typedef DkpDeviceTechnology UpDeviceTechnology;
+#define up_device_type_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_type_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
+
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/src/Makefile.am b/src/Makefile.am
index 315b2d6..ac20da9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -48,7 +48,7 @@ up-daemon-glue.h: org.freedesktop.DeviceKit.Power.xml Makefile.am
dbus-binding-tool --prefix=up_daemon --mode=glib-server --output=up-daemon-glue.h org.freedesktop.DeviceKit.Power.xml
up-device-glue.h: org.freedesktop.DeviceKit.Power.Device.xml Makefile.am
- dbus-binding-tool --prefix=dkp_device --mode=glib-server --output=up-device-glue.h org.freedesktop.DeviceKit.Power.Device.xml
+ dbus-binding-tool --prefix=up_device --mode=glib-server --output=up-device-glue.h org.freedesktop.DeviceKit.Power.Device.xml
up-qos-glue.h: org.freedesktop.DeviceKit.Power.QoS.xml Makefile.am
dbus-binding-tool --prefix=dkp_qos --mode=glib-server --output=up-qos-glue.h org.freedesktop.DeviceKit.Power.QoS.xml
diff --git a/src/dummy/up-backend.c b/src/dummy/up-backend.c
index 23e063c..d1445ad 100644
--- a/src/dummy/up-backend.c
+++ b/src/dummy/up-backend.c
@@ -43,8 +43,8 @@ static void up_backend_finalize (GObject *object);
struct UpBackendPrivate
{
UpDaemon *daemon;
- DkpDevice *device;
- DkpDeviceList *device_list; /* unused */
+ UpDevice *device;
+ UpDeviceList *device_list; /* unused */
GObject *native;
};
@@ -64,7 +64,7 @@ G_DEFINE_TYPE (UpBackend, up_backend, G_TYPE_OBJECT)
static gboolean
up_backend_changed_time_cb (UpBackend *backend)
{
- DkpDevice *device;
+ UpDevice *device;
GTimeVal timeval;
//FIXME!
@@ -85,7 +85,7 @@ up_backend_add_cb (UpBackend *backend)
gboolean ret;
/* coldplug */
- ret = dkp_device_coldplug (backend->priv->device, backend->priv->daemon, backend->priv->native);
+ ret = up_device_coldplug (backend->priv->device, backend->priv->daemon, backend->priv->native);
if (!ret) {
egg_warning ("failed to coldplug");
goto out;
@@ -157,8 +157,8 @@ up_backend_init (UpBackend *backend)
backend->priv = UP_BACKEND_GET_PRIVATE (backend);
backend->priv->daemon = NULL;
backend->priv->device_list = NULL;
- backend->priv->native = g_object_new (DKP_TYPE_DEVICE, NULL);
- backend->priv->device = dkp_device_new ();
+ backend->priv->native = g_object_new (UP_TYPE_DEVICE, NULL);
+ backend->priv->device = up_device_new ();
/* setup dummy */
g_object_set (backend->priv->device,
diff --git a/src/freebsd/up-backend.c b/src/freebsd/up-backend.c
index 18efb45..7118ebd 100644
--- a/src/freebsd/up-backend.c
+++ b/src/freebsd/up-backend.c
@@ -64,7 +64,7 @@ static gboolean up_backend_supports_sleep_state (const gchar *state);
struct UpBackendPrivate
{
UpDaemon *daemon;
- DkpDeviceList *device_list;
+ UpDeviceList *device_list;
GHashTable *handle_map;
guint poll_timer_id;
};
@@ -95,15 +95,15 @@ up_backend_refresh_devices (gpointer user_data)
{
UpBackend *backend;
GPtrArray *array;
- DkpDevice *device;
+ UpDevice *device;
guint i;
backend = UP_BACKEND (user_data);
- array = dkp_device_list_get_array (backend->priv->device_list);
+ array = up_device_list_get_array (backend->priv->device_list);
for (i = 0; i < array->len; i++) {
- device = DKP_DEVICE (g_ptr_array_index (array, i));
- dkp_device_refresh_internal (device);
+ device = UP_DEVICE (g_ptr_array_index (array, i));
+ up_device_refresh_internal (device);
}
g_ptr_array_unref (array);
@@ -125,7 +125,7 @@ up_backend_acpi_devd_notify (UpBackend *backend, const gchar *system, const gcha
if (!strcmp (subsystem, "ACAD")) {
native = dkp_acpi_native_new ("hw.acpi.acline");
- object = dkp_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
+ object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
} else if (!strcmp (subsystem, "CMBAT")) {
gchar *ptr;
int unit;
@@ -134,13 +134,13 @@ up_backend_acpi_devd_notify (UpBackend *backend, const gchar *system, const gcha
if (ptr != NULL && sscanf (ptr, ".BAT%i", &unit)) {
native = dkp_acpi_native_new_driver_unit ("battery", unit);
- object = dkp_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
+ object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
if (object == NULL) {
gpointer hptr;
hptr = g_hash_table_lookup (backend->priv->handle_map, type);
if (hptr != NULL) {
- object = dkp_device_list_lookup (backend->priv->device_list, G_OBJECT (hptr));
+ object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (hptr));
}
}
}
@@ -171,7 +171,7 @@ up_backend_acpi_devd_notify (UpBackend *backend, const gchar *system, const gcha
goto out;
}
- dkp_device_refresh_internal (DKP_DEVICE (object));
+ up_device_refresh_internal (UP_DEVICE (object));
if (object != NULL)
g_object_unref (object);
@@ -188,11 +188,11 @@ out:
static gboolean
up_backend_create_new_device (UpBackend *backend, DkpAcpiNative *native)
{
- DkpDevice *device;
+ UpDevice *device;
gboolean ret;
- device = DKP_DEVICE (dkp_device_supply_new ());
- ret = dkp_device_coldplug (device, backend->priv->daemon, G_OBJECT (native));
+ device = UP_DEVICE (up_device_supply_new ());
+ ret = up_device_coldplug (device, backend->priv->daemon, G_OBJECT (native));
if (!ret)
g_object_unref (device);
else {
@@ -260,15 +260,15 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
for (j = 0; dkp_has_sysctl ("dev.%s.%i.%%driver", handlers[i], j); j++) {
DkpAcpiNative *native;
- DkpDevice *device;
+ UpDevice *device;
GObject *object;
native = dkp_acpi_native_new_driver_unit (handlers[i], j);
- object = dkp_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
+ object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
if (object != NULL) {
- device = DKP_DEVICE (object);
- egg_warning ("treating add event as change event on %s", dkp_device_get_object_path (device));
- dkp_device_refresh_internal (device);
+ device = UP_DEVICE (object);
+ egg_warning ("treating add event as change event on %s", up_device_get_object_path (device));
+ up_device_refresh_internal (device);
} else {
up_backend_create_new_device (backend, native);
}
diff --git a/src/freebsd/up-device-supply.c b/src/freebsd/up-device-supply.c
index 69eb092..9aa0700 100644
--- a/src/freebsd/up-device-supply.c
+++ b/src/freebsd/up-device-supply.c
@@ -47,25 +47,25 @@
#define DKP_ACPIDEV "/dev/acpi"
-G_DEFINE_TYPE (DkpDeviceSupply, dkp_device_supply, DKP_TYPE_DEVICE)
-
-static gboolean dkp_device_supply_refresh (DkpDevice *device);
-static DkpDeviceTechnology dkp_device_supply_convert_device_technology (const gchar *type);
-static gboolean dkp_device_supply_acline_coldplug (DkpDevice *device);
-static gboolean dkp_device_supply_battery_coldplug (DkpDevice *device, DkpAcpiNative *native);
-static gboolean dkp_device_supply_acline_set_properties (DkpDevice *device);
-static gboolean dkp_device_supply_battery_set_properties (DkpDevice *device, DkpAcpiNative *native);
-static gboolean dkp_device_supply_get_on_battery (DkpDevice *device, gboolean *on_battery);
-static gboolean dkp_device_supply_get_low_battery (DkpDevice *device, gboolean *low_battery);
-static gboolean dkp_device_supply_get_online (DkpDevice *device, gboolean *online);
+G_DEFINE_TYPE (UpDeviceSupply, up_device_supply, UP_TYPE_DEVICE)
+
+static gboolean up_device_supply_refresh (UpDevice *device);
+static UpDeviceTechnology up_device_supply_convert_device_technology (const gchar *type);
+static gboolean up_device_supply_acline_coldplug (UpDevice *device);
+static gboolean up_device_supply_battery_coldplug (UpDevice *device, DkpAcpiNative *native);
+static gboolean up_device_supply_acline_set_properties (UpDevice *device);
+static gboolean up_device_supply_battery_set_properties (UpDevice *device, DkpAcpiNative *native);
+static gboolean up_device_supply_get_on_battery (UpDevice *device, gboolean *on_battery);
+static gboolean up_device_supply_get_low_battery (UpDevice *device, gboolean *low_battery);
+static gboolean up_device_supply_get_online (UpDevice *device, gboolean *online);
/**
- * dkp_device_supply_convert_device_technology:
+ * up_device_supply_convert_device_technology:
*
* This is taken from linux/dkp-device-supply.c.
**/
-static DkpDeviceTechnology
-dkp_device_supply_convert_device_technology (const gchar *type)
+static UpDeviceTechnology
+up_device_supply_convert_device_technology (const gchar *type)
{
if (type == NULL)
return DKP_DEVICE_TECHNOLOGY_UNKNOWN;
@@ -87,10 +87,10 @@ dkp_device_supply_convert_device_technology (const gchar *type)
}
/**
- * dkp_device_supply_reset_values:
+ * up_device_supply_reset_values:
**/
static void
-dkp_device_supply_reset_values (DkpDevice *device)
+up_device_supply_reset_values (UpDevice *device)
{
/* reset to default */
g_object_set (device,
@@ -120,10 +120,10 @@ dkp_device_supply_reset_values (DkpDevice *device)
}
/**
- * dkp_device_supply_acline_coldplug:
+ * up_device_supply_acline_coldplug:
**/
static gboolean
-dkp_device_supply_acline_coldplug (DkpDevice *device)
+up_device_supply_acline_coldplug (UpDevice *device)
{
gboolean ret;
@@ -133,30 +133,30 @@ dkp_device_supply_acline_coldplug (DkpDevice *device)
"type", DKP_DEVICE_TYPE_LINE_POWER,
NULL);
- ret = dkp_device_supply_acline_set_properties (device);
+ ret = up_device_supply_acline_set_properties (device);
return ret;
}
/**
- * dkp_device_supply_battery_coldplug:
+ * up_device_supply_battery_coldplug:
**/
static gboolean
-dkp_device_supply_battery_coldplug (DkpDevice *device, DkpAcpiNative *native)
+up_device_supply_battery_coldplug (UpDevice *device, DkpAcpiNative *native)
{
gboolean ret;
g_object_set (device, "type", DKP_DEVICE_TYPE_BATTERY, NULL);
- ret = dkp_device_supply_battery_set_properties (device, native);
+ ret = up_device_supply_battery_set_properties (device, native);
return ret;
}
/**
- * dkp_device_supply_battery_set_properties:
+ * up_device_supply_battery_set_properties:
**/
static gboolean
-dkp_device_supply_battery_set_properties (DkpDevice *device, DkpAcpiNative *native)
+up_device_supply_battery_set_properties (UpDevice *device, DkpAcpiNative *native)
{
gint fd;
gdouble volt, dvolt, rate, lastfull, cap, dcap, lcap, capacity;
@@ -164,8 +164,8 @@ dkp_device_supply_battery_set_properties (DkpDevice *device, DkpAcpiNative *nati
gboolean ret = FALSE;
guint64 time_to_empty, time_to_full;
gchar *vendor, *model, *serial;
- DkpDeviceTechnology technology;
- DkpDeviceState state;
+ UpDeviceTechnology technology;
+ UpDeviceState state;
union acpi_battery_ioctl_arg battif, battst, battinfo;
if (!dkp_has_sysctl ("hw.acpi.battery.units"))
@@ -200,14 +200,14 @@ dkp_device_supply_battery_set_properties (DkpDevice *device, DkpAcpiNative *nati
g_object_set (device, "is-present", is_present, NULL);
if (!is_present) {
- dkp_device_supply_reset_values (device);
+ up_device_supply_reset_values (device);
goto end;
}
vendor = dkp_make_safe_string (battif.bif.oeminfo);
model = dkp_make_safe_string (battif.bif.model);
serial = dkp_make_safe_string (battif.bif.serial);
- technology = dkp_device_supply_convert_device_technology (battif.bif.type);
+ technology = up_device_supply_convert_device_technology (battif.bif.type);
g_object_set (device,
"vendor", vendor,
@@ -323,10 +323,10 @@ end:
}
/**
- * dkp_device_supply_acline_set_properties:
+ * up_device_supply_acline_set_properties:
**/
static gboolean
-dkp_device_supply_acline_set_properties (DkpDevice *device)
+up_device_supply_acline_set_properties (UpDevice *device)
{
int acstate;
@@ -339,20 +339,20 @@ dkp_device_supply_acline_set_properties (DkpDevice *device)
}
/**
- * dkp_device_supply_coldplug:
+ * up_device_supply_coldplug:
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
**/
static gboolean
-dkp_device_supply_coldplug (DkpDevice *device)
+up_device_supply_coldplug (UpDevice *device)
{
DkpAcpiNative *native;
const gchar *native_path;
const gchar *driver;
gboolean ret = FALSE;
- dkp_device_supply_reset_values (device);
+ up_device_supply_reset_values (device);
- native = DKP_ACPI_NATIVE (dkp_device_get_native (device));
+ native = DKP_ACPI_NATIVE (up_device_get_native (device));
native_path = dkp_acpi_native_get_path (native);
driver = dkp_acpi_native_get_driver (native);
if (native_path == NULL) {
@@ -361,12 +361,12 @@ dkp_device_supply_coldplug (DkpDevice *device)
}
if (!strcmp (native_path, "hw.acpi.acline")) {
- ret = dkp_device_supply_acline_coldplug (device);
+ ret = up_device_supply_acline_coldplug (device);
goto out;
}
if (!g_strcmp0 (driver, "battery")) {
- ret = dkp_device_supply_battery_coldplug (device, native);
+ ret = up_device_supply_battery_coldplug (device, native);
goto out;
}
@@ -377,26 +377,26 @@ out:
}
/**
- * dkp_device_supply_refresh:
+ * up_device_supply_refresh:
*
* Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
-dkp_device_supply_refresh (DkpDevice *device)
+up_device_supply_refresh (UpDevice *device)
{
GObject *object;
GTimeVal timeval;
- DkpDeviceType type;
+ UpDeviceType type;
gboolean ret;
g_object_get (device, "type", &type, NULL);
switch (type) {
case DKP_DEVICE_TYPE_LINE_POWER:
- ret = dkp_device_supply_acline_set_properties (device);
+ ret = up_device_supply_acline_set_properties (device);
break;
case DKP_DEVICE_TYPE_BATTERY:
- object = dkp_device_get_native (device);
- ret = dkp_device_supply_battery_set_properties (device, DKP_ACPI_NATIVE (object));
+ object = up_device_get_native (device);
+ ret = up_device_supply_battery_set_properties (device, DKP_ACPI_NATIVE (object));
break;
default:
g_assert_not_reached ();
@@ -412,13 +412,13 @@ dkp_device_supply_refresh (DkpDevice *device)
}
/**
- * dkp_device_supply_get_on_battery:
+ * up_device_supply_get_on_battery:
**/
static gboolean
-dkp_device_supply_get_on_battery (DkpDevice *device, gboolean *on_battery)
+up_device_supply_get_on_battery (UpDevice *device, gboolean *on_battery)
{
- DkpDeviceType type;
- DkpDeviceState state;
+ UpDeviceType type;
+ UpDeviceState state;
gboolean is_present;
g_return_val_if_fail (on_battery != NULL, FALSE);
@@ -441,10 +441,10 @@ dkp_device_supply_get_on_battery (DkpDevice *device, gboolean *on_battery)
}
/**
- * dkp_device_supply_get_low_battery:
+ * up_device_supply_get_low_battery:
**/
static gboolean
-dkp_device_supply_get_low_battery (DkpDevice *device, gboolean *low_battery)
+up_device_supply_get_low_battery (UpDevice *device, gboolean *low_battery)
{
gboolean ret;
gboolean on_battery;
@@ -452,7 +452,7 @@ dkp_device_supply_get_low_battery (DkpDevice *device, gboolean *low_battery)
g_return_val_if_fail (low_battery != NULL, FALSE);
- ret = dkp_device_supply_get_on_battery (device, &on_battery);
+ ret = up_device_supply_get_on_battery (device, &on_battery);
if (!ret)
return FALSE;
@@ -467,12 +467,12 @@ dkp_device_supply_get_low_battery (DkpDevice *device, gboolean *low_battery)
}
/**
- * dkp_device_supply_get_online:
+ * up_device_supply_get_online:
**/
static gboolean
-dkp_device_supply_get_online (DkpDevice *device, gboolean *online)
+up_device_supply_get_online (UpDevice *device, gboolean *online)
{
- DkpDeviceType type;
+ UpDeviceType type;
gboolean online_tmp;
g_return_val_if_fail (online != NULL, FALSE);
@@ -491,52 +491,52 @@ dkp_device_supply_get_online (DkpDevice *device, gboolean *online)
}
/**
- * dkp_device_supply_init:
+ * up_device_supply_init:
**/
static void
-dkp_device_supply_init (DkpDeviceSupply *supply)
+up_device_supply_init (UpDeviceSupply *supply)
{
}
/**
- * dkp_device_supply_finalize:
+ * up_device_supply_finalize:
**/
static void
-dkp_device_supply_finalize (GObject *object)
+up_device_supply_finalize (GObject *object)
{
- DkpDeviceSupply *supply;
+ UpDeviceSupply *supply;
g_return_if_fail (object != NULL);
- g_return_if_fail (DKP_IS_SUPPLY (object));
+ g_return_if_fail (UP_IS_DEVICE_SUPPLY (object));
- supply = DKP_DEVICE_SUPPLY (object);
+ supply = UP_DEVICE_SUPPLY (object);
- G_OBJECT_CLASS (dkp_device_supply_parent_class)->finalize (object);
+ G_OBJECT_CLASS (up_device_supply_parent_class)->finalize (object);
}
/**
- * dkp_device_supply_class_init:
+ * up_device_supply_class_init:
**/
static void
-dkp_device_supply_class_init (DkpDeviceSupplyClass *klass)
+up_device_supply_class_init (UpDeviceSupplyClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- DkpDeviceClass *device_class = DKP_DEVICE_CLASS (klass);
-
- object_class->finalize = dkp_device_supply_finalize;
- device_class->get_on_battery = dkp_device_supply_get_on_battery;
- device_class->get_low_battery = dkp_device_supply_get_low_battery;
- device_class->get_online = dkp_device_supply_get_online;
- device_class->coldplug = dkp_device_supply_coldplug;
- device_class->refresh = dkp_device_supply_refresh;
+ UpDeviceClass *device_class = UP_DEVICE_CLASS (klass);
+
+ object_class->finalize = up_device_supply_finalize;
+ device_class->get_on_battery = up_device_supply_get_on_battery;
+ device_class->get_low_battery = up_device_supply_get_low_battery;
+ device_class->get_online = up_device_supply_get_online;
+ device_class->coldplug = up_device_supply_coldplug;
+ device_class->refresh = up_device_supply_refresh;
}
/**
- * dkp_device_supply_new:
+ * up_device_supply_new:
**/
-DkpDeviceSupply *
-dkp_device_supply_new (void)
+UpDeviceSupply *
+up_device_supply_new (void)
{
- return g_object_new (DKP_TYPE_SUPPLY, NULL);
+ return g_object_new (UP_TYPE_DEVICE_SUPPLY, NULL);
}
diff --git a/src/freebsd/up-device-supply.h b/src/freebsd/up-device-supply.h
index e1b042f..025a070 100644
--- a/src/freebsd/up-device-supply.h
+++ b/src/freebsd/up-device-supply.h
@@ -19,38 +19,38 @@
*
*/
-#ifndef __DKP_DEVICE_SUPPLY_H__
-#define __DKP_DEVICE_SUPPLY_H__
+#ifndef __UP_DEVICE_SUPPLY_H__
+#define __UP_DEVICE_SUPPLY_H__
#include <glib-object.h>
#include "up-device.h"
G_BEGIN_DECLS
-#define DKP_TYPE_SUPPLY (dkp_device_supply_get_type ())
-#define DKP_DEVICE_SUPPLY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DKP_TYPE_SUPPLY, DkpDeviceSupply))
-#define DKP_DEVICE_SUPPLY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DKP_TYPE_SUPPLY, DkpDeviceSupplyClass))
-#define DKP_IS_SUPPLY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DKP_TYPE_SUPPLY))
-#define DKP_IS_SUPPLY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DKP_TYPE_SUPPLY))
-#define DKP_DEVICE_SUPPLY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DKP_TYPE_SUPPLY, DkpDeviceSupplyClass))
+#define UP_TYPE_DEVICE_SUPPLY (up_device_supply_get_type ())
+#define UP_DEVICE_SUPPLY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_DEVICE_SUPPLY, UpDeviceSupply))
+#define UP_DEVICE_SUPPLY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_DEVICE_SUPPLY, UpDeviceSupplyClass))
+#define UP_IS_DEVICE_SUPPLY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_DEVICE_SUPPLY))
+#define UP_IS_DEVICE_SUPPLY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_DEVICE_SUPPLY))
+#define UP_DEVICE_SUPPLY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_DEVICE_SUPPLY, UpDeviceSupplyClass))
-typedef struct DkpDeviceSupplyPrivate DkpDeviceSupplyPrivate;
+typedef struct UpDeviceSupplyPrivate UpDeviceSupplyPrivate;
typedef struct
{
- DkpDevice parent;
- DkpDeviceSupplyPrivate *priv;
-} DkpDeviceSupply;
+ UpDevice parent;
+ UpDeviceSupplyPrivate *priv;
+} UpDeviceSupply;
typedef struct
{
- DkpDeviceClass parent_class;
-} DkpDeviceSupplyClass;
+ UpDeviceClass parent_class;
+} UpDeviceSupplyClass;
-GType dkp_device_supply_get_type (void);
-DkpDeviceSupply *dkp_device_supply_new (void);
+GType up_device_supply_get_type (void);
+UpDeviceSupply *up_device_supply_new (void);
G_END_DECLS
-#endif /* __DKP_DEVICE_SUPPLY_H__ */
+#endif /* __UP_DEVICE_SUPPLY_H__ */
diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c
index 0d14aee..34daf4b 100644
--- a/src/linux/up-backend.c
+++ b/src/linux/up-backend.c
@@ -50,9 +50,9 @@ static void up_backend_finalize (GObject *object);
struct UpBackendPrivate
{
UpDaemon *daemon;
- DkpDeviceList *device_list;
+ UpDeviceList *device_list;
GUdevClient *gudev_client;
- DkpDeviceList *managed_devices;
+ UpDeviceList *managed_devices;
};
enum {
@@ -71,12 +71,12 @@ static void up_backend_device_remove (UpBackend *backend, GUdevDevice *native);
/**
* up_backend_device_new:
**/
-static DkpDevice *
+static UpDevice *
up_backend_device_new (UpBackend *backend, GUdevDevice *native)
{
const gchar *subsys;
const gchar *native_path;
- DkpDevice *device = NULL;
+ UpDevice *device = NULL;
DkpInput *input;
gboolean ret;
@@ -84,8 +84,8 @@ up_backend_device_new (UpBackend *backend, GUdevDevice *native)
if (g_strcmp0 (subsys, "power_supply") == 0) {
/* are we a valid power supply */
- device = DKP_DEVICE (dkp_device_supply_new ());
- ret = dkp_device_coldplug (device, backend->priv->daemon, G_OBJECT (native));
+ device = UP_DEVICE (up_device_supply_new ());
+ ret = up_device_coldplug (device, backend->priv->daemon, G_OBJECT (native));
if (ret)
goto out;
g_object_unref (device);
@@ -96,8 +96,8 @@ up_backend_device_new (UpBackend *backend, GUdevDevice *native)
} else if (g_strcmp0 (subsys, "tty") == 0) {
/* try to detect a Watts Up? Pro monitor */
- device = DKP_DEVICE (dkp_device_wup_new ());
- ret = dkp_device_coldplug (device, backend->priv->daemon, G_OBJECT (native));
+ device = UP_DEVICE (up_device_wup_new ());
+ ret = up_device_coldplug (device, backend->priv->daemon, G_OBJECT (native));
if (ret)
goto out;
g_object_unref (device);
@@ -108,15 +108,15 @@ up_backend_device_new (UpBackend *backend, GUdevDevice *native)
} else if (g_strcmp0 (subsys, "usb") == 0) {
/* see if this is a CSR mouse or keyboard */
- device = DKP_DEVICE (dkp_device_csr_new ());
- ret = dkp_device_coldplug (device, backend->priv->daemon, G_OBJECT (native));
+ device = UP_DEVICE (up_device_csr_new ());
+ ret = up_device_coldplug (device, backend->priv->daemon, G_OBJECT (native));
if (ret)
goto out;
g_object_unref (device);
/* try to detect a HID UPS */
- device = DKP_DEVICE (dkp_device_hid_new ());
- ret = dkp_device_coldplug (device, backend->priv->daemon, G_OBJECT (native));
+ device = UP_DEVICE (up_device_hid_new ());
+ ret = up_device_coldplug (device, backend->priv->daemon, G_OBJECT (native));
if (ret)
goto out;
g_object_unref (device);
@@ -140,7 +140,7 @@ up_backend_device_new (UpBackend *backend, GUdevDevice *native)
NULL);
/* not a power device */
- dkp_device_list_insert (backend->priv->managed_devices, G_OBJECT (native), G_OBJECT (input));
+ up_device_list_insert (backend->priv->managed_devices, G_OBJECT (native), G_OBJECT (input));
/* no valid input object */
device = NULL;
@@ -160,11 +160,11 @@ static void
up_backend_device_changed (UpBackend *backend, GUdevDevice *native)
{
GObject *object;
- DkpDevice *device;
+ UpDevice *device;
gboolean ret;
/* first, check the device and add it if it doesn't exist */
- object = dkp_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
+ object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
if (object == NULL) {
egg_warning ("treating change event as add on %s", g_udev_device_get_sysfs_path (native));
up_backend_device_add (backend, native);
@@ -172,10 +172,10 @@ up_backend_device_changed (UpBackend *backend, GUdevDevice *native)
}
/* need to refresh device */
- device = DKP_DEVICE (object);
- ret = dkp_device_refresh_internal (device);
+ device = UP_DEVICE (object);
+ ret = up_device_refresh_internal (device);
if (!ret) {
- egg_debug ("no changes on %s", dkp_device_get_object_path (device));
+ egg_debug ("no changes on %s", up_device_get_object_path (device));
goto out;
}
out:
@@ -190,15 +190,15 @@ static gboolean
up_backend_device_add (UpBackend *backend, GUdevDevice *native)
{
GObject *object;
- DkpDevice *device;
+ UpDevice *device;
gboolean ret = TRUE;
/* does device exist in db? */
- object = dkp_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
+ object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
if (object != NULL) {
- device = DKP_DEVICE (object);
+ device = UP_DEVICE (object);
/* we already have the device; treat as change event */
- egg_warning ("treating add event as change event on %s", dkp_device_get_object_path (device));
+ egg_warning ("treating add event as change event on %s", up_device_get_object_path (device));
up_backend_device_changed (backend, native);
goto out;
}
@@ -225,16 +225,16 @@ static void
up_backend_device_remove (UpBackend *backend, GUdevDevice *native)
{
GObject *object;
- DkpDevice *device;
+ UpDevice *device;
/* does device exist in db? */
- object = dkp_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
+ object = up_device_list_lookup (backend->priv->device_list, G_OBJECT (native));
if (object == NULL) {
egg_debug ("ignoring remove event on %s", g_udev_device_get_sysfs_path (native));
goto out;
}
- device = DKP_DEVICE (object);
+ device = UP_DEVICE (object);
/* emit */
egg_debug ("emitting device-removed: %s", g_udev_device_get_sysfs_path (native));
g_signal_emit (backend, signals[SIGNAL_DEVICE_REMOVED], 0, native, device);
@@ -342,7 +342,7 @@ up_backend_init (UpBackend *backend)
backend->priv = UP_BACKEND_GET_PRIVATE (backend);
backend->priv->daemon = NULL;
backend->priv->device_list = NULL;
- backend->priv->managed_devices = dkp_device_list_new ();
+ backend->priv->managed_devices = up_device_list_new ();
}
/**
diff --git a/src/linux/up-device-csr.c b/src/linux/up-device-csr.c
index 2c67174..b52e616 100644
--- a/src/linux/up-device-csr.c
+++ b/src/linux/up-device-csr.c
@@ -40,7 +40,7 @@
#include "up-enum.h"
#include "up-device-csr.h"
-#define DKP_DEVICE_CSR_REFRESH_TIMEOUT 30L
+#define UP_DEVICE_CSR_REFRESH_TIMEOUT 30L
/* Internal CSR registers */
#define CSR_P6 (buf[0])
@@ -52,7 +52,7 @@
#define CSR_PB0 (buf[6])
#define CSR_PB1 (buf[7])
-struct DkpDeviceCsrPrivate
+struct UpDeviceCsrPrivate
{
guint poll_timer_id;
gboolean is_dual;
@@ -62,31 +62,31 @@ struct DkpDeviceCsrPrivate
struct usb_device *device;
};
-G_DEFINE_TYPE (DkpDeviceCsr, dkp_device_csr, DKP_TYPE_DEVICE)
-#define DKP_DEVICE_CSR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_CSR, DkpDeviceCsrPrivate))
+G_DEFINE_TYPE (UpDeviceCsr, up_device_csr, UP_TYPE_DEVICE)
+#define UP_DEVICE_CSR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE_CSR, UpDeviceCsrPrivate))
-static gboolean dkp_device_csr_refresh (DkpDevice *device);
+static gboolean up_device_csr_refresh (UpDevice *device);
/**
- * dkp_device_csr_poll_cb:
+ * up_device_csr_poll_cb:
**/
static gboolean
-dkp_device_csr_poll_cb (DkpDeviceCsr *csr)
+up_device_csr_poll_cb (UpDeviceCsr *csr)
{
- DkpDevice *device = DKP_DEVICE (csr);
+ UpDevice *device = UP_DEVICE (csr);
- egg_debug ("Polling: %s", dkp_device_get_object_path (device));
- dkp_device_csr_refresh (device);
+ egg_debug ("Polling: %s", up_device_get_object_path (device));
+ up_device_csr_refresh (device);
/* always continue polling */
return TRUE;
}
/**
- * dkp_device_csr_find_device:
+ * up_device_csr_find_device:
**/
static struct usb_device *
-dkp_device_csr_find_device (DkpDeviceCsr *csr)
+up_device_csr_find_device (UpDeviceCsr *csr)
{
struct usb_bus *curr_bus;
struct usb_device *curr_device;
@@ -123,14 +123,14 @@ out:
}
/**
- * dkp_device_csr_coldplug:
+ * up_device_csr_coldplug:
*
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
**/
static gboolean
-dkp_device_csr_coldplug (DkpDevice *device)
+up_device_csr_coldplug (UpDevice *device)
{
- DkpDeviceCsr *csr = DKP_DEVICE_CSR (device);
+ UpDeviceCsr *csr = UP_DEVICE_CSR (device);
GUdevDevice *native;
gboolean ret = FALSE;
const gchar *type;
@@ -139,7 +139,7 @@ dkp_device_csr_coldplug (DkpDevice *device)
const gchar *product;
/* get the type */
- native = G_UDEV_DEVICE (dkp_device_get_native (device));
+ native = G_UDEV_DEVICE (up_device_get_native (device));
type = g_udev_device_get_property (native, "DKP_BATTERY_TYPE");
if (type == NULL)
goto out;
@@ -166,7 +166,7 @@ dkp_device_csr_coldplug (DkpDevice *device)
}
/* try to get the usb device */
- csr->priv->device = dkp_device_csr_find_device (csr);
+ csr->priv->device = up_device_csr_find_device (csr);
if (csr->priv->device == NULL) {
egg_debug ("failed to get device %p", csr);
goto out;
@@ -198,29 +198,29 @@ dkp_device_csr_coldplug (DkpDevice *device)
NULL);
/* coldplug */
- ret = dkp_device_csr_refresh (device);
+ ret = up_device_csr_refresh (device);
if (!ret)
goto out;
/* set up a poll */
- csr->priv->poll_timer_id = g_timeout_add_seconds (DKP_DEVICE_CSR_REFRESH_TIMEOUT,
- (GSourceFunc) dkp_device_csr_poll_cb, csr);
+ csr->priv->poll_timer_id = g_timeout_add_seconds (UP_DEVICE_CSR_REFRESH_TIMEOUT,
+ (GSourceFunc) up_device_csr_poll_cb, csr);
out:
return ret;
}
/**
- * dkp_device_csr_refresh:
+ * up_device_csr_refresh:
*
* Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
-dkp_device_csr_refresh (DkpDevice *device)
+up_device_csr_refresh (UpDevice *device)
{
gboolean ret = FALSE;
GTimeVal timeval;
- DkpDeviceCsr *csr = DKP_DEVICE_CSR (device);
+ UpDeviceCsr *csr = UP_DEVICE_CSR (device);
usb_dev_handle *handle = NULL;
char buf[80];
unsigned int addr;
@@ -245,7 +245,7 @@ dkp_device_csr_refresh (DkpDevice *device)
}
/* get the charge */
- written = usb_control_msg (handle, 0xc0, 0x09, 0x03|addr, 0x00|addr, buf, 8, DKP_DEVICE_CSR_REFRESH_TIMEOUT);
+ written = usb_control_msg (handle, 0xc0, 0x09, 0x03|addr, 0x00|addr, buf, 8, UP_DEVICE_CSR_REFRESH_TIMEOUT);
ret = (written == 8);
if (!ret) {
egg_warning ("failed to write to device, wrote %i bytes", written);
@@ -277,12 +277,12 @@ out:
}
/**
- * dkp_device_csr_init:
+ * up_device_csr_init:
**/
static void
-dkp_device_csr_init (DkpDeviceCsr *csr)
+up_device_csr_init (UpDeviceCsr *csr)
{
- csr->priv = DKP_DEVICE_CSR_GET_PRIVATE (csr);
+ csr->priv = UP_DEVICE_CSR_GET_PRIVATE (csr);
usb_init ();
usb_find_busses ();
@@ -294,47 +294,47 @@ dkp_device_csr_init (DkpDeviceCsr *csr)
}
/**
- * dkp_device_csr_finalize:
+ * up_device_csr_finalize:
**/
static void
-dkp_device_csr_finalize (GObject *object)
+up_device_csr_finalize (GObject *object)
{
- DkpDeviceCsr *csr;
+ UpDeviceCsr *csr;
g_return_if_fail (object != NULL);
- g_return_if_fail (DKP_IS_CSR (object));
+ g_return_if_fail (UP_IS_DEVICE_CSR (object));
- csr = DKP_DEVICE_CSR (object);
+ csr = UP_DEVICE_CSR (object);
g_return_if_fail (csr->priv != NULL);
if (csr->priv->poll_timer_id > 0)
g_source_remove (csr->priv->poll_timer_id);
- G_OBJECT_CLASS (dkp_device_csr_parent_class)->finalize (object);
+ G_OBJECT_CLASS (up_device_csr_parent_class)->finalize (object);
}
/**
- * dkp_device_csr_class_init:
+ * up_device_csr_class_init:
**/
static void
-dkp_device_csr_class_init (DkpDeviceCsrClass *klass)
+up_device_csr_class_init (UpDeviceCsrClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- DkpDeviceClass *device_class = DKP_DEVICE_CLASS (klass);
+ UpDeviceClass *device_class = UP_DEVICE_CLASS (klass);
- object_class->finalize = dkp_device_csr_finalize;
- device_class->coldplug = dkp_device_csr_coldplug;
- device_class->refresh = dkp_device_csr_refresh;
+ object_class->finalize = up_device_csr_finalize;
+ device_class->coldplug = up_device_csr_coldplug;
+ device_class->refresh = up_device_csr_refresh;
- g_type_class_add_private (klass, sizeof (DkpDeviceCsrPrivate));
+ g_type_class_add_private (klass, sizeof (UpDeviceCsrPrivate));
}
/**
- * dkp_device_csr_new:
+ * up_device_csr_new:
**/
-DkpDeviceCsr *
-dkp_device_csr_new (void)
+UpDeviceCsr *
+up_device_csr_new (void)
{
- return g_object_new (DKP_TYPE_CSR, NULL);
+ return g_object_new (UP_TYPE_DEVICE_CSR, NULL);
}
diff --git a/src/linux/up-device-csr.h b/src/linux/up-device-csr.h
index d605853..65e7f35 100644
--- a/src/linux/up-device-csr.h
+++ b/src/linux/up-device-csr.h
@@ -19,38 +19,38 @@
*
*/
-#ifndef __DKP_DEVICE_CSR_H__
-#define __DKP_DEVICE_CSR_H__
+#ifndef __UP_DEVICE_CSR_H__
+#define __UP_DEVICE_CSR_H__
#include <glib-object.h>
#include "up-device.h"
G_BEGIN_DECLS
-#define DKP_TYPE_CSR (dkp_device_csr_get_type ())
-#define DKP_DEVICE_CSR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DKP_TYPE_CSR, DkpDeviceCsr))
-#define DKP_DEVICE_CSR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DKP_TYPE_CSR, DkpDeviceCsrClass))
-#define DKP_IS_CSR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DKP_TYPE_CSR))
-#define DKP_IS_CSR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DKP_TYPE_CSR))
-#define DKP_DEVICE_CSR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DKP_TYPE_CSR, DkpDeviceCsrClass))
+#define UP_TYPE_DEVICE_CSR (up_device_csr_get_type ())
+#define UP_DEVICE_CSR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_DEVICE_CSR, UpDeviceCsr))
+#define UP_DEVICE_CSR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_DEVICE_CSR, UpDeviceCsrClass))
+#define UP_IS_DEVICE_CSR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_DEVICE_CSR))
+#define UP_IS_DEVICE_CSR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_DEVICE_CSR))
+#define UP_DEVICE_CSR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_DEVICE_CSR, UpDeviceCsrClass))
-typedef struct DkpDeviceCsrPrivate DkpDeviceCsrPrivate;
+typedef struct UpDeviceCsrPrivate UpDeviceCsrPrivate;
typedef struct
{
- DkpDevice parent;
- DkpDeviceCsrPrivate *priv;
-} DkpDeviceCsr;
+ UpDevice parent;
+ UpDeviceCsrPrivate *priv;
+} UpDeviceCsr;
typedef struct
{
- DkpDeviceClass parent_class;
-} DkpDeviceCsrClass;
+ UpDeviceClass parent_class;
+} UpDeviceCsrClass;
-GType dkp_device_csr_get_type (void);
-DkpDeviceCsr *dkp_device_csr_new (void);
+GType up_device_csr_get_type (void);
+UpDeviceCsr *up_device_csr_new (void);
G_END_DECLS
-#endif /* __DKP_DEVICE_CSR_H__ */
+#endif /* __UP_DEVICE_CSR_H__ */
diff --git a/src/linux/up-device-hid.c b/src/linux/up-device-hid.c
index 7e88d0c..93a1b8e 100644
--- a/src/linux/up-device-hid.c
+++ b/src/linux/up-device-hid.c
@@ -53,54 +53,54 @@
#include "up-enum.h"
#include "up-device-hid.h"
-#define DKP_DEVICE_HID_REFRESH_TIMEOUT 30l
-
-#define DKP_DEVICE_HID_USAGE 0x840000
-#define DKP_DEVICE_HID_SERIAL 0x8400fe
-#define DKP_DEVICE_HID_CHEMISTRY 0x850089
-#define DKP_DEVICE_HID_CAPACITY_MODE 0x85002c
-#define DKP_DEVICE_HID_BATTERY_VOLTAGE 0x840030
-#define DKP_DEVICE_HID_BELOW_RCL 0x840042
-#define DKP_DEVICE_HID_SHUTDOWN_IMMINENT 0x840069
-#define DKP_DEVICE_HID_PRODUCT 0x8400fe
-#define DKP_DEVICE_HID_SERIAL_NUMBER 0x8400ff
-#define DKP_DEVICE_HID_CHARGING 0x850044
-#define DKP_DEVICE_HID_DISCHARGING 0x850045
-#define DKP_DEVICE_HID_REMAINING_CAPACITY 0x850066
-#define DKP_DEVICE_HID_RUNTIME_TO_EMPTY 0x850068
-#define DKP_DEVICE_HID_AC_PRESENT 0x8500d0
-#define DKP_DEVICE_HID_BATTERY_PRESENT 0x8500d1
-#define DKP_DEVICE_HID_DESIGN_CAPACITY 0x850083
-#define DKP_DEVICE_HID_DEVICE_NAME 0x850088
-#define DKP_DEVICE_HID_DEVICE_CHEMISTRY 0x850089
-#define DKP_DEVICE_HID_RECHARGEABLE 0x85008b
-#define DKP_DEVICE_HID_OEM_INFORMATION 0x85008f
-
-#define DKP_DEVICE_HID_PAGE_GENERIC_DESKTOP 0x01
-#define DKP_DEVICE_HID_PAGE_CONSUMER_PRODUCT 0x0c
-#define DKP_DEVICE_HID_PAGE_USB_MONITOR 0x80
-#define DKP_DEVICE_HID_PAGE_USB_ENUMERATED_VALUES 0x81
-#define DKP_DEVICE_HID_PAGE_VESA_VIRTUAL_CONTROLS 0x82
-#define DKP_DEVICE_HID_PAGE_RESERVED_MONITOR 0x83
-#define DKP_DEVICE_HID_PAGE_POWER_DEVICE 0x84
-#define DKP_DEVICE_HID_PAGE_BATTERY_SYSTEM 0x85
-
-struct DkpDeviceHidPrivate
+#define UP_DEVICE_HID_REFRESH_TIMEOUT 30l
+
+#define UP_DEVICE_HID_USAGE 0x840000
+#define UP_DEVICE_HID_SERIAL 0x8400fe
+#define UP_DEVICE_HID_CHEMISTRY 0x850089
+#define UP_DEVICE_HID_CAPACITY_MODE 0x85002c
+#define UP_DEVICE_HID_BATTERY_VOLTAGE 0x840030
+#define UP_DEVICE_HID_BELOW_RCL 0x840042
+#define UP_DEVICE_HID_SHUTDOWN_IMMINENT 0x840069
+#define UP_DEVICE_HID_PRODUCT 0x8400fe
+#define UP_DEVICE_HID_SERIAL_NUMBER 0x8400ff
+#define UP_DEVICE_HID_CHARGING 0x850044
+#define UP_DEVICE_HID_DISCHARGING 0x850045
+#define UP_DEVICE_HID_REMAINING_CAPACITY 0x850066
+#define UP_DEVICE_HID_RUNTIME_TO_EMPTY 0x850068
+#define UP_DEVICE_HID_AC_PRESENT 0x8500d0
+#define UP_DEVICE_HID_BATTERY_PRESENT 0x8500d1
+#define UP_DEVICE_HID_DESIGN_CAPACITY 0x850083
+#define UP_DEVICE_HID_DEVICE_NAME 0x850088
+#define UP_DEVICE_HID_DEVICE_CHEMISTRY 0x850089
+#define UP_DEVICE_HID_RECHARGEABLE 0x85008b
+#define UP_DEVICE_HID_OEM_INFORMATION 0x85008f
+
+#define UP_DEVICE_HID_PAGE_GENERIC_DESKTOP 0x01
+#define UP_DEVICE_HID_PAGE_CONSUMER_PRODUCT 0x0c
+#define UP_DEVICE_HID_PAGE_USB_MONITOR 0x80
+#define UP_DEVICE_HID_PAGE_USB_ENUMERATED_VALUES 0x81
+#define UP_DEVICE_HID_PAGE_VESA_VIRTUAL_CONTROLS 0x82
+#define UP_DEVICE_HID_PAGE_RESERVED_MONITOR 0x83
+#define UP_DEVICE_HID_PAGE_POWER_DEVICE 0x84
+#define UP_DEVICE_HID_PAGE_BATTERY_SYSTEM 0x85
+
+struct UpDeviceHidPrivate
{
guint poll_timer_id;
int fd;
};
-G_DEFINE_TYPE (DkpDeviceHid, dkp_device_hid, DKP_TYPE_DEVICE)
-#define DKP_DEVICE_HID_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_HID, DkpDeviceHidPrivate))
+G_DEFINE_TYPE (UpDeviceHid, up_device_hid, UP_TYPE_DEVICE)
+#define UP_DEVICE_HID_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE_HID, UpDeviceHidPrivate))
-static gboolean dkp_device_hid_refresh (DkpDevice *device);
+static gboolean up_device_hid_refresh (UpDevice *device);
/**
- * dkp_device_hid_is_ups:
+ * up_device_hid_is_ups:
**/
static gboolean
-dkp_device_hid_is_ups (DkpDeviceHid *hid)
+up_device_hid_is_ups (UpDeviceHid *hid)
{
guint i;
int retval;
@@ -117,7 +117,7 @@ dkp_device_hid_is_ups (DkpDeviceHid *hid)
/* can we use the hid device as a UPS? */
for (i = 0; i < device_info.num_applications; i++) {
retval = ioctl (hid->priv->fd, HIDIOCAPPLICATION, i);
- if (retval >> 16 == DKP_DEVICE_HID_PAGE_POWER_DEVICE) {
+ if (retval >> 16 == UP_DEVICE_HID_PAGE_POWER_DEVICE) {
ret = TRUE;
goto out;
}
@@ -127,25 +127,25 @@ out:
}
/**
- * dkp_device_hid_poll:
+ * up_device_hid_poll:
**/
static gboolean
-dkp_device_hid_poll (DkpDeviceHid *hid)
+up_device_hid_poll (UpDeviceHid *hid)
{
- DkpDevice *device = DKP_DEVICE (hid);
+ UpDevice *device = UP_DEVICE (hid);
- egg_debug ("Polling: %s", dkp_device_get_object_path (device));
- dkp_device_hid_refresh (device);
+ egg_debug ("Polling: %s", up_device_get_object_path (device));
+ up_device_hid_refresh (device);
/* always continue polling */
return TRUE;
}
/**
- * dkp_device_hid_get_string:
+ * up_device_hid_get_string:
**/
static const gchar *
-dkp_device_hid_get_string (DkpDeviceHid *hid, int sindex)
+up_device_hid_get_string (UpDeviceHid *hid, int sindex)
{
static struct hiddev_string_descriptor sdesc;
@@ -164,10 +164,10 @@ dkp_device_hid_get_string (DkpDeviceHid *hid, int sindex)
}
/**
- * dkp_device_hid_convert_device_technology:
+ * up_device_hid_convert_device_technology:
**/
-static DkpDeviceTechnology
-dkp_device_hid_convert_device_technology (const gchar *type)
+static UpDeviceTechnology
+up_device_hid_convert_device_technology (const gchar *type)
{
if (type == NULL)
return DKP_DEVICE_TECHNOLOGY_UNKNOWN;
@@ -178,53 +178,53 @@ dkp_device_hid_convert_device_technology (const gchar *type)
}
/**
- * dkp_device_hid_set_values:
+ * up_device_hid_set_values:
**/
static gboolean
-dkp_device_hid_set_values (DkpDeviceHid *hid, int code, int value)
+up_device_hid_set_values (UpDeviceHid *hid, int code, int value)
{
const gchar *type;
gboolean ret = TRUE;
- DkpDevice *device = DKP_DEVICE (hid);
+ UpDevice *device = UP_DEVICE (hid);
switch (code) {
- case DKP_DEVICE_HID_REMAINING_CAPACITY:
+ case UP_DEVICE_HID_REMAINING_CAPACITY:
g_object_set (device, "percentage", (gfloat) value, NULL);
break;
- case DKP_DEVICE_HID_RUNTIME_TO_EMPTY:
+ case UP_DEVICE_HID_RUNTIME_TO_EMPTY:
g_object_set (device, "time-to-empty", (gint64) value, NULL);
break;
- case DKP_DEVICE_HID_CHARGING:
+ case UP_DEVICE_HID_CHARGING:
if (value != 0)
g_object_set (device, "state", DKP_DEVICE_STATE_CHARGING, NULL);
break;
- case DKP_DEVICE_HID_DISCHARGING:
+ case UP_DEVICE_HID_DISCHARGING:
if (value != 0)
g_object_set (device, "state", DKP_DEVICE_STATE_DISCHARGING, NULL);
break;
- case DKP_DEVICE_HID_BATTERY_PRESENT:
+ case UP_DEVICE_HID_BATTERY_PRESENT:
g_object_set (device, "is-present", (value != 0), NULL);
break;
- case DKP_DEVICE_HID_DEVICE_NAME:
- g_object_set (device, "device-name", dkp_device_hid_get_string (hid, value), NULL);
+ case UP_DEVICE_HID_DEVICE_NAME:
+ g_object_set (device, "device-name", up_device_hid_get_string (hid, value), NULL);
break;
- case DKP_DEVICE_HID_CHEMISTRY:
- type = dkp_device_hid_get_string (hid, value);
- g_object_set (device, "technology", dkp_device_hid_convert_device_technology (type), NULL);
+ case UP_DEVICE_HID_CHEMISTRY:
+ type = up_device_hid_get_string (hid, value);
+ g_object_set (device, "technology", up_device_hid_convert_device_technology (type), NULL);
break;
- case DKP_DEVICE_HID_RECHARGEABLE:
+ case UP_DEVICE_HID_RECHARGEABLE:
g_object_set (device, "is-rechargeable", (value != 0), NULL);
break;
- case DKP_DEVICE_HID_OEM_INFORMATION:
- g_object_set (device, "vendor", dkp_device_hid_get_string (hid, value), NULL);
+ case UP_DEVICE_HID_OEM_INFORMATION:
+ g_object_set (device, "vendor", up_device_hid_get_string (hid, value), NULL);
break;
- case DKP_DEVICE_HID_PRODUCT:
- g_object_set (device, "model", dkp_device_hid_get_string (hid, value), NULL);
+ case UP_DEVICE_HID_PRODUCT:
+ g_object_set (device, "model", up_device_hid_get_string (hid, value), NULL);
break;
- case DKP_DEVICE_HID_SERIAL_NUMBER:
- g_object_set (device, "serial", dkp_device_hid_get_string (hid, value), NULL);
+ case UP_DEVICE_HID_SERIAL_NUMBER:
+ g_object_set (device, "serial", up_device_hid_get_string (hid, value), NULL);
break;
- case DKP_DEVICE_HID_DESIGN_CAPACITY:
+ case UP_DEVICE_HID_DESIGN_CAPACITY:
g_object_set (device, "energy-full-design", (gfloat) value, NULL);
break;
default:
@@ -235,10 +235,10 @@ dkp_device_hid_set_values (DkpDeviceHid *hid, int code, int value)
}
/**
- * dkp_device_hid_get_all_data:
+ * up_device_hid_get_all_data:
**/
static gboolean
-dkp_device_hid_get_all_data (DkpDeviceHid *hid)
+up_device_hid_get_all_data (UpDeviceHid *hid)
{
struct hiddev_report_info rinfo;
struct hiddev_field_info finfo;
@@ -269,7 +269,7 @@ dkp_device_hid_get_all_data (DkpDeviceHid *hid)
ioctl (hid->priv->fd, HIDIOCGUSAGE, &uref);
/* process each */
- dkp_device_hid_set_values (hid, uref.usage_code, uref.value);
+ up_device_hid_set_values (hid, uref.usage_code, uref.value);
/* we got some data */
ret = TRUE;
@@ -282,10 +282,10 @@ dkp_device_hid_get_all_data (DkpDeviceHid *hid)
}
/**
- * dkp_device_hid_fixup_state:
+ * up_device_hid_fixup_state:
**/
static void
-dkp_device_hid_fixup_state (DkpDevice *device)
+up_device_hid_fixup_state (UpDevice *device)
{
gdouble percentage;
@@ -298,14 +298,14 @@ dkp_device_hid_fixup_state (DkpDevice *device)
}
/**
- * dkp_device_hid_coldplug:
+ * up_device_hid_coldplug:
*
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
**/
static gboolean
-dkp_device_hid_coldplug (DkpDevice *device)
+up_device_hid_coldplug (UpDevice *device)
{
- DkpDeviceHid *hid = DKP_DEVICE_HID (device);
+ UpDeviceHid *hid = UP_DEVICE_HID (device);
GUdevDevice *native;
gboolean ret = FALSE;
const gchar *device_file;
@@ -313,7 +313,7 @@ dkp_device_hid_coldplug (DkpDevice *device)
const gchar *vendor;
/* detect what kind of device we are */
- native = G_UDEV_DEVICE (dkp_device_get_native (device));
+ native = G_UDEV_DEVICE (up_device_get_native (device));
type = g_udev_device_get_property (native, "DKP_BATTERY_TYPE");
if (type == NULL || g_strcmp0 (type, "ups") != 0)
goto out;
@@ -334,7 +334,7 @@ dkp_device_hid_coldplug (DkpDevice *device)
}
/* first check that we are an UPS */
- ret = dkp_device_hid_is_ups (hid);
+ ret = up_device_hid_is_ups (hid);
if (!ret) {
egg_debug ("not a HID device: %s", device_file);
goto out;
@@ -357,25 +357,25 @@ dkp_device_hid_coldplug (DkpDevice *device)
NULL);
/* coldplug everything */
- ret = dkp_device_hid_get_all_data (hid);
+ ret = up_device_hid_get_all_data (hid);
if (!ret) {
egg_debug ("failed to coldplug: %s", device_file);
goto out;
}
/* fix up device states */
- dkp_device_hid_fixup_state (device);
+ up_device_hid_fixup_state (device);
out:
return ret;
}
/**
- * dkp_device_hid_refresh:
+ * up_device_hid_refresh:
*
* Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
-dkp_device_hid_refresh (DkpDevice *device)
+up_device_hid_refresh (UpDevice *device)
{
gboolean set = FALSE;
gboolean ret = FALSE;
@@ -383,7 +383,7 @@ dkp_device_hid_refresh (DkpDevice *device)
guint i;
struct hiddev_event ev[64];
int rd;
- DkpDeviceHid *hid = DKP_DEVICE_HID (device);
+ UpDeviceHid *hid = UP_DEVICE_HID (device);
/* read any data */
rd = read (hid->priv->fd, ev, sizeof (ev));
@@ -403,7 +403,7 @@ dkp_device_hid_refresh (DkpDevice *device)
/* process each event */
for (i=0; i < rd / sizeof (ev[0]); i++) {
- set = dkp_device_hid_set_values (hid, ev[i].hid, ev[i].value);
+ set = up_device_hid_set_values (hid, ev[i].hid, ev[i].value);
/* if only takes one match to make refresh a success */
if (set)
@@ -411,7 +411,7 @@ dkp_device_hid_refresh (DkpDevice *device)
}
/* fix up device states */
- dkp_device_hid_fixup_state (device);
+ up_device_hid_fixup_state (device);
/* reset time */
g_get_current_time (&timeval);
@@ -421,29 +421,29 @@ out:
}
/**
- * dkp_device_hid_init:
+ * up_device_hid_init:
**/
static void
-dkp_device_hid_init (DkpDeviceHid *hid)
+up_device_hid_init (UpDeviceHid *hid)
{
- hid->priv = DKP_DEVICE_HID_GET_PRIVATE (hid);
+ hid->priv = UP_DEVICE_HID_GET_PRIVATE (hid);
hid->priv->fd = -1;
- hid->priv->poll_timer_id = g_timeout_add_seconds (DKP_DEVICE_HID_REFRESH_TIMEOUT,
- (GSourceFunc) dkp_device_hid_poll, hid);
+ hid->priv->poll_timer_id = g_timeout_add_seconds (UP_DEVICE_HID_REFRESH_TIMEOUT,
+ (GSourceFunc) up_device_hid_poll, hid);
}
/**
- * dkp_device_hid_finalize:
+ * up_device_hid_finalize:
**/
static void
-dkp_device_hid_finalize (GObject *object)
+up_device_hid_finalize (GObject *object)
{
- DkpDeviceHid *hid;
+ UpDeviceHid *hid;
g_return_if_fail (object != NULL);
- g_return_if_fail (DKP_IS_HID (object));
+ g_return_if_fail (UP_IS_DEVICE_HID (object));
- hid = DKP_DEVICE_HID (object);
+ hid = UP_DEVICE_HID (object);
g_return_if_fail (hid->priv != NULL);
if (hid->priv->fd > 0)
@@ -451,31 +451,31 @@ dkp_device_hid_finalize (GObject *object)
if (hid->priv->poll_timer_id > 0)
g_source_remove (hid->priv->poll_timer_id);
- G_OBJECT_CLASS (dkp_device_hid_parent_class)->finalize (object);
+ G_OBJECT_CLASS (up_device_hid_parent_class)->finalize (object);
}
/**
- * dkp_device_hid_class_init:
+ * up_device_hid_class_init:
**/
static void
-dkp_device_hid_class_init (DkpDeviceHidClass *klass)
+up_device_hid_class_init (UpDeviceHidClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- DkpDeviceClass *device_class = DKP_DEVICE_CLASS (klass);
+ UpDeviceClass *device_class = UP_DEVICE_CLASS (klass);
- object_class->finalize = dkp_device_hid_finalize;
- device_class->coldplug = dkp_device_hid_coldplug;
- device_class->refresh = dkp_device_hid_refresh;
+ object_class->finalize = up_device_hid_finalize;
+ device_class->coldplug = up_device_hid_coldplug;
+ device_class->refresh = up_device_hid_refresh;
- g_type_class_add_private (klass, sizeof (DkpDeviceHidPrivate));
+ g_type_class_add_private (klass, sizeof (UpDeviceHidPrivate));
}
/**
- * dkp_device_hid_new:
+ * up_device_hid_new:
**/
-DkpDeviceHid *
-dkp_device_hid_new (void)
+UpDeviceHid *
+up_device_hid_new (void)
{
- return g_object_new (DKP_TYPE_HID, NULL);
+ return g_object_new (UP_TYPE_DEVICE_HID, NULL);
}
diff --git a/src/linux/up-device-hid.h b/src/linux/up-device-hid.h
index 7736c94..86bd4d7 100644
--- a/src/linux/up-device-hid.h
+++ b/src/linux/up-device-hid.h
@@ -18,38 +18,38 @@
*
*/
-#ifndef __DKP_DEVICE_HID_H__
-#define __DKP_DEVICE_HID_H__
+#ifndef __UP_DEVICE_HID_H__
+#define __UP_DEVICE_HID_H__
#include <glib-object.h>
#include "up-device.h"
G_BEGIN_DECLS
-#define DKP_TYPE_HID (dkp_device_hid_get_type ())
-#define DKP_DEVICE_HID(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DKP_TYPE_HID, DkpDeviceHid))
-#define DKP_DEVICE_HID_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DKP_TYPE_HID, DkpDeviceHidClass))
-#define DKP_IS_HID(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DKP_TYPE_HID))
-#define DKP_IS_HID_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DKP_TYPE_HID))
-#define DKP_DEVICE_HID_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DKP_TYPE_HID, DkpDeviceHidClass))
+#define UP_TYPE_DEVICE_HID (up_device_hid_get_type ())
+#define UP_DEVICE_HID(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_DEVICE_HID, UpDeviceHid))
+#define UP_DEVICE_HID_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_DEVICE_HID, UpDeviceHidClass))
+#define UP_IS_DEVICE_HID(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_DEVICE_HID))
+#define UP_IS_DEVICE_HID_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_DEVICE_HID))
+#define UP_DEVICE_HID_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_DEVICE_HID, UpDeviceHidClass))
-typedef struct DkpDeviceHidPrivate DkpDeviceHidPrivate;
+typedef struct UpDeviceHidPrivate UpDeviceHidPrivate;
typedef struct
{
- DkpDevice parent;
- DkpDeviceHidPrivate *priv;
-} DkpDeviceHid;
+ UpDevice parent;
+ UpDeviceHidPrivate *priv;
+} UpDeviceHid;
typedef struct
{
- DkpDeviceClass parent_class;
-} DkpDeviceHidClass;
+ UpDeviceClass parent_class;
+} UpDeviceHidClass;
-GType dkp_device_hid_get_type (void);
-DkpDeviceHid *dkp_device_hid_new (void);
+GType up_device_hid_get_type (void);
+UpDeviceHid *up_device_hid_new (void);
G_END_DECLS
-#endif /* __DKP_DEVICE_HID_H__ */
+#endif /* __UP_DEVICE_HID_H__ */
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index cd7c6cb..d60f896 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -39,12 +39,12 @@
#include "up-enum.h"
#include "up-device-supply.h"
-#define DKP_DEVICE_SUPPLY_REFRESH_TIMEOUT 30 /* seconds */
-#define DKP_DEVICE_SUPPLY_UNKNOWN_TIMEOUT 2 /* seconds */
-#define DKP_DEVICE_SUPPLY_UNKNOWN_RETRIES 30
-#define DKP_DEVICE_SUPPLY_CHARGED_THRESHOLD 90.0f /* % */
+#define UP_DEVICE_SUPPLY_REFRESH_TIMEOUT 30 /* seconds */
+#define UP_DEVICE_SUPPLY_UNKNOWN_TIMEOUT 2 /* seconds */
+#define UP_DEVICE_SUPPLY_UNKNOWN_RETRIES 30
+#define UP_DEVICE_SUPPLY_CHARGED_THRESHOLD 90.0f /* % */
-struct DkpDeviceSupplyPrivate
+struct UpDeviceSupplyPrivate
{
guint poll_timer_id;
gboolean has_coldplug_values;
@@ -54,20 +54,20 @@ struct DkpDeviceSupplyPrivate
gboolean enable_poll;
};
-G_DEFINE_TYPE (DkpDeviceSupply, dkp_device_supply, DKP_TYPE_DEVICE)
-#define DKP_DEVICE_SUPPLY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_SUPPLY, DkpDeviceSupplyPrivate))
+G_DEFINE_TYPE (UpDeviceSupply, up_device_supply, UP_TYPE_DEVICE)
+#define UP_DEVICE_SUPPLY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE_SUPPLY, UpDeviceSupplyPrivate))
-static gboolean dkp_device_supply_refresh (DkpDevice *device);
+static gboolean up_device_supply_refresh (UpDevice *device);
/**
- * dkp_device_supply_refresh_line_power:
+ * up_device_supply_refresh_line_power:
*
* Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
-dkp_device_supply_refresh_line_power (DkpDeviceSupply *supply)
+up_device_supply_refresh_line_power (UpDeviceSupply *supply)
{
- DkpDevice *device = DKP_DEVICE (supply);
+ UpDevice *device = UP_DEVICE (supply);
GUdevDevice *native;
const gchar *native_path;
@@ -75,7 +75,7 @@ dkp_device_supply_refresh_line_power (DkpDeviceSupply *supply)
g_object_set (device, "power-supply", TRUE, NULL);
/* get new AC value */
- native = G_UDEV_DEVICE (dkp_device_get_native (device));
+ native = G_UDEV_DEVICE (up_device_get_native (device));
native_path = g_udev_device_get_sysfs_path (native);
g_object_set (device, "online", sysfs_get_int (native_path, "online"), NULL);
@@ -83,12 +83,12 @@ dkp_device_supply_refresh_line_power (DkpDeviceSupply *supply)
}
/**
- * dkp_device_supply_reset_values:
+ * up_device_supply_reset_values:
**/
static void
-dkp_device_supply_reset_values (DkpDeviceSupply *supply)
+up_device_supply_reset_values (UpDeviceSupply *supply)
{
- DkpDevice *device = DKP_DEVICE (supply);
+ UpDevice *device = UP_DEVICE (supply);
supply->priv->has_coldplug_values = FALSE;
supply->priv->energy_old = 0;
@@ -122,17 +122,17 @@ dkp_device_supply_reset_values (DkpDeviceSupply *supply)
}
/**
- * dkp_device_supply_get_on_battery:
+ * up_device_supply_get_on_battery:
**/
static gboolean
-dkp_device_supply_get_on_battery (DkpDevice *device, gboolean *on_battery)
+up_device_supply_get_on_battery (UpDevice *device, gboolean *on_battery)
{
- DkpDeviceSupply *supply = DKP_DEVICE_SUPPLY (device);
- DkpDeviceType type;
- DkpDeviceState state;
+ UpDeviceSupply *supply = UP_DEVICE_SUPPLY (device);
+ UpDeviceType type;
+ UpDeviceState state;
gboolean is_present;
- g_return_val_if_fail (DKP_IS_SUPPLY (supply), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE_SUPPLY (supply), FALSE);
g_return_val_if_fail (on_battery != NULL, FALSE);
g_object_get (device,
@@ -153,21 +153,21 @@ dkp_device_supply_get_on_battery (DkpDevice *device, gboolean *on_battery)
}
/**
- * dkp_device_supply_get_low_battery:
+ * up_device_supply_get_low_battery:
**/
static gboolean
-dkp_device_supply_get_low_battery (DkpDevice *device, gboolean *low_battery)
+up_device_supply_get_low_battery (UpDevice *device, gboolean *low_battery)
{
gboolean ret;
gboolean on_battery;
- DkpDeviceSupply *supply = DKP_DEVICE_SUPPLY (device);
+ UpDeviceSupply *supply = UP_DEVICE_SUPPLY (device);
gdouble percentage;
- g_return_val_if_fail (DKP_IS_SUPPLY (supply), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE_SUPPLY (supply), FALSE);
g_return_val_if_fail (low_battery != NULL, FALSE);
/* reuse the common checks */
- ret = dkp_device_supply_get_on_battery (device, &on_battery);
+ ret = up_device_supply_get_on_battery (device, &on_battery);
if (!ret)
return FALSE;
@@ -183,16 +183,16 @@ dkp_device_supply_get_low_battery (DkpDevice *device, gboolean *low_battery)
}
/**
- * dkp_device_supply_get_online:
+ * up_device_supply_get_online:
**/
static gboolean
-dkp_device_supply_get_online (DkpDevice *device, gboolean *online)
+up_device_supply_get_online (UpDevice *device, gboolean *online)
{
- DkpDeviceSupply *supply = DKP_DEVICE_SUPPLY (device);
- DkpDeviceType type;
+ UpDeviceSupply *supply = UP_DEVICE_SUPPLY (device);
+ UpDeviceType type;
gboolean online_tmp;
- g_return_val_if_fail (DKP_IS_SUPPLY (supply), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE_SUPPLY (supply), FALSE);
g_return_val_if_fail (online != NULL, FALSE);
g_object_get (device,
@@ -209,16 +209,16 @@ dkp_device_supply_get_online (DkpDevice *device, gboolean *online)
}
/**
- * dkp_device_supply_calculate_rate:
+ * up_device_supply_calculate_rate:
**/
static void
-dkp_device_supply_calculate_rate (DkpDeviceSupply *supply)
+up_device_supply_calculate_rate (UpDeviceSupply *supply)
{
guint time_s;
gdouble energy;
gdouble energy_rate;
GTimeVal now;
- DkpDevice *device = DKP_DEVICE (supply);
+ UpDevice *device = UP_DEVICE (supply);
g_object_get (device, "energy", &energy, NULL);
@@ -249,10 +249,10 @@ dkp_device_supply_calculate_rate (DkpDeviceSupply *supply)
}
/**
- * dkp_device_supply_convert_device_technology:
+ * up_device_supply_convert_device_technology:
**/
-static DkpDeviceTechnology
-dkp_device_supply_convert_device_technology (const gchar *type)
+static UpDeviceTechnology
+up_device_supply_convert_device_technology (const gchar *type)
{
if (type == NULL)
return DKP_DEVICE_TECHNOLOGY_UNKNOWN;
@@ -275,10 +275,10 @@ dkp_device_supply_convert_device_technology (const gchar *type)
}
/**
- * dkp_device_supply_get_string:
+ * up_device_supply_get_string:
**/
static gchar *
-dkp_device_supply_get_string (const gchar *native_path, const gchar *key)
+up_device_supply_get_string (const gchar *native_path, const gchar *key)
{
gchar *value;
@@ -300,10 +300,10 @@ out:
}
/**
- * dkp_device_supply_get_design_voltage:
+ * up_device_supply_get_design_voltage:
**/
static gdouble
-dkp_device_supply_get_design_voltage (const gchar *native_path)
+up_device_supply_get_design_voltage (const gchar *native_path)
{
gdouble voltage;
@@ -343,10 +343,10 @@ out:
}
/**
- * dkp_device_supply_make_safe_string:
+ * up_device_supply_make_safe_string:
**/
static void
-dkp_device_supply_make_safe_string (gchar *text)
+up_device_supply_make_safe_string (gchar *text)
{
guint i;
guint idx = 0;
@@ -372,20 +372,20 @@ dkp_device_supply_make_safe_string (gchar *text)
}
/**
- * dkp_device_supply_refresh_battery:
+ * up_device_supply_refresh_battery:
*
* Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
-dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
+up_device_supply_refresh_battery (UpDeviceSupply *supply)
{
gchar *status = NULL;
gchar *technology_native = NULL;
gboolean ret = TRUE;
gdouble voltage_design;
- DkpDeviceState old_state;
- DkpDeviceState state;
- DkpDevice *device = DKP_DEVICE (supply);
+ UpDeviceState old_state;
+ UpDeviceState state;
+ UpDevice *device = UP_DEVICE (supply);
const gchar *native_path;
GUdevDevice *native;
gboolean is_present;
@@ -408,14 +408,14 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
gboolean on_battery;
guint battery_count;
- native = G_UDEV_DEVICE (dkp_device_get_native (device));
+ native = G_UDEV_DEVICE (up_device_get_native (device));
native_path = g_udev_device_get_sysfs_path (native);
/* have we just been removed? */
is_present = sysfs_get_bool (native_path, "present");
g_object_set (device, "is-present", is_present, NULL);
if (!is_present) {
- dkp_device_supply_reset_values (supply);
+ up_device_supply_reset_values (supply);
goto out;
}
@@ -425,7 +425,7 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
energy = sysfs_get_double (native_path, "energy_avg") / 1000000.0;
/* used to convert A to W later */
- voltage_design = dkp_device_supply_get_design_voltage (native_path);
+ voltage_design = up_device_supply_get_design_voltage (native_path);
/* initial values */
if (!supply->priv->has_coldplug_values) {
@@ -434,18 +434,18 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
g_object_set (device, "power-supply", TRUE, NULL);
/* the ACPI spec is bad at defining battery type constants */
- technology_native = dkp_device_supply_get_string (native_path, "technology");
- g_object_set (device, "technology", dkp_device_supply_convert_device_technology (technology_native), NULL);
+ technology_native = up_device_supply_get_string (native_path, "technology");
+ g_object_set (device, "technology", up_device_supply_convert_device_technology (technology_native), NULL);
/* get values which may be blank */
- manufacturer = dkp_device_supply_get_string (native_path, "manufacturer");
- model_name = dkp_device_supply_get_string (native_path, "model_name");
- serial_number = dkp_device_supply_get_string (native_path, "serial_number");
+ manufacturer = up_device_supply_get_string (native_path, "manufacturer");
+ model_name = up_device_supply_get_string (native_path, "model_name");
+ serial_number = up_device_supply_get_string (native_path, "serial_number");
/* some vendors fill this with binary garbage */
- dkp_device_supply_make_safe_string (manufacturer);
- dkp_device_supply_make_safe_string (model_name);
- dkp_device_supply_make_safe_string (serial_number);
+ up_device_supply_make_safe_string (manufacturer);
+ up_device_supply_make_safe_string (model_name);
+ up_device_supply_make_safe_string (serial_number);
/* are we possibly recalled by the vendor? */
recall_notice = g_udev_device_has_property (native, "DKP_RECALL_NOTICE");
@@ -571,7 +571,7 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
/* the hardware reporting failed -- try to calculate this */
if (energy_rate < 0)
- dkp_device_supply_calculate_rate (supply);
+ up_device_supply_calculate_rate (supply);
/* get a precise percentage */
if (energy_full > 0.0f) {
@@ -584,7 +584,7 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
/* some batteries stop charging much before 100% */
if (state == DKP_DEVICE_STATE_UNKNOWN &&
- percentage > DKP_DEVICE_SUPPLY_CHARGED_THRESHOLD) {
+ percentage > UP_DEVICE_SUPPLY_CHARGED_THRESHOLD) {
egg_debug ("fixing up unknown %f", percentage);
state = DKP_DEVICE_STATE_FULLY_CHARGED;
}
@@ -594,7 +594,7 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
if (state == DKP_DEVICE_STATE_UNKNOWN) {
/* get global battery status */
- daemon = dkp_device_get_daemon (device);
+ daemon = up_device_get_daemon (device);
g_object_get (daemon,
"on-battery", &on_battery,
NULL);
@@ -626,7 +626,7 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply)
/* print what we did */
egg_debug ("guessing battery state '%s' using global on-battery:%i",
- dkp_device_state_to_text (state), on_battery);
+ up_device_state_to_text (state), on_battery);
g_object_unref (daemon);
}
@@ -690,40 +690,40 @@ out:
}
/**
- * dkp_device_supply_poll_battery:
+ * up_device_supply_poll_battery:
**/
static gboolean
-dkp_device_supply_poll_battery (DkpDeviceSupply *supply)
+up_device_supply_poll_battery (UpDeviceSupply *supply)
{
- DkpDevice *device = DKP_DEVICE (supply);
+ UpDevice *device = UP_DEVICE (supply);
- egg_debug ("No updates on supply %s for %i seconds; forcing update", dkp_device_get_object_path (device), DKP_DEVICE_SUPPLY_REFRESH_TIMEOUT);
+ egg_debug ("No updates on supply %s for %i seconds; forcing update", up_device_get_object_path (device), UP_DEVICE_SUPPLY_REFRESH_TIMEOUT);
supply->priv->poll_timer_id = 0;
- dkp_device_supply_refresh (device);
+ up_device_supply_refresh (device);
/* never repeat */
return FALSE;
}
/**
- * dkp_device_supply_coldplug:
+ * up_device_supply_coldplug:
*
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
**/
static gboolean
-dkp_device_supply_coldplug (DkpDevice *device)
+up_device_supply_coldplug (UpDevice *device)
{
- DkpDeviceSupply *supply = DKP_DEVICE_SUPPLY (device);
+ UpDeviceSupply *supply = UP_DEVICE_SUPPLY (device);
gboolean ret = FALSE;
GUdevDevice *native;
const gchar *native_path;
gchar *device_type = NULL;
- DkpDeviceType type = DKP_DEVICE_TYPE_UNKNOWN;
+ UpDeviceType type = DKP_DEVICE_TYPE_UNKNOWN;
- dkp_device_supply_reset_values (supply);
+ up_device_supply_reset_values (supply);
/* detect what kind of device we are */
- native = G_UDEV_DEVICE (dkp_device_get_native (device));
+ native = G_UDEV_DEVICE (up_device_get_native (device));
native_path = g_udev_device_get_sysfs_path (native);
if (native_path == NULL) {
egg_warning ("could not get native path for %p", device);
@@ -731,7 +731,7 @@ dkp_device_supply_coldplug (DkpDevice *device)
}
/* try to detect using the device type */
- device_type = dkp_device_supply_get_string (native_path, "type");
+ device_type = up_device_supply_get_string (native_path, "type");
if (device_type != NULL) {
if (g_ascii_strcasecmp (device_type, "mains") == 0) {
type = DKP_DEVICE_TYPE_LINE_POWER;
@@ -756,20 +756,20 @@ dkp_device_supply_coldplug (DkpDevice *device)
g_object_set (device, "type", type, NULL);
/* coldplug values */
- ret = dkp_device_supply_refresh (device);
+ ret = up_device_supply_refresh (device);
out:
g_free (device_type);
return ret;
}
/**
- * dkp_device_supply_setup_poll:
+ * up_device_supply_setup_poll:
**/
static gboolean
-dkp_device_supply_setup_poll (DkpDevice *device)
+up_device_supply_setup_poll (UpDevice *device)
{
- DkpDeviceState state;
- DkpDeviceSupply *supply = DKP_DEVICE_SUPPLY (device);
+ UpDeviceState state;
+ UpDeviceSupply *supply = UP_DEVICE_SUPPLY (device);
g_object_get (device, "state", &state, NULL);
@@ -779,10 +779,10 @@ dkp_device_supply_setup_poll (DkpDevice *device)
/* if it's unknown, poll faster than we would normally */
if (state == DKP_DEVICE_STATE_UNKNOWN &&
- supply->priv->unknown_retries < DKP_DEVICE_SUPPLY_UNKNOWN_RETRIES) {
+ supply->priv->unknown_retries < UP_DEVICE_SUPPLY_UNKNOWN_RETRIES) {
supply->priv->poll_timer_id =
- g_timeout_add_seconds (DKP_DEVICE_SUPPLY_UNKNOWN_TIMEOUT,
- (GSourceFunc) dkp_device_supply_poll_battery, supply);
+ g_timeout_add_seconds (UP_DEVICE_SUPPLY_UNKNOWN_TIMEOUT,
+ (GSourceFunc) up_device_supply_poll_battery, supply);
/* increase count, we don't want to poll at 0.5Hz forever */
supply->priv->unknown_retries++;
goto out;
@@ -790,24 +790,24 @@ dkp_device_supply_setup_poll (DkpDevice *device)
/* any other state just fall back */
supply->priv->poll_timer_id =
- g_timeout_add_seconds (DKP_DEVICE_SUPPLY_REFRESH_TIMEOUT,
- (GSourceFunc) dkp_device_supply_poll_battery, supply);
+ g_timeout_add_seconds (UP_DEVICE_SUPPLY_REFRESH_TIMEOUT,
+ (GSourceFunc) up_device_supply_poll_battery, supply);
out:
return (supply->priv->poll_timer_id != 0);
}
/**
- * dkp_device_supply_refresh:
+ * up_device_supply_refresh:
*
* Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
-dkp_device_supply_refresh (DkpDevice *device)
+up_device_supply_refresh (UpDevice *device)
{
gboolean ret;
GTimeVal timeval;
- DkpDeviceSupply *supply = DKP_DEVICE_SUPPLY (device);
- DkpDeviceType type;
+ UpDeviceSupply *supply = UP_DEVICE_SUPPLY (device);
+ UpDeviceType type;
if (supply->priv->poll_timer_id > 0) {
g_source_remove (supply->priv->poll_timer_id);
@@ -817,14 +817,14 @@ dkp_device_supply_refresh (DkpDevice *device)
g_object_get (device, "type", &type, NULL);
switch (type) {
case DKP_DEVICE_TYPE_LINE_POWER:
- ret = dkp_device_supply_refresh_line_power (supply);
+ ret = up_device_supply_refresh_line_power (supply);
break;
case DKP_DEVICE_TYPE_BATTERY:
- ret = dkp_device_supply_refresh_battery (supply);
+ ret = up_device_supply_refresh_battery (supply);
/* Seems that we don't get change uevents from the
* kernel on some BIOS types */
- dkp_device_supply_setup_poll (device);
+ up_device_supply_setup_poll (device);
break;
default:
g_assert_not_reached ();
@@ -841,62 +841,62 @@ dkp_device_supply_refresh (DkpDevice *device)
}
/**
- * dkp_device_supply_init:
+ * up_device_supply_init:
**/
static void
-dkp_device_supply_init (DkpDeviceSupply *supply)
+up_device_supply_init (UpDeviceSupply *supply)
{
- supply->priv = DKP_DEVICE_SUPPLY_GET_PRIVATE (supply);
+ supply->priv = UP_DEVICE_SUPPLY_GET_PRIVATE (supply);
supply->priv->unknown_retries = 0;
supply->priv->poll_timer_id = 0;
supply->priv->enable_poll = TRUE;
}
/**
- * dkp_device_supply_finalize:
+ * up_device_supply_finalize:
**/
static void
-dkp_device_supply_finalize (GObject *object)
+up_device_supply_finalize (GObject *object)
{
- DkpDeviceSupply *supply;
+ UpDeviceSupply *supply;
g_return_if_fail (object != NULL);
- g_return_if_fail (DKP_IS_SUPPLY (object));
+ g_return_if_fail (UP_IS_DEVICE_SUPPLY (object));
- supply = DKP_DEVICE_SUPPLY (object);
+ supply = UP_DEVICE_SUPPLY (object);
g_return_if_fail (supply->priv != NULL);
if (supply->priv->poll_timer_id > 0)
g_source_remove (supply->priv->poll_timer_id);
- G_OBJECT_CLASS (dkp_device_supply_parent_class)->finalize (object);
+ G_OBJECT_CLASS (up_device_supply_parent_class)->finalize (object);
}
/**
- * dkp_device_supply_class_init:
+ * up_device_supply_class_init:
**/
static void
-dkp_device_supply_class_init (DkpDeviceSupplyClass *klass)
+up_device_supply_class_init (UpDeviceSupplyClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- DkpDeviceClass *device_class = DKP_DEVICE_CLASS (klass);
+ UpDeviceClass *device_class = UP_DEVICE_CLASS (klass);
- object_class->finalize = dkp_device_supply_finalize;
- device_class->get_on_battery = dkp_device_supply_get_on_battery;
- device_class->get_low_battery = dkp_device_supply_get_low_battery;
- device_class->get_online = dkp_device_supply_get_online;
- device_class->coldplug = dkp_device_supply_coldplug;
- device_class->refresh = dkp_device_supply_refresh;
+ object_class->finalize = up_device_supply_finalize;
+ device_class->get_on_battery = up_device_supply_get_on_battery;
+ device_class->get_low_battery = up_device_supply_get_low_battery;
+ device_class->get_online = up_device_supply_get_online;
+ device_class->coldplug = up_device_supply_coldplug;
+ device_class->refresh = up_device_supply_refresh;
- g_type_class_add_private (klass, sizeof (DkpDeviceSupplyPrivate));
+ g_type_class_add_private (klass, sizeof (UpDeviceSupplyPrivate));
}
/**
- * dkp_device_supply_new:
+ * up_device_supply_new:
**/
-DkpDeviceSupply *
-dkp_device_supply_new (void)
+UpDeviceSupply *
+up_device_supply_new (void)
{
- return g_object_new (DKP_TYPE_SUPPLY, NULL);
+ return g_object_new (UP_TYPE_DEVICE_SUPPLY, NULL);
}
diff --git a/src/linux/up-device-supply.h b/src/linux/up-device-supply.h
index e1b042f..a83c0fd 100644
--- a/src/linux/up-device-supply.h
+++ b/src/linux/up-device-supply.h
@@ -19,38 +19,38 @@
*
*/
-#ifndef __DKP_DEVICE_SUPPLY_H__
-#define __DKP_DEVICE_SUPPLY_H__
+#ifndef __UP_DEVICE_SUPPLY_H__
+#define __UP_DEVICE_SUPPLY_H__
#include <glib-object.h>
#include "up-device.h"
G_BEGIN_DECLS
-#define DKP_TYPE_SUPPLY (dkp_device_supply_get_type ())
-#define DKP_DEVICE_SUPPLY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DKP_TYPE_SUPPLY, DkpDeviceSupply))
-#define DKP_DEVICE_SUPPLY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DKP_TYPE_SUPPLY, DkpDeviceSupplyClass))
-#define DKP_IS_SUPPLY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DKP_TYPE_SUPPLY))
-#define DKP_IS_SUPPLY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DKP_TYPE_SUPPLY))
-#define DKP_DEVICE_SUPPLY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DKP_TYPE_SUPPLY, DkpDeviceSupplyClass))
+#define UP_TYPE_DEVICE_SUPPLY (up_device_supply_get_type ())
+#define UP_DEVICE_SUPPLY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_DEVICE_SUPPLY, UpDeviceSupply))
+#define UP_DEVICE_SUPPLY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_DEVICE_SUPPLY, UpDeviceSupplyClass))
+#define UP_IS_DEVICE_SUPPLY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_DEVICE_SUPPLY))
+#define UP_IS_DEVICE_SUPPLY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_DEVICE_SUPPLY))
+#define UP_DEVICE_SUPPLY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_DEVICE_SUPPLY, UpDeviceSupplyClass))
-typedef struct DkpDeviceSupplyPrivate DkpDeviceSupplyPrivate;
+typedef struct UpDeviceSupplyPrivate UpDeviceSupplyPrivate;
typedef struct
{
- DkpDevice parent;
- DkpDeviceSupplyPrivate *priv;
-} DkpDeviceSupply;
+ UpDevice parent;
+ UpDeviceSupplyPrivate *priv;
+} UpDeviceSupply;
typedef struct
{
- DkpDeviceClass parent_class;
-} DkpDeviceSupplyClass;
+ UpDeviceClass parent_class;
+} UpDeviceSupplyClass;
-GType dkp_device_supply_get_type (void);
-DkpDeviceSupply *dkp_device_supply_new (void);
+GType up_device_supply_get_type (void);
+UpDeviceSupply *up_device_supply_new (void);
G_END_DECLS
-#endif /* __DKP_DEVICE_SUPPLY_H__ */
+#endif /* __UP_DEVICE_SUPPLY_H__ */
diff --git a/src/linux/up-device-wup.c b/src/linux/up-device-wup.c
index 8fc3296..96aec4f 100644
--- a/src/linux/up-device-wup.c
+++ b/src/linux/up-device-wup.c
@@ -47,58 +47,58 @@
#include "up-enum.h"
#include "up-device-wup.h"
-#define DKP_DEVICE_WUP_REFRESH_TIMEOUT 10 /* seconds */
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_WATTS 0x0
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_VOLTS 0x1
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_AMPS 0x2
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_KWH 0x3
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_COST 0x4
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_MONTHLY_KWH 0x5
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_MONTHLY_COST 0x6
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_MAX_WATTS 0x7
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_MAX_VOLTS 0x8
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_MAX_AMPS 0x9
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_MIN_WATTS 0xa
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_MIN_VOLTS 0xb
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_MIN_AMPS 0xc
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_POWER_FACTOR 0xd
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_DUTY_CYCLE 0xe
-#define DKP_DEVICE_WUP_RESPONSE_OFFSET_POWER_CYCLE 0xf
+#define UP_DEVICE_WUP_REFRESH_TIMEOUT 10 /* seconds */
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_WATTS 0x0
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_VOLTS 0x1
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_AMPS 0x2
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_KWH 0x3
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_COST 0x4
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_MONTHLY_KWH 0x5
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_MONTHLY_COST 0x6
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_MAX_WATTS 0x7
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_MAX_VOLTS 0x8
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_MAX_AMPS 0x9
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_MIN_WATTS 0xa
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_MIN_VOLTS 0xb
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_MIN_AMPS 0xc
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_POWER_FACTOR 0xd
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_DUTY_CYCLE 0xe
+#define UP_DEVICE_WUP_RESPONSE_OFFSET_POWER_CYCLE 0xf
/* commands can never be bigger then this */
-#define DKP_DEVICE_WUP_COMMAND_LEN 256
+#define UP_DEVICE_WUP_COMMAND_LEN 256
-struct DkpDeviceWupPrivate
+struct UpDeviceWupPrivate
{
guint poll_timer_id;
int fd;
};
-G_DEFINE_TYPE (DkpDeviceWup, dkp_device_wup, DKP_TYPE_DEVICE)
-#define DKP_DEVICE_WUP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_WUP, DkpDeviceWupPrivate))
+G_DEFINE_TYPE (UpDeviceWup, up_device_wup, UP_TYPE_DEVICE)
+#define UP_DEVICE_WUP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE_WUP, UpDeviceWupPrivate))
-static gboolean dkp_device_wup_refresh (DkpDevice *device);
+static gboolean up_device_wup_refresh (UpDevice *device);
/**
- * dkp_device_wup_poll_cb:
+ * up_device_wup_poll_cb:
**/
static gboolean
-dkp_device_wup_poll_cb (DkpDeviceWup *wup)
+up_device_wup_poll_cb (UpDeviceWup *wup)
{
- DkpDevice *device = DKP_DEVICE (wup);
+ UpDevice *device = UP_DEVICE (wup);
- egg_debug ("Polling: %s", dkp_device_get_object_path (device));
- dkp_device_wup_refresh (device);
+ egg_debug ("Polling: %s", up_device_get_object_path (device));
+ up_device_wup_refresh (device);
/* always continue polling */
return TRUE;
}
/**
- * dkp_device_wup_set_speed:
+ * up_device_wup_set_speed:
**/
static gboolean
-dkp_device_wup_set_speed (DkpDeviceWup *wup)
+up_device_wup_set_speed (UpDeviceWup *wup)
{
struct termios t;
int retval;
@@ -126,12 +126,12 @@ dkp_device_wup_set_speed (DkpDeviceWup *wup)
}
/**
- * dkp_device_wup_write_command:
+ * up_device_wup_write_command:
*
* data: a command string in the form "#command,subcommand,datalen,data[n]", e.g. "#R,W,0"
**/
static gboolean
-dkp_device_wup_write_command (DkpDeviceWup *wup, const gchar *data)
+up_device_wup_write_command (UpDeviceWup *wup, const gchar *data)
{
guint ret = TRUE;
gint retval;
@@ -148,16 +148,16 @@ dkp_device_wup_write_command (DkpDeviceWup *wup, const gchar *data)
}
/**
- * dkp_device_wup_read_command:
+ * up_device_wup_read_command:
*
* Return value: Some data to parse
**/
static gchar *
-dkp_device_wup_read_command (DkpDeviceWup *wup)
+up_device_wup_read_command (UpDeviceWup *wup)
{
int retval;
- gchar buffer[DKP_DEVICE_WUP_COMMAND_LEN];
- retval = read (wup->priv->fd, &buffer, DKP_DEVICE_WUP_COMMAND_LEN);
+ gchar buffer[UP_DEVICE_WUP_COMMAND_LEN];
+ retval = read (wup->priv->fd, &buffer, UP_DEVICE_WUP_COMMAND_LEN);
if (retval < 0) {
egg_debug ("failed to read from fd: %s", strerror (errno));
return NULL;
@@ -166,12 +166,12 @@ dkp_device_wup_read_command (DkpDeviceWup *wup)
}
/**
- * dkp_device_wup_parse_command:
+ * up_device_wup_parse_command:
*
* Return value: Som data to parse
**/
static gboolean
-dkp_device_wup_parse_command (DkpDeviceWup *wup, const gchar *data)
+up_device_wup_parse_command (UpDeviceWup *wup, const gchar *data)
{
gboolean ret = FALSE;
gchar command;
@@ -182,7 +182,7 @@ dkp_device_wup_parse_command (DkpDeviceWup *wup, const gchar *data)
guint size;
guint length;
guint number_tokens;
- DkpDevice *device = DKP_DEVICE (wup);
+ UpDevice *device = UP_DEVICE (wup);
const guint offset = 3;
/* invalid */
@@ -272,8 +272,8 @@ dkp_device_wup_parse_command (DkpDeviceWup *wup, const gchar *data)
/* update the command fields */
if (command == 'd' && subcommand == '-' && number_tokens - offset == 18) {
g_object_set (device,
- "energy-rate", strtod (tokens[offset+DKP_DEVICE_WUP_RESPONSE_OFFSET_WATTS], NULL) / 10.0f,
- "voltage", strtod (tokens[offset+DKP_DEVICE_WUP_RESPONSE_OFFSET_VOLTS], NULL) / 10.0f,
+ "energy-rate", strtod (tokens[offset+UP_DEVICE_WUP_RESPONSE_OFFSET_WATTS], NULL) / 10.0f,
+ "voltage", strtod (tokens[offset+UP_DEVICE_WUP_RESPONSE_OFFSET_VOLTS], NULL) / 10.0f,
NULL);
ret = TRUE;
} else {
@@ -287,14 +287,14 @@ out:
}
/**
- * dkp_device_wup_coldplug:
+ * up_device_wup_coldplug:
*
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
**/
static gboolean
-dkp_device_wup_coldplug (DkpDevice *device)
+up_device_wup_coldplug (UpDevice *device)
{
- DkpDeviceWup *wup = DKP_DEVICE_WUP (device);
+ UpDeviceWup *wup = UP_DEVICE_WUP (device);
GUdevDevice *native;
gboolean ret = FALSE;
const gchar *device_file;
@@ -305,7 +305,7 @@ dkp_device_wup_coldplug (DkpDevice *device)
const gchar *product;
/* detect what kind of device we are */
- native = G_UDEV_DEVICE (dkp_device_get_native (device));
+ native = G_UDEV_DEVICE (up_device_get_native (device));
type = g_udev_device_get_property (native, "DKP_MONITOR_TYPE");
if (type == NULL || g_strcmp0 (type, "wup") != 0)
goto out;
@@ -326,30 +326,30 @@ dkp_device_wup_coldplug (DkpDevice *device)
egg_debug ("opened %s", device_file);
/* set speed */
- ret = dkp_device_wup_set_speed (wup);
+ ret = up_device_wup_set_speed (wup);
if (!ret) {
egg_debug ("not a WUP device (cannot set speed): %s", device_file);
goto out;
}
/* attempt to clear */
- ret = dkp_device_wup_write_command (wup, "#R,W,0;");
+ ret = up_device_wup_write_command (wup, "#R,W,0;");
if (!ret)
egg_debug ("failed to clear, nonfatal");
/* setup logging interval */
- data = g_strdup_printf ("#L,W,3,E,1,%i;", DKP_DEVICE_WUP_REFRESH_TIMEOUT);
- ret = dkp_device_wup_write_command (wup, data);
+ data = g_strdup_printf ("#L,W,3,E,1,%i;", UP_DEVICE_WUP_REFRESH_TIMEOUT);
+ ret = up_device_wup_write_command (wup, data);
if (!ret)
egg_debug ("failed to setup logging interval, nonfatal");
g_free (data);
/* dummy read */
- data = dkp_device_wup_read_command (wup);
+ data = up_device_wup_read_command (wup);
egg_debug ("data after clear %s", data);
/* shouldn't do anything */
- dkp_device_wup_parse_command (wup, data);
+ up_device_wup_parse_command (wup, data);
g_free (data);
/* prefer DKP names */
@@ -376,7 +376,7 @@ dkp_device_wup_coldplug (DkpDevice *device)
/* coldplug */
egg_debug ("coldplug");
- dkp_device_wup_refresh (device);
+ up_device_wup_refresh (device);
/* hardcode true, as we'll retry later if busy */
ret = TRUE;
@@ -386,27 +386,27 @@ out:
}
/**
- * dkp_device_wup_refresh:
+ * up_device_wup_refresh:
*
* Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
-dkp_device_wup_refresh (DkpDevice *device)
+up_device_wup_refresh (UpDevice *device)
{
gboolean ret = FALSE;
GTimeVal timeval;
gchar *data = NULL;
- DkpDeviceWup *wup = DKP_DEVICE_WUP (device);
+ UpDeviceWup *wup = UP_DEVICE_WUP (device);
/* get data */
- data = dkp_device_wup_read_command (wup);
+ data = up_device_wup_read_command (wup);
if (data == NULL) {
egg_debug ("no data");
goto out;
}
/* parse */
- ret = dkp_device_wup_parse_command (wup, data);
+ ret = up_device_wup_parse_command (wup, data);
if (!ret) {
egg_debug ("failed to parse %s", data);
goto out;
@@ -423,29 +423,29 @@ out:
}
/**
- * dkp_device_wup_init:
+ * up_device_wup_init:
**/
static void
-dkp_device_wup_init (DkpDeviceWup *wup)
+up_device_wup_init (UpDeviceWup *wup)
{
- wup->priv = DKP_DEVICE_WUP_GET_PRIVATE (wup);
+ wup->priv = UP_DEVICE_WUP_GET_PRIVATE (wup);
wup->priv->fd = -1;
- wup->priv->poll_timer_id = g_timeout_add_seconds (DKP_DEVICE_WUP_REFRESH_TIMEOUT,
- (GSourceFunc) dkp_device_wup_poll_cb, wup);
+ wup->priv->poll_timer_id = g_timeout_add_seconds (UP_DEVICE_WUP_REFRESH_TIMEOUT,
+ (GSourceFunc) up_device_wup_poll_cb, wup);
}
/**
- * dkp_device_wup_finalize:
+ * up_device_wup_finalize:
**/
static void
-dkp_device_wup_finalize (GObject *object)
+up_device_wup_finalize (GObject *object)
{
- DkpDeviceWup *wup;
+ UpDeviceWup *wup;
g_return_if_fail (object != NULL);
- g_return_if_fail (DKP_IS_WUP (object));
+ g_return_if_fail (UP_IS_DEVICE_WUP (object));
- wup = DKP_DEVICE_WUP (object);
+ wup = UP_DEVICE_WUP (object);
g_return_if_fail (wup->priv != NULL);
if (wup->priv->fd > 0)
@@ -453,31 +453,31 @@ dkp_device_wup_finalize (GObject *object)
if (wup->priv->poll_timer_id > 0)
g_source_remove (wup->priv->poll_timer_id);
- G_OBJECT_CLASS (dkp_device_wup_parent_class)->finalize (object);
+ G_OBJECT_CLASS (up_device_wup_parent_class)->finalize (object);
}
/**
- * dkp_device_wup_class_init:
+ * up_device_wup_class_init:
**/
static void
-dkp_device_wup_class_init (DkpDeviceWupClass *klass)
+up_device_wup_class_init (UpDeviceWupClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- DkpDeviceClass *device_class = DKP_DEVICE_CLASS (klass);
+ UpDeviceClass *device_class = UP_DEVICE_CLASS (klass);
- object_class->finalize = dkp_device_wup_finalize;
- device_class->coldplug = dkp_device_wup_coldplug;
- device_class->refresh = dkp_device_wup_refresh;
+ object_class->finalize = up_device_wup_finalize;
+ device_class->coldplug = up_device_wup_coldplug;
+ device_class->refresh = up_device_wup_refresh;
- g_type_class_add_private (klass, sizeof (DkpDeviceWupPrivate));
+ g_type_class_add_private (klass, sizeof (UpDeviceWupPrivate));
}
/**
- * dkp_device_wup_new:
+ * up_device_wup_new:
**/
-DkpDeviceWup *
-dkp_device_wup_new (void)
+UpDeviceWup *
+up_device_wup_new (void)
{
- return g_object_new (DKP_TYPE_WUP, NULL);
+ return g_object_new (UP_TYPE_DEVICE_WUP, NULL);
}
diff --git a/src/linux/up-device-wup.h b/src/linux/up-device-wup.h
index 9d39360..27531fd 100644
--- a/src/linux/up-device-wup.h
+++ b/src/linux/up-device-wup.h
@@ -18,38 +18,38 @@
*
*/
-#ifndef __DKP_DEVICE_WUP_H__
-#define __DKP_DEVICE_WUP_H__
+#ifndef __UP_DEVICE_WUP_H__
+#define __UP_DEVICE_WUP_H__
#include <glib-object.h>
#include "up-device.h"
G_BEGIN_DECLS
-#define DKP_TYPE_WUP (dkp_device_wup_get_type ())
-#define DKP_DEVICE_WUP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DKP_TYPE_WUP, DkpDeviceWup))
-#define DKP_DEVICE_WUP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DKP_TYPE_WUP, DkpDeviceWupClass))
-#define DKP_IS_WUP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DKP_TYPE_WUP))
-#define DKP_IS_WUP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DKP_TYPE_WUP))
-#define DKP_DEVICE_WUP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DKP_TYPE_WUP, DkpDeviceWupClass))
+#define UP_TYPE_DEVICE_WUP (up_device_wup_get_type ())
+#define UP_DEVICE_WUP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_DEVICE_WUP, UpDeviceWup))
+#define UP_DEVICE_WUP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_DEVICE_WUP, UpDeviceWupClass))
+#define UP_IS_DEVICE_WUP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_DEVICE_WUP))
+#define UP_IS_DEVICE_WUP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_DEVICE_WUP))
+#define UP_DEVICE_WUP_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_DEVICE_WUP, UpDeviceWupClass))
-typedef struct DkpDeviceWupPrivate DkpDeviceWupPrivate;
+typedef struct UpDeviceWupPrivate UpDeviceWupPrivate;
typedef struct
{
- DkpDevice parent;
- DkpDeviceWupPrivate *priv;
-} DkpDeviceWup;
+ UpDevice parent;
+ UpDeviceWupPrivate *priv;
+} UpDeviceWup;
typedef struct
{
- DkpDeviceClass parent_class;
-} DkpDeviceWupClass;
+ UpDeviceClass parent_class;
+} UpDeviceWupClass;
-GType dkp_device_wup_get_type (void);
-DkpDeviceWup *dkp_device_wup_new (void);
+GType up_device_wup_get_type (void);
+UpDeviceWup *up_device_wup_new (void);
G_END_DECLS
-#endif /* __DKP_DEVICE_WUP_H__ */
+#endif /* __UP_DEVICE_WUP_H__ */
diff --git a/src/up-backend.h b/src/up-backend.h
index 4d3aecd..e88c1f6 100644
--- a/src/up-backend.h
+++ b/src/up-backend.h
@@ -52,13 +52,13 @@ typedef struct
GObjectClass parent_class;
void (* device_added) (UpBackend *backend,
GObject *native,
- DkpDevice *device);
+ UpDevice *device);
void (* device_changed) (UpBackend *backend,
GObject *native,
- DkpDevice *device);
+ UpDevice *device);
void (* device_removed) (UpBackend *backend,
GObject *native,
- DkpDevice *device);
+ UpDevice *device);
} UpBackendClass;
GType up_backend_get_type (void);
diff --git a/src/up-daemon.c b/src/up-daemon.c
index d3f59d5..3b6b481 100644
--- a/src/up-daemon.c
+++ b/src/up-daemon.c
@@ -73,7 +73,7 @@ struct UpDaemonPrivate
DBusGProxy *proxy;
DkpPolkit *polkit;
UpBackend *backend;
- DkpDeviceList *power_devices;
+ UpDeviceList *power_devices;
gboolean on_battery;
gboolean on_low_battery;
gboolean lid_is_closed;
@@ -309,14 +309,14 @@ up_daemon_get_on_battery_local (UpDaemon *daemon)
gboolean ret;
gboolean result = FALSE;
gboolean on_battery;
- DkpDevice *device;
+ UpDevice *device;
GPtrArray *array;
/* ask each device */
- array = dkp_device_list_get_array (daemon->priv->power_devices);
+ array = up_device_list_get_array (daemon->priv->power_devices);
for (i=0; i<array->len; i++) {
- device = (DkpDevice *) g_ptr_array_index (array, i);
- ret = dkp_device_get_on_battery (device, &on_battery);
+ device = (UpDevice *) g_ptr_array_index (array, i);
+ ret = up_device_get_on_battery (device, &on_battery);
if (ret && on_battery) {
result = TRUE;
break;
@@ -330,18 +330,18 @@ up_daemon_get_on_battery_local (UpDaemon *daemon)
* up_daemon_get_number_devices_of_type:
**/
guint
-up_daemon_get_number_devices_of_type (UpDaemon *daemon, DkpDeviceType type)
+up_daemon_get_number_devices_of_type (UpDaemon *daemon, UpDeviceType type)
{
guint i;
- DkpDevice *device;
+ UpDevice *device;
GPtrArray *array;
- DkpDeviceType type_tmp;
+ UpDeviceType type_tmp;
guint count = 0;
/* ask each device */
- array = dkp_device_list_get_array (daemon->priv->power_devices);
+ array = up_device_list_get_array (daemon->priv->power_devices);
for (i=0; i<array->len; i++) {
- device = (DkpDevice *) g_ptr_array_index (array, i);
+ device = (UpDevice *) g_ptr_array_index (array, i);
g_object_get (device,
"type", &type_tmp,
NULL);
@@ -364,14 +364,14 @@ up_daemon_get_on_low_battery_local (UpDaemon *daemon)
gboolean ret;
gboolean result = TRUE;
gboolean on_low_battery;
- DkpDevice *device;
+ UpDevice *device;
GPtrArray *array;
/* ask each device */
- array = dkp_device_list_get_array (daemon->priv->power_devices);
+ array = up_device_list_get_array (daemon->priv->power_devices);
for (i=0; i<array->len; i++) {
- device = (DkpDevice *) g_ptr_array_index (array, i);
- ret = dkp_device_get_low_battery (device, &on_low_battery);
+ device = (UpDevice *) g_ptr_array_index (array, i);
+ ret = up_device_get_low_battery (device, &on_low_battery);
if (ret && !on_low_battery) {
result = FALSE;
break;
@@ -393,14 +393,14 @@ up_daemon_get_on_ac_local (UpDaemon *daemon)
gboolean ret;
gboolean result = FALSE;
gboolean online;
- DkpDevice *device;
+ UpDevice *device;
GPtrArray *array;
/* ask each device */
- array = dkp_device_list_get_array (daemon->priv->power_devices);
+ array = up_device_list_get_array (daemon->priv->power_devices);
for (i=0; i<array->len; i++) {
- device = (DkpDevice *) g_ptr_array_index (array, i);
- ret = dkp_device_get_online (device, &online);
+ device = (UpDevice *) g_ptr_array_index (array, i);
+ ret = up_device_get_online (device, &online);
if (ret && online) {
result = TRUE;
break;
@@ -444,19 +444,19 @@ up_daemon_refresh_battery_devices (UpDaemon *daemon)
{
guint i;
GPtrArray *array;
- DkpDevice *device;
- DkpDeviceType type;
+ UpDevice *device;
+ UpDeviceType type;
/* refresh all devices in array */
- array = dkp_device_list_get_array (daemon->priv->power_devices);
+ array = up_device_list_get_array (daemon->priv->power_devices);
for (i=0; i<array->len; i++) {
- device = (DkpDevice *) g_ptr_array_index (array, i);
+ device = (UpDevice *) g_ptr_array_index (array, i);
/* only refresh battery devices */
g_object_get (device,
"type", &type,
NULL);
if (type == DKP_DEVICE_TYPE_BATTERY)
- dkp_device_refresh_internal (device);
+ up_device_refresh_internal (device);
}
g_ptr_array_unref (array);
@@ -472,14 +472,14 @@ up_daemon_enumerate_devices (UpDaemon *daemon, DBusGMethodInvocation *context)
guint i;
GPtrArray *array;
GPtrArray *object_paths;
- DkpDevice *device;
+ UpDevice *device;
/* build a pointer array of the object paths */
object_paths = g_ptr_array_new_with_free_func (g_free);
- array = dkp_device_list_get_array (daemon->priv->power_devices);
+ array = up_device_list_get_array (daemon->priv->power_devices);
for (i=0; i<array->len; i++) {
- device = (DkpDevice *) g_ptr_array_index (array, i);
- g_ptr_array_add (object_paths, g_strdup (dkp_device_get_object_path (device)));
+ device = (UpDevice *) g_ptr_array_index (array, i);
+ g_ptr_array_add (object_paths, g_strdup (up_device_get_object_path (device)));
}
g_ptr_array_unref (array);
@@ -694,7 +694,7 @@ out:
/**
* up_daemon_get_device_list:
**/
-DkpDeviceList *
+UpDeviceList *
up_daemon_get_device_list (UpDaemon *daemon)
{
return g_object_ref (daemon->priv->power_devices);
@@ -739,14 +739,14 @@ up_daemon_poll_battery_devices_for_a_little_bit (UpDaemon *daemon)
* up_daemon_device_changed_cb:
**/
static void
-up_daemon_device_changed_cb (DkpDevice *device, UpDaemon *daemon)
+up_daemon_device_changed_cb (UpDevice *device, UpDaemon *daemon)
{
const gchar *object_path;
- DkpDeviceType type;
+ UpDeviceType type;
gboolean ret;
g_return_if_fail (UP_IS_DAEMON (daemon));
- g_return_if_fail (DKP_IS_DEVICE (device));
+ g_return_if_fail (UP_IS_DEVICE (device));
/* refresh battery devices when AC state changes */
g_object_get (device,
@@ -773,7 +773,7 @@ up_daemon_device_changed_cb (DkpDevice *device, UpDaemon *daemon)
/* emit */
if (!daemon->priv->during_coldplug) {
- object_path = dkp_device_get_object_path (device);
+ object_path = up_device_get_object_path (device);
egg_debug ("emitting device-changed: %s", object_path);
/* don't crash the session */
@@ -789,17 +789,17 @@ up_daemon_device_changed_cb (DkpDevice *device, UpDaemon *daemon)
* up_daemon_device_added_cb:
**/
static void
-up_daemon_device_added_cb (UpBackend *backend, GObject *native, DkpDevice *device, UpDaemon *daemon)
+up_daemon_device_added_cb (UpBackend *backend, GObject *native, UpDevice *device, UpDaemon *daemon)
{
- DkpDeviceType type;
+ UpDeviceType type;
const gchar *object_path;
g_return_if_fail (UP_IS_DAEMON (daemon));
- g_return_if_fail (DKP_IS_DEVICE (device));
+ g_return_if_fail (UP_IS_DEVICE (device));
g_return_if_fail (G_IS_OBJECT (native));
/* add to device list */
- dkp_device_list_insert (daemon->priv->power_devices, native, G_OBJECT (device));
+ up_device_list_insert (daemon->priv->power_devices, native, G_OBJECT (device));
/* connect, so we get changes */
g_signal_connect (device, "changed",
@@ -814,7 +814,7 @@ up_daemon_device_added_cb (UpBackend *backend, GObject *native, DkpDevice *devic
/* emit */
if (!daemon->priv->during_coldplug) {
- object_path = dkp_device_get_object_path (device);
+ object_path = up_device_get_object_path (device);
egg_debug ("emitting added: %s (during coldplug %i)", object_path, daemon->priv->during_coldplug);
/* don't crash the session */
@@ -830,17 +830,17 @@ up_daemon_device_added_cb (UpBackend *backend, GObject *native, DkpDevice *devic
* up_daemon_device_removed_cb:
**/
static void
-up_daemon_device_removed_cb (UpBackend *backend, GObject *native, DkpDevice *device, UpDaemon *daemon)
+up_daemon_device_removed_cb (UpBackend *backend, GObject *native, UpDevice *device, UpDaemon *daemon)
{
- DkpDeviceType type;
+ UpDeviceType type;
const gchar *object_path;
g_return_if_fail (UP_IS_DAEMON (daemon));
- g_return_if_fail (DKP_IS_DEVICE (device));
+ g_return_if_fail (UP_IS_DEVICE (device));
g_return_if_fail (G_IS_OBJECT (native));
/* remove from list */
- dkp_device_list_remove (daemon->priv->power_devices, G_OBJECT(device));
+ up_device_list_remove (daemon->priv->power_devices, G_OBJECT(device));
/* refresh after a short delay */
g_object_get (device,
@@ -851,7 +851,7 @@ up_daemon_device_removed_cb (UpBackend *backend, GObject *native, DkpDevice *dev
/* emit */
if (!daemon->priv->during_coldplug) {
- object_path = dkp_device_get_object_path (device);
+ object_path = up_device_get_object_path (device);
egg_debug ("emitting device-removed: %s", object_path);
/* don't crash the session */
@@ -897,7 +897,7 @@ up_daemon_init (UpDaemon *daemon)
daemon->priv->kernel_can_hibernate = FALSE;
daemon->priv->hibernate_has_swap_space = FALSE;
daemon->priv->hibernate_has_encrypted_swap = FALSE;
- daemon->priv->power_devices = dkp_device_list_new ();
+ daemon->priv->power_devices = up_device_list_new ();
daemon->priv->on_battery = FALSE;
daemon->priv->on_low_battery = FALSE;
daemon->priv->during_coldplug = FALSE;
diff --git a/src/up-daemon.h b/src/up-daemon.h
index b295188..9c370b4 100644
--- a/src/up-daemon.h
+++ b/src/up-daemon.h
@@ -70,8 +70,8 @@ void up_daemon_test (gpointer user_data);
/* private */
guint up_daemon_get_number_devices_of_type (UpDaemon *daemon,
- DkpDeviceType type);
-DkpDeviceList *up_daemon_get_device_list (UpDaemon *daemon);
+ UpDeviceType type);
+UpDeviceList *up_daemon_get_device_list (UpDaemon *daemon);
gboolean up_daemon_startup (UpDaemon *daemon);
/* exported */
diff --git a/src/up-device-list.c b/src/up-device-list.c
index beecbc4..2da3051 100644
--- a/src/up-device-list.c
+++ b/src/up-device-list.c
@@ -30,33 +30,33 @@
#include "up-native.h"
#include "up-device-list.h"
-static void dkp_device_list_finalize (GObject *object);
+static void up_device_list_finalize (GObject *object);
-#define DKP_DEVICE_LIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_DEVICE_LIST, DkpDeviceListPrivate))
+#define UP_DEVICE_LIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE_LIST, UpDeviceListPrivate))
-struct DkpDeviceListPrivate
+struct UpDeviceListPrivate
{
GPtrArray *array;
GHashTable *map_native_path_to_device;
};
-G_DEFINE_TYPE (DkpDeviceList, dkp_device_list, G_TYPE_OBJECT)
+G_DEFINE_TYPE (UpDeviceList, up_device_list, G_TYPE_OBJECT)
/**
- * dkp_device_list_lookup:
+ * up_device_list_lookup:
*
- * Convert a native %GObject into a %DkpDevice -- we use the native path
+ * Convert a native %GObject into a %UpDevice -- we use the native path
* to look these up as it's the only thing they share.
*
* Return value: the object, or %NULL if not found. Free with g_object_unref()
**/
GObject *
-dkp_device_list_lookup (DkpDeviceList *list, GObject *native)
+up_device_list_lookup (UpDeviceList *list, GObject *native)
{
GObject *device;
const gchar *native_path;
- g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), NULL);
+ g_return_val_if_fail (UP_IS_DEVICE_LIST (list), NULL);
/* does device exist in db? */
native_path = dkp_native_get_native_path (native);
@@ -69,17 +69,17 @@ dkp_device_list_lookup (DkpDeviceList *list, GObject *native)
}
/**
- * dkp_device_list_insert:
+ * up_device_list_insert:
*
- * Insert a %GObject device and it's mapping to a backing %DkpDevice
+ * Insert a %GObject device and it's mapping to a backing %UpDevice
* into a list of devices.
**/
gboolean
-dkp_device_list_insert (DkpDeviceList *list, GObject *native, GObject *device)
+up_device_list_insert (UpDeviceList *list, GObject *native, GObject *device)
{
const gchar *native_path;
- g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE_LIST (list), FALSE);
g_return_val_if_fail (native != NULL, FALSE);
g_return_val_if_fail (device != NULL, FALSE);
@@ -96,10 +96,10 @@ dkp_device_list_insert (DkpDeviceList *list, GObject *native, GObject *device)
}
/**
- * dkp_device_list_remove_cb:
+ * up_device_list_remove_cb:
**/
static gboolean
-dkp_device_list_remove_cb (gpointer key, gpointer value, gpointer user_data)
+up_device_list_remove_cb (gpointer key, gpointer value, gpointer user_data)
{
if (value == user_data) {
egg_debug ("removed %s", (char *) key);
@@ -109,17 +109,17 @@ dkp_device_list_remove_cb (gpointer key, gpointer value, gpointer user_data)
}
/**
- * dkp_device_list_remove:
+ * up_device_list_remove:
**/
gboolean
-dkp_device_list_remove (DkpDeviceList *list, GObject *device)
+up_device_list_remove (UpDeviceList *list, GObject *device)
{
- g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE_LIST (list), FALSE);
g_return_val_if_fail (device != NULL, FALSE);
/* remove the device from the db */
g_hash_table_foreach_remove (list->priv->map_native_path_to_device,
- dkp_device_list_remove_cb, device);
+ up_device_list_remove_cb, device);
g_ptr_array_remove (list->priv->array, device);
/* we're removed the last instance? */
@@ -132,73 +132,73 @@ dkp_device_list_remove (DkpDeviceList *list, GObject *device)
}
/**
- * dkp_device_list_get_array:
+ * up_device_list_get_array:
*
* This is quick to iterate when we don't have GObject's to resolve
*
* Return value: the array, free with g_ptr_array_unref()
**/
GPtrArray *
-dkp_device_list_get_array (DkpDeviceList *list)
+up_device_list_get_array (UpDeviceList *list)
{
- g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), NULL);
+ g_return_val_if_fail (UP_IS_DEVICE_LIST (list), NULL);
return g_ptr_array_ref (list->priv->array);
}
/**
- * dkp_device_list_class_init:
- * @klass: The DkpDeviceListClass
+ * up_device_list_class_init:
+ * @klass: The UpDeviceListClass
**/
static void
-dkp_device_list_class_init (DkpDeviceListClass *klass)
+up_device_list_class_init (UpDeviceListClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = dkp_device_list_finalize;
- g_type_class_add_private (klass, sizeof (DkpDeviceListPrivate));
+ object_class->finalize = up_device_list_finalize;
+ g_type_class_add_private (klass, sizeof (UpDeviceListPrivate));
}
/**
- * dkp_device_list_init:
+ * up_device_list_init:
* @list: This class instance
**/
static void
-dkp_device_list_init (DkpDeviceList *list)
+up_device_list_init (UpDeviceList *list)
{
- list->priv = DKP_DEVICE_LIST_GET_PRIVATE (list);
+ list->priv = UP_DEVICE_LIST_GET_PRIVATE (list);
list->priv->array = g_ptr_array_new_with_free_func (g_object_unref);
list->priv->map_native_path_to_device = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
}
/**
- * dkp_device_list_finalize:
+ * up_device_list_finalize:
* @object: The object to finalize
**/
static void
-dkp_device_list_finalize (GObject *object)
+up_device_list_finalize (GObject *object)
{
- DkpDeviceList *list;
+ UpDeviceList *list;
- g_return_if_fail (DKP_IS_DEVICE_LIST (object));
+ g_return_if_fail (UP_IS_DEVICE_LIST (object));
- list = DKP_DEVICE_LIST (object);
+ list = UP_DEVICE_LIST (object);
g_ptr_array_unref (list->priv->array);
g_hash_table_unref (list->priv->map_native_path_to_device);
- G_OBJECT_CLASS (dkp_device_list_parent_class)->finalize (object);
+ G_OBJECT_CLASS (up_device_list_parent_class)->finalize (object);
}
/**
- * dkp_device_list_new:
+ * up_device_list_new:
*
- * Return value: a new DkpDeviceList object.
+ * Return value: a new UpDeviceList object.
**/
-DkpDeviceList *
-dkp_device_list_new (void)
+UpDeviceList *
+up_device_list_new (void)
{
- DkpDeviceList *list;
- list = g_object_new (DKP_TYPE_DEVICE_LIST, NULL);
- return DKP_DEVICE_LIST (list);
+ UpDeviceList *list;
+ list = g_object_new (UP_TYPE_DEVICE_LIST, NULL);
+ return UP_DEVICE_LIST (list);
}
@@ -209,39 +209,39 @@ dkp_device_list_new (void)
#include "egg-test.h"
void
-dkp_device_list_test (gpointer user_data)
+up_device_list_test (gpointer user_data)
{
EggTest *test = (EggTest *) user_data;
- DkpDeviceList *list;
+ UpDeviceList *list;
GObject *native;
GObject *device;
GObject *found;
gboolean ret;
- if (!egg_test_start (test, "DkpDeviceList"))
+ if (!egg_test_start (test, "UpDeviceList"))
return;
/************************************************************/
egg_test_title (test, "get instance");
- list = dkp_device_list_new ();
+ list = up_device_list_new ();
egg_test_assert (test, list != NULL);
/************************************************************/
egg_test_title (test, "add device");
native = g_object_new (G_TYPE_OBJECT, NULL);
device = g_object_new (G_TYPE_OBJECT, NULL);
- ret = dkp_device_list_insert (list, native, device);
+ ret = up_device_list_insert (list, native, device);
egg_test_assert (test, ret);
/************************************************************/
egg_test_title (test, "find device");
- found = dkp_device_list_lookup (list, native);
+ found = up_device_list_lookup (list, native);
egg_test_assert (test, (found != NULL));
g_object_unref (found);
/************************************************************/
egg_test_title (test, "remove device");
- ret = dkp_device_list_remove (list, device);
+ ret = up_device_list_remove (list, device);
egg_test_assert (test, ret);
/* unref */
diff --git a/src/up-device-list.h b/src/up-device-list.h
index aac2a6c..86fcf19 100644
--- a/src/up-device-list.h
+++ b/src/up-device-list.h
@@ -19,50 +19,50 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef __DKP_DEVICE_LIST_H
-#define __DKP_DEVICE_LIST_H
+#ifndef __UP_DEVICE_LIST_H
+#define __UP_DEVICE_LIST_H
#include <glib-object.h>
#include <dkp-enum.h>
G_BEGIN_DECLS
-#define DKP_TYPE_DEVICE_LIST (dkp_device_list_get_type ())
-#define DKP_DEVICE_LIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DKP_TYPE_DEVICE_LIST, DkpDeviceList))
-#define DKP_DEVICE_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DKP_TYPE_DEVICE_LIST, DkpDeviceListClass))
-#define DKP_IS_DEVICE_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DKP_TYPE_DEVICE_LIST))
-#define DKP_IS_DEVICE_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DKP_TYPE_DEVICE_LIST))
-#define DKP_DEVICE_LIST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DKP_TYPE_DEVICE_LIST, DkpDeviceListClass))
-#define DKP_DEVICE_LIST_ERROR (dkp_device_list_error_quark ())
-#define DKP_DEVICE_LIST_TYPE_ERROR (dkp_device_list_error_get_type ())
+#define UP_TYPE_DEVICE_LIST (up_device_list_get_type ())
+#define UP_DEVICE_LIST(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_DEVICE_LIST, UpDeviceList))
+#define UP_DEVICE_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_DEVICE_LIST, UpDeviceListClass))
+#define UP_IS_DEVICE_LIST(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_DEVICE_LIST))
+#define UP_IS_DEVICE_LIST_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_DEVICE_LIST))
+#define UP_DEVICE_LIST_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_DEVICE_LIST, UpDeviceListClass))
+#define UP_DEVICE_LIST_ERROR (up_device_list_error_quark ())
+#define UP_DEVICE_LIST_TYPE_ERROR (up_device_list_error_get_type ())
-typedef struct DkpDeviceListPrivate DkpDeviceListPrivate;
+typedef struct UpDeviceListPrivate UpDeviceListPrivate;
typedef struct
{
GObject parent;
- DkpDeviceListPrivate *priv;
-} DkpDeviceList;
+ UpDeviceListPrivate *priv;
+} UpDeviceList;
typedef struct
{
GObjectClass parent_class;
-} DkpDeviceListClass;
+} UpDeviceListClass;
-GType dkp_device_list_get_type (void);
-DkpDeviceList *dkp_device_list_new (void);
-void dkp_device_list_test (gpointer user_data);
+GType up_device_list_get_type (void);
+UpDeviceList *up_device_list_new (void);
+void up_device_list_test (gpointer user_data);
-GObject *dkp_device_list_lookup (DkpDeviceList *list,
+GObject *up_device_list_lookup (UpDeviceList *list,
GObject *native);
-gboolean dkp_device_list_insert (DkpDeviceList *list,
+gboolean up_device_list_insert (UpDeviceList *list,
GObject *native,
GObject *device);
-gboolean dkp_device_list_remove (DkpDeviceList *list,
+gboolean up_device_list_remove (UpDeviceList *list,
GObject *device);
-GPtrArray *dkp_device_list_get_array (DkpDeviceList *list);
+GPtrArray *up_device_list_get_array (UpDeviceList *list);
G_END_DECLS
-#endif /* __DKP_DEVICE_LIST_H */
+#endif /* __UP_DEVICE_LIST_H */
diff --git a/src/up-device.c b/src/up-device.c
index e8b6e99..54bc90a 100644
--- a/src/up-device.c
+++ b/src/up-device.c
@@ -42,7 +42,7 @@
#include "up-marshal.h"
#include "up-device-glue.h"
-struct DkpDevicePrivate
+struct UpDevicePrivate
{
gchar *object_path;
DBusGConnection *system_bus_connection;
@@ -65,9 +65,9 @@ struct DkpDevicePrivate
gboolean is_rechargeable;
gboolean has_history;
gboolean has_statistics;
- DkpDeviceType type;
- DkpDeviceState state;
- DkpDeviceTechnology technology;
+ UpDeviceType type;
+ UpDeviceState state;
+ UpDeviceTechnology technology;
gdouble capacity; /* percent */
gdouble energy; /* Watt Hours */
gdouble energy_empty; /* Watt Hours */
@@ -83,7 +83,7 @@ struct DkpDevicePrivate
gchar *recall_url;
};
-static gboolean dkp_device_register_device (DkpDevice *device);
+static gboolean up_device_register_device (UpDevice *device);
enum {
PROP_0,
@@ -124,23 +124,23 @@ enum {
static guint signals[SIGNAL_LAST] = { 0 };
-G_DEFINE_TYPE (DkpDevice, dkp_device, G_TYPE_OBJECT)
-#define DKP_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_DEVICE, DkpDevicePrivate))
+G_DEFINE_TYPE (UpDevice, up_device, G_TYPE_OBJECT)
+#define UP_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE, UpDevicePrivate))
#define DKP_DBUS_STRUCT_UINT_DOUBLE_UINT (dbus_g_type_get_struct ("GValueArray", \
G_TYPE_UINT, G_TYPE_DOUBLE, G_TYPE_UINT, G_TYPE_INVALID))
#define DKP_DBUS_STRUCT_DOUBLE_DOUBLE (dbus_g_type_get_struct ("GValueArray", \
G_TYPE_DOUBLE, G_TYPE_DOUBLE, G_TYPE_INVALID))
/**
- * dkp_device_error_quark:
+ * up_device_error_quark:
**/
GQuark
-dkp_device_error_quark (void)
+up_device_error_quark (void)
{
static GQuark ret = 0;
if (ret == 0) {
- ret = g_quark_from_static_string ("dkp_device_error");
+ ret = g_quark_from_static_string ("up_device_error");
}
return ret;
@@ -149,10 +149,10 @@ dkp_device_error_quark (void)
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
/**
- * dkp_device_error_get_type:
+ * up_device_error_get_type:
**/
GType
-dkp_device_error_get_type (void)
+up_device_error_get_type (void)
{
static GType etype = 0;
@@ -160,22 +160,22 @@ dkp_device_error_get_type (void)
{
static const GEnumValue values[] =
{
- ENUM_ENTRY (DKP_DEVICE_ERROR_GENERAL, "GeneralError"),
+ ENUM_ENTRY (UP_DEVICE_ERROR_GENERAL, "GeneralError"),
{ 0, 0, 0 }
};
- g_assert (DKP_DEVICE_NUM_ERRORS == G_N_ELEMENTS (values) - 1);
- etype = g_enum_register_static ("DkpDeviceError", values);
+ g_assert (UP_DEVICE_NUM_ERRORS == G_N_ELEMENTS (values) - 1);
+ etype = g_enum_register_static ("UpDeviceError", values);
}
return etype;
}
/**
- * dkp_device_get_property:
+ * up_device_get_property:
**/
static void
-dkp_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+up_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
- DkpDevice *device = DKP_DEVICE (object);
+ UpDevice *device = UP_DEVICE (object);
switch (prop_id) {
case PROP_NATIVE_PATH:
g_value_set_string (value, device->priv->native_path);
@@ -265,12 +265,12 @@ dkp_device_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
}
/**
- * dkp_device_set_property:
+ * up_device_set_property:
**/
static void
-dkp_device_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+up_device_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
- DkpDevice *device = DKP_DEVICE (object);
+ UpDevice *device = UP_DEVICE (object);
switch (prop_id) {
case PROP_NATIVE_PATH:
@@ -367,16 +367,16 @@ dkp_device_set_property (GObject *object, guint prop_id, const GValue *value, GP
}
/**
- * dkp_device_get_on_battery:
+ * up_device_get_on_battery:
*
* Note: Only implement for system devices, i.e. ones supplying the system
**/
gboolean
-dkp_device_get_on_battery (DkpDevice *device, gboolean *on_battery)
+up_device_get_on_battery (UpDevice *device, gboolean *on_battery)
{
- DkpDeviceClass *klass = DKP_DEVICE_GET_CLASS (device);
+ UpDeviceClass *klass = UP_DEVICE_GET_CLASS (device);
- g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE (device), FALSE);
/* no support */
if (klass->get_on_battery == NULL)
@@ -386,16 +386,16 @@ dkp_device_get_on_battery (DkpDevice *device, gboolean *on_battery)
}
/**
- * dkp_device_get_low_battery:
+ * up_device_get_low_battery:
*
* Note: Only implement for system devices, i.e. ones supplying the system
**/
gboolean
-dkp_device_get_low_battery (DkpDevice *device, gboolean *low_battery)
+up_device_get_low_battery (UpDevice *device, gboolean *low_battery)
{
- DkpDeviceClass *klass = DKP_DEVICE_GET_CLASS (device);
+ UpDeviceClass *klass = UP_DEVICE_GET_CLASS (device);
- g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE (device), FALSE);
/* no support */
if (klass->get_low_battery == NULL)
@@ -405,16 +405,16 @@ dkp_device_get_low_battery (DkpDevice *device, gboolean *low_battery)
}
/**
- * dkp_device_get_online:
+ * up_device_get_online:
*
* Note: Only implement for system devices, i.e. devices supplying the system
**/
gboolean
-dkp_device_get_online (DkpDevice *device, gboolean *online)
+up_device_get_online (UpDevice *device, gboolean *online)
{
- DkpDeviceClass *klass = DKP_DEVICE_GET_CLASS (device);
+ UpDeviceClass *klass = UP_DEVICE_GET_CLASS (device);
- g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE (device), FALSE);
/* no support */
if (klass->get_online == NULL)
@@ -424,10 +424,10 @@ dkp_device_get_online (DkpDevice *device, gboolean *online)
}
/**
- * dkp_device_get_id:
+ * up_device_get_id:
**/
static gchar *
-dkp_device_get_id (DkpDevice *device)
+up_device_get_id (UpDevice *device)
{
GString *string;
gchar *id = NULL;
@@ -507,12 +507,12 @@ out:
}
/**
- * dkp_device_get_daemon:
+ * up_device_get_daemon:
*
* Returns a refcounted #UpDaemon instance, or %NULL
**/
UpDaemon *
-dkp_device_get_daemon (DkpDevice *device)
+up_device_get_daemon (UpDevice *device)
{
if (device->priv->daemon == NULL)
return NULL;
@@ -520,19 +520,19 @@ dkp_device_get_daemon (DkpDevice *device)
}
/**
- * dkp_device_coldplug:
+ * up_device_coldplug:
*
* Return %TRUE on success, %FALSE if we failed to get data and should be removed
**/
gboolean
-dkp_device_coldplug (DkpDevice *device, UpDaemon *daemon, GObject *native)
+up_device_coldplug (UpDevice *device, UpDaemon *daemon, GObject *native)
{
gboolean ret;
const gchar *native_path;
- DkpDeviceClass *klass = DKP_DEVICE_GET_CLASS (device);
+ UpDeviceClass *klass = UP_DEVICE_GET_CLASS (device);
gchar *id = NULL;
- g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE (device), FALSE);
/* save */
device->priv->native = g_object_ref (native);
@@ -556,14 +556,14 @@ dkp_device_coldplug (DkpDevice *device, UpDaemon *daemon, GObject *native)
}
/* only put on the bus if we succeeded */
- ret = dkp_device_register_device (device);
+ ret = up_device_register_device (device);
if (!ret) {
egg_warning ("failed to register device %s", device->priv->native_path);
goto out;
}
/* force a refresh, although failure isn't fatal */
- ret = dkp_device_refresh_internal (device);
+ ret = up_device_refresh_internal (device);
if (!ret) {
egg_debug ("failed to refresh %s", device->priv->native_path);
@@ -574,7 +574,7 @@ dkp_device_coldplug (DkpDevice *device, UpDaemon *daemon, GObject *native)
}
/* get the id so we can load the old history */
- id = dkp_device_get_id (device);
+ id = up_device_get_id (device);
if (id != NULL)
dkp_history_set_id (device->priv->history, id);
@@ -588,10 +588,10 @@ out:
}
/**
- * dkp_device_get_statistics:
+ * up_device_get_statistics:
**/
gboolean
-dkp_device_get_statistics (DkpDevice *device, const gchar *type, DBusGMethodInvocation *context)
+up_device_get_statistics (UpDevice *device, const gchar *type, DBusGMethodInvocation *context)
{
GError *error;
GPtrArray *array = NULL;
@@ -600,7 +600,7 @@ dkp_device_get_statistics (DkpDevice *device, const gchar *type, DBusGMethodInvo
GValue *value;
guint i;
- g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE (device), FALSE);
g_return_val_if_fail (type != NULL, FALSE);
/* doesn't even try to support this */
@@ -650,10 +650,10 @@ out:
}
/**
- * dkp_device_get_history:
+ * up_device_get_history:
**/
gboolean
-dkp_device_get_history (DkpDevice *device, const gchar *type_string, guint timespan, guint resolution, DBusGMethodInvocation *context)
+up_device_get_history (UpDevice *device, const gchar *type_string, guint timespan, guint resolution, DBusGMethodInvocation *context)
{
GError *error;
GPtrArray *array = NULL;
@@ -663,7 +663,7 @@ dkp_device_get_history (DkpDevice *device, const gchar *type_string, guint times
guint i;
DkpHistoryType type = DKP_HISTORY_TYPE_UNKNOWN;
- g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE (device), FALSE);
g_return_val_if_fail (type_string != NULL, FALSE);
/* doesn't even try to support this */
@@ -715,17 +715,17 @@ out:
}
/**
- * dkp_device_refresh_internal:
+ * up_device_refresh_internal:
*
* NOTE: if you're calling this function you have to ensure you're doing the
* the changed signals on the right interfaces, although by monitoring
* notify::update-time this should be mostly done.
**/
gboolean
-dkp_device_refresh_internal (DkpDevice *device)
+up_device_refresh_internal (UpDevice *device)
{
gboolean ret = FALSE;
- DkpDeviceClass *klass = DKP_DEVICE_GET_CLASS (device);
+ UpDeviceClass *klass = UP_DEVICE_GET_CLASS (device);
/* not implemented */
if (klass->refresh == NULL)
@@ -749,44 +749,44 @@ out:
}
/**
- * dkp_device_refresh:
+ * up_device_refresh:
*
* Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
gboolean
-dkp_device_refresh (DkpDevice *device, DBusGMethodInvocation *context)
+up_device_refresh (UpDevice *device, DBusGMethodInvocation *context)
{
gboolean ret;
- g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
+ g_return_val_if_fail (UP_IS_DEVICE (device), FALSE);
- ret = dkp_device_refresh_internal (device);
+ ret = up_device_refresh_internal (device);
dbus_g_method_return (context);
return ret;
}
/**
- * dkp_device_get_object_path:
+ * up_device_get_object_path:
**/
const gchar *
-dkp_device_get_object_path (DkpDevice *device)
+up_device_get_object_path (UpDevice *device)
{
- g_return_val_if_fail (DKP_IS_DEVICE (device), NULL);
+ g_return_val_if_fail (UP_IS_DEVICE (device), NULL);
return device->priv->object_path;
}
GObject *
-dkp_device_get_native (DkpDevice *device)
+up_device_get_native (UpDevice *device)
{
- g_return_val_if_fail (DKP_IS_DEVICE (device), NULL);
+ g_return_val_if_fail (UP_IS_DEVICE (device), NULL);
return device->priv->native;
}
/**
- * dkp_device_compute_object_path:
+ * up_device_compute_object_path:
**/
static gchar *
-dkp_device_compute_object_path (DkpDevice *device)
+up_device_compute_object_path (UpDevice *device)
{
gchar *basename;
gchar *id;
@@ -795,7 +795,7 @@ dkp_device_compute_object_path (DkpDevice *device)
const gchar *type;
guint i;
- type = dkp_device_type_to_text (device->priv->type);
+ type = up_device_type_to_text (device->priv->type);
native_path = device->priv->native_path;
basename = g_path_get_basename (native_path);
id = g_strjoin ("_", type, basename, NULL);
@@ -818,14 +818,14 @@ dkp_device_compute_object_path (DkpDevice *device)
}
/**
- * dkp_device_register_device:
+ * up_device_register_device:
**/
static gboolean
-dkp_device_register_device (DkpDevice *device)
+up_device_register_device (UpDevice *device)
{
gboolean ret = TRUE;
- device->priv->object_path = dkp_device_compute_object_path (device);
+ device->priv->object_path = up_device_compute_object_path (device);
egg_debug ("object path = %s", device->priv->object_path);
dbus_g_connection_register_g_object (device->priv->system_bus_connection,
device->priv->object_path, G_OBJECT (device));
@@ -839,12 +839,12 @@ dkp_device_register_device (DkpDevice *device)
}
/**
- * dkp_device_perhaps_changed_cb:
+ * up_device_perhaps_changed_cb:
**/
static void
-dkp_device_perhaps_changed_cb (GObject *object, GParamSpec *pspec, DkpDevice *device)
+up_device_perhaps_changed_cb (GObject *object, GParamSpec *pspec, UpDevice *device)
{
- g_return_if_fail (DKP_IS_DEVICE (device));
+ g_return_if_fail (UP_IS_DEVICE (device));
/* don't proxy during coldplug */
if (device->priv->during_coldplug)
@@ -864,14 +864,14 @@ dkp_device_perhaps_changed_cb (GObject *object, GParamSpec *pspec, DkpDevice *de
}
/**
- * dkp_device_init:
+ * up_device_init:
**/
static void
-dkp_device_init (DkpDevice *device)
+up_device_init (UpDevice *device)
{
GError *error = NULL;
- device->priv = DKP_DEVICE_GET_PRIVATE (device);
+ device->priv = UP_DEVICE_GET_PRIVATE (device);
device->priv->object_path = NULL;
device->priv->system_bus_connection = NULL;
device->priv->system_bus_proxy = NULL;
@@ -886,21 +886,21 @@ dkp_device_init (DkpDevice *device)
egg_error ("error getting system bus: %s", error->message);
g_error_free (error);
}
- g_signal_connect (device, "notify::update-time", G_CALLBACK (dkp_device_perhaps_changed_cb), device);
+ g_signal_connect (device, "notify::update-time", G_CALLBACK (up_device_perhaps_changed_cb), device);
}
/**
- * dkp_device_finalize:
+ * up_device_finalize:
**/
static void
-dkp_device_finalize (GObject *object)
+up_device_finalize (GObject *object)
{
- DkpDevice *device;
+ UpDevice *device;
g_return_if_fail (object != NULL);
- g_return_if_fail (DKP_IS_DEVICE (object));
+ g_return_if_fail (UP_IS_DEVICE (object));
- device = DKP_DEVICE (object);
+ device = UP_DEVICE (object);
g_return_if_fail (device->priv != NULL);
if (device->priv->native != NULL)
g_object_unref (device->priv->native);
@@ -915,21 +915,21 @@ dkp_device_finalize (GObject *object)
g_free (device->priv->recall_vendor);
g_free (device->priv->recall_url);
- G_OBJECT_CLASS (dkp_device_parent_class)->finalize (object);
+ G_OBJECT_CLASS (up_device_parent_class)->finalize (object);
}
/**
- * dkp_device_class_init:
+ * up_device_class_init:
**/
static void
-dkp_device_class_init (DkpDeviceClass *klass)
+up_device_class_init (UpDeviceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = dkp_device_get_property;
- object_class->set_property = dkp_device_set_property;
- object_class->finalize = dkp_device_finalize;
+ object_class->get_property = up_device_get_property;
+ object_class->set_property = up_device_set_property;
+ object_class->finalize = up_device_finalize;
- g_type_class_add_private (klass, sizeof (DkpDevicePrivate));
+ g_type_class_add_private (klass, sizeof (UpDevicePrivate));
signals[SIGNAL_CHANGED] =
g_signal_new ("changed",
@@ -939,10 +939,10 @@ dkp_device_class_init (DkpDeviceClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- dbus_g_object_type_install_info (DKP_TYPE_DEVICE, &dbus_glib_dkp_device_object_info);
+ dbus_g_object_type_install_info (UP_TYPE_DEVICE, &dbus_glib_up_device_object_info);
/**
- * DkpDevice:update-time:
+ * UpDevice:update-time:
*/
g_object_class_install_property (object_class,
PROP_UPDATE_TIME,
@@ -951,7 +951,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
0, G_MAXUINT64, 0,
G_PARAM_READWRITE));
/**
- * DkpDevice:vendor:
+ * UpDevice:vendor:
*/
g_object_class_install_property (object_class,
PROP_VENDOR,
@@ -960,7 +960,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
NULL,
G_PARAM_READWRITE));
/**
- * DkpDevice:model:
+ * UpDevice:model:
*/
g_object_class_install_property (object_class,
PROP_MODEL,
@@ -969,7 +969,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
NULL,
G_PARAM_READWRITE));
/**
- * DkpDevice:serial:
+ * UpDevice:serial:
*/
g_object_class_install_property (object_class,
PROP_SERIAL,
@@ -978,7 +978,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
NULL,
G_PARAM_READWRITE));
/**
- * DkpDevice:native-path:
+ * UpDevice:native-path:
*/
g_object_class_install_property (object_class,
PROP_NATIVE_PATH,
@@ -987,7 +987,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
NULL,
G_PARAM_READWRITE));
/**
- * DkpDevice:power-supply:
+ * UpDevice:power-supply:
*/
g_object_class_install_property (object_class,
PROP_POWER_SUPPLY,
@@ -996,7 +996,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
FALSE,
G_PARAM_READWRITE));
/**
- * DkpDevice:online:
+ * UpDevice:online:
*/
g_object_class_install_property (object_class,
PROP_ONLINE,
@@ -1005,7 +1005,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
FALSE,
G_PARAM_READWRITE));
/**
- * DkpDevice:is-present:
+ * UpDevice:is-present:
*/
g_object_class_install_property (object_class,
PROP_IS_PRESENT,
@@ -1014,7 +1014,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
FALSE,
G_PARAM_READWRITE));
/**
- * DkpDevice:is-rechargeable:
+ * UpDevice:is-rechargeable:
*/
g_object_class_install_property (object_class,
PROP_IS_RECHARGEABLE,
@@ -1023,7 +1023,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
FALSE,
G_PARAM_READWRITE));
/**
- * DkpDevice:has-history:
+ * UpDevice:has-history:
*/
g_object_class_install_property (object_class,
PROP_HAS_HISTORY,
@@ -1032,7 +1032,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
FALSE,
G_PARAM_READWRITE));
/**
- * DkpDevice:has-statistics:
+ * UpDevice:has-statistics:
*/
g_object_class_install_property (object_class,
PROP_HAS_STATISTICS,
@@ -1041,7 +1041,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
FALSE,
G_PARAM_READWRITE));
/**
- * DkpDevice:type:
+ * UpDevice:type:
*/
g_object_class_install_property (object_class,
PROP_TYPE,
@@ -1052,7 +1052,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
DKP_DEVICE_TYPE_UNKNOWN,
G_PARAM_READWRITE));
/**
- * DkpDevice:state:
+ * UpDevice:state:
*/
g_object_class_install_property (object_class,
PROP_STATE,
@@ -1063,7 +1063,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
DKP_DEVICE_STATE_UNKNOWN,
G_PARAM_READWRITE));
/**
- * DkpDevice:technology:
+ * UpDevice:technology:
*/
g_object_class_install_property (object_class,
PROP_TECHNOLOGY,
@@ -1074,7 +1074,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
DKP_DEVICE_TECHNOLOGY_UNKNOWN,
G_PARAM_READWRITE));
/**
- * DkpDevice:capacity:
+ * UpDevice:capacity:
*/
g_object_class_install_property (object_class,
PROP_CAPACITY,
@@ -1082,7 +1082,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
0.0, 100.f, 100.0,
G_PARAM_READWRITE));
/**
- * DkpDevice:energy:
+ * UpDevice:energy:
*/
g_object_class_install_property (object_class,
PROP_ENERGY,
@@ -1090,7 +1090,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
/**
- * DkpDevice:energy-empty:
+ * UpDevice:energy-empty:
*/
g_object_class_install_property (object_class,
PROP_ENERGY_EMPTY,
@@ -1098,7 +1098,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
/**
- * DkpDevice:energy-full:
+ * UpDevice:energy-full:
*/
g_object_class_install_property (object_class,
PROP_ENERGY_FULL,
@@ -1106,7 +1106,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
/**
- * DkpDevice:energy-full-design:
+ * UpDevice:energy-full-design:
*/
g_object_class_install_property (object_class,
PROP_ENERGY_FULL_DESIGN,
@@ -1114,7 +1114,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
/**
- * DkpDevice:energy-rate:
+ * UpDevice:energy-rate:
*/
g_object_class_install_property (object_class,
PROP_ENERGY_RATE,
@@ -1122,7 +1122,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
/**
- * DkpDevice:voltage:
+ * UpDevice:voltage:
*/
g_object_class_install_property (object_class,
PROP_VOLTAGE,
@@ -1130,7 +1130,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
/**
- * DkpDevice:time-to-empty:
+ * UpDevice:time-to-empty:
*/
g_object_class_install_property (object_class,
PROP_TIME_TO_EMPTY,
@@ -1138,7 +1138,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
0, G_MAXINT64, 0,
G_PARAM_READWRITE));
/**
- * DkpDevice:time-to-full:
+ * UpDevice:time-to-full:
*/
g_object_class_install_property (object_class,
PROP_TIME_TO_FULL,
@@ -1146,7 +1146,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
0, G_MAXINT64, 0,
G_PARAM_READWRITE));
/**
- * DkpDevice:percentage:
+ * UpDevice:percentage:
*/
g_object_class_install_property (object_class,
PROP_PERCENTAGE,
@@ -1154,7 +1154,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
0.0, 100.f, 100.0,
G_PARAM_READWRITE));
/**
- * DkpDevice:recall-notice:
+ * UpDevice:recall-notice:
*/
g_object_class_install_property (object_class,
PROP_RECALL_NOTICE,
@@ -1163,7 +1163,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
FALSE,
G_PARAM_READWRITE));
/**
- * DkpDevice:recall-vendor:
+ * UpDevice:recall-vendor:
*/
g_object_class_install_property (object_class,
PROP_RECALL_VENDOR,
@@ -1172,7 +1172,7 @@ dkp_device_class_init (DkpDeviceClass *klass)
NULL,
G_PARAM_READWRITE));
/**
- * DkpDevice:recall-url:
+ * UpDevice:recall-url:
*/
g_object_class_install_property (object_class,
PROP_RECALL_URL,
@@ -1181,17 +1181,17 @@ dkp_device_class_init (DkpDeviceClass *klass)
NULL,
G_PARAM_READWRITE));
- dbus_g_error_domain_register (DKP_DEVICE_ERROR, NULL, DKP_DEVICE_TYPE_ERROR);
+ dbus_g_error_domain_register (UP_DEVICE_ERROR, NULL, UP_DEVICE_TYPE_ERROR);
}
/**
- * dkp_device_new:
+ * up_device_new:
**/
-DkpDevice *
-dkp_device_new (void)
+UpDevice *
+up_device_new (void)
{
- DkpDevice *device;
- device = DKP_DEVICE (g_object_new (DKP_TYPE_DEVICE, NULL));
+ UpDevice *device;
+ device = UP_DEVICE (g_object_new (UP_TYPE_DEVICE, NULL));
return device;
}
@@ -1202,17 +1202,17 @@ dkp_device_new (void)
#include "egg-test.h"
void
-dkp_device_test (gpointer user_data)
+up_device_test (gpointer user_data)
{
EggTest *test = (EggTest *) user_data;
- DkpDevice *device;
+ UpDevice *device;
- if (!egg_test_start (test, "DkpDevice"))
+ if (!egg_test_start (test, "UpDevice"))
return;
/************************************************************/
egg_test_title (test, "get instance");
- device = dkp_device_new ();
+ device = up_device_new ();
egg_test_assert (test, device != NULL);
/* unref */
diff --git a/src/up-device.h b/src/up-device.h
index 4133aef..020e529 100644
--- a/src/up-device.h
+++ b/src/up-device.h
@@ -19,8 +19,8 @@
*
*/
-#ifndef __DKP_DEVICE_H__
-#define __DKP_DEVICE_H__
+#ifndef __UP_DEVICE_H__
+#define __UP_DEVICE_H__
#include <glib-object.h>
#include <polkit/polkit.h>
@@ -30,78 +30,78 @@
G_BEGIN_DECLS
-#define DKP_TYPE_DEVICE (dkp_device_get_type ())
-#define DKP_DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DKP_TYPE_DEVICE, DkpDevice))
-#define DKP_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DKP_TYPE_DEVICE, DkpDeviceClass))
-#define DKP_IS_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DKP_TYPE_DEVICE))
-#define DKP_IS_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DKP_TYPE_DEVICE))
-#define DKP_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DKP_TYPE_DEVICE, DkpDeviceClass))
+#define UP_TYPE_DEVICE (up_device_get_type ())
+#define UP_DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UP_TYPE_DEVICE, UpDevice))
+#define UP_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), UP_TYPE_DEVICE, UpDeviceClass))
+#define UP_IS_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UP_TYPE_DEVICE))
+#define UP_IS_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UP_TYPE_DEVICE))
+#define UP_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UP_TYPE_DEVICE, UpDeviceClass))
-typedef struct DkpDevicePrivate DkpDevicePrivate;
+typedef struct UpDevicePrivate UpDevicePrivate;
typedef struct
{
GObject parent;
- DkpDevicePrivate *priv;
-} DkpDevice;
+ UpDevicePrivate *priv;
+} UpDevice;
typedef struct
{
GObjectClass parent_class;
/* vtable */
- gboolean (*coldplug) (DkpDevice *device);
- gboolean (*refresh) (DkpDevice *device);
- const gchar *(*get_id) (DkpDevice *device);
- gboolean (*get_on_battery) (DkpDevice *device,
+ gboolean (*coldplug) (UpDevice *device);
+ gboolean (*refresh) (UpDevice *device);
+ const gchar *(*get_id) (UpDevice *device);
+ gboolean (*get_on_battery) (UpDevice *device,
gboolean *on_battery);
- gboolean (*get_low_battery) (DkpDevice *device,
+ gboolean (*get_low_battery) (UpDevice *device,
gboolean *low_battery);
- gboolean (*get_online) (DkpDevice *device,
+ gboolean (*get_online) (UpDevice *device,
gboolean *online);
-} DkpDeviceClass;
+} UpDeviceClass;
typedef enum
{
- DKP_DEVICE_ERROR_GENERAL,
- DKP_DEVICE_NUM_ERRORS
-} DkpDeviceError;
+ UP_DEVICE_ERROR_GENERAL,
+ UP_DEVICE_NUM_ERRORS
+} UpDeviceError;
-#define DKP_DEVICE_ERROR dkp_device_error_quark ()
-#define DKP_DEVICE_TYPE_ERROR (dkp_device_error_get_type ())
+#define UP_DEVICE_ERROR up_device_error_quark ()
+#define UP_DEVICE_TYPE_ERROR (up_device_error_get_type ())
-GQuark dkp_device_error_quark (void);
-GType dkp_device_error_get_type (void);
-GType dkp_device_get_type (void);
-DkpDevice *dkp_device_new (void);
-void dkp_device_test (gpointer user_data);
+GQuark up_device_error_quark (void);
+GType up_device_error_get_type (void);
+GType up_device_get_type (void);
+UpDevice *up_device_new (void);
+void up_device_test (gpointer user_data);
-gboolean dkp_device_coldplug (DkpDevice *device,
+gboolean up_device_coldplug (UpDevice *device,
UpDaemon *daemon,
GObject *native);
-UpDaemon *dkp_device_get_daemon (DkpDevice *device);
-GObject *dkp_device_get_native (DkpDevice *device);
-const gchar *dkp_device_get_object_path (DkpDevice *device);
-gboolean dkp_device_get_on_battery (DkpDevice *device,
+UpDaemon *up_device_get_daemon (UpDevice *device);
+GObject *up_device_get_native (UpDevice *device);
+const gchar *up_device_get_object_path (UpDevice *device);
+gboolean up_device_get_on_battery (UpDevice *device,
gboolean *on_battery);
-gboolean dkp_device_get_low_battery (DkpDevice *device,
+gboolean up_device_get_low_battery (UpDevice *device,
gboolean *low_battery);
-gboolean dkp_device_get_online (DkpDevice *device,
+gboolean up_device_get_online (UpDevice *device,
gboolean *online);
-gboolean dkp_device_refresh_internal (DkpDevice *device);
+gboolean up_device_refresh_internal (UpDevice *device);
/* exported methods */
-gboolean dkp_device_refresh (DkpDevice *device,
+gboolean up_device_refresh (UpDevice *device,
DBusGMethodInvocation *context);
-gboolean dkp_device_get_history (DkpDevice *device,
+gboolean up_device_get_history (UpDevice *device,
const gchar *type,
guint timespan,
guint resolution,
DBusGMethodInvocation *context);
-gboolean dkp_device_get_statistics (DkpDevice *device,
+gboolean up_device_get_statistics (UpDevice *device,
const gchar *type,
DBusGMethodInvocation *context);
G_END_DECLS
-#endif /* __DKP_DEVICE_H__ */
+#endif /* __UP_DEVICE_H__ */
diff --git a/src/up-history.c b/src/up-history.c
index 6f2581a..c1a1c5d 100644
--- a/src/up-history.c
+++ b/src/up-history.c
@@ -45,7 +45,7 @@ struct DkpHistoryPrivate
gint64 time_full_last;
gint64 time_empty_last;
gdouble percentage_last;
- DkpDeviceState state;
+ UpDeviceState state;
GPtrArray *data_rate;
GPtrArray *data_charge;
GPtrArray *data_time_full;
@@ -114,7 +114,7 @@ dkp_history_array_limit_resolution (GPtrArray *array, guint max_num)
guint last;
guint first;
GPtrArray *new;
- DkpDeviceState state = DKP_DEVICE_STATE_UNKNOWN;
+ UpDeviceState state = DKP_DEVICE_STATE_UNKNOWN;
guint64 time_s = 0;
gdouble value = 0;
guint64 count = 0;
@@ -669,7 +669,7 @@ dkp_history_set_id (DkpHistory *history, const gchar *id)
* dkp_history_set_state:
**/
gboolean
-dkp_history_set_state (DkpHistory *history, DkpDeviceState state)
+dkp_history_set_state (DkpHistory *history, UpDeviceState state)
{
g_return_val_if_fail (DKP_IS_HISTORY (history), FALSE);
diff --git a/src/up-history.h b/src/up-history.h
index afabaca..cdac023 100644
--- a/src/up-history.h
+++ b/src/up-history.h
@@ -71,7 +71,7 @@ GPtrArray *dkp_history_get_profile_data (DkpHistory *history,
gboolean dkp_history_set_id (DkpHistory *history,
const gchar *id);
gboolean dkp_history_set_state (DkpHistory *history,
- DkpDeviceState state);
+ UpDeviceState state);
gboolean dkp_history_set_charge_data (DkpHistory *history,
gdouble percentage);
gboolean dkp_history_set_rate_data (DkpHistory *history,
diff --git a/src/up-self-test.c b/src/up-self-test.c
index 594f872..a8184ee 100644
--- a/src/up-self-test.c
+++ b/src/up-self-test.c
@@ -46,8 +46,8 @@ main (int argc, char **argv)
/* tests go here */
up_backend_test (test);
- dkp_device_test (test);
- dkp_device_list_test (test);
+ up_device_test (test);
+ up_device_list_test (test);
dkp_history_test (test);
dkp_native_test (test);
dkp_polkit_test (test);