diff options
-rw-r--r-- | configure.ac | 38 | ||||
-rw-r--r-- | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/dkp-backend.h | 74 | ||||
-rw-r--r-- | src/dkp-daemon.c | 1003 | ||||
-rw-r--r-- | src/dkp-daemon.h | 9 | ||||
-rw-r--r-- | src/dkp-device-list.c | 47 | ||||
-rw-r--r-- | src/dkp-device-list.h | 10 | ||||
-rw-r--r-- | src/dkp-device.c | 63 | ||||
-rw-r--r-- | src/dkp-device.h | 8 | ||||
-rw-r--r-- | src/dkp-main.c | 88 | ||||
-rw-r--r-- | src/dkp-marshal.list | 3 | ||||
-rw-r--r-- | src/dkp-native.h | 33 | ||||
-rw-r--r-- | src/dummy/.gitignore | 5 | ||||
-rw-r--r-- | src/dummy/Makefile.am | 23 | ||||
-rw-r--r-- | src/dummy/dkp-backend.c | 221 | ||||
-rw-r--r-- | src/dummy/dkp-native.c | 40 | ||||
-rw-r--r-- | src/linux/.gitignore | 5 | ||||
-rw-r--r-- | src/linux/Makefile.am | 37 | ||||
-rw-r--r-- | src/linux/dkp-backend.c | 408 | ||||
-rw-r--r-- | src/linux/dkp-device-csr.c (renamed from src/dkp-device-csr.c) | 2 | ||||
-rw-r--r-- | src/linux/dkp-device-csr.h (renamed from src/dkp-device-csr.h) | 0 | ||||
-rw-r--r-- | src/linux/dkp-device-hid.c (renamed from src/dkp-device-hid.c) | 2 | ||||
-rw-r--r-- | src/linux/dkp-device-hid.h (renamed from src/dkp-device-hid.h) | 0 | ||||
-rw-r--r-- | src/linux/dkp-device-supply.c (renamed from src/dkp-device-supply.c) | 8 | ||||
-rw-r--r-- | src/linux/dkp-device-supply.h (renamed from src/dkp-device-supply.h) | 0 | ||||
-rw-r--r-- | src/linux/dkp-device-wup.c (renamed from src/dkp-device-wup.c) | 2 | ||||
-rw-r--r-- | src/linux/dkp-device-wup.h (renamed from src/dkp-device-wup.h) | 0 | ||||
-rw-r--r-- | src/linux/dkp-input.c (renamed from src/dkp-input.c) | 0 | ||||
-rw-r--r-- | src/linux/dkp-input.h (renamed from src/dkp-input.h) | 0 | ||||
-rw-r--r-- | src/linux/sysfs-utils.c (renamed from src/sysfs-utils.c) | 0 | ||||
-rw-r--r-- | src/linux/sysfs-utils.h (renamed from src/sysfs-utils.h) | 0 |
31 files changed, 1455 insertions, 682 deletions
diff --git a/configure.ac b/configure.ac index 463b4b5..5189ecf 100644 --- a/configure.ac +++ b/configure.ac @@ -117,6 +117,7 @@ if test "x$GCC" = "xyes"; then *) CFLAGS="$CFLAGS -Wno-strict-aliasing" ;; esac + if test "x$enable_ansi" = "xyes"; then case " $CFLAGS " in *[\ \ ]-ansi[\ \ ]*) ;; @@ -141,10 +142,6 @@ if test "x$GCC" = "xyes"; then changequote([,])dnl fi -PKG_CHECK_MODULES(GUDEV, [gudev-1.0 >= 001]) -AC_SUBST(GUDEV_CFLAGS) -AC_SUBST(GUDEV_LIBS) - PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.6.0]) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) @@ -165,9 +162,33 @@ PKG_CHECK_MODULES(GIO, [gio-2.0 >= 2.16.1]) AC_SUBST(GIO_CFLAGS) AC_SUBST(GIO_LIBS) -dnl Check libusb -AC_CHECK_HEADERS(usb.h, , [AC_MSG_ERROR([Can't find usb.h. Please install libusb.])]) -AC_CHECK_LIB([usb], [usb_find_devices], [], [AC_MSG_ERROR([Can't use libusb.])]) +dnl --------------------------------------------------------------------------- +dnl - Compile time default choice of backend +dnl --------------------------------------------------------------------------- +AC_ARG_WITH([backend], + AS_HELP_STRING([--with-backend=<option>], + [Default backend to use linux, dummy (dummy)])) +# default to a sane option +if test x$with_backend = x; then + if test -e /usr/include/libudev.h ; then + with_backend=linux + else + with_backend=dummy + fi +fi +AC_DEFINE_UNQUOTED(BACKEND, "$with_backend", [backend]) +AC_SUBST(BACKEND, "$with_backend") + +# only need GUdev on linux +if test x$with_backend = xlinux; then + PKG_CHECK_MODULES(GUDEV, [gudev-1.0 >= 001]) + AC_SUBST(GUDEV_CFLAGS) + AC_SUBST(GUDEV_LIBS) + + dnl Check libusb also + AC_CHECK_HEADERS(usb.h, , [AC_MSG_ERROR([Can't find usb.h. Please install libusb.])]) + AC_CHECK_LIB([usb], [usb_find_devices], [], [AC_MSG_ERROR([Can't use libusb.])]) +fi if test "x$GCC" = "xyes"; then LDFLAGS="-Wl,--as-needed $LDFLAGS" @@ -183,6 +204,8 @@ AC_OUTPUT([ Makefile devkit-power-gobject.pc src/Makefile +src/dummy/Makefile +src/linux/Makefile tools/Makefile doc/Makefile doc/version.xml @@ -215,6 +238,7 @@ echo " cppflags: ${CPPFLAGS} xsltproc: ${XSLTPROC} + Backend: ${with_backend} Maintainer mode: ${USE_MAINTAINER_MODE} Building api docs: ${enable_gtk_doc} Building man pages: ${enable_man_pages} diff --git a/src/Makefile.am b/src/Makefile.am index 5e1c754..71e7d0f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,6 +19,7 @@ INCLUDES = \ -DEGG_CONSOLE="\"DKP_CONSOLE\"" \ -I$(top_srcdir)/devkit-power-gobject \ -I$(top_srcdir) \ + -I$(top_srcdir)/src/dummy -I$(top_builddir)/src/dummy \ $(GIO_CFLAGS) \ $(DBUS_GLIB_CFLAGS) \ $(GUDEV_CFLAGS) \ @@ -69,15 +70,9 @@ devkit_power_daemon_SOURCES = \ dkp-daemon.h dkp-daemon.c \ dkp-device.h dkp-device.c \ dkp-device-list.h dkp-device-list.c \ - dkp-device-supply.h dkp-device-supply.c \ - dkp-device-csr.h dkp-device-csr.c \ - dkp-device-wup.h dkp-device-wup.c \ - dkp-device-hid.h dkp-device-hid.c \ - dkp-input.h dkp-input.c \ dkp-qos.h dkp-qos.c \ dkp-wakeups.h dkp-wakeups.c \ dkp-history.h dkp-history.c \ - sysfs-utils.h sysfs-utils.c \ dkp-main.c \ $(BUILT_SOURCES) @@ -89,6 +84,7 @@ devkit_power_daemon_CPPFLAGS = \ devkit_power_daemon_LDADD = \ -lm \ + dummy/libdkpshared.a \ $(USB_LIBS) \ $(GIO_LIBS) \ $(DBUS_GLIB_LIBS) \ diff --git a/src/dkp-backend.h b/src/dkp-backend.h new file mode 100644 index 0000000..20d2e88 --- /dev/null +++ b/src/dkp-backend.h @@ -0,0 +1,74 @@ +/* -*- 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_BACKEND_H +#define __DKP_BACKEND_H + +#include <glib-object.h> +#include <dkp-enum.h> + +#include "dkp-device.h" +#include "dkp-daemon.h" + +G_BEGIN_DECLS + +#define DKP_TYPE_BACKEND (dkp_backend_get_type ()) +#define DKP_BACKEND(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DKP_TYPE_BACKEND, DkpBackend)) +#define DKP_BACKEND_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DKP_TYPE_BACKEND, DkpBackendClass)) +#define DKP_IS_BACKEND(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DKP_TYPE_BACKEND)) +#define DKP_IS_BACKEND_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DKP_TYPE_BACKEND)) +#define DKP_BACKEND_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DKP_TYPE_BACKEND, DkpBackendClass)) +#define DKP_BACKEND_ERROR (dkp_backend_error_quark ()) +#define DKP_BACKEND_TYPE_ERROR (dkp_backend_error_get_type ()) + +typedef struct DkpBackendPrivate DkpBackendPrivate; + +typedef struct +{ + GObject parent; + DkpBackendPrivate *priv; +} DkpBackend; + +typedef struct +{ + GObjectClass parent_class; + void (* device_added) (DkpBackend *backend, + GObject *native, + DkpDevice *device, + gboolean emit_signal); + void (* device_changed) (DkpBackend *backend, + GObject *native, + DkpDevice *device, + gboolean emit_signal); + void (* device_removed) (DkpBackend *backend, + GObject *native, + DkpDevice *device); +} DkpBackendClass; + +GType dkp_backend_get_type (void); +DkpBackend *dkp_backend_new (void); +gboolean dkp_backend_coldplug (DkpBackend *backend, + DkpDaemon *daemon); + +G_END_DECLS + +#endif /* __DKP_BACKEND_H */ + diff --git a/src/dkp-daemon.c b/src/dkp-daemon.c index db84c23..b3c400c 100644 --- a/src/dkp-daemon.c +++ b/src/dkp-daemon.c @@ -31,19 +31,14 @@ #include <glib-object.h> #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> -#include <gudev/gudev.h> #include "egg-debug.h" #include "dkp-polkit.h" -#include "dkp-daemon.h" -#include "dkp-device.h" -#include "dkp-device-supply.h" -#include "dkp-device-csr.h" -#include "dkp-device-wup.h" -#include "dkp-device-hid.h" -#include "dkp-input.h" #include "dkp-device-list.h" +#include "dkp-device.h" +#include "dkp-backend.h" +#include "dkp-daemon.h" #include "dkp-daemon-glue.h" #include "dkp-marshal.h" @@ -70,8 +65,6 @@ enum LAST_SIGNAL, }; -static const gchar *subsystems[] = {"power_supply", "usb", "tty", "input", NULL}; - static guint signals[LAST_SIGNAL] = { 0 }; struct DkpDaemonPrivate @@ -79,11 +72,10 @@ struct DkpDaemonPrivate DBusGConnection *connection; DBusGProxy *proxy; DkpPolkit *polkit; + DkpBackend *backend; DkpDeviceList *power_devices; - DkpDeviceList *managed_devices; gboolean on_battery; gboolean low_battery; - GUdevClient *gudev_client; gboolean lid_is_closed; gboolean lid_is_present; gboolean kernel_can_suspend; @@ -108,9 +100,6 @@ G_DEFINE_TYPE (DkpDaemon, dkp_daemon, G_TYPE_OBJECT) /* refresh all the devices after this much time when on-battery has changed */ #define DKP_DAEMON_ON_BATTERY_REFRESH_DEVICES_DELAY 3 /* seconds */ -static gboolean dkp_daemon_device_add (DkpDaemon *daemon, GUdevDevice *d, gboolean emit_event); -static void dkp_daemon_device_remove (DkpDaemon *daemon, GUdevDevice *d); - /** * dkp_daemon_set_lid_is_closed: **/ @@ -144,213 +133,6 @@ out: } /** - * dkp_daemon_error_quark: - **/ -GQuark -dkp_daemon_error_quark (void) -{ - static GQuark ret = 0; - if (ret == 0) - ret = g_quark_from_static_string ("dkp_daemon_error"); - return ret; -} - -#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } -/** - * dkp_daemon_error_get_type: - **/ -GType -dkp_daemon_error_get_type (void) -{ - static GType etype = 0; - - if (etype == 0) - { - static const GEnumValue values[] = - { - ENUM_ENTRY (DKP_DAEMON_ERROR_GENERAL, "GeneralError"), - ENUM_ENTRY (DKP_DAEMON_ERROR_NOT_SUPPORTED, "NotSupported"), - ENUM_ENTRY (DKP_DAEMON_ERROR_NO_SUCH_DEVICE, "NoSuchDevice"), - { 0, 0, 0 } - }; - g_assert (DKP_DAEMON_NUM_ERRORS == G_N_ELEMENTS (values) - 1); - etype = g_enum_register_static ("DkpDaemonError", values); - } - return etype; -} - -/** - * dkp_daemon_constructor: - **/ -static GObject * -dkp_daemon_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) -{ - DkpDaemon *daemon; - DkpDaemonClass *klass; - - klass = DKP_DAEMON_CLASS (g_type_class_peek (DKP_TYPE_DAEMON)); - daemon = DKP_DAEMON (G_OBJECT_CLASS (dkp_daemon_parent_class)->constructor (type, n_construct_properties, construct_properties)); - return G_OBJECT (daemon); -} - -/** - * dkp_daemon_get_property: - **/ -static void -dkp_daemon_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - DkpDaemon *daemon; - - daemon = DKP_DAEMON (object); - - switch (prop_id) { - - case PROP_DAEMON_VERSION: - g_value_set_string (value, PACKAGE_VERSION); - break; - - case PROP_CAN_SUSPEND: - g_value_set_boolean (value, daemon->priv->kernel_can_suspend); - break; - - case PROP_CAN_HIBERNATE: - g_value_set_boolean (value, (daemon->priv->kernel_can_hibernate && daemon->priv->kernel_has_swap_space)); - break; - - case PROP_ON_BATTERY: - g_value_set_boolean (value, daemon->priv->on_battery); - break; - - case PROP_ON_LOW_BATTERY: - g_value_set_boolean (value, daemon->priv->on_battery && daemon->priv->low_battery); - break; - - case PROP_LID_IS_CLOSED: - g_value_set_boolean (value, daemon->priv->lid_is_closed); - break; - - case PROP_LID_IS_PRESENT: - g_value_set_boolean (value, daemon->priv->lid_is_present); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/** - * dkp_daemon_class_init: - **/ -static void -dkp_daemon_class_init (DkpDaemonClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->constructor = dkp_daemon_constructor; - object_class->finalize = dkp_daemon_finalize; - object_class->get_property = dkp_daemon_get_property; - - g_type_class_add_private (klass, sizeof (DkpDaemonPrivate)); - - signals[DEVICE_ADDED_SIGNAL] = - g_signal_new ("device-added", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - - signals[DEVICE_REMOVED_SIGNAL] = - g_signal_new ("device-removed", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - - signals[DEVICE_CHANGED_SIGNAL] = - g_signal_new ("device-changed", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - - signals[CHANGED_SIGNAL] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 0); - - - g_object_class_install_property (object_class, - PROP_DAEMON_VERSION, - g_param_spec_string ("daemon-version", - "Daemon Version", - "The version of the running daemon", - NULL, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, - PROP_LID_IS_PRESENT, - g_param_spec_boolean ("lid-is-present", - "Is a laptop", - "If this computer is probably a laptop", - FALSE, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, - PROP_CAN_SUSPEND, - g_param_spec_boolean ("can-suspend", - "Can Suspend", - "Whether the system can suspend", - FALSE, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, - PROP_CAN_HIBERNATE, - g_param_spec_boolean ("can-hibernate", - "Can Hibernate", - "Whether the system can hibernate", - FALSE, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, - PROP_ON_BATTERY, - g_param_spec_boolean ("on-battery", - "On Battery", - "Whether the system is running on battery", - FALSE, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, - PROP_ON_LOW_BATTERY, - g_param_spec_boolean ("on-low-battery", - "On Low Battery", - "Whether the system is running on battery and if the battery is critically low", - FALSE, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, - PROP_LID_IS_CLOSED, - g_param_spec_boolean ("lid-is-closed", - "Laptop lid is closed", - "If the laptop lid is closed", - FALSE, - G_PARAM_READABLE)); - - dbus_g_object_type_install_info (DKP_TYPE_DAEMON, &dbus_glib_dkp_daemon_object_info); - - dbus_g_error_domain_register (DKP_DAEMON_ERROR, NULL, DKP_DAEMON_TYPE_ERROR); -} - -/** * dkp_daemon_check_state: **/ static gboolean @@ -428,65 +210,6 @@ out: } /** - * dkp_daemon_init: - **/ -static void -dkp_daemon_init (DkpDaemon *daemon) -{ - gfloat waterline; - - daemon->priv = DKP_DAEMON_GET_PRIVATE (daemon); - daemon->priv->polkit = dkp_polkit_new (); - daemon->priv->lid_is_present = FALSE; - daemon->priv->lid_is_closed = FALSE; - daemon->priv->kernel_can_suspend = FALSE; - daemon->priv->kernel_can_hibernate = FALSE; - daemon->priv->kernel_has_swap_space = FALSE; - - /* check if we have support */ - dkp_daemon_check_state (daemon); - - /* do we have enough swap? */ - if (daemon->priv->kernel_can_hibernate) { - waterline = dkp_daemon_check_swap (daemon); - if (waterline < DKP_DAEMON_SWAP_WATERLINE) - daemon->priv->kernel_has_swap_space = TRUE; - else - egg_debug ("not enough swap to enable hibernate"); - } -} - -/** - * dkp_daemon_finalize: - **/ -static void -dkp_daemon_finalize (GObject *object) -{ - DkpDaemon *daemon; - - g_return_if_fail (object != NULL); - g_return_if_fail (DKP_IS_DAEMON (object)); - - daemon = DKP_DAEMON (object); - - g_return_if_fail (daemon->priv != NULL); - - if (daemon->priv->proxy != NULL) - g_object_unref (daemon->priv->proxy); - if (daemon->priv->connection != NULL) - dbus_g_connection_unref (daemon->priv->connection); - if (daemon->priv->gudev_client != NULL) - g_object_unref (daemon->priv->gudev_client); - if (daemon->priv->power_devices != NULL) - g_object_unref (daemon->priv->power_devices); - if (daemon->priv->managed_devices != NULL) - g_object_unref (daemon->priv->managed_devices); - g_object_unref (daemon->priv->polkit); - - G_OBJECT_CLASS (dkp_daemon_parent_class)->finalize (object); -} - -/** * dkp_daemon_get_on_battery_local: * * As soon as _any_ battery goes discharging, this is true @@ -648,247 +371,6 @@ dkp_daemon_refresh_battery_devices (DkpDaemon *daemon) } /** - * dkp_daemon_refresh_battery_devices_cb: - **/ -static gboolean -dkp_daemon_refresh_battery_devices_cb (DkpDaemon *daemon) -{ - egg_debug ("doing the delayed refresh"); - dkp_daemon_refresh_battery_devices (daemon); - return FALSE; -} - -/** - * dkp_daemon_device_changed: - **/ -static void -dkp_daemon_device_changed (DkpDaemon *daemon, GUdevDevice *d, gboolean synthesized) -{ - GObject *object; - DkpDevice *device; - DkpDeviceType type; - gboolean ret; - - /* first, change the device and add it if it doesn't exist */ - object = dkp_device_list_lookup (daemon->priv->power_devices, d); - if (object != NULL) { - device = DKP_DEVICE (object); - egg_debug ("changed %s", dkp_device_get_object_path (device)); - dkp_device_changed (device, d, synthesized); - - /* refresh battery devices when AC state changes */ - g_object_get (device, - "type", &type, - NULL); - if (type == DKP_DEVICE_TYPE_LINE_POWER) { - /* refresh now, and again in a little while */ - dkp_daemon_refresh_battery_devices (daemon); - g_timeout_add_seconds (DKP_DAEMON_ON_BATTERY_REFRESH_DEVICES_DELAY, - (GSourceFunc) dkp_daemon_refresh_battery_devices_cb, daemon); - } - - } else { - egg_debug ("treating change event as add on %s", g_udev_device_get_sysfs_path (d)); - dkp_daemon_device_add (daemon, d, TRUE); - } - - /* second, check if the on_battery and low_battery state has changed */ - ret = (dkp_daemon_get_on_battery_local (daemon) && !dkp_daemon_get_on_ac_local (daemon)); - if (ret != daemon->priv->on_battery) { - daemon->priv->on_battery = ret; - egg_debug ("now on_battery = %s", ret ? "yes" : "no"); - g_signal_emit (daemon, signals[CHANGED_SIGNAL], 0); - - /* set pm-utils power policy */ - dkp_daemon_set_pmutils_powersave (daemon, daemon->priv->on_battery); - } - ret = dkp_daemon_get_low_battery_local (daemon); - if (ret != daemon->priv->low_battery) { - daemon->priv->low_battery = ret; - egg_debug ("now low_battery = %s", ret ? "yes" : "no"); - g_signal_emit (daemon, signals[CHANGED_SIGNAL], 0); - } -} - -/** - * dkp_daemon_device_went_away: - **/ -static void -dkp_daemon_device_went_away (gpointer user_data, GObject *device) -{ - DkpDaemon *daemon = DKP_DAEMON (user_data); - dkp_device_list_remove (daemon->priv->power_devices, device); -} - -/** - * dkp_daemon_device_get: - **/ -static DkpDevice * -dkp_daemon_device_get (DkpDaemon *daemon, GUdevDevice *d) -{ - const gchar *subsys; - const gchar *native_path; - DkpDevice *device = NULL; - DkpInput *input; - gboolean ret; - - subsys = g_udev_device_get_subsystem (d); - if (g_strcmp0 (subsys, "power_supply") == 0) { - - /* are we a valid power supply */ - device = DKP_DEVICE (dkp_device_supply_new ()); - ret = dkp_device_coldplug (device, daemon, d); - if (ret) - goto out; - g_object_unref (device); - - /* no valid power supply object */ - device = NULL; - - } else if (g_strcmp0 (subsys, "tty") == 0) { - - /* try to detect a Watts Up? Pro monitor */ - device = DKP_DEVICE (dkp_device_wup_new ()); - ret = dkp_device_coldplug (device, daemon, d); - if (ret) - goto out; - g_object_unref (device); - - /* no valid TTY object ;-( */ - device = NULL; - - } else if (g_strcmp0 (subsys, "usb") == 0) { - - /* see if this is a CSR mouse or keyboard */ - device = DKP_DEVICE (dkp_device_csr_new ()); - ret = dkp_device_coldplug (device, daemon, d); - if (ret) - goto out; - g_object_unref (device); - - /* try to detect a HID UPS */ - device = DKP_DEVICE (dkp_device_hid_new ()); - ret = dkp_device_coldplug (device, daemon, d); - if (ret) - goto out; - g_object_unref (device); - - /* no valid USB object ;-( */ - device = NULL; - - } else if (g_strcmp0 (subsys, "input") == 0) { - - /* check input device */ - input = dkp_input_new (); - ret = dkp_input_coldplug (input, daemon, d); - if (!ret) { - g_object_unref (input); - goto out; - } - - /* we now have a lid */ - daemon->priv->lid_is_present = TRUE; - - /* not a power device */ - dkp_device_list_insert (daemon->priv->managed_devices, d, G_OBJECT (input)); - - /* no valid input object */ - device = NULL; - - } else { - native_path = g_udev_device_get_sysfs_path (d); - egg_warning ("native path %s (%s) ignoring", native_path, subsys); - } -out: - return device; -} - -/** - * dkp_daemon_device_add: - **/ -static gboolean -dkp_daemon_device_add (DkpDaemon *daemon, GUdevDevice *d, gboolean emit_event) -{ - GObject *object; - DkpDevice *device; - gboolean ret = TRUE; - - /* does device exist in db? */ - object = dkp_device_list_lookup (daemon->priv->power_devices, d); - if (object != NULL) { - device = DKP_DEVICE (object); - /* we already have the device; treat as change event */ - egg_debug ("treating add event as change event on %s", dkp_device_get_object_path (device)); - dkp_daemon_device_changed (daemon, d, FALSE); - } else { - - /* get the right sort of device */ - device = dkp_daemon_device_get (daemon, d); - if (device == NULL) { - egg_debug ("not adding device %s", g_udev_device_get_sysfs_path (d)); - ret = FALSE; - goto out; - } - /* only take a weak ref; the device will stay on the bus until - * it's unreffed. So if we ref it, it'll never go away. - */ - g_object_weak_ref (G_OBJECT (device), dkp_daemon_device_went_away, daemon); - dkp_device_list_insert (daemon->priv->power_devices, d, G_OBJECT (device)); - if (emit_event) { - g_signal_emit (daemon, signals[DEVICE_ADDED_SIGNAL], 0, - dkp_device_get_object_path (device)); - } - } -out: - return ret; -} - -/** - * dkp_daemon_device_remove: - **/ -static void -dkp_daemon_device_remove (DkpDaemon *daemon, GUdevDevice *d) -{ - GObject *object; - DkpDevice *device; - - /* does device exist in db? */ - object = dkp_device_list_lookup (daemon->priv->power_devices, d); - if (object == NULL) { - egg_debug ("ignoring remove event on %s", g_udev_device_get_sysfs_path (d)); - } else { - device = DKP_DEVICE (object); - dkp_device_removed (device); - g_signal_emit (daemon, signals[DEVICE_REMOVED_SIGNAL], 0, - dkp_device_get_object_path (device)); - g_object_unref (device); - } -} - -/** - * dkp_daemon_uevent_signal_handler_cb: - **/ -static void -dkp_daemon_uevent_signal_handler_cb (GUdevClient *client, const gchar *action, - GUdevDevice *device, gpointer user_data) -{ - DkpDaemon *daemon = DKP_DAEMON (user_data); - - if (g_strcmp0 (action, "add") == 0) { - egg_debug ("add %s", g_udev_device_get_sysfs_path (device)); - dkp_daemon_device_add (daemon, device, TRUE); - } else if (g_strcmp0 (action, "remove") == 0) { - egg_debug ("remove %s", g_udev_device_get_sysfs_path (device)); - dkp_daemon_device_remove (daemon, device); - } else if (g_strcmp0 (action, "change") == 0) { - egg_debug ("change %s", g_udev_device_get_sysfs_path (device)); - dkp_daemon_device_changed (daemon, device, FALSE); - } else { - egg_warning ("unhandled action '%s' on %s", action, g_udev_device_get_sysfs_path (device)); - } -} - -/** * dkp_daemon_enumerate_devices: **/ gboolean @@ -1031,9 +513,7 @@ dkp_daemon_register_power_daemon (DkpDaemon *daemon) DBusConnection *connection; DBusError dbus_error; GError *error = NULL; - guint i; - error = NULL; daemon->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); if (daemon->priv->connection == NULL) { if (error != NULL) { @@ -1059,59 +539,468 @@ dkp_daemon_register_power_daemon (DkpDaemon *daemon) goto error; } - /* connect to the DeviceKit daemon */ - for (i=0; subsystems[i] != NULL; i++) - egg_debug ("registering subsystem : %s", subsystems[i]); - - daemon->priv->gudev_client = g_udev_client_new (subsystems); - g_signal_connect (daemon->priv->gudev_client, "uevent", - G_CALLBACK (dkp_daemon_uevent_signal_handler_cb), daemon); - return TRUE; error: return FALSE; } /** - * dkp_daemon_new: + * dkp_daemon_startup: **/ -DkpDaemon * -dkp_daemon_new (void) +gboolean +dkp_daemon_startup (DkpDaemon *daemon) { - DkpDaemon *daemon; - GUdevDevice *device; - GList *devices; - GList *l; - guint i; - - daemon = DKP_DAEMON (g_object_new (DKP_TYPE_DAEMON, NULL)); - - daemon->priv->power_devices = dkp_device_list_new (); - daemon->priv->managed_devices = dkp_device_list_new (); + gboolean ret; - if (!dkp_daemon_register_power_daemon (DKP_DAEMON (daemon))) { - g_object_unref (daemon); - return NULL; + /* register on bus */ + ret = dkp_daemon_register_power_daemon (daemon); + if (!ret) { + egg_warning ("failed to register"); + goto out; } - /* add all subsystems */ - for (i=0; subsystems[i] != NULL; i++) { - devices = g_udev_client_query_by_subsystem (daemon->priv->gudev_client, subsystems[i]); - for (l = devices; l != NULL; l = l->next) { - device = l->data; - dkp_daemon_device_add (daemon, device, FALSE); - } - g_list_foreach (devices, (GFunc) g_object_unref, NULL); - g_list_free (devices); + /* coldplug backend backend */ + ret = dkp_backend_coldplug (daemon->priv->backend, daemon); + if (!ret) { + egg_warning ("failed to coldplug backend"); + goto out; } + /* get battery state */ daemon->priv->on_battery = (dkp_daemon_get_on_battery_local (daemon) && !dkp_daemon_get_on_ac_local (daemon)); daemon->priv->low_battery = dkp_daemon_get_low_battery_local (daemon); /* set pm-utils power policy */ dkp_daemon_set_pmutils_powersave (daemon, daemon->priv->on_battery); +out: + return ret; +} + +/** + * dkp_daemon_refresh_battery_devices_cb: + **/ +static gboolean +dkp_daemon_refresh_battery_devices_cb (DkpDaemon *daemon) +{ + egg_debug ("doing the delayed refresh"); + dkp_daemon_refresh_battery_devices (daemon); + return FALSE; +} + +/** + * dkp_daemon_device_went_away_cb: + **/ +static void +dkp_daemon_device_went_away_cb (gpointer user_data, GObject *device) +{ + DkpDaemon *daemon = DKP_DAEMON (user_data); + dkp_device_list_remove (daemon->priv->power_devices, device); +} + +/** + * dkp_daemon_get_device_list: + **/ +DkpDeviceList * +dkp_daemon_get_device_list (DkpDaemon *daemon) +{ + return g_object_ref (daemon->priv->power_devices); +} + +/** + * dkp_daemon_device_added_cb: + **/ +static void +dkp_daemon_device_added_cb (DkpBackend *backend, GObject *native, DkpDevice *device, gboolean emit_signal, DkpDaemon *daemon) +{ + const gchar *object_path; + + g_return_if_fail (DKP_IS_DAEMON (daemon)); + g_return_if_fail (native != NULL); + g_return_if_fail (device != NULL); + + object_path = dkp_device_get_object_path (device); + egg_debug ("added: native:%p, device:%s (%i)", native, object_path, emit_signal); + + /* only take a weak ref; the device will stay on the bus until + * it's unreffed. So if we ref it, it'll never go away */ + g_object_weak_ref (G_OBJECT (device), dkp_daemon_device_went_away_cb, daemon); + dkp_device_list_insert (daemon->priv->power_devices, native, G_OBJECT (device)); + + /* emit */ + if (emit_signal) + g_signal_emit (daemon, signals[DEVICE_ADDED_SIGNAL], 0, object_path); +} + +/** + * dkp_daemon_device_changed_cb: + **/ +static void +dkp_daemon_device_changed_cb (DkpBackend *backend, GObject *native, DkpDevice *device, gboolean emit_signal, DkpDaemon *daemon) +{ + const gchar *object_path; + DkpDeviceType type; + gboolean ret; + + g_return_if_fail (DKP_IS_DAEMON (daemon)); + g_return_if_fail (native != NULL); + g_return_if_fail (device != NULL); + + object_path = dkp_device_get_object_path (device); + egg_debug ("changed: native:%p, device:%s (%i)", native, object_path, emit_signal); + + dkp_device_changed (device, native, emit_signal); + + /* refresh battery devices when AC state changes */ + g_object_get (device, + "type", &type, + NULL); + if (type == DKP_DEVICE_TYPE_LINE_POWER) { + /* refresh now, and again in a little while */ + dkp_daemon_refresh_battery_devices (daemon); + g_timeout_add_seconds (DKP_DAEMON_ON_BATTERY_REFRESH_DEVICES_DELAY, + (GSourceFunc) dkp_daemon_refresh_battery_devices_cb, daemon); + } + + /* second, check if the on_battery and low_battery state has changed */ + ret = (dkp_daemon_get_on_battery_local (daemon) && !dkp_daemon_get_on_ac_local (daemon)); + if (ret != daemon->priv->on_battery) { + daemon->priv->on_battery = ret; + egg_debug ("now on_battery = %s", ret ? "yes" : "no"); + g_signal_emit (daemon, signals[CHANGED_SIGNAL], 0); + + /* set pm-utils power policy */ + dkp_daemon_set_pmutils_powersave (daemon, daemon->priv->on_battery); + } + ret = dkp_daemon_get_low_battery_local (daemon); + if (ret != daemon->priv->low_battery) { + daemon->priv->low_battery = ret; + egg_debug ("now low_battery = %s", ret ? "yes" : "no"); + g_signal_emit (daemon, signals[CHANGED_SIGNAL], 0); + } +} + +/** + * dkp_daemon_device_removed_cb: + **/ +static void +dkp_daemon_device_removed_cb (DkpBackend *backend, GObject *native, DkpDevice *device, DkpDaemon *daemon) +{ + const gchar *object_path; + + g_return_if_fail (DKP_IS_DAEMON (daemon)); + g_return_if_fail (native != NULL); + g_return_if_fail (device != NULL); + + object_path = dkp_device_get_object_path (device); + egg_debug ("removed: native:%p, device:%s", native, object_path); + + dkp_device_removed (device); + g_signal_emit (daemon, signals[DEVICE_REMOVED_SIGNAL], 0, object_path); + g_object_unref (device); +} + +/** + * dkp_daemon_init: + **/ +static void +dkp_daemon_init (DkpDaemon *daemon) +{ + gfloat waterline; + + daemon->priv = DKP_DAEMON_GET_PRIVATE (daemon); + daemon->priv->polkit = dkp_polkit_new (); + daemon->priv->lid_is_present = FALSE; + daemon->priv->lid_is_closed = FALSE; + daemon->priv->kernel_can_suspend = FALSE; + daemon->priv->kernel_can_hibernate = FALSE; + daemon->priv->kernel_has_swap_space = FALSE; + daemon->priv->power_devices = dkp_device_list_new (); + daemon->priv->on_battery = FALSE; + daemon->priv->low_battery = FALSE; + + daemon->priv->backend = dkp_backend_new (); + g_signal_connect (daemon->priv->backend, "device-added", + G_CALLBACK (dkp_daemon_device_added_cb), daemon); + g_signal_connect (daemon->priv->backend, "device-changed", + G_CALLBACK (dkp_daemon_device_changed_cb), daemon); + g_signal_connect (daemon->priv->backend, "device-removed", + G_CALLBACK (dkp_daemon_device_removed_cb), daemon); + + /* check if we have support */ + dkp_daemon_check_state (daemon); + + /* do we have enough swap? */ + if (daemon->priv->kernel_can_hibernate) { + waterline = dkp_daemon_check_swap (daemon); + if (waterline < DKP_DAEMON_SWAP_WATERLINE) + daemon->priv->kernel_has_swap_space = TRUE; + else + egg_debug ("not enough swap to enable hibernate"); + } +} + +/** + * dkp_daemon_error_quark: + **/ +GQuark +dkp_daemon_error_quark (void) +{ + static GQuark ret = 0; + if (ret == 0) + ret = g_quark_from_static_string ("dkp_daemon_error"); + return ret; +} + +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } +/** + * dkp_daemon_error_get_type: + **/ +GType +dkp_daemon_error_get_type (void) +{ + static GType etype = 0; + + if (etype == 0) { + static const GEnumValue values[] = { + ENUM_ENTRY (DKP_DAEMON_ERROR_GENERAL, "GeneralError"), + ENUM_ENTRY (DKP_DAEMON_ERROR_NOT_SUPPORTED, "NotSupported"), + ENUM_ENTRY (DKP_DAEMON_ERROR_NO_SUCH_DEVICE, "NoSuchDevice"), + { 0, 0, 0 } + }; + g_assert (DKP_DAEMON_NUM_ERRORS == G_N_ELEMENTS (values) - 1); + etype = g_enum_register_static ("DkpDaemonError", values); + } + return etype; +} + +/** + * dkp_daemon_constructor: + **/ +static GObject * +dkp_daemon_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) +{ + DkpDaemon *daemon; + DkpDaemonClass *klass; + + klass = DKP_DAEMON_CLASS (g_type_class_peek (DKP_TYPE_DAEMON)); + daemon = DKP_DAEMON (G_OBJECT_CLASS (dkp_daemon_parent_class)->constructor (type, n_construct_properties, construct_properties)); + return G_OBJECT (daemon); +} + +/** + * dkp_daemon_get_property: + **/ +static void +dkp_daemon_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + DkpDaemon *daemon; + + daemon = DKP_DAEMON (object); + + switch (prop_id) { + + case PROP_DAEMON_VERSION: + g_value_set_string (value, PACKAGE_VERSION); + break; + + case PROP_CAN_SUSPEND: + g_value_set_boolean (value, daemon->priv->kernel_can_suspend); + break; + + case PROP_CAN_HIBERNATE: + g_value_set_boolean (value, (daemon->priv->kernel_can_hibernate && daemon->priv->kernel_has_swap_space)); + break; + case PROP_ON_BATTERY: + g_value_set_boolean (value, daemon->priv->on_battery); + break; + + case PROP_ON_LOW_BATTERY: + g_value_set_boolean (value, daemon->priv->on_battery && daemon->priv->low_battery); + break; + + case PROP_LID_IS_CLOSED: + g_value_set_boolean (value, daemon->priv->lid_is_closed); + break; + + case PROP_LID_IS_PRESENT: + g_value_set_boolean (value, daemon->priv->lid_is_present); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/** + * dkp_daemon_set_property: + **/ +static void +dkp_daemon_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +{ + DkpDaemon *daemon = DKP_DAEMON (object); + + switch (prop_id) { + + case PROP_LID_IS_CLOSED: + daemon->priv->lid_is_closed = g_value_get_boolean (value); + break; + + case PROP_LID_IS_PRESENT: + daemon->priv->lid_is_present = g_value_get_boolean (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +/** + * dkp_daemon_class_init: + **/ +static void +dkp_daemon_class_init (DkpDaemonClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->constructor = dkp_daemon_constructor; + object_class->finalize = dkp_daemon_finalize; + object_class->get_property = dkp_daemon_get_property; + object_class->set_property = dkp_daemon_set_property; + + g_type_class_add_private (klass, sizeof (DkpDaemonPrivate)); + + signals[DEVICE_ADDED_SIGNAL] = + g_signal_new ("device-added", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); + + signals[DEVICE_REMOVED_SIGNAL] = + g_signal_new ("device-removed", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); + + signals[DEVICE_CHANGED_SIGNAL] = + g_signal_new ("device-changed", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); + + signals[CHANGED_SIGNAL] = + g_signal_new ("changed", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 0); + + + g_object_class_install_property (object_class, + PROP_DAEMON_VERSION, + g_param_spec_string ("daemon-version", + "Daemon Version", + "The version of the running daemon", + NULL, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, + PROP_LID_IS_PRESENT, + g_param_spec_boolean ("lid-is-present", + "Is a laptop", + "If this computer is probably a laptop", + FALSE, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, + PROP_CAN_SUSPEND, + g_param_spec_boolean ("can-suspend", + "Can Suspend", + "Whether the system can suspend", + FALSE, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, + PROP_CAN_HIBERNATE, + g_param_spec_boolean ("can-hibernate", + "Can Hibernate", + "Whether the system can hibernate", + FALSE, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, + PROP_ON_BATTERY, + g_param_spec_boolean ("on-battery", + "On Battery", + "Whether the system is running on battery", + FALSE, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, + PROP_ON_LOW_BATTERY, + g_param_spec_boolean ("on-low-battery", + "On Low Battery", + "Whether the system is running on battery and if the battery is critically low", + FALSE, + G_PARAM_READABLE)); + + g_object_class_install_property (object_class, + PROP_LID_IS_CLOSED, + g_param_spec_boolean ("lid-is-closed", + "Laptop lid is closed", + "If the laptop lid is closed", + FALSE, + G_PARAM_READABLE)); + + dbus_g_object_type_install_info (DKP_TYPE_DAEMON, &dbus_glib_dkp_daemon_object_info); + + dbus_g_error_domain_register (DKP_DAEMON_ERROR, NULL, DKP_DAEMON_TYPE_ERROR); +} + +/** + * dkp_daemon_finalize: + **/ +static void +dkp_daemon_finalize (GObject *object) +{ + DkpDaemon *daemon; + + g_return_if_fail (object != NULL); + g_return_if_fail (DKP_IS_DAEMON (object)); + + daemon = DKP_DAEMON (object); + + g_return_if_fail (daemon->priv != NULL); + + if (daemon->priv->proxy != NULL) + g_object_unref (daemon->priv->proxy); + if (daemon->priv->connection != NULL) + dbus_g_connection_unref (daemon->priv->connection); + if (daemon->priv->power_devices != NULL) + g_object_unref (daemon->priv->power_devices); + g_object_unref (daemon->priv->polkit); + g_object_unref (daemon->priv->backend); + + G_OBJECT_CLASS (dkp_daemon_parent_class)->finalize (object); +} + +/** + * dkp_daemon_new: + **/ +DkpDaemon * +dkp_daemon_new (void) +{ + DkpDaemon *daemon; + daemon = DKP_DAEMON (g_object_new (DKP_TYPE_DAEMON, NULL)); return daemon; } diff --git a/src/dkp-daemon.h b/src/dkp-daemon.h index b1350c4..9ea1210 100644 --- a/src/dkp-daemon.h +++ b/src/dkp-daemon.h @@ -26,6 +26,7 @@ #include <dbus/dbus-glib.h> #include "dkp-enum.h" +#include "dkp-device-list.h" G_BEGIN_DECLS @@ -69,6 +70,11 @@ DkpDaemon *dkp_daemon_new (void); /* private */ guint dkp_daemon_get_number_devices_of_type (DkpDaemon *daemon, DkpDeviceType type); +DkpDeviceList *dkp_daemon_get_device_list (DkpDaemon *daemon); +gboolean dkp_daemon_set_lid_is_closed (DkpDaemon *daemon, + gboolean lid_is_closed, + gboolean notify); +gboolean dkp_daemon_startup (DkpDaemon *daemon); /* exported */ gboolean dkp_daemon_enumerate_devices (DkpDaemon *daemon, @@ -87,9 +93,6 @@ gboolean dkp_daemon_can_suspend (DkpDaemon *daemon, gboolean dkp_daemon_can_hibernate (DkpDaemon *daemon, gboolean interactive, DBusGMethodInvocation *context); -gboolean dkp_daemon_set_lid_is_closed (DkpDaemon *daemon, - gboolean lid_is_closed, - gboolean notify); G_END_DECLS diff --git a/src/dkp-device-list.c b/src/dkp-device-list.c index fee7bc8..d6d5591 100644 --- a/src/dkp-device-list.c +++ b/src/dkp-device-list.c @@ -27,6 +27,7 @@ #include "egg-debug.h" +#include "dkp-native.h" #include "dkp-device-list.h" static void dkp_device_list_class_init (DkpDeviceListClass *klass); @@ -38,7 +39,7 @@ static void dkp_device_list_finalize (GObject *object); struct DkpDeviceListPrivate { GPtrArray *array; - GHashTable *map_native_path_to_object; + GHashTable *map_native_path_to_device; }; G_DEFINE_TYPE (DkpDeviceList, dkp_device_list, G_TYPE_OBJECT) @@ -46,42 +47,42 @@ G_DEFINE_TYPE (DkpDeviceList, dkp_device_list, G_TYPE_OBJECT) /** * dkp_device_list_lookup: * - * Convert a %GUdevDevice into a %GObject -- we use the native path + * Convert a native %GObject into a %DkpDevice -- we use the native path * to look these up as it's the only thing they share. **/ GObject * -dkp_device_list_lookup (DkpDeviceList *list, GUdevDevice *device) +dkp_device_list_lookup (DkpDeviceList *list, GObject *native) { - GObject *object; + GObject *device; const gchar *native_path; g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), NULL); /* does device exist in db? */ - native_path = g_udev_device_get_sysfs_path (device); - object = g_hash_table_lookup (list->priv->map_native_path_to_object, native_path); - return object; + native_path = dkp_native_get_native_path (native); + device = g_hash_table_lookup (list->priv->map_native_path_to_device, native_path); + return device; } /** * dkp_device_list_insert: * - * Insert a %GUdevDevice device and it's mapping to a backing %GObject + * Insert a %GObject device and it's mapping to a backing %DkpDevice * into a list of devices. **/ gboolean -dkp_device_list_insert (DkpDeviceList *list, GUdevDevice *device, GObject *object) +dkp_device_list_insert (DkpDeviceList *list, GObject *native, GObject *device) { const gchar *native_path; g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), FALSE); + g_return_val_if_fail (native != NULL, FALSE); g_return_val_if_fail (device != NULL, FALSE); - g_return_val_if_fail (object != NULL, FALSE); - native_path = g_udev_device_get_sysfs_path (device); - g_hash_table_insert (list->priv->map_native_path_to_object, - g_strdup (native_path), object); - g_ptr_array_add (list->priv->array, g_object_ref (object)); + native_path = dkp_native_get_native_path (native); + g_hash_table_insert (list->priv->map_native_path_to_device, + g_strdup (native_path), device); + g_ptr_array_add (list->priv->array, g_object_ref (device)); egg_debug ("added %s", native_path); return TRUE; } @@ -103,23 +104,23 @@ dkp_device_list_remove_cb (gpointer key, gpointer value, gpointer user_data) * dkp_device_list_remove: **/ gboolean -dkp_device_list_remove (DkpDeviceList *list, GObject *object) +dkp_device_list_remove (DkpDeviceList *list, GObject *device) { g_return_val_if_fail (DKP_IS_DEVICE_LIST (list), FALSE); - g_return_val_if_fail (object != NULL, FALSE); + g_return_val_if_fail (device != NULL, FALSE); /* remove the device from the db */ - g_hash_table_foreach_remove (list->priv->map_native_path_to_object, - dkp_device_list_remove_cb, object); - g_ptr_array_remove (list->priv->array, object); - g_object_unref (object); + g_hash_table_foreach_remove (list->priv->map_native_path_to_device, + dkp_device_list_remove_cb, device); + g_ptr_array_remove (list->priv->array, device); + g_object_unref (device); return TRUE; } /** * dkp_device_list_get_array: * - * This is quick to iterate when we don't have GUdevDevice's to resolve + * This is quick to iterate when we don't have GObject's to resolve **/ const GPtrArray * dkp_device_list_get_array (DkpDeviceList *list) @@ -149,7 +150,7 @@ dkp_device_list_init (DkpDeviceList *list) { list->priv = DKP_DEVICE_LIST_GET_PRIVATE (list); list->priv->array = g_ptr_array_new (); - list->priv->map_native_path_to_object = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + list->priv->map_native_path_to_device = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); } /** @@ -167,7 +168,7 @@ dkp_device_list_finalize (GObject *object) g_ptr_array_foreach (list->priv->array, (GFunc) g_object_unref, NULL); g_ptr_array_free (list->priv->array, TRUE); - g_hash_table_unref (list->priv->map_native_path_to_object); + g_hash_table_unref (list->priv->map_native_path_to_device); G_OBJECT_CLASS (dkp_device_list_parent_class)->finalize (object); } diff --git a/src/dkp-device-list.h b/src/dkp-device-list.h index 943e78f..f73bf1a 100644 --- a/src/dkp-device-list.h +++ b/src/dkp-device-list.h @@ -25,8 +25,6 @@ #include <glib-object.h> #include <dkp-enum.h> -#include "dkp-device.h" - G_BEGIN_DECLS #define DKP_TYPE_DEVICE_LIST (dkp_device_list_get_type ()) @@ -54,12 +52,12 @@ typedef struct GType dkp_device_list_get_type (void); DkpDeviceList *dkp_device_list_new (void); GObject *dkp_device_list_lookup (DkpDeviceList *list, - GUdevDevice *device); + GObject *native); gboolean dkp_device_list_insert (DkpDeviceList *list, - GUdevDevice *device, - GObject *object); + GObject *native, + GObject *device); gboolean dkp_device_list_remove (DkpDeviceList *list, - GObject *object); + GObject *device); const GPtrArray *dkp_device_list_get_array (DkpDeviceList *list); G_END_DECLS diff --git a/src/dkp-device.c b/src/dkp-device.c index c3b0edc..869b4c2 100644 --- a/src/dkp-device.c +++ b/src/dkp-device.c @@ -31,12 +31,10 @@ #include <glib-object.h> #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> -#include <gudev/gudev.h> -#include "sysfs-utils.h" #include "egg-debug.h" -#include "dkp-device-supply.h" +#include "dkp-native.h" #include "dkp-device.h" #include "dkp-history.h" #include "dkp-history-obj.h" @@ -51,7 +49,7 @@ struct DkpDevicePrivate DBusGProxy *system_bus_proxy; DkpDaemon *daemon; DkpHistory *history; - GUdevDevice *d; + GObject *native; gboolean has_ever_refresh; /* properties */ @@ -278,10 +276,10 @@ dkp_device_set_property (GObject *object, guint prop_id, const GValue *value, GP DkpDevice *device = DKP_DEVICE (object); switch (prop_id) { -// case PROP_NATIVE_PATH: -// g_free (device->priv->native_path); -// device->priv->native_path = g_strdup (g_value_get_string (value)); -// break; + case PROP_NATIVE_PATH: + g_free (device->priv->native_path); + device->priv->native_path = g_strdup (g_value_get_string (value)); + break; case PROP_VENDOR: g_free (device->priv->vendor); device->priv->vendor = g_strdup (g_value_get_string (value)); @@ -518,7 +516,7 @@ dkp_device_get_daemon (DkpDevice *device) * Return %TRUE on success, %FALSE if we failed to get data and should be removed **/ gboolean -dkp_device_coldplug (DkpDevice *device, DkpDaemon *daemon, GUdevDevice *d) +dkp_device_coldplug (DkpDevice *device, DkpDaemon *daemon, GObject *native) { gboolean ret; const gchar *native_path; @@ -528,17 +526,19 @@ dkp_device_coldplug (DkpDevice *device, DkpDaemon *daemon, GUdevDevice *d) g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE); /* save */ - device->priv->d = g_object_ref (d); + device->priv->native = g_object_ref (native); device->priv->daemon = g_object_ref (daemon); - native_path = g_udev_device_get_sysfs_path (d); + native_path = dkp_native_get_native_path (native); device->priv->native_path = g_strdup (native_path); /* coldplug source */ - ret = klass->coldplug (device); - if (!ret) { - egg_debug ("failed to coldplug %p", device); - goto out; + if (klass->coldplug != NULL) { + ret = klass->coldplug (device); + if (!ret) { + egg_debug ("failed to coldplug %p", device); + goto out; + } } /* only put on the bus if we succeeded */ @@ -705,9 +705,13 @@ out: gboolean dkp_device_refresh_internal (DkpDevice *device) { - gboolean ret; + gboolean ret = FALSE; DkpDeviceClass *klass = DKP_DEVICE_GET_CLASS (device); + /* not implemented */ + if (klass->refresh == NULL) + goto out; + /* do the refresh */ ret = klass->refresh (device); if (!ret) { @@ -747,14 +751,14 @@ dkp_device_refresh (DkpDevice *device, DBusGMethodInvocation *context) * dkp_device_changed: **/ gboolean -dkp_device_changed (DkpDevice *device, GUdevDevice *d, gboolean synthesized) +dkp_device_changed (DkpDevice *device, GObject *native, gboolean emit_signal) { gboolean ret; g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE); - g_object_unref (device->priv->d); - device->priv->d = g_object_ref (d); + g_object_unref (device->priv->native); + device->priv->native = g_object_ref (native); ret = dkp_device_refresh_internal (device); @@ -778,11 +782,11 @@ dkp_device_get_object_path (DkpDevice *device) return device->priv->object_path; } -GUdevDevice * -dkp_device_get_d (DkpDevice *device) +GObject * +dkp_device_get_native (DkpDevice *device) { g_return_val_if_fail (DKP_IS_DEVICE (device), NULL); - return device->priv->d; + return device->priv->native; } /** @@ -881,7 +885,7 @@ dkp_device_init (DkpDevice *device) device->priv->system_bus_connection = NULL; device->priv->system_bus_proxy = NULL; device->priv->daemon = NULL; - device->priv->d = NULL; + device->priv->native = NULL; device->priv->has_ever_refresh = FALSE; device->priv->history = dkp_history_new (); @@ -905,7 +909,7 @@ dkp_device_finalize (GObject *object) device = DKP_DEVICE (object); g_return_if_fail (device->priv != NULL); - g_object_unref (device->priv->d); + g_object_unref (device->priv->native); g_object_unref (device->priv->daemon); g_object_unref (device->priv->history); g_free (device->priv->object_path); @@ -1185,3 +1189,14 @@ dkp_device_class_init (DkpDeviceClass *klass) dbus_g_error_domain_register (DKP_DEVICE_ERROR, NULL, DKP_DEVICE_TYPE_ERROR); } +/** + * dkp_device_new: + **/ +DkpDevice * +dkp_device_new (void) +{ + DkpDevice *device; + device = DKP_DEVICE (g_object_new (DKP_TYPE_DEVICE, NULL)); + return device; +} + diff --git a/src/dkp-device.h b/src/dkp-device.h index e217dcf..f26dba0 100644 --- a/src/dkp-device.h +++ b/src/dkp-device.h @@ -23,7 +23,6 @@ #define __DKP_DEVICE_H__ #include <glib-object.h> -#include <gudev/gudev.h> #include <polkit/polkit.h> #include <dbus/dbus-glib.h> @@ -74,15 +73,16 @@ typedef enum GQuark dkp_device_error_quark (void); GType dkp_device_error_get_type (void); GType dkp_device_get_type (void); +DkpDevice *dkp_device_new (void); gboolean dkp_device_coldplug (DkpDevice *device, DkpDaemon *daemon, - GUdevDevice *d); + GObject *native); DkpDaemon *dkp_device_get_daemon (DkpDevice *device); gboolean dkp_device_changed (DkpDevice *device, - GUdevDevice *d, + GObject *native, gboolean synthesized); void dkp_device_removed (DkpDevice *device); -GUdevDevice *dkp_device_get_d (DkpDevice *device); +GObject *dkp_device_get_native (DkpDevice *device); const gchar *dkp_device_get_object_path (DkpDevice *device); gboolean dkp_device_get_on_battery (DkpDevice *device, gboolean *on_battery); diff --git a/src/dkp-main.c b/src/dkp-main.c index 9f33d60..ed9f81c 100644 --- a/src/dkp-main.c +++ b/src/dkp-main.c @@ -1,27 +1,23 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * * Copyright (C) 2007 David Zeuthen <davidz@redhat.com> + * Copyright (C) 2008-2009 Richard Hughes <richard@hughsie.com> * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * Licensed under the GNU General Public License Version 2 * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. + * 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. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * 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. */ #ifdef HAVE_CONFIG_H @@ -39,7 +35,6 @@ #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> -#include <gudev/gudev.h> #include "egg-debug.h" @@ -47,53 +42,49 @@ #include "dkp-qos.h" #include "dkp-wakeups.h" -#define NAME_TO_CLAIM "org.freedesktop.DeviceKit.Power" +#define DEVKIT_POWER_SERVICE_NAME "org.freedesktop.DeviceKit.Power" static GMainLoop *loop = NULL; /** - * main_acquire_name_on_proxy: + * dkp_main_acquire_name_on_proxy: **/ static gboolean -main_acquire_name_on_proxy (DBusGProxy *bus_proxy) +dkp_main_acquire_name_on_proxy (DBusGProxy *bus_proxy, const gchar *name) { - GError *error; + GError *error = NULL; guint result; - gboolean res; gboolean ret = FALSE; if (bus_proxy == NULL) goto out; - error = NULL; - res = dbus_g_proxy_call (bus_proxy, - "RequestName", - &error, - G_TYPE_STRING, NAME_TO_CLAIM, + ret = dbus_g_proxy_call (bus_proxy, "RequestName", &error, + G_TYPE_STRING, name, G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &result, G_TYPE_INVALID); - if (!res) { + if (!ret) { if (error != NULL) { - egg_warning ("Failed to acquire %s: %s", NAME_TO_CLAIM, error->message); + egg_warning ("Failed to acquire %s: %s", name, error->message); g_error_free (error); } else { - egg_warning ("Failed to acquire %s", NAME_TO_CLAIM); + egg_warning ("Failed to acquire %s", name); } goto out; } + /* already taken */ if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { if (error != NULL) { - egg_warning ("Failed to acquire %s: %s", NAME_TO_CLAIM, error->message); + egg_warning ("Failed to acquire %s: %s", name, error->message); g_error_free (error); } else { - egg_warning ("Failed to acquire %s", NAME_TO_CLAIM); + egg_warning ("Failed to acquire %s", name); } + ret = FALSE; goto out; } - - ret = TRUE; out: return ret; } @@ -102,7 +93,7 @@ out: * dkp_main_sigint_handler: **/ static void -dkp_main_sigint_handler (int sig) +dkp_main_sigint_handler (gint sig) { egg_debug ("Handling SIGINT"); @@ -116,10 +107,10 @@ dkp_main_sigint_handler (int sig) /** * main: **/ -int -main (int argc, char **argv) +gint +main (gint argc, gchar **argv) { - GError *error; + GError *error = NULL; DkpDaemon *daemon; DkpQos *qos; DkpWakeups *wakeups; @@ -127,7 +118,8 @@ main (int argc, char **argv) DBusGProxy *bus_proxy; DBusGConnection *bus; gboolean verbose = FALSE; - int ret = 1; + gboolean ret; + gint retval = 1; const GOptionEntry entries[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, @@ -143,7 +135,7 @@ main (int argc, char **argv) g_option_context_free (context); egg_debug_init (verbose); - error = NULL; + /* get bus connection */ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); if (bus == NULL) { egg_warning ("Couldn't connect to system bus: %s", error->message); @@ -151,6 +143,7 @@ main (int argc, char **argv) goto out; } + /* get proxy */ bus_proxy = dbus_g_proxy_new_for_name (bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); if (bus_proxy == NULL) { @@ -158,7 +151,9 @@ main (int argc, char **argv) goto out; } - if (!main_acquire_name_on_proxy (bus_proxy) ) { + /* aquire name */ + ret = dkp_main_acquire_name_on_proxy (bus_proxy, DEVKIT_POWER_SERVICE_NAME); + if (!ret) { egg_warning ("Could not acquire name; bailing out"); goto out; } @@ -171,8 +166,11 @@ main (int argc, char **argv) qos = dkp_qos_new (); wakeups = dkp_wakeups_new (); daemon = dkp_daemon_new (); - if (daemon == NULL) + ret = dkp_daemon_startup (daemon); + if (!ret) { + egg_warning ("Could not startup; bailing out"); goto out; + } loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); @@ -181,8 +179,8 @@ main (int argc, char **argv) g_object_unref (wakeups); g_object_unref (daemon); g_main_loop_unref (loop); - ret = 0; + retval = 0; out: - return ret; + return retval; } diff --git a/src/dkp-marshal.list b/src/dkp-marshal.list index deb5c1d..86ba607 100644 --- a/src/dkp-marshal.list +++ b/src/dkp-marshal.list @@ -1,4 +1,7 @@ VOID:BOOLEAN,STRING,BOOLEAN,INT,INT,STRING,DOUBLE VOID:STRING,BOOLEAN,STRING,BOOLEAN,INT,INT,STRING,DOUBLE VOID:STRING,INT +VOID:POINTER,BOOLEAN +VOID:POINTER,POINTER +VOID:POINTER,POINTER,BOOLEAN diff --git a/src/dkp-native.h b/src/dkp-native.h new file mode 100644 index 0000000..53a9673 --- /dev/null +++ b/src/dkp-native.h @@ -0,0 +1,33 @@ +/* -*- 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_NATIVE_H__ +#define __DKP_NATIVE_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +const gchar *dkp_native_get_native_path (GObject *object); + +G_END_DECLS + +#endif /* __DKP_NATIVE_H__ */ + diff --git a/src/dummy/.gitignore b/src/dummy/.gitignore new file mode 100644 index 0000000..ed89e2f --- /dev/null +++ b/src/dummy/.gitignore @@ -0,0 +1,5 @@ +.deps +.libs +*.o +*.a + diff --git a/src/dummy/Makefile.am b/src/dummy/Makefile.am new file mode 100644 index 0000000..aa1c944 --- /dev/null +++ b/src/dummy/Makefile.am @@ -0,0 +1,23 @@ +## Process this file with automake to produce Makefile.in + +INCLUDES = \ + -I$(top_builddir)/src -I$(top_srcdir)/src \ + -DEGG_LOG_FILE=\""$(DKP_LOG_DIR)/DeviceKit-power"\" \ + -DEGG_VERBOSE="\"DKP_VERBOSE\"" \ + -DEGG_LOGGING="\"DKP_LOGGING\"" \ + -DEGG_CONSOLE="\"DKP_CONSOLE\"" \ + -DDKP_COMPILATION \ + -I$(top_srcdir)/devkit-power-gobject \ + $(DBUS_GLIB_CFLAGS) \ + $(POLKIT_CFLAGS) \ + $(GLIB_CFLAGS) + +noinst_LIBRARIES = libdkpshared.a +libdkpshared_a_SOURCES = \ + dkp-backend.c \ + dkp-native.c \ + $(BUILT_SOURCES) + +clean-local : + rm -f *~ + diff --git a/src/dummy/dkp-backend.c b/src/dummy/dkp-backend.c new file mode 100644 index 0000000..0241a76 --- /dev/null +++ b/src/dummy/dkp-backend.c @@ -0,0 +1,221 @@ +/* -*- 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 <math.h> +#include <glib/gi18n.h> +#include <gio/gio.h> + +#include "egg-debug.h" + +#include "dkp-backend.h" +#include "dkp-daemon.h" +#include "dkp-marshal.h" +#include "dkp-device.h" + +static void dkp_backend_class_init (DkpBackendClass *klass); +static void dkp_backend_init (DkpBackend *backend); +static void dkp_backend_finalize (GObject *object); + +#define DKP_BACKEND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_BACKEND, DkpBackendPrivate)) + +struct DkpBackendPrivate +{ + DkpDaemon *daemon; + DkpDevice *device; + DkpDeviceList *device_list; /* unused */ + GObject *native; +}; + +enum { + SIGNAL_DEVICE_ADDED, + SIGNAL_DEVICE_CHANGED, + SIGNAL_DEVICE_REMOVED, + SIGNAL_LAST +}; + +static guint signals [SIGNAL_LAST] = { 0 }; + +G_DEFINE_TYPE (DkpBackend, dkp_backend, G_TYPE_OBJECT) + +/** + * dkp_backend_changed_time_cb: + **/ +static gboolean +dkp_backend_changed_time_cb (DkpBackend *backend) +{ + /* emit */ + g_signal_emit (backend, signals[SIGNAL_DEVICE_CHANGED], 0, backend->priv->native, backend->priv->device, TRUE); + return TRUE; +} + +/** + * dkp_backend_add_cb: + **/ +static gboolean +dkp_backend_add_cb (DkpBackend *backend) +{ + gboolean ret; + + /* coldplug */ + ret = dkp_device_coldplug (backend->priv->device, backend->priv->daemon, backend->priv->native); + if (!ret) { + egg_warning ("failed to coldplug"); + goto out; + } + + /* emit */ + g_signal_emit (backend, signals[SIGNAL_DEVICE_ADDED], 0, backend->priv->native, backend->priv->device, TRUE); + + /* setup poll */ + g_timeout_add_seconds (2, (GSourceFunc) dkp_backend_changed_time_cb, backend); +out: + return FALSE; +} + +/** + * dkp_backend_coldplug: + * @backend: The %DkpBackend class instance + * @daemon: The %DkpDaemon controlling instance + * + * Finds all the devices already plugged in, and emits device-add signals for + * each of them. + * + * Return value: %TRUE for success + **/ +gboolean +dkp_backend_coldplug (DkpBackend *backend, DkpDaemon *daemon) +{ + backend->priv->daemon = g_object_ref (daemon); + backend->priv->device_list = dkp_daemon_get_device_list (daemon); + + /* small delay until first device is added */ + g_timeout_add_seconds (1, (GSourceFunc) dkp_backend_add_cb, backend); + + return TRUE; +} + +/** + * dkp_backend_class_init: + * @klass: The DkpBackendClass + **/ +static void +dkp_backend_class_init (DkpBackendClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->finalize = dkp_backend_finalize; + + signals [SIGNAL_DEVICE_ADDED] = + g_signal_new ("device-added", + G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DkpBackendClass, device_added), + NULL, NULL, dkp_marshal_VOID__POINTER_POINTER_BOOLEAN, + G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_BOOLEAN); + signals [SIGNAL_DEVICE_CHANGED] = + g_signal_new ("device-changed", + G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DkpBackendClass, device_changed), + NULL, NULL, dkp_marshal_VOID__POINTER_POINTER_BOOLEAN, + G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_BOOLEAN); + signals [SIGNAL_DEVICE_REMOVED] = + g_signal_new ("device-removed", + G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DkpBackendClass, device_removed), + NULL, NULL, dkp_marshal_VOID__POINTER_POINTER, + G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); + + g_type_class_add_private (klass, sizeof (DkpBackendPrivate)); +} + +/** + * dkp_backend_init: + **/ +static void +dkp_backend_init (DkpBackend *backend) +{ + backend->priv = DKP_BACKEND_GET_PRIVATE (backend); + backend->priv->daemon = NULL; + backend->priv->device_list = NULL; + backend->priv->native = g_object_new (DKP_TYPE_DEVICE, NULL); + backend->priv->device = dkp_device_new (); + + /* setup dummy */ + g_object_set (backend->priv->device, + "native-path", "/hal/blows/goats", + "vendor", "hughsie", + "model", "BAT1", + "serial", "0001", + "type", DKP_DEVICE_TYPE_BATTERY, + "online", FALSE, + "power-supply", TRUE, + "is-present", TRUE, + "is-rechargeable", TRUE, + "has-history", FALSE, + "has-statistics", FALSE, + "state", DKP_DEVICE_STATE_DISCHARGING, + "energy", 0.0f, + "energy-empty", 0.0f, + "energy-full", 10.0f, + "energy-full-design", 10.0f, + "energy-rate", 5.0f, + "percentage", 50.0f, + NULL); +} + +/** + * dkp_backend_finalize: + **/ +static void +dkp_backend_finalize (GObject *object) +{ + DkpBackend *backend; + + g_return_if_fail (DKP_IS_BACKEND (object)); + + backend = DKP_BACKEND (object); + + if (backend->priv->daemon != NULL) + g_object_unref (backend->priv->daemon); + if (backend->priv->device_list != NULL) + g_object_unref (backend->priv->device_list); + + g_object_unref (backend->priv->native); + g_object_unref (backend->priv->device); + + G_OBJECT_CLASS (dkp_backend_parent_class)->finalize (object); +} + +/** + * dkp_backend_new: + * + * Return value: a new %DkpBackend object. + **/ +DkpBackend * +dkp_backend_new (void) +{ + DkpBackend *backend; + backend = g_object_new (DKP_TYPE_BACKEND, NULL); + return DKP_BACKEND (backend); +} + diff --git a/src/dummy/dkp-native.c b/src/dummy/dkp-native.c new file mode 100644 index 0000000..1dea65c --- /dev/null +++ b/src/dummy/dkp-native.c @@ -0,0 +1,40 @@ +/* -*- 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 "dkp-native.h" + +/** + * dkp_native_get_native_path: + * @object: the native tracking object + * + * This converts a GObject used as the device data into a native path. + * This would be implemented on a Linux system using: + * g_udev_device_get_sysfs_path (G_UDEV_DEVICE (object)) + * + * Return value: The native path for the device which is unique, e.g. "/sys/class/power/BAT1" + **/ +const gchar * +dkp_native_get_native_path (GObject *object) +{ + return "/sys/dummy"; +} + diff --git a/src/linux/.gitignore b/src/linux/.gitignore new file mode 100644 index 0000000..ed89e2f --- /dev/null +++ b/src/linux/.gitignore @@ -0,0 +1,5 @@ +.deps +.libs +*.o +*.a + diff --git a/src/linux/Makefile.am b/src/linux/Makefile.am new file mode 100644 index 0000000..489563b --- /dev/null +++ b/src/linux/Makefile.am @@ -0,0 +1,37 @@ +## Process this file with automake to produce Makefile.in + +INCLUDES = \ + -I$(top_builddir)/src -I$(top_srcdir)/src \ + -DEGG_LOG_FILE=\""$(DKP_LOG_DIR)/DeviceKit-power"\" \ + -DEGG_VERBOSE="\"DKP_VERBOSE\"" \ + -DEGG_LOGGING="\"DKP_LOGGING\"" \ + -DEGG_CONSOLE="\"DKP_CONSOLE\"" \ + -DDKP_COMPILATION \ + -I$(top_srcdir)/devkit-power-gobject \ + $(GIO_CFLAGS) \ + $(DBUS_GLIB_CFLAGS) \ + $(GUDEV_CFLAGS) \ + $(POLKIT_CFLAGS) \ + $(GLIB_CFLAGS) + +noinst_LIBRARIES = libdkpshared.a +libdkpshared_a_SOURCES = \ + dkp-device-supply.c \ + dkp-device-supply.h \ + dkp-device-csr.c \ + dkp-device-csr.h \ + dkp-device-hid.c \ + dkp-device-hid.h \ + dkp-device-wup.c \ + dkp-device-wup.h \ + dkp-input.c \ + dkp-input.h \ + dkp-backend.c \ + dkp-native.c \ + sysfs-utils.c \ + sysfs-utils.h \ + $(BUILT_SOURCES) + +clean-local : + rm -f *~ + diff --git a/src/linux/dkp-backend.c b/src/linux/dkp-backend.c new file mode 100644 index 0000000..d4cf421 --- /dev/null +++ b/src/linux/dkp-backend.c @@ -0,0 +1,408 @@ +/* -*- 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 <math.h> +#include <glib/gi18n.h> +#include <gio/gio.h> +#include <gudev/gudev.h> + +#include "egg-debug.h" + +#include "dkp-backend.h" +#include "dkp-daemon.h" +#include "dkp-marshal.h" +#include "dkp-device.h" + +#include "dkp-device-supply.h" +#include "dkp-device-csr.h" +#include "dkp-device-wup.h" +#include "dkp-device-hid.h" +#include "dkp-input.h" + +static void dkp_backend_class_init (DkpBackendClass *klass); +static void dkp_backend_init (DkpBackend *backend); +static void dkp_backend_finalize (GObject *object); + +#define DKP_BACKEND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DKP_TYPE_BACKEND, DkpBackendPrivate)) + +struct DkpBackendPrivate +{ + DkpDaemon *daemon; + DkpDevice *device; + DkpDeviceList *device_list; + GObject *native; + GUdevClient *gudev_client; + DkpDeviceList *managed_devices; +}; + +enum { + SIGNAL_DEVICE_ADDED, + SIGNAL_DEVICE_CHANGED, + SIGNAL_DEVICE_REMOVED, + SIGNAL_LAST +}; + +static guint signals [SIGNAL_LAST] = { 0 }; + +G_DEFINE_TYPE (DkpBackend, dkp_backend, G_TYPE_OBJECT) + +static gboolean dkp_backend_device_add (DkpBackend *backend, GUdevDevice *native, gboolean emit_signal); +static void dkp_backend_device_remove (DkpBackend *backend, GUdevDevice *native); + +/** + * dkp_backend_device_changed: + **/ +static void +dkp_backend_device_changed (DkpBackend *backend, GUdevDevice *native, gboolean emit_signal) +{ + GObject *object; + DkpDevice *device; + + /* first, change the device and add it if it doesn't exist */ + object = dkp_device_list_lookup (backend->priv->device_list, native); + if (object == NULL) { + egg_debug ("treating change event as add on %s", g_udev_device_get_sysfs_path (native)); + dkp_backend_device_add (backend, native, TRUE); + goto out; + } + + device = DKP_DEVICE (object); + egg_debug ("changed %s", dkp_device_get_object_path (device)); + + /* emit */ + g_signal_emit (backend, signals[SIGNAL_DEVICE_CHANGED], 0, native, device, emit_signal); +} + +/** + * dkp_backend_device_get: + **/ +static DkpDevice * +dkp_backend_device_get (DkpBackend *backend, GUdevDevice *native) +{ + const gchar *subsys; + const gchar *native_path; + DkpDevice *device = NULL; + DkpInput *input; + gboolean ret; + + subsys = g_udev_device_get_subsystem (native); + if (g_strcmp0 (subsys, "power_supply") == 0) { + + /* are we a valid power supply */ + device = DKP_DEVICE (dkp_device_supply_new ()); + ret = dkp_device_coldplug (device, backend, native); + if (ret) + goto out; + g_object_unref (device); + + /* no valid power supply object */ + device = NULL; + + } else if (g_strcmp0 (subsys, "tty") == 0) { + + /* try to detect a Watts Up? Pro monitor */ + device = DKP_DEVICE (dkp_device_wup_new ()); + ret = dkp_device_coldplug (device, backend, native); + if (ret) + goto out; + g_object_unref (device); + + /* no valid TTY object ;-( */ + device = NULL; + + } else if (g_strcmp0 (subsys, "usb") == 0) { + + /* see if this is a CSR mouse or keyboard */ + device = DKP_DEVICE (dkp_device_csr_new ()); + ret = dkp_device_coldplug (device, backend, native); + if (ret) + goto out; + g_object_unref (device); + + /* try to detect a HID UPS */ + device = DKP_DEVICE (dkp_device_hid_new ()); + ret = dkp_device_coldplug (device, backend, native); + if (ret) + goto out; + g_object_unref (device); + + /* no valid USB object ;-( */ + device = NULL; + + } else if (g_strcmp0 (subsys, "input") == 0) { + + /* check input device */ + input = dkp_input_new (); + ret = dkp_input_coldplug (input, backend, native); + if (!ret) { + g_object_unref (input); + goto out; + } + + /* we now have a lid */ + g_object_set (backend->priv->daemon, + "lid-is-present, TRUE, + NULL); + + /* not a power device */ + dkp_device_list_insert (backend->priv->managed_devices, native, G_OBJECT (input)); + + /* no valid input object */ + device = NULL; + + } else { + native_path = g_udev_device_get_sysfs_path (native); + egg_warning ("native path %s (%s) ignoring", native_path, subsys); + } +out: + return device; +} + +/** + * dkp_backend_device_add: + **/ +static gboolean +dkp_backend_device_add (DkpBackend *backend, GUdevDevice *native, gboolean emit_signal) +{ + GObject *object; + DkpDevice *device; + gboolean ret = TRUE; + + /* does device exist in db? */ + object = dkp_device_list_lookup (backend->priv->device_list, native); + if (object != NULL) { + device = DKP_DEVICE (object); + /* we already have the device; treat as change event */ + egg_debug ("treating add event as change event on %s", dkp_device_get_object_path (device)); + dkp_backend_device_changed (backend, native, FALSE); + goto out; + } + + /* get the right sort of device */ + device = dkp_backend_device_get (backend, native); + if (device == NULL) { + egg_debug ("not adding device %s", g_udev_device_get_sysfs_path (native)); + ret = FALSE; + goto out; + } + + /* emit */ + g_signal_emit (backend, signals[SIGNAL_DEVICE_ADDED], 0, native, device, emit_signal); +out: + return ret; +} + +/** + * dkp_backend_device_remove: + **/ +static void +dkp_backend_device_remove (DkpBackend *backend, GUdevDevice *native) +{ + GObject *object; + DkpDevice *device; + + /* does device exist in db? */ + object = dkp_device_list_lookup (backend->priv->device_list, native); + if (object == NULL) { + egg_debug ("ignoring remove event on %s", g_udev_device_get_sysfs_path (native)); + } else { + device = DKP_DEVICE (object); + /* emit */ + g_signal_emit (backend, signals[SIGNAL_DEVICE_REMOVED], 0, native, device); + } +} + +/** + * dkp_backend_uevent_signal_handler_cb: + **/ +static void +dkp_backend_uevent_signal_handler_cb (GUdevClient *client, const gchar *action, + GUdevDevice *device, gpointer user_data) +{ + DkpBackend *backend = DKP_DAEMON (user_data); + + if (g_strcmp0 (action, "add") == 0) { + egg_debug ("add %s", g_udev_device_get_sysfs_path (device)); + dkp_backend_device_add (backend, device, TRUE); + } else if (g_strcmp0 (action, "remove") == 0) { + egg_debug ("remove %s", g_udev_device_get_sysfs_path (device)); + dkp_backend_device_remove (backend, device); + } else if (g_strcmp0 (action, "change") == 0) { + egg_debug ("change %s", g_udev_device_get_sysfs_path (device)); + dkp_backend_device_changed (backend, device, FALSE); + } else { + egg_warning ("unhandled action '%s' on %s", action, g_udev_device_get_sysfs_path (device)); + } +} + +/** + * dkp_backend_add_cb: + **/ +static gboolean +dkp_backend_add_cb (DkpBackend *backend) +{ + gboolean ret; + + /* coldplug */ + ret = dkp_device_coldplug (backend->priv->device, backend->priv->daemon, backend->priv->native); + if (!ret) { + egg_warning ("failed to coldplug"); + goto out; + } + + /* emit */ + g_signal_emit (backend, signals[SIGNAL_DEVICE_ADDED], 0, backend->priv->native, backend->priv->device, TRUE); +out: + return FALSE; +} + +/** + * dkp_backend_coldplug: + * @backend: The %DkpBackend class instance + * @daemon: The %DkpDaemon controlling instance + * + * Finds all the devices already plugged in, and emits device-add signals for + * each of them. + * + * Return value: %TRUE for success + **/ +gboolean +dkp_backend_coldplug (DkpBackend *backend, DkpDaemon *daemon) +{ + GUdevDevice *native; + GList *devices; + GList *l; + guint i; + const gchar *subsystems[] = {"power_supply", "usb", "tty", "input", NULL}; + + backend->priv->daemon = g_object_ref (daemon); + backend->priv->device_list = dkp_daemon_get_device_list (daemon); + + /* add all subsystems */ + for (i=0; subsystems[i] != NULL; i++) { + devices = g_udev_client_query_by_subsystem (backend->priv->gudev_client, subsystems[i]); + for (l = devices; l != NULL; l = l->next) { + native = l->data; + dkp_backend_device_add (backend, native, FALSE); + } + g_list_foreach (devices, (GFunc) g_object_unref, NULL); + g_list_free (devices); + } + + /* connect to the DeviceKit backend */ + for (i=0; subsystems[i] != NULL; i++) + egg_debug ("registering subsystem : %s", subsystems[i]); + backend->priv->gudev_client = g_udev_client_new (subsystems); + g_signal_connect (backend->priv->gudev_client, "uevent", + G_CALLBACK (dkp_backend_uevent_signal_handler_cb), backend); + + return TRUE; +} + +/** + * dkp_backend_class_init: + * @klass: The DkpBackendClass + **/ +static void +dkp_backend_class_init (DkpBackendClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->finalize = dkp_backend_finalize; + + signals [SIGNAL_DEVICE_ADDED] = + g_signal_new ("device-added", + G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DkpBackendClass, device_added), + NULL, NULL, dkp_marshal_VOID__POINTER_POINTER_BOOLEAN, + G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_BOOLEAN); + signals [SIGNAL_DEVICE_CHANGED] = + g_signal_new ("device-changed", + G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DkpBackendClass, device_changed), + NULL, NULL, dkp_marshal_VOID__POINTER_POINTER_BOOLEAN, + G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_BOOLEAN); + signals [SIGNAL_DEVICE_REMOVED] = + g_signal_new ("device-removed", + G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DkpBackendClass, device_removed), + NULL, NULL, dkp_marshal_VOID__POINTER_POINTER, + G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER); + + g_type_class_add_private (klass, sizeof (DkpBackendPrivate)); +} + +/** + * dkp_backend_init: + **/ +static void +dkp_backend_init (DkpBackend *backend) +{ + backend->priv = DKP_BACKEND_GET_PRIVATE (backend); + backend->priv->daemon = NULL; + backend->priv->device_list = NULL; + backend->priv->native = g_object_new (DKP_TYPE_DEVICE, NULL); + backend->priv->device = dkp_device_new (); + backend->priv->managed_devices = dkp_device_list_new (); +} + +/** + * dkp_backend_finalize: + **/ +static void +dkp_backend_finalize (GObject *object) +{ + DkpBackend *backend; + + g_return_if_fail (DKP_IS_BACKEND (object)); + + backend = DKP_BACKEND (object); + + if (backend->priv->daemon != NULL) + g_object_unref (backend->priv->daemon); + if (backend->priv->device_list != NULL) + g_object_unref (backend->priv->device_list); + if (backend->priv->gudev_client != NULL) + g_object_unref (backend->priv->gudev_client); + + g_object_unref (backend->priv->native); + g_object_unref (backend->priv->device); + g_object_unref (backend->priv->managed_devices); + + G_OBJECT_CLASS (dkp_backend_parent_class)->finalize (object); +} + +/** + * dkp_backend_new: + * + * Return value: a new %DkpBackend object. + **/ +DkpBackend * +dkp_backend_new (void) +{ + DkpBackend *backend; + backend = g_object_new (DKP_TYPE_BACKEND, NULL); + return DKP_BACKEND (backend); +} + diff --git a/src/dkp-device-csr.c b/src/linux/dkp-device-csr.c index 3397ab8..2110180 100644 --- a/src/dkp-device-csr.c +++ b/src/linux/dkp-device-csr.c @@ -141,7 +141,7 @@ dkp_device_csr_coldplug (DkpDevice *device) const gchar *product; /* detect what kind of device we are */ - d = dkp_device_get_d (device); + d = dkp_device_get_native (device); if (d == NULL) egg_error ("could not get device"); diff --git a/src/dkp-device-csr.h b/src/linux/dkp-device-csr.h index 04e101b..04e101b 100644 --- a/src/dkp-device-csr.h +++ b/src/linux/dkp-device-csr.h diff --git a/src/dkp-device-hid.c b/src/linux/dkp-device-hid.c index a2853e7..60abb9d 100644 --- a/src/dkp-device-hid.c +++ b/src/linux/dkp-device-hid.c @@ -315,7 +315,7 @@ dkp_device_hid_coldplug (DkpDevice *device) const gchar *vendor; /* detect what kind of device we are */ - d = dkp_device_get_d (device); + d = dkp_device_get_native (device); if (d == NULL) egg_error ("could not get device"); diff --git a/src/dkp-device-hid.h b/src/linux/dkp-device-hid.h index 8607331..8607331 100644 --- a/src/dkp-device-hid.h +++ b/src/linux/dkp-device-hid.h diff --git a/src/dkp-device-supply.c b/src/linux/dkp-device-supply.c index fb091a3..43ca7f1 100644 --- a/src/dkp-device-supply.c +++ b/src/linux/dkp-device-supply.c @@ -71,7 +71,7 @@ dkp_device_supply_refresh_line_power (DkpDeviceSupply *supply) GUdevDevice *d; const gchar *native_path; - d = dkp_device_get_d (device); + d = dkp_device_get_native (device); if (d == NULL) egg_error ("could not get device"); @@ -337,7 +337,7 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply) gboolean on_battery; guint battery_count; - d = dkp_device_get_d (device); + d = dkp_device_get_native (device); if (d == NULL) { egg_warning ("could not get device"); ret = FALSE; @@ -532,7 +532,7 @@ dkp_device_supply_refresh_battery (DkpDeviceSupply *supply) if (state == DKP_DEVICE_STATE_UNKNOWN) { /* get global battery status */ - daemon = dkp_device_get_daemon (device); + daemon = dkp_device_get_nativeaemon (device); g_object_get (daemon, "on-battery", &on_battery, NULL); @@ -640,7 +640,7 @@ dkp_device_supply_coldplug (DkpDevice *device) dkp_device_supply_reset_values (supply); /* detect what kind of device we are */ - d = dkp_device_get_d (device); + d = dkp_device_get_native (device); if (d == NULL) egg_error ("could not get device"); diff --git a/src/dkp-device-supply.h b/src/linux/dkp-device-supply.h index b767eac..b767eac 100644 --- a/src/dkp-device-supply.h +++ b/src/linux/dkp-device-supply.h diff --git a/src/dkp-device-wup.c b/src/linux/dkp-device-wup.c index 1eca160..a5373a0 100644 --- a/src/dkp-device-wup.c +++ b/src/linux/dkp-device-wup.c @@ -308,7 +308,7 @@ dkp_device_wup_coldplug (DkpDevice *device) const gchar *product; /* detect what kind of device we are */ - d = dkp_device_get_d (device); + d = dkp_device_get_native (device); if (d == NULL) egg_error ("could not get device"); diff --git a/src/dkp-device-wup.h b/src/linux/dkp-device-wup.h index 02eaa4b..02eaa4b 100644 --- a/src/dkp-device-wup.h +++ b/src/linux/dkp-device-wup.h diff --git a/src/dkp-input.c b/src/linux/dkp-input.c index e36f603..e36f603 100644 --- a/src/dkp-input.c +++ b/src/linux/dkp-input.c diff --git a/src/dkp-input.h b/src/linux/dkp-input.h index bae5005..bae5005 100644 --- a/src/dkp-input.h +++ b/src/linux/dkp-input.h diff --git a/src/sysfs-utils.c b/src/linux/sysfs-utils.c index bd7510b..bd7510b 100644 --- a/src/sysfs-utils.c +++ b/src/linux/sysfs-utils.c diff --git a/src/sysfs-utils.h b/src/linux/sysfs-utils.h index 43f3802..43f3802 100644 --- a/src/sysfs-utils.h +++ b/src/linux/sysfs-utils.h |