Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 2/4] obex-client: Port session code to use D-Bus properties interface
Date: Fri, 14 Dec 2012 23:31:58 +0200	[thread overview]
Message-ID: <1355520720-11731-2-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1355520720-11731-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 doc/obex-client-api.txt |  6 +---
 obexd/client/session.c  | 86 ++++++++++++++++++++++++++++---------------------
 2 files changed, 51 insertions(+), 41 deletions(-)

diff --git a/doc/obex-client-api.txt b/doc/obex-client-api.txt
index 19c8541..f516760 100644
--- a/doc/obex-client-api.txt
+++ b/doc/obex-client-api.txt
@@ -43,11 +43,7 @@ Service		org.bluez.obex.client
 Interface	org.bluez.obex.Session
 Object path	[variable prefix]/{session0,session1,...}
 
-Methods		dict GetProperties()
-
-			Returns all properties for the session.
-
-		string GetCapabilities()
+Methods		string GetCapabilities()
 
 			Get remote device capabilities.
 
diff --git a/obexd/client/session.c b/obexd/client/session.c
index 2bac229..40d6c9c 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
@@ -524,39 +524,6 @@ void obc_session_shutdown(struct obc_session *session)
 	obc_session_unref(session);
 }
 
-static DBusMessage *session_get_properties(DBusConnection *connection,
-				DBusMessage *message, void *user_data)
-{
-	struct obc_session *session = user_data;
-	DBusMessage *reply;
-	DBusMessageIter iter, dict;
-
-	reply = dbus_message_new_method_return(message);
-	if (!reply)
-		return NULL;
-
-	dbus_message_iter_init_append(reply, &iter);
-
-	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
-			DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
-			DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
-			DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
-
-	if (session->source != NULL)
-		obex_dbus_dict_append(&dict, "Source", DBUS_TYPE_STRING,
-							&session->source);
-
-	obex_dbus_dict_append(&dict, "Destination", DBUS_TYPE_STRING,
-							&session->destination);
-
-	obex_dbus_dict_append(&dict, "Channel", DBUS_TYPE_BYTE,
-							&session->channel);
-
-	dbus_message_iter_close_container(&iter, &dict);
-
-	return reply;
-}
-
 static void capabilities_complete_callback(struct obc_session *session,
 						struct obc_transfer *transfer,
 						GError *err, void *user_data)
@@ -621,16 +588,63 @@ fail:
 
 }
 
+static gboolean get_source(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct obc_session *session = data;
+
+	if (session->source == NULL)
+		return FALSE;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
+							&session->source);
+
+	return TRUE;
+}
+
+static gboolean source_exists(const GDBusPropertyTable *property, void *data)
+{
+	struct obc_session *session = data;
+
+	return session->source != NULL;
+}
+
+static gboolean get_destination(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct obc_session *session = data;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
+							&session->destination);
+
+	return TRUE;
+}
+
+static gboolean get_channel(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct obc_session *session = data;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE,
+							&session->channel);
+
+	return TRUE;
+}
+
 static const GDBusMethodTable session_methods[] = {
-	{ GDBUS_METHOD("GetProperties",
-				NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
-				session_get_properties) },
 	{ GDBUS_ASYNC_METHOD("GetCapabilities",
 				NULL, GDBUS_ARGS({ "capabilities", "s" }),
 				get_capabilities) },
 	{ }
 };
 
+static const GDBusPropertyTable session_properties[] = {
+	{ "Source", "s", get_source, NULL, source_exists },
+	{ "Destination", "s", get_destination },
+	{ "Channel", "y", get_channel },
+	{ }
+};
+
 static gboolean session_queue_complete(gpointer data)
 {
 	struct obc_session *session = data;
-- 
1.7.11.7


  reply	other threads:[~2012-12-14 21:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-14 21:31 [PATCH BlueZ 1/4] obex-client: Port MAP module to use D-Bus properties interface Luiz Augusto von Dentz
2012-12-14 21:31 ` Luiz Augusto von Dentz [this message]
2012-12-14 21:31 ` [PATCH BlueZ 3/4] obex-client: Port transfer code " Luiz Augusto von Dentz
2012-12-14 21:32 ` [PATCH BlueZ 4/4] test: Update map-client " Luiz Augusto von Dentz
2012-12-16 11:28 ` [PATCH BlueZ 1/4] obex-client: Port MAP module " Johan Hedberg

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=1355520720-11731-2-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --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