linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/15] Manager/Adapter transition to ObjectManager
@ 2012-12-05 12:51 Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 01/15] cups: Remove unnecessary code Mikel Astiz
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Main changes from v2 include the suggestions from Lizardo:
- Python style improved.
- Utility library renamed to bluezutils.py to avoid collisions in distros.
- Recently added test-cyclingspeed also considered in the patchset.

>From previous cover-letter:

This proposal completely removes org.bluez.Manager, with two main consequences:
1. Clients have a harder time to find adapters. Therefore, some helper function have been added to be used by test scripts.
2. The concept of "default adapter" disappears.

All test scripts have been updated here but not all of them were tested, so apoligies if this breaks your script (some of them are already broken, by the way).

Regarding the testing code written in C, they haven't been updated. The idea is to address these once the python part has been agreed.

Mikel Astiz (15):
  cups: Remove unnecessary code
  test: Add utility library for python scripts
  test: Avoid using DefaultAdapter()
  test: Update monitor script to ObjectManager
  test: Update test-manager script to ObjectManager
  test: Use ObjectManager instead of Adapters property
  dbus: Remove org.bluez.Manager
  test: Use ObjectManager instead of Devices property
  test: Add helper function to find devices
  adapter: Remove DeviceCreated/DeviceRemoved signals
  adapter: Remove redundant Devices property
  test: Avoid using Adapter.FindDevice()
  adapter: Remove FindDevice method from D-Bus API
  dbus: Rename to org.bluez.Device1
  dbus: Rename to org.bluez.Adapter1

 Makefile.am            |   3 +-
 Makefile.tools         |   2 +-
 doc/adapter-api.txt    |  23 +------
 doc/bluez-docs.xml     |   7 ---
 doc/device-api.txt     |   2 +-
 doc/manager-api.txt    |  51 ----------------
 doc/oob-api.txt        |   2 +-
 profiles/cups/main.c   |  46 +++++---------
 src/adapter.c          |  89 +--------------------------
 src/adapter.h          |   2 +-
 src/device.h           |   2 +-
 src/manager.c          | 163 -------------------------------------------------
 src/manager.h          |   3 -
 test/agent.c           |   7 ++-
 test/bluezutils.py     |  47 ++++++++++++++
 test/dbusdef.py        |   5 +-
 test/list-devices      |  20 +++---
 test/monitor-bluetooth |  68 ++++++++++-----------
 test/simple-agent      |  22 +++----
 test/simple-endpoint   |   7 +--
 test/simple-player     |   7 +--
 test/simple-service    |   7 +--
 test/test-adapter      |  41 ++++++-------
 test/test-attrib       |  18 ++----
 test/test-cyclingspeed |  20 +++---
 test/test-device       |  84 ++++++++++++-------------
 test/test-discovery    |  15 ++---
 test/test-health       |  11 +++-
 test/test-health-sink  |  12 +++-
 test/test-heartrate    |  23 +++----
 test/test-manager      |  33 +++++-----
 test/test-nap          |  10 +--
 test/test-oob          |  33 +++++-----
 test/test-proximity    |  17 +-----
 test/test-service      |   8 +--
 test/test-thermometer  |  20 +++---
 36 files changed, 288 insertions(+), 642 deletions(-)
 delete mode 100644 doc/manager-api.txt
 create mode 100644 test/bluezutils.py

-- 
1.7.11.7


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

* [PATCH v3 01/15] cups: Remove unnecessary code
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 02/15] test: Add utility library for python scripts Mikel Astiz
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

The adapter is always known so the code to handle the NULL case is not
needed.
---
 profiles/cups/main.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/profiles/cups/main.c b/profiles/cups/main.c
index 5aa927f..977c057 100644
--- a/profiles/cups/main.c
+++ b/profiles/cups/main.c
@@ -31,6 +31,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
 #include <signal.h>
 #include <sys/socket.h>
 #include <glib.h>
@@ -338,26 +339,7 @@ static void remote_device_found(const char *adapter, const char *bdaddr,
 
 	adapter_reply = NULL;
 
-	if (adapter == NULL) {
-		message = dbus_message_new_method_call("org.bluez", "/",
-							"org.bluez.Manager",
-							"DefaultAdapter");
-
-		adapter_reply = dbus_connection_send_with_reply_and_block(conn,
-							message, -1, NULL);
-
-		dbus_message_unref(message);
-
-		if (!adapter_reply)
-			return;
-
-		if (dbus_message_get_args(adapter_reply, NULL,
-					DBUS_TYPE_OBJECT_PATH, &adapter,
-					DBUS_TYPE_INVALID) == FALSE) {
-			dbus_message_unref(adapter_reply);
-			return;
-		}
-	}
+	assert(adapter != NULL);
 
 	message = dbus_message_new_method_call("org.bluez", adapter,
 							"org.bluez.Adapter",
-- 
1.7.11.7


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

* [PATCH v3 02/15] test: Add utility library for python scripts
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 01/15] cups: Remove unnecessary code Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 03/15] test: Avoid using DefaultAdapter() Mikel Astiz
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Several convenience functions/features will be removed from BlueZ's
D-Bus API, and therefore a utility library is required to avoid
boilerplate code in the test scripts.
---
 Makefile.tools     |  2 +-
 test/bluezutils.py | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 test/bluezutils.py

diff --git a/Makefile.tools b/Makefile.tools
index 1cbd876..90b35d5 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -210,7 +210,7 @@ else
 EXTRA_DIST += test/rctest.1 test/hciemu.1 test/bdaddr.8
 endif
 
-EXTRA_DIST += test/sap_client.py test/hsplay test/hsmicro \
+EXTRA_DIST += test/sap_client.py test/hsplay test/hsmicro test/bluezutils.py \
 		test/dbusdef.py test/monitor-bluetooth test/list-devices \
 		test/test-discovery test/test-manager test/test-adapter \
 		test/test-device test/test-service test/simple-agent \
diff --git a/test/bluezutils.py b/test/bluezutils.py
new file mode 100644
index 0000000..0b8aec3
--- /dev/null
+++ b/test/bluezutils.py
@@ -0,0 +1,25 @@
+import dbus
+
+SERVICE_NAME = "org.bluez"
+ADAPTER_INTERFACE = SERVICE_NAME + ".Adapter"
+
+def get_managed_objects():
+	bus = dbus.SystemBus()
+	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
+				"org.freedesktop.DBus.ObjectManager")
+	return manager.GetManagedObjects()
+
+def find_adapter(pattern=None):
+	return find_adapter_in_objects(get_managed_objects(), pattern)
+
+def find_adapter_in_objects(objects, pattern=None):
+	bus = dbus.SystemBus()
+	for path, ifaces in objects.iteritems():
+		adapter = ifaces.get(ADAPTER_INTERFACE)
+		if adapter is None:
+			continue
+		if not pattern or pattern == adapter["Address"] or
+							path.endswith(pattern)):
+			obj = bus.get_object(SERVICE_NAME, path)
+			return dbus.Interface(obj, ADAPTER_INTERFACE)
+	raise Exception("Bluetooth adapter not found")
-- 
1.7.11.7


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

* [PATCH v3 03/15] test: Avoid using DefaultAdapter()
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 01/15] cups: Remove unnecessary code Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 02/15] test: Add utility library for python scripts Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 04/15] test: Update monitor script to ObjectManager Mikel Astiz
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Call the utility library -which uses ObjectManager API- to avoid using
Manager.FindAdapter() and Manager.DefaultAdapter().
---
 test/dbusdef.py        |  5 ++---
 test/simple-agent      | 10 +++-------
 test/simple-endpoint   |  7 +++----
 test/simple-player     |  7 +++----
 test/simple-service    |  7 +++----
 test/test-adapter      |  9 ++-------
 test/test-attrib       | 11 ++---------
 test/test-cyclingspeed | 11 ++---------
 test/test-device       | 11 +++--------
 test/test-discovery    | 11 ++---------
 test/test-heartrate    | 14 +++-----------
 test/test-manager      |  3 ++-
 test/test-nap          | 10 ++--------
 test/test-oob          | 21 +++++++++++----------
 test/test-proximity    | 12 ++----------
 test/test-service      |  8 ++------
 test/test-thermometer  | 14 +++-----------
 17 files changed, 50 insertions(+), 121 deletions(-)

diff --git a/test/dbusdef.py b/test/dbusdef.py
index 5af6153..f1cd35a 100644
--- a/test/dbusdef.py
+++ b/test/dbusdef.py
@@ -1,4 +1,5 @@
 import dbus
+import bluezutils
 
 bus = dbus.SystemBus()
 
@@ -8,9 +9,7 @@ dummy = dbus.Interface(bus.get_object('org.bluez', '/'), 'org.freedesktop.DBus.I
 #print dummy.Introspect()
 
 
-manager = dbus.Interface(bus.get_object('org.bluez', '/'), 'org.bluez.Manager')
-
 try:
-	adapter = dbus.Interface(bus.get_object('org.bluez', manager.DefaultAdapter()), 'org.bluez.Adapter')
+	adapter = bluezutils.find_adapter()
 except:
 	pass
diff --git a/test/simple-agent b/test/simple-agent
index aeddc97..13c3ce7 100755
--- a/test/simple-agent
+++ b/test/simple-agent
@@ -9,6 +9,7 @@ import dbus
 import dbus.service
 import dbus.mainloop.glib
 from optparse import OptionParser
+import bluezutils
 
 bus = None
 device_obj = None
@@ -135,8 +136,6 @@ if __name__ == '__main__':
 	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 
 	bus = dbus.SystemBus()
-	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-							"org.bluez.Manager")
 
 	capability = "KeyboardDisplay"
 
@@ -151,12 +150,9 @@ if __name__ == '__main__':
 		capability  = options.capability
 
 	if len(args) > 0:
-		path = manager.FindAdapter(args[0])
+		adapter = bluezutils.find_adapter(args[0])
 	else:
-		path = manager.DefaultAdapter()
-
-	adapter = dbus.Interface(bus.get_object("org.bluez", path),
-							"org.bluez.Adapter")
+		adapter = bluezutils.find_adapter()
 
 	path = "/test/agent"
 	agent = Agent(bus, path)
diff --git a/test/simple-endpoint b/test/simple-endpoint
index 79e38c7..b363943 100755
--- a/test/simple-endpoint
+++ b/test/simple-endpoint
@@ -7,6 +7,7 @@ import dbus
 import dbus.service
 import dbus.mainloop.glib
 import gobject
+import bluezutils
 
 A2DP_SOURCE_UUID = "0000110A-0000-1000-8000-00805F9B34FB"
 A2DP_SINK_UUID = "0000110B-0000-1000-8000-00805F9B34FB"
@@ -82,13 +83,11 @@ if __name__ == '__main__':
 	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 
 	bus = dbus.SystemBus()
-	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-						"org.bluez.Manager")
 
 	if len(sys.argv) > 1:
-		path = manager.FindAdapter(sys.argv[1])
+		path = bluezutils.find_adapter(sys.argv[1]).object_path
 	else:
-		path = manager.DefaultAdapter()
+		path = bluezutils.find_adapter().object_path
 
 	media = dbus.Interface(bus.get_object("org.bluez", path),
 						"org.bluez.Media")
diff --git a/test/simple-player b/test/simple-player
index 0037f3a..7eb7d7e 100755
--- a/test/simple-player
+++ b/test/simple-player
@@ -7,6 +7,7 @@ import dbus
 import dbus.service
 import dbus.mainloop.glib
 import gobject
+import bluezutils
 
 class Player(dbus.service.Object):
 	properties = None
@@ -141,13 +142,11 @@ if __name__ == '__main__':
 	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 
 	bus = dbus.SystemBus()
-	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-						"org.bluez.Manager")
 
 	if len(sys.argv) > 1:
-		path = manager.FindAdapter(sys.argv[1])
+		path = bluezutils.find_adapter(sys.argv[1]).object_path
 	else:
-		path = manager.DefaultAdapter()
+		path = bluezutils.find_adapter().object_path
 
 	media = dbus.Interface(bus.get_object("org.bluez", path),
 						"org.bluez.Media")
diff --git a/test/simple-service b/test/simple-service
index ed27d0c..02d7648 100755
--- a/test/simple-service
+++ b/test/simple-service
@@ -5,6 +5,7 @@ from __future__ import absolute_import, print_function, unicode_literals
 import sys
 import time
 import dbus
+import bluezutils
 
 xml = ' \
 <?xml version="1.0" encoding="UTF-8" ?> 	\
@@ -103,13 +104,11 @@ xml = ' \
 '
 
 bus = dbus.SystemBus()
-manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-						"org.bluez.Manager")
 
 if len(sys.argv) > 1:
-	path = manager.FindAdapter(sys.argv[1])
+	path = bluezutils.find_adapter(sys.argv[1]).object_path
 else:
-	path = manager.DefaultAdapter()
+	path = bluezutils.find_adapter().object_path
 
 service = dbus.Interface(bus.get_object("org.bluez", path),
 						"org.bluez.Service")
diff --git a/test/test-adapter b/test/test-adapter
index a37dd30..dc66aa6 100755
--- a/test/test-adapter
+++ b/test/test-adapter
@@ -6,11 +6,10 @@ import sys
 import dbus
 import time
 from optparse import OptionParser, make_option
+import bluezutils
 
 bus = dbus.SystemBus()
 
-manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager")
-
 option_list = [
 		make_option("-i", "--device", action="store",
 				type="string", dest="dev_id"),
@@ -19,11 +18,7 @@ parser = OptionParser(option_list=option_list)
 
 (options, args) = parser.parse_args()
 
-if options.dev_id:
-	adapter_path = manager.FindAdapter(options.dev_id)
-else:
-	adapter_path = manager.DefaultAdapter()
-
+adapter_path = bluezutils.find_adapter(options.dev_id).object_path
 adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
 					"org.freedesktop.DBus.Properties")
 
diff --git a/test/test-attrib b/test/test-attrib
index f83859d..f75a566 100755
--- a/test/test-attrib
+++ b/test/test-attrib
@@ -13,13 +13,12 @@ import sys
 import dbus
 import dbus.mainloop.glib
 from optparse import OptionParser, make_option
+import bluezutils
 
 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 bus = dbus.SystemBus()
 mainloop = gobject.MainLoop()
 
-manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager")
-
 option_list = [
 		make_option("-i", "--device", action="store",
 				type="string", dest="dev_id"),
@@ -28,13 +27,7 @@ parser = OptionParser(option_list=option_list)
 
 (options, args) = parser.parse_args()
 
-if options.dev_id:
-	adapter_path = manager.FindAdapter(options.dev_id)
-else:
-	adapter_path = manager.DefaultAdapter()
-
-adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
-							"org.bluez.Adapter")
+adapter = bluezutils.find_adapter(options.dev_id)
 
 if (len(args) < 1):
 	print("Usage: %s <command>" % (sys.argv[0]))
diff --git a/test/test-cyclingspeed b/test/test-cyclingspeed
index 841456c..2bfea36 100755
--- a/test/test-cyclingspeed
+++ b/test/test-cyclingspeed
@@ -125,15 +125,8 @@ if __name__ == "__main__":
 		print("\tSetCumulativeWheelRevolutions <value>")
 		sys.exit(1)
 
-	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-					"org.bluez.Manager")
-	if options.adapter:
-		adapter_path = manager.FindAdapter(options.adapter)
-	else:
-		adapter_path = manager.DefaultAdapter()
-
-	adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
-							"org.bluez.Adapter")
+	adapter = bluezutils.find_adapter(options.adapter)
+	adapter_path = adapter.object_path
 
 	device_path = adapter.FindDevice(options.address)
 
diff --git a/test/test-device b/test/test-device
index c26d7f6..f4a40c4 100755
--- a/test/test-device
+++ b/test/test-device
@@ -9,13 +9,12 @@ import dbus
 import dbus.mainloop.glib
 import re
 from optparse import OptionParser, make_option
+import bluezutils
 
 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 bus = dbus.SystemBus()
 mainloop = GObject.MainLoop()
 
-manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager")
-
 option_list = [
 		make_option("-i", "--device", action="store",
 				type="string", dest="dev_id"),
@@ -24,13 +23,9 @@ parser = OptionParser(option_list=option_list)
 
 (options, args) = parser.parse_args()
 
-if options.dev_id:
-	adapter_path = manager.FindAdapter(options.dev_id)
-else:
-	adapter_path = manager.DefaultAdapter()
+adapter = bluezutils.find_adapter(options.dev_id)
 
-adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
-							"org.bluez.Adapter")
+adapter_path = adapter.object_path
 
 if (len(args) < 1):
 	print("Usage: %s <command>" % (sys.argv[0]))
diff --git a/test/test-discovery b/test/test-discovery
index e85ab60..0f73fe4 100755
--- a/test/test-discovery
+++ b/test/test-discovery
@@ -7,6 +7,7 @@ from gi.repository import GObject
 import dbus
 import dbus.mainloop.glib
 from optparse import OptionParser, make_option
+import bluezutils
 
 compact = False
 devices = {}
@@ -88,8 +89,6 @@ if __name__ == '__main__':
 	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 
 	bus = dbus.SystemBus()
-	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-							"org.bluez.Manager")
 
 	option_list = [
 			make_option("-i", "--device", action="store",
@@ -101,17 +100,11 @@ if __name__ == '__main__':
 
 	(options, args) = parser.parse_args()
 
-	if options.dev_id:
-		adapter_path = manager.FindAdapter(options.dev_id)
-	else:
-		adapter_path = manager.DefaultAdapter()
+	adapter = bluezutils.find_adapter(options.dev_id)
 
 	if options.compact:
 		compact = True;
 
-	adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
-							"org.bluez.Adapter")
-
 	bus.add_signal_receiver(devices_found,
 					dbus_interface = "org.bluez.Adapter",
 					signal_name = "DevicesFound")
diff --git a/test/test-heartrate b/test/test-heartrate
index a7d05b4..a08e8df 100755
--- a/test/test-heartrate
+++ b/test/test-heartrate
@@ -13,6 +13,7 @@ import dbus
 import dbus.service
 import dbus.mainloop.glib
 from optparse import OptionParser, make_option
+import bluezutils
 
 class Watcher(dbus.service.Object):
 	@dbus.service.method("org.bluez.HeartRateWatcher",
@@ -36,9 +37,6 @@ if __name__ == "__main__":
 
 	bus = dbus.SystemBus()
 
-	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-					"org.bluez.Manager")
-
 	option_list = [
 		make_option("-i", "--adapter", action="store",
 			type="string", dest="adapter"),
@@ -56,14 +54,8 @@ if __name__ == "__main__":
 		print("\tReset")
 		sys.exit(1)
 
-	if options.adapter:
-		adapter_path = manager.FindAdapter(options.adapter)
-	else:
-		adapter_path = manager.DefaultAdapter()
-
-	adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
-							"org.bluez.Adapter")
-
+	adapter = bluezutils.find_adapter(options.adapter)
+	adapter_path = adapter.object_path
 	heartrateManager = dbus.Interface(bus.get_object("org.bluez",
 				adapter_path), "org.bluez.HeartRateManager")
 
diff --git a/test/test-manager b/test/test-manager
index 8a7e2f6..16d6b08 100755
--- a/test/test-manager
+++ b/test/test-manager
@@ -6,6 +6,7 @@ from gi.repository import GObject
 
 import dbus
 import dbus.mainloop.glib
+import bluezutils
 
 def adapter_added(path):
 	print("Adapter with path %s added" % (path))
@@ -31,7 +32,7 @@ if __name__ == "__main__":
 	manager.connect_to_signal("DefaultAdapterChanged", default_changed)
 
 	try:
-		path = manager.DefaultAdapter()
+		path = bluezutils.find_adapter().object_path
 		default_changed(path)
 	except:
 		pass
diff --git a/test/test-nap b/test/test-nap
index dc779ad..b3d6907 100755
--- a/test/test-nap
+++ b/test/test-nap
@@ -6,12 +6,10 @@ import sys
 import time
 import dbus
 from optparse import OptionParser, make_option
+import bluezutils
 
 bus = dbus.SystemBus()
 
-manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-						"org.bluez.Manager")
-
 option_list = [
 		make_option("-i", "--device", action="store",
 				type="string", dest="dev_id"),
@@ -20,11 +18,7 @@ parser = OptionParser(option_list=option_list)
 
 (options, args) = parser.parse_args()
 
-if options.dev_id:
-	adapter_path = manager.FindAdapter(options.dev_id)
-else:
-	adapter_path = manager.DefaultAdapter()
-
+adapter_path = bluezutils.find_adapter(options.dev_id).object_path
 server = dbus.Interface(bus.get_object("org.bluez", adapter_path),
 						"org.bluez.NetworkServer")
 
diff --git a/test/test-oob b/test/test-oob
index d44215f..34e042d 100755
--- a/test/test-oob
+++ b/test/test-oob
@@ -5,6 +5,7 @@ from __future__ import absolute_import, print_function, unicode_literals
 import gobject
 
 import dbus.mainloop.glib
+import bluezutils
 
 def create_device_reply(device):
 	print("Pairing succeed!")
@@ -20,19 +21,19 @@ if __name__ == '__main__':
 	mainloop = gobject.MainLoop()
 
 	bus = dbus.SystemBus()
-	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-							"org.bluez.Manager")
 
-	adapter0_path = manager.FindAdapter("hci0")
-	adapter1_path = manager.FindAdapter("hci1")
+	managed_objects = bluezutils.get_managed_objects()
+	adapter0 = bluezutils.find_adapter_in_objects(managed_objects, "hci0")
+	adapter1 = bluezutils.find_adapter_in_objects(managed_objects, "hci1")
 
-	adapter0 = dbus.Interface(bus.get_object("org.bluez", adapter0_path),
-							"org.bluez.Adapter")
-	adapter1 = dbus.Interface(bus.get_object("org.bluez", adapter1_path),
-							"org.bluez.Adapter")
+	adapter0_path = adapter0.object_path
+	adapter1_path = adapter1.object_path
+
+	adapter0_address = managed_objects[adapter0_path][
+					bluezutils.ADAPTER_INTERFACE]["Address"]
+	adapter1_address = managed_objects[adapter1_path][
+					bluezutils.ADAPTER_INTERFACE]["Address"]
 
-	adapter0_address = adapter0.GetProperties()["Address"]
-	adapter1_address = adapter1.GetProperties()["Address"]
 	print("Adapters:")
 	print("    hci0: " + adapter0_address)
 	print("    hci1: " + adapter1_address)
diff --git a/test/test-proximity b/test/test-proximity
index 3cb98cc..afde3fb 100755
--- a/test/test-proximity
+++ b/test/test-proximity
@@ -12,6 +12,7 @@ import sys
 import dbus
 import dbus.mainloop.glib
 from optparse import OptionParser, make_option
+import bluezutils
 
 def properties_changed(interface, changed, invalidated):
 	if interface != "org.bluez.ProximityMonitor":
@@ -25,9 +26,6 @@ if __name__ == "__main__":
 
 	bus = dbus.SystemBus()
 
-	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-					"org.bluez.Manager")
-
 	option_list = [
 		make_option("-i", "--adapter", action="store",
 			type="string", dest="dev_id"),
@@ -39,13 +37,7 @@ if __name__ == "__main__":
 
 	(options, args) = parser.parse_args()
 
-	if options.dev_id:
-		adapter_path = manager.FindAdapter(options.dev_id)
-	else:
-		adapter_path = manager.DefaultAdapter()
-
-	adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
-							"org.bluez.Adapter")
+	adapter = bluezutils.find_adapter(options.dev_id)
 
 	if (len(args) < 1):
 		print("Usage: %s <command>" % (sys.argv[0]))
diff --git a/test/test-service b/test/test-service
index 8eea9e2..09e351f 100755
--- a/test/test-service
+++ b/test/test-service
@@ -6,11 +6,10 @@ import sys
 import dbus
 import time
 from optparse import OptionParser, make_option
+import bluezutils
 
 bus = dbus.SystemBus()
 
-manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager")
-
 option_list = [
 		make_option("-i", "--device", action="store",
 				type="string", dest="dev_id"),
@@ -19,10 +18,7 @@ parser = OptionParser(option_list=option_list)
 
 (options, args) = parser.parse_args()
 
-if options.dev_id:
-	adapter_path = manager.FindAdapter(options.dev_id)
-else:
-	adapter_path = manager.DefaultAdapter()
+adapter_path = bluezutils.find_adapter(options.dev_id).object_path
 
 service = dbus.Interface(bus.get_object("org.bluez", adapter_path),
 						"org.bluez.Service")
diff --git a/test/test-thermometer b/test/test-thermometer
index e14a345..5a884a3 100755
--- a/test/test-thermometer
+++ b/test/test-thermometer
@@ -13,6 +13,7 @@ import dbus
 import dbus.service
 import dbus.mainloop.glib
 from optparse import OptionParser, make_option
+import bluezutils
 
 class Watcher(dbus.service.Object):
 	@dbus.service.method("org.bluez.ThermometerWatcher",
@@ -40,9 +41,6 @@ if __name__ == "__main__":
 
 	bus = dbus.SystemBus()
 
-	manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-					"org.bluez.Manager")
-
 	option_list = [
 		make_option("-i", "--adapter", action="store",
 			type="string", dest="adapter"),
@@ -60,14 +58,8 @@ if __name__ == "__main__":
 		print("\tEnableIntermediateMeasurement")
 		sys.exit(1)
 
-	if options.adapter:
-		adapter_path = manager.FindAdapter(options.adapter)
-	else:
-		adapter_path = manager.DefaultAdapter()
-
-	adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
-							"org.bluez.Adapter")
-
+	adapter = bluezutils.find_adapter(options.adapter)
+	adapter_path = adapter.object_path
 	thermometer_manager = dbus.Interface(bus.get_object("org.bluez",
 				adapter_path), "org.bluez.ThermometerManager")
 
-- 
1.7.11.7


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

* [PATCH v3 04/15] test: Update monitor script to ObjectManager
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (2 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 03/15] test: Avoid using DefaultAdapter() Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 05/15] test: Update test-manager " Mikel Astiz
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Make the script compatible with the new API provided by the
ObjectManager and Properties interfaces.
---
 test/monitor-bluetooth | 68 +++++++++++++++++++++++---------------------------
 1 file changed, 31 insertions(+), 37 deletions(-)

diff --git a/test/monitor-bluetooth b/test/monitor-bluetooth
index 4a598e1..45cc910 100755
--- a/test/monitor-bluetooth
+++ b/test/monitor-bluetooth
@@ -7,15 +7,28 @@ import gobject
 import dbus
 import dbus.mainloop.glib
 
-def property_changed(name, value, path, interface):
-	iface = interface[interface.rfind(".") + 1:]
-	val = str(value)
-	print("{%s.PropertyChanged} [%s] %s = %s" % (iface, path, name, val))
+relevant_ifaces = [ "org.bluez.Adapter", "org.bluez.Device" ]
 
-def object_signal(value, path, interface, member):
+def property_changed(interface, changed, invalidated, path):
 	iface = interface[interface.rfind(".") + 1:]
-	val = str(value)
-	print("{%s.%s} [%s] Path = %s" % (iface, member, path, val))
+	for name, value in changed.iteritems():
+		val = str(value)
+		print("{%s.PropertyChanged} [%s] %s = %s" % (iface, path, name,
+									val))
+
+def interfaces_added(path, interfaces):
+	for iface, props in interfaces.iteritems():
+		if not(iface in relevant_ifaces):
+			continue
+		print("{Added %s} [%s]" % (iface, path))
+		for name, value in props.iteritems():
+			print("      %s = %s" % (name, value))
+
+def interfaces_removed(path, interfaces):
+	for iface in interfaces:
+		if not(iface in relevant_ifaces):
+			continue
+		print("{Removed %s} [%s]" % (iface, path))
 
 if __name__ == '__main__':
 	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -23,36 +36,17 @@ if __name__ == '__main__':
 	bus = dbus.SystemBus()
 
 	bus.add_signal_receiver(property_changed, bus_name="org.bluez",
-					signal_name = "PropertyChanged",
-						path_keyword="path",
-						interface_keyword="interface")
-
-	bus.add_signal_receiver(object_signal, bus_name="org.bluez",
-					signal_name = "AdapterAdded",
-						path_keyword="path",
-						member_keyword="member",
-						interface_keyword="interface")
-	bus.add_signal_receiver(object_signal, bus_name="org.bluez",
-					signal_name = "AdapterRemoved",
-						path_keyword="path",
-						member_keyword="member",
-						interface_keyword="interface")
-	bus.add_signal_receiver(object_signal, bus_name="org.bluez",
-					signal_name = "DefaultAdapterChanged",
-						path_keyword="path",
-						member_keyword="member",
-						interface_keyword="interface")
-
-	bus.add_signal_receiver(object_signal, bus_name="org.bluez",
-					signal_name = "DeviceCreated",
-						path_keyword="path",
-						member_keyword="member",
-						interface_keyword="interface")
-	bus.add_signal_receiver(object_signal, bus_name="org.bluez",
-					signal_name = "DeviceRemoved",
-						path_keyword="path",
-						member_keyword="member",
-						interface_keyword="interface")
+			dbus_interface="org.freedesktop.DBus.Properties",
+			signal_name="PropertiesChanged",
+			path_keyword="path")
+
+	bus.add_signal_receiver(interfaces_added, bus_name="org.bluez",
+			dbus_interface="org.freedesktop.DBus.ObjectManager",
+			signal_name="InterfacesAdded")
+
+	bus.add_signal_receiver(interfaces_removed, bus_name="org.bluez",
+			dbus_interface="org.freedesktop.DBus.ObjectManager",
+			signal_name="InterfacesRemoved")
 
 	mainloop = gobject.MainLoop()
 	mainloop.run()
-- 
1.7.11.7


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

* [PATCH v3 05/15] test: Update test-manager script to ObjectManager
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (3 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 04/15] test: Update monitor script to ObjectManager Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 06/15] test: Use ObjectManager instead of Adapters property Mikel Astiz
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Make the script compatible with the new API provided by the
ObjectManager interface.
---
 test/test-manager | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/test/test-manager b/test/test-manager
index 16d6b08..c5e8007 100755
--- a/test/test-manager
+++ b/test/test-manager
@@ -8,34 +8,32 @@ import dbus
 import dbus.mainloop.glib
 import bluezutils
 
-def adapter_added(path):
-	print("Adapter with path %s added" % (path))
+def interfaces_added(path, interfaces):
+	if interfaces.get("org.bluez.Adapter") != None:
+		print("Adapter with path %s added" % (path))
 
-def adapter_removed(path):
-	print("Adapter with path %s removed" % (path))
-
-def default_changed(path):
-	print("Default adapter is now at path %s" % (path))
+def interfaces_removed(path, interfaces):
+	if "org.bluez.Adapter" in interfaces:
+		print("Adapter with path %s removed" % (path))
 
 if __name__ == "__main__":
 	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 
 	bus = dbus.SystemBus()
 
-	manager = dbus.Interface(bus.get_object('org.bluez', '/'),
-							'org.bluez.Manager')
-
-	manager.connect_to_signal("AdapterAdded", adapter_added)
-
-	manager.connect_to_signal("AdapterRemoved", adapter_removed)
+	bus.add_signal_receiver(interfaces_added, bus_name="org.bluez",
+			dbus_interface="org.freedesktop.DBus.ObjectManager",
+			signal_name="InterfacesAdded")
 
-	manager.connect_to_signal("DefaultAdapterChanged", default_changed)
+	bus.add_signal_receiver(interfaces_removed, bus_name="org.bluez",
+			dbus_interface="org.freedesktop.DBus.ObjectManager",
+			signal_name="InterfacesRemoved")
 
 	try:
 		path = bluezutils.find_adapter().object_path
-		default_changed(path)
+		print("Adapter found at path %s" % (path))
 	except:
-		pass
+		print("No adapter found")
 
 	mainloop = GObject.MainLoop()
 	mainloop.run()
-- 
1.7.11.7


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

* [PATCH v3 06/15] test: Use ObjectManager instead of Adapters property
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (4 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 05/15] test: Update test-manager " Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 07/15] dbus: Remove org.bluez.Manager Mikel Astiz
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Use the objects and interfaces reported by the ObjectManager in order
to list the available adapters.
---
 test/test-health      |  9 +++++++--
 test/test-health-sink | 10 ++++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/test/test-health b/test/test-health
index a7df679..9d2f62f 100755
--- a/test/test-health
+++ b/test/test-health
@@ -132,9 +132,14 @@ if not con:
 	sys.exit()
 
 manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-						"org.bluez.Manager")
+					"org.freedesktop.DBus.ObjectManager")
 
-adapters = manager.GetProperties()["Adapters"]
+objects = manager.GetManagedObjects()
+adapters = []
+
+for path, ifaces in objects.iteritems():
+	if ifaces.has_key("org.bluez.Adapter"):
+		adapters.append(path)
 
 i = 1
 for ad in adapters:
diff --git a/test/test-health-sink b/test/test-health-sink
index 333b2fb..a886d85 100755
--- a/test/test-health-sink
+++ b/test/test-health-sink
@@ -22,9 +22,15 @@ app_path = hdp_manager.CreateApplication({"DataType": dbus.types.UInt16(4103),
 print(app_path)
 
 manager = dbus.Interface(bus.get_object("org.bluez", "/"),
-						"org.bluez.Manager")
+					"org.freedesktop.DBus.ObjectManager")
+
+objects = manager.GetManagedObjects()
+adapters = []
+
+for path, ifaces in objects.iteritems():
+	if ifaces.has_key("org.bluez.Adapter"):
+		adapters.append(path)
 
-adapters = manager.GetProperties()["Adapters"]
 i = 1
 for ad in adapters:
 	print("%d. %s" % (i, ad))
-- 
1.7.11.7


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

* [PATCH v3 07/15] dbus: Remove org.bluez.Manager
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (5 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 06/15] test: Use ObjectManager instead of Adapters property Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 08/15] test: Use ObjectManager instead of Devices property Mikel Astiz
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

After the decision to drop the "default-adapter" feature in the D-Bus
API, the org.bluez.Manager interface can be entirely dropped since it
has been replaced by the ObjectManager.
---
 Makefile.am         |   3 +-
 doc/bluez-docs.xml  |   7 ---
 doc/manager-api.txt |  51 ----------------
 src/adapter.c       |   4 +-
 src/manager.c       | 163 ----------------------------------------------------
 src/manager.h       |   3 -
 6 files changed, 3 insertions(+), 228 deletions(-)
 delete mode 100644 doc/manager-api.txt

diff --git a/Makefile.am b/Makefile.am
index 438fca6..9b2f9f6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -345,8 +345,7 @@ CLEANFILES += $(rules_DATA)
 
 EXTRA_DIST += scripts/bluetooth-hid2hci.rules scripts/bluetooth-serial.rules
 
-EXTRA_DIST += doc/manager-api.txt \
-		doc/adapter-api.txt doc/device-api.txt doc/profile-api.txt \
+EXTRA_DIST += doc/adapter-api.txt doc/device-api.txt doc/profile-api.txt \
 		doc/service-api.txt doc/agent-api.txt doc/attribute-api.txt \
 		doc/network-api.txt doc/control-api.txt doc/health-api.txt \
 		doc/sap-api.txt doc/media-api.txt doc/assigned-numbers.txt \
diff --git a/doc/bluez-docs.xml b/doc/bluez-docs.xml
index a90dde7..814ce00 100644
--- a/doc/bluez-docs.xml
+++ b/doc/bluez-docs.xml
@@ -47,13 +47,6 @@
     </legalnotice>
   </bookinfo>
 
-  <reference id="manager">
-    <title>Manager interface</title>
-    <para>
-<programlisting><xi:include href="manager-api.txt" parse="text" /></programlisting>
-    </para>
-  </reference>
-
   <reference id="adapter">
     <title>Adapter interface</title>
     <para>
diff --git a/doc/manager-api.txt b/doc/manager-api.txt
deleted file mode 100644
index 3add587..0000000
--- a/doc/manager-api.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-BlueZ D-Bus Manager API description
-***********************************
-
-Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
-Copyright (C) 2005-2006  Johan Hedberg <johan.hedberg@nokia.com>
-Copyright (C) 2005-2006  Claudio Takahasi <claudio.takahasi@indt.org.br>
-Copyright (C) 2006-2007  Luiz von Dentz <luiz.dentz@indt.org.br>
-
-
-Manager hierarchy
-=================
-
-Service		org.bluez
-Interface	org.bluez.Manager
-Object path	/
-
-		object DefaultAdapter()
-
-			Returns object path for the default adapter.
-
-			Possible errors: org.bluez.Error.InvalidArguments
-					 org.bluez.Error.NoSuchAdapter
-
-		object FindAdapter(string pattern)
-
-			Returns object path for the specified adapter. Valid
-			patterns are "hci0" or "00:11:22:33:44:55".
-
-			Possible errors: org.bluez.Error.InvalidArguments
-					 org.bluez.Error.NoSuchAdapter
-
-Signals		AdapterAdded(object adapter)
-
-			Parameter is object path of added adapter.
-
-		AdapterRemoved(object adapter)
-
-			Parameter is object path of removed adapter.
-
-		DefaultAdapterChanged(object adapter)
-
-			Parameter is object path of the new default adapter.
-
-			In case all adapters are removed this signal will not
-			be emitted. The AdapterRemoved signal has to be used
-			to detect that no default adapter is selected or
-			available anymore.
-
-Properties	array{object} Adapters [readonly]
-
-			List of adapter object paths.
diff --git a/src/adapter.c b/src/adapter.c
index 3c5d277..ea0394f 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -86,6 +86,7 @@
 #define REMOVE_TEMP_TIMEOUT (3 * 60)
 #define PENDING_FOUND_MAX 5
 
+static const char *base_path = "/org/bluez";
 static GSList *adapter_drivers = NULL;
 
 enum session_req_type {
@@ -2973,7 +2974,6 @@ struct btd_adapter *adapter_create(int id)
 {
 	char path[MAX_PATH_LENGTH];
 	struct btd_adapter *adapter;
-	const char *base_path = manager_get_base_path();
 
 	adapter = g_try_new0(struct btd_adapter, 1);
 	if (!adapter) {
@@ -3604,7 +3604,7 @@ const char *btd_adapter_any_request_path(void)
 	if (adapter_any_refcount++ > 0)
 		return adapter_any_path;
 
-	adapter_any_path = g_strdup_printf("%s/any", manager_get_base_path());
+	adapter_any_path = g_strdup_printf("%s/any", base_path);
 
 	return adapter_any_path;
 }
diff --git a/src/manager.c b/src/manager.c
index 3088dd9..3c415db 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -54,141 +54,11 @@
 #include "error.h"
 #include "manager.h"
 
-static const char *base_path = "/org/bluez";
-
 static int default_adapter_id = -1;
 static GSList *adapters = NULL;
 
-const char *manager_get_base_path(void)
-{
-	return base_path;
-}
-
-static DBusMessage *default_adapter(DBusConnection *conn,
-					DBusMessage *msg, void *data)
-{
-	DBusMessage *reply;
-	struct btd_adapter *adapter;
-	const gchar *path;
-
-	adapter = manager_find_adapter_by_id(default_adapter_id);
-	if (!adapter)
-		return btd_error_no_such_adapter(msg);
-
-	reply = dbus_message_new_method_return(msg);
-	if (!reply)
-		return NULL;
-
-	path = adapter_get_path(adapter);
-
-	dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path,
-				DBUS_TYPE_INVALID);
-
-	return reply;
-}
-
-static DBusMessage *find_adapter(DBusConnection *conn,
-					DBusMessage *msg, void *data)
-{
-	DBusMessage *reply;
-	struct btd_adapter *adapter;
-	const char *pattern;
-	int dev_id;
-	const gchar *path;
-
-	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &pattern,
-							DBUS_TYPE_INVALID))
-		return btd_error_invalid_args(msg);
-
-	/* hci_devid() would make sense to use here, except it is
-	 * restricted to devices which are up */
-	if (!strcmp(pattern, "any") || !strcmp(pattern, "00:00:00:00:00:00")) {
-		path = adapter_any_get_path();
-		if (path != NULL)
-			goto done;
-		return btd_error_no_such_adapter(msg);
-	} else if (!strncmp(pattern, "hci", 3) && strlen(pattern) >= 4) {
-		dev_id = atoi(pattern + 3);
-		adapter = manager_find_adapter_by_id(dev_id);
-	} else {
-		bdaddr_t bdaddr;
-		str2ba(pattern, &bdaddr);
-		adapter = manager_find_adapter(&bdaddr);
-	}
-
-	if (!adapter)
-		return btd_error_no_such_adapter(msg);
-
-	path = adapter_get_path(adapter);
-
-done:
-	reply = dbus_message_new_method_return(msg);
-	if (!reply)
-		return NULL;
-
-	dbus_message_append_args(reply, DBUS_TYPE_OBJECT_PATH, &path,
-							DBUS_TYPE_INVALID);
-
-	return reply;
-}
-
-static gboolean manager_property_get_adapters(
-					const GDBusPropertyTable *property,
-					DBusMessageIter *iter, void *data)
-{
-	DBusMessageIter entry;
-	GSList *l;
-
-	dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
-				DBUS_TYPE_OBJECT_PATH_AS_STRING, &entry);
-
-	for (l = adapters; l != NULL; l = l->next) {
-		struct btd_adapter *adapter = l->data;
-		const char *path = adapter_get_path(adapter);
-
-		dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH,
-								&path);
-	}
-
-	dbus_message_iter_close_container(iter, &entry);
-
-	return TRUE;
-}
-
-static const GDBusMethodTable manager_methods[] = {
-	{ GDBUS_METHOD("DefaultAdapter",
-			NULL, GDBUS_ARGS({ "adapter", "o" }),
-			default_adapter) },
-	{ GDBUS_METHOD("FindAdapter",
-			GDBUS_ARGS({ "pattern", "s" }),
-			GDBUS_ARGS({ "adapter", "o" }),
-			find_adapter) },
-	{ }
-};
-
-static const GDBusSignalTable manager_signals[] = {
-	{ GDBUS_SIGNAL("AdapterAdded",
-			GDBUS_ARGS({ "adapter", "o" })) },
-	{ GDBUS_SIGNAL("AdapterRemoved",
-			GDBUS_ARGS({ "adapter", "o" })) },
-	{ GDBUS_SIGNAL("DefaultAdapterChanged",
-			GDBUS_ARGS({ "adapter", "o" })) },
-	{ }
-};
-
-static const GDBusPropertyTable manager_properties[] = {
-	{ "Adapters", "ao", manager_property_get_adapters },
-	{ }
-};
-
 bool manager_init(const char *path)
 {
-	if (!g_dbus_register_interface(btd_get_dbus_connection(),
-					"/", MANAGER_INTERFACE,
-					manager_methods, manager_signals,
-					manager_properties, NULL, NULL))
-		return false;
-
 	btd_profile_init();
 
 	return true;
@@ -196,21 +66,7 @@ bool manager_init(const char *path)
 
 static void manager_set_default_adapter(int id)
 {
-	struct btd_adapter *adapter;
-	const gchar *path;
-
 	default_adapter_id = id;
-
-	adapter = manager_find_adapter_by_id(id);
-	if (!adapter)
-		return;
-
-	path = adapter_get_path(adapter);
-
-	g_dbus_emit_signal(btd_get_dbus_connection(), "/",
-				MANAGER_INTERFACE, "DefaultAdapterChanged",
-				DBUS_TYPE_OBJECT_PATH, &path,
-				DBUS_TYPE_INVALID);
 }
 
 struct btd_adapter *manager_get_default_adapter(void)
@@ -221,24 +77,15 @@ struct btd_adapter *manager_get_default_adapter(void)
 static void manager_remove_adapter(struct btd_adapter *adapter)
 {
 	uint16_t dev_id = adapter_get_dev_id(adapter);
-	const gchar *path = adapter_get_path(adapter);
 
 	adapters = g_slist_remove(adapters, adapter);
 
-	g_dbus_emit_property_changed(btd_get_dbus_connection(), "/",
-					MANAGER_INTERFACE, "Adapters");
-
 	if (default_adapter_id == dev_id || default_adapter_id < 0) {
 		int new_default = hci_get_route(NULL);
 
 		manager_set_default_adapter(new_default);
 	}
 
-	g_dbus_emit_signal(btd_get_dbus_connection(), "/",
-				MANAGER_INTERFACE, "AdapterRemoved",
-				DBUS_TYPE_OBJECT_PATH, &path,
-				DBUS_TYPE_INVALID);
-
 	adapter_remove(adapter);
 	btd_adapter_unref(adapter);
 
@@ -259,9 +106,6 @@ void manager_cleanup(const char *path)
 	}
 
 	btd_start_exit_timer();
-
-	g_dbus_unregister_interface(btd_get_dbus_connection(),
-						"/", MANAGER_INTERFACE);
 }
 
 static gint adapter_id_cmp(gconstpointer a, gconstpointer b)
@@ -338,13 +182,6 @@ struct btd_adapter *btd_manager_register_adapter(int id, gboolean up)
 	}
 
 	path = adapter_get_path(adapter);
-	g_dbus_emit_signal(btd_get_dbus_connection(), "/",
-				MANAGER_INTERFACE, "AdapterAdded",
-				DBUS_TYPE_OBJECT_PATH, &path,
-				DBUS_TYPE_INVALID);
-
-	g_dbus_emit_property_changed(btd_get_dbus_connection(),  "/",
-					MANAGER_INTERFACE, "Adapters");
 
 	btd_stop_exit_timer();
 
diff --git a/src/manager.h b/src/manager.h
index 4d094b6..fdaabfd 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -25,14 +25,11 @@
 #include <bluetooth/bluetooth.h>
 #include <dbus/dbus.h>
 
-#define MANAGER_INTERFACE "org.bluez.Manager"
-
 typedef void (*adapter_cb) (struct btd_adapter *adapter, gpointer user_data);
 
 bool manager_init(const char *path);
 void manager_cleanup(const char *path);
 
-const char *manager_get_base_path(void);
 struct btd_adapter *manager_find_adapter(const bdaddr_t *sba);
 struct btd_adapter *manager_find_adapter_by_id(int id);
 struct btd_adapter *manager_get_default_adapter(void);
-- 
1.7.11.7


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

* [PATCH v3 08/15] test: Use ObjectManager instead of Devices property
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (6 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 07/15] dbus: Remove org.bluez.Manager Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 09/15] test: Add helper function to find devices Mikel Astiz
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Use the objects and interfaces reported by the ObjectManager in order
to list the available devices per adapter.
---
 test/list-devices | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/test/list-devices b/test/list-devices
index fcff3e7..e8f3f24 100755
--- a/test/list-devices
+++ b/test/list-devices
@@ -30,6 +30,10 @@ def extract_uuids(uuid_list):
 	return list
 
 objects = manager.GetManagedObjects()
+
+all_devices = (str(path) for path, interfaces in objects.iteritems() if
+					"org.bluez.Device" in interfaces.keys())
+
 for path, interfaces in objects.iteritems():
 	if "org.bluez.Adapter" not in interfaces.keys():
 		continue
@@ -39,19 +43,13 @@ for path, interfaces in objects.iteritems():
 	properties = interfaces["org.bluez.Adapter"]
 	for key in properties.keys():
 		value = properties[key]
-		if (key == "Devices"):
-			list = extract_objects(value)
-			print("    %s = %s" % (key, list))
-		elif (key == "UUIDs"):
+		if (key == "UUIDs"):
 			list = extract_uuids(value)
 			print("    %s = %s" % (key, list))
 		else:
 			print("    %s = %s" % (key, value))
 
-	try:
-		device_list = properties["Devices"]
-	except:
-		device_list = []
+	device_list = [d for d in all_devices if d.startswith(path + "/")]
 
 	for dev_path in device_list:
 		print("    [ " + dev_path + " ]")
-- 
1.7.11.7


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

* [PATCH v3 09/15] test: Add helper function to find devices
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (7 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 08/15] test: Use ObjectManager instead of Devices property Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 10/15] adapter: Remove DeviceCreated/DeviceRemoved signals Mikel Astiz
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Add a helper function to the utility library as an alternative to the
convenience method Adapter.FindDevice() in the D-Bus API.
---
 test/bluezutils.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/test/bluezutils.py b/test/bluezutils.py
index 0b8aec3..70fe01b 100644
--- a/test/bluezutils.py
+++ b/test/bluezutils.py
@@ -2,6 +2,7 @@ import dbus
 
 SERVICE_NAME = "org.bluez"
 ADAPTER_INTERFACE = SERVICE_NAME + ".Adapter"
+DEVICE_INTERFACE = SERVICE_NAME + ".Device"
 
 def get_managed_objects():
 	bus = dbus.SystemBus()
@@ -23,3 +24,24 @@ def find_adapter_in_objects(objects, pattern=None):
 			obj = bus.get_object(SERVICE_NAME, path)
 			return dbus.Interface(obj, ADAPTER_INTERFACE)
 	raise Exception("Bluetooth adapter not found")
+
+def find_device(device_address, adapter_pattern=None):
+	return find_device_in_objects(get_managed_objects(), device_address,
+								adapter_pattern)
+
+def find_device_in_objects(objects, device_address, adapter_pattern=None):
+	bus = dbus.SystemBus()
+	path_prefix = ""
+	if adapter_pattern:
+		adapter = find_adapter_in_objects(objects, adapter_pattern)
+		path_prefix = adapter.object_path
+	for path, ifaces in objects.iteritems():
+		device = ifaces.get(DEVICE_INTERFACE)
+		if device is None:
+			continue
+		if (device["Address"] == device_address and
+						path.startswith(path_prefix)):
+			obj = bus.get_object(SERVICE_NAME, path)
+			return dbus.Interface(obj, DEVICE_INTERFACE)
+
+	raise Exception("Bluetooth device not found")
-- 
1.7.11.7


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

* [PATCH v3 10/15] adapter: Remove DeviceCreated/DeviceRemoved signals
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (8 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 09/15] test: Add helper function to find devices Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 11/15] adapter: Remove redundant Devices property Mikel Astiz
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

The Adapter interface already reports changes in the device list in form
of property changes, so there is no need to keep these two signals.
---
 doc/adapter-api.txt |  8 --------
 src/adapter.c       | 17 -----------------
 2 files changed, 25 deletions(-)

diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index b638586..132e60f 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -116,14 +116,6 @@ Signals		DevicesFound(array{object path, dict values})
 			The dictionary contains the properties from the
 			org.bluez.Device interface.
 
-		DeviceCreated(object device)
-
-			Parameter is object path of created device.
-
-		DeviceRemoved(object device)
-
-			Parameter is object path of removed device.
-
 Properties	string Address [readonly]
 
 			The Bluetooth device address.
diff --git a/src/adapter.c b/src/adapter.c
index ea0394f..a816ae3 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1010,7 +1010,6 @@ static struct btd_device *adapter_create_device(struct btd_adapter *adapter,
 						uint8_t bdaddr_type)
 {
 	struct btd_device *device;
-	const char *path;
 
 	DBG("%s", address);
 
@@ -1022,12 +1021,6 @@ static struct btd_device *adapter_create_device(struct btd_adapter *adapter,
 
 	adapter->devices = g_slist_append(adapter->devices, device);
 
-	path = device_get_path(device);
-	g_dbus_emit_signal(btd_get_dbus_connection(), adapter->path,
-			ADAPTER_INTERFACE, "DeviceCreated",
-			DBUS_TYPE_OBJECT_PATH, &path,
-			DBUS_TYPE_INVALID);
-
 	g_dbus_emit_property_changed(btd_get_dbus_connection(),
 				adapter->path, ADAPTER_INTERFACE, "Devices");
 
@@ -1055,7 +1048,6 @@ void adapter_remove_device(struct btd_adapter *adapter,
 						struct btd_device *dev,
 						gboolean remove_storage)
 {
-	const gchar *dev_path = device_get_path(dev);
 	struct discovery *discovery = adapter->discovery;
 	GList *l;
 
@@ -1087,11 +1079,6 @@ void adapter_remove_device(struct btd_adapter *adapter,
 	g_dbus_emit_property_changed(btd_get_dbus_connection(),
 				adapter->path, ADAPTER_INTERFACE, "Devices");
 
-	g_dbus_emit_signal(btd_get_dbus_connection(), adapter->path,
-			ADAPTER_INTERFACE, "DeviceRemoved",
-			DBUS_TYPE_OBJECT_PATH, &dev_path,
-			DBUS_TYPE_INVALID);
-
 	device_remove(dev, remove_storage);
 }
 
@@ -1683,10 +1670,6 @@ static const GDBusMethodTable adapter_methods[] = {
 };
 
 static const GDBusSignalTable adapter_signals[] = {
-	{ GDBUS_SIGNAL("DeviceCreated",
-			GDBUS_ARGS({ "device", "o" })) },
-	{ GDBUS_SIGNAL("DeviceRemoved",
-			GDBUS_ARGS({ "device", "o" })) },
 	{ GDBUS_SIGNAL("DevicesFound",
 			GDBUS_ARGS({ "devices", "a{oa{sv}}" })) },
 	{ }
-- 
1.7.11.7


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

* [PATCH v3 11/15] adapter: Remove redundant Devices property
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (9 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 10/15] adapter: Remove DeviceCreated/DeviceRemoved signals Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 12/15] test: Avoid using Adapter.FindDevice() Mikel Astiz
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

The ObjectManager interface already reports the list of devices, so the
the property can be entirely removed.
---
 doc/adapter-api.txt |  4 ----
 src/adapter.c       | 30 ------------------------------
 2 files changed, 34 deletions(-)

diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index 132e60f..3582793 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -180,10 +180,6 @@ Properties	string Address [readonly]
 
 			Indicates that a device discovery procedure is active.
 
-		array{object} Devices [readonly]
-
-			List of device object paths.
-
 		array{string} UUIDs [readonly]
 
 			List of 128-bit UUIDs that represents the available
diff --git a/src/adapter.c b/src/adapter.c
index a816ae3..0c37ba4 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1021,9 +1021,6 @@ static struct btd_device *adapter_create_device(struct btd_adapter *adapter,
 
 	adapter->devices = g_slist_append(adapter->devices, device);
 
-	g_dbus_emit_property_changed(btd_get_dbus_connection(),
-				adapter->path, ADAPTER_INTERFACE, "Devices");
-
 	return device;
 }
 
@@ -1076,9 +1073,6 @@ void adapter_remove_device(struct btd_adapter *adapter,
 		service_auth_cancel(auth);
 	}
 
-	g_dbus_emit_property_changed(btd_get_dbus_connection(),
-				adapter->path, ADAPTER_INTERFACE, "Devices");
-
 	device_remove(dev, remove_storage);
 }
 
@@ -1384,29 +1378,6 @@ static gboolean adapter_property_get_discovering(
 	return TRUE;
 }
 
-static gboolean adapter_property_get_devices(
-					const GDBusPropertyTable *property,
-					DBusMessageIter *iter, void *data)
-{
-	struct btd_adapter *adapter = data;
-	DBusMessageIter entry;
-	GSList *l;
-
-	dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
-				DBUS_TYPE_OBJECT_PATH_AS_STRING, &entry);
-
-	for (l = adapter->devices; l != NULL; l = l->next) {
-		const char *path = device_get_path(l->data);
-
-		dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH,
-								&path);
-	}
-
-	dbus_message_iter_close_container(iter, &entry);
-
-	return TRUE;
-}
-
 static gboolean adapter_property_get_uuids(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -1691,7 +1662,6 @@ static const GDBusPropertyTable adapter_properties[] = {
 	{ "PairableTimeout", "u", adapter_property_get_pairable_timeout,
 				adapter_property_set_pairable_timeout },
 	{ "Discovering", "b", adapter_property_get_discovering },
-	{ "Devices", "ao", adapter_property_get_devices },
 	{ "UUIDs", "as", adapter_property_get_uuids },
 	{ }
 };
-- 
1.7.11.7


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

* [PATCH v3 12/15] test: Avoid using Adapter.FindDevice()
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (10 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 11/15] adapter: Remove redundant Devices property Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 13/15] adapter: Remove FindDevice method from D-Bus API Mikel Astiz
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

The method is now deprecated and thus the replacement utility library
should be used in the test scripts.
---
 test/simple-agent      | 12 +++++------
 test/test-attrib       |  7 ++-----
 test/test-cyclingspeed |  9 ++++++--
 test/test-device       | 57 +++++++++++++++++++++++++++-----------------------
 test/test-heartrate    | 13 +++++++-----
 test/test-oob          | 12 +++++++----
 test/test-proximity    |  7 ++-----
 test/test-thermometer  | 10 +++++++--
 8 files changed, 71 insertions(+), 56 deletions(-)

diff --git a/test/simple-agent b/test/simple-agent
index 13c3ce7..3c51530 100755
--- a/test/simple-agent
+++ b/test/simple-agent
@@ -149,10 +149,9 @@ if __name__ == '__main__':
 	if options.capability:
 		capability  = options.capability
 
+	adapter_pattern = None
 	if len(args) > 0:
-		adapter = bluezutils.find_adapter(args[0])
-	else:
-		adapter = bluezutils.find_adapter()
+		adapter_pattern = args[0]
 
 	path = "/test/agent"
 	agent = Agent(bus, path)
@@ -160,16 +159,15 @@ if __name__ == '__main__':
 	mainloop = GObject.MainLoop()
 
 	if len(args) > 1:
-		dev_path = adapter.FindDevice(args[1])
-		device = dbus.Interface(bus.get_object("org.bluez", dev_path),
-						"org.bluez.Device")
-
+		device = bluezutils.find_device(args[1], adapter_pattern)
+		dev_path = device.object_path
 		agent.set_exit_on_release(False)
 		device.Pair(path, capability, timeout=options.timeout,
 					reply_handler=pair_reply,
 					error_handler=pair_error)
 		device_obj = device
 	else:
+		adapter = bluezutils.find_adapter(adapter_pattern)
 		adapter.RegisterAgent(path, capability)
 		print("Agent registered")
 
diff --git a/test/test-attrib b/test/test-attrib
index f75a566..2b0b010 100755
--- a/test/test-attrib
+++ b/test/test-attrib
@@ -27,8 +27,6 @@ parser = OptionParser(option_list=option_list)
 
 (options, args) = parser.parse_args()
 
-adapter = bluezutils.find_adapter(options.dev_id)
-
 if (len(args) < 1):
 	print("Usage: %s <command>" % (sys.argv[0]))
 	print("")
@@ -39,6 +37,7 @@ if (len(args) < 1):
 	sys.exit(1)
 
 if (args[0] == "list"):
+	adapter = bluezutils.find_adapter(options.dev_id)
 	for path in adapter.GetProperties()["Devices"]:
 		device = dbus.Interface(bus.get_object("org.bluez", path),
 							"org.bluez.Device")
@@ -63,9 +62,7 @@ if (args[0] == "services"):
 	if (len(args) < 2):
 		print("Need address parameter")
 	else:
-		path = adapter.FindDevice(args[1])
-		device = dbus.Interface(bus.get_object("org.bluez", path),
-							"org.bluez.Device")
+		device = bluezutils.find_device(args[1], options.dev_id)
 		properties = device.GetProperties()
 		for path in properties["Services"]:
 			print(path)
diff --git a/test/test-cyclingspeed b/test/test-cyclingspeed
index 2bfea36..10a16aa 100755
--- a/test/test-cyclingspeed
+++ b/test/test-cyclingspeed
@@ -125,10 +125,15 @@ if __name__ == "__main__":
 		print("\tSetCumulativeWheelRevolutions <value>")
 		sys.exit(1)
 
-	adapter = bluezutils.find_adapter(options.adapter)
+	managed_objects = bluezutils.get_managed_objects()
+	adapter = bluezutils.find_adapter_in_objects(managed_objects,
+								options.adapter)
 	adapter_path = adapter.object_path
 
-	device_path = adapter.FindDevice(options.address)
+	device = bluezutils.find_device_in_objects(managed_objects,
+								options.address,
+								options.adapter)
+	device_path = device.object_path
 
 	cscmanager = dbus.Interface(bus.get_object("org.bluez", adapter_path),
 						"org.bluez.CyclingSpeedManager")
diff --git a/test/test-device b/test/test-device
index f4a40c4..d40d656 100755
--- a/test/test-device
+++ b/test/test-device
@@ -23,10 +23,6 @@ parser = OptionParser(option_list=option_list)
 
 (options, args) = parser.parse_args()
 
-adapter = bluezutils.find_adapter(options.dev_id)
-
-adapter_path = adapter.object_path
-
 if (len(args) < 1):
 	print("Usage: %s <command>" % (sys.argv[0]))
 	print("")
@@ -45,6 +41,9 @@ if (len(args) < 1):
 	sys.exit(1)
 
 if (args[0] == "list"):
+	adapter = bluezutils.find_adapter(options.dev_id)
+	adapter_path = adapter.object_path
+
 	om = dbus.Interface(bus.get_object("org.bluez", "/"),
 					"org.freedesktop.DBus.ObjectManager")
 	objects = om.GetManagedObjects()
@@ -73,6 +72,7 @@ if (args[0] == "create"):
 	if (len(args) < 2):
 		print("Need address parameter")
 	else:
+		adapter = bluezutils.find_adapter(options.dev_id)
 		adapter.CreateDevice(args[1],
 				reply_handler=create_device_reply,
 				error_handler=create_device_error)
@@ -82,8 +82,14 @@ if (args[0] == "remove"):
 	if (len(args) < 2):
 		print("Need address or object path parameter")
 	else:
+		managed_objects = bluezutils.get_managed_objects()
+		adapter = bluezutils.find_adapter_in_objects(managed_objects,
+								options.dev_id)
 		try:
-			path = adapter.FindDevice(args[1])
+			dev = bluezutils.find_device_in_objects(managed_objects,
+								args[1],
+								options.dev_id)
+			path = dev.object_path
 		except:
 			path = args[1]
 		adapter.RemoveDevice(path)
@@ -93,9 +99,7 @@ if (args[0] == "connect"):
 	if (len(args) < 2):
 		print("Need address parameter")
 	else:
-		path = adapter.FindDevice(args[1])
-		device = dbus.Interface(bus.get_object("org.bluez", path),
-							"org.bluez.Device")
+		device = bluezutils.find_device(args[1], options.dev_id)
 		if (len(args) > 2):
 			device.ConnectProfile(args[2])
 		else:
@@ -106,9 +110,7 @@ if (args[0] == "disconnect"):
 	if (len(args) < 2):
 		print("Need address parameter")
 	else:
-		path = adapter.FindDevice(args[1])
-		device = dbus.Interface(bus.get_object("org.bluez", path),
-							"org.bluez.Device")
+		device = bluezutils.find_device(args[1], options.dev_id)
 		if (len(args) > 2):
 			device.DisconnectProfile(args[2])
 		else:
@@ -119,9 +121,7 @@ if (args[0] == "discover"):
 	if (len(args) < 2):
 		print("Need address parameter")
 	else:
-		path = adapter.FindDevice(args[1])
-		device = dbus.Interface(bus.get_object("org.bluez", path),
-							"org.bluez.Device")
+		device = bluezutils.find_device(args[1], options.dev_id)
 		if (len(args) < 3):
 			pattern = ""
 		else:
@@ -139,7 +139,7 @@ if (args[0] == "class"):
 	if (len(args) < 2):
 		print("Need address parameter")
 	else:
-		path = adapter.FindDevice(args[1])
+		device = bluezutils.find_device(args[1], options.dev_id)
 		device = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
 		cls = device.Get("org.bluez.Device", "Class")
@@ -150,10 +150,11 @@ if (args[0] == "name"):
 	if (len(args) < 2):
 		print("Need address parameter")
 	else:
-		path = adapter.FindDevice(args[1])
-		device = dbus.Interface(bus.get_object("org.bluez", path),
+		device = bluezutils.find_device(args[1], options.dev_id)
+		path = device.object_path
+		props = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
-		name = device.Get("org.bluez.Device", "Name")
+		name = props.Get("org.bluez.Device", "Name")
 		print(name)
 	sys.exit(0)
 
@@ -161,8 +162,9 @@ if (args[0] == "alias"):
 	if (len(args) < 2):
 		print("Need address parameter")
 	else:
-		path = adapter.FindDevice(args[1])
-		device = dbus.Interface(bus.get_object("org.bluez", path),
+		device = bluezutils.find_device(args[1], options.dev_id)
+		path = device.object_path
+		props = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
 		if (len(args) < 3):
 			alias = device.Get("org.bluez.Device", "Alias")
@@ -175,8 +177,9 @@ if (args[0] == "trusted"):
 	if (len(args) < 2):
 		print("Need address parameter")
 	else:
-		path = adapter.FindDevice(args[1])
-		device = dbus.Interface(bus.get_object("org.bluez", path),
+		device = bluezutils.find_device(args[1], options.dev_id)
+		path = device.object_path
+		props = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
 		if (len(args) < 3):
 			trusted = device.Get("org.bluez.Device", "Trusted")
@@ -195,8 +198,9 @@ if (args[0] == "blocked"):
 	if (len(args) < 2):
 		print("Need address parameter")
 	else:
-		path = adapter.FindDevice(args[1])
-		device = dbus.Interface(bus.get_object("org.bluez", path),
+		device = bluezutils.find_device(args[1], options.dev_id)
+		path = device.object_path
+		props = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
 		if (len(args) < 3):
 			blocked = device.Get("org.bluez.Device", "Blocked")
@@ -215,8 +219,9 @@ if (args[0] == "services"):
 	if (len(args) < 2):
 		print("Need address parameter")
 	else:
-		path = adapter.FindDevice(args[1])
-		device = dbus.Interface(bus.get_object("org.bluez", path),
+		device = bluezutils.find_device(args[1], options.dev_id)
+		path = device.object_path
+		props = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
 		services = device.Get("org.bluez.Device", "Services")
 		for path in services:
diff --git a/test/test-heartrate b/test/test-heartrate
index a08e8df..47dd012 100755
--- a/test/test-heartrate
+++ b/test/test-heartrate
@@ -54,18 +54,21 @@ if __name__ == "__main__":
 		print("\tReset")
 		sys.exit(1)
 
-	adapter = bluezutils.find_adapter(options.adapter)
+	managed_objects = bluezutils.get_managed_objects()
+	adapter = bluezutils.find_adapter_in_objects(managed_objects,
+								options.adapter)
 	adapter_path = adapter.object_path
+
 	heartrateManager = dbus.Interface(bus.get_object("org.bluez",
 				adapter_path), "org.bluez.HeartRateManager")
 
 	path = "/test/watcher"
 	heartrateManager.RegisterWatcher(path)
 
-	device_path = adapter.FindDevice(options.address)
-
-	device = dbus.Interface(bus.get_object("org.bluez", device_path),
-							"org.bluez.Device")
+	device = bluezutils.find_device_in_objects(managed_objects,
+								options.address,
+								options.adapter)
+	device_path = device.object_path
 
 	heartrate = dbus.Interface(bus.get_object("org.bluez",
 					device_path), "org.bluez.HeartRate")
diff --git a/test/test-oob b/test/test-oob
index 34e042d..87c558f 100755
--- a/test/test-oob
+++ b/test/test-oob
@@ -42,14 +42,18 @@ if __name__ == '__main__':
 	print("Removing any existing bond...")
 
 	try:
-		device = adapter0.FindDevice(adapter1_address)
-		adapter0.RemoveDevice(device)
+		dev = bluezutils.find_device_in_objects(managed_objects,
+							adapter1_address,
+							adapter0_address)
+		adapter0.RemoveDevice(dev.object_path)
 	except:
 		pass
 
 	try:
-		device = adapter1.FindDevice(adapter0_address)
-		adapter1.RemoveDevice(device)
+		dev = bluezutils.find_device_in_objects(managed_objects,
+							adapter0_address,
+							adapter1_address)
+		adapter1.RemoveDevice(dev.object_path)
 	except:
 		pass
 
diff --git a/test/test-proximity b/test/test-proximity
index afde3fb..d6862de 100755
--- a/test/test-proximity
+++ b/test/test-proximity
@@ -35,10 +35,6 @@ if __name__ == "__main__":
 		]
 	parser = OptionParser(option_list=option_list)
 
-	(options, args) = parser.parse_args()
-
-	adapter = bluezutils.find_adapter(options.dev_id)
-
 	if (len(args) < 1):
 		print("Usage: %s <command>" % (sys.argv[0]))
 		print("")
@@ -46,7 +42,8 @@ if __name__ == "__main__":
 		print("  -b MAC ImmediateAlertLevel <none|mild|high>")
 		sys.exit(1)
 
-	device_path = adapter.FindDevice(options.address)
+	device = bluezutils.find_device(options.address, options.dev_id)
+	device_path = device.object_path
 
 	bus.add_signal_receiver(properties_changed, bus_name="org.bluez",
 			path=device_path,
diff --git a/test/test-thermometer b/test/test-thermometer
index 5a884a3..fdb772f 100755
--- a/test/test-thermometer
+++ b/test/test-thermometer
@@ -58,12 +58,18 @@ if __name__ == "__main__":
 		print("\tEnableIntermediateMeasurement")
 		sys.exit(1)
 
-	adapter = bluezutils.find_adapter(options.adapter)
+	managed_objects = bluezutils.get_managed_objects()
+	adapter = bluezutils.find_adapter_in_objects(managed_objects,
+								options.adapter)
 	adapter_path = adapter.object_path
+
 	thermometer_manager = dbus.Interface(bus.get_object("org.bluez",
 				adapter_path), "org.bluez.ThermometerManager")
 
-	device_path = adapter.FindDevice(options.address)
+	device = bluezutils.find_device_in_objects(managed_objects,
+								options.address,
+								options.adapter)
+	device_path = device.object_path
 
 	bus.add_signal_receiver(properties_changed, bus_name="org.bluez",
 			path=device_path,
-- 
1.7.11.7


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

* [PATCH v3 13/15] adapter: Remove FindDevice method from D-Bus API
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (11 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 12/15] test: Avoid using Adapter.FindDevice() Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 14/15] dbus: Rename to org.bluez.Device1 Mikel Astiz
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

ObjectManager.GetManagedObjects() returns all devices and their
corresponding properties to any interested client. The device address is
included in the property dictionary and therefore having such a
FindDevice method is an unnecessary duplication.
---
 doc/adapter-api.txt |  7 -------
 src/adapter.c       | 38 --------------------------------------
 2 files changed, 45 deletions(-)

diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index 3582793..983a20d 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -64,13 +64,6 @@ Methods		void RequestSession()
 					 org.bluez.Error.Failed
 					 org.bluez.Error.NotAuthorized
 
-		object FindDevice(string address)
-
-			Returns the object path of device for given address.
-
-			Possible Errors: org.bluez.Error.DoesNotExist
-					 org.bluez.Error.InvalidArguments
-
 		void RemoveDevice(object device)
 
 			This removes the remote device object at the given
diff --git a/src/adapter.c b/src/adapter.c
index 0c37ba4..a1c7170 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1521,40 +1521,6 @@ static DBusMessage *remove_device(DBusConnection *conn, DBusMessage *msg,
 	return NULL;
 }
 
-static DBusMessage *find_device(DBusConnection *conn, DBusMessage *msg,
-								void *data)
-{
-	struct btd_adapter *adapter = data;
-	struct btd_device *device;
-	DBusMessage *reply;
-	const gchar *address;
-	GSList *l;
-	const gchar *dev_path;
-
-	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
-						DBUS_TYPE_INVALID))
-		return btd_error_invalid_args(msg);
-
-	l = g_slist_find_custom(adapter->devices,
-			address, (GCompareFunc) device_address_cmp);
-	if (!l)
-		return btd_error_does_not_exist(msg);
-
-	device = l->data;
-
-	reply = dbus_message_new_method_return(msg);
-	if (!reply)
-		return NULL;
-
-	dev_path = device_get_path(device);
-
-	dbus_message_append_args(reply,
-				DBUS_TYPE_OBJECT_PATH, &dev_path,
-				DBUS_TYPE_INVALID);
-
-	return reply;
-}
-
 static void agent_removed(struct agent *agent, struct btd_adapter *adapter)
 {
 	mgmt_set_io_capability(adapter->dev_id, IO_CAPABILITY_NOINPUTNOOUTPUT);
@@ -1626,10 +1592,6 @@ static const GDBusMethodTable adapter_methods[] = {
 	{ GDBUS_ASYNC_METHOD("RemoveDevice",
 			GDBUS_ARGS({ "device", "o" }), NULL,
 			remove_device) },
-	{ GDBUS_METHOD("FindDevice",
-			GDBUS_ARGS({ "address", "s" }),
-			GDBUS_ARGS({ "device", "o" }),
-			find_device) },
 	{ GDBUS_METHOD("RegisterAgent",
 			GDBUS_ARGS({ "agent", "o" },
 					{ "capability", "s" }), NULL,
-- 
1.7.11.7


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

* [PATCH v3 14/15] dbus: Rename to org.bluez.Device1
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (12 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 13/15] adapter: Remove FindDevice method from D-Bus API Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 12:51 ` [PATCH v3 15/15] dbus: Rename to org.bluez.Adapter1 Mikel Astiz
  2012-12-05 14:44 ` [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Johan Hedberg
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Trivially add the numbering suffix to org.bluez.Device according to
the proposal for BlueZ 5.
---
 doc/adapter-api.txt    |  2 +-
 doc/device-api.txt     |  2 +-
 profiles/cups/main.c   |  4 ++--
 src/device.h           |  2 +-
 test/bluezutils.py     |  2 +-
 test/list-devices      |  4 ++--
 test/monitor-bluetooth |  2 +-
 test/simple-agent      |  4 ++--
 test/test-attrib       |  2 +-
 test/test-device       | 22 +++++++++++-----------
 10 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index 983a20d..cf8374d 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -107,7 +107,7 @@ Signals		DevicesFound(array{object path, dict values})
 			device discovery.
 
 			The dictionary contains the properties from the
-			org.bluez.Device interface.
+			org.bluez.Device1 interface.
 
 Properties	string Address [readonly]
 
diff --git a/doc/device-api.txt b/doc/device-api.txt
index c1f2361..36ea1d9 100644
--- a/doc/device-api.txt
+++ b/doc/device-api.txt
@@ -11,7 +11,7 @@ Device hierarchy
 ================
 
 Service		org.bluez
-Interface	org.bluez.Device
+Interface	org.bluez.Device1
 Object path	[variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
 
 Methods		dict DiscoverServices(string pattern)
diff --git a/profiles/cups/main.c b/profiles/cups/main.c
index 977c057..ae0cc6a 100644
--- a/profiles/cups/main.c
+++ b/profiles/cups/main.c
@@ -133,7 +133,7 @@ static char *device_get_ieee1284_id(const char *adapter, const char *device)
 
 	/* Look for the service handle of the HCRP service */
 	message = dbus_message_new_method_call("org.bluez", device,
-						"org.bluez.Device",
+						"org.bluez.Device1",
 						"DiscoverServices");
 	dbus_message_iter_init_append(message, &iter);
 	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &hcr_print);
@@ -309,7 +309,7 @@ static gboolean device_is_printer(const char *adapter, const char *device_path,
 	gboolean retval;
 
 	message = dbus_message_new_method_call("org.bluez", device_path,
-							"org.bluez.Device",
+							"org.bluez.Device1",
 							"GetProperties");
 
 	reply = dbus_connection_send_with_reply_and_block(conn,
diff --git a/src/device.h b/src/device.h
index 1d7f54f..cb0bb50 100644
--- a/src/device.h
+++ b/src/device.h
@@ -22,7 +22,7 @@
  *
  */
 
-#define DEVICE_INTERFACE	"org.bluez.Device"
+#define DEVICE_INTERFACE	"org.bluez.Device1"
 
 struct btd_device;
 
diff --git a/test/bluezutils.py b/test/bluezutils.py
index 70fe01b..803805b 100644
--- a/test/bluezutils.py
+++ b/test/bluezutils.py
@@ -2,7 +2,7 @@ import dbus
 
 SERVICE_NAME = "org.bluez"
 ADAPTER_INTERFACE = SERVICE_NAME + ".Adapter"
-DEVICE_INTERFACE = SERVICE_NAME + ".Device"
+DEVICE_INTERFACE = SERVICE_NAME + ".Device1"
 
 def get_managed_objects():
 	bus = dbus.SystemBus()
diff --git a/test/list-devices b/test/list-devices
index e8f3f24..7e56239 100755
--- a/test/list-devices
+++ b/test/list-devices
@@ -32,7 +32,7 @@ def extract_uuids(uuid_list):
 objects = manager.GetManagedObjects()
 
 all_devices = (str(path) for path, interfaces in objects.iteritems() if
-					"org.bluez.Device" in interfaces.keys())
+					"org.bluez.Device1" in interfaces.keys())
 
 for path, interfaces in objects.iteritems():
 	if "org.bluez.Adapter" not in interfaces.keys():
@@ -55,7 +55,7 @@ for path, interfaces in objects.iteritems():
 		print("    [ " + dev_path + " ]")
 
 		dev = objects[dev_path]
-		properties = dev["org.bluez.Device"]
+		properties = dev["org.bluez.Device1"]
 
 		for key in properties.keys():
 			value = properties[key]
diff --git a/test/monitor-bluetooth b/test/monitor-bluetooth
index 45cc910..cfda322 100755
--- a/test/monitor-bluetooth
+++ b/test/monitor-bluetooth
@@ -7,7 +7,7 @@ import gobject
 import dbus
 import dbus.mainloop.glib
 
-relevant_ifaces = [ "org.bluez.Adapter", "org.bluez.Device" ]
+relevant_ifaces = [ "org.bluez.Adapter", "org.bluez.Device1" ]
 
 def property_changed(interface, changed, invalidated, path):
 	iface = interface[interface.rfind(".") + 1:]
diff --git a/test/simple-agent b/test/simple-agent
index 3c51530..15f2a32 100755
--- a/test/simple-agent
+++ b/test/simple-agent
@@ -24,11 +24,11 @@ def ask(prompt):
 def set_trusted(path):
 	props = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
-	props.Set("org.bluez.Device", "Trusted", True)
+	props.Set("org.bluez.Device1", "Trusted", True)
 
 def dev_connect(path):
 	dev = dbus.Interface(bus.get_object("org.bluez", path),
-							"org.bluez.Device")
+							"org.bluez.Device1")
 	dev.Connect()
 
 class Rejected(dbus.DBusException):
diff --git a/test/test-attrib b/test/test-attrib
index 2b0b010..aadffaa 100755
--- a/test/test-attrib
+++ b/test/test-attrib
@@ -40,7 +40,7 @@ if (args[0] == "list"):
 	adapter = bluezutils.find_adapter(options.dev_id)
 	for path in adapter.GetProperties()["Devices"]:
 		device = dbus.Interface(bus.get_object("org.bluez", path),
-							"org.bluez.Device")
+							"org.bluez.Device1")
 		devprop = device.GetProperties()
 		print("[ %s ]" % devprop["Address"])
 		for path in devprop["Services"]:
diff --git a/test/test-device b/test/test-device
index d40d656..655eeae 100755
--- a/test/test-device
+++ b/test/test-device
@@ -49,9 +49,9 @@ if (args[0] == "list"):
 	objects = om.GetManagedObjects()
 
 	for path, interfaces in objects.iteritems():
-		if "org.bluez.Device" not in interfaces:
+		if "org.bluez.Device1" not in interfaces:
 			continue
-		properties = interfaces["org.bluez.Device"]
+		properties = interfaces["org.bluez.Device1"]
 		if properties["Adapter"] != adapter_path:
 			continue;
 		print("%s %s" % (properties["Address"], properties["Alias"]))
@@ -142,7 +142,7 @@ if (args[0] == "class"):
 		device = bluezutils.find_device(args[1], options.dev_id)
 		device = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
-		cls = device.Get("org.bluez.Device", "Class")
+		cls = device.Get("org.bluez.Device1", "Class")
 		print("0x%06x" % cls)
 	sys.exit(0)
 
@@ -154,7 +154,7 @@ if (args[0] == "name"):
 		path = device.object_path
 		props = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
-		name = props.Get("org.bluez.Device", "Name")
+		name = props.Get("org.bluez.Device1", "Name")
 		print(name)
 	sys.exit(0)
 
@@ -167,10 +167,10 @@ if (args[0] == "alias"):
 		props = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
 		if (len(args) < 3):
-			alias = device.Get("org.bluez.Device", "Alias")
+			alias = device.Get("org.bluez.Device1", "Alias")
 			print(alias)
 		else:
-			device.Set("org.bluez.Device", "Alias", args[2])
+			device.Set("org.bluez.Device1", "Alias", args[2])
 	sys.exit(0)
 
 if (args[0] == "trusted"):
@@ -182,7 +182,7 @@ if (args[0] == "trusted"):
 		props = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
 		if (len(args) < 3):
-			trusted = device.Get("org.bluez.Device", "Trusted")
+			trusted = device.Get("org.bluez.Device1", "Trusted")
 			print(trusted)
 		else:
 			if (args[2] == "yes"):
@@ -191,7 +191,7 @@ if (args[0] == "trusted"):
 				value = dbus.Boolean(0)
 			else:
 				value = dbus.Boolean(args[2])
-			device.Set("org.bluez.Device", "Trusted", value)
+			device.Set("org.bluez.Device1", "Trusted", value)
 	sys.exit(0)
 
 if (args[0] == "blocked"):
@@ -203,7 +203,7 @@ if (args[0] == "blocked"):
 		props = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
 		if (len(args) < 3):
-			blocked = device.Get("org.bluez.Device", "Blocked")
+			blocked = device.Get("org.bluez.Device1", "Blocked")
 			print(blocked)
 		else:
 			if (args[2] == "yes"):
@@ -212,7 +212,7 @@ if (args[0] == "blocked"):
 				value = dbus.Boolean(0)
 			else:
 				value = dbus.Boolean(args[2])
-			device.Set("org.bluez.Device", "Blocked", value)
+			device.Set("org.bluez.Device1", "Blocked", value)
 	sys.exit(0)
 
 if (args[0] == "services"):
@@ -223,7 +223,7 @@ if (args[0] == "services"):
 		path = device.object_path
 		props = dbus.Interface(bus.get_object("org.bluez", path),
 					"org.freedesktop.DBus.Properties")
-		services = device.Get("org.bluez.Device", "Services")
+		services = device.Get("org.bluez.Device1", "Services")
 		for path in services:
 			print(path)
 	sys.exit(0)
-- 
1.7.11.7


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

* [PATCH v3 15/15] dbus: Rename to org.bluez.Adapter1
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (13 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 14/15] dbus: Rename to org.bluez.Device1 Mikel Astiz
@ 2012-12-05 12:51 ` Mikel Astiz
  2012-12-05 14:44 ` [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Johan Hedberg
  15 siblings, 0 replies; 17+ messages in thread
From: Mikel Astiz @ 2012-12-05 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mikel Astiz

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

Trivially add the numbering suffix to org.bluez.Adapter according to
the proposal for BlueZ 5.
---
 doc/adapter-api.txt    |  2 +-
 doc/oob-api.txt        |  2 +-
 profiles/cups/main.c   | 20 ++++++++++----------
 src/adapter.h          |  2 +-
 test/agent.c           |  7 ++++---
 test/bluezutils.py     |  2 +-
 test/list-devices      |  4 ++--
 test/monitor-bluetooth |  2 +-
 test/test-adapter      | 32 ++++++++++++++++----------------
 test/test-discovery    |  4 ++--
 test/test-health       |  4 ++--
 test/test-health-sink  |  4 ++--
 test/test-manager      |  4 ++--
 13 files changed, 45 insertions(+), 44 deletions(-)

diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index cf8374d..5d2ea65 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -11,7 +11,7 @@ Adapter hierarchy
 =================
 
 Service		org.bluez
-Interface	org.bluez.Adapter
+Interface	org.bluez.Adapter1
 Object path	[variable prefix]/{hci0,hci1,...}
 
 Methods		void RequestSession()
diff --git a/doc/oob-api.txt b/doc/oob-api.txt
index 7f73db4..d54f612 100644
--- a/doc/oob-api.txt
+++ b/doc/oob-api.txt
@@ -28,7 +28,7 @@ Methods		dict ReadLocalData()
 					16 bytes randomizer blob.
 
 			Other data that can be transmitted via OOB mechanism
-			can be obtained from org.bluez.Adapter interface.
+			can be obtained from org.bluez.Adapter1 interface.
 
 			Note: This method will generate and return new data
 			every time it is called. Data received in previous
diff --git a/profiles/cups/main.c b/profiles/cups/main.c
index ae0cc6a..ef3a176 100644
--- a/profiles/cups/main.c
+++ b/profiles/cups/main.c
@@ -342,7 +342,7 @@ static void remote_device_found(const char *adapter, const char *bdaddr,
 	assert(adapter != NULL);
 
 	message = dbus_message_new_method_call("org.bluez", adapter,
-							"org.bluez.Adapter",
+							"org.bluez.Adapter1",
 							"FindDevice");
 	dbus_message_iter_init_append(message, &iter);
 	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &bdaddr);
@@ -357,7 +357,7 @@ static void remote_device_found(const char *adapter, const char *bdaddr,
 
 	if (!reply) {
 		message = dbus_message_new_method_call("org.bluez", adapter,
-							"org.bluez.Adapter",
+							"org.bluez.Adapter1",
 							"CreateDevice");
 		dbus_message_iter_init_append(message, &iter);
 		dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &bdaddr);
@@ -417,7 +417,7 @@ static gboolean list_known_printers(const char *adapter)
 	DBusMessage *message, *reply;
 
 	message = dbus_message_new_method_call("org.bluez", adapter,
-						"org.bluez.Adapter",
+						"org.bluez.Adapter1",
 						"ListDevices");
 	if (message == NULL)
 		return FALSE;
@@ -467,7 +467,7 @@ static gboolean list_known_printers(const char *adapter)
 static DBusHandlerResult filter_func(DBusConnection *connection,
 					DBusMessage *message, void *user_data)
 {
-	if (dbus_message_is_signal(message, "org.bluez.Adapter",
+	if (dbus_message_is_signal(message, "org.bluez.Adapter1",
 						"DeviceFound")) {
 		const char *adapter, *bdaddr;
 		char *name;
@@ -481,7 +481,7 @@ static DBusHandlerResult filter_func(DBusConnection *connection,
 		if (parse_device_properties(&iter, &name, NULL))
 			remote_device_found(adapter, bdaddr, name);
 		g_free (name);
-	} else if (dbus_message_is_signal(message, "org.bluez.Adapter",
+	} else if (dbus_message_is_signal(message, "org.bluez.Adapter1",
 						"DeviceDisappeared")) {
 		const char *bdaddr;
 
@@ -489,7 +489,7 @@ static DBusHandlerResult filter_func(DBusConnection *connection,
 					DBUS_TYPE_STRING, &bdaddr,
 					DBUS_TYPE_INVALID);
 		remote_device_disappeared(bdaddr);
-	} else if (dbus_message_is_signal(message, "org.bluez.Adapter",
+	} else if (dbus_message_is_signal(message, "org.bluez.Adapter1",
 						"PropertyChanged")) {
 		DBusMessageIter iter, value_iter;
 		const char *name;
@@ -582,7 +582,7 @@ static gboolean list_printers(void)
 
 #define MATCH_FORMAT				\
 	"type='signal',"			\
-	"interface='org.bluez.Adapter',"	\
+	"interface='org.bluez.Adapter1',"	\
 	"sender='org.bluez',"			\
 	"path='%s'"
 
@@ -595,7 +595,7 @@ static gboolean list_printers(void)
 
 	doing_disco = TRUE;
 	message = dbus_message_new_method_call("org.bluez", adapter,
-					"org.bluez.Adapter",
+					"org.bluez.Adapter1",
 					"StartDiscovery");
 
 	if (!dbus_connection_send_with_reply(conn, message, NULL, -1)) {
@@ -649,7 +649,7 @@ static gboolean print_ieee1284(const char *bdaddr)
 	}
 
 	message = dbus_message_new_method_call("org.bluez", adapter,
-			"org.bluez.Adapter",
+			"org.bluez.Adapter1",
 			"FindDevice");
 	dbus_message_iter_init_append(message, &iter);
 	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &bdaddr);
@@ -664,7 +664,7 @@ static gboolean print_ieee1284(const char *bdaddr)
 
 	if (!reply) {
 		message = dbus_message_new_method_call("org.bluez", adapter,
-				"org.bluez.Adapter",
+				"org.bluez.Adapter1",
 				"CreateDevice");
 		dbus_message_iter_init_append(message, &iter);
 		dbus_message_iter_append_basic(&iter,
diff --git a/src/adapter.h b/src/adapter.h
index e131e6d..0ec0b8f 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -30,7 +30,7 @@
 #include <glib.h>
 #include <stdbool.h>
 
-#define ADAPTER_INTERFACE	"org.bluez.Adapter"
+#define ADAPTER_INTERFACE	"org.bluez.Adapter1"
 
 #define MODE_OFF		0x00
 #define MODE_CONNECTABLE	0x01
diff --git a/test/agent.c b/test/agent.c
index 1713ec3..85dfb22 100644
--- a/test/agent.c
+++ b/test/agent.c
@@ -346,7 +346,7 @@ static int register_agent(DBusConnection *conn, const char *adapter_path,
 	DBusError err;
 
 	msg = dbus_message_new_method_call("org.bluez", adapter_path,
-					"org.bluez.Adapter", "RegisterAgent");
+					"org.bluez.Adapter1", "RegisterAgent");
 	if (!msg) {
 		fprintf(stderr, "Can't allocate new method call\n");
 		return -1;
@@ -385,7 +385,8 @@ static int unregister_agent(DBusConnection *conn, const char *adapter_path,
 	DBusError err;
 
 	msg = dbus_message_new_method_call("org.bluez", adapter_path,
-					"org.bluez.Adapter", "UnregisterAgent");
+							"org.bluez.Adapter1",
+							"UnregisterAgent");
 	if (!msg) {
 		fprintf(stderr, "Can't allocate new method call\n");
 		return -1;
@@ -435,7 +436,7 @@ static int create_paired_device(DBusConnection *conn, const char *adapter_path,
 	DBusPendingCall *pending;
 
 	msg = dbus_message_new_method_call("org.bluez", adapter_path,
-						"org.bluez.Adapter",
+						"org.bluez.Adapter1",
 						"CreatePairedDevice");
 	if (!msg) {
 		fprintf(stderr, "Can't allocate new method call\n");
diff --git a/test/bluezutils.py b/test/bluezutils.py
index 803805b..d0c4773 100644
--- a/test/bluezutils.py
+++ b/test/bluezutils.py
@@ -1,7 +1,7 @@
 import dbus
 
 SERVICE_NAME = "org.bluez"
-ADAPTER_INTERFACE = SERVICE_NAME + ".Adapter"
+ADAPTER_INTERFACE = SERVICE_NAME + ".Adapter1"
 DEVICE_INTERFACE = SERVICE_NAME + ".Device1"
 
 def get_managed_objects():
diff --git a/test/list-devices b/test/list-devices
index 7e56239..0aac217 100755
--- a/test/list-devices
+++ b/test/list-devices
@@ -35,12 +35,12 @@ all_devices = (str(path) for path, interfaces in objects.iteritems() if
 					"org.bluez.Device1" in interfaces.keys())
 
 for path, interfaces in objects.iteritems():
-	if "org.bluez.Adapter" not in interfaces.keys():
+	if "org.bluez.Adapter1" not in interfaces.keys():
 		continue
 
 	print("[ " + path + " ]")
 
-	properties = interfaces["org.bluez.Adapter"]
+	properties = interfaces["org.bluez.Adapter1"]
 	for key in properties.keys():
 		value = properties[key]
 		if (key == "UUIDs"):
diff --git a/test/monitor-bluetooth b/test/monitor-bluetooth
index cfda322..bc5ddaf 100755
--- a/test/monitor-bluetooth
+++ b/test/monitor-bluetooth
@@ -7,7 +7,7 @@ import gobject
 import dbus
 import dbus.mainloop.glib
 
-relevant_ifaces = [ "org.bluez.Adapter", "org.bluez.Device1" ]
+relevant_ifaces = [ "org.bluez.Adapter1", "org.bluez.Device1" ]
 
 def property_changed(interface, changed, invalidated, path):
 	iface = interface[interface.rfind(".") + 1:]
diff --git a/test/test-adapter b/test/test-adapter
index dc66aa6..95e6662 100755
--- a/test/test-adapter
+++ b/test/test-adapter
@@ -37,16 +37,16 @@ if (len(args) < 1):
 	sys.exit(1)
 
 if (args[0] == "address"):
-	addr = adapter.Get("org.bluez.Adapter", "Address")
+	addr = adapter.Get("org.bluez.Adapter1", "Address")
 	print(addr)
 	sys.exit(0)
 
 if (args[0] == "name"):
 	if (len(args) < 2):
-		name = adapter.Get("org.bluez.Adapter", "Name")
+		name = adapter.Get("org.bluez.Adapter1", "Name")
 		print(name)
 	else:
-		adapter.Set("org.bluez.Adapter", "Name", args[1])
+		adapter.Set("org.bluez.Adapter1", "Name", args[1])
 	sys.exit(0)
 
 if (args[0] == "list"):
@@ -55,12 +55,12 @@ if (args[0] == "list"):
 					"org.freedesktop.DBus.ObjectManager")
 		objects = om.GetManagedObjects()
 		for path, interfaces in objects.iteritems():
-			if "org.bluez.Adapter" not in interfaces:
+			if "org.bluez.Adapter1" not in interfaces:
 				continue
 
 			print(" [ %s ]" % (path))
 
-			props = interfaces["org.bluez.Adapter"]
+			props = interfaces["org.bluez.Adapter1"]
 
 			for (key, value) in props.items():
 				if (key == "Class"):
@@ -72,7 +72,7 @@ if (args[0] == "list"):
 
 if (args[0] == "powered"):
 	if (len(args) < 2):
-		powered = adapter.Get("org.bluez.Adapter", "Powered")
+		powered = adapter.Get("org.bluez.Adapter1", "Powered")
 		print(powered)
 	else:
 		if (args[1] == "on"):
@@ -81,12 +81,12 @@ if (args[0] == "powered"):
 			value = dbus.Boolean(0)
 		else:
 			value = dbus.Boolean(args[1])
-		adapter.Set("org.bluez.Adapter", "Powered", value)
+		adapter.Set("org.bluez.Adapter1", "Powered", value)
 	sys.exit(0)
 
 if (args[0] == "pairable"):
 	if (len(args) < 2):
-		pairable = adapter.Get("org.bluez.Adapter", "Pairable")
+		pairable = adapter.Get("org.bluez.Adapter1", "Pairable")
 		print(pairable)
 	else:
 		if (args[1] == "on"):
@@ -95,21 +95,21 @@ if (args[0] == "pairable"):
 			value = dbus.Boolean(0)
 		else:
 			value = dbus.Boolean(args[1])
-		adapter.Set("org.bluez.Adapter", "Pairable", value)
+		adapter.Set("org.bluez.Adapter1", "Pairable", value)
 	sys.exit(0)
 
 if (args[0] == "pairabletimeout"):
 	if (len(args) < 2):
-		pt = adapter.Get("org.bluez.Adapter", "PairableTimeout")
+		pt = adapter.Get("org.bluez.Adapter1", "PairableTimeout")
 		print(pt)
 	else:
 		timeout = dbus.UInt32(args[1])
-		adapter.Set("org.bluez.Adapter", "PairableTimeout", timeout)
+		adapter.Set("org.bluez.Adapter1", "PairableTimeout", timeout)
 	sys.exit(0)
 
 if (args[0] == "discoverable"):
 	if (len(args) < 2):
-		discoverable = adapter.Get("org.bluez.Adapter", "Discoverable")
+		discoverable = adapter.Get("org.bluez.Adapter1", "Discoverable")
 		print(discoverable)
 	else:
 		if (args[1] == "on"):
@@ -118,20 +118,20 @@ if (args[0] == "discoverable"):
 			value = dbus.Boolean(0)
 		else:
 			value = dbus.Boolean(args[1])
-		adapter.Set("org.bluez.Adapter", "Discoverable", value)
+		adapter.Set("org.bluez.Adapter1", "Discoverable", value)
 	sys.exit(0)
 
 if (args[0] == "discoverabletimeout"):
 	if (len(args) < 2):
-		dt = adapter.Get("org.bluez.Adapter", "DiscoverableTimeout")
+		dt = adapter.Get("org.bluez.Adapter1", "DiscoverableTimeout")
 		print(dt)
 	else:
 		to = dbus.UInt32(args[1])
-		adapter.Set("org.bluez.Adapter", "DiscoverableTimeout", to)
+		adapter.Set("org.bluez.Adapter1", "DiscoverableTimeout", to)
 	sys.exit(0)
 
 if (args[0] == "discovering"):
-	discovering = adapter.Get("org.bluez.Adapter", "Discovering")
+	discovering = adapter.Get("org.bluez.Adapter1", "Discovering")
 	print(discovering)
 	sys.exit(0)
 
diff --git a/test/test-discovery b/test/test-discovery
index 0f73fe4..0004f52 100755
--- a/test/test-discovery
+++ b/test/test-discovery
@@ -106,11 +106,11 @@ if __name__ == '__main__':
 		compact = True;
 
 	bus.add_signal_receiver(devices_found,
-					dbus_interface = "org.bluez.Adapter",
+					dbus_interface = "org.bluez.Adapter1",
 					signal_name = "DevicesFound")
 
 	bus.add_signal_receiver(property_changed,
-					dbus_interface = "org.bluez.Adapter",
+					dbus_interface = "org.bluez.Adapter1",
 					signal_name = "PropertyChanged")
 
 	adapter.StartDiscovery()
diff --git a/test/test-health b/test/test-health
index 9d2f62f..e0f95a6 100755
--- a/test/test-health
+++ b/test/test-health
@@ -138,7 +138,7 @@ objects = manager.GetManagedObjects()
 adapters = []
 
 for path, ifaces in objects.iteritems():
-	if ifaces.has_key("org.bluez.Adapter"):
+	if ifaces.has_key("org.bluez.Adapter1"):
 		adapters.append(path)
 
 i = 1
@@ -160,7 +160,7 @@ while select == None:
 		sys.exit()
 
 adapter =  dbus.Interface(bus.get_object("org.bluez", select),
-						"org.bluez.Adapter")
+						"org.bluez.Adapter1")
 
 devices = adapter.GetProperties()["Devices"]
 
diff --git a/test/test-health-sink b/test/test-health-sink
index a886d85..a14f16b 100755
--- a/test/test-health-sink
+++ b/test/test-health-sink
@@ -28,7 +28,7 @@ objects = manager.GetManagedObjects()
 adapters = []
 
 for path, ifaces in objects.iteritems():
-	if ifaces.has_key("org.bluez.Adapter"):
+	if ifaces.has_key("org.bluez.Adapter1"):
 		adapters.append(path)
 
 i = 1
@@ -50,7 +50,7 @@ while select == None:
 		sys.exit()
 
 adapter =  dbus.Interface(bus.get_object("org.bluez", select),
-						"org.bluez.Adapter")
+						"org.bluez.Adapter1")
 
 devices = adapter.GetProperties()["Devices"]
 
diff --git a/test/test-manager b/test/test-manager
index c5e8007..1e3882f 100755
--- a/test/test-manager
+++ b/test/test-manager
@@ -9,11 +9,11 @@ import dbus.mainloop.glib
 import bluezutils
 
 def interfaces_added(path, interfaces):
-	if interfaces.get("org.bluez.Adapter") != None:
+	if interfaces.get("org.bluez.Adapter1") != None:
 		print("Adapter with path %s added" % (path))
 
 def interfaces_removed(path, interfaces):
-	if "org.bluez.Adapter" in interfaces:
+	if "org.bluez.Adapter1" in interfaces:
 		print("Adapter with path %s removed" % (path))
 
 if __name__ == "__main__":
-- 
1.7.11.7


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

* Re: [PATCH v3 00/15] Manager/Adapter transition to ObjectManager
  2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
                   ` (14 preceding siblings ...)
  2012-12-05 12:51 ` [PATCH v3 15/15] dbus: Rename to org.bluez.Adapter1 Mikel Astiz
@ 2012-12-05 14:44 ` Johan Hedberg
  15 siblings, 0 replies; 17+ messages in thread
From: Johan Hedberg @ 2012-12-05 14:44 UTC (permalink / raw)
  To: Mikel Astiz; +Cc: linux-bluetooth, Mikel Astiz

Hi Mikel,

On Wed, Dec 05, 2012, Mikel Astiz wrote:
> Main changes from v2 include the suggestions from Lizardo:
> - Python style improved.
> - Utility library renamed to bluezutils.py to avoid collisions in distros.
> - Recently added test-cyclingspeed also considered in the patchset.
> 
> From previous cover-letter:
> 
> This proposal completely removes org.bluez.Manager, with two main consequences:
> 1. Clients have a harder time to find adapters. Therefore, some helper
> function have been added to be used by test scripts.
> 2. The concept of "default adapter" disappears.
> 
> All test scripts have been updated here but not all of them were
> tested, so apoligies if this breaks your script (some of them are
> already broken, by the way).
> 
> Regarding the testing code written in C, they haven't been updated.
> The idea is to address these once the python part has been agreed.
> 
> Mikel Astiz (15):
>   cups: Remove unnecessary code
>   test: Add utility library for python scripts
>   test: Avoid using DefaultAdapter()
>   test: Update monitor script to ObjectManager
>   test: Update test-manager script to ObjectManager
>   test: Use ObjectManager instead of Adapters property
>   dbus: Remove org.bluez.Manager
>   test: Use ObjectManager instead of Devices property
>   test: Add helper function to find devices
>   adapter: Remove DeviceCreated/DeviceRemoved signals
>   adapter: Remove redundant Devices property
>   test: Avoid using Adapter.FindDevice()
>   adapter: Remove FindDevice method from D-Bus API
>   dbus: Rename to org.bluez.Device1
>   dbus: Rename to org.bluez.Adapter1

All patches in this set have been applied. Thanks.

Johan

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

end of thread, other threads:[~2012-12-05 14:44 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-05 12:51 [PATCH v3 00/15] Manager/Adapter transition to ObjectManager Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 01/15] cups: Remove unnecessary code Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 02/15] test: Add utility library for python scripts Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 03/15] test: Avoid using DefaultAdapter() Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 04/15] test: Update monitor script to ObjectManager Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 05/15] test: Update test-manager " Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 06/15] test: Use ObjectManager instead of Adapters property Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 07/15] dbus: Remove org.bluez.Manager Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 08/15] test: Use ObjectManager instead of Devices property Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 09/15] test: Add helper function to find devices Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 10/15] adapter: Remove DeviceCreated/DeviceRemoved signals Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 11/15] adapter: Remove redundant Devices property Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 12/15] test: Avoid using Adapter.FindDevice() Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 13/15] adapter: Remove FindDevice method from D-Bus API Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 14/15] dbus: Rename to org.bluez.Device1 Mikel Astiz
2012-12-05 12:51 ` [PATCH v3 15/15] dbus: Rename to org.bluez.Adapter1 Mikel Astiz
2012-12-05 14:44 ` [PATCH v3 00/15] Manager/Adapter transition to ObjectManager 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).