summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2009-07-02 17:51:27 +0100
committerRichard Hughes <richard@hughsie.com>2009-07-02 17:51:27 +0100
commit56881f8eafbfbcf8bf774e2d8ed31eda4943872a (patch)
tree426a112ca39b900245f5fdf14d07c0875cedeb76
parent936c57bf60f28531afe136b470cf2709beec49b5 (diff)
Add a lid-is-present property
-rw-r--r--devkit-power-gobject/dkp-client.c46
-rw-r--r--devkit-power-gobject/dkp-client.h1
-rw-r--r--src/dkp-daemon.c19
-rw-r--r--src/org.freedesktop.DeviceKit.Power.xml11
4 files changed, 71 insertions, 6 deletions
diff --git a/devkit-power-gobject/dkp-client.c b/devkit-power-gobject/dkp-client.c
index c547d00..8754d5c 100644
--- a/devkit-power-gobject/dkp-client.c
+++ b/devkit-power-gobject/dkp-client.c
@@ -50,6 +50,7 @@ struct DkpClientPrivate
gboolean lid_is_closed;
gboolean on_battery;
gboolean on_low_battery;
+ gboolean lid_is_present;
};
enum {
@@ -67,7 +68,9 @@ enum {
PROP_CAN_HIBERNATE,
PROP_ON_BATTERY,
PROP_ON_LOW_BATTERY,
- PROP_LID_IS_CLOSED
+ PROP_LID_IS_CLOSED,
+ PROP_LID_IS_PRESENT,
+ PROP_LAST
};
static guint signals [DKP_CLIENT_LAST_SIGNAL] = { 0 };
@@ -293,6 +296,13 @@ dkp_client_ensure_properties (DkpClient *client)
}
client->priv->on_low_battery = g_value_get_boolean (value);
+ value = g_hash_table_lookup (props, "lid-is-present");
+ if (value == NULL) {
+ g_warning ("No 'lid-is-present' property");
+ goto out;
+ }
+ client->priv->lid_is_present = g_value_get_boolean (value);
+
/* cached */
client->priv->have_properties = TRUE;
@@ -339,7 +349,7 @@ dkp_client_can_hibernate (DkpClient *client)
*
* Get whether the laptop lid is closed.
*
- * Return value: TRUE if lid is closed FALSE other wise.
+ * Return value: %TRUE if lid is closed or %FALSE otherwise.
*/
gboolean
dkp_client_lid_is_closed (DkpClient *client)
@@ -350,6 +360,22 @@ dkp_client_lid_is_closed (DkpClient *client)
}
/**
+ * dkp_client_get_lid_is_present:
+ * @client : a #DkpClient instance.
+ *
+ * Gets if the system has a lide device.
+ *
+ * Return value: %TRUE if system has a lid that can be closed or %FALSE otherwise.
+ */
+gboolean
+dkp_client_get_lid_is_present (DkpClient *client)
+{
+ g_return_val_if_fail (DKP_IS_CLIENT (client), FALSE);
+ dkp_client_ensure_properties (client);
+ return client->priv->lid_is_present;
+}
+
+/**
* dkp_client_can_suspend:
* @client : a #DkpClient instance.
*
@@ -479,18 +505,21 @@ dkp_client_get_property (GObject *object,
case PROP_CAN_SUSPEND:
g_value_set_boolean (value, client->priv->can_suspend);
break;
- case PROP_CAN_HIBERNATE:
+ case PROP_CAN_HIBERNATE:
g_value_set_boolean (value, client->priv->can_hibernate);
break;
case PROP_ON_BATTERY:
g_value_set_boolean (value, client->priv->on_battery);
break;
- case PROP_ON_LOW_BATTERY:
+ case PROP_ON_LOW_BATTERY:
g_value_set_boolean (value, client->priv->on_low_battery);
break;
- case PROP_LID_IS_CLOSED:
+ case PROP_LID_IS_CLOSED:
g_value_set_boolean (value, client->priv->lid_is_closed);
break;
+ case PROP_LID_IS_PRESENT:
+ g_value_set_boolean (value, client->priv->lid_is_present);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -553,6 +582,13 @@ dkp_client_class_init (DkpClientClass *klass)
FALSE,
G_PARAM_READABLE));
+ g_object_class_install_property (object_class,
+ PROP_LID_IS_PRESENT,
+ g_param_spec_boolean ("lid-is-present",
+ NULL, NULL,
+ FALSE,
+ G_PARAM_READABLE));
+
signals [DKP_DEVICE_ADDED] =
g_signal_new ("device-added",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/devkit-power-gobject/dkp-client.h b/devkit-power-gobject/dkp-client.h
index 722ad5b..e50d8e3 100644
--- a/devkit-power-gobject/dkp-client.h
+++ b/devkit-power-gobject/dkp-client.h
@@ -85,6 +85,7 @@ gboolean dkp_client_lid_is_closed (DkpClient *client);
gboolean dkp_client_can_suspend (DkpClient *client);
gboolean dkp_client_on_battery (DkpClient *client);
gboolean dkp_client_on_low_battery (DkpClient *client);
+gboolean dkp_client_get_lid_is_present (DkpClient *client);
G_END_DECLS
diff --git a/src/dkp-daemon.c b/src/dkp-daemon.c
index 1362bdf..895b769 100644
--- a/src/dkp-daemon.c
+++ b/src/dkp-daemon.c
@@ -56,6 +56,8 @@ enum
PROP_ON_BATTERY,
PROP_ON_LOW_BATTERY,
PROP_LID_IS_CLOSED,
+ PROP_LID_IS_PRESENT,
+ PROP_LAST
};
enum
@@ -82,6 +84,7 @@ struct DkpDaemonPrivate
gboolean low_battery;
DevkitClient *devkit_client;
gboolean lid_is_closed;
+ gboolean lid_is_present;
};
static void dkp_daemon_class_init (DkpDaemonClass *klass);
@@ -220,6 +223,10 @@ dkp_daemon_get_property (GObject *object,
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;
@@ -282,6 +289,14 @@ dkp_daemon_class_init (DkpDaemonClass *klass)
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",
@@ -334,6 +349,7 @@ dkp_daemon_init (DkpDaemon *daemon)
{
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;
}
@@ -595,6 +611,9 @@ dkp_daemon_device_get (DkpDaemon *daemon, DevkitDevice *d)
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));
diff --git a/src/org.freedesktop.DeviceKit.Power.xml b/src/org.freedesktop.DeviceKit.Power.xml
index 6b5ce03..dd310cd 100644
--- a/src/org.freedesktop.DeviceKit.Power.xml
+++ b/src/org.freedesktop.DeviceKit.Power.xml
@@ -129,7 +129,6 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2
<!-- ************************************************************ -->
-
<property name="daemon-version" type="s" access="read">
<doc:doc><doc:description><doc:para>
Version of the running daemon, e.g. <doc:tt>002</doc:tt>.
@@ -172,6 +171,16 @@ method return sender=:1.386 -> dest=:1.451 reply_serial=2
</doc:doc>
</property>
+ <property name="lid-is-present" type="b" access="read">
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ If the system has a lid device.
+ </doc:para>
+ </doc:description>
+ </doc:doc>
+ </property>
+
<signal name="Changed">
<doc:doc>
<doc:description>