summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-09-23 16:19:11 -0700
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-09-23 17:54:01 -0700
commit76e387a844f84c8115442058f5b13f4e3170d1e3 (patch)
tree1630108d6a3e4a6be8ddd370b0086b4929c9c4b8 /src
parenta34ec607308e143df09848025decbeae9c2d98f2 (diff)
Make Powered/Discoverable properties changeable via SetProperty.
Diffstat (limited to 'src')
-rw-r--r--src/adapter.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/adapter.c b/src/adapter.c
index eb40f854..b4a74a36 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -597,6 +597,36 @@ done:
return dbus_message_new_method_return(msg);
}
+static DBusMessage *set_powered(DBusConnection *conn, DBusMessage *msg,
+ gboolean powered, void *data)
+{
+ struct btd_adapter *adapter = data;
+ uint8_t mode;
+
+ mode = powered ? get_mode(&adapter->bdaddr, "on") : MODE_OFF;
+
+ if (mode == adapter->mode)
+ return dbus_message_new_method_return(msg);
+
+ return set_mode(conn, msg, mode, data);
+}
+
+static DBusMessage *set_discoverable(DBusConnection *conn, DBusMessage *msg,
+ gboolean discoverable, void *data)
+{
+ struct btd_adapter *adapter = data;
+ const char *strmode;
+ uint8_t mode;
+
+ strmode = discoverable ? "discoverable" : "connectable";
+ mode = get_mode(&adapter->bdaddr, strmode);
+
+ if (mode == adapter->mode)
+ return dbus_message_new_method_return(msg);
+
+ return set_mode(conn, msg, mode, data);
+}
+
static struct session_req *find_session(GSList *list, DBusMessage *msg)
{
GSList *l;
@@ -1645,6 +1675,24 @@ static DBusMessage *set_property(DBusConnection *conn,
return set_mode(conn, msg, get_mode(&adapter->bdaddr, mode),
data);
+ } else if (g_str_equal("Powered", property)) {
+ gboolean powered;
+
+ if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_BOOLEAN)
+ return invalid_args(msg);
+
+ dbus_message_iter_get_basic(&sub, &powered);
+
+ return set_powered(conn, msg, powered, data);
+ } else if (g_str_equal("Discoverable", property)) {
+ gboolean discoverable;
+
+ if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_BOOLEAN)
+ return invalid_args(msg);
+
+ dbus_message_iter_get_basic(&sub, &discoverable);
+
+ return set_discoverable(conn, msg, discoverable, data);
}
return invalid_args(msg);