Commit 180503eb authored by Emilio Pozuelo Monfort's avatar Emilio Pozuelo Monfort Committed by Thomas Haller

bluez: listen to Connected changes in NMBluezDevice

parent f422acc9
......@@ -48,6 +48,7 @@ typedef struct {
char *name;
guint32 capabilities;
gint rssi;
gboolean connected;
NMConnectionProvider *provider;
GSList *connections;
......@@ -62,6 +63,7 @@ enum {
PROP_CAPABILITIES,
PROP_RSSI,
PROP_USABLE,
PROP_CONNECTED,
LAST_PROP
};
......@@ -131,6 +133,14 @@ nm_bluez_device_get_rssi (NMBluezDevice *self)
return NM_BLUEZ_DEVICE_GET_PRIVATE (self)->rssi;
}
gboolean
nm_bluez_device_get_connected (NMBluezDevice *self)
{
g_return_val_if_fail (NM_IS_BLUEZ_DEVICE (self), FALSE);
return NM_BLUEZ_DEVICE_GET_PRIVATE (self)->connected;
}
static void
check_emit_usable (NMBluezDevice *self)
{
......@@ -297,6 +307,12 @@ property_changed (DBusGProxy *proxy,
priv->capabilities = uint_val;
g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_CAPABILITIES);
}
} else if (!strcmp (property, "Connected")) {
gboolean connected = g_value_get_boolean (value);
if (priv->connected != connected) {
priv->connected = connected;
g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_CONNECTED);
}
}
check_emit_usable (self);
......@@ -494,6 +510,9 @@ get_property (GObject *object, guint prop_id,
case PROP_USABLE:
g_value_set_boolean (value, priv->usable);
break;
case PROP_CONNECTED:
g_value_set_boolean (value, priv->connected);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -579,6 +598,14 @@ nm_bluez_device_class_init (NMBluezDeviceClass *config_class)
FALSE,
G_PARAM_READABLE));
g_object_class_install_property
(object_class, PROP_CONNECTED,
g_param_spec_boolean (NM_BLUEZ_DEVICE_CONNECTED,
"Connected",
"Connected",
FALSE,
G_PARAM_READABLE));
/* Signals */
signals[INITIALIZED] = g_signal_new ("initialized",
G_OBJECT_CLASS_TYPE (object_class),
......
......@@ -40,6 +40,7 @@
#define NM_BLUEZ_DEVICE_CAPABILITIES "capabilities"
#define NM_BLUEZ_DEVICE_RSSI "rssi"
#define NM_BLUEZ_DEVICE_USABLE "usable"
#define NM_BLUEZ_DEVICE_CONNECTED "connected"
typedef struct {
GObject parent;
......@@ -74,5 +75,7 @@ guint32 nm_bluez_device_get_capabilities (NMBluezDevice *self);
gint nm_bluez_device_get_rssi (NMBluezDevice *self);
gboolean nm_bluez_device_get_connected (NMBluezDevice *self);
#endif /* NM_BLUEZ_DEVICE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment