linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gustavo Padovan <gustavo@padovan.org>
To: linux-bluetooth@vger.kernel.org
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Subject: [RFC v1 7/9] adapter: add Pairing property to report ongoing Pairing Session
Date: Tue, 11 Jun 2013 01:03:29 +0100	[thread overview]
Message-ID: <1370909011-19315-7-git-send-email-gustavo@padovan.org> (raw)
In-Reply-To: <1370909011-19315-1-git-send-email-gustavo@padovan.org>

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Pairing is a readonly property that will be true whenever on or more
Pairing Sessions are running.
---
 src/adapter.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 5e8c675..f4b0892 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -169,8 +169,11 @@ struct btd_adapter {
 	GSList *connections;		/* Connected devices */
 	GSList *devices;		/* Devices structure pointers */
 	GSList *connect_list;		/* Devices to connect when found */
+
+	bool pairing;			/* pairing property state */
 	uint32_t pairing_settings;	/* settings before pairing session*/
 	GSList *pairing_list;		/* list of pairing sessions */
+
 	struct btd_device *connect_le;	/* LE device waiting to be connected */
 	sdp_list_t *services;		/* Services associated to adapter */
 
@@ -1734,6 +1737,11 @@ static void discoverable_disconnect(DBusConnection *conn, void *user_data)
 
 	if (!(adapter->pairing_settings & MGMT_SETTING_PAIRABLE))
 		set_mode(adapter, MGMT_OP_SET_PAIRABLE, 0x00);
+
+	adapter->pairing = false;
+
+	g_dbus_emit_property_changed(dbus_conn, adapter->path,
+					ADAPTER_INTERFACE, "Pairing");
 }
 
 static DBusMessage *request_pairing_session(DBusConnection *conn,
@@ -1781,6 +1789,11 @@ static DBusMessage *request_pairing_session(DBusConnection *conn,
 	if (!(adapter->pairing_settings & MGMT_SETTING_PAIRABLE))
 		set_mode(adapter, MGMT_OP_SET_PAIRABLE, 0x01);
 
+	adapter->pairing = true;
+
+	g_dbus_emit_property_changed(dbus_conn, adapter->path,
+					ADAPTER_INTERFACE, "Pairing");
+
 	return dbus_message_new_method_return(msg);
 }
 
@@ -1821,6 +1834,11 @@ static DBusMessage *release_pairing_session(DBusConnection *conn,
 	if (!(adapter->pairing_settings & MGMT_SETTING_PAIRABLE))
 		set_mode(adapter, MGMT_OP_SET_PAIRABLE, 0x00);
 
+	adapter->pairing = false;
+
+	g_dbus_emit_property_changed(dbus_conn, adapter->path,
+					ADAPTER_INTERFACE, "Pairing");
+
 	return dbus_message_new_method_return(msg);
 }
 
@@ -2175,6 +2193,17 @@ static void property_set_pairable_timeout(const GDBusPropertyTable *property,
 	trigger_pairable_timeout(adapter);
 }
 
+static gboolean property_get_pairing(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *user_data)
+{
+	struct btd_adapter *adapter = user_data;
+	dbus_bool_t pairing = adapter->pairing;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &pairing);
+
+	return TRUE;
+}
+
 static gboolean property_get_discovering(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *user_data)
 {
@@ -2300,6 +2329,7 @@ static const GDBusPropertyTable adapter_properties[] = {
 	{ "Pairable", "b", property_get_pairable, property_set_pairable },
 	{ "PairableTimeout", "u", property_get_pairable_timeout,
 					property_set_pairable_timeout },
+	{ "Pairing", "b", property_get_pairing },
 	{ "Discovering", "b", property_get_discovering },
 	{ "UUIDs", "as", property_get_uuids },
 	{ "Modalias", "s", property_get_modalias, NULL,
-- 
1.8.1.4


  parent reply	other threads:[~2013-06-11  0:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-11  0:03 [RFC v1 1/9] adapter: fix setting of discoverable timeout Gustavo Padovan
2013-06-11  0:03 ` [RFC v1 2/9] adapter: remove unused toggle_discoverable Gustavo Padovan
2013-06-11  0:03 ` [RFC v1 3/9] adapter: rename discovery_client to watch_client Gustavo Padovan
2013-06-11  0:03 ` [RFC v1 4/9] adapter: rename compare_discovery_sender Gustavo Padovan
2013-06-11  0:03 ` [RFC v1 5/9] doc: add RequestPairingSession() and ReleasePairingSession() Gustavo Padovan
2013-06-11  1:22   ` Marcel Holtmann
2013-06-11 10:00   ` Bastien Nocera
2013-06-11 10:07     ` Gustavo Padovan
2013-06-11 10:14       ` Bastien Nocera
2013-06-11  0:03 ` [RFC v1 6/9] adapter: " Gustavo Padovan
2013-06-11  0:03 ` Gustavo Padovan [this message]
2013-06-11  0:03 ` [RFC v1 8/9] adapter: forbid properties to be set during Pairing Session Gustavo Padovan
2013-06-11  0:03 ` [RFC v1 9/9] test: add pairing command to test-adapter Gustavo Padovan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1370909011-19315-7-git-send-email-gustavo@padovan.org \
    --to=gustavo@padovan.org \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).