summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/linux/Makefile.am1
-rw-r--r--src/linux/up-backend.c34
-rw-r--r--src/linux/up-dock.c19
-rw-r--r--src/linux/up-dock.h2
4 files changed, 53 insertions, 3 deletions
diff --git a/src/linux/Makefile.am b/src/linux/Makefile.am
index d19b20d..c4646f7 100644
--- a/src/linux/Makefile.am
+++ b/src/linux/Makefile.am
@@ -5,6 +5,7 @@ INCLUDES = \
-DUP_COMPILATION \
-DG_UDEV_API_IS_SUBJECT_TO_CHANGE \
-DG_LOG_DOMAIN=\"UPower-Linux\" \
+ -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \
-I$(top_srcdir)/libupower-glib \
$(USB_CFLAGS) \
$(GIO_CFLAGS) \
diff --git a/src/linux/up-backend.c b/src/linux/up-backend.c
index c671d2d..069ca9b 100644
--- a/src/linux/up-backend.c
+++ b/src/linux/up-backend.c
@@ -284,6 +284,38 @@ up_backend_uevent_signal_handler_cb (GUdevClient *client, const gchar *action,
}
/**
+ * up_backend_should_poll_docks:
+ **/
+static gboolean
+up_backend_should_poll_docks (void)
+{
+ gboolean ret;
+ GKeyFile *keyfile;
+ GError *error = NULL;
+
+ /* get the settings from the config file */
+ keyfile = g_key_file_new ();
+ ret = g_key_file_load_from_file (keyfile,
+ PACKAGE_SYSCONF_DIR "/UPower/UPower.conf",
+ G_KEY_FILE_NONE,
+ &error);
+ if (!ret) {
+ g_error ("Failed to get poll setting, assuming FALSE: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
+ ret = g_key_file_get_boolean (keyfile,
+ "UPower",
+ "PollDockDevices",
+ NULL);
+ g_debug ("Polling docks: %s", ret ? "YES" : "NO");
+out:
+ g_key_file_free (keyfile);
+ return ret;
+}
+
+/**
* up_backend_coldplug:
* @backend: The %UpBackend class instance
* @daemon: The %UpDaemon controlling instance
@@ -323,6 +355,8 @@ up_backend_coldplug (UpBackend *backend, UpDaemon *daemon)
/* add dock update object */
backend->priv->dock = up_dock_new ();
+ ret = up_backend_should_poll_docks ();
+ up_dock_set_should_poll (backend->priv->dock, ret);
ret = up_dock_coldplug (backend->priv->dock, daemon);
if (!ret)
g_warning ("failed to coldplug dock devices");
diff --git a/src/linux/up-dock.c b/src/linux/up-dock.c
index 59475f7..78fb7d3 100644
--- a/src/linux/up-dock.c
+++ b/src/linux/up-dock.c
@@ -106,14 +106,27 @@ up_dock_poll_cb (UpDock *dock)
/**
* up_dock_coldplug:
**/
+void
+up_dock_set_should_poll (UpDock *dock, gboolean should_poll)
+{
+ if (should_poll && dock->priv->poll_id == 0) {
+ dock->priv->poll_id = g_timeout_add_seconds (UP_DOCK_POLL_TIMEOUT,
+ (GSourceFunc) up_dock_poll_cb,
+ dock);
+ } else if (dock->priv->poll_id > 0) {
+ g_source_remove (dock->priv->poll_id);
+ dock->priv->poll_id = 0;
+ }
+}
+
+/**
+ * up_dock_coldplug:
+ **/
gboolean
up_dock_coldplug (UpDock *dock, UpDaemon *daemon)
{
/* save daemon */
dock->priv->daemon = g_object_ref (daemon);
- dock->priv->poll_id = g_timeout_add_seconds (UP_DOCK_POLL_TIMEOUT,
- (GSourceFunc) up_dock_poll_cb,
- dock);
return up_dock_refresh (dock);
}
diff --git a/src/linux/up-dock.h b/src/linux/up-dock.h
index 1f7c80a..0c79251 100644
--- a/src/linux/up-dock.h
+++ b/src/linux/up-dock.h
@@ -51,6 +51,8 @@ GType up_dock_get_type (void);
UpDock *up_dock_new (void);
gboolean up_dock_coldplug (UpDock *dock,
UpDaemon *daemon);
+void up_dock_set_should_poll (UpDock *dock,
+ gboolean should_poll);
G_END_DECLS