summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libupower-glib/up-client.c49
-rw-r--r--libupower-glib/up-client.h1
-rw-r--r--src/org.freedesktop.UPower.xml12
-rw-r--r--src/up-daemon.c26
-rw-r--r--src/up-daemon.h2
5 files changed, 90 insertions, 0 deletions
diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c
index 01ceeb8..2fb5280 100644
--- a/libupower-glib/up-client.c
+++ b/libupower-glib/up-client.c
@@ -64,6 +64,7 @@ struct _UpClientPrivate
gboolean on_battery;
gboolean on_low_battery;
gboolean lid_is_present;
+ gboolean is_docked;
gboolean done_enumerate;
};
@@ -84,6 +85,7 @@ enum {
PROP_ON_LOW_BATTERY,
PROP_LID_IS_CLOSED,
PROP_LID_IS_PRESENT,
+ PROP_IS_DOCKED,
PROP_LAST
};
@@ -406,6 +408,17 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
g_object_notify (G_OBJECT(client), "lid-is-present");
}
+ value = g_hash_table_lookup (props, "IsDocked");
+ if (value == NULL) {
+ g_warning ("No 'IsDocked' property");
+ goto out;
+ }
+ ret = g_value_get_boolean (value);
+ if (ret != client->priv->is_docked) {
+ client->priv->is_docked = ret;
+ g_object_notify (G_OBJECT(client), "is-docked");
+ }
+
/* cached */
client->priv->have_properties = TRUE;
@@ -488,6 +501,24 @@ up_client_get_lid_is_present (UpClient *client)
}
/**
+ * up_client_get_is_docked:
+ * @client: a #UpClient instance.
+ *
+ * Get whether the machine is docked into a docking station.
+ *
+ * Return value: %TRUE if the machine is docked
+ *
+ * Since: 0.9.2
+ */
+gboolean
+up_client_get_is_docked (UpClient *client)
+{
+ g_return_val_if_fail (UP_IS_CLIENT (client), FALSE);
+ up_client_get_properties_sync (client, NULL, NULL);
+ return client->priv->is_docked;
+}
+
+/**
* up_client_get_can_suspend:
* @client: a #UpClient instance.
*
@@ -650,6 +681,9 @@ up_client_get_property (GObject *object,
case PROP_LID_IS_PRESENT:
g_value_set_boolean (value, client->priv->lid_is_present);
break;
+ case PROP_IS_DOCKED:
+ g_value_set_boolean (value, client->priv->is_docked);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -768,6 +802,21 @@ up_client_class_init (UpClientClass *klass)
G_PARAM_READABLE));
/**
+ * UpClient:is-docked:
+ *
+ * If the laptop is docked
+ *
+ * Since: 0.9.8
+ */
+ g_object_class_install_property (object_class,
+ PROP_IS_DOCKED,
+ g_param_spec_boolean ("is-docked",
+ "If a laptop is docked",
+ NULL,
+ FALSE,
+ G_PARAM_READABLE));
+
+ /**
* UpClient::device-added:
* @client: the #UpClient instance that emitted the signal
* @device: the #UpDevice that was added.
diff --git a/libupower-glib/up-client.h b/libupower-glib/up-client.h
index 642999b..05c8a07 100644
--- a/libupower-glib/up-client.h
+++ b/libupower-glib/up-client.h
@@ -99,6 +99,7 @@ const gchar *up_client_get_daemon_version (UpClient *client);
gboolean up_client_get_can_hibernate (UpClient *client);
gboolean up_client_get_lid_is_closed (UpClient *client);
gboolean up_client_get_lid_is_present (UpClient *client);
+gboolean up_client_get_is_docked (UpClient *client);
gboolean up_client_get_can_suspend (UpClient *client);
gboolean up_client_get_on_battery (UpClient *client);
gboolean up_client_get_on_low_battery (UpClient *client);
diff --git a/src/org.freedesktop.UPower.xml b/src/org.freedesktop.UPower.xml
index 5a5fe57..6cb636d 100644
--- a/src/org.freedesktop.UPower.xml
+++ b/src/org.freedesktop.UPower.xml
@@ -304,6 +304,18 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2
</doc:doc>
</property>
+ <property name="IsDocked" type="b" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ If the system is currently docked.
+ Note: the "is-docked" value is the result of a heuristic,
+ which may involve testing the display output.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </property>
+
</interface>
</node>
diff --git a/src/up-daemon.c b/src/up-daemon.c
index 4587649..dbdb488 100644
--- a/src/up-daemon.c
+++ b/src/up-daemon.c
@@ -51,6 +51,7 @@ enum
PROP_ON_LOW_BATTERY,
PROP_LID_IS_CLOSED,
PROP_LID_IS_PRESENT,
+ PROP_IS_DOCKED,
PROP_LAST
};
@@ -78,6 +79,7 @@ struct UpDaemonPrivate
gboolean on_low_battery;
gboolean lid_is_closed;
gboolean lid_is_present;
+ gboolean is_docked;
gboolean kernel_can_suspend;
gboolean kernel_can_hibernate;
gboolean hibernate_has_encrypted_swap;
@@ -773,6 +775,18 @@ up_daemon_set_lid_is_present (UpDaemon *daemon, gboolean lid_is_present)
}
/**
+ * up_daemon_set_is_docked:
+ **/
+void
+up_daemon_set_is_docked (UpDaemon *daemon, gboolean is_docked)
+{
+ UpDaemonPrivate *priv = daemon->priv;
+ g_debug ("is_docked = %s", is_docked ? "yes" : "no");
+ priv->is_docked = is_docked;
+ g_object_notify (G_OBJECT (daemon), "is-docked");
+}
+
+/**
* up_daemon_set_on_battery:
**/
void
@@ -1001,6 +1015,7 @@ up_daemon_init (UpDaemon *daemon)
daemon->priv = UP_DAEMON_GET_PRIVATE (daemon);
daemon->priv->polkit = up_polkit_new ();
daemon->priv->lid_is_present = FALSE;
+ daemon->priv->is_docked = FALSE;
daemon->priv->lid_is_closed = FALSE;
daemon->priv->kernel_can_suspend = FALSE;
daemon->priv->kernel_can_hibernate = FALSE;
@@ -1135,6 +1150,9 @@ up_daemon_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
case PROP_LID_IS_PRESENT:
g_value_set_boolean (value, priv->lid_is_present);
break;
+ case PROP_IS_DOCKED:
+ g_value_set_boolean (value, priv->is_docked);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1232,6 +1250,14 @@ up_daemon_class_init (UpDaemonClass *klass)
G_PARAM_READABLE));
g_object_class_install_property (object_class,
+ PROP_IS_DOCKED,
+ g_param_spec_boolean ("is-docked",
+ "Is docked",
+ "If this computer is docked",
+ FALSE,
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class,
PROP_CAN_SUSPEND,
g_param_spec_boolean ("can-suspend",
"Can Suspend",
diff --git a/src/up-daemon.h b/src/up-daemon.h
index e240d1e..4d92b19 100644
--- a/src/up-daemon.h
+++ b/src/up-daemon.h
@@ -77,6 +77,8 @@ void up_daemon_set_lid_is_closed (UpDaemon *daemon,
gboolean lid_is_closed);
void up_daemon_set_lid_is_present (UpDaemon *daemon,
gboolean lid_is_present);
+void up_daemon_set_is_docked (UpDaemon *daemon,
+ gboolean is_docked);
void up_daemon_set_on_battery (UpDaemon *daemon,
gboolean on_battery);
void up_daemon_set_on_low_battery (UpDaemon *daemon,