[gnome-power-manager: 1/4] Remove our local copy of libdevkit-power
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-power-manager: 1/4] Remove our local copy of libdevkit-power
- Date: Tue, 21 Apr 2009 07:31:41 -0400 (EDT)
commit 65d9d7af432330e990c85ec03ef1a1d6e41ba008
Author: Richard Hughes <richard hughsie com>
Date: Sat Apr 18 09:36:44 2009 +0100
Remove our local copy of libdevkit-power
DeviceKit-power 007 ships a shared library which we can use instead of
copying and old version of the library. The new one has proper GObject
setters and getters and so convert the engine to use this new model.
---
Makefile.am | 1 -
configure.ac | 6 +-
libdevkit-power/.gitignore | 9 -
libdevkit-power/Makefile.am | 46 ---
libdevkit-power/dkp-client.c | 534 -----------------------------------
libdevkit-power/dkp-client.h | 76 -----
libdevkit-power/dkp-device.c | 519 ----------------------------------
libdevkit-power/dkp-device.h | 76 -----
libdevkit-power/dkp-enum.c | 205 --------------
libdevkit-power/dkp-enum.h | 72 -----
libdevkit-power/dkp-history-obj.c | 173 ------------
libdevkit-power/dkp-history-obj.h | 51 ----
libdevkit-power/dkp-object.c | 553 -------------------------------------
libdevkit-power/dkp-object.h | 72 -----
libdevkit-power/dkp-stats-obj.c | 120 --------
libdevkit-power/dkp-stats-obj.h | 46 ---
libdevkit-power/dkp-wakeups-obj.c | 104 -------
libdevkit-power/dkp-wakeups-obj.h | 49 ----
libdevkit-power/dkp-wakeups.c | 282 -------------------
libdevkit-power/dkp-wakeups.h | 67 -----
libdevkit-power/egg-debug.c | 1 -
libdevkit-power/egg-debug.h | 1 -
libdevkit-power/egg-obj-list.c | 1 -
libdevkit-power/egg-obj-list.h | 1 -
libdevkit-power/egg-string.c | 1 -
libdevkit-power/egg-string.h | 1 -
src/Makefile.am | 14 +-
src/gpm-ac-adapter.c | 4 +-
src/gpm-control.c | 2 +-
src/gpm-devicekit.c | 299 ++++++++++++--------
src/gpm-devicekit.h | 9 +-
src/gpm-engine.c | 267 +++++++++++-------
src/gpm-engine.h | 19 +-
src/gpm-graph-widget.c | 69 +++--
src/gpm-graph-widget.h | 3 +-
src/gpm-manager.c | 157 +++++++----
src/gpm-marshal.list | 2 +-
src/gpm-point-obj.c | 12 +-
src/gpm-point-obj.h | 6 +-
src/gpm-statistics.c | 304 ++++++++++++---------
src/gpm-tray-icon.c | 29 ++-
41 files changed, 724 insertions(+), 3539 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 240252b..b73e2bf 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,6 @@ ACLOCAL_AMFLAGS = -I m4
SUBDIRS = \
libhal-glib \
- libdevkit-power \
src \
po \
docs \
diff --git a/configure.ac b/configure.ac
index dbef24f..fba2737 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,6 +102,7 @@ XRANDR_REQUIRED=1.2.0
POLKIT_GNOME_REQUIRED=0.8
CANBERRA_REQUIRED=0.10
DEVKIT_REQUIRED=001
+DEVKIT_POWER_REQUIRED=007
dnl ---------------------------------------------------------------------------
dnl - Make above strings available for packaging files (e.g. rpm spec files)
@@ -172,7 +173,9 @@ PKG_CHECK_MODULES(UNIQUE, unique-1.0 >= $UNIQUE_REQUIRED)
AC_SUBST(UNIQUE_CFLAGS)
AC_SUBST(UNIQUE_LIBS)
-PKG_CHECK_MODULES(DEVKIT, devkit-gobject >= $DEVKIT_REQUIRED)
+PKG_CHECK_MODULES(DEVKIT, [
+ devkit-gobject >= $DEVKIT_REQUIRED
+ devkit-power-gobject >= $DEVKIT_POWER_REQUIRED])
AC_SUBST(DEVKIT_CFLAGS)
AC_SUBST(DEVKIT_LIBS)
@@ -623,7 +626,6 @@ applets/Makefile
applets/brightness/Makefile
applets/inhibit/Makefile
libhal-glib/Makefile
-libdevkit-power/Makefile
docs/Makefile
man/Makefile
help/Makefile
diff --git a/libdevkit-power/.gitignore b/libdevkit-power/.gitignore
deleted file mode 100644
index bb7ad05..0000000
--- a/libdevkit-power/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-*.lo
-*.la
-*.o
-.deps
-.libs
-Makefile.in
-hal-marshal.c
-hal-marshal.h
-
diff --git a/libdevkit-power/Makefile.am b/libdevkit-power/Makefile.am
deleted file mode 100644
index 0a774cc..0000000
--- a/libdevkit-power/Makefile.am
+++ /dev/null
@@ -1,46 +0,0 @@
-INCLUDES = \
- $(GLIB_CFLAGS) \
- $(DBUS_CFLAGS) \
- -I$(top_srcdir)/libdevkit-power \
- -DEGG_LOG_FILE=\""$(DKP_LOG_DIR)/DeviceKit-power"\" \
- -DEGG_VERBOSE="\"DKP_VERBOSE\"" \
- -DEGG_LOGGING="\"DKP_LOGGING\"" \
- -DEGG_CONSOLE="\"DKP_CONSOLE\"" \
- -DPACKAGE_DATA_DIR=\""$(datadir)"\" \
- -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
-
-noinst_LTLIBRARIES = \
- libdevkit-power.la
-
-libdevkit_power_la_SOURCES = \
- egg-debug.c \
- egg-debug.h \
- egg-string.c \
- egg-string.h \
- egg-obj-list.c \
- egg-obj-list.h \
- dkp-client.c \
- dkp-client.h \
- dkp-device.c \
- dkp-device.h \
- dkp-wakeups-obj.c \
- dkp-wakeups-obj.h \
- dkp-wakeups.c \
- dkp-wakeups.h \
- dkp-history-obj.h \
- dkp-history-obj.c \
- dkp-stats-obj.h \
- dkp-stats-obj.c \
- dkp-enum.c \
- dkp-enum.h \
- dkp-object.c \
- dkp-object.h
-
-libdevkit_power_la_LIBADD = $(INTLLIBS) $(GLIB_LIBS) $(DBUS_LIBS)
-
-
-clean-local:
- rm -f *~
-
-CLEANFILES = $(BUILT_SOURCES)
-
diff --git a/libdevkit-power/dkp-client.c b/libdevkit-power/dkp-client.c
deleted file mode 100644
index 91d4a09..0000000
--- a/libdevkit-power/dkp-client.c
+++ /dev/null
@@ -1,534 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-
-#include "egg-debug.h"
-#include "dkp-client.h"
-#include "dkp-device.h"
-
-static void dkp_client_class_init (DkpClientClass *klass);
-static void dkp_client_init (DkpClient *client);
-static void dkp_client_finalize (GObject *object);
-
-#define DKP_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_CLIENT, DkpClientPrivate))
-
-struct DkpClientPrivate
-{
- DBusGConnection *bus;
- DBusGProxy *proxy;
- DBusGProxy *prop_proxy;
- GHashTable *hash;
- GPtrArray *array;
-
- gboolean have_properties;
-
- gchar *daemon_version;
- gboolean can_suspend;
- gboolean can_hibernate;
- gboolean on_battery;
- gboolean on_low_battery;
-};
-
-enum {
- DKP_DEVICE_ADDED,
- DKP_DEVICE_CHANGED,
- DKP_DEVICE_REMOVED,
- DKP_CLIENT_CHANGED,
- DKP_CLIENT_LAST_SIGNAL
-};
-
-static guint signals [DKP_CLIENT_LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (DkpClient, dkp_client, G_TYPE_OBJECT)
-
-/**
- * dkp_client_get_device:
- **/
-static DkpDevice *
-dkp_client_get_device (DkpClient *client, const gchar *object_path)
-{
- DkpDevice *device;
- device = g_hash_table_lookup (client->priv->hash, object_path);
- return device;
-}
-
-/**
- * dkp_client_enumerate_devices:
- *
- * Return a list of devices, which need to be unref'd, and the array needs
- * to be freed
- **/
-GPtrArray *
-dkp_client_enumerate_devices (DkpClient *client)
-{
- guint i;
- GPtrArray *array;
- DkpDevice *device;
-
- array = g_ptr_array_new ();
- for (i=0; i<client->priv->array->len; i++) {
- device = g_ptr_array_index (client->priv->array, i);
- g_object_ref (device);
- g_ptr_array_add (array, device);
- }
- return array;
-}
-
-/**
- * dkp_client_enumerate_devices_private:
- **/
-static GPtrArray *
-dkp_client_enumerate_devices_private (DkpClient *client, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
- GPtrArray *devices = NULL;
- GType g_type_array;
-
- g_type_array = dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_OBJECT_PATH);
- ret = dbus_g_proxy_call (client->priv->proxy, "EnumerateDevices", &error_local,
- G_TYPE_INVALID,
- g_type_array, &devices,
- G_TYPE_INVALID);
- if (!ret) {
- egg_warning ("Couldn't enumerate devices: %s", error_local->message);
- if (error != NULL)
- *error = g_error_new (1, 0, "%s", error_local->message);
- g_error_free (error_local);
- }
- return devices;
-}
-
-/**
- * dkp_client_suspend:
- **/
-gboolean
-dkp_client_suspend (DkpClient *client, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
-
- g_return_val_if_fail (DKP_IS_CLIENT (client), FALSE);
- g_return_val_if_fail (client->priv->proxy != NULL, FALSE);
-
- ret = dbus_g_proxy_call (client->priv->proxy, "Suspend", &error_local,
- G_TYPE_INVALID, G_TYPE_INVALID);
- if (!ret) {
- egg_warning ("Couldn't suspend: %s", error_local->message);
- if (error != NULL)
- *error = g_error_new (1, 0, "%s", error_local->message);
- g_error_free (error_local);
- }
- return ret;
-}
-
-/**
- * dkp_client_hibernate:
- **/
-gboolean
-dkp_client_hibernate (DkpClient *client, GError **error)
-{
- gboolean ret;
- GError *error_local = NULL;
-
- g_return_val_if_fail (DKP_IS_CLIENT (client), FALSE);
- g_return_val_if_fail (client->priv->proxy != NULL, FALSE);
-
- ret = dbus_g_proxy_call (client->priv->proxy, "Hibernate", &error_local,
- G_TYPE_INVALID, G_TYPE_INVALID);
- if (!ret) {
- egg_warning ("Couldn't hibernate: %s", error_local->message);
- if (error != NULL)
- *error = g_error_new (1, 0, "%s", error_local->message);
- g_error_free (error_local);
- }
- return ret;
-}
-
-/**
- * dkp_client_ensure_properties:
- **/
-static void
-dkp_client_ensure_properties (DkpClient *client)
-{
- gboolean ret;
- GError *error;
- GHashTable *props;
- GValue *value;
-
- props = NULL;
-
- if (client->priv->have_properties)
- goto out;
-
- error = NULL;
- ret = dbus_g_proxy_call (client->priv->prop_proxy, "GetAll", &error,
- G_TYPE_STRING, "org.freedesktop.DeviceKit.Power",
- G_TYPE_INVALID,
- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), &props,
- G_TYPE_INVALID);
- if (!ret) {
- g_warning ("Error invoking GetAll() to get properties: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
-
- value = g_hash_table_lookup (props, "daemon-version");
- if (value == NULL) {
- g_warning ("No 'daemon-version' property");
- goto out;
- }
- client->priv->daemon_version = g_strdup (g_value_get_string (value));
-
- value = g_hash_table_lookup (props, "can-suspend");
- if (value == NULL) {
- g_warning ("No 'can-suspend' property");
- goto out;
- }
- client->priv->can_suspend = g_value_get_boolean (value);
-
- value = g_hash_table_lookup (props, "can-hibernate");
- if (value == NULL) {
- g_warning ("No 'can-hibernate' property");
- goto out;
- }
- client->priv->can_hibernate = g_value_get_boolean (value);
-
- value = g_hash_table_lookup (props, "on-battery");
- if (value == NULL) {
- g_warning ("No 'on-battery' property");
- goto out;
- }
- client->priv->on_battery = g_value_get_boolean (value);
-
- value = g_hash_table_lookup (props, "on-low-battery");
- if (value == NULL) {
- g_warning ("No 'on-low-battery' property");
- goto out;
- }
- client->priv->on_low_battery = g_value_get_boolean (value);
-
- /* cached */
- client->priv->have_properties = TRUE;
-
- out:
- if (props != NULL)
- g_hash_table_unref (props);
-}
-
-/**
- * dkp_client_get_daemon_version:
- **/
-const gchar *
-dkp_client_get_daemon_version (DkpClient *client)
-{
- g_return_val_if_fail (DKP_IS_CLIENT (client), NULL);
- dkp_client_ensure_properties (client);
- return client->priv->daemon_version;
-}
-
-/**
- * dkp_client_can_hibernate:
- **/
-gboolean
-dkp_client_can_hibernate (DkpClient *client)
-{
- g_return_val_if_fail (DKP_IS_CLIENT (client), FALSE);
- dkp_client_ensure_properties (client);
- return client->priv->can_hibernate;
-}
-
-/**
- * dkp_client_can_suspend:
- **/
-gboolean
-dkp_client_can_suspend (DkpClient *client)
-{
- g_return_val_if_fail (DKP_IS_CLIENT (client), FALSE);
- dkp_client_ensure_properties (client);
- return client->priv->can_suspend;
-}
-
-/**
- * dkp_client_on_battery:
- **/
-gboolean
-dkp_client_on_battery (DkpClient *client)
-{
- g_return_val_if_fail (DKP_IS_CLIENT (client), FALSE);
- dkp_client_ensure_properties (client);
- return client->priv->on_battery;
-}
-
-/**
- * dkp_client_on_low_battery:
- **/
-gboolean
-dkp_client_on_low_battery (DkpClient *client)
-{
- g_return_val_if_fail (DKP_IS_CLIENT (client), FALSE);
- dkp_client_ensure_properties (client);
- return client->priv->on_low_battery;
-}
-
-/**
- * dkp_client_add:
- **/
-static DkpDevice *
-dkp_client_add (DkpClient *client, const gchar *object_path)
-{
- DkpDevice *device;
-
- /* create new device */
- device = dkp_device_new ();
- dkp_device_set_object_path (device, object_path);
-
- g_ptr_array_add (client->priv->array, device);
- g_hash_table_insert (client->priv->hash, g_strdup (object_path), device);
- return device;
-}
-
-/**
- * dkp_client_remove:
- **/
-static gboolean
-dkp_client_remove (DkpClient *client, DkpDevice *device)
-{
- /* deallocate it */
- g_object_unref (device);
-
- g_ptr_array_remove (client->priv->array, device);
- g_hash_table_remove (client->priv->hash, device);
- return TRUE;
-}
-
-/**
- * dkp_client_added_cb:
- **/
-static void
-dkp_device_added_cb (DBusGProxy *proxy, const gchar *object_path, DkpClient *client)
-{
- DkpDevice *device;
-
- /* create new device */
- device = dkp_client_add (client, object_path);
- g_signal_emit (client, signals [DKP_DEVICE_ADDED], 0, device);
-}
-
-/**
- * dkp_client_changed_cb:
- **/
-static void
-dkp_device_changed_cb (DBusGProxy *proxy, const gchar *object_path, DkpClient *client)
-{
- DkpDevice *device;
- device = dkp_client_get_device (client, object_path);
- if (device != NULL)
- g_signal_emit (client, signals [DKP_DEVICE_CHANGED], 0, device);
-}
-
-/**
- * dkp_client_removed_cb:
- **/
-static void
-dkp_device_removed_cb (DBusGProxy *proxy, const gchar *object_path, DkpClient *client)
-{
- DkpDevice *device;
- device = dkp_client_get_device (client, object_path);
- if (device != NULL)
- g_signal_emit (client, signals [DKP_DEVICE_REMOVED], 0, device);
- dkp_client_remove (client, device);
-}
-
-/**
- * dkp_client_changed_cb:
- **/
-static void
-dkp_client_changed_cb (DBusGProxy *proxy, DkpClient *client)
-{
- client->priv->have_properties = FALSE;
- g_signal_emit (client, signals [DKP_CLIENT_CHANGED], 0);
-}
-
-/**
- * dkp_client_class_init:
- * @klass: The DkpClientClass
- **/
-static void
-dkp_client_class_init (DkpClientClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = dkp_client_finalize;
-
- signals [DKP_DEVICE_ADDED] =
- g_signal_new ("device-added",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DkpClientClass, device_added),
- NULL, NULL, g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
- signals [DKP_DEVICE_REMOVED] =
- g_signal_new ("device-removed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DkpClientClass, device_removed),
- NULL, NULL, g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
- signals [DKP_DEVICE_CHANGED] =
- g_signal_new ("device-changed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DkpClientClass, device_changed),
- NULL, NULL, g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
- signals [DKP_CLIENT_CHANGED] =
- g_signal_new ("changed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DkpClientClass, changed),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- g_type_class_add_private (klass, sizeof (DkpClientPrivate));
-}
-
-/**
- * dkp_client_init:
- * @client: This class instance
- **/
-static void
-dkp_client_init (DkpClient *client)
-{
- GError *error = NULL;
- const gchar *object_path;
- GPtrArray *devices;
- guint i;
-
- client->priv = DKP_CLIENT_GET_PRIVATE (client);
- client->priv->hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- client->priv->array = g_ptr_array_new ();
-
- /* get on the bus */
- client->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (client->priv->bus == NULL) {
- egg_warning ("Couldn't connect to system bus: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- /* connect to main interface */
- client->priv->proxy = dbus_g_proxy_new_for_name (client->priv->bus,
- "org.freedesktop.DeviceKit.Power",
- "/org/freedesktop/DeviceKit/Power",
- "org.freedesktop.DeviceKit.Power");
- if (client->priv->proxy == NULL) {
- egg_warning ("Couldn't connect to proxy");
- goto out;
- }
-
- client->priv->prop_proxy = dbus_g_proxy_new_for_name (client->priv->bus,
- "org.freedesktop.DeviceKit.Power",
- "/org/freedesktop/DeviceKit/Power",
- "org.freedesktop.DBus.Properties");
- if (client->priv->prop_proxy == NULL) {
- egg_warning ("Couldn't connect to proxy");
- goto out;
- }
-
- dbus_g_proxy_add_signal (client->priv->proxy, "DeviceAdded", G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (client->priv->proxy, "DeviceRemoved", G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (client->priv->proxy, "DeviceChanged", G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (client->priv->proxy, "Changed", G_TYPE_INVALID);
-
- /* all callbacks */
- dbus_g_proxy_connect_signal (client->priv->proxy, "DeviceAdded",
- G_CALLBACK (dkp_device_added_cb), client, NULL);
- dbus_g_proxy_connect_signal (client->priv->proxy, "DeviceRemoved",
- G_CALLBACK (dkp_device_removed_cb), client, NULL);
- dbus_g_proxy_connect_signal (client->priv->proxy, "DeviceChanged",
- G_CALLBACK (dkp_device_changed_cb), client, NULL);
- dbus_g_proxy_connect_signal (client->priv->proxy, "Changed",
- G_CALLBACK (dkp_client_changed_cb), client, NULL);
-
- /* coldplug */
- devices = dkp_client_enumerate_devices_private (client, NULL);
- if (devices == NULL)
- goto out;
- for (i=0; i<devices->len; i++) {
- object_path = (const gchar *) g_ptr_array_index (devices, i);
- dkp_client_add (client, object_path);
- }
-out:
- return;
-}
-
-/**
- * dkp_client_finalize:
- * @object: The object to finalize
- **/
-static void
-dkp_client_finalize (GObject *object)
-{
- DkpClient *client;
- DkpDevice *device;
- guint i;
-
- g_return_if_fail (DKP_IS_CLIENT (object));
-
- client = DKP_CLIENT (object);
-
- /* free any devices */
- for (i=0; i<client->priv->array->len; i++) {
- device = (DkpDevice *) g_ptr_array_index (client->priv->array, i);
- dkp_client_remove (client, device);
- }
-
- g_ptr_array_free (client->priv->array, TRUE);
- g_hash_table_unref (client->priv->hash);
- dbus_g_connection_unref (client->priv->bus);
-
- if (client->priv->proxy != NULL)
- g_object_unref (client->priv->proxy);
-
- if (client->priv->prop_proxy != NULL)
- g_object_unref (client->priv->prop_proxy);
-
- g_free (client->priv->daemon_version);
-
- G_OBJECT_CLASS (dkp_client_parent_class)->finalize (object);
-}
-
-/**
- * dkp_client_new:
- *
- * Return value: a new DkpClient object.
- **/
-DkpClient *
-dkp_client_new (void)
-{
- DkpClient *client;
- client = g_object_new (DKP_TYPE_CLIENT, NULL);
- return DKP_CLIENT (client);
-}
-
diff --git a/libdevkit-power/dkp-client.h b/libdevkit-power/dkp-client.h
deleted file mode 100644
index 785f240..0000000
--- a/libdevkit-power/dkp-client.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __DKP_CLIENT_H
-#define __DKP_CLIENT_H
-
-#include <glib-object.h>
-#include <dkp-enum.h>
-#include "dkp-device.h"
-
-G_BEGIN_DECLS
-
-#define DKP_TYPE_CLIENT (dkp_client_get_type ())
-#define DKP_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DKP_TYPE_CLIENT, DkpClient))
-#define DKP_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DKP_TYPE_CLIENT, DkpClientClass))
-#define DKP_IS_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DKP_TYPE_CLIENT))
-#define DKP_IS_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DKP_TYPE_CLIENT))
-#define DKP_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DKP_TYPE_CLIENT, DkpClientClass))
-#define DKP_CLIENT_ERROR (dkp_client_error_quark ())
-#define DKP_CLIENT_TYPE_ERROR (dkp_client_error_get_type ())
-
-typedef struct DkpClientPrivate DkpClientPrivate;
-
-typedef struct
-{
- GObject parent;
- DkpClientPrivate *priv;
-} DkpClient;
-
-typedef struct
-{
- GObjectClass parent_class;
- void (*device_added) (DkpClient *client,
- const DkpDevice *device);
- void (*device_changed) (DkpClient *client,
- const DkpDevice *device);
- void (*device_removed) (DkpClient *client,
- const DkpDevice *device);
- void (*changed) (DkpClient *client);
-} DkpClientClass;
-
-GType dkp_client_get_type (void);
-DkpClient *dkp_client_new (void);
-GPtrArray *dkp_client_enumerate_devices (DkpClient *client);
-gboolean dkp_client_suspend (DkpClient *client,
- GError **error);
-gboolean dkp_client_hibernate (DkpClient *client,
- GError **error);
-const gchar *dkp_client_get_daemon_version (DkpClient *client);
-gboolean dkp_client_can_hibernate (DkpClient *client);
-gboolean dkp_client_can_suspend (DkpClient *client);
-gboolean dkp_client_on_battery (DkpClient *client);
-gboolean dkp_client_on_low_battery (DkpClient *client);
-
-G_END_DECLS
-
-#endif /* __DKP_CLIENT_H */
-
diff --git a/libdevkit-power/dkp-device.c b/libdevkit-power/dkp-device.c
deleted file mode 100644
index 1949b9e..0000000
--- a/libdevkit-power/dkp-device.c
+++ /dev/null
@@ -1,519 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-
-#include "egg-debug.h"
-#include "egg-obj-list.h"
-
-#include "dkp-device.h"
-#include "dkp-object.h"
-#include "dkp-stats-obj.h"
-#include "dkp-history-obj.h"
-
-static void dkp_device_class_init (DkpDeviceClass *klass);
-static void dkp_device_init (DkpDevice *device);
-static void dkp_device_finalize (GObject *object);
-
-#define DKP_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_DEVICE, DkpDevicePrivate))
-
-struct DkpDevicePrivate
-{
- gchar *object_path;
- DkpObject *obj;
- DBusGConnection *bus;
- DBusGProxy *proxy_device;
- DBusGProxy *proxy_props;
-};
-
-enum {
- DKP_DEVICE_CHANGED,
- DKP_DEVICE_LAST_SIGNAL
-};
-
-static guint signals [DKP_DEVICE_LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (DkpDevice, dkp_device, G_TYPE_OBJECT)
-
-/**
- * dkp_device_get_device_properties:
- **/
-static GHashTable *
-dkp_device_get_device_properties (DkpDevice *device)
-{
- gboolean ret;
- GError *error = NULL;
- GHashTable *hash_table = NULL;
-
- ret = dbus_g_proxy_call (device->priv->proxy_props, "GetAll", &error,
- G_TYPE_STRING, "org.freedesktop.DeviceKit.Power.Device",
- G_TYPE_INVALID,
- dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
- &hash_table,
- G_TYPE_INVALID);
- if (!ret) {
- egg_debug ("Couldn't call GetAll() to get properties for %s: %s", device->priv->object_path, error->message);
- g_error_free (error);
- goto out;
- }
-out:
- return hash_table;
-}
-
-/**
- * dkp_device_refresh_internal:
- **/
-static gboolean
-dkp_device_refresh_internal (DkpDevice *device)
-{
- GHashTable *hash;
-
- /* get all the properties */
- hash = dkp_device_get_device_properties (device);
- if (hash == NULL) {
- egg_warning ("Cannot get device properties for %s", device->priv->object_path);
- return FALSE;
- }
- dkp_object_set_from_map (device->priv->obj, hash);
- g_hash_table_unref (hash);
- return TRUE;
-}
-
-/**
- * dkp_device_changed_cb:
- **/
-static void
-dkp_device_changed_cb (DBusGProxy *proxy, DkpDevice *device)
-{
- g_return_if_fail (DKP_IS_DEVICE (device));
- dkp_device_refresh_internal (device);
- g_signal_emit (device, signals [DKP_DEVICE_CHANGED], 0, device->priv->obj);
-}
-
-/**
- * dkp_device_set_object_path:
- **/
-gboolean
-dkp_device_set_object_path (DkpDevice *device, const gchar *object_path)
-{
- GError *error = NULL;
- gboolean ret = FALSE;
- DBusGProxy *proxy_device;
- DBusGProxy *proxy_props;
-
- g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
-
- if (device->priv->object_path != NULL)
- return FALSE;
- if (object_path == NULL)
- return FALSE;
-
- /* connect to the bus */
- device->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (device->priv->bus == NULL) {
- egg_warning ("Couldn't connect to system bus: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- /* connect to the correct path for properties */
- proxy_props = dbus_g_proxy_new_for_name (device->priv->bus, "org.freedesktop.DeviceKit.Power",
- object_path, "org.freedesktop.DBus.Properties");
- if (proxy_props == NULL) {
- egg_warning ("Couldn't connect to proxy");
- goto out;
- }
-
- /* connect to the correct path for all the other methods */
- proxy_device = dbus_g_proxy_new_for_name (device->priv->bus, "org.freedesktop.DeviceKit.Power",
- object_path, "org.freedesktop.DeviceKit.Power.Device");
- if (proxy_device == NULL) {
- egg_warning ("Couldn't connect to proxy");
- goto out;
- }
-
- /* listen to Changed */
- dbus_g_proxy_add_signal (proxy_device, "Changed", G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy_device, "Changed",
- G_CALLBACK (dkp_device_changed_cb), device, NULL);
-
- /* yay */
- egg_debug ("using object_path: %s", object_path);
- device->priv->proxy_device = proxy_device;
- device->priv->proxy_props = proxy_props;
- device->priv->object_path = g_strdup (object_path);
-
- /* coldplug */
- ret = dkp_device_refresh_internal (device);
- if (!ret)
- egg_warning ("cannot refresh");
-out:
- return ret;
-}
-
-/**
- * dkp_device_get_object_path:
- **/
-const gchar *
-dkp_device_get_object_path (const DkpDevice *device)
-{
- g_return_val_if_fail (DKP_IS_DEVICE (device), NULL);
- return device->priv->object_path;
-}
-
-/**
- * dkp_device_get_object:
- **/
-const DkpObject *
-dkp_device_get_object (const DkpDevice *device)
-{
- g_return_val_if_fail (DKP_IS_DEVICE (device), NULL);
- return device->priv->obj;
-}
-
-/**
- * dkp_device_print_history:
- **/
-static gboolean
-dkp_device_print_history (const DkpDevice *device, const gchar *type)
-{
- guint i;
- EggObjList *array;
- DkpHistoryObj *obj;
- gboolean ret = FALSE;
-
- /* get a fair chunk of data */
- array = dkp_device_get_history (device, type, 120, 10);
- if (array == NULL)
- goto out;
-
- /* pretty print */
- g_print (" History (%s):\n", type);
- for (i=0; i<array->len; i++) {
- obj = (DkpHistoryObj *) egg_obj_list_index (array, i);
- g_print (" %i\t%.3f\t%s\n", obj->time, obj->value, dkp_device_state_to_text (obj->state));
- }
- g_object_unref (array);
- ret = TRUE;
-out:
- return ret;
-}
-
-/**
- * dkp_device_print:
- **/
-gboolean
-dkp_device_print (const DkpDevice *device)
-{
- g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
-
- /* print to screen */
- dkp_object_print (device->priv->obj);
-
- /* if we can, get history */
- dkp_device_print_history (device, "charge");
- dkp_device_print_history (device, "rate");
-
- return TRUE;
-}
-
-/**
- * dkp_device_refresh:
- **/
-gboolean
-dkp_device_refresh (DkpDevice *device)
-{
- GError *error = NULL;
- gboolean ret;
-
- g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
- g_return_val_if_fail (device->priv->proxy_device != NULL, FALSE);
-
- /* just refresh the device */
- ret = dbus_g_proxy_call (device->priv->proxy_device, "Refresh", &error,
- G_TYPE_INVALID, G_TYPE_INVALID);
- if (!ret) {
- egg_debug ("Refresh() on %s failed: %s", device->priv->object_path, error->message);
- g_error_free (error);
- goto out;
- }
-out:
- return ret;
-}
-
-/**
- * dkp_device_get_history:
- *
- * Returns an array of %DkpHistoryObj's
- **/
-EggObjList *
-dkp_device_get_history (const DkpDevice *device, const gchar *type, guint timespec, guint resolution)
-{
- GError *error = NULL;
- GType g_type_gvalue_array_old;
- GType g_type_gvalue_array_new;
- GPtrArray *gvalue_ptr_array = NULL;
- GValueArray *gva;
- GValue *gv;
- guint i;
- DkpHistoryObj *obj;
- EggObjList *array = NULL;
- gboolean ret;
-
- g_return_val_if_fail (DKP_IS_DEVICE (device), NULL);
- g_return_val_if_fail (device->priv->proxy_device != NULL, NULL);
-
- g_type_gvalue_array_old = dbus_g_type_get_collection ("GPtrArray",
- dbus_g_type_get_struct("GValueArray",
- G_TYPE_UINT,
- G_TYPE_DOUBLE,
- G_TYPE_STRING,
- G_TYPE_INVALID));
- g_type_gvalue_array_new = dbus_g_type_get_collection ("GPtrArray",
- dbus_g_type_get_struct("GValueArray",
- G_TYPE_UINT,
- G_TYPE_DOUBLE,
- G_TYPE_UINT,
- G_TYPE_INVALID));
-
- /* get compound data */
- ret = dbus_g_proxy_call (device->priv->proxy_device, "GetHistory", &error,
- G_TYPE_STRING, type,
- G_TYPE_UINT, timespec,
- G_TYPE_UINT, resolution,
- G_TYPE_INVALID,
- g_type_gvalue_array_new, &gvalue_ptr_array,
- G_TYPE_INVALID);
-
- /* this failed, try with the old daemon */
- if (!ret && error->code == 16) {
- egg_warning ("falling back to old daemon type");
- g_clear_error (&error);
- ret = dbus_g_proxy_call (device->priv->proxy_device, "GetHistory", &error,
- G_TYPE_STRING, type,
- G_TYPE_UINT, timespec,
- G_TYPE_UINT, resolution,
- G_TYPE_INVALID,
- g_type_gvalue_array_old, &gvalue_ptr_array,
- G_TYPE_INVALID);
- }
-
- /* we failed */
- if (!ret) {
- egg_debug ("GetHistory(%s,%i) on %s failed: %s", type, timespec,
- device->priv->object_path, error->message);
- g_error_free (error);
- goto out;
- }
-
- /* no data */
- if (gvalue_ptr_array->len == 0)
- goto out;
-
- /* convert */
- array = egg_obj_list_new ();
- egg_obj_list_set_copy (array, (EggObjListCopyFunc) dkp_history_obj_copy);
- egg_obj_list_set_free (array, (EggObjListFreeFunc) dkp_history_obj_free);
-
- for (i=0; i<gvalue_ptr_array->len; i++) {
- gva = (GValueArray *) g_ptr_array_index (gvalue_ptr_array, i);
- obj = dkp_history_obj_new ();
- /* 0 */
- gv = g_value_array_get_nth (gva, 0);
- obj->time = g_value_get_uint (gv);
- g_value_unset (gv);
- /* 1 */
- gv = g_value_array_get_nth (gva, 1);
- obj->value = g_value_get_double (gv);
- g_value_unset (gv);
- /* 2 */
- gv = g_value_array_get_nth (gva, 2);
- if (G_VALUE_HOLDS_STRING(gv))
- obj->state = dkp_device_state_from_text (g_value_get_string (gv));
- else
- obj->state = g_value_get_uint (gv);
- g_value_unset (gv);
- egg_obj_list_add (array, obj);
- dkp_history_obj_free (obj);
- g_value_array_free (gva);
- }
-
-out:
- if (gvalue_ptr_array != NULL)
- g_ptr_array_free (gvalue_ptr_array, TRUE);
- return array;
-}
-
-/**
- * dkp_device_get_statistics:
- *
- * Returns an array of %DkpStatsObj's
- **/
-EggObjList *
-dkp_device_get_statistics (const DkpDevice *device, const gchar *type)
-{
- GError *error = NULL;
- GType g_type_gvalue_array;
- GPtrArray *gvalue_ptr_array = NULL;
- GValueArray *gva;
- GValue *gv;
- guint i;
- DkpStatsObj *obj;
- EggObjList *array = NULL;
- gboolean ret;
-
- g_return_val_if_fail (DKP_IS_DEVICE (device), NULL);
- g_return_val_if_fail (device->priv->proxy_device != NULL, NULL);
-
- g_type_gvalue_array = dbus_g_type_get_collection ("GPtrArray",
- dbus_g_type_get_struct("GValueArray",
- G_TYPE_DOUBLE,
- G_TYPE_DOUBLE,
- G_TYPE_INVALID));
-
- /* get compound data */
- ret = dbus_g_proxy_call (device->priv->proxy_device, "GetStatistics", &error,
- G_TYPE_STRING, type,
- G_TYPE_INVALID,
- g_type_gvalue_array, &gvalue_ptr_array,
- G_TYPE_INVALID);
- if (!ret) {
- egg_debug ("GetStatistics(%s) on %s failed: %s", type,
- device->priv->object_path, error->message);
- g_error_free (error);
- goto out;
- }
-
- /* no data */
- if (gvalue_ptr_array->len == 0)
- goto out;
-
- /* convert */
- array = egg_obj_list_new ();
- egg_obj_list_set_copy (array, (EggObjListCopyFunc) dkp_stats_obj_copy);
- egg_obj_list_set_free (array, (EggObjListFreeFunc) dkp_stats_obj_free);
- egg_obj_list_set_to_string (array, (EggObjListToStringFunc) dkp_stats_obj_to_string);
- egg_obj_list_set_from_string (array, (EggObjListFromStringFunc) dkp_stats_obj_from_string);
-
- for (i=0; i<gvalue_ptr_array->len; i++) {
- gva = (GValueArray *) g_ptr_array_index (gvalue_ptr_array, i);
- obj = dkp_stats_obj_new ();
- /* 0 */
- gv = g_value_array_get_nth (gva, 0);
- obj->value = g_value_get_double (gv);
- g_value_unset (gv);
- /* 1 */
- gv = g_value_array_get_nth (gva, 1);
- obj->accuracy = g_value_get_double (gv);
- g_value_unset (gv);
- /* 2 */
- egg_obj_list_add (array, obj);
- dkp_stats_obj_free (obj);
- g_value_array_free (gva);
- }
-out:
- if (gvalue_ptr_array != NULL)
- g_ptr_array_free (gvalue_ptr_array, TRUE);
- return array;
-}
-
-/**
- * dkp_device_class_init:
- * @klass: The DkpDeviceClass
- **/
-static void
-dkp_device_class_init (DkpDeviceClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = dkp_device_finalize;
-
- /**
- * PkClient::changed:
- * @device: the #DkpDevice instance that emitted the signal
- * @obj: the #DkpObject that has changed
- *
- * The ::changed signal is emitted when the device data has changed.
- **/
- signals [DKP_DEVICE_CHANGED] =
- g_signal_new ("changed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DkpDeviceClass, changed),
- NULL, NULL, g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
-
- g_type_class_add_private (klass, sizeof (DkpDevicePrivate));
-}
-
-/**
- * dkp_device_init:
- * @device: This class instance
- **/
-static void
-dkp_device_init (DkpDevice *device)
-{
- device->priv = DKP_DEVICE_GET_PRIVATE (device);
- device->priv->object_path = NULL;
- device->priv->proxy_device = NULL;
- device->priv->proxy_props = NULL;
- device->priv->obj = dkp_object_new ();
-}
-
-/**
- * dkp_device_finalize:
- * @object: The object to finalize
- **/
-static void
-dkp_device_finalize (GObject *object)
-{
- DkpDevice *device;
-
- g_return_if_fail (DKP_IS_DEVICE (object));
-
- device = DKP_DEVICE (object);
-
- g_free (device->priv->object_path);
- dkp_object_free (device->priv->obj);
- if (device->priv->proxy_device != NULL)
- g_object_unref (device->priv->proxy_device);
- if (device->priv->proxy_props != NULL)
- g_object_unref (device->priv->proxy_props);
-
- G_OBJECT_CLASS (dkp_device_parent_class)->finalize (object);
-}
-
-/**
- * dkp_device_new:
- *
- * Return value: a new DkpDevice object.
- **/
-DkpDevice *
-dkp_device_new (void)
-{
- DkpDevice *device;
- device = g_object_new (DKP_TYPE_DEVICE, NULL);
- return DKP_DEVICE (device);
-}
-
diff --git a/libdevkit-power/dkp-device.h b/libdevkit-power/dkp-device.h
deleted file mode 100644
index 3171d91..0000000
--- a/libdevkit-power/dkp-device.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __DKP_DEVICE_H
-#define __DKP_DEVICE_H
-
-#include <glib-object.h>
-#include <dkp-enum.h>
-#include <dkp-object.h>
-#include "egg-obj-list.h"
-
-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 DKP_DEVICE_ERROR (dkp_device_error_quark ())
-#define DKP_DEVICE_TYPE_ERROR (dkp_device_error_get_type ())
-
-typedef struct DkpDevicePrivate DkpDevicePrivate;
-
-typedef struct
-{
- GObject parent;
- DkpDevicePrivate *priv;
-} DkpDevice;
-
-typedef struct
-{
- GObjectClass parent_class;
- void (*changed) (DkpDevice *device,
- const DkpObject *obj);
-} DkpDeviceClass;
-
-GType dkp_device_get_type (void);
-DkpDevice *dkp_device_new (void);
-
-const DkpObject *dkp_device_get_object (const DkpDevice *device);
-const gchar *dkp_device_get_object_path (const DkpDevice *device);
-gboolean dkp_device_set_object_path (DkpDevice *device,
- const gchar *object_path);
-
-gboolean dkp_device_print (const DkpDevice *device);
-gboolean dkp_device_refresh (DkpDevice *device);
-EggObjList *dkp_device_get_history (const DkpDevice *device,
- const gchar *type,
- guint timespec,
- guint resolution);
-EggObjList *dkp_device_get_statistics (const DkpDevice *device,
- const gchar *type);
-
-G_END_DECLS
-
-#endif /* __DKP_DEVICE_H */
-
diff --git a/libdevkit-power/dkp-enum.c b/libdevkit-power/dkp-enum.c
deleted file mode 100644
index be93e7e..0000000
--- a/libdevkit-power/dkp-enum.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 David Zeuthen <davidz redhat com>
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <glib.h>
-#include <string.h>
-#include "egg-debug.h"
-#include "egg-string.h"
-
-#include "dkp-enum.h"
-
-/**
- * dkp_device_type_to_text:
- **/
-const gchar *
-dkp_device_type_to_text (DkpDeviceType type_enum)
-{
- const gchar *type = NULL;
- switch (type_enum) {
- case DKP_DEVICE_TYPE_LINE_POWER:
- type = "line-power";
- break;
- case DKP_DEVICE_TYPE_BATTERY:
- type = "battery";
- break;
- case DKP_DEVICE_TYPE_UPS:
- type = "ups";
- break;
- case DKP_DEVICE_TYPE_MONITOR:
- type = "monitor";
- break;
- case DKP_DEVICE_TYPE_MOUSE:
- type = "mouse";
- break;
- case DKP_DEVICE_TYPE_KEYBOARD:
- type = "keyboard";
- break;
- case DKP_DEVICE_TYPE_PDA:
- type = "pda";
- break;
- case DKP_DEVICE_TYPE_PHONE:
- type = "phone";
- break;
- case DKP_DEVICE_TYPE_UNKNOWN:
- type = "unknown";
- break;
- default:
- g_assert_not_reached ();
- break;
- }
- return type;
-}
-
-/**
- * dkp_device_type_from_text:
- **/
-DkpDeviceType
-dkp_device_type_from_text (const gchar *type)
-{
- if (type == NULL)
- return DKP_DEVICE_TYPE_UNKNOWN;
- if (egg_strequal (type, "line-power"))
- return DKP_DEVICE_TYPE_LINE_POWER;
- if (egg_strequal (type, "battery"))
- return DKP_DEVICE_TYPE_BATTERY;
- if (egg_strequal (type, "ups"))
- return DKP_DEVICE_TYPE_UPS;
- if (egg_strequal (type, "monitor"))
- return DKP_DEVICE_TYPE_MONITOR;
- if (egg_strequal (type, "mouse"))
- return DKP_DEVICE_TYPE_MOUSE;
- if (egg_strequal (type, "keyboard"))
- return DKP_DEVICE_TYPE_KEYBOARD;
- if (egg_strequal (type, "pda"))
- return DKP_DEVICE_TYPE_PDA;
- if (egg_strequal (type, "phone"))
- return DKP_DEVICE_TYPE_PHONE;
- return DKP_DEVICE_TYPE_UNKNOWN;
-}
-
-/**
- * dkp_device_state_to_text:
- **/
-const gchar *
-dkp_device_state_to_text (DkpDeviceState state_enum)
-{
- const gchar *state = NULL;
- switch (state_enum) {
- case DKP_DEVICE_STATE_CHARGING:
- state = "charging";
- break;
- case DKP_DEVICE_STATE_DISCHARGING:
- state = "discharging";
- break;
- case DKP_DEVICE_STATE_EMPTY:
- state = "empty";
- break;
- case DKP_DEVICE_STATE_FULLY_CHARGED:
- state = "fully-charged";
- break;
- case DKP_DEVICE_STATE_UNKNOWN:
- state = "unknown";
- break;
- default:
- g_assert_not_reached ();
- break;
- }
- return state;
-}
-
-/**
- * dkp_device_state_from_text:
- **/
-DkpDeviceState
-dkp_device_state_from_text (const gchar *state)
-{
- if (state == NULL)
- return DKP_DEVICE_STATE_UNKNOWN;
- if (egg_strequal (state, "charging"))
- return DKP_DEVICE_STATE_CHARGING;
- if (egg_strequal (state, "discharging"))
- return DKP_DEVICE_STATE_DISCHARGING;
- if (egg_strequal (state, "empty"))
- return DKP_DEVICE_STATE_EMPTY;
- if (egg_strequal (state, "fully-charged"))
- return DKP_DEVICE_STATE_FULLY_CHARGED;
- return DKP_DEVICE_STATE_UNKNOWN;
-}
-
-/**
- * dkp_device_technology_to_text:
- **/
-const gchar *
-dkp_device_technology_to_text (DkpDeviceTechnology technology_enum)
-{
- const gchar *technology = NULL;
- switch (technology_enum) {
- case DKP_DEVICE_TECHNOLGY_LITHIUM_ION:
- technology = "lithium-ion";
- break;
- case DKP_DEVICE_TECHNOLGY_LITHIUM_POLYMER:
- technology = "lithium-polymer";
- break;
- case DKP_DEVICE_TECHNOLGY_LITHIUM_IRON_PHOSPHATE:
- technology = "lithium-iron-phosphate";
- break;
- case DKP_DEVICE_TECHNOLGY_LEAD_ACID:
- technology = "lead-acid";
- break;
- case DKP_DEVICE_TECHNOLGY_NICKEL_CADMIUM:
- technology = "nickel-cadmium";
- break;
- case DKP_DEVICE_TECHNOLGY_NICKEL_METAL_HYDRIDE:
- technology = "nickel-metal-hydride";
- break;
- case DKP_DEVICE_TECHNOLGY_UNKNOWN:
- technology = "unknown";
- break;
- default:
- g_assert_not_reached ();
- break;
- }
- return technology;
-}
-
-/**
- * dkp_device_technology_from_text:
- **/
-DkpDeviceTechnology
-dkp_device_technology_from_text (const gchar *technology)
-{
- if (technology == NULL)
- return DKP_DEVICE_TECHNOLGY_UNKNOWN;
- if (egg_strequal (technology, "lithium-ion"))
- return DKP_DEVICE_TECHNOLGY_LITHIUM_ION;
- if (egg_strequal (technology, "lithium-polymer"))
- return DKP_DEVICE_TECHNOLGY_LITHIUM_POLYMER;
- if (egg_strequal (technology, "lithium-iron-phosphate"))
- return DKP_DEVICE_TECHNOLGY_LITHIUM_IRON_PHOSPHATE;
- if (egg_strequal (technology, "lead-acid"))
- return DKP_DEVICE_TECHNOLGY_LEAD_ACID;
- if (egg_strequal (technology, "nickel-cadmium"))
- return DKP_DEVICE_TECHNOLGY_NICKEL_CADMIUM;
- if (egg_strequal (technology, "nickel-metal-hydride"))
- return DKP_DEVICE_TECHNOLGY_NICKEL_METAL_HYDRIDE;
- return DKP_DEVICE_TECHNOLGY_UNKNOWN;
-}
-
diff --git a/libdevkit-power/dkp-enum.h b/libdevkit-power/dkp-enum.h
deleted file mode 100644
index 11241e4..0000000
--- a/libdevkit-power/dkp-enum.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 David Zeuthen <davidz redhat com>
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef __DKP_ENUM_H__
-#define __DKP_ENUM_H__
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-typedef enum {
- DKP_DEVICE_TYPE_UNKNOWN,
- DKP_DEVICE_TYPE_LINE_POWER,
- DKP_DEVICE_TYPE_BATTERY,
- DKP_DEVICE_TYPE_UPS,
- DKP_DEVICE_TYPE_MONITOR,
- DKP_DEVICE_TYPE_MOUSE,
- DKP_DEVICE_TYPE_KEYBOARD,
- DKP_DEVICE_TYPE_PDA,
- DKP_DEVICE_TYPE_PHONE,
- DKP_DEVICE_TYPE_LAST
-} DkpDeviceType;
-
-typedef enum {
- DKP_DEVICE_STATE_UNKNOWN,
- DKP_DEVICE_STATE_CHARGING,
- DKP_DEVICE_STATE_DISCHARGING,
- DKP_DEVICE_STATE_EMPTY,
- DKP_DEVICE_STATE_FULLY_CHARGED,
- DKP_DEVICE_STATE_LAST
-} DkpDeviceState;
-
-typedef enum {
- DKP_DEVICE_TECHNOLGY_UNKNOWN,
- DKP_DEVICE_TECHNOLGY_LITHIUM_ION,
- DKP_DEVICE_TECHNOLGY_LITHIUM_POLYMER,
- DKP_DEVICE_TECHNOLGY_LITHIUM_IRON_PHOSPHATE,
- DKP_DEVICE_TECHNOLGY_LEAD_ACID,
- DKP_DEVICE_TECHNOLGY_NICKEL_CADMIUM,
- DKP_DEVICE_TECHNOLGY_NICKEL_METAL_HYDRIDE,
- DKP_DEVICE_TECHNOLGY_LAST
-} DkpDeviceTechnology;
-
-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);
-DkpDeviceType dkp_device_type_from_text (const gchar *type);
-DkpDeviceState dkp_device_state_from_text (const gchar *state);
-DkpDeviceTechnology dkp_device_technology_from_text (const gchar *technology);
-
-G_END_DECLS
-
-#endif /* __DKP_ENUM_H__ */
-
diff --git a/libdevkit-power/dkp-history-obj.c b/libdevkit-power/dkp-history-obj.c
deleted file mode 100644
index 5727cb9..0000000
--- a/libdevkit-power/dkp-history-obj.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <glib.h>
-#include <glib-object.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "egg-debug.h"
-#include "dkp-enum.h"
-#include "dkp-history-obj.h"
-
-/**
- * dkp_history_obj_clear_internal:
- **/
-static void
-dkp_history_obj_clear_internal (DkpHistoryObj *obj)
-{
- obj->time = 0;
- obj->value = 0.0f;
- obj->state = 0;
-}
-
-/**
- * dkp_history_obj_copy:
- **/
-DkpHistoryObj *
-dkp_history_obj_copy (const DkpHistoryObj *cobj)
-{
- DkpHistoryObj *obj;
- obj = g_new0 (DkpHistoryObj, 1);
- obj->time = cobj->time;
- obj->value = cobj->value;
- obj->state = cobj->state;
- return obj;
-}
-
-/**
- * dkp_history_obj_equal:
- **/
-gboolean
-dkp_history_obj_equal (const DkpHistoryObj *obj1, const DkpHistoryObj *obj2)
-{
- if (obj1->time == obj2->time &&
- obj1->value == obj2->value &&
- obj1->state == obj2->state)
- return TRUE;
- return FALSE;
-}
-
-/**
- * dkp_history_obj_print:
- **/
-gboolean
-dkp_history_obj_print (const DkpHistoryObj *obj)
-{
- g_print ("%i\t%.3f\t%s", obj->time, obj->value, dkp_device_state_to_text (obj->state));
- return TRUE;
-}
-
-/**
- * dkp_history_obj_new:
- **/
-DkpHistoryObj *
-dkp_history_obj_new (void)
-{
- DkpHistoryObj *obj;
- obj = g_new0 (DkpHistoryObj, 1);
- dkp_history_obj_clear_internal (obj);
- return obj;
-}
-
-/**
- * dkp_history_obj_clear:
- **/
-gboolean
-dkp_history_obj_clear (DkpHistoryObj *obj)
-{
- if (obj == NULL)
- return FALSE;
- dkp_history_obj_free (obj);
- dkp_history_obj_clear_internal (obj);
- return TRUE;
-}
-
-/**
- * dkp_history_obj_free:
- **/
-gboolean
-dkp_history_obj_free (DkpHistoryObj *obj)
-{
- if (obj == NULL)
- return FALSE;
- g_free (obj);
- return TRUE;
-}
-
-/**
- * dkp_history_obj_create:
- **/
-DkpHistoryObj *
-dkp_history_obj_create (gdouble value, DkpDeviceState state)
-{
- DkpHistoryObj *obj;
- GTimeVal timeval;
-
- g_get_current_time (&timeval);
- obj = dkp_history_obj_new ();
- obj->time = timeval.tv_sec;
- obj->value = value;
- obj->state = state;
- return obj;
-}
-
-/**
- * dkp_history_obj_from_string:
- **/
-DkpHistoryObj *
-dkp_history_obj_from_string (const gchar *text)
-{
- DkpHistoryObj *obj = NULL;
- gchar **parts = NULL;
- guint length;
-
- if (text == NULL)
- goto out;
-
- /* split by tab */
- parts = g_strsplit (text, "\t", 0);
- length = g_strv_length (parts);
- if (length != 3) {
- egg_warning ("invalid string: '%s'", text);
- goto out;
- }
-
- /* parse and create */
- obj = dkp_history_obj_new ();
- obj->time = atoi (parts[0]);
- obj->value = atof (parts[1]);
- obj->state = dkp_device_state_from_text (parts[2]);
-out:
- g_strfreev (parts);
- return obj;
-}
-
-/**
- * dkp_history_obj_to_string:
- **/
-gchar *
-dkp_history_obj_to_string (const DkpHistoryObj *obj)
-{
- if (obj == NULL)
- return NULL;
- return g_strdup_printf ("%i\t%.3f\t%s", obj->time, obj->value, dkp_device_state_to_text (obj->state));
-}
-
diff --git a/libdevkit-power/dkp-history-obj.h b/libdevkit-power/dkp-history-obj.h
deleted file mode 100644
index d98abbb..0000000
--- a/libdevkit-power/dkp-history-obj.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef __DKP_HISTORY_OBJ_H__
-#define __DKP_HISTORY_OBJ_H__
-
-#include <glib.h>
-#include "dkp-enum.h"
-
-G_BEGIN_DECLS
-
-typedef struct
-{
- guint time;
- gdouble value;
- DkpDeviceState state;
-} DkpHistoryObj;
-
-DkpHistoryObj *dkp_history_obj_new (void);
-gboolean dkp_history_obj_clear (DkpHistoryObj *obj);
-gboolean dkp_history_obj_free (DkpHistoryObj *obj);
-DkpHistoryObj *dkp_history_obj_copy (const DkpHistoryObj *cobj);
-gboolean dkp_history_obj_print (const DkpHistoryObj *obj);
-DkpHistoryObj *dkp_history_obj_create (gdouble value,
- DkpDeviceState state);
-gboolean dkp_history_obj_equal (const DkpHistoryObj *obj1,
- const DkpHistoryObj *obj2);
-DkpHistoryObj *dkp_history_obj_from_string (const gchar *text);
-gchar *dkp_history_obj_to_string (const DkpHistoryObj *obj);
-
-G_END_DECLS
-
-#endif /* __DKP_HISTORY_OBJ_H__ */
-
diff --git a/libdevkit-power/dkp-object.c b/libdevkit-power/dkp-object.c
deleted file mode 100644
index eca0904..0000000
--- a/libdevkit-power/dkp-object.c
+++ /dev/null
@@ -1,553 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <glib.h>
-#include <glib-object.h>
-#include <string.h>
-
-#include "egg-debug.h"
-#include "egg-string.h"
-
-#include "dkp-enum.h"
-#include "dkp-object.h"
-
-/**
- * dkp_object_clear_internal:
- **/
-static void
-dkp_object_clear_internal (DkpObject *obj)
-{
- obj->type = DKP_DEVICE_TYPE_UNKNOWN;
- obj->update_time = 0;
- obj->energy = 0;
- obj->energy_full = 0;
- obj->energy_full_design = 0;
- obj->energy_rate = 0;
- obj->voltage = 0;
- obj->percentage = 0;
- obj->capacity = 0;
- obj->time_to_empty = 0;
- obj->time_to_full = 0;
- obj->state = DKP_DEVICE_STATE_UNKNOWN;
- obj->technology = DKP_DEVICE_TECHNOLGY_UNKNOWN;
- obj->vendor = NULL;
- obj->model = NULL;
- obj->serial = NULL;
- obj->native_path = NULL;
- obj->online = FALSE;
- obj->is_present = FALSE;
- obj->power_supply = FALSE;
- obj->is_rechargeable = FALSE;
- obj->has_history = FALSE;
- obj->has_statistics = FALSE;
-}
-
-/**
- * dkp_object_collect_props:
- **/
-static void
-dkp_object_collect_props (const char *key, const GValue *value, DkpObject *obj)
-{
- gboolean handled = TRUE;
-
- if (g_strcmp0 (key, "native-path") == 0)
- obj->native_path = g_strdup (g_value_get_string (value));
- else if (g_strcmp0 (key, "vendor") == 0)
- obj->vendor = g_strdup (g_value_get_string (value));
- else if (g_strcmp0 (key, "model") == 0)
- obj->model = g_strdup (g_value_get_string (value));
- else if (g_strcmp0 (key, "serial") == 0)
- obj->serial = g_strdup (g_value_get_string (value));
- else if (g_strcmp0 (key, "update-time") == 0)
- obj->update_time = g_value_get_uint64 (value);
- else if (g_strcmp0 (key, "type") == 0) {
- if (G_VALUE_HOLDS_STRING(value))
- obj->type = dkp_device_type_from_text (g_value_get_string (value));
- else
- obj->type = g_value_get_uint (value);
- } else if (g_strcmp0 (key, "online") == 0)
- obj->online = g_value_get_boolean (value);
- else if (g_strcmp0 (key, "has-history") == 0)
- obj->has_history = g_value_get_boolean (value);
- else if (g_strcmp0 (key, "has-statistics") == 0)
- obj->has_statistics = g_value_get_boolean (value);
- else if (g_strcmp0 (key, "energy") == 0)
- obj->energy = g_value_get_double (value);
- else if (g_strcmp0 (key, "energy-empty") == 0)
- obj->energy_empty = g_value_get_double (value);
- else if (g_strcmp0 (key, "energy-full") == 0)
- obj->energy_full = g_value_get_double (value);
- else if (g_strcmp0 (key, "energy-full-design") == 0)
- obj->energy_full_design = g_value_get_double (value);
- else if (g_strcmp0 (key, "energy-rate") == 0)
- obj->energy_rate = g_value_get_double (value);
- else if (g_strcmp0 (key, "voltage") == 0)
- obj->voltage = g_value_get_double (value);
- else if (g_strcmp0 (key, "time-to-full") == 0)
- obj->time_to_full = g_value_get_int64 (value);
- else if (g_strcmp0 (key, "time-to-empty") == 0)
- obj->time_to_empty = g_value_get_int64 (value);
- else if (g_strcmp0 (key, "percentage") == 0)
- obj->percentage = g_value_get_double (value);
- else if (g_strcmp0 (key, "technology") == 0) {
- if (G_VALUE_HOLDS_STRING(value))
- obj->technology = dkp_device_technology_from_text (g_value_get_string (value));
- else
- obj->technology = g_value_get_uint (value);
- } else if (g_strcmp0 (key, "is-present") == 0)
- obj->is_present = g_value_get_boolean (value);
- else if (g_strcmp0 (key, "is-rechargeable") == 0)
- obj->is_rechargeable = g_value_get_boolean (value);
- else if (g_strcmp0 (key, "power-supply") == 0)
- obj->power_supply = g_value_get_boolean (value);
- else if (g_strcmp0 (key, "capacity") == 0)
- obj->capacity = g_value_get_double (value);
- else if (g_strcmp0 (key, "state") == 0) {
- if (G_VALUE_HOLDS_STRING(value))
- obj->state = dkp_device_state_from_text (g_value_get_string (value));
- else
- obj->state = g_value_get_uint (value);
- } else
- handled = FALSE;
-
- if (!handled)
- egg_warning ("unhandled property '%s'", key);
-}
-
-/**
- * dkp_object_set_from_map:
- **/
-gboolean
-dkp_object_set_from_map (DkpObject *obj, GHashTable *hash_table)
-{
- g_hash_table_foreach (hash_table, (GHFunc) dkp_object_collect_props, obj);
- return TRUE;
-}
-
-/**
- * dkp_object_copy:
- **/
-DkpObject *
-dkp_object_copy (const DkpObject *cobj)
-{
- DkpObject *obj;
- obj = g_new0 (DkpObject, 1);
-
- obj->type = cobj->type;
- obj->update_time = cobj->update_time;
- obj->energy = cobj->energy;
- obj->energy_full = cobj->energy_full;
- obj->energy_full_design = cobj->energy_full_design;
- obj->energy_rate = cobj->energy_rate;
- obj->voltage = cobj->voltage;
- obj->percentage = cobj->percentage;
- obj->capacity = cobj->capacity;
- obj->time_to_empty = cobj->time_to_empty;
- obj->time_to_full = cobj->time_to_full;
- obj->state = cobj->state;
- obj->technology = cobj->technology;
- obj->vendor = g_strdup (cobj->vendor);
- obj->model = g_strdup (cobj->model);
- obj->serial = g_strdup (cobj->serial);
- obj->native_path = g_strdup (cobj->native_path);
- obj->online = cobj->online;
- obj->is_present = cobj->is_present;
- obj->power_supply = cobj->power_supply;
- obj->is_rechargeable = cobj->is_rechargeable;
- obj->has_history = cobj->has_history;
- obj->has_statistics = cobj->has_statistics;
-
- return obj;
-}
-
-/**
- * dkp_object_equal:
- **/
-gboolean
-dkp_object_equal (const DkpObject *obj1, const DkpObject *obj2)
-{
- if (obj1->type == obj2->type &&
- obj1->update_time == obj2->update_time &&
- obj1->energy == obj2->energy &&
- obj1->energy_full == obj2->energy_full &&
- obj1->energy_full_design == obj2->energy_full_design &&
- obj1->voltage == obj2->voltage &&
- obj1->energy_rate == obj2->energy_rate &&
- obj1->percentage == obj2->percentage &&
- obj1->has_history == obj2->has_history &&
- obj1->has_statistics == obj2->has_statistics &&
- obj1->capacity == obj2->capacity &&
- obj1->time_to_empty == obj2->time_to_empty &&
- obj1->time_to_full == obj2->time_to_full &&
- obj1->state == obj2->state &&
- obj1->technology == obj2->technology &&
- g_strcmp0 (obj1->vendor, obj2->vendor) == 0 &&
- g_strcmp0 (obj1->model, obj2->model) == 0 &&
- g_strcmp0 (obj1->serial, obj2->serial) == 0 &&
- g_strcmp0 (obj1->native_path, obj2->native_path) == 0 &&
- obj1->online == obj2->online &&
- obj1->is_present == obj2->is_present &&
- obj1->power_supply == obj2->power_supply &&
- obj1->is_rechargeable == obj2->is_rechargeable)
- return TRUE;
- return FALSE;
-}
-
-/**
- * dkp_object_time_to_text:
- **/
-static gchar *
-dkp_object_time_to_text (gint seconds)
-{
- gfloat value = seconds;
-
- if (value < 0)
- return g_strdup ("unknown");
- if (value < 60)
- return g_strdup_printf ("%.0f seconds", value);
- value /= 60.0;
- if (value < 60)
- return g_strdup_printf ("%.1f minutes", value);
- value /= 60.0;
- if (value < 60)
- return g_strdup_printf ("%.1f hours", value);
- value /= 24.0;
- return g_strdup_printf ("%.1f days", value);
-}
-
-/**
- * dkp_object_bool_to_text:
- **/
-static const gchar *
-dkp_object_bool_to_text (gboolean ret)
-{
- return ret ? "yes" : "no";
-}
-
-/**
- * dkp_object_print:
- **/
-gboolean
-dkp_object_print (const DkpObject *obj)
-{
- gboolean ret = TRUE;
- struct tm *time_tm;
- time_t t;
- gchar time_buf[256];
- gchar *time_str;
-
- /* get a human readable time */
- t = (time_t) obj->update_time;
- time_tm = localtime (&t);
- strftime (time_buf, sizeof time_buf, "%c", time_tm);
-
- g_print (" native-path: %s\n", obj->native_path);
- if (!egg_strzero (obj->vendor))
- g_print (" vendor: %s\n", obj->vendor);
- if (!egg_strzero (obj->model))
- g_print (" model: %s\n", obj->model);
- if (!egg_strzero (obj->serial))
- g_print (" serial: %s\n", obj->serial);
- g_print (" power supply: %s\n", dkp_object_bool_to_text (obj->power_supply));
- g_print (" updated: %s (%d seconds ago)\n", time_buf, (int) (time (NULL) - obj->update_time));
- g_print (" has history: %s\n", dkp_object_bool_to_text (obj->has_history));
- g_print (" has statistics: %s\n", dkp_object_bool_to_text (obj->has_statistics));
- g_print (" %s\n", dkp_device_type_to_text (obj->type));
-
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD ||
- obj->type == DKP_DEVICE_TYPE_UPS)
- g_print (" present: %s\n", dkp_object_bool_to_text (obj->is_present));
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD)
- g_print (" rechargeable: %s\n", dkp_object_bool_to_text (obj->is_rechargeable));
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD)
- g_print (" state: %s\n", dkp_device_state_to_text (obj->state));
- if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
- g_print (" energy: %g Wh\n", obj->energy);
- g_print (" energy-empty: %g Wh\n", obj->energy_empty);
- g_print (" energy-full: %g Wh\n", obj->energy_full);
- g_print (" energy-full-design: %g Wh\n", obj->energy_full_design);
- }
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MONITOR)
- g_print (" energy-rate: %g W\n", obj->energy_rate);
- if (obj->type == DKP_DEVICE_TYPE_UPS ||
- obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MONITOR)
- g_print (" voltage: %g V\n", obj->voltage);
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_UPS) {
- if (obj->time_to_full >= 0) {
- time_str = dkp_object_time_to_text (obj->time_to_full);
- g_print (" time to full: %s\n", time_str);
- g_free (time_str);
- }
- if (obj->time_to_empty >= 0) {
- time_str = dkp_object_time_to_text (obj->time_to_empty);
- g_print (" time to empty: %s\n", time_str);
- g_free (time_str);
- }
- }
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD ||
- obj->type == DKP_DEVICE_TYPE_UPS)
- g_print (" percentage: %g%%\n", obj->percentage);
- if (obj->type == DKP_DEVICE_TYPE_BATTERY)
- g_print (" capacity: %g%%\n", obj->capacity);
- if (obj->type == DKP_DEVICE_TYPE_BATTERY)
- g_print (" technology: %s\n", dkp_device_technology_to_text (obj->technology));
- if (obj->type == DKP_DEVICE_TYPE_LINE_POWER)
- g_print (" online: %s\n", dkp_object_bool_to_text (obj->online));
-
- return ret;
-}
-
-/**
- * dkp_object_diff:
- **/
-gboolean
-dkp_object_diff (const DkpObject *old, const DkpObject *obj)
-{
- gchar *time_str;
- gchar *time_str_old;
-
- g_print (" native-path: %s\n", obj->native_path);
- if (g_strcmp0 (obj->vendor, old->vendor) != 0)
- g_print (" vendor: %s -> %s\n", old->vendor, obj->vendor);
- if (g_strcmp0 (obj->model, old->model) != 0)
- g_print (" model: %s -> %s\n", old->model, obj->model);
- if (g_strcmp0 (obj->serial, old->serial) != 0)
- g_print (" serial: %s -> %s\n", old->serial, obj->serial);
- if (obj->has_history != old->has_history)
- g_print (" has history: %s -> %s\n",
- dkp_object_bool_to_text (old->has_history),
- dkp_object_bool_to_text (obj->has_history));
- if (obj->has_statistics != old->has_statistics)
- g_print (" has statistics: %s -> %s\n",
- dkp_object_bool_to_text (old->has_statistics),
- dkp_object_bool_to_text (obj->has_statistics));
-
- g_print (" %s\n", dkp_device_type_to_text (obj->type));
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD)
- if (old->is_present != obj->is_present)
- g_print (" present: %s -> %s\n",
- dkp_object_bool_to_text (old->is_present),
- dkp_object_bool_to_text (obj->is_present));
- if (obj->type == DKP_DEVICE_TYPE_BATTERY)
- if (old->is_rechargeable != obj->is_rechargeable)
- g_print (" rechargeable: %s -> %s\n",
- dkp_object_bool_to_text (old->is_rechargeable),
- dkp_object_bool_to_text (obj->is_rechargeable));
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD ||
- obj->type == DKP_DEVICE_TYPE_UPS)
- if (old->state != obj->state)
- g_print (" state: %s -> %s\n",
- dkp_device_state_to_text (old->state),
- dkp_device_state_to_text (obj->state));
- if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
- if (old->energy != obj->energy)
- g_print (" energy: %g -> %g Wh\n",
- old->energy,
- obj->energy);
- if (old->energy_empty != obj->energy_empty)
- g_print (" energy-empty: %g -> %g Wh\n",
- old->energy_empty,
- obj->energy_empty);
- if (old->energy_full != obj->energy_full)
- g_print (" energy-full: %g -> %g Wh\n",
- old->energy_full,
- obj->energy_full);
- if (old->energy_full_design != obj->energy_full_design)
- g_print (" energy-full-design: %g -> %g Wh\n",
- old->energy_full_design,
- obj->energy_full_design);
- }
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MONITOR)
- if (old->energy_rate != obj->energy_rate)
- g_print (" energy-rate: %g -> %g W\n",
- old->energy_rate, obj->energy_rate);
- if (obj->type == DKP_DEVICE_TYPE_UPS ||
- obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MONITOR)
- if (old->voltage != obj->voltage)
- g_print (" voltage: %g -> %g V\n",
- old->voltage, obj->voltage);
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_UPS) {
- if (old->time_to_full != obj->time_to_full) {
- time_str_old = dkp_object_time_to_text (old->time_to_full);
- time_str = dkp_object_time_to_text (obj->time_to_full);
- g_print (" time to full: %s -> %s\n", time_str_old, time_str);
- g_free (time_str_old);
- g_free (time_str);
- }
- if (old->time_to_empty != obj->time_to_empty) {
- time_str_old = dkp_object_time_to_text (old->time_to_empty);
- time_str = dkp_object_time_to_text (obj->time_to_empty);
- g_print (" time to empty: %s -> %s\n", time_str_old, time_str);
- g_free (time_str_old);
- g_free (time_str);
- }
- }
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_UPS ||
- obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD)
- if (old->percentage != obj->percentage)
- g_print (" percentage: %g%% -> %g%%\n",
- old->percentage, obj->percentage);
- if (obj->type == DKP_DEVICE_TYPE_BATTERY)
- if (old->capacity != obj->capacity)
- g_print (" capacity: %g%% -> %g%%\n",
- old->capacity, obj->capacity);
- if (obj->type == DKP_DEVICE_TYPE_BATTERY)
- if (old->technology != obj->technology)
- g_print (" technology: %s -> %s\n",
- dkp_device_technology_to_text (old->technology),
- dkp_device_technology_to_text (obj->technology));
- if (obj->type == DKP_DEVICE_TYPE_LINE_POWER)
- if (old->online != obj->online)
- g_print (" online: %s -> %s\n",
- dkp_object_bool_to_text (old->online),
- dkp_object_bool_to_text (obj->online));
- return TRUE;
-}
-
-/**
- * dkp_object_new:
- **/
-DkpObject *
-dkp_object_new (void)
-{
- DkpObject *obj;
- obj = g_new0 (DkpObject, 1);
- dkp_object_clear_internal (obj);
- return obj;
-}
-
-/**
- * dkp_object_free_internal:
- **/
-static gboolean
-dkp_object_free_internal (DkpObject *obj)
-{
- g_free (obj->vendor);
- g_free (obj->model);
- g_free (obj->serial);
- g_free (obj->native_path);
- return TRUE;
-}
-
-/**
- * dkp_object_free:
- **/
-gboolean
-dkp_object_free (DkpObject *obj)
-{
- if (obj == NULL)
- return FALSE;
- dkp_object_free_internal (obj);
- g_free (obj);
- return TRUE;
-}
-
-/**
- * dkp_object_clear:
- **/
-gboolean
-dkp_object_clear (DkpObject *obj)
-{
- if (obj == NULL)
- return FALSE;
- dkp_object_free_internal (obj);
- dkp_object_clear_internal (obj);
- return TRUE;
-}
-
-/**
- * dkp_object_get_id:
- **/
-gchar *
-dkp_object_get_id (DkpObject *obj)
-{
- GString *string;
- gchar *id = NULL;
-
- /* line power */
- if (obj->type == DKP_DEVICE_TYPE_LINE_POWER) {
- goto out;
-
- /* batteries */
- } else if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
- /* we don't have an ID if we are not present */
- if (!obj->is_present)
- goto out;
-
- string = g_string_new ("");
-
- /* in an ideal world, model-capacity-serial */
- if (obj->model != NULL && strlen (obj->model) > 2) {
- g_string_append (string, obj->model);
- g_string_append_c (string, '-');
- }
- if (obj->energy_full_design > 0) {
- /* FIXME: this may not be stable if we are using voltage_now */
- g_string_append_printf (string, "%i", (guint) obj->energy_full_design);
- g_string_append_c (string, '-');
- }
- if (obj->serial != NULL && strlen (obj->serial) > 2) {
- g_string_append (string, obj->serial);
- g_string_append_c (string, '-');
- }
-
- /* make sure we are sane */
- if (string->len == 0) {
- /* just use something generic */
- g_string_append (string, "generic_id");
- } else {
- /* remove trailing '-' */
- g_string_set_size (string, string->len - 1);
- }
-
- /* the id may have invalid chars that need to be replaced */
- id = g_string_free (string, FALSE);
-
- } else {
- /* generic fallback */
- id = g_strdup_printf ("%s-%s-%s", obj->vendor, obj->model, obj->serial);
- }
-
- g_strdelimit (id, "\\\t\"?' /,.", '_');
-
-out:
- return id;
-}
-
diff --git a/libdevkit-power/dkp-object.h b/libdevkit-power/dkp-object.h
deleted file mode 100644
index c836360..0000000
--- a/libdevkit-power/dkp-object.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef __DKP_OBJECT_H__
-#define __DKP_OBJECT_H__
-
-#include <glib.h>
-#include "dkp-enum.h"
-
-G_BEGIN_DECLS
-
-typedef struct {
- guint64 update_time;
- gchar *vendor;
- gchar *model;
- gchar *serial;
- gchar *native_path;
- gboolean power_supply;
- gboolean online;
- gboolean is_present;
- gboolean is_rechargeable;
- gboolean has_history;
- gboolean has_statistics;
- DkpDeviceType type;
- DkpDeviceState state;
- DkpDeviceTechnology technology;
- gdouble capacity; /* percent */
- gdouble energy; /* Watt Hours */
- gdouble energy_empty; /* Watt Hours */
- gdouble energy_full; /* Watt Hours */
- gdouble energy_full_design; /* Watt Hours */
- gdouble energy_rate; /* Watts */
- gdouble voltage; /* Volts */
- gint64 time_to_empty; /* seconds */
- gint64 time_to_full; /* seconds */
- gdouble percentage; /* percent */
-} DkpObject;
-
-DkpObject *dkp_object_new (void);
-gboolean dkp_object_clear (DkpObject *obj);
-gboolean dkp_object_free (DkpObject *obj);
-gchar *dkp_object_get_id (DkpObject *obj);
-DkpObject *dkp_object_copy (const DkpObject *cobj);
-gboolean dkp_object_print (const DkpObject *obj);
-gboolean dkp_object_diff (const DkpObject *old,
- const DkpObject *obj);
-gboolean dkp_object_equal (const DkpObject *obj1,
- const DkpObject *obj2);
-gboolean dkp_object_set_from_map (DkpObject *obj,
- GHashTable *hash_table);
-
-G_END_DECLS
-
-#endif /* __DKP_OBJECT_H__ */
-
diff --git a/libdevkit-power/dkp-stats-obj.c b/libdevkit-power/dkp-stats-obj.c
deleted file mode 100644
index dbb3841..0000000
--- a/libdevkit-power/dkp-stats-obj.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <glib.h>
-#include <glib-object.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "egg-debug.h"
-#include "dkp-stats-obj.h"
-
-/**
- * dkp_stats_obj_copy:
- **/
-DkpStatsObj *
-dkp_stats_obj_copy (const DkpStatsObj *cobj)
-{
- DkpStatsObj *obj;
- obj = g_new0 (DkpStatsObj, 1);
- obj->value = cobj->value;
- obj->accuracy = cobj->accuracy;
- return obj;
-}
-
-/**
- * dkp_stats_obj_new:
- **/
-DkpStatsObj *
-dkp_stats_obj_new (void)
-{
- DkpStatsObj *obj;
- obj = g_new0 (DkpStatsObj, 1);
- obj->value = 0.0f;
- obj->accuracy = 0;
- return obj;
-}
-
-/**
- * dkp_stats_obj_free:
- **/
-gboolean
-dkp_stats_obj_free (DkpStatsObj *obj)
-{
- if (obj == NULL)
- return FALSE;
- g_free (obj);
- return TRUE;
-}
-
-/**
- * dkp_stats_obj_create:
- **/
-DkpStatsObj *
-dkp_stats_obj_create (gdouble value, gdouble accuracy)
-{
- DkpStatsObj *obj;
- obj = dkp_stats_obj_new ();
- obj->value = value;
- obj->accuracy = accuracy;
- return obj;
-}
-
-/**
- * dkp_stats_obj_from_string:
- **/
-DkpStatsObj *
-dkp_stats_obj_from_string (const gchar *text)
-{
- DkpStatsObj *obj = NULL;
- gchar **parts = NULL;
- guint length;
-
- if (text == NULL)
- goto out;
-
- /* split by tab */
- parts = g_strsplit (text, "\t", 0);
- length = g_strv_length (parts);
- if (length != 2) {
- egg_warning ("invalid string: '%s'", text);
- goto out;
- }
-
- /* parse and create */
- obj = dkp_stats_obj_new ();
- obj->value = atoi (parts[0]);
- obj->accuracy = atof (parts[1]);
-out:
- g_strfreev (parts);
- return obj;
-}
-
-/**
- * dkp_stats_obj_to_string:
- **/
-gchar *
-dkp_stats_obj_to_string (const DkpStatsObj *obj)
-{
- if (obj == NULL)
- return NULL;
- return g_strdup_printf ("%.2f\t%.2f", obj->value, obj->accuracy);
-}
-
diff --git a/libdevkit-power/dkp-stats-obj.h b/libdevkit-power/dkp-stats-obj.h
deleted file mode 100644
index f29c09a..0000000
--- a/libdevkit-power/dkp-stats-obj.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 Richard Hughes <richard hughsie com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef __DKP_STATS_OBJ_H__
-#define __DKP_STATS_OBJ_H__
-
-#include <glib.h>
-#include "dkp-enum.h"
-
-G_BEGIN_DECLS
-
-typedef struct
-{
- gdouble value;
- gdouble accuracy;
-} DkpStatsObj;
-
-DkpStatsObj *dkp_stats_obj_new (void);
-gboolean dkp_stats_obj_free (DkpStatsObj *obj);
-DkpStatsObj *dkp_stats_obj_copy (const DkpStatsObj *cobj);
-DkpStatsObj *dkp_stats_obj_create (gdouble value,
- gdouble accuracy);
-DkpStatsObj *dkp_stats_obj_from_string (const gchar *text);
-gchar *dkp_stats_obj_to_string (const DkpStatsObj *obj);
-
-G_END_DECLS
-
-#endif /* __DKP_STATS_OBJ_H__ */
-
diff --git a/libdevkit-power/dkp-wakeups-obj.c b/libdevkit-power/dkp-wakeups-obj.c
deleted file mode 100644
index fcbaa94..0000000
--- a/libdevkit-power/dkp-wakeups-obj.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard hughsie com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#include <glib.h>
-#include <glib-object.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "egg-debug.h"
-#include "dkp-enum.h"
-#include "dkp-wakeups-obj.h"
-
-/**
- * dkp_wakeups_obj_clear_internal:
- **/
-static void
-dkp_wakeups_obj_clear_internal (DkpWakeupsObj *obj)
-{
- obj->id = 0;
- obj->old = 0;
- obj->value = 0.0f;
- obj->is_userspace = FALSE;
- obj->cmdline = NULL;
- obj->details = NULL;
-}
-
-/**
- * dkp_wakeups_obj_copy:
- **/
-DkpWakeupsObj *
-dkp_wakeups_obj_copy (const DkpWakeupsObj *cobj)
-{
- DkpWakeupsObj *obj;
- obj = g_new0 (DkpWakeupsObj, 1);
- obj->id = cobj->id;
- obj->value = cobj->value;
- obj->is_userspace = cobj->is_userspace;
- return obj;
-}
-
-/**
- * dkp_wakeups_obj_equal:
- **/
-gboolean
-dkp_wakeups_obj_equal (const DkpWakeupsObj *obj1, const DkpWakeupsObj *obj2)
-{
- if (obj1->id == obj2->id)
- return TRUE;
- return FALSE;
-}
-
-/**
- * dkp_wakeups_obj_print:
- **/
-gboolean
-dkp_wakeups_obj_print (const DkpWakeupsObj *obj)
-{
- g_print ("userspace:%i id:%i, interrupts:%.1f, cmdline:%s, details:%s\n", obj->is_userspace, obj->id, obj->value, obj->cmdline, obj->details);
- return TRUE;
-}
-
-/**
- * dkp_wakeups_obj_new:
- **/
-DkpWakeupsObj *
-dkp_wakeups_obj_new (void)
-{
- DkpWakeupsObj *obj;
- obj = g_new0 (DkpWakeupsObj, 1);
- dkp_wakeups_obj_clear_internal (obj);
- return obj;
-}
-
-/**
- * dkp_wakeups_obj_free:
- **/
-void
-dkp_wakeups_obj_free (DkpWakeupsObj *obj)
-{
- if (obj == NULL)
- return;
- g_free (obj->cmdline);
- g_free (obj->details);
- g_free (obj);
- return;
-}
-
diff --git a/libdevkit-power/dkp-wakeups-obj.h b/libdevkit-power/dkp-wakeups-obj.h
deleted file mode 100644
index 7939cfd..0000000
--- a/libdevkit-power/dkp-wakeups-obj.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard hughsie com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifndef __DKP_WAKEUPS_OBJ_H__
-#define __DKP_WAKEUPS_OBJ_H__
-
-#include <glib.h>
-#include "dkp-enum.h"
-
-G_BEGIN_DECLS
-
-typedef struct
-{
- gboolean is_userspace;
- guint id;
- guint old;
- gfloat value;
- gchar *cmdline;
- gchar *details;
-} DkpWakeupsObj;
-
-DkpWakeupsObj *dkp_wakeups_obj_new (void);
-void dkp_wakeups_obj_free (DkpWakeupsObj *obj);
-DkpWakeupsObj *dkp_wakeups_obj_copy (const DkpWakeupsObj *cobj);
-gboolean dkp_wakeups_obj_print (const DkpWakeupsObj *obj);
-gboolean dkp_wakeups_obj_equal (const DkpWakeupsObj *obj1,
- const DkpWakeupsObj *obj2);
-
-G_END_DECLS
-
-#endif /* __DKP_WAKEUPS_OBJ_H__ */
-
diff --git a/libdevkit-power/dkp-wakeups.c b/libdevkit-power/dkp-wakeups.c
deleted file mode 100644
index de48ac8..0000000
--- a/libdevkit-power/dkp-wakeups.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard hughsie com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-
-#include "egg-debug.h"
-#include "dkp-wakeups.h"
-
-static void dkp_wakeups_class_init (DkpWakeupsClass *klass);
-static void dkp_wakeups_init (DkpWakeups *wakeups);
-static void dkp_wakeups_finalize (GObject *object);
-
-#define DKP_WAKEUPS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_WAKEUPS, DkpWakeupsPrivate))
-
-struct DkpWakeupsPrivate
-{
- DBusGConnection *bus;
- DBusGProxy *proxy;
-};
-
-enum {
- DKP_WAKEUPS_DATA_CHANGED,
- DKP_WAKEUPS_TOTAL_CHANGED,
- DKP_WAKEUPS_LAST_SIGNAL
-};
-
-static guint signals [DKP_WAKEUPS_LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (DkpWakeups, dkp_wakeups, G_TYPE_OBJECT)
-
-/**
- * dkp_wakeups_get_total:
- **/
-guint
-dkp_wakeups_get_total (DkpWakeups *wakeups, GError **error)
-{
- guint total = 0;
- gboolean ret;
- GError *error_local = NULL;
-
- g_return_val_if_fail (DKP_IS_WAKEUPS (wakeups), FALSE);
- g_return_val_if_fail (wakeups->priv->proxy != NULL, FALSE);
-
- ret = dbus_g_proxy_call (wakeups->priv->proxy, "GetTotal", &error_local,
- G_TYPE_INVALID,
- G_TYPE_UINT, &total,
- G_TYPE_INVALID);
- if (!ret) {
- egg_warning ("Couldn't get total: %s", error_local->message);
- if (error != NULL)
- *error = g_error_new (1, 0, "%s", error_local->message);
- g_error_free (error_local);
- }
- return total;
-}
-
-/**
- * dkp_wakeups_get_data:
- *
- * Returns an array of %DkpWakeupsObj's
- **/
-GPtrArray *
-dkp_wakeups_get_data (DkpWakeups *wakeups, GError **error)
-{
- GError *error_local = NULL;
- GType g_type_gvalue_array;
- GPtrArray *gvalue_ptr_array = NULL;
- GValueArray *gva;
- GValue *gv;
- guint i;
- DkpWakeupsObj *obj;
- GPtrArray *array = NULL;
- gboolean ret;
-
- g_return_val_if_fail (DKP_IS_WAKEUPS (wakeups), FALSE);
- g_return_val_if_fail (wakeups->priv->proxy != NULL, FALSE);
-
- g_type_gvalue_array = dbus_g_type_get_collection ("GPtrArray",
- dbus_g_type_get_struct("GValueArray",
- G_TYPE_BOOLEAN,
- G_TYPE_UINT,
- G_TYPE_DOUBLE,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_INVALID));
-
- /* get compound data */
- ret = dbus_g_proxy_call (wakeups->priv->proxy, "GetData", &error_local,
- G_TYPE_INVALID,
- g_type_gvalue_array, &gvalue_ptr_array,
- G_TYPE_INVALID);
- if (!ret) {
- egg_debug ("GetData on failed: %s", error_local->message);
- if (error != NULL)
- *error = g_error_new (1, 0, "%s", error_local->message);
- g_error_free (error_local);
- goto out;
- }
-
- /* no data */
- if (gvalue_ptr_array->len == 0)
- goto out;
-
- /* convert */
- array = g_ptr_array_new ();
- for (i=0; i<gvalue_ptr_array->len; i++) {
- gva = (GValueArray *) g_ptr_array_index (gvalue_ptr_array, i);
- obj = dkp_wakeups_obj_new ();
-
- /* 0 */
- gv = g_value_array_get_nth (gva, 0);
- obj->is_userspace = g_value_get_boolean (gv);
- g_value_unset (gv);
-
- /* 1 */
- gv = g_value_array_get_nth (gva, 1);
- obj->id = g_value_get_uint (gv);
- g_value_unset (gv);
-
- /* 2 */
- gv = g_value_array_get_nth (gva, 2);
- obj->value = g_value_get_double (gv);
- g_value_unset (gv);
-
- /* 3 */
- gv = g_value_array_get_nth (gva, 3);
- obj->cmdline = g_strdup (g_value_get_string (gv));
- g_value_unset (gv);
-
- /* 4 */
- gv = g_value_array_get_nth (gva, 4);
- obj->details = g_strdup (g_value_get_string (gv));
- g_value_unset (gv);
-
- /* add */
- g_ptr_array_add (array, obj);
- g_value_array_free (gva);
- }
-out:
- if (gvalue_ptr_array != NULL)
- g_ptr_array_free (gvalue_ptr_array, TRUE);
- return array;
-}
-
-/**
- * dkp_wakeups_total_changed_cb:
- **/
-static void
-dkp_wakeups_total_changed_cb (DBusGProxy *proxy, guint value, DkpWakeups *wakeups)
-{
- g_signal_emit (wakeups, signals [DKP_WAKEUPS_TOTAL_CHANGED], 0, value);
-}
-
-/**
- * dkp_wakeups_data_changed_cb:
- **/
-static void
-dkp_wakeups_data_changed_cb (DBusGProxy *proxy, DkpWakeups *wakeups)
-{
- g_signal_emit (wakeups, signals [DKP_WAKEUPS_DATA_CHANGED], 0);
-}
-
-/**
- * dkp_wakeups_class_init:
- * @klass: The DkpWakeupsClass
- **/
-static void
-dkp_wakeups_class_init (DkpWakeupsClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = dkp_wakeups_finalize;
-
- signals [DKP_WAKEUPS_DATA_CHANGED] =
- g_signal_new ("data-changed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DkpWakeupsClass, data_changed),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- signals [DKP_WAKEUPS_TOTAL_CHANGED] =
- g_signal_new ("total-changed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DkpWakeupsClass, data_changed),
- NULL, NULL, g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1, G_TYPE_UINT);
-
- g_type_class_add_private (klass, sizeof (DkpWakeupsPrivate));
-}
-
-/**
- * dkp_wakeups_init:
- * @wakeups: This class instance
- **/
-static void
-dkp_wakeups_init (DkpWakeups *wakeups)
-{
- GError *error = NULL;
-
- wakeups->priv = DKP_WAKEUPS_GET_PRIVATE (wakeups);
-
- /* get on the bus */
- wakeups->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (wakeups->priv->bus == NULL) {
- egg_warning ("Couldn't connect to system bus: %s", error->message);
- g_error_free (error);
- goto out;
- }
-
- /* connect to main interface */
- wakeups->priv->proxy = dbus_g_proxy_new_for_name (wakeups->priv->bus,
- "org.freedesktop.DeviceKit.Power",
- "/org/freedesktop/DeviceKit/Power/Wakeups",
- "org.freedesktop.DeviceKit.Power.Wakeups");
- if (wakeups->priv->proxy == NULL) {
- egg_warning ("Couldn't connect to proxy");
- goto out;
- }
- dbus_g_proxy_add_signal (wakeups->priv->proxy, "TotalChanged", G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_add_signal (wakeups->priv->proxy, "DataChanged", G_TYPE_INVALID);
-
- /* all callbacks */
- dbus_g_proxy_connect_signal (wakeups->priv->proxy, "TotalChanged",
- G_CALLBACK (dkp_wakeups_total_changed_cb), wakeups, NULL);
- dbus_g_proxy_connect_signal (wakeups->priv->proxy, "DataChanged",
- G_CALLBACK (dkp_wakeups_data_changed_cb), wakeups, NULL);
-out:
- return;
-}
-
-/**
- * dkp_wakeups_finalize:
- * @object: The object to finalize
- **/
-static void
-dkp_wakeups_finalize (GObject *object)
-{
- DkpWakeups *wakeups;
-
- g_return_if_fail (DKP_IS_WAKEUPS (object));
-
- wakeups = DKP_WAKEUPS (object);
- if (wakeups->priv->proxy != NULL)
- g_object_unref (wakeups->priv->proxy);
-
- G_OBJECT_CLASS (dkp_wakeups_parent_class)->finalize (object);
-}
-
-/**
- * dkp_wakeups_new:
- *
- * Return value: a new DkpWakeups object.
- **/
-DkpWakeups *
-dkp_wakeups_new (void)
-{
- DkpWakeups *wakeups;
- wakeups = g_object_new (DKP_TYPE_WAKEUPS, NULL);
- return DKP_WAKEUPS (wakeups);
-}
-
diff --git a/libdevkit-power/dkp-wakeups.h b/libdevkit-power/dkp-wakeups.h
deleted file mode 100644
index 770e5bc..0000000
--- a/libdevkit-power/dkp-wakeups.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2009 Richard Hughes <richard hughsie com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __DKP_WAKEUPS_H
-#define __DKP_WAKEUPS_H
-
-#include <glib-object.h>
-#include <dkp-enum.h>
-#include "dkp-device.h"
-#include "dkp-wakeups-obj.h"
-
-G_BEGIN_DECLS
-
-#define DKP_TYPE_WAKEUPS (dkp_wakeups_get_type ())
-#define DKP_WAKEUPS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DKP_TYPE_WAKEUPS, DkpWakeups))
-#define DKP_WAKEUPS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DKP_TYPE_WAKEUPS, DkpWakeupsClass))
-#define DKP_IS_WAKEUPS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DKP_TYPE_WAKEUPS))
-#define DKP_IS_WAKEUPS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DKP_TYPE_WAKEUPS))
-#define DKP_WAKEUPS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DKP_TYPE_WAKEUPS, DkpWakeupsClass))
-#define DKP_WAKEUPS_ERROR (dkp_wakeups_error_quark ())
-#define DKP_WAKEUPS_TYPE_ERROR (dkp_wakeups_error_get_type ())
-
-typedef struct DkpWakeupsPrivate DkpWakeupsPrivate;
-
-typedef struct
-{
- GObject parent;
- DkpWakeupsPrivate *priv;
-} DkpWakeups;
-
-typedef struct
-{
- GObjectClass parent_class;
- void (*data_changed) (DkpWakeups *wakeups);
- void (*total_changed) (DkpWakeups *wakeups,
- guint value);
-} DkpWakeupsClass;
-
-GType dkp_wakeups_get_type (void);
-DkpWakeups *dkp_wakeups_new (void);
-guint dkp_wakeups_get_total (DkpWakeups *wakeups,
- GError **error);
-GPtrArray *dkp_wakeups_get_data (DkpWakeups *wakeups,
- GError **error);
-
-G_END_DECLS
-
-#endif /* __DKP_WAKEUPS_H */
-
diff --git a/libdevkit-power/egg-debug.c b/libdevkit-power/egg-debug.c
deleted file mode 120000
index 0a3eb62..0000000
--- a/libdevkit-power/egg-debug.c
+++ /dev/null
@@ -1 +0,0 @@
-../src/egg-debug.c
\ No newline at end of file
diff --git a/libdevkit-power/egg-debug.h b/libdevkit-power/egg-debug.h
deleted file mode 120000
index db811d2..0000000
--- a/libdevkit-power/egg-debug.h
+++ /dev/null
@@ -1 +0,0 @@
-../src/egg-debug.h
\ No newline at end of file
diff --git a/libdevkit-power/egg-obj-list.c b/libdevkit-power/egg-obj-list.c
deleted file mode 120000
index 1c4969c..0000000
--- a/libdevkit-power/egg-obj-list.c
+++ /dev/null
@@ -1 +0,0 @@
-../src/egg-obj-list.c
\ No newline at end of file
diff --git a/libdevkit-power/egg-obj-list.h b/libdevkit-power/egg-obj-list.h
deleted file mode 120000
index 2fcc135..0000000
--- a/libdevkit-power/egg-obj-list.h
+++ /dev/null
@@ -1 +0,0 @@
-../src/egg-obj-list.h
\ No newline at end of file
diff --git a/libdevkit-power/egg-string.c b/libdevkit-power/egg-string.c
deleted file mode 120000
index 6ad7909..0000000
--- a/libdevkit-power/egg-string.c
+++ /dev/null
@@ -1 +0,0 @@
-../src/egg-string.c
\ No newline at end of file
diff --git a/libdevkit-power/egg-string.h b/libdevkit-power/egg-string.h
deleted file mode 120000
index d7e801b..0000000
--- a/libdevkit-power/egg-string.h
+++ /dev/null
@@ -1 +0,0 @@
-../src/egg-string.h
\ No newline at end of file
diff --git a/src/Makefile.am b/src/Makefile.am
index 44f4f59..964ab05 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,6 +20,8 @@ INCLUDES = \
$(LIBNOTIFY_CFLAGS) \
$(CANBERRA_CFLAGS) \
$(GSTREAMER_CFLAGS) \
+ -DI_KNOW_THE_DEVICEKIT_POWER_API_IS_SUBJECT_TO_CHANGE \
+ $(DEVKIT_CFLAGS) \
$(POLKIT_CFLAGS) \
$(POLKIT_GNOME_CFLAGS) \
-DBINDIR=\"$(bindir)\" \
@@ -35,16 +37,12 @@ INCLUDES = \
-DEGG_LOGGING="\"GPM_LOGGING\"" \
-DEGG_CONSOLE="\"GPM_CONSOLE\"" \
-I$(top_srcdir) \
- -I$(top_srcdir)/libdevkit-power \
-I$(top_srcdir)/libhal-glib \
$(NULL)
LOCAL_LIBHAL_LIBS = \
$(top_builddir)/libhal-glib/libhal.la
-DEVKIT_POWER_LIBS = \
- $(top_builddir)/libdevkit-power/libdevkit-power.la
-
bin_PROGRAMS = \
gnome-power-manager \
gnome-power-preferences \
@@ -63,8 +61,6 @@ gnome_power_statistics_SOURCES = \
egg-unique.c \
egg-precision.h \
egg-precision.c \
- egg-obj-list.c \
- egg-obj-list.h \
egg-array-float.c \
egg-array-float.h \
egg-idletime.h \
@@ -82,7 +78,7 @@ gnome_power_statistics_SOURCES = \
gnome_power_statistics_LDADD = \
$(GLIB_LIBS) \
- $(DEVKIT_POWER_LIBS) \
+ $(DEVKIT_LIBS) \
$(GNOME_LIBS) \
$(UNIQUE_LIBS) \
$(DBUS_LIBS) \
@@ -226,7 +222,7 @@ gnome_power_manager_LDADD = \
$(LIBNOTIFY_LIBS) \
$(GPM_EXTRA_LIBS) \
$(LOCAL_LIBHAL_LIBS) \
- $(DEVKIT_POWER_LIBS) \
+ $(DEVKIT_LIBS) \
$(NULL)
gnome_power_manager_CFLAGS = \
@@ -296,7 +292,7 @@ gnome_power_self_test_LDADD = \
$(GNOME_LIBS) \
$(GSTREAMER_LIBS) \
$(POLKIT_GNOME_LIBS) \
- $(DEVKIT_POWER_LIBS) \
+ $(DEVKIT_LIBS) \
$(DBUS_LIBS) \
$(LIBNOTIFY_LIBS) \
$(LOCAL_LIBHAL_LIBS) \
diff --git a/src/gpm-ac-adapter.c b/src/gpm-ac-adapter.c
index d5c2235..cee1d07 100644
--- a/src/gpm-ac-adapter.c
+++ b/src/gpm-ac-adapter.c
@@ -37,9 +37,7 @@
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
-
- #include <dkp-client.h>
- #include <dkp-device.h>
+#include <devkit-power-gobject/devicekit-power.h>
#include "gpm-common.h"
#include "egg-debug.h"
diff --git a/src/gpm-control.c b/src/gpm-control.c
index 8e28321..043b667 100644
--- a/src/gpm-control.c
+++ b/src/gpm-control.c
@@ -41,7 +41,7 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <gnome-keyring.h>
#include <gconf/gconf-client.h>
-#include <dkp-client.h>
+#include <devkit-power-gobject/devicekit-power.h>
#ifdef HAVE_POLKIT
#include <polkit/polkit.h>
diff --git a/src/gpm-devicekit.c b/src/gpm-devicekit.c
index 9d40657..2169230 100644
--- a/src/gpm-devicekit.c
+++ b/src/gpm-devicekit.c
@@ -22,16 +22,17 @@
#include "config.h"
#include <glib/gi18n.h>
+#include <devkit-power-gobject/devicekit-power.h>
#include "egg-debug.h"
#include "egg-precision.h"
-#include "dkp-enum.h"
-#include "dkp-object.h"
-
#include "gpm-devicekit.h"
#include "gpm-common.h"
+#define GPM_DKP_TIME_PRECISION 5*60
+#define GPM_DKP_TEXT_MIN_TIME 120
+
/**
* gpm_devicekit_get_object_icon_index:
* @percent: The charge of the device
@@ -47,17 +48,20 @@
* Return value: The character string for the filename suffix.
**/
static const gchar *
-gpm_devicekit_get_object_icon_index (const DkpObject *obj)
+gpm_devicekit_get_object_icon_index (DkpDevice *device)
{
- if (obj->percentage < 10)
+ gdouble percentage;
+ /* get device properties */
+ g_object_get (device, "percentage", &percentage, NULL);
+ if (percentage < 10)
return "000";
- else if (obj->percentage < 30)
+ else if (percentage < 30)
return "020";
- else if (obj->percentage < 50)
+ else if (percentage < 50)
return "040";
- else if (obj->percentage < 70)
+ else if (percentage < 70)
return "060";
- else if (obj->percentage < 90)
+ else if (percentage < 90)
return "080";
return "100";
}
@@ -69,70 +73,82 @@ gpm_devicekit_get_object_icon_index (const DkpObject *obj)
*
**/
gchar *
-gpm_devicekit_get_object_icon (const DkpObject *obj)
+gpm_devicekit_get_object_icon (DkpDevice *device)
{
gchar *filename = NULL;
const gchar *prefix = NULL;
const gchar *index_str;
+ DkpDeviceType type;
+ DkpDeviceState state;
+ gboolean is_present;
+ gdouble percentage;
+
+ g_return_val_if_fail (device != NULL, NULL);
- g_return_val_if_fail (obj != NULL, NULL);
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ "state", &state,
+ "percentage", &percentage,
+ "is-present", &is_present,
+ NULL);
/* get correct icon prefix */
- prefix = dkp_device_type_to_text (obj->type);
+ prefix = dkp_device_type_to_text (type);
/* get the icon from some simple rules */
- if (obj->type == DKP_DEVICE_TYPE_LINE_POWER) {
+ if (type == DKP_DEVICE_TYPE_LINE_POWER) {
filename = g_strdup ("gpm-ac-adapter");
- } else if (obj->type == DKP_DEVICE_TYPE_MONITOR) {
+ } else if (type == DKP_DEVICE_TYPE_MONITOR) {
filename = g_strdup ("gpm-monitor");
- } else if (obj->type == DKP_DEVICE_TYPE_UPS) {
- if (!obj->is_present) {
+ } else if (type == DKP_DEVICE_TYPE_UPS) {
+ if (!is_present) {
/* battery missing */
filename = g_strdup_printf ("gpm-%s-missing", prefix);
- } else if (obj->state == DKP_DEVICE_STATE_FULLY_CHARGED) {
+ } else if (state == DKP_DEVICE_STATE_FULLY_CHARGED) {
filename = g_strdup_printf ("gpm-%s-100", prefix);
- } else if (obj->state == DKP_DEVICE_STATE_CHARGING) {
- index_str = gpm_devicekit_get_object_icon_index (obj);
+ } else if (state == DKP_DEVICE_STATE_CHARGING) {
+ index_str = gpm_devicekit_get_object_icon_index (device);
filename = g_strdup_printf ("gpm-%s-%s-charging", prefix, index_str);
- } else if (obj->state == DKP_DEVICE_STATE_DISCHARGING) {
- index_str = gpm_devicekit_get_object_icon_index (obj);
+ } else if (state == DKP_DEVICE_STATE_DISCHARGING) {
+ index_str = gpm_devicekit_get_object_icon_index (device);
filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
}
- } else if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
- if (!obj->is_present) {
+ } else if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (!is_present) {
/* battery missing */
filename = g_strdup_printf ("gpm-%s-missing", prefix);
- } else if (obj->state == DKP_DEVICE_STATE_FULLY_CHARGED) {
+ } else if (state == DKP_DEVICE_STATE_FULLY_CHARGED) {
filename = g_strdup_printf ("gpm-%s-charged", prefix);
- } else if (obj->state == DKP_DEVICE_STATE_UNKNOWN && obj->percentage > 95.0f) {
- egg_warning ("fixing up unknown %f", obj->percentage);
+ } else if (state == DKP_DEVICE_STATE_UNKNOWN && percentage > 95.0f) {
+ egg_warning ("fixing up unknown %f", percentage);
filename = g_strdup_printf ("gpm-%s-charged", prefix);
- } else if (obj->state == DKP_DEVICE_STATE_CHARGING) {
- index_str = gpm_devicekit_get_object_icon_index (obj);
+ } else if (state == DKP_DEVICE_STATE_CHARGING) {
+ index_str = gpm_devicekit_get_object_icon_index (device);
filename = g_strdup_printf ("gpm-%s-%s-charging", prefix, index_str);
- } else if (obj->state == DKP_DEVICE_STATE_DISCHARGING) {
- index_str = gpm_devicekit_get_object_icon_index (obj);
+ } else if (state == DKP_DEVICE_STATE_DISCHARGING) {
+ index_str = gpm_devicekit_get_object_icon_index (device);
filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
}
- } else if (obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD ||
- obj->type == DKP_DEVICE_TYPE_PHONE) {
- if (!obj->is_present) {
+ } else if (type == DKP_DEVICE_TYPE_MOUSE ||
+ type == DKP_DEVICE_TYPE_KEYBOARD ||
+ type == DKP_DEVICE_TYPE_PHONE) {
+ if (!is_present) {
/* battery missing */
filename = g_strdup_printf ("gpm-%s-000", prefix);
- } else if (obj->state == DKP_DEVICE_STATE_FULLY_CHARGED) {
+ } else if (state == DKP_DEVICE_STATE_FULLY_CHARGED) {
filename = g_strdup_printf ("gpm-%s-100", prefix);
- } else if (obj->state == DKP_DEVICE_STATE_DISCHARGING) {
- index_str = gpm_devicekit_get_object_icon_index (obj);
+ } else if (state == DKP_DEVICE_STATE_DISCHARGING) {
+ index_str = gpm_devicekit_get_object_icon_index (device);
filename = g_strdup_printf ("gpm-%s-%s", prefix, index_str);
}
}
@@ -140,15 +156,11 @@ gpm_devicekit_get_object_icon (const DkpObject *obj)
return filename;
}
-
-#define GPM_DKP_TIME_PRECISION 5*60
-#define GPM_DKP_TEXT_MIN_TIME 120
-
/**
* gpm_devicekit_get_object_summary:
**/
gchar *
-gpm_devicekit_get_object_summary (const DkpObject *obj)
+gpm_devicekit_get_object_summary (DkpDevice *device)
{
const gchar *type_desc = NULL;
gchar *description = NULL;
@@ -156,56 +168,72 @@ gpm_devicekit_get_object_summary (const DkpObject *obj)
guint time_to_empty_round;
gchar *time_to_full_str;
gchar *time_to_empty_str;
-
- if (!obj->is_present)
+ DkpDeviceType type;
+ DkpDeviceState state;
+ gdouble percentage;
+ gboolean is_present;
+ gint64 time_to_full;
+ gint64 time_to_empty;
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ "state", &state,
+ "percentage", &percentage,
+ "is-present", &is_present,
+ "time-to-full", &time_to_full,
+ "time-to-empty", &time_to_empty,
+ NULL);
+
+ if (!is_present)
return NULL;
- type_desc = gpm_device_type_to_localised_text (obj->type, 1);
+ type_desc = gpm_device_type_to_localised_text (type, 1);
/* don't display all the extra stuff for keyboards and mice */
- if (obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD ||
- obj->type == DKP_DEVICE_TYPE_PDA)
- return g_strdup_printf ("%s (%.1f%%)", type_desc, obj->percentage);
+ if (type == DKP_DEVICE_TYPE_MOUSE ||
+ type == DKP_DEVICE_TYPE_KEYBOARD ||
+ type == DKP_DEVICE_TYPE_PDA)
+ return g_strdup_printf ("%s (%.1f%%)", type_desc, percentage);
/* we care if we are on AC */
- if (obj->type == DKP_DEVICE_TYPE_PHONE) {
- if (obj->state == DKP_DEVICE_STATE_CHARGING || !obj->state == DKP_DEVICE_STATE_DISCHARGING)
- return g_strdup_printf ("%s charging (%.1f%%)", type_desc, obj->percentage);
- return g_strdup_printf ("%s (%.1f%%)", type_desc, obj->percentage);
+ if (type == DKP_DEVICE_TYPE_PHONE) {
+ if (state == DKP_DEVICE_STATE_CHARGING || !state == DKP_DEVICE_STATE_DISCHARGING)
+ return g_strdup_printf ("%s charging (%.1f%%)", type_desc, percentage);
+ return g_strdup_printf ("%s (%.1f%%)", type_desc, percentage);
}
/* precalculate so we don't get Unknown time remaining */
- time_to_full_round = egg_precision_round_down (obj->time_to_full, GPM_DKP_TIME_PRECISION);
- time_to_empty_round = egg_precision_round_down (obj->time_to_empty, GPM_DKP_TIME_PRECISION);
+ time_to_full_round = egg_precision_round_down (time_to_full, GPM_DKP_TIME_PRECISION);
+ time_to_empty_round = egg_precision_round_down (time_to_empty, GPM_DKP_TIME_PRECISION);
/* we always display "Laptop battery 16 minutes remaining" as we need to clarify what device we are refering to */
- if (obj->state == DKP_DEVICE_STATE_FULLY_CHARGED) {
+ if (state == DKP_DEVICE_STATE_FULLY_CHARGED) {
- if (obj->type == DKP_DEVICE_TYPE_BATTERY && time_to_empty_round > GPM_DKP_TEXT_MIN_TIME) {
+ if (type == DKP_DEVICE_TYPE_BATTERY && time_to_empty_round > GPM_DKP_TEXT_MIN_TIME) {
time_to_empty_str = gpm_get_timestring (time_to_empty_round);
description = g_strdup_printf (_("%s fully charged (%.1f%%)\nProvides %s battery runtime"),
- type_desc, obj->percentage, time_to_empty_str);
+ type_desc, percentage, time_to_empty_str);
g_free (time_to_empty_str);
} else {
description = g_strdup_printf (_("%s fully charged (%.1f%%)"),
- type_desc, obj->percentage);
+ type_desc, percentage);
}
- } else if (obj->state == DKP_DEVICE_STATE_DISCHARGING) {
+ } else if (state == DKP_DEVICE_STATE_DISCHARGING) {
if (time_to_empty_round > GPM_DKP_TEXT_MIN_TIME) {
time_to_empty_str = gpm_get_timestring (time_to_empty_round);
description = g_strdup_printf (_("%s %s remaining (%.1f%%)"),
- type_desc, time_to_empty_str, obj->percentage);
+ type_desc, time_to_empty_str, percentage);
g_free (time_to_empty_str);
} else {
/* don't display "Unknown remaining" */
description = g_strdup_printf (_("%s discharging (%.1f%%)"),
- type_desc, obj->percentage);
+ type_desc, percentage);
}
- } else if (obj->state == DKP_DEVICE_STATE_CHARGING) {
+ } else if (state == DKP_DEVICE_STATE_CHARGING) {
if (time_to_full_round > GPM_DKP_TEXT_MIN_TIME &&
time_to_empty_round > GPM_DKP_TEXT_MIN_TIME) {
@@ -214,7 +242,7 @@ gpm_devicekit_get_object_summary (const DkpObject *obj)
time_to_full_str = gpm_get_timestring (time_to_full_round);
time_to_empty_str = gpm_get_timestring (time_to_empty_round);
description = g_strdup_printf (_("%s %s until charged (%.1f%%)\nProvides %s battery runtime"),
- type_desc, time_to_full_str, obj->percentage, time_to_empty_str);
+ type_desc, time_to_full_str, percentage, time_to_empty_str);
g_free (time_to_full_str);
g_free (time_to_empty_str);
@@ -223,19 +251,19 @@ gpm_devicekit_get_object_summary (const DkpObject *obj)
/* display only charge time */
time_to_full_str = gpm_get_timestring (time_to_full_round);
description = g_strdup_printf (_("%s %s until charged (%.1f%%)"),
- type_desc, time_to_full_str, obj->percentage);
+ type_desc, time_to_full_str, percentage);
g_free (time_to_full_str);
} else {
/* don't display "Unknown remaining" */
description = g_strdup_printf (_("%s charging (%.1f%%)"),
- type_desc, obj->percentage);
+ type_desc, percentage);
}
} else {
egg_warning ("in an undefined state we are not charging or "
"discharging and the batteries are also not charged");
- description = g_strdup_printf ("%s (%.1f%%)", type_desc, obj->percentage);
+ description = g_strdup_printf ("%s (%.1f%%)", type_desc, percentage);
}
return description;
}
@@ -244,91 +272,128 @@ gpm_devicekit_get_object_summary (const DkpObject *obj)
* gpm_devicekit_get_object_description:
**/
gchar *
-gpm_devicekit_get_object_description (const DkpObject *obj)
+gpm_devicekit_get_object_description (DkpDevice *device)
{
GString *details;
const gchar *text;
gchar *time_str;
-
- g_return_val_if_fail (obj != NULL, NULL);
+ DkpDeviceType type;
+ DkpDeviceState state;
+ DkpDeviceTechnology technology;
+ gdouble percentage;
+ gdouble capacity;
+ gdouble energy;
+ gdouble energy_full;
+ gdouble energy_full_design;
+ gdouble energy_rate;
+ gboolean is_present;
+ gint64 time_to_full;
+ gint64 time_to_empty;
+ gchar *vendor = NULL;
+ gchar *serial = NULL;
+ gchar *model = NULL;
+
+ g_return_val_if_fail (device != NULL, NULL);
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ "state", &state,
+ "percentage", &percentage,
+ "is-present", &is_present,
+ "time-to-full", &time_to_full,
+ "time-to-empty", &time_to_empty,
+ "technology", &technology,
+ "capacity", &capacity,
+ "energy", &energy,
+ "energy-full", &energy_full,
+ "energy-full-design", &energy_full_design,
+ "energy-rate", &energy_rate,
+ "vendor", &vendor,
+ "serial", &serial,
+ "model", &model,
+ NULL);
details = g_string_new ("");
- text = gpm_device_type_to_localised_text (obj->type, 1);
+ text = gpm_device_type_to_localised_text (type, 1);
g_string_append_printf (details, _("<b>Product:</b> %s\n"), text);
- if (!obj->is_present)
+ if (!is_present)
g_string_append_printf (details, _("<b>Status:</b> %s\n"), _("Missing"));
- else if (obj->state == DKP_DEVICE_STATE_FULLY_CHARGED)
+ else if (state == DKP_DEVICE_STATE_FULLY_CHARGED)
g_string_append_printf (details, _("<b>Status:</b> %s\n"), _("Charged"));
- else if (obj->state == DKP_DEVICE_STATE_CHARGING)
+ else if (state == DKP_DEVICE_STATE_CHARGING)
g_string_append_printf (details, _("<b>Status:</b> %s\n"), _("Charging"));
- else if (obj->state == DKP_DEVICE_STATE_DISCHARGING)
+ else if (state == DKP_DEVICE_STATE_DISCHARGING)
g_string_append_printf (details, _("<b>Status:</b> %s\n"), _("Discharging"));
- if (obj->percentage >= 0)
- g_string_append_printf (details, _("<b>Percentage charge:</b> %.1f%%\n"), obj->percentage);
- if (obj->vendor)
- g_string_append_printf (details, _("<b>Vendor:</b> %s\n"), obj->vendor);
- if (obj->technology != DKP_DEVICE_TECHNOLGY_UNKNOWN) {
- text = gpm_device_technology_to_localised_text (obj->technology);
+ if (percentage >= 0)
+ g_string_append_printf (details, _("<b>Percentage charge:</b> %.1f%%\n"), percentage);
+ if (vendor)
+ g_string_append_printf (details, _("<b>Vendor:</b> %s\n"), vendor);
+ if (technology != DKP_DEVICE_TECHNOLOGY_UNKNOWN) {
+ text = gpm_device_technology_to_localised_text (technology);
g_string_append_printf (details, _("<b>Technology:</b> %s\n"), text);
}
- if (obj->serial)
- g_string_append_printf (details, _("<b>Serial number:</b> %s\n"), obj->serial);
- if (obj->model)
- g_string_append_printf (details, _("<b>Model:</b> %s\n"), obj->model);
- if (obj->time_to_full > 0) {
- time_str = gpm_get_timestring (obj->time_to_full);
+ if (serial)
+ g_string_append_printf (details, _("<b>Serial number:</b> %s\n"), serial);
+ if (model)
+ g_string_append_printf (details, _("<b>Model:</b> %s\n"), model);
+ if (time_to_full > 0) {
+ time_str = gpm_get_timestring (time_to_full);
g_string_append_printf (details, _("<b>Charge time:</b> %s\n"), time_str);
g_free (time_str);
}
- if (obj->time_to_empty > 0) {
- time_str = gpm_get_timestring (obj->time_to_empty);
+ if (time_to_empty > 0) {
+ time_str = gpm_get_timestring (time_to_empty);
g_string_append_printf (details, _("<b>Discharge time:</b> %s\n"), time_str);
g_free (time_str);
}
- if (obj->capacity > 0) {
+ if (capacity > 0) {
const gchar *condition;
- if (obj->capacity > 99) {
+ if (capacity > 99) {
/* Translators: Excellent, Good, Fair and Poor are all related to battery Capacity */
condition = _("Excellent");
- } else if (obj->capacity > 90) {
+ } else if (capacity > 90) {
condition = _("Good");
- } else if (obj->capacity > 70) {
+ } else if (capacity > 70) {
condition = _("Fair");
} else {
condition = _("Poor");
}
/* Translators: %.1f is a percentage and %s the condition (Excellent, Good, ...) */
g_string_append_printf (details, _("<b>Capacity:</b> %.1f%% (%s)\n"),
- obj->capacity, condition);
+ capacity, condition);
}
- if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
- if (obj->energy > 0)
+ if (type == DKP_DEVICE_TYPE_BATTERY) {
+ if (energy > 0)
g_string_append_printf (details, _("<b>Current charge:</b> %.1f Wh\n"),
- obj->energy);
- if (obj->energy_full > 0 &&
- obj->energy_full_design != obj->energy_full)
+ energy);
+ if (energy_full > 0 &&
+ energy_full_design != energy_full)
g_string_append_printf (details, _("<b>Last full charge:</b> %.1f Wh\n"),
- obj->energy_full);
- if (obj->energy_full_design > 0)
+ energy_full);
+ if (energy_full_design > 0)
/* Translators: Design charge is the amount of charge the battery is designed to have when brand new */
g_string_append_printf (details, _("<b>Design charge:</b> %.1f Wh\n"),
- obj->energy_full_design);
- if (obj->energy_rate > 0)
+ energy_full_design);
+ if (energy_rate > 0)
g_string_append_printf (details, _("<b>Charge rate:</b> %.1f W\n"),
- obj->energy_rate);
+ energy_rate);
}
- if (obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD) {
- if (obj->energy > 0)
+ if (type == DKP_DEVICE_TYPE_MOUSE ||
+ type == DKP_DEVICE_TYPE_KEYBOARD) {
+ if (energy > 0)
g_string_append_printf (details, _("<b>Current charge:</b> %.0f/7\n"),
- obj->energy);
- if (obj->energy_full_design > 0)
+ energy);
+ if (energy_full_design > 0)
g_string_append_printf (details, _("<b>Design charge:</b> %.0f/7\n"),
- obj->energy_full_design);
+ energy_full_design);
}
/* remove the last \n */
g_string_truncate (details, details->len-1);
+ g_free (vendor);
+ g_free (serial);
+ g_free (model);
return g_string_free (details, FALSE);
}
@@ -418,25 +483,25 @@ gpm_device_technology_to_localised_text (DkpDeviceTechnology technology_enum)
{
const gchar *technology = NULL;
switch (technology_enum) {
- case DKP_DEVICE_TECHNOLGY_LITHIUM_ION:
+ case DKP_DEVICE_TECHNOLOGY_LITHIUM_ION:
technology = _("Lithium Ion");
break;
- case DKP_DEVICE_TECHNOLGY_LITHIUM_POLYMER:
+ case DKP_DEVICE_TECHNOLOGY_LITHIUM_POLYMER:
technology = _("Lithium Polymer");
break;
- case DKP_DEVICE_TECHNOLGY_LITHIUM_IRON_PHOSPHATE:
+ case DKP_DEVICE_TECHNOLOGY_LITHIUM_IRON_PHOSPHATE:
technology = _("Lithium Iron Phosphate");
break;
- case DKP_DEVICE_TECHNOLGY_LEAD_ACID:
+ case DKP_DEVICE_TECHNOLOGY_LEAD_ACID:
technology = _("Lead acid");
break;
- case DKP_DEVICE_TECHNOLGY_NICKEL_CADMIUM:
+ case DKP_DEVICE_TECHNOLOGY_NICKEL_CADMIUM:
technology = _("Nickel Cadmium");
break;
- case DKP_DEVICE_TECHNOLGY_NICKEL_METAL_HYDRIDE:
+ case DKP_DEVICE_TECHNOLOGY_NICKEL_METAL_HYDRIDE:
technology = _("Nickel metal hydride");
break;
- case DKP_DEVICE_TECHNOLGY_UNKNOWN:
+ case DKP_DEVICE_TECHNOLOGY_UNKNOWN:
technology = _("Unknown technology");
break;
default:
diff --git a/src/gpm-devicekit.h b/src/gpm-devicekit.h
index 6a518e0..3442cf9 100644
--- a/src/gpm-devicekit.h
+++ b/src/gpm-devicekit.h
@@ -23,8 +23,7 @@
#define __GPM_DEVICEKIT_H
#include <glib-object.h>
-#include "dkp-enum.h"
-#include "dkp-object.h"
+#include <devkit-power-gobject/devicekit-power.h>
G_BEGIN_DECLS
@@ -32,9 +31,9 @@ const gchar *gpm_device_type_to_localised_text (DkpDeviceType type,
guint number);
const gchar *gpm_device_type_to_icon (DkpDeviceType type);
const gchar *gpm_device_technology_to_localised_text (DkpDeviceTechnology technology_enum);
-gchar *gpm_devicekit_get_object_icon (const DkpObject *obj);
-gchar *gpm_devicekit_get_object_summary (const DkpObject *obj);
-gchar *gpm_devicekit_get_object_description (const DkpObject *obj);
+gchar *gpm_devicekit_get_object_icon (DkpDevice *device);
+gchar *gpm_devicekit_get_object_summary (DkpDevice *device);
+gchar *gpm_devicekit_get_object_description (DkpDevice *device);
G_END_DECLS
diff --git a/src/gpm-engine.c b/src/gpm-engine.c
index 2d7653c..735ba67 100644
--- a/src/gpm-engine.c
+++ b/src/gpm-engine.c
@@ -25,8 +25,7 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <gconf/gconf-client.h>
-#include <dkp-client.h>
-#include <dkp-device.h>
+#include <devkit-power-gobject/devicekit-power.h>
#include "egg-debug.h"
@@ -99,11 +98,16 @@ typedef enum {
* gpm_engine_get_warning_csr:
**/
static GpmEngineWarning
-gpm_engine_get_warning_csr (GpmEngine *engine, const DkpObject *obj)
+gpm_engine_get_warning_csr (GpmEngine *engine, DkpDevice *device)
{
- if (obj->percentage < 26.0f)
+ gdouble percentage;
+
+ /* get device properties */
+ g_object_get (device, "percentage", &percentage, NULL);
+
+ if (percentage < 26.0f)
return GPM_ENGINE_WARNING_LOW;
- else if (obj->percentage < 13.0f)
+ else if (percentage < 13.0f)
return GPM_ENGINE_WARNING_CRITICAL;
return GPM_ENGINE_WARNING_NONE;
}
@@ -112,18 +116,23 @@ gpm_engine_get_warning_csr (GpmEngine *engine, const DkpObject *obj)
* gpm_engine_get_warning_percentage:
**/
static GpmEngineWarning
-gpm_engine_get_warning_percentage (GpmEngine *engine, const DkpObject *obj)
+gpm_engine_get_warning_percentage (GpmEngine *engine, DkpDevice *device)
{
+ gdouble percentage;
+
+ /* get device properties */
+ g_object_get (device, "percentage", &percentage, NULL);
+
/* this is probably an error condition */
- if (obj->percentage == 0) {
+ if (percentage == 0) {
egg_warning ("percentage zero, something's gone wrong");
return GPM_ENGINE_WARNING_NONE;
}
- if (obj->percentage <= engine->priv->action_percentage)
+ if (percentage <= engine->priv->action_percentage)
return GPM_ENGINE_WARNING_ACTION;
- else if (obj->percentage <= engine->priv->critical_percentage)
+ else if (percentage <= engine->priv->critical_percentage)
return GPM_ENGINE_WARNING_CRITICAL;
- else if (obj->percentage <= engine->priv->low_percentage)
+ else if (percentage <= engine->priv->low_percentage)
return GPM_ENGINE_WARNING_LOW;
return GPM_ENGINE_WARNING_NONE;
}
@@ -132,19 +141,28 @@ gpm_engine_get_warning_percentage (GpmEngine *engine, const DkpObject *obj)
* gpm_engine_get_warning_time:
**/
static GpmEngineWarning
-gpm_engine_get_warning_time (GpmEngine *engine, const DkpObject *obj)
+gpm_engine_get_warning_time (GpmEngine *engine, DkpDevice *device)
{
+ DkpDeviceType type;
+ gint64 time_to_empty;
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ "time-to-empty", &time_to_empty,
+ NULL);
+
/* this is probably an error condition */
- if (obj->time_to_empty == 0) {
- egg_debug ("time zero, falling back to percentage for %s", dkp_device_type_to_text (obj->type));
- return gpm_engine_get_warning_percentage (engine, obj);
+ if (time_to_empty == 0) {
+ egg_debug ("time zero, falling back to percentage for %s", dkp_device_type_to_text (type));
+ return gpm_engine_get_warning_percentage (engine, device);
}
- if (obj->time_to_empty <= engine->priv->action_time)
+ if (time_to_empty <= engine->priv->action_time)
return GPM_ENGINE_WARNING_ACTION;
- else if (obj->time_to_empty <= engine->priv->critical_time)
+ else if (time_to_empty <= engine->priv->critical_time)
return GPM_ENGINE_WARNING_CRITICAL;
- else if (obj->time_to_empty <= engine->priv->low_time)
+ else if (time_to_empty <= engine->priv->low_time)
return GPM_ENGINE_WARNING_LOW;
return GPM_ENGINE_WARNING_NONE;
}
@@ -158,41 +176,49 @@ gpm_engine_get_warning_time (GpmEngine *engine, const DkpObject *obj)
* Return value: A GpmEngine state, e.g. GPM_ENGINE_WARNING_DISCHARGING
**/
static GpmEngineWarning
-gpm_engine_get_warning (GpmEngine *engine, const DkpObject *obj)
+gpm_engine_get_warning (GpmEngine *engine, DkpDevice *device)
{
- GpmEngineWarning type;
+ DkpDeviceType type;
+ DkpDeviceState state;
+ GpmEngineWarning warning_type;
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ "state", &state,
+ NULL);
/* default to no engine */
- type = GPM_ENGINE_WARNING_NONE;
+ warning_type = GPM_ENGINE_WARNING_NONE;
- if (obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD) {
+ if (type == DKP_DEVICE_TYPE_MOUSE ||
+ type == DKP_DEVICE_TYPE_KEYBOARD) {
- type = gpm_engine_get_warning_csr (engine, obj);
+ warning_type = gpm_engine_get_warning_csr (engine, device);
- } else if (obj->type == DKP_DEVICE_TYPE_UPS ||
- obj->type == DKP_DEVICE_TYPE_PDA) {
+ } else if (type == DKP_DEVICE_TYPE_UPS ||
+ type == DKP_DEVICE_TYPE_PDA) {
- type = gpm_engine_get_warning_percentage (engine, obj);
+ warning_type = gpm_engine_get_warning_percentage (engine, device);
- } else if (obj->type == DKP_DEVICE_TYPE_PHONE) {
+ } else if (type == DKP_DEVICE_TYPE_PHONE) {
- type = gpm_engine_get_warning_percentage (engine, obj);
+ warning_type = gpm_engine_get_warning_percentage (engine, device);
- } else if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
+ } else if (type == DKP_DEVICE_TYPE_BATTERY) {
/* only use the time when it is accurate, and GConf is not disabled */
if (engine->priv->use_time_primary)
- type = gpm_engine_get_warning_time (engine, obj);
+ warning_type = gpm_engine_get_warning_time (engine, device);
else
- type = gpm_engine_get_warning_percentage (engine, obj);
+ warning_type = gpm_engine_get_warning_percentage (engine, device);
}
/* If we have no important engines, we should test for discharging */
- if (type == GPM_ENGINE_WARNING_NONE) {
- if (obj->state == DKP_DEVICE_STATE_DISCHARGING)
- type = GPM_ENGINE_WARNING_DISCHARGING;
+ if (warning_type == GPM_ENGINE_WARNING_NONE) {
+ if (state == DKP_DEVICE_STATE_DISCHARGING)
+ warning_type = GPM_ENGINE_WARNING_DISCHARGING;
}
- return type;
+ return warning_type;
}
/**
@@ -207,8 +233,7 @@ gpm_engine_get_summary (GpmEngine *engine)
{
guint i;
GPtrArray *array;
- const DkpDevice *device;
- const DkpObject *obj;
+ DkpDevice *device;
GString *tooltip = NULL;
gchar *part;
@@ -221,8 +246,7 @@ gpm_engine_get_summary (GpmEngine *engine)
array = engine->priv->array;
for (i=0;i<array->len;i++) {
device = g_ptr_array_index (engine->priv->array, i);
- obj = dkp_device_get_object (device);
- part = gpm_devicekit_get_object_summary (obj);
+ part = gpm_devicekit_get_object_summary (device);
if (part != NULL)
g_string_append_printf (tooltip, "%s\n", part);
g_free (part);
@@ -242,32 +266,41 @@ gpm_engine_get_summary (GpmEngine *engine)
* Returns the icon
**/
static gchar *
-gpm_engine_get_icon_priv (GpmEngine *engine, DkpDeviceType type, GpmEngineWarning warning, gboolean state)
+gpm_engine_get_icon_priv (GpmEngine *engine, DkpDeviceType device_type, GpmEngineWarning warning, gboolean use_state)
{
guint i;
GPtrArray *array;
- const DkpDevice *device;
- const DkpObject *obj;
+ DkpDevice *device;
GpmEngineWarning warning_temp;
+ DkpDeviceType type;
+ DkpDeviceState state;
+ gboolean is_present;
/* do we have specific device types? */
array = engine->priv->array;
for (i=0;i<array->len;i++) {
device = g_ptr_array_index (engine->priv->array, i);
- obj = dkp_device_get_object (device);
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ "state", &state,
+ "is-present", &is_present,
+ NULL);
+
warning_temp = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(device), "engine-warning-old"));
- if (obj->type == type && obj->is_present) {
+ if (type == device_type && is_present) {
if (warning != GPM_ENGINE_WARNING_NONE) {
if (warning_temp == warning)
- return gpm_devicekit_get_object_icon (obj);
+ return gpm_devicekit_get_object_icon (device);
continue;
}
- if (state) {
- if (obj->state == DKP_DEVICE_STATE_CHARGING || obj->state == DKP_DEVICE_STATE_DISCHARGING)
- return gpm_devicekit_get_object_icon (obj);
+ if (use_state) {
+ if (state == DKP_DEVICE_STATE_CHARGING || state == DKP_DEVICE_STATE_DISCHARGING)
+ return gpm_devicekit_get_object_icon (device);
continue;
}
- return gpm_devicekit_get_object_icon (obj);
+ return gpm_devicekit_get_object_icon (device);
}
}
return NULL;
@@ -471,20 +504,26 @@ gpm_engine_conf_key_changed_cb (GConfClient *conf, guint cnxn_id, GConfEntry *en
* gpm_engine_device_check_capacity:
**/
static gboolean
-gpm_engine_device_check_capacity (GpmEngine *engine, const DkpDevice *device)
+gpm_engine_device_check_capacity (GpmEngine *engine, DkpDevice *device)
{
- const DkpObject *obj;
gboolean ret;
+ DkpDeviceType type;
+ gdouble capacity;
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ "capacity", &capacity,
+ NULL);
- obj = dkp_device_get_object (device);
- if (obj->type != DKP_DEVICE_TYPE_BATTERY || obj->capacity > 50.0f)
+ if (type != DKP_DEVICE_TYPE_BATTERY || capacity > 50.0f)
return FALSE;
/* only emit this if specified in gconf */
ret = gconf_client_get_bool (engine->priv->conf, GPM_CONF_NOTIFY_LOW_CAPACITY, NULL);
if (ret) {
egg_debug ("** EMIT: low-capacity");
- g_signal_emit (engine, signals [LOW_CAPACITY], 0, obj->type, (guint) obj->capacity);
+ g_signal_emit (engine, signals [LOW_CAPACITY], 0, device);
}
return TRUE;
}
@@ -496,18 +535,22 @@ static void
gpm_engine_device_add (GpmEngine *engine, DkpDevice *device)
{
GpmEngineWarning warning;
- const DkpObject *obj;
+ DkpDeviceState state;
/* assign warning */
- obj = dkp_device_get_object (device);
- warning = gpm_engine_get_warning (engine, obj);
+ warning = gpm_engine_get_warning (engine, device);
g_object_set_data (G_OBJECT(device), "engine-warning-old", GUINT_TO_POINTER(warning));
/* check capacity */
gpm_engine_device_check_capacity (engine, device);
+ /* get device properties */
+ g_object_get (device,
+ "state", &state,
+ NULL);
+
/* add old state for transitions */
- g_object_set_data (G_OBJECT(device), "engine-state-old", GUINT_TO_POINTER(obj->state));
+ g_object_set_data (G_OBJECT(device), "engine-state-old", GUINT_TO_POINTER(state));
}
/**
@@ -522,22 +565,27 @@ gpm_engine_coldplug_idle_cb (GpmEngine *engine)
gboolean has_ups = FALSE;
GpmPrefsServer *prefs_server;
DkpDevice *device;
- const DkpObject *obj;
+ DkpDeviceType type;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (GPM_IS_ENGINE (engine), FALSE);
/* get array */
- engine->priv->array = dkp_client_enumerate_devices (engine->priv->client);
+ engine->priv->array = dkp_client_enumerate_devices (engine->priv->client, NULL);
/* do we have specific device types? */
array = engine->priv->array;
for (i=0;i<array->len;i++) {
device = g_ptr_array_index (engine->priv->array, i);
- obj = dkp_device_get_object (device);
- if (obj->type == DKP_DEVICE_TYPE_BATTERY)
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ NULL);
+
+ if (type == DKP_DEVICE_TYPE_BATTERY)
has_battery = TRUE;
- else if (obj->type == DKP_DEVICE_TYPE_UPS)
+ else if (type == DKP_DEVICE_TYPE_UPS)
has_ups = TRUE;
}
@@ -597,53 +645,56 @@ static void
gpm_engine_device_changed_cb (DkpClient *client, DkpDevice *device, GpmEngine *engine)
{
DkpDeviceState state;
- const DkpObject *obj;
+ DkpDeviceState state_old;
GpmEngineWarning warning_old;
GpmEngineWarning warning;
gboolean ret;
- obj = dkp_device_get_object (device);
-
/* check the warning state has not changed */
warning_old = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(device), "engine-warning-old"));
- warning = gpm_engine_get_warning (engine, obj);
+ warning = gpm_engine_get_warning (engine, device);
if (warning != warning_old) {
if (warning == GPM_ENGINE_WARNING_LOW) {
egg_debug ("** EMIT: charge-low");
- g_signal_emit (engine, signals [CHARGE_LOW], 0, obj);
+ g_signal_emit (engine, signals [CHARGE_LOW], 0, device);
} else if (warning == GPM_ENGINE_WARNING_CRITICAL) {
egg_debug ("** EMIT: charge-low");
- g_signal_emit (engine, signals [CHARGE_CRITICAL], 0, obj);
+ g_signal_emit (engine, signals [CHARGE_CRITICAL], 0, device);
} else if (warning == GPM_ENGINE_WARNING_ACTION) {
egg_debug ("** EMIT: charge-low");
- g_signal_emit (engine, signals [CHARGE_ACTION], 0, obj);
+ g_signal_emit (engine, signals [CHARGE_ACTION], 0, device);
}
/* save new state */
g_object_set_data (G_OBJECT(device), "engine-warning-old", GUINT_TO_POINTER(warning));
}
+ /* get device properties */
+ g_object_get (device,
+ "state", &state,
+ NULL);
+
/* see if any interesting state changes have happened */
- state = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(device), "engine-state-old"));
- if (state != obj->state) {
+ state_old = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(device), "engine-state-old"));
+ if (state_old != state) {
- if (state == DKP_DEVICE_STATE_DISCHARGING) {
+ if (state_old == DKP_DEVICE_STATE_DISCHARGING) {
/* only emit this if specified in gconf */
ret = gconf_client_get_bool (engine->priv->conf, GPM_CONF_NOTIFY_DISCHARGING, NULL);
if (ret) {
egg_debug ("** EMIT: discharging");
- g_signal_emit (engine, signals [DISCHARGING], 0, obj->type);
+ g_signal_emit (engine, signals [DISCHARGING], 0, device);
}
- } else if (state == DKP_DEVICE_STATE_FULLY_CHARGED) {
+ } else if (state_old == DKP_DEVICE_STATE_FULLY_CHARGED) {
/* only emit this if specified in gconf */
ret = gconf_client_get_bool (engine->priv->conf, GPM_CONF_NOTIFY_FULLY_CHARGED, NULL);
if (ret) {
egg_debug ("** EMIT: discharging");
- g_signal_emit (engine, signals [FULLY_CHARGED], 0, obj->type);
+ g_signal_emit (engine, signals [FULLY_CHARGED], 0, device);
}
}
/* save new state */
- g_object_set_data (G_OBJECT(device), "engine-state-old", GUINT_TO_POINTER(obj->state));
+ g_object_set_data (G_OBJECT(device), "engine-state-old", GUINT_TO_POINTER(state));
}
gpm_engine_recalculate_state (engine);
@@ -673,16 +724,18 @@ gpm_engine_get_devices (GpmEngine *engine)
static void
phone_device_added_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
{
- DkpObject *obj;
DkpDevice *device;
device = dkp_device_new ();
egg_debug ("phone added %i", idx);
-
- obj = (DkpObject *) dkp_device_get_object (device);
- obj->native_path = g_strdup_printf ("phone_%i", idx);
- obj->is_rechargeable = TRUE;
- obj->type = DKP_DEVICE_TYPE_PHONE;
+
+ /* get device properties */
+ g_object_set (device,
+ "type", DKP_DEVICE_TYPE_PHONE,
+ "is-rechargeable", TRUE,
+ "native-path", g_strdup_printf ("phone_%i", idx),
+ "is-present", TRUE,
+ NULL);
/* state changed */
gpm_engine_device_add (engine, device);
@@ -698,14 +751,19 @@ phone_device_removed_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
{
guint i;
DkpDevice *device;
- const DkpObject *obj;
+ DkpDeviceType type;
egg_debug ("phone removed %i", idx);
for (i=0; i<engine->priv->array->len; i++) {
device = g_ptr_array_index (engine->priv->array, i);
- obj = dkp_device_get_object (device);
- if (obj->type == DKP_DEVICE_TYPE_PHONE) {
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ NULL);
+
+ if (type == DKP_DEVICE_TYPE_PHONE) {
g_ptr_array_remove_index (engine->priv->array, i);
g_object_unref (device);
break;
@@ -724,17 +782,28 @@ phone_device_refresh_cb (GpmPhone *phone, guint idx, GpmEngine *engine)
{
guint i;
DkpDevice *device;
- DkpObject *obj;
+ DkpDeviceType type;
+ DkpDeviceState state;
+ gboolean is_present;
+ gdouble percentage;
egg_debug ("phone refresh %i", idx);
for (i=0; i<engine->priv->array->len; i++) {
device = g_ptr_array_index (engine->priv->array, i);
- obj = (DkpObject *) dkp_device_get_object (device);
- if (obj->type == DKP_DEVICE_TYPE_PHONE) {
- obj->is_present = gpm_phone_get_present (phone, idx);
- obj->state = gpm_phone_get_on_ac (phone, idx) ? DKP_DEVICE_STATE_CHARGING : DKP_DEVICE_STATE_DISCHARGING;
- obj->percentage = gpm_phone_get_percentage (phone, idx);
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ "state", &state,
+ "percentage", &percentage,
+ "is-present", &is_present,
+ NULL);
+
+ if (type == DKP_DEVICE_TYPE_PHONE) {
+ is_present = gpm_phone_get_present (phone, idx);
+ state = gpm_phone_get_on_ac (phone, idx) ? DKP_DEVICE_STATE_CHARGING : DKP_DEVICE_STATE_DISCHARGING;
+ percentage = gpm_phone_get_percentage (phone, idx);
break;
}
}
@@ -834,30 +903,30 @@ gpm_engine_class_init (GpmEngineClass *klass)
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GpmEngineClass, low_capacity),
- NULL, NULL, gpm_marshal_VOID__UINT_UINT,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
signals [PERHAPS_RECALL] =
g_signal_new ("perhaps-recall",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GpmEngineClass, perhaps_recall),
- NULL, NULL, gpm_marshal_VOID__UINT_STRING_STRING,
+ NULL, NULL, gpm_marshal_VOID__POINTER_STRING_STRING,
G_TYPE_NONE,
- 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
+ 3, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING);
signals [FULLY_CHARGED] =
g_signal_new ("fully-charged",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GpmEngineClass, fully_charged),
NULL, NULL, g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1, G_TYPE_UINT);
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
signals [DISCHARGING] =
g_signal_new ("discharging",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GpmEngineClass, discharging),
- NULL, NULL, g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
signals [CHARGE_ACTION] =
g_signal_new ("charge-action",
G_TYPE_FROM_CLASS (object_class),
diff --git a/src/gpm-engine.h b/src/gpm-engine.h
index eac427c..caaef13 100644
--- a/src/gpm-engine.h
+++ b/src/gpm-engine.h
@@ -23,7 +23,7 @@
#define __GPM_ENGINE_H
#include <glib-object.h>
-#include <dkp-device.h>
+#include <devkit-power-gobject/devicekit-power.h>
G_BEGIN_DECLS
@@ -50,24 +50,21 @@ typedef struct
void (* summary_changed) (GpmEngine *engine,
gchar *status);
void (* perhaps_recall) (GpmEngine *engine,
- DkpDeviceType kind,
+ DkpDevice *device,
const gchar *oem_vendor,
const gchar *website);
void (* low_capacity) (GpmEngine *engine,
- DkpDeviceType kind,
- guint capacity);
+ DkpDevice *device);
void (* charge_low) (GpmEngine *engine,
- DkpDeviceType kind,
- DkpObject *obj);
+ DkpDevice *device);
void (* charge_critical) (GpmEngine *engine,
- DkpDeviceType kind,
- DkpObject *obj);
+ DkpDevice *device);
void (* charge_action) (GpmEngine *engine,
- DkpDeviceType kind);
+ DkpDevice *device);
void (* fully_charged) (GpmEngine *engine,
- DkpDeviceType kind);
+ DkpDevice *device);
void (* discharging) (GpmEngine *engine,
- DkpDeviceType kind);
+ DkpDevice *device);
} GpmEngineClass;
GType gpm_engine_get_type (void);
diff --git a/src/gpm-graph-widget.c b/src/gpm-graph-widget.c
index c863521..2122958 100644
--- a/src/gpm-graph-widget.c
+++ b/src/gpm-graph-widget.c
@@ -28,6 +28,7 @@
#include "gpm-common.h"
#include "gpm-point-obj.h"
#include "gpm-graph-widget.h"
+
#include "egg-debug.h"
#include "egg-color.h"
#include "egg-precision.h"
@@ -207,6 +208,29 @@ gpm_graph_widget_init (GpmGraphWidget *graph)
}
/**
+ * gpm_graph_widget_data_clear:
+ **/
+gboolean
+gpm_graph_widget_data_clear (GpmGraphWidget *graph)
+{
+ guint i;
+ GPtrArray *array;
+
+ g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
+
+ for (i=0; i<graph->priv->data_list->len; i++) {
+ array = g_ptr_array_index (graph->priv->data_list, i);
+ g_ptr_array_foreach (array, (GFunc) gpm_point_obj_free, NULL);
+ g_ptr_array_free (array, TRUE);
+ }
+
+ g_ptr_array_set_size (graph->priv->data_list, 0);
+ g_ptr_array_set_size (graph->priv->plot_list, 0);
+
+ return TRUE;
+}
+
+/**
* gpm_graph_widget_finalize:
* @object: This graph class instance
**/
@@ -216,11 +240,11 @@ gpm_graph_widget_finalize (GObject *object)
PangoContext *context;
GpmGraphWidget *graph = (GpmGraphWidget*) object;
- /* clear key */
+ /* clear key and data */
gpm_graph_widget_key_data_clear (graph);
+ gpm_graph_widget_data_clear (graph);
/* free data */
- g_ptr_array_foreach (graph->priv->data_list, (GFunc) g_object_unref, NULL);
g_ptr_array_free (graph->priv->data_list, TRUE);
g_ptr_array_free (graph->priv->plot_list, TRUE);
@@ -231,34 +255,31 @@ gpm_graph_widget_finalize (GObject *object)
}
/**
- * gpm_graph_widget_data_clear:
- **/
-gboolean
-gpm_graph_widget_data_clear (GpmGraphWidget *graph)
-{
- g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
-
- g_ptr_array_foreach (graph->priv->data_list, (GFunc) g_object_unref, NULL);
- g_ptr_array_set_size (graph->priv->data_list, 0);
- g_ptr_array_set_size (graph->priv->plot_list, 0);
-
- return TRUE;
-}
-
-/**
* gpm_graph_widget_data_assign:
* @graph: This class instance
+ * @data: an array of GpmPointObj's
*
* Sets the data for the graph
**/
gboolean
-gpm_graph_widget_data_assign (GpmGraphWidget *graph, GpmGraphWidgetPlot plot, EggObjList *data)
+gpm_graph_widget_data_assign (GpmGraphWidget *graph, GpmGraphWidgetPlot plot, GPtrArray *data)
{
+ GPtrArray *copy;
+ GpmPointObj *obj;
+ guint i;
+
g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
+ /* make a deep copy */
+ copy = g_ptr_array_new ();
+ for (i=0; i<data->len; i++) {
+ obj = gpm_point_obj_copy (g_ptr_array_index (data, i));
+ g_ptr_array_add (copy, obj);
+ }
+
/* get the new data */
- g_ptr_array_add (graph->priv->data_list, g_object_ref (data));
+ g_ptr_array_add (graph->priv->data_list, copy);
g_ptr_array_add (graph->priv->plot_list, GUINT_TO_POINTER(plot));
/* refresh */
@@ -498,7 +519,7 @@ gpm_graph_widget_auto_range (GpmGraphWidget *graph)
gfloat smallest_y = G_MAXFLOAT;
guint rounding_x = 1;
guint rounding_y = 1;
- EggObjList *data;
+ GPtrArray *data;
GpmPointObj *point;
guint i, j;
guint len = 0;
@@ -528,7 +549,7 @@ gpm_graph_widget_auto_range (GpmGraphWidget *graph)
for (j=0; j<array->len; j++) {
data = g_ptr_array_index (array, j);
for (i=0; i < data->len; i++) {
- point = (GpmPointObj *) egg_obj_list_index (data, i);
+ point = (GpmPointObj *) g_ptr_array_index (data, i);
if (point->x > biggest_x)
biggest_x = point->x;
if (point->y > biggest_y)
@@ -709,7 +730,7 @@ gpm_graph_widget_draw_line (GpmGraphWidget *graph, cairo_t *cr)
{
gfloat oldx, oldy;
gfloat newx, newy;
- EggObjList *data;
+ GPtrArray *data;
GPtrArray *array;
GpmGraphWidgetPlot plot;
GpmPointObj *point;
@@ -731,14 +752,14 @@ gpm_graph_widget_draw_line (GpmGraphWidget *graph, cairo_t *cr)
plot = GPOINTER_TO_UINT (g_ptr_array_index (graph->priv->plot_list, j));
/* get the very first point so we can work out the old */
- point = (GpmPointObj *) egg_obj_list_index (data, 0);
+ point = (GpmPointObj *) g_ptr_array_index (data, 0);
oldx = 0;
oldy = 0;
gpm_graph_widget_get_pos_on_graph (graph, point->x, point->y, &oldx, &oldy);
gpm_graph_widget_draw_dot (cr, oldx, oldy, point->color);
for (i=1; i < data->len; i++) {
- point = (GpmPointObj *) egg_obj_list_index (data, i);
+ point = (GpmPointObj *) g_ptr_array_index (data, i);
gpm_graph_widget_get_pos_on_graph (graph, point->x, point->y, &newx, &newy);
diff --git a/src/gpm-graph-widget.h b/src/gpm-graph-widget.h
index f0151ca..6fae9e1 100644
--- a/src/gpm-graph-widget.h
+++ b/src/gpm-graph-widget.h
@@ -23,7 +23,6 @@
#define __GPM_GRAPH_WIDGET_H__
#include <gtk/gtk.h>
-#include "egg-obj-list.h"
#include "gpm-point-obj.h"
G_BEGIN_DECLS
@@ -82,7 +81,7 @@ void gpm_graph_widget_enable_legend (GpmGraphWidget *graph,
gboolean gpm_graph_widget_data_clear (GpmGraphWidget *graph);
gboolean gpm_graph_widget_data_assign (GpmGraphWidget *graph,
GpmGraphWidgetPlot plot,
- EggObjList *array);
+ GPtrArray *array);
void gpm_graph_widget_set_type_x (GpmGraphWidget *graph,
GpmGraphWidgetType axis);
void gpm_graph_widget_set_type_y (GpmGraphWidget *graph,
diff --git a/src/gpm-manager.c b/src/gpm-manager.c
index 3b223f6..41532a1 100644
--- a/src/gpm-manager.c
+++ b/src/gpm-manager.c
@@ -40,7 +40,7 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <gconf/gconf-client.h>
#include <canberra-gtk.h>
-#include <dkp-device.h>
+#include <devkit-power-gobject/devicekit-power.h>
#include "egg-debug.h"
#include "egg-console-kit.h"
@@ -1155,7 +1155,7 @@ gpm_manager_perhaps_recall (GpmManager *manager)
* gpm_engine_perhaps_recall_cb:
*/
static void
-gpm_engine_perhaps_recall_cb (GpmEngine *engine, DkpDeviceType type, gchar *oem_vendor, gchar *website, GpmManager *manager)
+gpm_engine_perhaps_recall_cb (GpmEngine *engine, DkpDevice *device, gchar *oem_vendor, gchar *website, GpmManager *manager)
{
g_object_set_data (G_OBJECT (manager), "recall-oem-vendor", (gpointer) g_strdup (oem_vendor));
g_object_set_data (G_OBJECT (manager), "recall-oem-website", (gpointer) g_strdup (website));
@@ -1164,18 +1164,6 @@ gpm_engine_perhaps_recall_cb (GpmEngine *engine, DkpDeviceType type, gchar *oem_
}
/**
- * gpm_engine_low_capacity_cb:
- */
-static void
-gpm_engine_low_capacity_cb (GpmEngine *engine, DkpDeviceType type, guint capacity, GpmManager *manager)
-{
- /* We should notify the user if the battery has a low capacity,
- * where capacity is the ratio of the last_full capacity with that of
- * the design capacity. (#326740) */
- gpm_notify_low_capacity (manager->priv->notify, capacity);
-}
-
-/**
* gpm_engine_icon_changed_cb:
*/
static void
@@ -1197,18 +1185,51 @@ gpm_engine_summary_changed_cb (GpmEngine *engine, gchar *summary, GpmManager *ma
* gpm_engine_low_capacity_cb:
*/
static void
-gpm_engine_fully_charged_cb (GpmEngine *engine, DkpDeviceType type, GpmManager *manager)
+gpm_engine_low_capacity_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
{
+ gdouble capacity;
+
+ /* get device properties */
+ g_object_get (device,
+ "capacity", &capacity,
+ NULL);
+
+ /* We should notify the user if the battery has a low capacity,
+ * where capacity is the ratio of the last_full capacity with that of
+ * the design capacity. (#326740) */
+ gpm_notify_low_capacity (manager->priv->notify, capacity);
+}
+
+/**
+ * gpm_engine_fully_charged_cb:
+ */
+static void
+gpm_engine_fully_charged_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
+{
+ DkpDeviceType type;
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ NULL);
+
if (type == DKP_DEVICE_TYPE_BATTERY)
gpm_notify_fully_charged_primary (manager->priv->notify);
}
/**
- * gpm_engine_low_capacity_cb:
+ * gpm_engine_discharging_cb:
*/
static void
-gpm_engine_discharging_cb (GpmEngine *engine, DkpDeviceType type, GpmManager *manager)
+gpm_engine_discharging_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
{
+ DkpDeviceType type;
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ NULL);
+
if (type == DKP_DEVICE_TYPE_BATTERY)
gpm_notify_discharging_primary (manager->priv->notify);
else if (type == DKP_DEVICE_TYPE_UPS)
@@ -1245,42 +1266,52 @@ control_sleep_failure_cb (GpmControl *control, GpmControlAction action, GpmManag
* gpm_engine_charge_low_cb:
*/
static void
-gpm_engine_charge_low_cb (GpmEngine *engine, DkpObject *obj, GpmManager *manager)
+gpm_engine_charge_low_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
{
const gchar *title = NULL;
gchar *message = NULL;
gchar *remaining_text;
gchar *icon;
-
- if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
+ DkpDeviceType type;
+ gdouble percentage;
+ gint64 time_to_empty;
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ "percentage", &percentage,
+ "time-to-empty", &time_to_empty,
+ NULL);
+
+ if (type == DKP_DEVICE_TYPE_BATTERY) {
title = _("Laptop battery low");
- remaining_text = gpm_get_timestring (obj->time_to_empty);
+ remaining_text = gpm_get_timestring (time_to_empty);
message = g_strdup_printf (_("You have approximately <b>%s</b> of remaining battery life (%.1f%%)"),
- remaining_text, obj->percentage);
- } else if (obj->type == DKP_DEVICE_TYPE_UPS) {
+ remaining_text, percentage);
+ } else if (type == DKP_DEVICE_TYPE_UPS) {
title = _("UPS low");
- remaining_text = gpm_get_timestring (obj->time_to_empty);
+ remaining_text = gpm_get_timestring (time_to_empty);
message = g_strdup_printf (_("You have approximately <b>%s</b> of remaining UPS backup power (%.1f%%)"),
- remaining_text, obj->percentage);
- } else if (obj->type == DKP_DEVICE_TYPE_MOUSE) {
+ remaining_text, percentage);
+ } else if (type == DKP_DEVICE_TYPE_MOUSE) {
title = _("Mouse battery low");
- message = g_strdup_printf (_("The wireless mouse attached to this computer is low in power (%.1f%%)"), obj->percentage);
+ message = g_strdup_printf (_("The wireless mouse attached to this computer is low in power (%.1f%%)"), percentage);
- } else if (obj->type == DKP_DEVICE_TYPE_KEYBOARD) {
+ } else if (type == DKP_DEVICE_TYPE_KEYBOARD) {
title = _("Keyboard battery low");
- message = g_strdup_printf (_("The wireless keyboard attached to this computer is low in power (%.1f%%)"), obj->percentage);
+ message = g_strdup_printf (_("The wireless keyboard attached to this computer is low in power (%.1f%%)"), percentage);
- } else if (obj->type == DKP_DEVICE_TYPE_PDA) {
+ } else if (type == DKP_DEVICE_TYPE_PDA) {
title = _("PDA battery low");
- message = g_strdup_printf (_("The PDA attached to this computer is low in power (%.1f%%)"), obj->percentage);
+ message = g_strdup_printf (_("The PDA attached to this computer is low in power (%.1f%%)"), percentage);
- } else if (obj->type == DKP_DEVICE_TYPE_PHONE) {
+ } else if (type == DKP_DEVICE_TYPE_PHONE) {
title = _("Cell phone battery low");
- message = g_strdup_printf (_("The cell phone attached to this computer is low in power (%.1f%%)"), obj->percentage);
+ message = g_strdup_printf (_("The cell phone attached to this computer is low in power (%.1f%%)"), percentage);
}
/* get correct icon */
- icon = gpm_devicekit_get_object_icon (obj);
+ icon = gpm_devicekit_get_object_icon (device);
gpm_notify_display (manager->priv->notify, title, message, GPM_NOTIFY_TIMEOUT_LONG, icon, GPM_NOTIFY_URGENCY_NORMAL);
gpm_manager_play (manager, GPM_MANAGER_SOUND_BATTERY_LOW, TRUE);
g_free (icon);
@@ -1301,7 +1332,7 @@ gpm_manager_get_time_until_action_text (GpmManager *manager)
* gpm_engine_charge_critical_cb:
*/
static void
-gpm_engine_charge_critical_cb (GpmEngine *engine, DkpObject *obj, GpmManager *manager)
+gpm_engine_charge_critical_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
{
const gchar *title = NULL;
gchar *message = NULL;
@@ -1310,10 +1341,20 @@ gpm_engine_charge_critical_cb (GpmEngine *engine, DkpObject *obj, GpmManager *ma
gchar *action;
gchar *icon;
gchar *time_text;
-
- if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
+ DkpDeviceType type;
+ gdouble percentage;
+ gint64 time_to_empty;
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ "percentage", &percentage,
+ "time-to-empty", &time_to_empty,
+ NULL);
+
+ if (type == DKP_DEVICE_TYPE_BATTERY) {
title = _("Laptop battery critically low");
- remaining_text = gpm_get_timestring (obj->time_to_empty);
+ remaining_text = gpm_get_timestring (time_to_empty);
time_text = gpm_manager_get_time_until_action_text (manager);
/* we have to do different warnings depending on the policy */
@@ -1334,43 +1375,43 @@ gpm_engine_charge_critical_cb (GpmEngine *engine, DkpObject *obj, GpmManager *ma
action_text = g_strdup_printf (_("This computer will shutdown in %s if the AC is not connected."), time_text);
message = g_strdup_printf (_("You have approximately <b>%s</b> of remaining battery life (%.1f%%). %s"),
- remaining_text, obj->percentage, action_text);
+ remaining_text, percentage, action_text);
g_free (action);
g_free (action_text);
g_free (remaining_text);
g_free (time_text);
- } else if (obj->type == DKP_DEVICE_TYPE_UPS) {
+ } else if (type == DKP_DEVICE_TYPE_UPS) {
title = _("UPS critically low");
- remaining_text = gpm_get_timestring (obj->time_to_empty);
+ remaining_text = gpm_get_timestring (time_to_empty);
message = g_strdup_printf (_("You have approximately <b>%s</b> of remaining UPS power (%.1f%%). "
"Restore AC power to your computer to avoid losing data."),
- remaining_text, obj->percentage);
+ remaining_text, percentage);
g_free (remaining_text);
- } else if (obj->type == DKP_DEVICE_TYPE_MOUSE) {
+ } else if (type == DKP_DEVICE_TYPE_MOUSE) {
title = _("Mouse battery low");
message = g_strdup_printf (_("The wireless mouse attached to this computer is very low in power (%.1f%%). "
"This device will soon stop functioning if not charged."),
- obj->percentage);
- } else if (obj->type == DKP_DEVICE_TYPE_KEYBOARD) {
+ percentage);
+ } else if (type == DKP_DEVICE_TYPE_KEYBOARD) {
title = _("Keyboard battery low");
message = g_strdup_printf (_("The wireless keyboard attached to this computer is very low in power (%.1f%%). "
"This device will soon stop functioning if not charged."),
- obj->percentage);
- } else if (obj->type == DKP_DEVICE_TYPE_PDA) {
+ percentage);
+ } else if (type == DKP_DEVICE_TYPE_PDA) {
title = _("PDA battery low");
message = g_strdup_printf (_("The PDA attached to this computer is very low in power (%.1f%%). "
"This device will soon stop functioning if not charged."),
- obj->percentage);
- } else if (obj->type == DKP_DEVICE_TYPE_PHONE) {
+ percentage);
+ } else if (type == DKP_DEVICE_TYPE_PHONE) {
title = _("Cell phone battery low");
message = g_strdup_printf (_("Your cell phone is very low in power (%.1f%%). "
"This device will soon stop functioning if not charged."),
- obj->percentage);
+ percentage);
}
/* get correct icon */
- icon = gpm_devicekit_get_object_icon (obj);
+ icon = gpm_devicekit_get_object_icon (device);
gpm_notify_display (manager->priv->notify, title, message, GPM_NOTIFY_TIMEOUT_LONG, icon, GPM_NOTIFY_URGENCY_CRITICAL);
gpm_manager_play (manager, GPM_MANAGER_SOUND_BATTERY_LOW, TRUE);
g_free (icon);
@@ -1381,14 +1422,20 @@ gpm_engine_charge_critical_cb (GpmEngine *engine, DkpObject *obj, GpmManager *ma
* gpm_engine_charge_action_cb:
*/
static void
-gpm_engine_charge_action_cb (GpmEngine *engine, DkpObject *obj, GpmManager *manager)
+gpm_engine_charge_action_cb (GpmEngine *engine, DkpDevice *device, GpmManager *manager)
{
const gchar *title = NULL;
gchar *action;
gchar *message = NULL;
gchar *icon;
+ DkpDeviceType type;
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ NULL);
- if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
+ if (type == DKP_DEVICE_TYPE_BATTERY) {
title = _("Laptop battery critically low");
/* we have to do different warnings depending on the policy */
@@ -1420,7 +1467,7 @@ gpm_engine_charge_action_cb (GpmEngine *engine, DkpObject *obj, GpmManager *mana
/* wait 10 seconds for user-panic */
g_timeout_add_seconds (10, (GSourceFunc) manager_critical_action_do, manager);
- } else if (obj->type == DKP_DEVICE_TYPE_UPS) {
+ } else if (type == DKP_DEVICE_TYPE_UPS) {
title = _("UPS critically low");
/* we have to do different warnings depending on the policy */
@@ -1449,7 +1496,7 @@ gpm_engine_charge_action_cb (GpmEngine *engine, DkpObject *obj, GpmManager *mana
return;
/* get correct icon */
- icon = gpm_devicekit_get_object_icon (obj);
+ icon = gpm_devicekit_get_object_icon (device);
gpm_notify_display (manager->priv->notify,
title, message, GPM_NOTIFY_TIMEOUT_LONG,
icon, GPM_NOTIFY_URGENCY_CRITICAL);
diff --git a/src/gpm-marshal.list b/src/gpm-marshal.list
index 7bfab9c..1a94c6a 100644
--- a/src/gpm-marshal.list
+++ b/src/gpm-marshal.list
@@ -1,6 +1,6 @@
NONE:INT,BOXED
NONE:STRING,STRING
-NONE:UINT,STRING,STRING
+NONE:POINTER,STRING,STRING
NONE:UINT,UINT,BOOL
NONE:STRING,STRING,STRING
NONE:STRING,BOOLEAN
diff --git a/src/gpm-point-obj.c b/src/gpm-point-obj.c
index f7ab137..b3bfa5c 100644
--- a/src/gpm-point-obj.c
+++ b/src/gpm-point-obj.c
@@ -24,10 +24,10 @@
#include "gpm-point-obj.h"
/**
- * dkp_point_obj_copy:
+ * gpm_point_obj_copy:
**/
GpmPointObj *
-dkp_point_obj_copy (const GpmPointObj *cobj)
+gpm_point_obj_copy (const GpmPointObj *cobj)
{
GpmPointObj *obj;
obj = g_new0 (GpmPointObj, 1);
@@ -38,10 +38,10 @@ dkp_point_obj_copy (const GpmPointObj *cobj)
}
/**
- * dkp_point_obj_new:
+ * gpm_point_obj_new:
**/
GpmPointObj *
-dkp_point_obj_new (void)
+gpm_point_obj_new (void)
{
GpmPointObj *obj;
obj = g_new0 (GpmPointObj, 1);
@@ -52,10 +52,10 @@ dkp_point_obj_new (void)
}
/**
- * dkp_point_obj_free:
+ * gpm_point_obj_free:
**/
void
-dkp_point_obj_free (GpmPointObj *obj)
+gpm_point_obj_free (GpmPointObj *obj)
{
if (obj == NULL)
return;
diff --git a/src/gpm-point-obj.h b/src/gpm-point-obj.h
index c87c106..a37e2a6 100644
--- a/src/gpm-point-obj.h
+++ b/src/gpm-point-obj.h
@@ -32,9 +32,9 @@ typedef struct
guint32 color;
} GpmPointObj;
-GpmPointObj *dkp_point_obj_new (void);
-GpmPointObj *dkp_point_obj_copy (const GpmPointObj *cobj);
-void dkp_point_obj_free (GpmPointObj *obj);
+GpmPointObj *gpm_point_obj_new (void);
+GpmPointObj *gpm_point_obj_copy (const GpmPointObj *cobj);
+void gpm_point_obj_free (GpmPointObj *obj);
G_END_DECLS
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index fece39d..25a9e85 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -30,11 +30,10 @@
#include <gtk/gtk.h>
#include <dbus/dbus-glib.h>
#include <gconf/gconf-client.h>
+#include <devkit-power-gobject/devicekit-power.h>
#include "egg-debug.h"
#include "egg-color.h"
-#include "egg-string.h"
-#include "egg-obj-list.h"
#include "egg-array-float.h"
#include "egg-unique.h"
@@ -42,11 +41,6 @@
#include "gpm-stock-icons.h"
#include "gpm-devicekit.h"
#include "gpm-graph-widget.h"
-#include "dkp-client.h"
-#include "dkp-history-obj.h"
-#include "dkp-stats-obj.h"
-#include "dkp-device.h"
-#include "dkp-wakeups.h"
static GladeXML *glade_xml = NULL;
static GtkListStore *list_store_info = NULL;
@@ -230,13 +224,13 @@ gpm_stats_add_info_data (const gchar *attr, const gchar *text)
/**
* gpm_stats_update_smooth_data:
**/
-static EggObjList *
-gpm_stats_update_smooth_data (EggObjList *list)
+static GPtrArray *
+gpm_stats_update_smooth_data (GPtrArray *list)
{
guint i;
GpmPointObj *point;
- GpmPointObj point_new;
- EggObjList *new;
+ GpmPointObj *point_new;
+ GPtrArray *new;
EggArrayFloat *raw;
EggArrayFloat *convolved;
EggArrayFloat *outliers;
@@ -246,7 +240,7 @@ gpm_stats_update_smooth_data (EggObjList *list)
raw = egg_array_float_new (list->len);
convolved = egg_array_float_new (list->len);
for (i=0; i<list->len; i++) {
- point = (GpmPointObj *) egg_obj_list_index (list, i);
+ point = (GpmPointObj *) g_ptr_array_index (list, i);
egg_array_float_set (raw, i, point->y);
}
@@ -258,15 +252,14 @@ gpm_stats_update_smooth_data (EggObjList *list)
convolved = egg_array_float_convolve (outliers, gaussian);
/* add the smoothed data back into a new array */
- new = egg_obj_list_new ();
- egg_obj_list_set_copy (new, (EggObjListCopyFunc) dkp_point_obj_copy);
- egg_obj_list_set_free (new, (EggObjListFreeFunc) dkp_point_obj_free);
+ new = g_ptr_array_new ();
for (i=0; i<list->len; i++) {
- point = (GpmPointObj *) egg_obj_list_index (list, i);
- point_new.color = point->color;
- point_new.x = point->x;
- point_new.y = egg_array_float_get (convolved, i);
- egg_obj_list_add (new, &point_new);
+ point = (GpmPointObj *) g_ptr_array_index (list, i);
+ point_new = g_new0 (GpmPointObj, 1);
+ point_new->color = point->color;
+ point_new->x = point->x;
+ point_new->y = egg_array_float_get (convolved, i);
+ g_ptr_array_add (new, point_new);
}
/* free data */
@@ -313,118 +306,165 @@ gpm_stats_bool_to_text (gboolean ret)
* gpm_stats_update_info_page_details:
**/
static void
-gpm_stats_update_info_page_details (const DkpDevice *device)
+gpm_stats_update_info_page_details (DkpDevice *device)
{
- const DkpObject *obj;
struct tm *time_tm;
time_t t;
gchar time_buf[256];
gchar *text;
guint refreshed;
+ DkpDeviceType type;
+ DkpDeviceState state;
+ DkpDeviceTechnology technology;
+ gdouble percentage;
+ gdouble capacity;
+ gdouble energy;
+ gdouble energy_empty;
+ gdouble energy_full;
+ gdouble energy_full_design;
+ gdouble energy_rate;
+ gdouble voltage;
+ gboolean online;
+ gboolean is_present;
+ gboolean power_supply;
+ gboolean is_rechargeable;
+ guint64 update_time;
+ gint64 time_to_full;
+ gint64 time_to_empty;
+ gchar *vendor = NULL;
+ gchar *serial = NULL;
+ gchar *model = NULL;
gtk_list_store_clear (list_store_info);
- obj = dkp_device_get_object (device);
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ "state", &state,
+ "percentage", &percentage,
+ "online", &online,
+ "update_time", &update_time,
+ "power_supply", &power_supply,
+ "is_rechargeable", &is_rechargeable,
+ "is-present", &is_present,
+ "time-to-full", &time_to_full,
+ "time-to-empty", &time_to_empty,
+ "technology", &technology,
+ "capacity", &capacity,
+ "energy", &energy,
+ "energy-empty", &energy_empty,
+ "energy-full", &energy_full,
+ "energy-full-design", &energy_full_design,
+ "energy-rate", &energy_rate,
+ "voltage", &voltage,
+ "vendor", &vendor,
+ "serial", &serial,
+ "model", &model,
+ NULL);
/* get a human readable time */
- t = (time_t) obj->update_time;
+ t = (time_t) update_time;
time_tm = localtime (&t);
strftime (time_buf, sizeof time_buf, "%c", time_tm);
gpm_stats_add_info_data (_("Device"), dkp_device_get_object_path (device));
- gpm_stats_add_info_data (_("Type"), gpm_device_type_to_localised_text (obj->type, 1));
- if (!egg_strzero (obj->vendor))
- gpm_stats_add_info_data (_("Vendor"), obj->vendor);
- if (!egg_strzero (obj->model))
- gpm_stats_add_info_data (_("Model"), obj->model);
- if (!egg_strzero (obj->serial))
- gpm_stats_add_info_data (_("Serial number"), obj->serial);
- gpm_stats_add_info_data (_("Supply"), gpm_stats_bool_to_text (obj->power_supply));
-
- refreshed = (int) (time (NULL) - obj->update_time);
+ gpm_stats_add_info_data (_("Type"), gpm_device_type_to_localised_text (type, 1));
+ if (vendor != NULL && vendor[0] != '\0')
+ gpm_stats_add_info_data (_("Vendor"), vendor);
+ if (model != NULL && model[0] != '\0')
+ gpm_stats_add_info_data (_("Model"), model);
+ if (serial != NULL && serial[0] != '\0')
+ gpm_stats_add_info_data (_("Serial number"), serial);
+ gpm_stats_add_info_data (_("Supply"), gpm_stats_bool_to_text (power_supply));
+
+ refreshed = (int) (time (NULL) - update_time);
text = g_strdup_printf (ngettext ("%d second", "%d seconds", refreshed), refreshed);
gpm_stats_add_info_data (_("Refreshed"), text);
g_free (text);
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD ||
- obj->type == DKP_DEVICE_TYPE_UPS)
- gpm_stats_add_info_data (_("Present"), gpm_stats_bool_to_text (obj->is_present));
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD)
- gpm_stats_add_info_data (_("Rechargeable"), gpm_stats_bool_to_text (obj->is_rechargeable));
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD)
- gpm_stats_add_info_data (_("State"), dkp_device_state_to_text (obj->state));
- if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
- text = g_strdup_printf ("%.1f Wh", obj->energy);
+ if (type == DKP_DEVICE_TYPE_BATTERY ||
+ type == DKP_DEVICE_TYPE_MOUSE ||
+ type == DKP_DEVICE_TYPE_KEYBOARD ||
+ type == DKP_DEVICE_TYPE_UPS)
+ gpm_stats_add_info_data (_("Present"), gpm_stats_bool_to_text (is_present));
+ if (type == DKP_DEVICE_TYPE_BATTERY ||
+ type == DKP_DEVICE_TYPE_MOUSE ||
+ type == DKP_DEVICE_TYPE_KEYBOARD)
+ gpm_stats_add_info_data (_("Rechargeable"), gpm_stats_bool_to_text (is_rechargeable));
+ if (type == DKP_DEVICE_TYPE_BATTERY ||
+ type == DKP_DEVICE_TYPE_MOUSE ||
+ type == DKP_DEVICE_TYPE_KEYBOARD)
+ gpm_stats_add_info_data (_("State"), dkp_device_state_to_text (state));
+ if (type == DKP_DEVICE_TYPE_BATTERY) {
+ text = g_strdup_printf ("%.1f Wh", energy);
gpm_stats_add_info_data (_("Energy"), text);
g_free (text);
- text = g_strdup_printf ("%.1f Wh", obj->energy_empty);
+ text = g_strdup_printf ("%.1f Wh", energy_empty);
gpm_stats_add_info_data (_("Energy when empty"), text);
g_free (text);
- text = g_strdup_printf ("%.1f Wh", obj->energy_full);
+ text = g_strdup_printf ("%.1f Wh", energy_full);
gpm_stats_add_info_data (_("Energy when full"), text);
g_free (text);
- text = g_strdup_printf ("%.1f Wh", obj->energy_full_design);
+ text = g_strdup_printf ("%.1f Wh", energy_full_design);
gpm_stats_add_info_data (_("Energy (design)"), text);
g_free (text);
}
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MONITOR) {
- text = g_strdup_printf ("%.1f W", obj->energy_rate);
+ if (type == DKP_DEVICE_TYPE_BATTERY ||
+ type == DKP_DEVICE_TYPE_MONITOR) {
+ text = g_strdup_printf ("%.1f W", energy_rate);
gpm_stats_add_info_data (_("Rate"), text);
g_free (text);
}
- if (obj->type == DKP_DEVICE_TYPE_UPS ||
- obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MONITOR) {
- text = g_strdup_printf ("%.1f V", obj->voltage);
+ if (type == DKP_DEVICE_TYPE_UPS ||
+ type == DKP_DEVICE_TYPE_BATTERY ||
+ type == DKP_DEVICE_TYPE_MONITOR) {
+ text = g_strdup_printf ("%.1f V", voltage);
gpm_stats_add_info_data (_("Voltage"), text);
g_free (text);
}
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_UPS) {
- if (obj->time_to_full >= 0) {
- text = gpm_stats_time_to_text (obj->time_to_full);
+ if (type == DKP_DEVICE_TYPE_BATTERY ||
+ type == DKP_DEVICE_TYPE_UPS) {
+ if (time_to_full >= 0) {
+ text = gpm_stats_time_to_text (time_to_full);
gpm_stats_add_info_data (_("Time to full"), text);
g_free (text);
}
- if (obj->time_to_empty >= 0) {
- text = gpm_stats_time_to_text (obj->time_to_empty);
+ if (time_to_empty >= 0) {
+ text = gpm_stats_time_to_text (time_to_empty);
gpm_stats_add_info_data (_("Time to empty"), text);
g_free (text);
}
}
- if (obj->type == DKP_DEVICE_TYPE_BATTERY ||
- obj->type == DKP_DEVICE_TYPE_MOUSE ||
- obj->type == DKP_DEVICE_TYPE_KEYBOARD ||
- obj->type == DKP_DEVICE_TYPE_UPS) {
- text = g_strdup_printf ("%.1f%%", obj->percentage);
+ if (type == DKP_DEVICE_TYPE_BATTERY ||
+ type == DKP_DEVICE_TYPE_MOUSE ||
+ type == DKP_DEVICE_TYPE_KEYBOARD ||
+ type == DKP_DEVICE_TYPE_UPS) {
+ text = g_strdup_printf ("%.1f%%", percentage);
gpm_stats_add_info_data (_("Percentage"), text);
g_free (text);
}
- if (obj->type == DKP_DEVICE_TYPE_BATTERY) {
- text = g_strdup_printf ("%.1f%%", obj->capacity);
+ if (type == DKP_DEVICE_TYPE_BATTERY) {
+ text = g_strdup_printf ("%.1f%%", capacity);
gpm_stats_add_info_data (_("Capacity"), text);
g_free (text);
}
- if (obj->type == DKP_DEVICE_TYPE_BATTERY)
- gpm_stats_add_info_data (_("Technology"), gpm_device_technology_to_localised_text (obj->technology));
- if (obj->type == DKP_DEVICE_TYPE_LINE_POWER)
- gpm_stats_add_info_data (_("Online"), gpm_stats_bool_to_text (obj->online));
+ if (type == DKP_DEVICE_TYPE_BATTERY)
+ gpm_stats_add_info_data (_("Technology"), gpm_device_technology_to_localised_text (technology));
+ if (type == DKP_DEVICE_TYPE_LINE_POWER)
+ gpm_stats_add_info_data (_("Online"), gpm_stats_bool_to_text (online));
+
+ g_free (vendor);
+ g_free (serial);
+ g_free (model);
}
/**
* gpm_stats_set_graph_data:
**/
static void
-gpm_stats_set_graph_data (GtkWidget *widget, EggObjList *data, gboolean use_smoothed, gboolean use_points)
+gpm_stats_set_graph_data (GtkWidget *widget, GPtrArray *data, gboolean use_smoothed, gboolean use_points)
{
- EggObjList *smoothed;
+ GPtrArray *smoothed;
gpm_graph_widget_data_clear (GPM_GRAPH_WIDGET (widget));
@@ -439,7 +479,8 @@ gpm_stats_set_graph_data (GtkWidget *widget, EggObjList *data, gboolean use_smoo
if (use_points)
gpm_graph_widget_data_assign (GPM_GRAPH_WIDGET (widget), GPM_GRAPH_WIDGET_PLOT_POINTS, data);
gpm_graph_widget_data_assign (GPM_GRAPH_WIDGET (widget), GPM_GRAPH_WIDGET_PLOT_LINE, smoothed);
- g_object_unref (smoothed);
+ g_ptr_array_foreach (smoothed, (GFunc) gpm_point_obj_free, NULL);
+ g_ptr_array_free (smoothed, TRUE);
}
/* show */
@@ -450,23 +491,20 @@ gpm_stats_set_graph_data (GtkWidget *widget, EggObjList *data, gboolean use_smoo
* gpm_stats_update_info_page_history:
**/
static void
-gpm_stats_update_info_page_history (const DkpDevice *device)
+gpm_stats_update_info_page_history (DkpDevice *device)
{
- EggObjList *array;
+ GPtrArray *array;
guint i;
DkpHistoryObj *hobj;
GtkWidget *widget;
gboolean checked;
gboolean points;
GpmPointObj *point;
- EggObjList *new;
+ GPtrArray *new;
gint32 offset = 0;
GTimeVal timeval;
- new = egg_obj_list_new ();
- egg_obj_list_set_copy (new, (EggObjListCopyFunc) dkp_point_obj_copy);
- egg_obj_list_set_free (new, (EggObjListFreeFunc) dkp_point_obj_free);
-
+ new = g_ptr_array_new ();
widget = glade_xml_get_widget (glade_xml, "custom_graph_history");
gpm_graph_widget_set_type_x (GPM_GRAPH_WIDGET (widget), GPM_GRAPH_WIDGET_TYPE_TIME);
if (strcmp (history_type, GPM_HISTORY_CHARGE_VALUE) == 0)
@@ -476,7 +514,7 @@ gpm_stats_update_info_page_history (const DkpDevice *device)
else
gpm_graph_widget_set_type_y (GPM_GRAPH_WIDGET (widget), GPM_GRAPH_WIDGET_TYPE_TIME);
- array = dkp_device_get_history (device, history_type, history_time, 150);
+ array = dkp_device_get_history (device, history_type, history_time, 150, NULL);
if (array == NULL) {
gtk_widget_hide (widget);
goto out;
@@ -487,13 +525,13 @@ gpm_stats_update_info_page_history (const DkpDevice *device)
offset = timeval.tv_sec;
for (i=0; i<array->len; i++) {
- hobj = (DkpHistoryObj *) egg_obj_list_index (array, i);
+ hobj = (DkpHistoryObj *) g_ptr_array_index (array, i);
/* abandon this point */
if (hobj->state == DKP_DEVICE_STATE_UNKNOWN)
continue;
- point = dkp_point_obj_new ();
+ point = gpm_point_obj_new ();
point->x = (gint32) hobj->time - offset;
point->y = hobj->value;
if (hobj->state == DKP_DEVICE_STATE_CHARGING)
@@ -506,8 +544,7 @@ gpm_stats_update_info_page_history (const DkpDevice *device)
else
point->color = egg_color_from_rgb (0, 255, 0);
}
- egg_obj_list_add (new, point);
- dkp_point_obj_free (point);
+ g_ptr_array_add (new, point);
}
/* render */
@@ -521,8 +558,10 @@ gpm_stats_update_info_page_history (const DkpDevice *device)
widget = glade_xml_get_widget (glade_xml, "custom_graph_history");
gpm_stats_set_graph_data (widget, new, checked, points);
- g_object_unref (array);
- g_object_unref (new);
+ g_ptr_array_foreach (array, (GFunc) dkp_history_obj_free, NULL);
+ g_ptr_array_free (array, TRUE);
+ g_ptr_array_foreach (new, (GFunc) gpm_point_obj_free, NULL);
+ g_ptr_array_free (new, TRUE);
out:
return;
}
@@ -531,23 +570,20 @@ out:
* gpm_stats_update_info_page_stats:
**/
static void
-gpm_stats_update_info_page_stats (const DkpDevice *device)
+gpm_stats_update_info_page_stats (DkpDevice *device)
{
- EggObjList *array;
+ GPtrArray *array;
guint i;
DkpStatsObj *sobj;
GtkWidget *widget;
gboolean checked;
gboolean points;
GpmPointObj *point;
- EggObjList *new;
+ GPtrArray *new;
gboolean use_data = FALSE;
const gchar *type = NULL;
- new = egg_obj_list_new ();
- egg_obj_list_set_copy (new, (EggObjListCopyFunc) dkp_point_obj_copy);
- egg_obj_list_set_free (new, (EggObjListFreeFunc) dkp_point_obj_free);
-
+ new = g_ptr_array_new ();
widget = glade_xml_get_widget (glade_xml, "custom_graph_stats");
if (strcmp (stats_type, GPM_STATS_CHARGE_DATA_VALUE) == 0) {
type = "charging";
@@ -571,23 +607,22 @@ gpm_stats_update_info_page_stats (const DkpDevice *device)
else
gpm_graph_widget_set_type_y (GPM_GRAPH_WIDGET (widget), GPM_GRAPH_WIDGET_TYPE_PERCENTAGE);
- array = dkp_device_get_statistics (device, type);
+ array = dkp_device_get_statistics (device, type, NULL);
if (array == NULL) {
gtk_widget_hide (widget);
goto out;
}
for (i=0; i<array->len; i++) {
- sobj = (DkpStatsObj *) egg_obj_list_index (array, i);
- point = dkp_point_obj_new ();
+ sobj = (DkpStatsObj *) g_ptr_array_index (array, i);
+ point = gpm_point_obj_new ();
point->x = i;
if (use_data)
point->y = sobj->value;
else
point->y = sobj->accuracy;
point->color = egg_color_from_rgb (255, 0, 0);
- egg_obj_list_add (new, point);
- dkp_point_obj_free (point);
+ g_ptr_array_add (new, point);
}
/* render */
@@ -601,8 +636,10 @@ gpm_stats_update_info_page_stats (const DkpDevice *device)
widget = glade_xml_get_widget (glade_xml, "custom_graph_stats");
gpm_stats_set_graph_data (widget, new, checked, points);
- g_object_unref (array);
- g_object_unref (new);
+ g_ptr_array_foreach (array, (GFunc) dkp_stats_obj_free, NULL);
+ g_ptr_array_free (array, TRUE);
+ g_ptr_array_foreach (new, (GFunc) gpm_point_obj_free, NULL);
+ g_ptr_array_free (new, TRUE);
out:
return;
}
@@ -611,7 +648,7 @@ out:
* gpm_stats_update_info_data_page:
**/
static void
-gpm_stats_update_info_data_page (const DkpDevice *device, gint page)
+gpm_stats_update_info_data_page (DkpDevice *device, gint page)
{
if (page == 0)
gpm_stats_update_info_page_details (device);
@@ -625,15 +662,22 @@ gpm_stats_update_info_data_page (const DkpDevice *device, gint page)
* gpm_stats_update_info_data:
**/
static void
-gpm_stats_update_info_data (const DkpDevice *device)
+gpm_stats_update_info_data (DkpDevice *device)
{
gint page;
GtkWidget *widget;
GtkWidget *page_widget;
- const DkpObject *obj;
+ gboolean has_history;
+ gboolean has_statistics;
+
+ /* get properties */
+ g_object_get (device,
+ "has-history", &has_history,
+ "has-statistics", &has_statistics,
+ NULL);
+
widget = glade_xml_get_widget (glade_xml, "notebook1");
- obj = dkp_device_get_object (device);
/* show info page */
page_widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK(widget), 0);
@@ -641,14 +685,14 @@ gpm_stats_update_info_data (const DkpDevice *device)
/* hide history if no support */
page_widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK(widget), 1);
- if (obj->has_history)
+ if (has_history)
gtk_widget_show (page_widget);
else
gtk_widget_hide (page_widget);
/* hide statistics if no support */
page_widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK(widget), 2);
- if (obj->has_statistics)
+ if (has_statistics)
gtk_widget_show (page_widget);
else
gtk_widget_hide (page_widget);
@@ -950,11 +994,11 @@ gpm_stats_notebook_changed_cb (GtkNotebook *notebook, GtkNotebookPage *page, gin
if (current_device == NULL)
return;
- if (egg_strequal (current_device, "wakeups"))
+ if (g_strcmp0 (current_device, "wakeups") == 0)
return;
device = dkp_device_new ();
- dkp_device_set_object_path (device, current_device);
+ dkp_device_set_object_path (device, current_device, NULL);
gpm_stats_update_info_data_page (device, page_num);
gpm_stats_update_info_data (device);
g_object_unref (device);
@@ -968,7 +1012,7 @@ gpm_stats_button_update_ui (void)
{
DkpDevice *device;
device = dkp_device_new ();
- dkp_device_set_object_path (device, current_device);
+ dkp_device_set_object_path (device, current_device, NULL);
gpm_stats_update_info_data (device);
g_object_unref (device);
}
@@ -995,11 +1039,11 @@ gpm_stats_devices_treeview_clicked_cb (GtkTreeSelection *selection, gboolean dat
egg_debug ("selected row is: %s", current_device);
/* is special device */
- if (egg_strequal (current_device, "wakeups")) {
+ if (g_strcmp0 (current_device, "wakeups") == 0) {
gpm_stats_update_wakeups_data ();
} else {
device = dkp_device_new ();
- dkp_device_set_object_path (device, current_device);
+ dkp_device_set_object_path (device, current_device, NULL);
gpm_stats_update_info_data (device);
g_object_unref (device);
}
@@ -1040,18 +1084,22 @@ gpm_stats_window_activated_cb (EggUnique *egg_unique, gpointer data)
* gpm_stats_add_device:
**/
static void
-gpm_stats_add_device (const DkpDevice *device)
+gpm_stats_add_device (DkpDevice *device)
{
const gchar *id;
GtkTreeIter iter;
- const DkpObject *obj;
const gchar *text;
const gchar *icon;
+ DkpDeviceType type;
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type,
+ NULL);
- obj = dkp_device_get_object (device);
id = dkp_device_get_object_path (device);
- text = gpm_device_type_to_localised_text (obj->type, 1);
- icon = gpm_devicekit_get_object_icon (obj);
+ text = gpm_device_type_to_localised_text (type, 1);
+ icon = gpm_devicekit_get_object_icon (device);
gtk_list_store_append (list_store_devices, &iter);
gtk_list_store_set (list_store_devices, &iter,
@@ -1066,7 +1114,7 @@ gpm_stats_add_device (const DkpDevice *device)
static void
gpm_stats_data_changed_cb (DkpClient *client, gpointer user_data)
{
- if (egg_strequal (current_device, "wakeups"))
+ if (g_strcmp0 (current_device, "wakeups") == 0)
gpm_stats_update_wakeups_data ();
}
@@ -1074,7 +1122,7 @@ gpm_stats_data_changed_cb (DkpClient *client, gpointer user_data)
* gpm_stats_device_added_cb:
**/
static void
-gpm_stats_device_added_cb (DkpClient *client, const DkpDevice *device, gpointer user_data)
+gpm_stats_device_added_cb (DkpClient *client, DkpDevice *device, gpointer user_data)
{
const gchar *object_path;
object_path = dkp_device_get_object_path (device);
@@ -1086,7 +1134,7 @@ gpm_stats_device_added_cb (DkpClient *client, const DkpDevice *device, gpointer
* gpm_stats_device_changed_cb:
**/
static void
-gpm_stats_device_changed_cb (DkpClient *client, const DkpDevice *device, gpointer user_data)
+gpm_stats_device_changed_cb (DkpClient *client, DkpDevice *device, gpointer user_data)
{
const gchar *object_path;
object_path = dkp_device_get_object_path (device);
@@ -1101,7 +1149,7 @@ gpm_stats_device_changed_cb (DkpClient *client, const DkpDevice *device, gpointe
* gpm_stats_device_removed_cb:
**/
static void
-gpm_stats_device_removed_cb (DkpClient *client, const DkpDevice *device, gpointer user_data)
+gpm_stats_device_removed_cb (DkpClient *client, DkpDevice *device, gpointer user_data)
{
const gchar *object_path;
GtkTreeIter iter;
@@ -1534,7 +1582,7 @@ main (int argc, char *argv[])
g_signal_connect (wakeups, "data-changed", G_CALLBACK (gpm_stats_data_changed_cb), NULL);
/* coldplug */
- devices = dkp_client_enumerate_devices (client);
+ devices = dkp_client_enumerate_devices (client, NULL);
if (devices == NULL)
goto out;
for (i=0; i < devices->len; i++) {
diff --git a/src/gpm-tray-icon.c b/src/gpm-tray-icon.c
index dd2b971..de8e81b 100644
--- a/src/gpm-tray-icon.c
+++ b/src/gpm-tray-icon.c
@@ -39,7 +39,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <gconf/gconf-client.h>
-#include <dkp-device.h>
+#include <devkit-power-gobject/devicekit-power.h>
#include "egg-debug.h"
@@ -177,7 +177,6 @@ gpm_tray_icon_show_info_cb (GtkMenuItem *item, gpointer data)
gchar *description = NULL;
GtkWidget *dialog;
GtkWidget *image;
- const DkpObject *obj;
const gchar *object_path;
DkpDevice *device = NULL;
gboolean ret;
@@ -196,12 +195,11 @@ gpm_tray_icon_show_info_cb (GtkMenuItem *item, gpointer data)
}
device = dkp_device_new ();
- ret = dkp_device_set_object_path (device, object_path);
+ ret = dkp_device_set_object_path (device, object_path, NULL);
if (!ret)
goto out;
- obj = dkp_device_get_object (device);
- icon_name = gpm_devicekit_get_object_icon (obj);
- description = gpm_devicekit_get_object_description (obj);
+ icon_name = gpm_devicekit_get_object_icon (device);
+ description = gpm_devicekit_get_object_description (device);
image = gtk_image_new ();
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -466,15 +464,22 @@ gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *arr
GtkWidget *item;
GtkWidget *image;
const gchar *object_path;
- const DkpObject *obj;
const gchar *desc;
- const DkpDevice *device;
+ DkpDevice *device;
+ DkpDeviceType type_tmp;
+ gdouble percentage;
/* find type */
for (i=0;i<array->len;i++) {
device = g_ptr_array_index (array, i);
- obj = dkp_device_get_object (device);
- if (obj->type != type)
+
+ /* get device properties */
+ g_object_get (device,
+ "type", &type_tmp,
+ "percentage", &percentage,
+ NULL);
+
+ if (type != type_tmp)
continue;
object_path = dkp_device_get_object_path (device);
@@ -483,11 +488,11 @@ gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *arr
/* generate the label */
desc = gpm_device_type_to_localised_text (type, 1);
- label = g_strdup_printf ("%s (%.1f%%)", desc, obj->percentage);
+ label = g_strdup_printf ("%s (%.1f%%)", desc, percentage);
item = gtk_image_menu_item_new_with_label (label);
/* generate the image */
- icon_name = gpm_devicekit_get_object_icon (obj);
+ icon_name = gpm_devicekit_get_object_icon (device);
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]