All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] bluetooth: Move functions from hfp.c to bluetooth.c
@ 2010-06-20  8:51 Gustavo F. Padovan
  2010-06-20  8:51 ` [PATCH 2/6] bluetooth: add device_properties_cb() and has_uuid() Gustavo F. Padovan
  2010-06-22  3:56 ` [PATCH 1/6] bluetooth: Move functions from hfp.c to bluetooth.c Denis Kenzior
  0 siblings, 2 replies; 8+ messages in thread
From: Gustavo F. Padovan @ 2010-06-20  8:51 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 3961 bytes --]

The part that call device_properties_cb is commented to permit this patch
compile.
device_properties_cb() will be changed, so it will have separated patch.
---
 plugins/bluetooth.c |  122 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 122 insertions(+), 0 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 0b1b560..e27982b 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -199,6 +199,124 @@ done:
 	g_slist_free(prop_handlers);
 }
 
+static void parse_string(DBusMessageIter *iter, gpointer user_data)
+{
+	char **str = user_data;
+	int arg_type = dbus_message_iter_get_arg_type(iter);
+
+	if (arg_type != DBUS_TYPE_OBJECT_PATH && arg_type != DBUS_TYPE_STRING)
+		return;
+
+	dbus_message_iter_get_basic(iter, str);
+}
+
+static void parse_devices(DBusMessageIter *array, gpointer user_data)
+{
+	DBusMessageIter value;
+	GSList **device_list = user_data;
+
+	DBG("");
+
+	if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
+		return;
+
+	dbus_message_iter_recurse(array, &value);
+
+	while (dbus_message_iter_get_arg_type(&value)
+			== DBUS_TYPE_OBJECT_PATH) {
+		const char *path;
+
+		dbus_message_iter_get_basic(&value, &path);
+
+		*device_list = g_slist_prepend(*device_list, (gpointer) path);
+
+		dbus_message_iter_next(&value);
+	}
+}
+
+static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
+{
+	const char *path = user_data;
+	DBusMessage *reply;
+	GSList *device_list = NULL;
+	GSList *l;
+	const char *addr;
+
+	reply = dbus_pending_call_steal_reply(call);
+
+	if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
+		DBG("Bluetooth daemon is apparently not available.");
+		goto done;
+	}
+
+	bluetooth_parse_properties(reply, "Devices", parse_devices, &device_list,
+				"Address", parse_string, &addr, NULL);
+
+	DBG("Adapter Address: %s, Path: %s", addr, path);
+	g_hash_table_insert(adapter_address_hash,
+				g_strdup(path), g_strdup(addr));
+
+	for (l = device_list; l; l = l->next) {
+		/*
+		const char *device = l->data;
+
+		bluetooth_send_with_reply(device, BLUEZ_DEVICE_INTERFACE,
+				"GetProperties", device_properties_cb,
+				g_strdup(device), g_free, -1, DBUS_TYPE_INVALID);
+		*/
+	}
+
+done:
+	g_slist_free(device_list);
+	dbus_message_unref(reply);
+}
+
+static void parse_adapters(DBusMessageIter *array, gpointer user_data)
+{
+	DBusMessageIter value;
+
+	DBG("");
+
+	if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
+		return;
+
+	dbus_message_iter_recurse(array, &value);
+
+	while (dbus_message_iter_get_arg_type(&value)
+			== DBUS_TYPE_OBJECT_PATH) {
+		const char *path;
+
+		dbus_message_iter_get_basic(&value, &path);
+
+		DBG("Calling GetProperties on %s", path);
+
+		bluetooth_send_with_reply(path, BLUEZ_ADAPTER_INTERFACE,
+				"GetProperties", adapter_properties_cb,
+				g_strdup(path), g_free, -1, DBUS_TYPE_INVALID);
+
+		dbus_message_iter_next(&value);
+	}
+}
+
+static void manager_properties_cb(DBusPendingCall *call, gpointer user_data)
+{
+	DBusMessage *reply;
+
+	reply = dbus_pending_call_steal_reply(call);
+
+	if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
+		DBG("Bluetooth daemon is apparently not available.");
+		goto done;
+	}
+
+	DBG("");
+
+	bluetooth_parse_properties(reply, "Adapters", parse_adapters, NULL, NULL);
+
+done:
+	dbus_message_unref(reply);
+}
+
 int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
 {
 	if (uuid_hash)
@@ -215,6 +333,10 @@ int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
 done:
 	g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
 
+	bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
+				manager_properties_cb, NULL, NULL, -1,
+				DBUS_TYPE_INVALID);
+
 	return 0;
 }
 
-- 
1.7.1


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

end of thread, other threads:[~2010-06-22  3:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-20  8:51 [PATCH 1/6] bluetooth: Move functions from hfp.c to bluetooth.c Gustavo F. Padovan
2010-06-20  8:51 ` [PATCH 2/6] bluetooth: add device_properties_cb() and has_uuid() Gustavo F. Padovan
2010-06-20  8:51   ` [PATCH 3/6] bluetooth: add watches for the bluetoothd service and adapters Gustavo F. Padovan
2010-06-20  8:51     ` [PATCH 4/6] bluetooth: add PropertyChanged watch Gustavo F. Padovan
2010-06-20  8:51       ` [PATCH 5/6] hfp: use bluetooth helpers and remove similar code Gustavo F. Padovan
2010-06-20  8:51         ` [PATCH 6/6] bluetooth: make bluetooth.c not a plugin Gustavo F. Padovan
2010-06-22  3:59           ` Denis Kenzior
2010-06-22  3:56 ` [PATCH 1/6] bluetooth: Move functions from hfp.c to bluetooth.c Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.