linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties
@ 2012-12-17 11:50 Luiz Augusto von Dentz
  2012-12-17 11:50 ` [PATCH BlueZ 2/5] obexd: Enable ObjectManager Luiz Augusto von Dentz
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-12-17 11:50 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 doc/obexd-api.txt   | 12 ++++--------
 obexd/src/manager.c | 50 ++++++++++++++++++--------------------------------
 2 files changed, 22 insertions(+), 40 deletions(-)

diff --git a/doc/obexd-api.txt b/doc/obexd-api.txt
index 680febe..53e61f5 100644
--- a/doc/obexd-api.txt
+++ b/doc/obexd-api.txt
@@ -74,14 +74,10 @@ Service		org.bluez.obex
 Interface	org.bluez.obex.Session
 Object path	/session{0, 1, 2, ...}
 
-Methods
-		dict GetProperties()
-
-
-Signals		TBD
+Properties	string Target [readonly]
 
+			Target UUID
 
-Properties
-		string Address [readonly]
+		string Root [readonly]
 
-			Bluetooth device address or USB
+			Root path
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 02dc999..85aa965 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -255,42 +255,29 @@ static char *target2str(const uint8_t *t)
 				t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15]);
 }
 
-static DBusMessage *get_properties(DBusConnection *conn,
-				DBusMessage *msg, void *data)
+static gboolean get_target(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
 {
 	struct obex_session *os = data;
-	DBusMessage *reply;
-	DBusMessageIter iter;
-	DBusMessageIter dict;
 	char *uuid;
-	const char *root;
-
-	reply = dbus_message_new_method_return(msg);
-	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);
-
-	/* Target */
 	uuid = target2str(os->service->target);
-	dbus_message_iter_append_dict_entry(&dict, "Target",
-					DBUS_TYPE_STRING, &uuid);
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &uuid);
 	g_free(uuid);
 
-	/* Root folder */
-	root = obex_option_root_folder();
-	dbus_message_iter_append_dict_entry(&dict, "Root",
-					DBUS_TYPE_STRING, &root);
+	return TRUE;
+}
 
-	/* FIXME: Added Remote Address or USB */
+static gboolean get_root(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct obex_session *os = data;
+	const char *root;
 
-	dbus_message_iter_close_container(&iter, &dict);
+	root = obex_option_root_folder();
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &root);
 
-	return reply;
+	return TRUE;
 }
 
 static DBusMessage *transfer_cancel(DBusConnection *connection,
@@ -339,10 +326,9 @@ static const GDBusSignalTable transfer_signals[] = {
 	{ }
 };
 
-static const GDBusMethodTable session_methods[] = {
-	{ GDBUS_METHOD("GetProperties",
-				NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
-				get_properties) },
+static const GDBusPropertyTable session_properties[] = {
+	{ "Target", "s", get_target },
+	{ "Root", "s", get_root },
 	{ }
 };
 
@@ -610,8 +596,8 @@ void manager_register_session(struct obex_session *os)
 
 	if (!g_dbus_register_interface(connection, path,
 				SESSION_INTERFACE,
-				session_methods, NULL,
-				NULL, os, NULL)) {
+				NULL, NULL,
+				session_properties, os, NULL)) {
 		error("Cannot register Session interface.");
 		goto done;
 	}
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH BlueZ 2/5] obexd: Enable ObjectManager
  2012-12-17 11:50 [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties Luiz Augusto von Dentz
@ 2012-12-17 11:50 ` Luiz Augusto von Dentz
  2012-12-17 11:50 ` [PATCH BlueZ 3/5] obexd: Remove SessionCreated and SessionRemoved signals Luiz Augusto von Dentz
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-12-17 11:50 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 obexd/src/manager.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 85aa965..034f6ab 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -350,6 +350,8 @@ gboolean manager_init(void)
 		return FALSE;
 	}
 
+	g_dbus_attach_object_manager(connection);
+
 	return g_dbus_register_interface(connection, OBEX_MANAGER_PATH,
 					OBEX_MANAGER_INTERFACE,
 					manager_methods, manager_signals, NULL,
@@ -368,6 +370,8 @@ void manager_cleanup(void)
 	if (agent)
 		agent_free(agent);
 
+	g_dbus_detach_object_manager(connection);
+
 	dbus_connection_unref(connection);
 }
 
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH BlueZ 3/5] obexd: Remove SessionCreated and SessionRemoved signals
  2012-12-17 11:50 [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties Luiz Augusto von Dentz
  2012-12-17 11:50 ` [PATCH BlueZ 2/5] obexd: Enable ObjectManager Luiz Augusto von Dentz
@ 2012-12-17 11:50 ` Luiz Augusto von Dentz
  2012-12-17 11:50 ` [PATCH BlueZ 4/5] obex-client: Enable ObjectManager Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-12-17 11:50 UTC (permalink / raw)
  To: linux-bluetooth

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

With ObjectManager these signals no longer are necessary.
---
 doc/obexd-api.txt   | 12 +-----------
 obexd/src/manager.c | 12 ------------
 2 files changed, 1 insertion(+), 23 deletions(-)

diff --git a/doc/obexd-api.txt b/doc/obexd-api.txt
index 53e61f5..822157d 100644
--- a/doc/obexd-api.txt
+++ b/doc/obexd-api.txt
@@ -29,17 +29,7 @@ Methods
 
 			Possible errors: org.bluez.obex.Error.DoesNotExist
 
-Signals		SessionCreated(object session)
-
-			Signal sent when OBEX connection has been accepted.
-			(FTP only)
-
-		SessionRemoved(object session)
-
-			Sent when the transport is disconnected
-			(FTP only)
-
-		TransferStarted(object transfer)
+Signals		TransferStarted(object transfer)
 
 			Signal sent when an object push operation starts.
 			(OPP only)
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 034f6ab..c585aa1 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -310,8 +310,6 @@ static const GDBusSignalTable manager_signals[] = {
 	{ GDBUS_SIGNAL("TransferStarted", GDBUS_ARGS({ "transfer", "o"})) },
 	{ GDBUS_SIGNAL("TransferCompleted", GDBUS_ARGS({ "transfer", "o" },
 							{ "success", "b" })) },
-	{ GDBUS_SIGNAL("SessionCreated", GDBUS_ARGS({ "session", "o" })) },
-	{ GDBUS_SIGNAL("SessionRemoved", GDBUS_ARGS({ "session", "o" })) },
 	{ }
 };
 
@@ -606,11 +604,6 @@ void manager_register_session(struct obex_session *os)
 		goto done;
 	}
 
-	g_dbus_emit_signal(connection, OBEX_MANAGER_PATH,
-			OBEX_MANAGER_INTERFACE, "SessionCreated",
-			DBUS_TYPE_OBJECT_PATH, &path,
-			DBUS_TYPE_INVALID);
-
 done:
 	g_free(path);
 }
@@ -619,11 +612,6 @@ void manager_unregister_session(struct obex_session *os)
 {
 	char *path = g_strdup_printf("/session%u", GPOINTER_TO_UINT(os));
 
-	g_dbus_emit_signal(connection, OBEX_MANAGER_PATH,
-			OBEX_MANAGER_INTERFACE, "SessionRemoved",
-			DBUS_TYPE_OBJECT_PATH, &path,
-			DBUS_TYPE_INVALID);
-
 	g_dbus_unregister_interface(connection, path,
 				SESSION_INTERFACE);
 
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH BlueZ 4/5] obex-client: Enable ObjectManager
  2012-12-17 11:50 [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties Luiz Augusto von Dentz
  2012-12-17 11:50 ` [PATCH BlueZ 2/5] obexd: Enable ObjectManager Luiz Augusto von Dentz
  2012-12-17 11:50 ` [PATCH BlueZ 3/5] obexd: Remove SessionCreated and SessionRemoved signals Luiz Augusto von Dentz
@ 2012-12-17 11:50 ` Luiz Augusto von Dentz
  2012-12-17 11:50 ` [PATCH BlueZ 5/5] TODO: Mark Convert obexd & obex-client to ObjectManager/Properties as done Luiz Augusto von Dentz
  2012-12-17 12:11 ` [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties Johan Hedberg
  4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-12-17 11:50 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 obexd/client/manager.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/obexd/client/manager.c b/obexd/client/manager.c
index 7a7c33f..4929383 100644
--- a/obexd/client/manager.c
+++ b/obexd/client/manager.c
@@ -269,6 +269,8 @@ int manager_init(void)
 		return -1;
 	}
 
+	g_dbus_attach_object_manager(conn);
+
 	if (g_dbus_register_interface(conn, CLIENT_PATH, CLIENT_INTERFACE,
 						client_methods, NULL, NULL,
 							NULL, NULL) == FALSE) {
@@ -299,5 +301,6 @@ void manager_exit(void)
 		module->exit();
 
 	g_dbus_unregister_interface(conn, CLIENT_PATH, CLIENT_INTERFACE);
+	g_dbus_detach_object_manager(conn);
 	dbus_connection_unref(conn);
 }
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH BlueZ 5/5] TODO: Mark Convert obexd & obex-client to ObjectManager/Properties as done
  2012-12-17 11:50 [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2012-12-17 11:50 ` [PATCH BlueZ 4/5] obex-client: Enable ObjectManager Luiz Augusto von Dentz
@ 2012-12-17 11:50 ` Luiz Augusto von Dentz
  2012-12-17 12:11 ` [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties Johan Hedberg
  4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2012-12-17 11:50 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 TODO | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/TODO b/TODO
index d9a708b..5a70e40 100644
--- a/TODO
+++ b/TODO
@@ -60,8 +60,6 @@ BlueZ 5
 Priority/Complexity omitted as all items are required before 5.0 is
 released.
 
-- Convert obexd & obex-client to ObjectManager/Properties
-
 - [pending] Convert storage to user per-remote device directories and
   ini-file format
 
@@ -87,6 +85,8 @@ Completed items:
 
 - Convert obexd to use org.bluez.Profile
 
+- Convert obexd & obex-client to ObjectManager/Properties
+
 - Remove org.bluez.Service interface (it has become unnecessary thanks
   to org.bluez.Profile). obexd needs to be converted to use the new
   interface first.
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties
  2012-12-17 11:50 [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties Luiz Augusto von Dentz
                   ` (3 preceding siblings ...)
  2012-12-17 11:50 ` [PATCH BlueZ 5/5] TODO: Mark Convert obexd & obex-client to ObjectManager/Properties as done Luiz Augusto von Dentz
@ 2012-12-17 12:11 ` Johan Hedberg
  4 siblings, 0 replies; 6+ messages in thread
From: Johan Hedberg @ 2012-12-17 12:11 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Mon, Dec 17, 2012, Luiz Augusto von Dentz wrote:
> ---
>  doc/obexd-api.txt   | 12 ++++--------
>  obexd/src/manager.c | 50 ++++++++++++++++++--------------------------------
>  2 files changed, 22 insertions(+), 40 deletions(-)

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-12-17 12:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-17 11:50 [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties Luiz Augusto von Dentz
2012-12-17 11:50 ` [PATCH BlueZ 2/5] obexd: Enable ObjectManager Luiz Augusto von Dentz
2012-12-17 11:50 ` [PATCH BlueZ 3/5] obexd: Remove SessionCreated and SessionRemoved signals Luiz Augusto von Dentz
2012-12-17 11:50 ` [PATCH BlueZ 4/5] obex-client: Enable ObjectManager Luiz Augusto von Dentz
2012-12-17 11:50 ` [PATCH BlueZ 5/5] TODO: Mark Convert obexd & obex-client to ObjectManager/Properties as done Luiz Augusto von Dentz
2012-12-17 12:11 ` [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties Johan Hedberg

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).