[gnome-bluetooth/moblin-dev: 2/4] Make default-adaptor-powered a read/write property



commit 87a54402b91b424fe57f2000c4bf6105068afa4d
Author: Ross Burton <ross linux intel com>
Date:   Mon Jan 25 17:21:06 2010 +0000

    Make default-adaptor-powered a read/write property

 lib/bluetooth-client.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index 06fd7be..967c113 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -1217,6 +1217,35 @@ bluetooth_client_get_property (GObject        *object,
 	}
 }
 
+static void
+bluetooth_client_set_property (GObject      *object,
+			       guint         property_id,
+			       const GValue *value,
+			       GParamSpec   *pspec)
+{
+	switch (property_id) {
+	case PROP_DEFAULT_ADAPTER_POWERED:
+		{
+			DBusGProxy *adapter;
+
+			adapter = bluetooth_client_get_default_adapter (BLUETOOTH_CLIENT (object));
+			if (adapter == NULL)
+				return;
+
+			dbus_g_proxy_call (adapter, "SetProperty", NULL,
+					   G_TYPE_STRING, "Powered",
+					   G_TYPE_VALUE, value,
+					   G_TYPE_INVALID, G_TYPE_INVALID);
+
+			g_object_unref (adapter);
+		}
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+		break;
+	}
+}
+
 static void bluetooth_client_finalize(GObject *client)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
@@ -1254,6 +1283,7 @@ static void bluetooth_client_class_init(BluetoothClientClass *klass)
 
 	object_class->finalize = bluetooth_client_finalize;
 	object_class->get_property = bluetooth_client_get_property;
+	object_class->set_property = bluetooth_client_set_property;
 
 
 	g_object_class_install_property (object_class, PROP_DEFAULT_ADAPTER,
@@ -1261,7 +1291,7 @@ static void bluetooth_client_class_init(BluetoothClientClass *klass)
 							      NULL, G_PARAM_READABLE));
 	g_object_class_install_property (object_class, PROP_DEFAULT_ADAPTER_POWERED,
 					 g_param_spec_boolean ("default-adapter-powered", NULL, NULL,
-					 		       FALSE, G_PARAM_READABLE));
+					 		       FALSE, G_PARAM_READWRITE));
 
 	dbus_g_object_register_marshaller(marshal_VOID__STRING_BOXED,
 						G_TYPE_NONE, G_TYPE_STRING,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]