* [RFC v0 00/11] External HFP Profile
@ 2012-11-22 17:53 Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 01/11] hfp_hf: Add HFP external Profile registration Claudio Takahasi
` (13 more replies)
0 siblings, 14 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]
BlueZ supports now external profile registration, see:
bluez/doc/profile-api.txt
This patch series has the initial implementation of the HFP external
profile in oFono. HandsfreeAgent and HandsfreeGateway interfaces were
removed from BlueZ.
The next step: implement SCO connection handling in oFono.
Claudio Takahasi (11):
hfp_hf: Add HFP external Profile registration
hfp_hf: Add BlueZ Profile handler
hfp_hf: Add parsing of Profile NewConnection call
hfp_hf: Add SLC setup
hfp_hf: Add Profile1 Release
hfp_hf: Remove HandsfreeAgent and HandsfreeGateway
hfp_hf: Register HFP modem dynamically
hfp_hf: Fix updating alias
bluetooth: Reuse D-Bus dictionary parser function
hfp_hf: Add Version and Features parsing
bluetooth: Use generic function to parse dict
plugins/bluetooth.c | 245 ++++++++++++++++++++++---------
plugins/bluetooth.h | 10 +-
plugins/hfp_hf.c | 404 +++++++++++++++++++++++++---------------------------
3 files changed, 379 insertions(+), 280 deletions(-)
--
1.7.11.7
^ permalink raw reply [flat|nested] 49+ messages in thread
* [RFC v0 01/11] hfp_hf: Add HFP external Profile registration
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
@ 2012-11-22 17:53 ` Claudio Takahasi
2012-11-26 11:08 ` Johan Hedberg
2012-11-22 17:53 ` [RFC v0 02/11] hfp_hf: Add BlueZ Profile handler Claudio Takahasi
` (12 subsequent siblings)
13 siblings, 1 reply; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6579 bytes --]
This patch adds the functions to allow registering and unregistering HFP
external profile using BlueZ ProfileManager1 interface.
---
plugins/bluetooth.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++
plugins/bluetooth.h | 5 +-
plugins/hfp_hf.c | 12 +++++
3 files changed, 153 insertions(+), 1 deletion(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 09c9870..201c851 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -65,6 +65,39 @@ struct cb_data {
GIOChannel *io;
};
+static void append_variant(DBusMessageIter *iter, int type, void *val)
+{
+ DBusMessageIter value;
+ char sig[2] = { type, '\0' };
+
+ dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value);
+
+ dbus_message_iter_append_basic(&value, type, val);
+
+ dbus_message_iter_close_container(iter, &value);
+}
+
+static void dict_append_entry(DBusMessageIter *dict, const char *key, int type,
+ void *val)
+{
+ DBusMessageIter entry;
+
+ if (type == DBUS_TYPE_STRING) {
+ const char *str = *((const char **) val);
+ if (str == NULL)
+ return;
+ }
+
+ dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL,
+ &entry);
+
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+
+ append_variant(&entry, type, val);
+
+ dbus_message_iter_close_container(dict, &entry);
+}
+
void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
char *buf, int size)
{
@@ -968,6 +1001,110 @@ void bluetooth_unregister_uuid(const char *uuid)
bluetooth_unref();
}
+static void register_profile_cb(DBusPendingCall *call, gpointer user_data)
+{
+ DBusMessage *reply;
+ DBusError derr;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&derr);
+
+ if (dbus_set_error_from_message(&derr, reply)) {
+ ofono_error("RegisterProfile() replied an error: %s, %s",
+ derr.name, derr.message);
+ dbus_error_free(&derr);
+ goto done;
+ }
+
+ DBG("");
+
+done:
+ dbus_message_unref(reply);
+}
+
+int bluetooth_register_profile(const char *uuid, const char *name,
+ const char *object)
+{
+ DBusMessageIter iter, dict;
+ DBusPendingCall *c;
+ DBusMessage *msg;
+
+ DBG("Bluetooth: Registering %s (%s) profile", uuid, name);
+
+ msg = dbus_message_new_method_call(BLUEZ_SERVICE, "/org/bluez",
+ BLUEZ_PROFILE_MGMT_INTERFACE, "RegisterProfile");
+
+ dbus_message_iter_init_append(msg, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &object);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &uuid);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict);
+ dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ if (!dbus_connection_send_with_reply(connection, msg, &c, -1)) {
+ ofono_error("Sending RegisterProfile failed");
+ dbus_message_unref(msg);
+ return -EIO;
+ }
+
+ dbus_pending_call_set_notify(c, register_profile_cb, NULL, NULL);
+ dbus_pending_call_unref(c);
+
+ dbus_message_unref(msg);
+
+ return 0;
+}
+
+static void unregister_profile_cb(DBusPendingCall *call, gpointer user_data)
+{
+ DBusMessage *reply;
+ DBusError derr;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&derr);
+
+ if (dbus_set_error_from_message(&derr, reply)) {
+ ofono_error("UnregisterProfile() replied an error: %s, %s",
+ derr.name, derr.message);
+ dbus_error_free(&derr);
+ goto done;
+ }
+
+ DBG("");
+
+done:
+ dbus_message_unref(reply);
+}
+
+void bluetooth_unregister_profile(const char *object)
+{
+ DBusMessageIter iter;
+ DBusPendingCall *c;
+ DBusMessage *msg;
+
+ DBG("Bluetooth: Unregistering profile %s", object);
+
+ msg = dbus_message_new_method_call(BLUEZ_SERVICE, "/org/bluez",
+ BLUEZ_PROFILE_MGMT_INTERFACE, "UnregisterProfile");
+
+ dbus_message_iter_init_append(msg, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &object);
+
+ if (!dbus_connection_send_with_reply(connection, msg, &c, -1)) {
+ ofono_error("Sending RegisterProfile failed");
+ dbus_message_unref(msg);
+ return;
+ }
+
+ dbus_pending_call_set_notify(c, unregister_profile_cb, NULL, NULL);
+ dbus_pending_call_unref(c);
+
+ dbus_message_unref(msg);
+}
+
struct server *bluetooth_register_server(guint8 channel, const char *sdp_record,
ConnectFunc cb, gpointer user_data)
{
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index af59d3d..ffaf9e3 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -24,6 +24,7 @@
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
+#define BLUEZ_PROFILE_MGMT_INTERFACE BLUEZ_SERVICE ".ProfileManager1"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
#define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device"
#define BLUEZ_SERVICE_INTERFACE BLUEZ_SERVICE ".Service"
@@ -66,7 +67,9 @@ void bluetooth_get_properties();
int bluetooth_register_uuid(const char *uuid,
struct bluetooth_profile *profile);
void bluetooth_unregister_uuid(const char *uuid);
-
+int bluetooth_register_profile(const char *uuid, const char *name,
+ const char *object);
+void bluetooth_unregister_profile(const char *object);
struct server *bluetooth_register_server(guint8 channel, const char *sdp_record,
ConnectFunc cb, gpointer user_data);
void bluetooth_unregister_server(struct server *server);
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 7c500e3..1e0064c 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -54,6 +54,8 @@
#define HFP_AGENT_INTERFACE "org.bluez.HandsfreeAgent"
#define HFP_AGENT_ERROR_INTERFACE "org.bluez.Error"
+#define HFP_EXT_PROFILE_PATH "/bluetooth/profile/hfp_hf"
+
#ifndef DBUS_TYPE_UNIX_FD
#define DBUS_TYPE_UNIX_FD -1
#endif
@@ -534,6 +536,14 @@ static int hfp_init(void)
return err;
}
+ err = bluetooth_register_profile(HFP_HS_UUID, "hfp_hf",
+ HFP_EXT_PROFILE_PATH);
+ if (err < 0) {
+ bluetooth_unregister_uuid(HFP_AG_UUID);
+ ofono_modem_driver_unregister(&hfp_driver);
+ return err;
+ }
+
modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, NULL);
@@ -542,6 +552,8 @@ static int hfp_init(void)
static void hfp_exit(void)
{
+
+ bluetooth_unregister_profile(HFP_EXT_PROFILE_PATH);
bluetooth_unregister_uuid(HFP_AG_UUID);
ofono_modem_driver_unregister(&hfp_driver);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v0 02/11] hfp_hf: Add BlueZ Profile handler
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 01/11] hfp_hf: Add HFP external Profile registration Claudio Takahasi
@ 2012-11-22 17:53 ` Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 03/11] hfp_hf: Add parsing of Profile NewConnection call Claudio Takahasi
` (11 subsequent siblings)
13 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3981 bytes --]
This patch declares the external HFP Profile handler. It contains the
initial implementation of the D-Bus Profile1 interface and methods
responsible for handling Bluetooth connections.
---
plugins/bluetooth.h | 1 +
plugins/hfp_hf.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index ffaf9e3..96f3a53 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -25,6 +25,7 @@
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
#define BLUEZ_PROFILE_MGMT_INTERFACE BLUEZ_SERVICE ".ProfileManager1"
+#define BLUEZ_PROFILE_INTERFACE BLUEZ_SERVICE ".Profile1"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
#define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device"
#define BLUEZ_SERVICE_INTERFACE BLUEZ_SERVICE ".Service"
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 1e0064c..405ada2 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -339,6 +339,47 @@ static int hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
return 0;
}
+static DBusMessage *profile_new_connection(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler NewConnection");
+ return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *profile_release(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler Release");
+ return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *profile_cancel(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler Cancel");
+ return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *profile_disconnection(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler RequestDisconnection");
+ return dbus_message_new_method_return(msg);
+}
+
+static const GDBusMethodTable profile_methods[] = {
+ { GDBUS_ASYNC_METHOD("NewConnection",
+ GDBUS_ARGS({ "device", "o"}, { "fd", "h"},
+ { "fd_properties", "a{sv}" }),
+ NULL, profile_new_connection) },
+ { GDBUS_METHOD("Release", NULL, NULL, profile_release) },
+ { GDBUS_METHOD("Cancel", NULL, NULL, profile_cancel) },
+ { GDBUS_METHOD("RequestDisconnection",
+ GDBUS_ARGS({"o"}), NULL,
+ profile_disconnection) },
+ { }
+};
+
static int hfp_probe(struct ofono_modem *modem)
{
const char *obj_path = ofono_modem_get_path(modem);
@@ -526,12 +567,24 @@ static int hfp_init(void)
connection = ofono_dbus_get_connection();
+ /* Registers External Profile handler */
+ if (!g_dbus_register_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE,
+ profile_methods, NULL,
+ NULL, NULL, NULL)) {
+ ofono_error("Register Profile interface failed: %s",
+ HFP_EXT_PROFILE_PATH);
+ return -EIO;
+ }
+
err = ofono_modem_driver_register(&hfp_driver);
if (err < 0)
return err;
err = bluetooth_register_uuid(HFP_AG_UUID, &hfp_hf);
if (err < 0) {
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
ofono_modem_driver_unregister(&hfp_driver);
return err;
}
@@ -539,6 +592,8 @@ static int hfp_init(void)
err = bluetooth_register_profile(HFP_HS_UUID, "hfp_hf",
HFP_EXT_PROFILE_PATH);
if (err < 0) {
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
bluetooth_unregister_uuid(HFP_AG_UUID);
ofono_modem_driver_unregister(&hfp_driver);
return err;
@@ -552,7 +607,8 @@ static int hfp_init(void)
static void hfp_exit(void)
{
-
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
bluetooth_unregister_profile(HFP_EXT_PROFILE_PATH);
bluetooth_unregister_uuid(HFP_AG_UUID);
ofono_modem_driver_unregister(&hfp_driver);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v0 03/11] hfp_hf: Add parsing of Profile NewConnection call
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 01/11] hfp_hf: Add HFP external Profile registration Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 02/11] hfp_hf: Add BlueZ Profile handler Claudio Takahasi
@ 2012-11-22 17:53 ` Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 04/11] hfp_hf: Add SLC setup Claudio Takahasi
` (10 subsequent siblings)
13 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2085 bytes --]
This patch adds the parsing of the mandatory arguments in NewConnection
method call implemented in Profile1 interface.
---
plugins/bluetooth.h | 1 +
plugins/hfp_hf.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 96f3a53..a9355f6 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -24,6 +24,7 @@
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
+#define BLUEZ_ERROR_INTERFACE BLUEZ_SERVICE ".Error"
#define BLUEZ_PROFILE_MGMT_INTERFACE BLUEZ_SERVICE ".ProfileManager1"
#define BLUEZ_PROFILE_INTERFACE BLUEZ_SERVICE ".Profile1"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 405ada2..edb7671 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -342,8 +342,41 @@ static int hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct ofono_modem *modem;
+ const char *device;
+ DBusMessageIter entry;
+ int fd;
+
DBG("Profile handler NewConnection");
+
+ if (dbus_message_iter_init(msg, &entry) == FALSE)
+ goto error;
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_OBJECT_PATH)
+ goto error;
+
+ dbus_message_iter_get_basic(&entry, &device);
+ modem = g_hash_table_lookup(modem_hash, device);
+ if (modem == NULL) {
+ DBG("%s: modem not found", device);
+ goto error;
+ }
+
+ dbus_message_iter_next(&entry);
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_UNIX_FD)
+ goto error;
+
+ dbus_message_iter_get_basic(&entry, &fd);
+ if (fd < 0)
+ goto error;
+
+ DBG("modem %p, SLC FD: %d", modem, fd);
+
return dbus_message_new_method_return(msg);
+
+error:
+ return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
+ "Invalid arguments in method call");
}
static DBusMessage *profile_release(DBusConnection *conn,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v0 04/11] hfp_hf: Add SLC setup
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
` (2 preceding siblings ...)
2012-11-22 17:53 ` [RFC v0 03/11] hfp_hf: Add parsing of Profile NewConnection call Claudio Takahasi
@ 2012-11-22 17:53 ` Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 05/11] hfp_hf: Add Profile1 Release Claudio Takahasi
` (9 subsequent siblings)
13 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1796 bytes --]
This patch adds the SLC setup when the NewConnection is notified.
---
plugins/hfp_hf.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index edb7671..819c8cd 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -101,9 +101,10 @@ static void slc_failed(gpointer userdata)
struct hfp_data *data = ofono_modem_get_data(modem);
DBusMessage *msg;
- msg = g_dbus_create_error(data->slc_msg, HFP_AGENT_ERROR_INTERFACE
- ".Failed",
- "HFP Handshake failed");
+ msg = g_dbus_create_error(data->slc_msg, BLUEZ_ERROR_INTERFACE
+ ".Failed",
+ "HFP Handshake failed");
+
g_dbus_send_message(connection, msg);
dbus_message_unref(data->slc_msg);
data->slc_msg = NULL;
@@ -343,9 +344,11 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct ofono_modem *modem;
+ struct hfp_data *hfp_data;
const char *device;
DBusMessageIter entry;
- int fd;
+ int fd, err;
+ guint16 version = 0x0105;
DBG("Profile handler NewConnection");
@@ -370,9 +373,18 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
if (fd < 0)
goto error;
- DBG("modem %p, SLC FD: %d", modem, fd);
+ hfp_data = ofono_modem_get_data(modem);
+ DBG("modem %p, hfp_data: %p SLC FD: %d", modem, hfp_data, fd);
- return dbus_message_new_method_return(msg);
+ hfp_slc_info_init(&hfp_data->info, version);
+
+ err = service_level_connection(modem, fd);
+ if (err < 0 && err != -EINPROGRESS)
+ return __ofono_error_failed(msg);
+
+ hfp_data->slc_msg = dbus_message_ref(msg);
+
+ return NULL;
error:
return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v0 05/11] hfp_hf: Add Profile1 Release
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
` (3 preceding siblings ...)
2012-11-22 17:53 ` [RFC v0 04/11] hfp_hf: Add SLC setup Claudio Takahasi
@ 2012-11-22 17:53 ` Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 06/11] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway Claudio Takahasi
` (8 subsequent siblings)
13 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 740 bytes --]
This patch adds the Release method of the external Profile handler.
Release method gets called when BlueZ unregisters the HFP profile.
---
plugins/hfp_hf.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 819c8cd..c536691 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -395,6 +395,12 @@ static DBusMessage *profile_release(DBusConnection *conn,
DBusMessage *msg, void *data)
{
DBG("Profile handler Release");
+
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
+
+ g_hash_table_foreach_remove(modem_hash, hfp_remove_modem, NULL);
+
return dbus_message_new_method_return(msg);
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v0 06/11] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
` (4 preceding siblings ...)
2012-11-22 17:53 ` [RFC v0 05/11] hfp_hf: Add Profile1 Release Claudio Takahasi
@ 2012-11-22 17:53 ` Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 07/11] hfp_hf: Register HFP modem dynamically Claudio Takahasi
` (7 subsequent siblings)
13 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 8610 bytes --]
This patch removes the deprecated HandsfreeAgent and HandsfreeGateway
interfaces. New connections are now being managed by a BlueZ external
Profile handler.
---
plugins/hfp_hf.c | 215 ++-----------------------------------------------------
1 file changed, 7 insertions(+), 208 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index c536691..dc00227 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -49,11 +49,6 @@
#include "bluetooth.h"
-#define BLUEZ_GATEWAY_INTERFACE BLUEZ_SERVICE ".HandsfreeGateway"
-
-#define HFP_AGENT_INTERFACE "org.bluez.HandsfreeAgent"
-#define HFP_AGENT_ERROR_INTERFACE "org.bluez.Error"
-
#define HFP_EXT_PROFILE_PATH "/bluetooth/profile/hfp_hf"
#ifndef DBUS_TYPE_UNIX_FD
@@ -65,11 +60,8 @@ static GHashTable *modem_hash = NULL;
struct hfp_data {
struct hfp_slc_info info;
- char *handsfree_path;
char *handsfree_address;
DBusMessage *slc_msg;
- gboolean agent_registered;
- DBusPendingCall *call;
};
static void hfp_debug(const char *str, void *user_data)
@@ -161,54 +153,6 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
return -EINPROGRESS;
}
-static DBusMessage *hfp_agent_new_connection(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- int fd, err;
- struct ofono_modem *modem = data;
- struct hfp_data *hfp_data = ofono_modem_get_data(modem);
- guint16 version;
-
- if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UNIX_FD, &fd,
- DBUS_TYPE_UINT16, &version, DBUS_TYPE_INVALID))
- return __ofono_error_invalid_args(msg);
-
- hfp_slc_info_init(&hfp_data->info, version);
-
- err = service_level_connection(modem, fd);
- if (err < 0 && err != -EINPROGRESS)
- return __ofono_error_failed(msg);
-
- hfp_data->slc_msg = msg;
- dbus_message_ref(msg);
-
- return NULL;
-}
-
-static DBusMessage *hfp_agent_release(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct ofono_modem *modem = data;
- struct hfp_data *hfp_data = ofono_modem_get_data(modem);
- const char *obj_path = ofono_modem_get_path(modem);
-
- g_dbus_unregister_interface(connection, obj_path, HFP_AGENT_INTERFACE);
- hfp_data->agent_registered = FALSE;
-
- g_hash_table_remove(modem_hash, hfp_data->handsfree_path);
- ofono_modem_remove(modem);
-
- return dbus_message_new_method_return(msg);
-}
-
-static const GDBusMethodTable agent_methods[] = {
- { GDBUS_ASYNC_METHOD("NewConnection",
- GDBUS_ARGS({ "fd", "h" }, { "version", "q" }),
- NULL, hfp_agent_new_connection) },
- { GDBUS_METHOD("Release", NULL, NULL, hfp_agent_release) },
- { }
-};
-
static int hfp_hf_probe(const char *device, const char *dev_addr,
const char *adapter_addr, const char *alias)
{
@@ -234,10 +178,6 @@ static int hfp_hf_probe(const char *device, const char *dev_addr,
if (data == NULL)
goto free;
- data->handsfree_path = g_strdup(device);
- if (data->handsfree_path == NULL)
- goto free;
-
data->handsfree_address = g_strdup(dev_addr);
if (data->handsfree_address == NULL)
goto free;
@@ -251,9 +191,6 @@ static int hfp_hf_probe(const char *device, const char *dev_addr,
return 0;
free:
- if (data != NULL)
- g_free(data->handsfree_path);
-
g_free(data);
ofono_modem_remove(modem);
@@ -300,46 +237,6 @@ static void hfp_hf_set_alias(const char *device, const char *alias)
ofono_modem_set_name(modem, alias);
}
-static int hfp_register_ofono_handsfree(struct ofono_modem *modem)
-{
- const char *obj_path = ofono_modem_get_path(modem);
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusMessage *msg;
-
- DBG("Registering oFono Agent to bluetooth daemon");
-
- msg = dbus_message_new_method_call(BLUEZ_SERVICE, data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "RegisterAgent");
- if (msg == NULL)
- return -ENOMEM;
-
- dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &obj_path,
- DBUS_TYPE_INVALID);
-
- g_dbus_send_message(connection, msg);
- return 0;
-}
-
-static int hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
-{
- const char *obj_path = ofono_modem_get_path(modem);
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusMessage *msg;
-
- DBG("Unregistering oFono Agent from bluetooth daemon");
-
- msg = dbus_message_new_method_call(BLUEZ_SERVICE, data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "UnregisterAgent");
- if (msg == NULL)
- return -ENOMEM;
-
- dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &obj_path,
- DBUS_TYPE_INVALID);
-
- g_dbus_send_message(connection, msg);
- return 0;
-}
-
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -433,19 +330,7 @@ static const GDBusMethodTable profile_methods[] = {
static int hfp_probe(struct ofono_modem *modem)
{
- const char *obj_path = ofono_modem_get_path(modem);
- struct hfp_data *data = ofono_modem_get_data(modem);
-
- if (data == NULL)
- return -EINVAL;
-
- g_dbus_register_interface(connection, obj_path, HFP_AGENT_INTERFACE,
- agent_methods, NULL, NULL, modem, NULL);
-
- data->agent_registered = TRUE;
-
- if (hfp_register_ofono_handsfree(modem) != 0)
- return -EINVAL;
+ DBG("modem: %p", modem);
return 0;
}
@@ -453,124 +338,38 @@ static int hfp_probe(struct ofono_modem *modem)
static void hfp_remove(struct ofono_modem *modem)
{
struct hfp_data *data = ofono_modem_get_data(modem);
- const char *obj_path = ofono_modem_get_path(modem);
-
- if (data->call != NULL)
- dbus_pending_call_cancel(data->call);
- if (g_dbus_unregister_interface(connection, obj_path,
- HFP_AGENT_INTERFACE))
- hfp_unregister_ofono_handsfree(modem);
+ DBG("modem: %p", modem);
g_free(data->handsfree_address);
- g_free(data->handsfree_path);
g_free(data);
ofono_modem_set_data(modem, NULL);
}
-static void hfp_connect_reply(DBusPendingCall *call, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusError derr;
- DBusMessage *reply, *msg;
-
- reply = dbus_pending_call_steal_reply(call);
-
- if (ofono_modem_get_powered(modem))
- goto done;
-
- dbus_error_init(&derr);
- if (!dbus_set_error_from_message(&derr, reply))
- goto done;
-
- DBG("Connect reply: %s", derr.message);
-
- if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) {
- msg = dbus_message_new_method_call(BLUEZ_SERVICE,
- data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "Disconnect");
- if (msg == NULL)
- ofono_error("Disconnect failed");
- else
- g_dbus_send_message(connection, msg);
- }
-
- ofono_modem_set_powered(modem, FALSE);
-
- dbus_error_free(&derr);
-
-done:
- dbus_message_unref(reply);
- data->call = NULL;
-}
-
/* power up hardware */
static int hfp_enable(struct ofono_modem *modem)
{
- struct hfp_data *data = ofono_modem_get_data(modem);
- int status;
-
DBG("%p", modem);
- status = bluetooth_send_with_reply(data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "Connect",
- &data->call, hfp_connect_reply,
- modem, NULL,
- DBUS_TIMEOUT, DBUS_TYPE_INVALID);
-
- if (status < 0)
- return -EINVAL;
-
- return -EINPROGRESS;
-}
-
-static void hfp_power_down(DBusPendingCall *call, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusMessage *reply;
- DBusError derr;
-
- reply = dbus_pending_call_steal_reply(call);
-
- dbus_error_init(&derr);
- if (dbus_set_error_from_message(&derr, reply)) {
- DBG("Disconnect reply: %s", derr.message);
- dbus_error_free(&derr);
- goto done;
- }
-
- ofono_modem_set_powered(modem, FALSE);
+ if (ofono_modem_get_powered(modem))
+ return 0;
-done:
- dbus_message_unref(reply);
- data->call = NULL;
+ return -ENOTCONN;
}
static int hfp_disable(struct ofono_modem *modem)
{
struct hfp_data *data = ofono_modem_get_data(modem);
- int status;
DBG("%p", modem);
g_at_chat_unref(data->info.chat);
data->info.chat = NULL;
- if (data->agent_registered) {
- status = bluetooth_send_with_reply(data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "Disconnect",
- &data->call, hfp_power_down,
- modem, NULL,
- DBUS_TIMEOUT, DBUS_TYPE_INVALID);
-
- if (status < 0)
- return -EINVAL;
- }
+ ofono_modem_set_powered(modem, FALSE);
- return -EINPROGRESS;
+ return 0;
}
static void hfp_pre_sim(struct ofono_modem *modem)
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v0 07/11] hfp_hf: Register HFP modem dynamically
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
` (5 preceding siblings ...)
2012-11-22 17:53 ` [RFC v0 06/11] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway Claudio Takahasi
@ 2012-11-22 17:53 ` Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 08/11] hfp_hf: Fix updating alias Claudio Takahasi
` (6 subsequent siblings)
13 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6684 bytes --]
This patch moves the modem creation from the Bluetooth profile probe
to the NewConnection method call. HFP modem are now registered when
the Bluetooth link is established.
---
plugins/hfp_hf.c | 108 ++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 72 insertions(+), 36 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index dc00227..ed81c49 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -57,13 +57,26 @@
static DBusConnection *connection;
static GHashTable *modem_hash = NULL;
+static GHashTable *hfp_hash = NULL;
struct hfp_data {
struct hfp_slc_info info;
- char *handsfree_address;
+ gchar *device_address;
+ gchar *adapter_address;
+ gchar *device_alias;
+ gchar *device_path;
DBusMessage *slc_msg;
};
+static void hfp_data_free(struct hfp_data *hfp_data)
+{
+ g_free(hfp_data->device_address);
+ g_free(hfp_data->adapter_address);
+ g_free(hfp_data->device_alias);
+ g_free(hfp_data->device_path);
+ g_free(hfp_data);
+}
+
static void hfp_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
@@ -117,6 +130,12 @@ static void hfp_disconnected_cb(gpointer user_data)
g_at_chat_unref(data->info.chat);
data->info.chat = NULL;
+
+ g_hash_table_remove(modem_hash, data->device_path);
+
+ ofono_modem_remove(modem);
+
+ hfp_data_free(data);
}
/* either oFono or Phone could request SLC connection */
@@ -153,46 +172,72 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
return -EINPROGRESS;
}
-static int hfp_hf_probe(const char *device, const char *dev_addr,
- const char *adapter_addr, const char *alias)
+static int modem_register(const char *device, struct hfp_data *hfp_data, int fd)
{
struct ofono_modem *modem;
- struct hfp_data *data;
char buf[256];
+ guint16 version = 0x0105;
/* We already have this device in our hash, ignore */
if (g_hash_table_lookup(modem_hash, device) != NULL)
return -EALREADY;
- ofono_info("Using device: %s, devaddr: %s, adapter: %s",
- device, dev_addr, adapter_addr);
-
strcpy(buf, "hfp/");
- bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
+ bluetooth_create_path(hfp_data->device_address,
+ hfp_data->adapter_address, buf + 4, sizeof(buf) - 4);
modem = ofono_modem_create(buf, "hfp");
if (modem == NULL)
return -ENOMEM;
- data = g_try_new0(struct hfp_data, 1);
- if (data == NULL)
+ ofono_modem_set_data(modem, hfp_data);
+ ofono_modem_set_name(modem, hfp_data->device_alias);
+ ofono_modem_register(modem);
+
+ g_hash_table_insert(modem_hash, g_strdup(device), modem);
+
+ hfp_slc_info_init(&hfp_data->info, version);
+
+ return service_level_connection(modem, fd);
+}
+
+static int hfp_hf_probe(const char *device, const char *dev_addr,
+ const char *adapter_addr, const char *alias)
+{
+ struct hfp_data *hfp_data;
+
+ if (g_hash_table_lookup(hfp_hash, device) != NULL)
+ return -EALREADY;
+
+ ofono_info("Using device: %s, devaddr: %s, adapter: %s",
+ device, dev_addr, adapter_addr);
+
+ hfp_data = g_try_new0(struct hfp_data, 1);
+ if (hfp_data == NULL)
goto free;
- data->handsfree_address = g_strdup(dev_addr);
- if (data->handsfree_address == NULL)
+ hfp_data->adapter_address = g_strdup(adapter_addr);
+ if (hfp_data->adapter_address == NULL)
goto free;
- ofono_modem_set_data(modem, data);
- ofono_modem_set_name(modem, alias);
- ofono_modem_register(modem);
+ hfp_data->device_address = g_strdup(dev_addr);
+ if (hfp_data->device_address == NULL)
+ goto free;
- g_hash_table_insert(modem_hash, g_strdup(device), modem);
+ hfp_data->device_path = g_strdup(device);
+ if (hfp_data->device_path == NULL)
+ goto free;
+
+ hfp_data->device_alias = g_strdup(alias);
+ if (hfp_data->device_alias == NULL)
+ goto free;
+
+ g_hash_table_insert(hfp_hash, g_strdup(device), hfp_data);
return 0;
free:
- g_free(data);
- ofono_modem_remove(modem);
+ hfp_data_free(hfp_data);
return -ENOMEM;
}
@@ -240,12 +285,10 @@ static void hfp_hf_set_alias(const char *device, const char *alias)
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- struct ofono_modem *modem;
struct hfp_data *hfp_data;
const char *device;
DBusMessageIter entry;
int fd, err;
- guint16 version = 0x0105;
DBG("Profile handler NewConnection");
@@ -256,9 +299,9 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
goto error;
dbus_message_iter_get_basic(&entry, &device);
- modem = g_hash_table_lookup(modem_hash, device);
- if (modem == NULL) {
- DBG("%s: modem not found", device);
+ hfp_data = g_hash_table_lookup(hfp_hash, device);
+ if (hfp_data == NULL) {
+ DBG("%s: doesn't support HFP", device);
goto error;
}
@@ -270,12 +313,9 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
if (fd < 0)
goto error;
- hfp_data = ofono_modem_get_data(modem);
- DBG("modem %p, hfp_data: %p SLC FD: %d", modem, hfp_data, fd);
-
- hfp_slc_info_init(&hfp_data->info, version);
+ DBG("hfp_data: %p SLC FD: %d", hfp_data, fd);
- err = service_level_connection(modem, fd);
+ err = modem_register(device, hfp_data, fd);
if (err < 0 && err != -EINPROGRESS)
return __ofono_error_failed(msg);
@@ -337,14 +377,7 @@ static int hfp_probe(struct ofono_modem *modem)
static void hfp_remove(struct ofono_modem *modem)
{
- struct hfp_data *data = ofono_modem_get_data(modem);
-
DBG("modem: %p", modem);
-
- g_free(data->handsfree_address);
- g_free(data);
-
- ofono_modem_set_data(modem, NULL);
}
/* power up hardware */
@@ -378,7 +411,7 @@ static void hfp_pre_sim(struct ofono_modem *modem)
DBG("%p", modem);
- ofono_devinfo_create(modem, 0, "hfpmodem", data->handsfree_address);
+ ofono_devinfo_create(modem, 0, "hfpmodem", data->device_address);
ofono_voicecall_create(modem, 0, "hfpmodem", &data->info);
ofono_netreg_create(modem, 0, "hfpmodem", &data->info);
ofono_call_volume_create(modem, 0, "hfpmodem", &data->info);
@@ -452,6 +485,8 @@ static int hfp_init(void)
modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, NULL);
+ hfp_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+
return 0;
}
@@ -464,6 +499,7 @@ static void hfp_exit(void)
ofono_modem_driver_unregister(&hfp_driver);
g_hash_table_destroy(modem_hash);
+ g_hash_table_destroy(hfp_hash);
}
OFONO_PLUGIN_DEFINE(hfp, "Hands-Free Profile Plugins", VERSION,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v0 08/11] hfp_hf: Fix updating alias
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
` (6 preceding siblings ...)
2012-11-22 17:53 ` [RFC v0 07/11] hfp_hf: Register HFP modem dynamically Claudio Takahasi
@ 2012-11-22 17:53 ` Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 09/11] bluetooth: Reuse D-Bus dictionary parser function Claudio Takahasi
` (5 subsequent siblings)
13 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]
This patch fixes the Bluetooth device alias for the HFP when the modem
is not registered yet. Modem is being created with the first alias
informed when in the Bluetooth profile probe callback.
---
plugins/hfp_hf.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index ed81c49..25f3415 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -271,15 +271,20 @@ static void hfp_hf_remove(const char *prefix)
static void hfp_hf_set_alias(const char *device, const char *alias)
{
struct ofono_modem *modem;
+ struct hfp_data *hfp_data;
if (device == NULL || alias == NULL)
return;
- modem = g_hash_table_lookup(modem_hash, device);
- if (modem == NULL)
- return;
+ hfp_data = g_hash_table_lookup(hfp_hash, device);
+ if (hfp_data) {
+ g_free(hfp_data->device_alias);
+ hfp_data->device_alias = g_strdup(alias);
+ }
- ofono_modem_set_name(modem, alias);
+ modem = g_hash_table_lookup(modem_hash, device);
+ if (modem)
+ ofono_modem_set_name(modem, alias);
}
static DBusMessage *profile_new_connection(DBusConnection *conn,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v0 09/11] bluetooth: Reuse D-Bus dictionary parser function
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
` (7 preceding siblings ...)
2012-11-22 17:53 ` [RFC v0 08/11] hfp_hf: Fix updating alias Claudio Takahasi
@ 2012-11-22 17:53 ` Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 10/11] hfp_hf: Add Version and Features parsing Claudio Takahasi
` (4 subsequent siblings)
13 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3565 bytes --]
This patch changes the Bluetooth D-Bus property parser function to allow
reusing on other messages. The dictionary can be placed on any position
of the message, the current implementation assumes that the first
message parameter should be a dictionary.
---
plugins/bluetooth.c | 27 ++++++++++++++++-----------
plugins/bluetooth.h | 3 ++-
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 201c851..37738e7 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -195,11 +195,14 @@ static gint property_handler_compare(gconstpointer a, gconstpointer b)
return strcmp(handler->property, property);
}
-void bluetooth_parse_properties(DBusMessage *reply, const char *property, ...)
+void bluetooth_parse_properties(DBusMessageIter *array, const char *property, ...)
{
va_list args;
GSList *prop_handlers = NULL;
- DBusMessageIter array, dict;
+ DBusMessageIter dict;
+
+ if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
+ goto done;
va_start(args, property);
@@ -218,13 +221,7 @@ void bluetooth_parse_properties(DBusMessage *reply, const char *property, ...)
va_end(args);
- if (dbus_message_iter_init(reply, &array) == FALSE)
- goto done;
-
- if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
- goto done;
-
- dbus_message_iter_recurse(&array, &dict);
+ dbus_message_iter_recurse(array, &dict);
while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
DBusMessageIter entry, value;
@@ -324,6 +321,7 @@ static void device_properties_cb(DBusPendingCall *call, gpointer user_data)
const char *adapter_addr = NULL;
const char *device_addr = NULL;
const char *alias = NULL;
+ DBusMessageIter iter;
struct DBusError derr;
GSList *uuids = NULL;
@@ -341,7 +339,10 @@ static void device_properties_cb(DBusPendingCall *call, gpointer user_data)
DBG("");
- bluetooth_parse_properties(reply, "UUIDs", parse_uuids, &uuids,
+ if (dbus_message_iter_init(reply, &iter) == FALSE)
+ goto done;
+
+ bluetooth_parse_properties(&iter, "UUIDs", parse_uuids, &uuids,
"Adapter", parse_string, &adapter,
"Address", parse_string, &device_addr,
"Alias", parse_string, &alias, NULL);
@@ -480,6 +481,7 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
{
const char *path = user_data;
DBusMessage *reply;
+ DBusMessageIter iter;
DBusError derr;
GSList *device_list = NULL;
GSList *l;
@@ -499,7 +501,10 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
DBG("");
- bluetooth_parse_properties(reply,
+ if (dbus_message_iter_init(reply, &iter) == FALSE)
+ goto done;
+
+ bluetooth_parse_properties(&iter,
"Devices", parse_devices, &device_list,
"Address", parse_string, &addr,
NULL);
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index a9355f6..5b4d9d4 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -84,7 +84,8 @@ int bluetooth_send_with_reply(const char *path, const char *interface,
DBusPendingCallNotifyFunction cb,
void *user_data, DBusFreeFunction free_func,
int timeout, int type, ...);
-void bluetooth_parse_properties(DBusMessage *reply, const char *property, ...);
+void bluetooth_parse_properties(DBusMessageIter *array,
+ const char *property, ...);
int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
struct ofono_modem *modem);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v0 10/11] hfp_hf: Add Version and Features parsing
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
` (8 preceding siblings ...)
2012-11-22 17:53 ` [RFC v0 09/11] bluetooth: Reuse D-Bus dictionary parser function Claudio Takahasi
@ 2012-11-22 17:53 ` Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 11/11] bluetooth: Use generic function to parse dict Claudio Takahasi
` (3 subsequent siblings)
13 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2202 bytes --]
This patch adds parsing of the Version and Features properties of the
NewConnection fd_dictionary.
---
plugins/hfp_hf.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 25f3415..0f1e75e 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -77,6 +77,16 @@ static void hfp_data_free(struct hfp_data *hfp_data)
g_free(hfp_data);
}
+static void parse_guint16(DBusMessageIter *iter, gpointer user_data)
+{
+ guint16 *value = user_data;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16)
+ return;
+
+ dbus_message_iter_get_basic(iter, value);
+}
+
static void hfp_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
@@ -172,11 +182,11 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
return -EINPROGRESS;
}
-static int modem_register(const char *device, struct hfp_data *hfp_data, int fd)
+static int modem_register(const char *device, struct hfp_data *hfp_data,
+ int fd, guint16 version)
{
struct ofono_modem *modem;
char buf[256];
- guint16 version = 0x0105;
/* We already have this device in our hash, ignore */
if (g_hash_table_lookup(modem_hash, device) != NULL)
@@ -294,6 +304,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
const char *device;
DBusMessageIter entry;
int fd, err;
+ guint16 version = 0x0105, features = 0x0000;
DBG("Profile handler NewConnection");
@@ -318,9 +329,17 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
if (fd < 0)
goto error;
- DBG("hfp_data: %p SLC FD: %d", hfp_data, fd);
+ dbus_message_iter_next(&entry);
+
+ bluetooth_parse_properties(&entry,
+ "Version", parse_guint16, &version,
+ "Features", parse_guint16, &features,
+ NULL);
+
+ DBG("hfp_data: %p SLC FD: %d Version: 0x%04x Features: 0x%04x",
+ hfp_data, fd, version, features);
- err = modem_register(device, hfp_data, fd);
+ err = modem_register(device, hfp_data, fd, version);
if (err < 0 && err != -EINPROGRESS)
return __ofono_error_failed(msg);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v0 11/11] bluetooth: Use generic function to parse dict
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
` (9 preceding siblings ...)
2012-11-22 17:53 ` [RFC v0 10/11] hfp_hf: Add Version and Features parsing Claudio Takahasi
@ 2012-11-22 17:53 ` Claudio Takahasi
2012-11-23 8:44 ` [RFC v0 00/11] External HFP Profile Johan Hedberg
` (2 subsequent siblings)
13 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-22 17:53 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3219 bytes --]
This patch changes the Device PropertiesChanged signal parser to use
the generic utility function to decode dictionary entries.
---
plugins/bluetooth.c | 81 ++++++++++++++++++-----------------------------------
1 file changed, 27 insertions(+), 54 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 37738e7..a3dccee 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -401,8 +401,9 @@ static void get_device_properties(const char *path)
static gboolean properties_changed(DBusConnection *conn, DBusMessage *msg,
void *user_data)
{
- const char *property, *interface;
- DBusMessageIter iter, dict, entry, variant;
+ const char *interface, *path, *alias = NULL;
+ DBusMessageIter iter;
+ GSList *uuids = NULL;
DBG("");
@@ -420,59 +421,31 @@ static gboolean properties_changed(DBusConnection *conn, DBusMessage *msg,
if (!dbus_message_iter_next(&iter))
return FALSE;
- /* Reading Dict entries containing properties */
- dbus_message_iter_recurse(&iter, &dict);
-
- do {
- if (dbus_message_iter_get_arg_type(&dict) !=
- DBUS_TYPE_DICT_ENTRY)
- return FALSE;
-
- dbus_message_iter_recurse(&dict, &entry);
-
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
- return FALSE;
-
- dbus_message_iter_get_basic(&entry, &property);
-
- if (!dbus_message_iter_next(&entry))
- return FALSE;
-
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
- return FALSE;
-
- dbus_message_iter_recurse(&entry, &variant);
- if (g_str_equal(property, "UUIDs") == TRUE) {
- GSList *uuids = NULL;
- const char *path = dbus_message_get_path(msg);
-
- parse_uuids(&variant, &uuids);
-
- /* We need the full set of properties to be able to
- * create the modem properly, including Adapter and
- * Alias, so refetch everything again
- */
- if (uuids)
- get_device_properties(path);
- } else if (g_str_equal(property, "Alias") == TRUE) {
- const char *path = dbus_message_get_path(msg);
- struct bluetooth_profile *profile;
- const char *alias = NULL;
- GHashTableIter hash_iter;
- gpointer key, value;
-
- parse_string(&variant, &alias);
-
- g_hash_table_iter_init(&hash_iter, uuid_hash);
- while (g_hash_table_iter_next(&hash_iter, &key,
- &value)) {
- profile = value;
- if (profile->set_alias)
- profile->set_alias(path, alias);
- }
+ bluetooth_parse_properties(&iter,
+ "UUIDs", parse_uuids, &uuids,
+ "Alias", parse_string, &alias,
+ NULL);
+
+ path = dbus_message_get_path(msg);
+
+ /* We need the full set of properties to be able to
+ * create the modem properly, including Adapter and
+ * Alias, so refetch everything again
+ */
+ if (uuids)
+ get_device_properties(path);
+
+ if (alias) {
+ GHashTableIter hash_iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init(&hash_iter, uuid_hash);
+ while (g_hash_table_iter_next(&hash_iter, &key, &value)) {
+ struct bluetooth_profile *profile = value;
+ if (profile->set_alias)
+ profile->set_alias(path, alias);
}
-
- } while (dbus_message_iter_next(&dict));
+ }
return TRUE;
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [RFC v0 00/11] External HFP Profile
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
` (10 preceding siblings ...)
2012-11-22 17:53 ` [RFC v0 11/11] bluetooth: Use generic function to parse dict Claudio Takahasi
@ 2012-11-23 8:44 ` Johan Hedberg
2012-11-23 8:54 ` Johan Hedberg
2012-11-23 11:43 ` Johan Hedberg
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
13 siblings, 1 reply; 49+ messages in thread
From: Johan Hedberg @ 2012-11-23 8:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2035 bytes --]
Hi Claudio,
On Thu, Nov 22, 2012, Claudio Takahasi wrote:
> BlueZ supports now external profile registration, see:
> bluez/doc/profile-api.txt
>
> This patch series has the initial implementation of the HFP external
> profile in oFono. HandsfreeAgent and HandsfreeGateway interfaces were
> removed from BlueZ.
>
> The next step: implement SCO connection handling in oFono.
In general the patches seem quite good, but I get the following when
connecting HFP, disconnecting and reconnecting (all actions triggered
from the phone side):
ofonod[3940]: plugins/hfp_hf.c:profile_new_connection() Profile handler NewConnection
ofonod[3940]: plugins/hfp_hf.c:profile_new_connection() hfp_data: 0x4e190f0 SLC FD: 9 Version: 0x0106 Features: 0x0027
==3940== Invalid read of size 8
==3940== at 0x47E565: profile_new_connection (hfp_hf.c:196)
==3940== by 0x40F960: process_message.isra.0 (object.c:197)
==3940== by 0x37F181D874: ??? (in /usr/lib64/libdbus-1.so.3.7.1)
==3940== by 0x37F180FAEF: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.7.1)
==3940== by 0x40DFE7: message_dispatch (mainloop.c:76)
==3940== by 0x37EE0483BA: g_timeout_dispatch (gmain.c:3882)
==3940== by 0x37EE047824: g_main_context_dispatch (gmain.c:2539)
==3940== by 0x37EE047B57: g_main_context_iterate.isra.23 (gmain.c:3146)
==3940== by 0x37EE047F51: g_main_loop_run (gmain.c:3340)
==3940== by 0x40DC41: main (main.c:247)
==3940== Address 0x4e19130 is 64 bytes inside a block of size 96 free'd
==3940== at 0x4A07786: free (vg_replace_malloc.c:446)
==3940== by 0x37EE04D50E: g_free (gmem.c:252)
==3940== by 0x37EE045797: g_source_callback_unref (gmain.c:1288)
==3940== by 0x37EE04528A: g_source_destroy_internal (gmain.c:957)
==3940== by 0x37EE04786F: g_main_context_dispatch (gmain.c:2563)
==3940== by 0x37EE047B57: g_main_context_iterate.isra.23 (gmain.c:3146)
==3940== by 0x37EE047F51: g_main_loop_run (gmain.c:3340)
==3940== by 0x40DC41: main (main.c:247)
Johan
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [RFC v0 00/11] External HFP Profile
2012-11-23 8:44 ` [RFC v0 00/11] External HFP Profile Johan Hedberg
@ 2012-11-23 8:54 ` Johan Hedberg
0 siblings, 0 replies; 49+ messages in thread
From: Johan Hedberg @ 2012-11-23 8:54 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3051 bytes --]
Hi Claudio,
On Fri, Nov 23, 2012, Johan Hedberg wrote:
> On Thu, Nov 22, 2012, Claudio Takahasi wrote:
> > BlueZ supports now external profile registration, see:
> > bluez/doc/profile-api.txt
> >
> > This patch series has the initial implementation of the HFP external
> > profile in oFono. HandsfreeAgent and HandsfreeGateway interfaces were
> > removed from BlueZ.
> >
> > The next step: implement SCO connection handling in oFono.
>
> In general the patches seem quite good, but I get the following when
> connecting HFP, disconnecting and reconnecting (all actions triggered
> from the phone side):
>
> ofonod[3940]: plugins/hfp_hf.c:profile_new_connection() Profile handler NewConnection
> ofonod[3940]: plugins/hfp_hf.c:profile_new_connection() hfp_data: 0x4e190f0 SLC FD: 9 Version: 0x0106 Features: 0x0027
> ==3940== Invalid read of size 8
> ==3940== at 0x47E565: profile_new_connection (hfp_hf.c:196)
> ==3940== by 0x40F960: process_message.isra.0 (object.c:197)
> ==3940== by 0x37F181D874: ??? (in /usr/lib64/libdbus-1.so.3.7.1)
> ==3940== by 0x37F180FAEF: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.7.1)
> ==3940== by 0x40DFE7: message_dispatch (mainloop.c:76)
> ==3940== by 0x37EE0483BA: g_timeout_dispatch (gmain.c:3882)
> ==3940== by 0x37EE047824: g_main_context_dispatch (gmain.c:2539)
> ==3940== by 0x37EE047B57: g_main_context_iterate.isra.23 (gmain.c:3146)
> ==3940== by 0x37EE047F51: g_main_loop_run (gmain.c:3340)
> ==3940== by 0x40DC41: main (main.c:247)
> ==3940== Address 0x4e19130 is 64 bytes inside a block of size 96 free'd
> ==3940== at 0x4A07786: free (vg_replace_malloc.c:446)
> ==3940== by 0x37EE04D50E: g_free (gmem.c:252)
> ==3940== by 0x37EE045797: g_source_callback_unref (gmain.c:1288)
> ==3940== by 0x37EE04528A: g_source_destroy_internal (gmain.c:957)
> ==3940== by 0x37EE04786F: g_main_context_dispatch (gmain.c:2563)
> ==3940== by 0x37EE047B57: g_main_context_iterate.isra.23 (gmain.c:3146)
> ==3940== by 0x37EE047F51: g_main_loop_run (gmain.c:3340)
> ==3940== by 0x40DC41: main (main.c:247)
I also found this leak:
==3940== 195 (96 direct, 99 indirect) bytes in 1 blocks are definitely lost in loss record 134 of 175
==3940== at 0x4A0881C: malloc (vg_replace_malloc.c:270)
==3940== by 0x37EE04D55D: g_try_malloc0 (gmem.c:296)
==3940== by 0x47E2F3: hfp_hf_probe (hfp_hf.c:225)
==3940== by 0x47B9A4: device_properties_cb (bluetooth.c:307)
==3940== by 0x37F180C729: ??? (in /usr/lib64/libdbus-1.so.3.7.1)
==3940== by 0x37F180F7F2: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.7.1)
==3940== by 0x40DFE7: message_dispatch (mainloop.c:76)
==3940== by 0x37EE0483BA: g_timeout_dispatch (gmain.c:3882)
==3940== by 0x37EE047824: g_main_context_dispatch (gmain.c:2539)
==3940== by 0x37EE047B57: g_main_context_iterate.isra.23 (gmain.c:3146)
==3940== by 0x37EE047F51: g_main_loop_run (gmain.c:3340)
==3940== by 0x40DC41: main (main.c:247)
Johan
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [RFC v0 00/11] External HFP Profile
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
` (11 preceding siblings ...)
2012-11-23 8:44 ` [RFC v0 00/11] External HFP Profile Johan Hedberg
@ 2012-11-23 11:43 ` Johan Hedberg
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
13 siblings, 0 replies; 49+ messages in thread
From: Johan Hedberg @ 2012-11-23 11:43 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]
Hi Claudio,
On Thu, Nov 22, 2012, Claudio Takahasi wrote:
> BlueZ supports now external profile registration, see:
> bluez/doc/profile-api.txt
>
> This patch series has the initial implementation of the HFP external
> profile in oFono. HandsfreeAgent and HandsfreeGateway interfaces were
> removed from BlueZ.
I also got this weirdness:
ofonod[9813]: plugins/hfp_hf.c:profile_new_connection() Profile handler NewConnection
ofonod[9813]: plugins/hfp_hf.c:profile_new_connection() /org/bluez/hci0/dev_70_F9_27_18_1F_B9: doesn't support HFP
Which seems to be from the following set of code in
profile_new_connection():
hfp_data = g_hash_table_lookup(hfp_hash, device);
if (hfp_data == NULL) {
DBG("%s: doesn't support HFP", device);
goto error;
}
You can't rely on SDP having been completed by the time there's an
incoming HFP connection. This is a very likely scenario when the remote
initiates the connection. In such a case the mere fact that the remote
has connected HFP to us *is* the proof that the remote supports HFP and
you should just accept such connection attempts.
Johan
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [RFC v0 01/11] hfp_hf: Add HFP external Profile registration
2012-11-22 17:53 ` [RFC v0 01/11] hfp_hf: Add HFP external Profile registration Claudio Takahasi
@ 2012-11-26 11:08 ` Johan Hedberg
2012-11-26 11:24 ` Johan Hedberg
0 siblings, 1 reply; 49+ messages in thread
From: Johan Hedberg @ 2012-11-26 11:08 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1029 bytes --]
Hi Claudio,
On Thu, Nov 22, 2012, Claudio Takahasi wrote:
> +int bluetooth_register_profile(const char *uuid, const char *name,
> + const char *object)
> +{
> + DBusMessageIter iter, dict;
> + DBusPendingCall *c;
> + DBusMessage *msg;
> +
> + DBG("Bluetooth: Registering %s (%s) profile", uuid, name);
> +
> + msg = dbus_message_new_method_call(BLUEZ_SERVICE, "/org/bluez",
> + BLUEZ_PROFILE_MGMT_INTERFACE, "RegisterProfile");
> +
> + dbus_message_iter_init_append(msg, &iter);
> + dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &object);
> + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &uuid);
> +
> + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict);
> + dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
> + dbus_message_iter_close_container(&iter, &dict);
You're missing the "AutoConnect" dict entry here. Without it HFP will
not be connected using Device.Connect (only remotely initiated or with
Device.ConnectProfile).
Johan
^ permalink raw reply [flat|nested] 49+ messages in thread
* Re: [RFC v0 01/11] hfp_hf: Add HFP external Profile registration
2012-11-26 11:08 ` Johan Hedberg
@ 2012-11-26 11:24 ` Johan Hedberg
0 siblings, 0 replies; 49+ messages in thread
From: Johan Hedberg @ 2012-11-26 11:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1240 bytes --]
Hi Claudio,
> On Thu, Nov 22, 2012, Claudio Takahasi wrote:
> > +int bluetooth_register_profile(const char *uuid, const char *name,
> > + const char *object)
> > +{
> > + DBusMessageIter iter, dict;
> > + DBusPendingCall *c;
> > + DBusMessage *msg;
> > +
> > + DBG("Bluetooth: Registering %s (%s) profile", uuid, name);
> > +
> > + msg = dbus_message_new_method_call(BLUEZ_SERVICE, "/org/bluez",
> > + BLUEZ_PROFILE_MGMT_INTERFACE, "RegisterProfile");
> > +
> > + dbus_message_iter_init_append(msg, &iter);
> > + dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &object);
> > + dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &uuid);
> > +
> > + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict);
> > + dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
> > + dbus_message_iter_close_container(&iter, &dict);
>
> You're missing the "AutoConnect" dict entry here. Without it HFP will
> not be connected using Device.Connect (only remotely initiated or with
> Device.ConnectProfile).
Actually never mind. I added the auto_connect value to the profile
defaults table on the BlueZ side so this is not needed in the
RegisterProfile method call.
Johan
^ permalink raw reply [flat|nested] 49+ messages in thread
* [RFC v1 00/15] External HFP Profile
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
` (12 preceding siblings ...)
2012-11-23 11:43 ` Johan Hedberg
@ 2012-11-26 13:26 ` Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 01/15] hfp_hf: Add HFP external Profile registration Claudio Takahasi
` (15 more replies)
13 siblings, 16 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:26 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1641 bytes --]
BlueZ supports now external profile registration, see:
bluez/doc/profile-api.txt
This patch series has the initial implementation of the HFP external
profile in oFono. HandsfreeAgent and HandsfreeGateway interfaces were
removed from BlueZ.
Modem are being registered dinamically when the new connection is
notified instead of registering the modem when the Bluetooth device
is created/probed.
* Needs to be applied after "[PATCH v0 1/4] bluetooth: Fix reading
Bluetooth Adapters" series
Changes from RFC v0:
- memory leak fixes
- fixed invalid read
- handle connections if the Bluetooth device is still being created
(eg: SDP running).
The next step: implement SCO connection handling in oFono.
Claudio Takahasi (15):
hfp_hf: Add HFP external Profile registration
hfp_hf: Add BlueZ Profile handler
hfp_hf: Add parsing of Profile NewConnection call
hfp_hf: Add SLC setup
hfp_hf: Add Profile1 Release
hfp_hf: Remove HandsfreeAgent and HandsfreeGateway
hfp_hf: Register HFP modem dynamically
hfp_hf: Fix updating alias
bluetooth: Reuse D-Bus dictionary parser function
hfp_hf: Add Version and Features parsing
bluetooth: Use generic function to parse dict
hfp_hf: Request secure connections
bluetooth: Fix memory leak of adapter_any_path
hfp_hf: Handle connections before probe
bluetooth: Fix memory leak of UUIDs list
plugins/bluetooth.c | 275 ++++++++++++++++++++++++--------
plugins/bluetooth.h | 12 +-
plugins/hfp_hf.c | 447 ++++++++++++++++++++++++++--------------------------
3 files changed, 449 insertions(+), 285 deletions(-)
--
1.7.11.7
^ permalink raw reply [flat|nested] 49+ messages in thread
* [RFC v1 01/15] hfp_hf: Add HFP external Profile registration
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
@ 2012-11-26 13:26 ` Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 02/15] hfp_hf: Add BlueZ Profile handler Claudio Takahasi
` (14 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:26 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6579 bytes --]
This patch adds the functions to allow registering and unregistering HFP
external profile using BlueZ ProfileManager1 interface.
---
plugins/bluetooth.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++
plugins/bluetooth.h | 5 +-
plugins/hfp_hf.c | 12 +++++
3 files changed, 153 insertions(+), 1 deletion(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 09c9870..201c851 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -65,6 +65,39 @@ struct cb_data {
GIOChannel *io;
};
+static void append_variant(DBusMessageIter *iter, int type, void *val)
+{
+ DBusMessageIter value;
+ char sig[2] = { type, '\0' };
+
+ dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value);
+
+ dbus_message_iter_append_basic(&value, type, val);
+
+ dbus_message_iter_close_container(iter, &value);
+}
+
+static void dict_append_entry(DBusMessageIter *dict, const char *key, int type,
+ void *val)
+{
+ DBusMessageIter entry;
+
+ if (type == DBUS_TYPE_STRING) {
+ const char *str = *((const char **) val);
+ if (str == NULL)
+ return;
+ }
+
+ dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL,
+ &entry);
+
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+
+ append_variant(&entry, type, val);
+
+ dbus_message_iter_close_container(dict, &entry);
+}
+
void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
char *buf, int size)
{
@@ -968,6 +1001,110 @@ void bluetooth_unregister_uuid(const char *uuid)
bluetooth_unref();
}
+static void register_profile_cb(DBusPendingCall *call, gpointer user_data)
+{
+ DBusMessage *reply;
+ DBusError derr;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&derr);
+
+ if (dbus_set_error_from_message(&derr, reply)) {
+ ofono_error("RegisterProfile() replied an error: %s, %s",
+ derr.name, derr.message);
+ dbus_error_free(&derr);
+ goto done;
+ }
+
+ DBG("");
+
+done:
+ dbus_message_unref(reply);
+}
+
+int bluetooth_register_profile(const char *uuid, const char *name,
+ const char *object)
+{
+ DBusMessageIter iter, dict;
+ DBusPendingCall *c;
+ DBusMessage *msg;
+
+ DBG("Bluetooth: Registering %s (%s) profile", uuid, name);
+
+ msg = dbus_message_new_method_call(BLUEZ_SERVICE, "/org/bluez",
+ BLUEZ_PROFILE_MGMT_INTERFACE, "RegisterProfile");
+
+ dbus_message_iter_init_append(msg, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &object);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &uuid);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict);
+ dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ if (!dbus_connection_send_with_reply(connection, msg, &c, -1)) {
+ ofono_error("Sending RegisterProfile failed");
+ dbus_message_unref(msg);
+ return -EIO;
+ }
+
+ dbus_pending_call_set_notify(c, register_profile_cb, NULL, NULL);
+ dbus_pending_call_unref(c);
+
+ dbus_message_unref(msg);
+
+ return 0;
+}
+
+static void unregister_profile_cb(DBusPendingCall *call, gpointer user_data)
+{
+ DBusMessage *reply;
+ DBusError derr;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&derr);
+
+ if (dbus_set_error_from_message(&derr, reply)) {
+ ofono_error("UnregisterProfile() replied an error: %s, %s",
+ derr.name, derr.message);
+ dbus_error_free(&derr);
+ goto done;
+ }
+
+ DBG("");
+
+done:
+ dbus_message_unref(reply);
+}
+
+void bluetooth_unregister_profile(const char *object)
+{
+ DBusMessageIter iter;
+ DBusPendingCall *c;
+ DBusMessage *msg;
+
+ DBG("Bluetooth: Unregistering profile %s", object);
+
+ msg = dbus_message_new_method_call(BLUEZ_SERVICE, "/org/bluez",
+ BLUEZ_PROFILE_MGMT_INTERFACE, "UnregisterProfile");
+
+ dbus_message_iter_init_append(msg, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &object);
+
+ if (!dbus_connection_send_with_reply(connection, msg, &c, -1)) {
+ ofono_error("Sending RegisterProfile failed");
+ dbus_message_unref(msg);
+ return;
+ }
+
+ dbus_pending_call_set_notify(c, unregister_profile_cb, NULL, NULL);
+ dbus_pending_call_unref(c);
+
+ dbus_message_unref(msg);
+}
+
struct server *bluetooth_register_server(guint8 channel, const char *sdp_record,
ConnectFunc cb, gpointer user_data)
{
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index af59d3d..ffaf9e3 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -24,6 +24,7 @@
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
+#define BLUEZ_PROFILE_MGMT_INTERFACE BLUEZ_SERVICE ".ProfileManager1"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
#define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device"
#define BLUEZ_SERVICE_INTERFACE BLUEZ_SERVICE ".Service"
@@ -66,7 +67,9 @@ void bluetooth_get_properties();
int bluetooth_register_uuid(const char *uuid,
struct bluetooth_profile *profile);
void bluetooth_unregister_uuid(const char *uuid);
-
+int bluetooth_register_profile(const char *uuid, const char *name,
+ const char *object);
+void bluetooth_unregister_profile(const char *object);
struct server *bluetooth_register_server(guint8 channel, const char *sdp_record,
ConnectFunc cb, gpointer user_data);
void bluetooth_unregister_server(struct server *server);
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 7c500e3..1e0064c 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -54,6 +54,8 @@
#define HFP_AGENT_INTERFACE "org.bluez.HandsfreeAgent"
#define HFP_AGENT_ERROR_INTERFACE "org.bluez.Error"
+#define HFP_EXT_PROFILE_PATH "/bluetooth/profile/hfp_hf"
+
#ifndef DBUS_TYPE_UNIX_FD
#define DBUS_TYPE_UNIX_FD -1
#endif
@@ -534,6 +536,14 @@ static int hfp_init(void)
return err;
}
+ err = bluetooth_register_profile(HFP_HS_UUID, "hfp_hf",
+ HFP_EXT_PROFILE_PATH);
+ if (err < 0) {
+ bluetooth_unregister_uuid(HFP_AG_UUID);
+ ofono_modem_driver_unregister(&hfp_driver);
+ return err;
+ }
+
modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, NULL);
@@ -542,6 +552,8 @@ static int hfp_init(void)
static void hfp_exit(void)
{
+
+ bluetooth_unregister_profile(HFP_EXT_PROFILE_PATH);
bluetooth_unregister_uuid(HFP_AG_UUID);
ofono_modem_driver_unregister(&hfp_driver);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 02/15] hfp_hf: Add BlueZ Profile handler
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 01/15] hfp_hf: Add HFP external Profile registration Claudio Takahasi
@ 2012-11-26 13:26 ` Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 03/15] hfp_hf: Add parsing of Profile NewConnection call Claudio Takahasi
` (13 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:26 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3981 bytes --]
This patch declares the external HFP Profile handler. It contains the
initial implementation of the D-Bus Profile1 interface and methods
responsible for handling Bluetooth connections.
---
plugins/bluetooth.h | 1 +
plugins/hfp_hf.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index ffaf9e3..96f3a53 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -25,6 +25,7 @@
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
#define BLUEZ_PROFILE_MGMT_INTERFACE BLUEZ_SERVICE ".ProfileManager1"
+#define BLUEZ_PROFILE_INTERFACE BLUEZ_SERVICE ".Profile1"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
#define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device"
#define BLUEZ_SERVICE_INTERFACE BLUEZ_SERVICE ".Service"
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 1e0064c..405ada2 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -339,6 +339,47 @@ static int hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
return 0;
}
+static DBusMessage *profile_new_connection(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler NewConnection");
+ return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *profile_release(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler Release");
+ return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *profile_cancel(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler Cancel");
+ return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *profile_disconnection(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler RequestDisconnection");
+ return dbus_message_new_method_return(msg);
+}
+
+static const GDBusMethodTable profile_methods[] = {
+ { GDBUS_ASYNC_METHOD("NewConnection",
+ GDBUS_ARGS({ "device", "o"}, { "fd", "h"},
+ { "fd_properties", "a{sv}" }),
+ NULL, profile_new_connection) },
+ { GDBUS_METHOD("Release", NULL, NULL, profile_release) },
+ { GDBUS_METHOD("Cancel", NULL, NULL, profile_cancel) },
+ { GDBUS_METHOD("RequestDisconnection",
+ GDBUS_ARGS({"o"}), NULL,
+ profile_disconnection) },
+ { }
+};
+
static int hfp_probe(struct ofono_modem *modem)
{
const char *obj_path = ofono_modem_get_path(modem);
@@ -526,12 +567,24 @@ static int hfp_init(void)
connection = ofono_dbus_get_connection();
+ /* Registers External Profile handler */
+ if (!g_dbus_register_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE,
+ profile_methods, NULL,
+ NULL, NULL, NULL)) {
+ ofono_error("Register Profile interface failed: %s",
+ HFP_EXT_PROFILE_PATH);
+ return -EIO;
+ }
+
err = ofono_modem_driver_register(&hfp_driver);
if (err < 0)
return err;
err = bluetooth_register_uuid(HFP_AG_UUID, &hfp_hf);
if (err < 0) {
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
ofono_modem_driver_unregister(&hfp_driver);
return err;
}
@@ -539,6 +592,8 @@ static int hfp_init(void)
err = bluetooth_register_profile(HFP_HS_UUID, "hfp_hf",
HFP_EXT_PROFILE_PATH);
if (err < 0) {
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
bluetooth_unregister_uuid(HFP_AG_UUID);
ofono_modem_driver_unregister(&hfp_driver);
return err;
@@ -552,7 +607,8 @@ static int hfp_init(void)
static void hfp_exit(void)
{
-
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
bluetooth_unregister_profile(HFP_EXT_PROFILE_PATH);
bluetooth_unregister_uuid(HFP_AG_UUID);
ofono_modem_driver_unregister(&hfp_driver);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 03/15] hfp_hf: Add parsing of Profile NewConnection call
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 01/15] hfp_hf: Add HFP external Profile registration Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 02/15] hfp_hf: Add BlueZ Profile handler Claudio Takahasi
@ 2012-11-26 13:26 ` Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 04/15] hfp_hf: Add SLC setup Claudio Takahasi
` (12 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:26 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2085 bytes --]
This patch adds the parsing of the mandatory arguments in NewConnection
method call implemented in Profile1 interface.
---
plugins/bluetooth.h | 1 +
plugins/hfp_hf.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 96f3a53..a9355f6 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -24,6 +24,7 @@
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
+#define BLUEZ_ERROR_INTERFACE BLUEZ_SERVICE ".Error"
#define BLUEZ_PROFILE_MGMT_INTERFACE BLUEZ_SERVICE ".ProfileManager1"
#define BLUEZ_PROFILE_INTERFACE BLUEZ_SERVICE ".Profile1"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 405ada2..edb7671 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -342,8 +342,41 @@ static int hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct ofono_modem *modem;
+ const char *device;
+ DBusMessageIter entry;
+ int fd;
+
DBG("Profile handler NewConnection");
+
+ if (dbus_message_iter_init(msg, &entry) == FALSE)
+ goto error;
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_OBJECT_PATH)
+ goto error;
+
+ dbus_message_iter_get_basic(&entry, &device);
+ modem = g_hash_table_lookup(modem_hash, device);
+ if (modem == NULL) {
+ DBG("%s: modem not found", device);
+ goto error;
+ }
+
+ dbus_message_iter_next(&entry);
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_UNIX_FD)
+ goto error;
+
+ dbus_message_iter_get_basic(&entry, &fd);
+ if (fd < 0)
+ goto error;
+
+ DBG("modem %p, SLC FD: %d", modem, fd);
+
return dbus_message_new_method_return(msg);
+
+error:
+ return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
+ "Invalid arguments in method call");
}
static DBusMessage *profile_release(DBusConnection *conn,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 04/15] hfp_hf: Add SLC setup
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (2 preceding siblings ...)
2012-11-26 13:26 ` [RFC v1 03/15] hfp_hf: Add parsing of Profile NewConnection call Claudio Takahasi
@ 2012-11-26 13:26 ` Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 05/15] hfp_hf: Add Profile1 Release Claudio Takahasi
` (11 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:26 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1796 bytes --]
This patch adds the SLC setup when the NewConnection is notified.
---
plugins/hfp_hf.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index edb7671..819c8cd 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -101,9 +101,10 @@ static void slc_failed(gpointer userdata)
struct hfp_data *data = ofono_modem_get_data(modem);
DBusMessage *msg;
- msg = g_dbus_create_error(data->slc_msg, HFP_AGENT_ERROR_INTERFACE
- ".Failed",
- "HFP Handshake failed");
+ msg = g_dbus_create_error(data->slc_msg, BLUEZ_ERROR_INTERFACE
+ ".Failed",
+ "HFP Handshake failed");
+
g_dbus_send_message(connection, msg);
dbus_message_unref(data->slc_msg);
data->slc_msg = NULL;
@@ -343,9 +344,11 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct ofono_modem *modem;
+ struct hfp_data *hfp_data;
const char *device;
DBusMessageIter entry;
- int fd;
+ int fd, err;
+ guint16 version = 0x0105;
DBG("Profile handler NewConnection");
@@ -370,9 +373,18 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
if (fd < 0)
goto error;
- DBG("modem %p, SLC FD: %d", modem, fd);
+ hfp_data = ofono_modem_get_data(modem);
+ DBG("modem %p, hfp_data: %p SLC FD: %d", modem, hfp_data, fd);
- return dbus_message_new_method_return(msg);
+ hfp_slc_info_init(&hfp_data->info, version);
+
+ err = service_level_connection(modem, fd);
+ if (err < 0 && err != -EINPROGRESS)
+ return __ofono_error_failed(msg);
+
+ hfp_data->slc_msg = dbus_message_ref(msg);
+
+ return NULL;
error:
return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 05/15] hfp_hf: Add Profile1 Release
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (3 preceding siblings ...)
2012-11-26 13:26 ` [RFC v1 04/15] hfp_hf: Add SLC setup Claudio Takahasi
@ 2012-11-26 13:26 ` Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 06/15] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway Claudio Takahasi
` (10 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:26 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 740 bytes --]
This patch adds the Release method of the external Profile handler.
Release method gets called when BlueZ unregisters the HFP profile.
---
plugins/hfp_hf.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 819c8cd..c536691 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -395,6 +395,12 @@ static DBusMessage *profile_release(DBusConnection *conn,
DBusMessage *msg, void *data)
{
DBG("Profile handler Release");
+
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
+
+ g_hash_table_foreach_remove(modem_hash, hfp_remove_modem, NULL);
+
return dbus_message_new_method_return(msg);
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 06/15] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (4 preceding siblings ...)
2012-11-26 13:26 ` [RFC v1 05/15] hfp_hf: Add Profile1 Release Claudio Takahasi
@ 2012-11-26 13:27 ` Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 07/15] hfp_hf: Register HFP modem dynamically Claudio Takahasi
` (9 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 8610 bytes --]
This patch removes the deprecated HandsfreeAgent and HandsfreeGateway
interfaces. New connections are now being managed by a BlueZ external
Profile handler.
---
plugins/hfp_hf.c | 215 ++-----------------------------------------------------
1 file changed, 7 insertions(+), 208 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index c536691..dc00227 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -49,11 +49,6 @@
#include "bluetooth.h"
-#define BLUEZ_GATEWAY_INTERFACE BLUEZ_SERVICE ".HandsfreeGateway"
-
-#define HFP_AGENT_INTERFACE "org.bluez.HandsfreeAgent"
-#define HFP_AGENT_ERROR_INTERFACE "org.bluez.Error"
-
#define HFP_EXT_PROFILE_PATH "/bluetooth/profile/hfp_hf"
#ifndef DBUS_TYPE_UNIX_FD
@@ -65,11 +60,8 @@ static GHashTable *modem_hash = NULL;
struct hfp_data {
struct hfp_slc_info info;
- char *handsfree_path;
char *handsfree_address;
DBusMessage *slc_msg;
- gboolean agent_registered;
- DBusPendingCall *call;
};
static void hfp_debug(const char *str, void *user_data)
@@ -161,54 +153,6 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
return -EINPROGRESS;
}
-static DBusMessage *hfp_agent_new_connection(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- int fd, err;
- struct ofono_modem *modem = data;
- struct hfp_data *hfp_data = ofono_modem_get_data(modem);
- guint16 version;
-
- if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UNIX_FD, &fd,
- DBUS_TYPE_UINT16, &version, DBUS_TYPE_INVALID))
- return __ofono_error_invalid_args(msg);
-
- hfp_slc_info_init(&hfp_data->info, version);
-
- err = service_level_connection(modem, fd);
- if (err < 0 && err != -EINPROGRESS)
- return __ofono_error_failed(msg);
-
- hfp_data->slc_msg = msg;
- dbus_message_ref(msg);
-
- return NULL;
-}
-
-static DBusMessage *hfp_agent_release(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct ofono_modem *modem = data;
- struct hfp_data *hfp_data = ofono_modem_get_data(modem);
- const char *obj_path = ofono_modem_get_path(modem);
-
- g_dbus_unregister_interface(connection, obj_path, HFP_AGENT_INTERFACE);
- hfp_data->agent_registered = FALSE;
-
- g_hash_table_remove(modem_hash, hfp_data->handsfree_path);
- ofono_modem_remove(modem);
-
- return dbus_message_new_method_return(msg);
-}
-
-static const GDBusMethodTable agent_methods[] = {
- { GDBUS_ASYNC_METHOD("NewConnection",
- GDBUS_ARGS({ "fd", "h" }, { "version", "q" }),
- NULL, hfp_agent_new_connection) },
- { GDBUS_METHOD("Release", NULL, NULL, hfp_agent_release) },
- { }
-};
-
static int hfp_hf_probe(const char *device, const char *dev_addr,
const char *adapter_addr, const char *alias)
{
@@ -234,10 +178,6 @@ static int hfp_hf_probe(const char *device, const char *dev_addr,
if (data == NULL)
goto free;
- data->handsfree_path = g_strdup(device);
- if (data->handsfree_path == NULL)
- goto free;
-
data->handsfree_address = g_strdup(dev_addr);
if (data->handsfree_address == NULL)
goto free;
@@ -251,9 +191,6 @@ static int hfp_hf_probe(const char *device, const char *dev_addr,
return 0;
free:
- if (data != NULL)
- g_free(data->handsfree_path);
-
g_free(data);
ofono_modem_remove(modem);
@@ -300,46 +237,6 @@ static void hfp_hf_set_alias(const char *device, const char *alias)
ofono_modem_set_name(modem, alias);
}
-static int hfp_register_ofono_handsfree(struct ofono_modem *modem)
-{
- const char *obj_path = ofono_modem_get_path(modem);
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusMessage *msg;
-
- DBG("Registering oFono Agent to bluetooth daemon");
-
- msg = dbus_message_new_method_call(BLUEZ_SERVICE, data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "RegisterAgent");
- if (msg == NULL)
- return -ENOMEM;
-
- dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &obj_path,
- DBUS_TYPE_INVALID);
-
- g_dbus_send_message(connection, msg);
- return 0;
-}
-
-static int hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
-{
- const char *obj_path = ofono_modem_get_path(modem);
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusMessage *msg;
-
- DBG("Unregistering oFono Agent from bluetooth daemon");
-
- msg = dbus_message_new_method_call(BLUEZ_SERVICE, data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "UnregisterAgent");
- if (msg == NULL)
- return -ENOMEM;
-
- dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &obj_path,
- DBUS_TYPE_INVALID);
-
- g_dbus_send_message(connection, msg);
- return 0;
-}
-
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -433,19 +330,7 @@ static const GDBusMethodTable profile_methods[] = {
static int hfp_probe(struct ofono_modem *modem)
{
- const char *obj_path = ofono_modem_get_path(modem);
- struct hfp_data *data = ofono_modem_get_data(modem);
-
- if (data == NULL)
- return -EINVAL;
-
- g_dbus_register_interface(connection, obj_path, HFP_AGENT_INTERFACE,
- agent_methods, NULL, NULL, modem, NULL);
-
- data->agent_registered = TRUE;
-
- if (hfp_register_ofono_handsfree(modem) != 0)
- return -EINVAL;
+ DBG("modem: %p", modem);
return 0;
}
@@ -453,124 +338,38 @@ static int hfp_probe(struct ofono_modem *modem)
static void hfp_remove(struct ofono_modem *modem)
{
struct hfp_data *data = ofono_modem_get_data(modem);
- const char *obj_path = ofono_modem_get_path(modem);
-
- if (data->call != NULL)
- dbus_pending_call_cancel(data->call);
- if (g_dbus_unregister_interface(connection, obj_path,
- HFP_AGENT_INTERFACE))
- hfp_unregister_ofono_handsfree(modem);
+ DBG("modem: %p", modem);
g_free(data->handsfree_address);
- g_free(data->handsfree_path);
g_free(data);
ofono_modem_set_data(modem, NULL);
}
-static void hfp_connect_reply(DBusPendingCall *call, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusError derr;
- DBusMessage *reply, *msg;
-
- reply = dbus_pending_call_steal_reply(call);
-
- if (ofono_modem_get_powered(modem))
- goto done;
-
- dbus_error_init(&derr);
- if (!dbus_set_error_from_message(&derr, reply))
- goto done;
-
- DBG("Connect reply: %s", derr.message);
-
- if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) {
- msg = dbus_message_new_method_call(BLUEZ_SERVICE,
- data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "Disconnect");
- if (msg == NULL)
- ofono_error("Disconnect failed");
- else
- g_dbus_send_message(connection, msg);
- }
-
- ofono_modem_set_powered(modem, FALSE);
-
- dbus_error_free(&derr);
-
-done:
- dbus_message_unref(reply);
- data->call = NULL;
-}
-
/* power up hardware */
static int hfp_enable(struct ofono_modem *modem)
{
- struct hfp_data *data = ofono_modem_get_data(modem);
- int status;
-
DBG("%p", modem);
- status = bluetooth_send_with_reply(data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "Connect",
- &data->call, hfp_connect_reply,
- modem, NULL,
- DBUS_TIMEOUT, DBUS_TYPE_INVALID);
-
- if (status < 0)
- return -EINVAL;
-
- return -EINPROGRESS;
-}
-
-static void hfp_power_down(DBusPendingCall *call, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusMessage *reply;
- DBusError derr;
-
- reply = dbus_pending_call_steal_reply(call);
-
- dbus_error_init(&derr);
- if (dbus_set_error_from_message(&derr, reply)) {
- DBG("Disconnect reply: %s", derr.message);
- dbus_error_free(&derr);
- goto done;
- }
-
- ofono_modem_set_powered(modem, FALSE);
+ if (ofono_modem_get_powered(modem))
+ return 0;
-done:
- dbus_message_unref(reply);
- data->call = NULL;
+ return -ENOTCONN;
}
static int hfp_disable(struct ofono_modem *modem)
{
struct hfp_data *data = ofono_modem_get_data(modem);
- int status;
DBG("%p", modem);
g_at_chat_unref(data->info.chat);
data->info.chat = NULL;
- if (data->agent_registered) {
- status = bluetooth_send_with_reply(data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "Disconnect",
- &data->call, hfp_power_down,
- modem, NULL,
- DBUS_TIMEOUT, DBUS_TYPE_INVALID);
-
- if (status < 0)
- return -EINVAL;
- }
+ ofono_modem_set_powered(modem, FALSE);
- return -EINPROGRESS;
+ return 0;
}
static void hfp_pre_sim(struct ofono_modem *modem)
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 07/15] hfp_hf: Register HFP modem dynamically
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (5 preceding siblings ...)
2012-11-26 13:27 ` [RFC v1 06/15] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway Claudio Takahasi
@ 2012-11-26 13:27 ` Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 08/15] hfp_hf: Fix updating alias Claudio Takahasi
` (8 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6714 bytes --]
This patch moves the modem creation from the Bluetooth profile probe
to the NewConnection method call. HFP modem are now registered when
the Bluetooth link is established.
---
plugins/hfp_hf.c | 109 +++++++++++++++++++++++++++++++++++++------------------
1 file changed, 73 insertions(+), 36 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index dc00227..b3ea13f 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -57,13 +57,28 @@
static DBusConnection *connection;
static GHashTable *modem_hash = NULL;
+static GHashTable *hfp_hash = NULL;
struct hfp_data {
struct hfp_slc_info info;
- char *handsfree_address;
+ gchar *device_address;
+ gchar *adapter_address;
+ gchar *device_alias;
+ gchar *device_path;
DBusMessage *slc_msg;
};
+static void hfp_data_free(gpointer user_data)
+{
+ struct hfp_data *hfp_data = user_data;
+
+ g_free(hfp_data->device_address);
+ g_free(hfp_data->adapter_address);
+ g_free(hfp_data->device_alias);
+ g_free(hfp_data->device_path);
+ g_free(hfp_data);
+}
+
static void hfp_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
@@ -117,6 +132,10 @@ static void hfp_disconnected_cb(gpointer user_data)
g_at_chat_unref(data->info.chat);
data->info.chat = NULL;
+
+ g_hash_table_remove(modem_hash, data->device_path);
+
+ ofono_modem_remove(modem);
}
/* either oFono or Phone could request SLC connection */
@@ -153,46 +172,72 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
return -EINPROGRESS;
}
-static int hfp_hf_probe(const char *device, const char *dev_addr,
- const char *adapter_addr, const char *alias)
+static int modem_register(const char *device, struct hfp_data *hfp_data, int fd)
{
struct ofono_modem *modem;
- struct hfp_data *data;
char buf[256];
+ guint16 version = 0x0105;
/* We already have this device in our hash, ignore */
if (g_hash_table_lookup(modem_hash, device) != NULL)
return -EALREADY;
- ofono_info("Using device: %s, devaddr: %s, adapter: %s",
- device, dev_addr, adapter_addr);
-
strcpy(buf, "hfp/");
- bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
+ bluetooth_create_path(hfp_data->device_address,
+ hfp_data->adapter_address, buf + 4, sizeof(buf) - 4);
modem = ofono_modem_create(buf, "hfp");
if (modem == NULL)
return -ENOMEM;
- data = g_try_new0(struct hfp_data, 1);
- if (data == NULL)
+ ofono_modem_set_data(modem, hfp_data);
+ ofono_modem_set_name(modem, hfp_data->device_alias);
+ ofono_modem_register(modem);
+
+ g_hash_table_insert(modem_hash, g_strdup(device), modem);
+
+ hfp_slc_info_init(&hfp_data->info, version);
+
+ return service_level_connection(modem, fd);
+}
+
+static int hfp_hf_probe(const char *device, const char *dev_addr,
+ const char *adapter_addr, const char *alias)
+{
+ struct hfp_data *hfp_data;
+
+ if (g_hash_table_lookup(hfp_hash, device) != NULL)
+ return -EALREADY;
+
+ ofono_info("Using device: %s, devaddr: %s, adapter: %s",
+ device, dev_addr, adapter_addr);
+
+ hfp_data = g_try_new0(struct hfp_data, 1);
+ if (hfp_data == NULL)
goto free;
- data->handsfree_address = g_strdup(dev_addr);
- if (data->handsfree_address == NULL)
+ hfp_data->adapter_address = g_strdup(adapter_addr);
+ if (hfp_data->adapter_address == NULL)
goto free;
- ofono_modem_set_data(modem, data);
- ofono_modem_set_name(modem, alias);
- ofono_modem_register(modem);
+ hfp_data->device_address = g_strdup(dev_addr);
+ if (hfp_data->device_address == NULL)
+ goto free;
- g_hash_table_insert(modem_hash, g_strdup(device), modem);
+ hfp_data->device_path = g_strdup(device);
+ if (hfp_data->device_path == NULL)
+ goto free;
+
+ hfp_data->device_alias = g_strdup(alias);
+ if (hfp_data->device_alias == NULL)
+ goto free;
+
+ g_hash_table_insert(hfp_hash, g_strdup(device), hfp_data);
return 0;
free:
- g_free(data);
- ofono_modem_remove(modem);
+ hfp_data_free(hfp_data);
return -ENOMEM;
}
@@ -240,12 +285,10 @@ static void hfp_hf_set_alias(const char *device, const char *alias)
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- struct ofono_modem *modem;
struct hfp_data *hfp_data;
const char *device;
DBusMessageIter entry;
int fd, err;
- guint16 version = 0x0105;
DBG("Profile handler NewConnection");
@@ -256,9 +299,9 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
goto error;
dbus_message_iter_get_basic(&entry, &device);
- modem = g_hash_table_lookup(modem_hash, device);
- if (modem == NULL) {
- DBG("%s: modem not found", device);
+ hfp_data = g_hash_table_lookup(hfp_hash, device);
+ if (hfp_data == NULL) {
+ DBG("%s: doesn't support HFP", device);
goto error;
}
@@ -270,12 +313,9 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
if (fd < 0)
goto error;
- hfp_data = ofono_modem_get_data(modem);
- DBG("modem %p, hfp_data: %p SLC FD: %d", modem, hfp_data, fd);
-
- hfp_slc_info_init(&hfp_data->info, version);
+ DBG("hfp_data: %p SLC FD: %d", hfp_data, fd);
- err = service_level_connection(modem, fd);
+ err = modem_register(device, hfp_data, fd);
if (err < 0 && err != -EINPROGRESS)
return __ofono_error_failed(msg);
@@ -337,14 +377,7 @@ static int hfp_probe(struct ofono_modem *modem)
static void hfp_remove(struct ofono_modem *modem)
{
- struct hfp_data *data = ofono_modem_get_data(modem);
-
DBG("modem: %p", modem);
-
- g_free(data->handsfree_address);
- g_free(data);
-
- ofono_modem_set_data(modem, NULL);
}
/* power up hardware */
@@ -378,7 +411,7 @@ static void hfp_pre_sim(struct ofono_modem *modem)
DBG("%p", modem);
- ofono_devinfo_create(modem, 0, "hfpmodem", data->handsfree_address);
+ ofono_devinfo_create(modem, 0, "hfpmodem", data->device_address);
ofono_voicecall_create(modem, 0, "hfpmodem", &data->info);
ofono_netreg_create(modem, 0, "hfpmodem", &data->info);
ofono_call_volume_create(modem, 0, "hfpmodem", &data->info);
@@ -452,6 +485,9 @@ static int hfp_init(void)
modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, NULL);
+ hfp_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+ hfp_data_free);
+
return 0;
}
@@ -464,6 +500,7 @@ static void hfp_exit(void)
ofono_modem_driver_unregister(&hfp_driver);
g_hash_table_destroy(modem_hash);
+ g_hash_table_destroy(hfp_hash);
}
OFONO_PLUGIN_DEFINE(hfp, "Hands-Free Profile Plugins", VERSION,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 08/15] hfp_hf: Fix updating alias
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (6 preceding siblings ...)
2012-11-26 13:27 ` [RFC v1 07/15] hfp_hf: Register HFP modem dynamically Claudio Takahasi
@ 2012-11-26 13:27 ` Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 09/15] bluetooth: Reuse D-Bus dictionary parser function Claudio Takahasi
` (7 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]
This patch fixes the Bluetooth device alias for the HFP when the modem
is not registered yet. Modem is being created with the first alias
informed when in the Bluetooth profile probe callback.
---
plugins/hfp_hf.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index b3ea13f..326f5d9 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -271,15 +271,20 @@ static void hfp_hf_remove(const char *prefix)
static void hfp_hf_set_alias(const char *device, const char *alias)
{
struct ofono_modem *modem;
+ struct hfp_data *hfp_data;
if (device == NULL || alias == NULL)
return;
- modem = g_hash_table_lookup(modem_hash, device);
- if (modem == NULL)
- return;
+ hfp_data = g_hash_table_lookup(hfp_hash, device);
+ if (hfp_data) {
+ g_free(hfp_data->device_alias);
+ hfp_data->device_alias = g_strdup(alias);
+ }
- ofono_modem_set_name(modem, alias);
+ modem = g_hash_table_lookup(modem_hash, device);
+ if (modem)
+ ofono_modem_set_name(modem, alias);
}
static DBusMessage *profile_new_connection(DBusConnection *conn,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 09/15] bluetooth: Reuse D-Bus dictionary parser function
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (7 preceding siblings ...)
2012-11-26 13:27 ` [RFC v1 08/15] hfp_hf: Fix updating alias Claudio Takahasi
@ 2012-11-26 13:27 ` Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 10/15] hfp_hf: Add Version and Features parsing Claudio Takahasi
` (6 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3565 bytes --]
This patch changes the Bluetooth D-Bus property parser function to allow
reusing on other messages. The dictionary can be placed on any position
of the message, the current implementation assumes that the first
message parameter should be a dictionary.
---
plugins/bluetooth.c | 27 ++++++++++++++++-----------
plugins/bluetooth.h | 3 ++-
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 201c851..37738e7 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -195,11 +195,14 @@ static gint property_handler_compare(gconstpointer a, gconstpointer b)
return strcmp(handler->property, property);
}
-void bluetooth_parse_properties(DBusMessage *reply, const char *property, ...)
+void bluetooth_parse_properties(DBusMessageIter *array, const char *property, ...)
{
va_list args;
GSList *prop_handlers = NULL;
- DBusMessageIter array, dict;
+ DBusMessageIter dict;
+
+ if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
+ goto done;
va_start(args, property);
@@ -218,13 +221,7 @@ void bluetooth_parse_properties(DBusMessage *reply, const char *property, ...)
va_end(args);
- if (dbus_message_iter_init(reply, &array) == FALSE)
- goto done;
-
- if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
- goto done;
-
- dbus_message_iter_recurse(&array, &dict);
+ dbus_message_iter_recurse(array, &dict);
while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
DBusMessageIter entry, value;
@@ -324,6 +321,7 @@ static void device_properties_cb(DBusPendingCall *call, gpointer user_data)
const char *adapter_addr = NULL;
const char *device_addr = NULL;
const char *alias = NULL;
+ DBusMessageIter iter;
struct DBusError derr;
GSList *uuids = NULL;
@@ -341,7 +339,10 @@ static void device_properties_cb(DBusPendingCall *call, gpointer user_data)
DBG("");
- bluetooth_parse_properties(reply, "UUIDs", parse_uuids, &uuids,
+ if (dbus_message_iter_init(reply, &iter) == FALSE)
+ goto done;
+
+ bluetooth_parse_properties(&iter, "UUIDs", parse_uuids, &uuids,
"Adapter", parse_string, &adapter,
"Address", parse_string, &device_addr,
"Alias", parse_string, &alias, NULL);
@@ -480,6 +481,7 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
{
const char *path = user_data;
DBusMessage *reply;
+ DBusMessageIter iter;
DBusError derr;
GSList *device_list = NULL;
GSList *l;
@@ -499,7 +501,10 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
DBG("");
- bluetooth_parse_properties(reply,
+ if (dbus_message_iter_init(reply, &iter) == FALSE)
+ goto done;
+
+ bluetooth_parse_properties(&iter,
"Devices", parse_devices, &device_list,
"Address", parse_string, &addr,
NULL);
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index a9355f6..5b4d9d4 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -84,7 +84,8 @@ int bluetooth_send_with_reply(const char *path, const char *interface,
DBusPendingCallNotifyFunction cb,
void *user_data, DBusFreeFunction free_func,
int timeout, int type, ...);
-void bluetooth_parse_properties(DBusMessage *reply, const char *property, ...);
+void bluetooth_parse_properties(DBusMessageIter *array,
+ const char *property, ...);
int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
struct ofono_modem *modem);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 10/15] hfp_hf: Add Version and Features parsing
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (8 preceding siblings ...)
2012-11-26 13:27 ` [RFC v1 09/15] bluetooth: Reuse D-Bus dictionary parser function Claudio Takahasi
@ 2012-11-26 13:27 ` Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 11/15] bluetooth: Use generic function to parse dict Claudio Takahasi
` (5 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2195 bytes --]
This patch adds parsing of the Version and Features properties of the
NewConnection fd_dictionary.
---
plugins/hfp_hf.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 326f5d9..70005f0 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -79,6 +79,16 @@ static void hfp_data_free(gpointer user_data)
g_free(hfp_data);
}
+static void parse_guint16(DBusMessageIter *iter, gpointer user_data)
+{
+ guint16 *value = user_data;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16)
+ return;
+
+ dbus_message_iter_get_basic(iter, value);
+}
+
static void hfp_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
@@ -172,11 +182,11 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
return -EINPROGRESS;
}
-static int modem_register(const char *device, struct hfp_data *hfp_data, int fd)
+static int modem_register(const char *device, struct hfp_data *hfp_data,
+ int fd, guint16 version)
{
struct ofono_modem *modem;
char buf[256];
- guint16 version = 0x0105;
/* We already have this device in our hash, ignore */
if (g_hash_table_lookup(modem_hash, device) != NULL)
@@ -294,6 +304,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
const char *device;
DBusMessageIter entry;
int fd, err;
+ guint16 version = 0x0105, features = 0x0000;
DBG("Profile handler NewConnection");
@@ -318,9 +329,17 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
if (fd < 0)
goto error;
- DBG("hfp_data: %p SLC FD: %d", hfp_data, fd);
+ dbus_message_iter_next(&entry);
+
+ bluetooth_parse_properties(&entry,
+ "Version", parse_guint16, &version,
+ "Features", parse_guint16, &features,
+ NULL);
+
+ DBG("hfp_data: %p SLC FD: %d Version: 0x%04x Features: 0x%04x",
+ hfp_data, fd, version, features);
- err = modem_register(device, hfp_data, fd);
+ err = modem_register(device, hfp_data, fd, version);
if (err < 0 && err != -EINPROGRESS)
return __ofono_error_failed(msg);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 11/15] bluetooth: Use generic function to parse dict
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (9 preceding siblings ...)
2012-11-26 13:27 ` [RFC v1 10/15] hfp_hf: Add Version and Features parsing Claudio Takahasi
@ 2012-11-26 13:27 ` Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 12/15] hfp_hf: Request secure connections Claudio Takahasi
` (4 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3219 bytes --]
This patch changes the Device PropertiesChanged signal parser to use
the generic utility function to decode dictionary entries.
---
plugins/bluetooth.c | 81 ++++++++++++++++++-----------------------------------
1 file changed, 27 insertions(+), 54 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 37738e7..a3dccee 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -401,8 +401,9 @@ static void get_device_properties(const char *path)
static gboolean properties_changed(DBusConnection *conn, DBusMessage *msg,
void *user_data)
{
- const char *property, *interface;
- DBusMessageIter iter, dict, entry, variant;
+ const char *interface, *path, *alias = NULL;
+ DBusMessageIter iter;
+ GSList *uuids = NULL;
DBG("");
@@ -420,59 +421,31 @@ static gboolean properties_changed(DBusConnection *conn, DBusMessage *msg,
if (!dbus_message_iter_next(&iter))
return FALSE;
- /* Reading Dict entries containing properties */
- dbus_message_iter_recurse(&iter, &dict);
-
- do {
- if (dbus_message_iter_get_arg_type(&dict) !=
- DBUS_TYPE_DICT_ENTRY)
- return FALSE;
-
- dbus_message_iter_recurse(&dict, &entry);
-
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
- return FALSE;
-
- dbus_message_iter_get_basic(&entry, &property);
-
- if (!dbus_message_iter_next(&entry))
- return FALSE;
-
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
- return FALSE;
-
- dbus_message_iter_recurse(&entry, &variant);
- if (g_str_equal(property, "UUIDs") == TRUE) {
- GSList *uuids = NULL;
- const char *path = dbus_message_get_path(msg);
-
- parse_uuids(&variant, &uuids);
-
- /* We need the full set of properties to be able to
- * create the modem properly, including Adapter and
- * Alias, so refetch everything again
- */
- if (uuids)
- get_device_properties(path);
- } else if (g_str_equal(property, "Alias") == TRUE) {
- const char *path = dbus_message_get_path(msg);
- struct bluetooth_profile *profile;
- const char *alias = NULL;
- GHashTableIter hash_iter;
- gpointer key, value;
-
- parse_string(&variant, &alias);
-
- g_hash_table_iter_init(&hash_iter, uuid_hash);
- while (g_hash_table_iter_next(&hash_iter, &key,
- &value)) {
- profile = value;
- if (profile->set_alias)
- profile->set_alias(path, alias);
- }
+ bluetooth_parse_properties(&iter,
+ "UUIDs", parse_uuids, &uuids,
+ "Alias", parse_string, &alias,
+ NULL);
+
+ path = dbus_message_get_path(msg);
+
+ /* We need the full set of properties to be able to
+ * create the modem properly, including Adapter and
+ * Alias, so refetch everything again
+ */
+ if (uuids)
+ get_device_properties(path);
+
+ if (alias) {
+ GHashTableIter hash_iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init(&hash_iter, uuid_hash);
+ while (g_hash_table_iter_next(&hash_iter, &key, &value)) {
+ struct bluetooth_profile *profile = value;
+ if (profile->set_alias)
+ profile->set_alias(path, alias);
}
-
- } while (dbus_message_iter_next(&dict));
+ }
return TRUE;
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 12/15] hfp_hf: Request secure connections
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (10 preceding siblings ...)
2012-11-26 13:27 ` [RFC v1 11/15] bluetooth: Use generic function to parse dict Claudio Takahasi
@ 2012-11-26 13:27 ` Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 13/15] bluetooth: Fix memory leak of adapter_any_path Claudio Takahasi
` (3 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2289 bytes --]
This patch changes the HFP external profile registration requesting
authentication and authorization for new connections.
---
plugins/bluetooth.c | 9 ++++++++-
plugins/bluetooth.h | 2 +-
plugins/hfp_hf.c | 2 +-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index a3dccee..3b11b63 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -1002,7 +1002,7 @@ done:
}
int bluetooth_register_profile(const char *uuid, const char *name,
- const char *object)
+ const char *object, gboolean secure)
{
DBusMessageIter iter, dict;
DBusPendingCall *c;
@@ -1019,6 +1019,13 @@ int bluetooth_register_profile(const char *uuid, const char *name,
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict);
dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
+ if (secure) {
+ dict_append_entry(&dict, "RequireAuthentication",
+ DBUS_TYPE_BOOLEAN, &secure);
+ dict_append_entry(&dict, "RequireAuthorization",
+ DBUS_TYPE_BOOLEAN, &secure);
+ }
+
dbus_message_iter_close_container(&iter, &dict);
if (!dbus_connection_send_with_reply(connection, msg, &c, -1)) {
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 5b4d9d4..a3937ac 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -70,7 +70,7 @@ int bluetooth_register_uuid(const char *uuid,
struct bluetooth_profile *profile);
void bluetooth_unregister_uuid(const char *uuid);
int bluetooth_register_profile(const char *uuid, const char *name,
- const char *object);
+ const char *object, gboolean secure);
void bluetooth_unregister_profile(const char *object);
struct server *bluetooth_register_server(guint8 channel, const char *sdp_record,
ConnectFunc cb, gpointer user_data);
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 70005f0..22514da 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -497,7 +497,7 @@ static int hfp_init(void)
}
err = bluetooth_register_profile(HFP_HS_UUID, "hfp_hf",
- HFP_EXT_PROFILE_PATH);
+ HFP_EXT_PROFILE_PATH, TRUE);
if (err < 0) {
g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
BLUEZ_PROFILE_INTERFACE);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 13/15] bluetooth: Fix memory leak of adapter_any_path
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (11 preceding siblings ...)
2012-11-26 13:27 ` [RFC v1 12/15] hfp_hf: Request secure connections Claudio Takahasi
@ 2012-11-26 13:27 ` Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 14/15] hfp_hf: Handle connections before probe Claudio Takahasi
` (2 subsequent siblings)
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]
This patch fixes a memory leak when BlueZ service re-connects to the
system Bus and oFono calls FindAdapter method.
---
plugins/bluetooth.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 3b11b63..92e11f0 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -45,7 +45,7 @@ static GHashTable *adapter_address_hash = NULL;
static gint bluetooth_refcount;
static GSList *server_list = NULL;
static const char *adapter_any_name = "any";
-static char *adapter_any_path;
+static char *adapter_any_path = NULL;
#define TIMEOUT 60 /* Timeout for user response (seconds) */
@@ -733,6 +733,7 @@ static void find_adapter_cb(DBusPendingCall *call, gpointer user_data)
dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID);
+ g_free(adapter_any_path);
adapter_any_path = g_strdup(path);
g_slist_foreach(server_list, (GFunc) add_record, NULL);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 14/15] hfp_hf: Handle connections before probe
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (12 preceding siblings ...)
2012-11-26 13:27 ` [RFC v1 13/15] bluetooth: Fix memory leak of adapter_any_path Claudio Takahasi
@ 2012-11-26 13:27 ` Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 15/15] bluetooth: Fix memory leak of UUIDs list Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5373 bytes --]
This patch allows oFono HFP plugin to handle HFP connections before
the Bluetooth device creation procedure finishes.
---
plugins/bluetooth.c | 26 +++++++++++++++++
plugins/bluetooth.h | 2 ++
plugins/hfp_hf.c | 84 +++++++++++++++++++++++++++++++++++------------------
3 files changed, 83 insertions(+), 29 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 92e11f0..3e63a3d 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -31,6 +31,8 @@
#include <unistd.h>
#include <glib.h>
#include <gdbus.h>
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/rfcomm.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
@@ -1148,5 +1150,29 @@ void bluetooth_unregister_server(struct server *server)
bluetooth_unref();
}
+int bluetooth_get_address(int fd, char *adapter_address, char *device_address)
+{
+ struct sockaddr_rc saddr;
+ socklen_t alen;
+
+ alen = sizeof(saddr);
+
+ if (adapter_address) {
+ if (getsockname(fd, (struct sockaddr *)&saddr, &alen) < 0)
+ return -errno;
+
+ ba2str(&saddr.rc_bdaddr, adapter_address);
+ }
+
+ if (device_address) {
+ if (getpeername(fd, (struct sockaddr *)&saddr, &alen) < 0)
+ return -errno;
+
+ ba2str(&saddr.rc_bdaddr, device_address);
+ }
+
+ return 0;
+}
+
OFONO_PLUGIN_DEFINE(bluetooth, "Bluetooth Utils Plugins", VERSION,
OFONO_PLUGIN_PRIORITY_DEFAULT, NULL, NULL)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index a3937ac..10db23d 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -90,3 +90,5 @@ void bluetooth_parse_properties(DBusMessageIter *array,
int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
struct ofono_modem *modem);
void bluetooth_sap_client_unregister(struct ofono_modem *modem);
+
+int bluetooth_get_address(int fd, char *adapter_address, char *device_address);
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 22514da..9c07a1d 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -79,6 +79,40 @@ static void hfp_data_free(gpointer user_data)
g_free(hfp_data);
}
+static struct hfp_data *hfp_data_new(const gchar *adapter_addr,
+ const gchar *device_addr,
+ const gchar *device_path,
+ const gchar *alias)
+{
+ struct hfp_data *hfp_data;
+
+ hfp_data = g_try_new0(struct hfp_data, 1);
+ if (hfp_data == NULL)
+ return NULL;
+
+ hfp_data->adapter_address = g_strdup(adapter_addr);
+ if (hfp_data->adapter_address == NULL)
+ goto free;
+
+ hfp_data->device_address = g_strdup(device_addr);
+ if (hfp_data->device_address == NULL)
+ goto free;
+
+ hfp_data->device_path = g_strdup(device_path);
+ if (hfp_data->device_path == NULL)
+ goto free;
+
+ hfp_data->device_alias = g_strdup(alias);
+ if (hfp_data->device_alias == NULL)
+ goto free;
+
+ return hfp_data;
+
+free:
+ hfp_data_free(hfp_data);
+ return NULL;
+}
+
static void parse_guint16(DBusMessageIter *iter, gpointer user_data)
{
guint16 *value = user_data;
@@ -222,34 +256,13 @@ static int hfp_hf_probe(const char *device, const char *dev_addr,
ofono_info("Using device: %s, devaddr: %s, adapter: %s",
device, dev_addr, adapter_addr);
- hfp_data = g_try_new0(struct hfp_data, 1);
+ hfp_data = hfp_data_new(adapter_addr, dev_addr, device, alias);
if (hfp_data == NULL)
- goto free;
-
- hfp_data->adapter_address = g_strdup(adapter_addr);
- if (hfp_data->adapter_address == NULL)
- goto free;
-
- hfp_data->device_address = g_strdup(dev_addr);
- if (hfp_data->device_address == NULL)
- goto free;
-
- hfp_data->device_path = g_strdup(device);
- if (hfp_data->device_path == NULL)
- goto free;
-
- hfp_data->device_alias = g_strdup(alias);
- if (hfp_data->device_alias == NULL)
- goto free;
+ return -ENOMEM;
g_hash_table_insert(hfp_hash, g_strdup(device), hfp_data);
return 0;
-
-free:
- hfp_data_free(hfp_data);
-
- return -ENOMEM;
}
static gboolean hfp_remove_modem(gpointer key, gpointer value,
@@ -315,12 +328,6 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
goto error;
dbus_message_iter_get_basic(&entry, &device);
- hfp_data = g_hash_table_lookup(hfp_hash, device);
- if (hfp_data == NULL) {
- DBG("%s: doesn't support HFP", device);
- goto error;
- }
-
dbus_message_iter_next(&entry);
if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_UNIX_FD)
goto error;
@@ -336,6 +343,25 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
"Features", parse_guint16, &features,
NULL);
+ hfp_data = g_hash_table_lookup(hfp_hash, device);
+ if (hfp_data == NULL) {
+ char adapter_address[18], device_address[18];
+
+ /*
+ * Incoming connection notification can arrive before
+ * the Bluetooth device creation finishes.
+ */
+ if (bluetooth_get_address(fd, adapter_address,
+ device_address) < 0)
+ return g_dbus_create_error(msg,
+ BLUEZ_ERROR_INTERFACE ".Rejected",
+ "Invalid arguments in method call");
+
+ hfp_data = hfp_data_new(adapter_address, device_address,
+ device, device_address);
+ g_hash_table_insert(hfp_hash, g_strdup(device), hfp_data);
+ }
+
DBG("hfp_data: %p SLC FD: %d Version: 0x%04x Features: 0x%04x",
hfp_data, fd, version, features);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [RFC v1 15/15] bluetooth: Fix memory leak of UUIDs list
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (13 preceding siblings ...)
2012-11-26 13:27 ` [RFC v1 14/15] hfp_hf: Handle connections before probe Claudio Takahasi
@ 2012-11-26 13:27 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
15 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-11-26 13:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 587 bytes --]
---
plugins/bluetooth.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 3e63a3d..4dee100 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -434,8 +434,10 @@ static gboolean properties_changed(DBusConnection *conn, DBusMessage *msg,
* create the modem properly, including Adapter and
* Alias, so refetch everything again
*/
- if (uuids)
+ if (uuids) {
get_device_properties(path);
+ g_slist_free(uuids);
+ }
if (alias) {
GHashTableIter hash_iter;
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 00/14] External HFP Profile
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
` (14 preceding siblings ...)
2012-11-26 13:27 ` [RFC v1 15/15] bluetooth: Fix memory leak of UUIDs list Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 01/14] hfp_hf: Add HFP external Profile registration Claudio Takahasi
` (14 more replies)
15 siblings, 15 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1661 bytes --]
BlueZ supports now external profile registration, see:
bluez/doc/profile-api.txt
This patch series has the initial implementation of the HFP external
profile in oFono. HandsfreeAgent and HandsfreeGateway interfaces were
removed from BlueZ.
Modem are being registered dinamically when the new connection is
notified instead of registering the modem when the Bluetooth device
is created/probed.
* Needs to be applied after "[PATCH v0 1/4] bluetooth: Fix reading
Bluetooth Adapters" series
Changes from RFC v1:
- Remove optional RequireAuthorization & RequireAuthentication to
Register HFP profile.
Next actions:
- Implement MediaTransport
- MediaEndpoint set configuration
Development branch:
git://git.infradead.org/users/cktakahasi/ofono.git hfp
Claudio Takahasi (14):
hfp_hf: Add HFP external Profile registration
hfp_hf: Add BlueZ Profile handler
hfp_hf: Add parsing of Profile NewConnection call
hfp_hf: Add SLC setup
hfp_hf: Add Profile1 Release
hfp_hf: Remove HandsfreeAgent and HandsfreeGateway
hfp_hf: Register HFP modem dynamically
hfp_hf: Fix updating alias
bluetooth: Reuse D-Bus dictionary parser function
hfp_hf: Add Version and Features parsing
bluetooth: Use generic function to parse dict
bluetooth: Fix memory leak of adapter_any_path
hfp_hf: Handle connections before probe
bluetooth: Fix memory leak of UUIDs list
plugins/bluetooth.c | 268 +++++++++++++++++++++++--------
plugins/bluetooth.h | 12 +-
plugins/hfp_hf.c | 451 +++++++++++++++++++++++++++-------------------------
3 files changed, 446 insertions(+), 285 deletions(-)
--
1.7.11.7
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH v0 01/14] hfp_hf: Add HFP external Profile registration
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 02/14] hfp_hf: Add BlueZ Profile handler Claudio Takahasi
` (13 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6579 bytes --]
This patch adds the functions to allow registering and unregistering HFP
external profile using BlueZ ProfileManager1 interface.
---
plugins/bluetooth.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++
plugins/bluetooth.h | 5 +-
plugins/hfp_hf.c | 12 +++++
3 files changed, 153 insertions(+), 1 deletion(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 09c9870..201c851 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -65,6 +65,39 @@ struct cb_data {
GIOChannel *io;
};
+static void append_variant(DBusMessageIter *iter, int type, void *val)
+{
+ DBusMessageIter value;
+ char sig[2] = { type, '\0' };
+
+ dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, sig, &value);
+
+ dbus_message_iter_append_basic(&value, type, val);
+
+ dbus_message_iter_close_container(iter, &value);
+}
+
+static void dict_append_entry(DBusMessageIter *dict, const char *key, int type,
+ void *val)
+{
+ DBusMessageIter entry;
+
+ if (type == DBUS_TYPE_STRING) {
+ const char *str = *((const char **) val);
+ if (str == NULL)
+ return;
+ }
+
+ dbus_message_iter_open_container(dict, DBUS_TYPE_DICT_ENTRY, NULL,
+ &entry);
+
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+
+ append_variant(&entry, type, val);
+
+ dbus_message_iter_close_container(dict, &entry);
+}
+
void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
char *buf, int size)
{
@@ -968,6 +1001,110 @@ void bluetooth_unregister_uuid(const char *uuid)
bluetooth_unref();
}
+static void register_profile_cb(DBusPendingCall *call, gpointer user_data)
+{
+ DBusMessage *reply;
+ DBusError derr;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&derr);
+
+ if (dbus_set_error_from_message(&derr, reply)) {
+ ofono_error("RegisterProfile() replied an error: %s, %s",
+ derr.name, derr.message);
+ dbus_error_free(&derr);
+ goto done;
+ }
+
+ DBG("");
+
+done:
+ dbus_message_unref(reply);
+}
+
+int bluetooth_register_profile(const char *uuid, const char *name,
+ const char *object)
+{
+ DBusMessageIter iter, dict;
+ DBusPendingCall *c;
+ DBusMessage *msg;
+
+ DBG("Bluetooth: Registering %s (%s) profile", uuid, name);
+
+ msg = dbus_message_new_method_call(BLUEZ_SERVICE, "/org/bluez",
+ BLUEZ_PROFILE_MGMT_INTERFACE, "RegisterProfile");
+
+ dbus_message_iter_init_append(msg, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &object);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &uuid);
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &dict);
+ dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
+ dbus_message_iter_close_container(&iter, &dict);
+
+ if (!dbus_connection_send_with_reply(connection, msg, &c, -1)) {
+ ofono_error("Sending RegisterProfile failed");
+ dbus_message_unref(msg);
+ return -EIO;
+ }
+
+ dbus_pending_call_set_notify(c, register_profile_cb, NULL, NULL);
+ dbus_pending_call_unref(c);
+
+ dbus_message_unref(msg);
+
+ return 0;
+}
+
+static void unregister_profile_cb(DBusPendingCall *call, gpointer user_data)
+{
+ DBusMessage *reply;
+ DBusError derr;
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ dbus_error_init(&derr);
+
+ if (dbus_set_error_from_message(&derr, reply)) {
+ ofono_error("UnregisterProfile() replied an error: %s, %s",
+ derr.name, derr.message);
+ dbus_error_free(&derr);
+ goto done;
+ }
+
+ DBG("");
+
+done:
+ dbus_message_unref(reply);
+}
+
+void bluetooth_unregister_profile(const char *object)
+{
+ DBusMessageIter iter;
+ DBusPendingCall *c;
+ DBusMessage *msg;
+
+ DBG("Bluetooth: Unregistering profile %s", object);
+
+ msg = dbus_message_new_method_call(BLUEZ_SERVICE, "/org/bluez",
+ BLUEZ_PROFILE_MGMT_INTERFACE, "UnregisterProfile");
+
+ dbus_message_iter_init_append(msg, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &object);
+
+ if (!dbus_connection_send_with_reply(connection, msg, &c, -1)) {
+ ofono_error("Sending RegisterProfile failed");
+ dbus_message_unref(msg);
+ return;
+ }
+
+ dbus_pending_call_set_notify(c, unregister_profile_cb, NULL, NULL);
+ dbus_pending_call_unref(c);
+
+ dbus_message_unref(msg);
+}
+
struct server *bluetooth_register_server(guint8 channel, const char *sdp_record,
ConnectFunc cb, gpointer user_data)
{
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index af59d3d..ffaf9e3 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -24,6 +24,7 @@
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
+#define BLUEZ_PROFILE_MGMT_INTERFACE BLUEZ_SERVICE ".ProfileManager1"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
#define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device"
#define BLUEZ_SERVICE_INTERFACE BLUEZ_SERVICE ".Service"
@@ -66,7 +67,9 @@ void bluetooth_get_properties();
int bluetooth_register_uuid(const char *uuid,
struct bluetooth_profile *profile);
void bluetooth_unregister_uuid(const char *uuid);
-
+int bluetooth_register_profile(const char *uuid, const char *name,
+ const char *object);
+void bluetooth_unregister_profile(const char *object);
struct server *bluetooth_register_server(guint8 channel, const char *sdp_record,
ConnectFunc cb, gpointer user_data);
void bluetooth_unregister_server(struct server *server);
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 7c500e3..1e0064c 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -54,6 +54,8 @@
#define HFP_AGENT_INTERFACE "org.bluez.HandsfreeAgent"
#define HFP_AGENT_ERROR_INTERFACE "org.bluez.Error"
+#define HFP_EXT_PROFILE_PATH "/bluetooth/profile/hfp_hf"
+
#ifndef DBUS_TYPE_UNIX_FD
#define DBUS_TYPE_UNIX_FD -1
#endif
@@ -534,6 +536,14 @@ static int hfp_init(void)
return err;
}
+ err = bluetooth_register_profile(HFP_HS_UUID, "hfp_hf",
+ HFP_EXT_PROFILE_PATH);
+ if (err < 0) {
+ bluetooth_unregister_uuid(HFP_AG_UUID);
+ ofono_modem_driver_unregister(&hfp_driver);
+ return err;
+ }
+
modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, NULL);
@@ -542,6 +552,8 @@ static int hfp_init(void)
static void hfp_exit(void)
{
+
+ bluetooth_unregister_profile(HFP_EXT_PROFILE_PATH);
bluetooth_unregister_uuid(HFP_AG_UUID);
ofono_modem_driver_unregister(&hfp_driver);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 02/14] hfp_hf: Add BlueZ Profile handler
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 01/14] hfp_hf: Add HFP external Profile registration Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 03/14] hfp_hf: Add parsing of Profile NewConnection call Claudio Takahasi
` (12 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4351 bytes --]
This patch declares the external HFP Profile handler. It contains the
initial implementation of the D-Bus Profile1 interface and methods
responsible for handling Bluetooth connections.
---
plugins/bluetooth.h | 2 ++
plugins/hfp_hf.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index ffaf9e3..a9355f6 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -24,7 +24,9 @@
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
+#define BLUEZ_ERROR_INTERFACE BLUEZ_SERVICE ".Error"
#define BLUEZ_PROFILE_MGMT_INTERFACE BLUEZ_SERVICE ".ProfileManager1"
+#define BLUEZ_PROFILE_INTERFACE BLUEZ_SERVICE ".Profile1"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
#define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device"
#define BLUEZ_SERVICE_INTERFACE BLUEZ_SERVICE ".Service"
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 1e0064c..6836c45 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -339,6 +339,55 @@ static int hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
return 0;
}
+static DBusMessage *profile_new_connection(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler NewConnection");
+ return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
+ ".NotImplemented",
+ "Implementation not provided");
+}
+
+static DBusMessage *profile_release(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler Release");
+ return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
+ ".NotImplemented",
+ "Implementation not provided");
+}
+
+static DBusMessage *profile_cancel(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler Cancel");
+ return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
+ ".NotImplemented",
+ "Implementation not provided");
+}
+
+static DBusMessage *profile_disconnection(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ DBG("Profile handler RequestDisconnection");
+ return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
+ ".NotImplemented",
+ "Implementation not provided");
+}
+
+static const GDBusMethodTable profile_methods[] = {
+ { GDBUS_ASYNC_METHOD("NewConnection",
+ GDBUS_ARGS({ "device", "o"}, { "fd", "h"},
+ { "fd_properties", "a{sv}" }),
+ NULL, profile_new_connection) },
+ { GDBUS_METHOD("Release", NULL, NULL, profile_release) },
+ { GDBUS_METHOD("Cancel", NULL, NULL, profile_cancel) },
+ { GDBUS_METHOD("RequestDisconnection",
+ GDBUS_ARGS({"device", "o"}), NULL,
+ profile_disconnection) },
+ { }
+};
+
static int hfp_probe(struct ofono_modem *modem)
{
const char *obj_path = ofono_modem_get_path(modem);
@@ -526,12 +575,24 @@ static int hfp_init(void)
connection = ofono_dbus_get_connection();
+ /* Registers External Profile handler */
+ if (!g_dbus_register_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE,
+ profile_methods, NULL,
+ NULL, NULL, NULL)) {
+ ofono_error("Register Profile interface failed: %s",
+ HFP_EXT_PROFILE_PATH);
+ return -EIO;
+ }
+
err = ofono_modem_driver_register(&hfp_driver);
if (err < 0)
return err;
err = bluetooth_register_uuid(HFP_AG_UUID, &hfp_hf);
if (err < 0) {
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
ofono_modem_driver_unregister(&hfp_driver);
return err;
}
@@ -539,6 +600,8 @@ static int hfp_init(void)
err = bluetooth_register_profile(HFP_HS_UUID, "hfp_hf",
HFP_EXT_PROFILE_PATH);
if (err < 0) {
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
bluetooth_unregister_uuid(HFP_AG_UUID);
ofono_modem_driver_unregister(&hfp_driver);
return err;
@@ -552,7 +615,8 @@ static int hfp_init(void)
static void hfp_exit(void)
{
-
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
bluetooth_unregister_profile(HFP_EXT_PROFILE_PATH);
bluetooth_unregister_uuid(HFP_AG_UUID);
ofono_modem_driver_unregister(&hfp_driver);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 03/14] hfp_hf: Add parsing of Profile NewConnection call
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 01/14] hfp_hf: Add HFP external Profile registration Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 02/14] hfp_hf: Add BlueZ Profile handler Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 04/14] hfp_hf: Add SLC setup Claudio Takahasi
` (11 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1685 bytes --]
This patch adds the parsing of the mandatory arguments in NewConnection
method call implemented in Profile1 interface.
---
plugins/hfp_hf.c | 37 ++++++++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 6836c45..03f3371 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -342,10 +342,41 @@ static int hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct ofono_modem *modem;
+ const char *device;
+ DBusMessageIter entry;
+ int fd;
+
DBG("Profile handler NewConnection");
- return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
- ".NotImplemented",
- "Implementation not provided");
+
+ if (dbus_message_iter_init(msg, &entry) == FALSE)
+ goto error;
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_OBJECT_PATH)
+ goto error;
+
+ dbus_message_iter_get_basic(&entry, &device);
+ modem = g_hash_table_lookup(modem_hash, device);
+ if (modem == NULL) {
+ DBG("%s: modem not found", device);
+ goto error;
+ }
+
+ dbus_message_iter_next(&entry);
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_UNIX_FD)
+ goto error;
+
+ dbus_message_iter_get_basic(&entry, &fd);
+ if (fd < 0)
+ goto error;
+
+ DBG("modem %p, SLC FD: %d", modem, fd);
+
+ return dbus_message_new_method_return(msg);
+
+error:
+ return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
+ "Invalid arguments in method call");
}
static DBusMessage *profile_release(DBusConnection *conn,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 04/14] hfp_hf: Add SLC setup
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (2 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 03/14] hfp_hf: Add parsing of Profile NewConnection call Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 05/14] hfp_hf: Add Profile1 Release Claudio Takahasi
` (10 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1796 bytes --]
This patch adds the SLC setup when the NewConnection is notified.
---
plugins/hfp_hf.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 03f3371..644067c 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -101,9 +101,10 @@ static void slc_failed(gpointer userdata)
struct hfp_data *data = ofono_modem_get_data(modem);
DBusMessage *msg;
- msg = g_dbus_create_error(data->slc_msg, HFP_AGENT_ERROR_INTERFACE
- ".Failed",
- "HFP Handshake failed");
+ msg = g_dbus_create_error(data->slc_msg, BLUEZ_ERROR_INTERFACE
+ ".Failed",
+ "HFP Handshake failed");
+
g_dbus_send_message(connection, msg);
dbus_message_unref(data->slc_msg);
data->slc_msg = NULL;
@@ -343,9 +344,11 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct ofono_modem *modem;
+ struct hfp_data *hfp_data;
const char *device;
DBusMessageIter entry;
- int fd;
+ int fd, err;
+ guint16 version = 0x0105;
DBG("Profile handler NewConnection");
@@ -370,9 +373,18 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
if (fd < 0)
goto error;
- DBG("modem %p, SLC FD: %d", modem, fd);
+ hfp_data = ofono_modem_get_data(modem);
+ DBG("modem %p, hfp_data: %p SLC FD: %d", modem, hfp_data, fd);
- return dbus_message_new_method_return(msg);
+ hfp_slc_info_init(&hfp_data->info, version);
+
+ err = service_level_connection(modem, fd);
+ if (err < 0 && err != -EINPROGRESS)
+ return __ofono_error_failed(msg);
+
+ hfp_data->slc_msg = dbus_message_ref(msg);
+
+ return NULL;
error:
return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 05/14] hfp_hf: Add Profile1 Release
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (3 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 04/14] hfp_hf: Add SLC setup Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 06/14] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway Claudio Takahasi
` (9 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 942 bytes --]
This patch adds the Release method of the external Profile handler.
Release method gets called when BlueZ unregisters the HFP profile.
---
plugins/hfp_hf.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 644067c..dd09142 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -395,9 +395,13 @@ static DBusMessage *profile_release(DBusConnection *conn,
DBusMessage *msg, void *data)
{
DBG("Profile handler Release");
- return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
- ".NotImplemented",
- "Implementation not provided");
+
+ g_dbus_unregister_interface(connection, HFP_EXT_PROFILE_PATH,
+ BLUEZ_PROFILE_INTERFACE);
+
+ g_hash_table_foreach_remove(modem_hash, hfp_remove_modem, NULL);
+
+ return dbus_message_new_method_return(msg);
}
static DBusMessage *profile_cancel(DBusConnection *conn,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 06/14] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (4 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 05/14] hfp_hf: Add Profile1 Release Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 07/14] hfp_hf: Register HFP modem dynamically Claudio Takahasi
` (8 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 8610 bytes --]
This patch removes the deprecated HandsfreeAgent and HandsfreeGateway
interfaces. New connections are now being managed by a BlueZ external
Profile handler.
---
plugins/hfp_hf.c | 215 ++-----------------------------------------------------
1 file changed, 7 insertions(+), 208 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index dd09142..d91c197 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -49,11 +49,6 @@
#include "bluetooth.h"
-#define BLUEZ_GATEWAY_INTERFACE BLUEZ_SERVICE ".HandsfreeGateway"
-
-#define HFP_AGENT_INTERFACE "org.bluez.HandsfreeAgent"
-#define HFP_AGENT_ERROR_INTERFACE "org.bluez.Error"
-
#define HFP_EXT_PROFILE_PATH "/bluetooth/profile/hfp_hf"
#ifndef DBUS_TYPE_UNIX_FD
@@ -65,11 +60,8 @@ static GHashTable *modem_hash = NULL;
struct hfp_data {
struct hfp_slc_info info;
- char *handsfree_path;
char *handsfree_address;
DBusMessage *slc_msg;
- gboolean agent_registered;
- DBusPendingCall *call;
};
static void hfp_debug(const char *str, void *user_data)
@@ -161,54 +153,6 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
return -EINPROGRESS;
}
-static DBusMessage *hfp_agent_new_connection(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- int fd, err;
- struct ofono_modem *modem = data;
- struct hfp_data *hfp_data = ofono_modem_get_data(modem);
- guint16 version;
-
- if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UNIX_FD, &fd,
- DBUS_TYPE_UINT16, &version, DBUS_TYPE_INVALID))
- return __ofono_error_invalid_args(msg);
-
- hfp_slc_info_init(&hfp_data->info, version);
-
- err = service_level_connection(modem, fd);
- if (err < 0 && err != -EINPROGRESS)
- return __ofono_error_failed(msg);
-
- hfp_data->slc_msg = msg;
- dbus_message_ref(msg);
-
- return NULL;
-}
-
-static DBusMessage *hfp_agent_release(DBusConnection *conn,
- DBusMessage *msg, void *data)
-{
- struct ofono_modem *modem = data;
- struct hfp_data *hfp_data = ofono_modem_get_data(modem);
- const char *obj_path = ofono_modem_get_path(modem);
-
- g_dbus_unregister_interface(connection, obj_path, HFP_AGENT_INTERFACE);
- hfp_data->agent_registered = FALSE;
-
- g_hash_table_remove(modem_hash, hfp_data->handsfree_path);
- ofono_modem_remove(modem);
-
- return dbus_message_new_method_return(msg);
-}
-
-static const GDBusMethodTable agent_methods[] = {
- { GDBUS_ASYNC_METHOD("NewConnection",
- GDBUS_ARGS({ "fd", "h" }, { "version", "q" }),
- NULL, hfp_agent_new_connection) },
- { GDBUS_METHOD("Release", NULL, NULL, hfp_agent_release) },
- { }
-};
-
static int hfp_hf_probe(const char *device, const char *dev_addr,
const char *adapter_addr, const char *alias)
{
@@ -234,10 +178,6 @@ static int hfp_hf_probe(const char *device, const char *dev_addr,
if (data == NULL)
goto free;
- data->handsfree_path = g_strdup(device);
- if (data->handsfree_path == NULL)
- goto free;
-
data->handsfree_address = g_strdup(dev_addr);
if (data->handsfree_address == NULL)
goto free;
@@ -251,9 +191,6 @@ static int hfp_hf_probe(const char *device, const char *dev_addr,
return 0;
free:
- if (data != NULL)
- g_free(data->handsfree_path);
-
g_free(data);
ofono_modem_remove(modem);
@@ -300,46 +237,6 @@ static void hfp_hf_set_alias(const char *device, const char *alias)
ofono_modem_set_name(modem, alias);
}
-static int hfp_register_ofono_handsfree(struct ofono_modem *modem)
-{
- const char *obj_path = ofono_modem_get_path(modem);
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusMessage *msg;
-
- DBG("Registering oFono Agent to bluetooth daemon");
-
- msg = dbus_message_new_method_call(BLUEZ_SERVICE, data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "RegisterAgent");
- if (msg == NULL)
- return -ENOMEM;
-
- dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &obj_path,
- DBUS_TYPE_INVALID);
-
- g_dbus_send_message(connection, msg);
- return 0;
-}
-
-static int hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
-{
- const char *obj_path = ofono_modem_get_path(modem);
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusMessage *msg;
-
- DBG("Unregistering oFono Agent from bluetooth daemon");
-
- msg = dbus_message_new_method_call(BLUEZ_SERVICE, data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "UnregisterAgent");
- if (msg == NULL)
- return -ENOMEM;
-
- dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &obj_path,
- DBUS_TYPE_INVALID);
-
- g_dbus_send_message(connection, msg);
- return 0;
-}
-
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
@@ -437,19 +334,7 @@ static const GDBusMethodTable profile_methods[] = {
static int hfp_probe(struct ofono_modem *modem)
{
- const char *obj_path = ofono_modem_get_path(modem);
- struct hfp_data *data = ofono_modem_get_data(modem);
-
- if (data == NULL)
- return -EINVAL;
-
- g_dbus_register_interface(connection, obj_path, HFP_AGENT_INTERFACE,
- agent_methods, NULL, NULL, modem, NULL);
-
- data->agent_registered = TRUE;
-
- if (hfp_register_ofono_handsfree(modem) != 0)
- return -EINVAL;
+ DBG("modem: %p", modem);
return 0;
}
@@ -457,124 +342,38 @@ static int hfp_probe(struct ofono_modem *modem)
static void hfp_remove(struct ofono_modem *modem)
{
struct hfp_data *data = ofono_modem_get_data(modem);
- const char *obj_path = ofono_modem_get_path(modem);
-
- if (data->call != NULL)
- dbus_pending_call_cancel(data->call);
- if (g_dbus_unregister_interface(connection, obj_path,
- HFP_AGENT_INTERFACE))
- hfp_unregister_ofono_handsfree(modem);
+ DBG("modem: %p", modem);
g_free(data->handsfree_address);
- g_free(data->handsfree_path);
g_free(data);
ofono_modem_set_data(modem, NULL);
}
-static void hfp_connect_reply(DBusPendingCall *call, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusError derr;
- DBusMessage *reply, *msg;
-
- reply = dbus_pending_call_steal_reply(call);
-
- if (ofono_modem_get_powered(modem))
- goto done;
-
- dbus_error_init(&derr);
- if (!dbus_set_error_from_message(&derr, reply))
- goto done;
-
- DBG("Connect reply: %s", derr.message);
-
- if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) {
- msg = dbus_message_new_method_call(BLUEZ_SERVICE,
- data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "Disconnect");
- if (msg == NULL)
- ofono_error("Disconnect failed");
- else
- g_dbus_send_message(connection, msg);
- }
-
- ofono_modem_set_powered(modem, FALSE);
-
- dbus_error_free(&derr);
-
-done:
- dbus_message_unref(reply);
- data->call = NULL;
-}
-
/* power up hardware */
static int hfp_enable(struct ofono_modem *modem)
{
- struct hfp_data *data = ofono_modem_get_data(modem);
- int status;
-
DBG("%p", modem);
- status = bluetooth_send_with_reply(data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "Connect",
- &data->call, hfp_connect_reply,
- modem, NULL,
- DBUS_TIMEOUT, DBUS_TYPE_INVALID);
-
- if (status < 0)
- return -EINVAL;
-
- return -EINPROGRESS;
-}
-
-static void hfp_power_down(DBusPendingCall *call, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct hfp_data *data = ofono_modem_get_data(modem);
- DBusMessage *reply;
- DBusError derr;
-
- reply = dbus_pending_call_steal_reply(call);
-
- dbus_error_init(&derr);
- if (dbus_set_error_from_message(&derr, reply)) {
- DBG("Disconnect reply: %s", derr.message);
- dbus_error_free(&derr);
- goto done;
- }
-
- ofono_modem_set_powered(modem, FALSE);
+ if (ofono_modem_get_powered(modem))
+ return 0;
-done:
- dbus_message_unref(reply);
- data->call = NULL;
+ return -ENOTCONN;
}
static int hfp_disable(struct ofono_modem *modem)
{
struct hfp_data *data = ofono_modem_get_data(modem);
- int status;
DBG("%p", modem);
g_at_chat_unref(data->info.chat);
data->info.chat = NULL;
- if (data->agent_registered) {
- status = bluetooth_send_with_reply(data->handsfree_path,
- BLUEZ_GATEWAY_INTERFACE, "Disconnect",
- &data->call, hfp_power_down,
- modem, NULL,
- DBUS_TIMEOUT, DBUS_TYPE_INVALID);
-
- if (status < 0)
- return -EINVAL;
- }
+ ofono_modem_set_powered(modem, FALSE);
- return -EINPROGRESS;
+ return 0;
}
static void hfp_pre_sim(struct ofono_modem *modem)
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 07/14] hfp_hf: Register HFP modem dynamically
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (5 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 06/14] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 08/14] hfp_hf: Fix updating alias Claudio Takahasi
` (7 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6713 bytes --]
This patch moves the modem creation from the Bluetooth profile probe
to the NewConnection method call. HFP modem is now registered when
the Bluetooth link is established.
---
plugins/hfp_hf.c | 109 +++++++++++++++++++++++++++++++++++++------------------
1 file changed, 73 insertions(+), 36 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index d91c197..1d1edf1 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -57,13 +57,28 @@
static DBusConnection *connection;
static GHashTable *modem_hash = NULL;
+static GHashTable *hfp_hash = NULL;
struct hfp_data {
struct hfp_slc_info info;
- char *handsfree_address;
+ gchar *device_address;
+ gchar *adapter_address;
+ gchar *device_alias;
+ gchar *device_path;
DBusMessage *slc_msg;
};
+static void hfp_data_free(gpointer user_data)
+{
+ struct hfp_data *hfp_data = user_data;
+
+ g_free(hfp_data->device_address);
+ g_free(hfp_data->adapter_address);
+ g_free(hfp_data->device_alias);
+ g_free(hfp_data->device_path);
+ g_free(hfp_data);
+}
+
static void hfp_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
@@ -117,6 +132,10 @@ static void hfp_disconnected_cb(gpointer user_data)
g_at_chat_unref(data->info.chat);
data->info.chat = NULL;
+
+ g_hash_table_remove(modem_hash, data->device_path);
+
+ ofono_modem_remove(modem);
}
/* either oFono or Phone could request SLC connection */
@@ -153,46 +172,72 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
return -EINPROGRESS;
}
-static int hfp_hf_probe(const char *device, const char *dev_addr,
- const char *adapter_addr, const char *alias)
+static int modem_register(const char *device, struct hfp_data *hfp_data, int fd)
{
struct ofono_modem *modem;
- struct hfp_data *data;
char buf[256];
+ guint16 version = 0x0105;
/* We already have this device in our hash, ignore */
if (g_hash_table_lookup(modem_hash, device) != NULL)
return -EALREADY;
- ofono_info("Using device: %s, devaddr: %s, adapter: %s",
- device, dev_addr, adapter_addr);
-
strcpy(buf, "hfp/");
- bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
+ bluetooth_create_path(hfp_data->device_address,
+ hfp_data->adapter_address, buf + 4, sizeof(buf) - 4);
modem = ofono_modem_create(buf, "hfp");
if (modem == NULL)
return -ENOMEM;
- data = g_try_new0(struct hfp_data, 1);
- if (data == NULL)
+ ofono_modem_set_data(modem, hfp_data);
+ ofono_modem_set_name(modem, hfp_data->device_alias);
+ ofono_modem_register(modem);
+
+ g_hash_table_insert(modem_hash, g_strdup(device), modem);
+
+ hfp_slc_info_init(&hfp_data->info, version);
+
+ return service_level_connection(modem, fd);
+}
+
+static int hfp_hf_probe(const char *device, const char *dev_addr,
+ const char *adapter_addr, const char *alias)
+{
+ struct hfp_data *hfp_data;
+
+ if (g_hash_table_lookup(hfp_hash, device) != NULL)
+ return -EALREADY;
+
+ ofono_info("Using device: %s, devaddr: %s, adapter: %s",
+ device, dev_addr, adapter_addr);
+
+ hfp_data = g_try_new0(struct hfp_data, 1);
+ if (hfp_data == NULL)
goto free;
- data->handsfree_address = g_strdup(dev_addr);
- if (data->handsfree_address == NULL)
+ hfp_data->adapter_address = g_strdup(adapter_addr);
+ if (hfp_data->adapter_address == NULL)
goto free;
- ofono_modem_set_data(modem, data);
- ofono_modem_set_name(modem, alias);
- ofono_modem_register(modem);
+ hfp_data->device_address = g_strdup(dev_addr);
+ if (hfp_data->device_address == NULL)
+ goto free;
- g_hash_table_insert(modem_hash, g_strdup(device), modem);
+ hfp_data->device_path = g_strdup(device);
+ if (hfp_data->device_path == NULL)
+ goto free;
+
+ hfp_data->device_alias = g_strdup(alias);
+ if (hfp_data->device_alias == NULL)
+ goto free;
+
+ g_hash_table_insert(hfp_hash, g_strdup(device), hfp_data);
return 0;
free:
- g_free(data);
- ofono_modem_remove(modem);
+ hfp_data_free(hfp_data);
return -ENOMEM;
}
@@ -240,12 +285,10 @@ static void hfp_hf_set_alias(const char *device, const char *alias)
static DBusMessage *profile_new_connection(DBusConnection *conn,
DBusMessage *msg, void *data)
{
- struct ofono_modem *modem;
struct hfp_data *hfp_data;
const char *device;
DBusMessageIter entry;
int fd, err;
- guint16 version = 0x0105;
DBG("Profile handler NewConnection");
@@ -256,9 +299,9 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
goto error;
dbus_message_iter_get_basic(&entry, &device);
- modem = g_hash_table_lookup(modem_hash, device);
- if (modem == NULL) {
- DBG("%s: modem not found", device);
+ hfp_data = g_hash_table_lookup(hfp_hash, device);
+ if (hfp_data == NULL) {
+ DBG("%s: doesn't support HFP", device);
goto error;
}
@@ -270,12 +313,9 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
if (fd < 0)
goto error;
- hfp_data = ofono_modem_get_data(modem);
- DBG("modem %p, hfp_data: %p SLC FD: %d", modem, hfp_data, fd);
-
- hfp_slc_info_init(&hfp_data->info, version);
+ DBG("hfp_data: %p SLC FD: %d", hfp_data, fd);
- err = service_level_connection(modem, fd);
+ err = modem_register(device, hfp_data, fd);
if (err < 0 && err != -EINPROGRESS)
return __ofono_error_failed(msg);
@@ -341,14 +381,7 @@ static int hfp_probe(struct ofono_modem *modem)
static void hfp_remove(struct ofono_modem *modem)
{
- struct hfp_data *data = ofono_modem_get_data(modem);
-
DBG("modem: %p", modem);
-
- g_free(data->handsfree_address);
- g_free(data);
-
- ofono_modem_set_data(modem, NULL);
}
/* power up hardware */
@@ -382,7 +415,7 @@ static void hfp_pre_sim(struct ofono_modem *modem)
DBG("%p", modem);
- ofono_devinfo_create(modem, 0, "hfpmodem", data->handsfree_address);
+ ofono_devinfo_create(modem, 0, "hfpmodem", data->device_address);
ofono_voicecall_create(modem, 0, "hfpmodem", &data->info);
ofono_netreg_create(modem, 0, "hfpmodem", &data->info);
ofono_call_volume_create(modem, 0, "hfpmodem", &data->info);
@@ -456,6 +489,9 @@ static int hfp_init(void)
modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, NULL);
+ hfp_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+ hfp_data_free);
+
return 0;
}
@@ -468,6 +504,7 @@ static void hfp_exit(void)
ofono_modem_driver_unregister(&hfp_driver);
g_hash_table_destroy(modem_hash);
+ g_hash_table_destroy(hfp_hash);
}
OFONO_PLUGIN_DEFINE(hfp, "Hands-Free Profile Plugins", VERSION,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 08/14] hfp_hf: Fix updating alias
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (6 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 07/14] hfp_hf: Register HFP modem dynamically Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 09/14] bluetooth: Reuse D-Bus dictionary parser function Claudio Takahasi
` (6 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]
This patch fixes the Bluetooth device alias for the HFP when the modem
is not registered yet. Modem is being created with the first alias
informed when in the Bluetooth profile probe callback.
---
plugins/hfp_hf.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 1d1edf1..da20917 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -271,15 +271,20 @@ static void hfp_hf_remove(const char *prefix)
static void hfp_hf_set_alias(const char *device, const char *alias)
{
struct ofono_modem *modem;
+ struct hfp_data *hfp_data;
if (device == NULL || alias == NULL)
return;
- modem = g_hash_table_lookup(modem_hash, device);
- if (modem == NULL)
- return;
+ hfp_data = g_hash_table_lookup(hfp_hash, device);
+ if (hfp_data) {
+ g_free(hfp_data->device_alias);
+ hfp_data->device_alias = g_strdup(alias);
+ }
- ofono_modem_set_name(modem, alias);
+ modem = g_hash_table_lookup(modem_hash, device);
+ if (modem)
+ ofono_modem_set_name(modem, alias);
}
static DBusMessage *profile_new_connection(DBusConnection *conn,
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 09/14] bluetooth: Reuse D-Bus dictionary parser function
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (7 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 08/14] hfp_hf: Fix updating alias Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 10/14] hfp_hf: Add Version and Features parsing Claudio Takahasi
` (5 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3565 bytes --]
This patch changes the Bluetooth D-Bus property parser function to allow
reusing on other messages. The dictionary can be placed on any position
of the message, the current implementation assumes that the first
message parameter should be a dictionary.
---
plugins/bluetooth.c | 27 ++++++++++++++++-----------
plugins/bluetooth.h | 3 ++-
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 201c851..37738e7 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -195,11 +195,14 @@ static gint property_handler_compare(gconstpointer a, gconstpointer b)
return strcmp(handler->property, property);
}
-void bluetooth_parse_properties(DBusMessage *reply, const char *property, ...)
+void bluetooth_parse_properties(DBusMessageIter *array, const char *property, ...)
{
va_list args;
GSList *prop_handlers = NULL;
- DBusMessageIter array, dict;
+ DBusMessageIter dict;
+
+ if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
+ goto done;
va_start(args, property);
@@ -218,13 +221,7 @@ void bluetooth_parse_properties(DBusMessage *reply, const char *property, ...)
va_end(args);
- if (dbus_message_iter_init(reply, &array) == FALSE)
- goto done;
-
- if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
- goto done;
-
- dbus_message_iter_recurse(&array, &dict);
+ dbus_message_iter_recurse(array, &dict);
while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
DBusMessageIter entry, value;
@@ -324,6 +321,7 @@ static void device_properties_cb(DBusPendingCall *call, gpointer user_data)
const char *adapter_addr = NULL;
const char *device_addr = NULL;
const char *alias = NULL;
+ DBusMessageIter iter;
struct DBusError derr;
GSList *uuids = NULL;
@@ -341,7 +339,10 @@ static void device_properties_cb(DBusPendingCall *call, gpointer user_data)
DBG("");
- bluetooth_parse_properties(reply, "UUIDs", parse_uuids, &uuids,
+ if (dbus_message_iter_init(reply, &iter) == FALSE)
+ goto done;
+
+ bluetooth_parse_properties(&iter, "UUIDs", parse_uuids, &uuids,
"Adapter", parse_string, &adapter,
"Address", parse_string, &device_addr,
"Alias", parse_string, &alias, NULL);
@@ -480,6 +481,7 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
{
const char *path = user_data;
DBusMessage *reply;
+ DBusMessageIter iter;
DBusError derr;
GSList *device_list = NULL;
GSList *l;
@@ -499,7 +501,10 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
DBG("");
- bluetooth_parse_properties(reply,
+ if (dbus_message_iter_init(reply, &iter) == FALSE)
+ goto done;
+
+ bluetooth_parse_properties(&iter,
"Devices", parse_devices, &device_list,
"Address", parse_string, &addr,
NULL);
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index a9355f6..5b4d9d4 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -84,7 +84,8 @@ int bluetooth_send_with_reply(const char *path, const char *interface,
DBusPendingCallNotifyFunction cb,
void *user_data, DBusFreeFunction free_func,
int timeout, int type, ...);
-void bluetooth_parse_properties(DBusMessage *reply, const char *property, ...);
+void bluetooth_parse_properties(DBusMessageIter *array,
+ const char *property, ...);
int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
struct ofono_modem *modem);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 10/14] hfp_hf: Add Version and Features parsing
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (8 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 09/14] bluetooth: Reuse D-Bus dictionary parser function Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 11/14] bluetooth: Use generic function to parse dict Claudio Takahasi
` (4 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2195 bytes --]
This patch adds parsing of the Version and Features properties of the
NewConnection fd_dictionary.
---
plugins/hfp_hf.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index da20917..8dd8dd9 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -79,6 +79,16 @@ static void hfp_data_free(gpointer user_data)
g_free(hfp_data);
}
+static void parse_guint16(DBusMessageIter *iter, gpointer user_data)
+{
+ guint16 *value = user_data;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16)
+ return;
+
+ dbus_message_iter_get_basic(iter, value);
+}
+
static void hfp_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
@@ -172,11 +182,11 @@ static int service_level_connection(struct ofono_modem *modem, int fd)
return -EINPROGRESS;
}
-static int modem_register(const char *device, struct hfp_data *hfp_data, int fd)
+static int modem_register(const char *device, struct hfp_data *hfp_data,
+ int fd, guint16 version)
{
struct ofono_modem *modem;
char buf[256];
- guint16 version = 0x0105;
/* We already have this device in our hash, ignore */
if (g_hash_table_lookup(modem_hash, device) != NULL)
@@ -294,6 +304,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
const char *device;
DBusMessageIter entry;
int fd, err;
+ guint16 version = 0x0105, features = 0x0000;
DBG("Profile handler NewConnection");
@@ -318,9 +329,17 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
if (fd < 0)
goto error;
- DBG("hfp_data: %p SLC FD: %d", hfp_data, fd);
+ dbus_message_iter_next(&entry);
+
+ bluetooth_parse_properties(&entry,
+ "Version", parse_guint16, &version,
+ "Features", parse_guint16, &features,
+ NULL);
+
+ DBG("hfp_data: %p SLC FD: %d Version: 0x%04x Features: 0x%04x",
+ hfp_data, fd, version, features);
- err = modem_register(device, hfp_data, fd);
+ err = modem_register(device, hfp_data, fd, version);
if (err < 0 && err != -EINPROGRESS)
return __ofono_error_failed(msg);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 11/14] bluetooth: Use generic function to parse dict
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (9 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 10/14] hfp_hf: Add Version and Features parsing Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 12/14] bluetooth: Fix memory leak of adapter_any_path Claudio Takahasi
` (3 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3219 bytes --]
This patch changes the Device PropertiesChanged signal parser to use
the generic utility function to decode dictionary entries.
---
plugins/bluetooth.c | 81 ++++++++++++++++++-----------------------------------
1 file changed, 27 insertions(+), 54 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 37738e7..a3dccee 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -401,8 +401,9 @@ static void get_device_properties(const char *path)
static gboolean properties_changed(DBusConnection *conn, DBusMessage *msg,
void *user_data)
{
- const char *property, *interface;
- DBusMessageIter iter, dict, entry, variant;
+ const char *interface, *path, *alias = NULL;
+ DBusMessageIter iter;
+ GSList *uuids = NULL;
DBG("");
@@ -420,59 +421,31 @@ static gboolean properties_changed(DBusConnection *conn, DBusMessage *msg,
if (!dbus_message_iter_next(&iter))
return FALSE;
- /* Reading Dict entries containing properties */
- dbus_message_iter_recurse(&iter, &dict);
-
- do {
- if (dbus_message_iter_get_arg_type(&dict) !=
- DBUS_TYPE_DICT_ENTRY)
- return FALSE;
-
- dbus_message_iter_recurse(&dict, &entry);
-
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_STRING)
- return FALSE;
-
- dbus_message_iter_get_basic(&entry, &property);
-
- if (!dbus_message_iter_next(&entry))
- return FALSE;
-
- if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
- return FALSE;
-
- dbus_message_iter_recurse(&entry, &variant);
- if (g_str_equal(property, "UUIDs") == TRUE) {
- GSList *uuids = NULL;
- const char *path = dbus_message_get_path(msg);
-
- parse_uuids(&variant, &uuids);
-
- /* We need the full set of properties to be able to
- * create the modem properly, including Adapter and
- * Alias, so refetch everything again
- */
- if (uuids)
- get_device_properties(path);
- } else if (g_str_equal(property, "Alias") == TRUE) {
- const char *path = dbus_message_get_path(msg);
- struct bluetooth_profile *profile;
- const char *alias = NULL;
- GHashTableIter hash_iter;
- gpointer key, value;
-
- parse_string(&variant, &alias);
-
- g_hash_table_iter_init(&hash_iter, uuid_hash);
- while (g_hash_table_iter_next(&hash_iter, &key,
- &value)) {
- profile = value;
- if (profile->set_alias)
- profile->set_alias(path, alias);
- }
+ bluetooth_parse_properties(&iter,
+ "UUIDs", parse_uuids, &uuids,
+ "Alias", parse_string, &alias,
+ NULL);
+
+ path = dbus_message_get_path(msg);
+
+ /* We need the full set of properties to be able to
+ * create the modem properly, including Adapter and
+ * Alias, so refetch everything again
+ */
+ if (uuids)
+ get_device_properties(path);
+
+ if (alias) {
+ GHashTableIter hash_iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init(&hash_iter, uuid_hash);
+ while (g_hash_table_iter_next(&hash_iter, &key, &value)) {
+ struct bluetooth_profile *profile = value;
+ if (profile->set_alias)
+ profile->set_alias(path, alias);
}
-
- } while (dbus_message_iter_next(&dict));
+ }
return TRUE;
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 12/14] bluetooth: Fix memory leak of adapter_any_path
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (10 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 11/14] bluetooth: Use generic function to parse dict Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 13/14] hfp_hf: Handle connections before probe Claudio Takahasi
` (2 subsequent siblings)
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]
This patch fixes a memory leak when BlueZ service re-connects to the
system Bus and oFono calls FindAdapter method.
---
plugins/bluetooth.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index a3dccee..6447e77 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -45,7 +45,7 @@ static GHashTable *adapter_address_hash = NULL;
static gint bluetooth_refcount;
static GSList *server_list = NULL;
static const char *adapter_any_name = "any";
-static char *adapter_any_path;
+static char *adapter_any_path = NULL;
#define TIMEOUT 60 /* Timeout for user response (seconds) */
@@ -733,6 +733,7 @@ static void find_adapter_cb(DBusPendingCall *call, gpointer user_data)
dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &path,
DBUS_TYPE_INVALID);
+ g_free(adapter_any_path);
adapter_any_path = g_strdup(path);
g_slist_foreach(server_list, (GFunc) add_record, NULL);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 13/14] hfp_hf: Handle connections before probe
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (11 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 12/14] bluetooth: Fix memory leak of adapter_any_path Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 14/14] bluetooth: Fix memory leak of UUIDs list Claudio Takahasi
2012-12-17 14:28 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5373 bytes --]
This patch allows oFono HFP plugin to handle HFP connections before
the Bluetooth device creation procedure finishes.
---
plugins/bluetooth.c | 26 +++++++++++++++++
plugins/bluetooth.h | 2 ++
plugins/hfp_hf.c | 84 +++++++++++++++++++++++++++++++++++------------------
3 files changed, 83 insertions(+), 29 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 6447e77..ce6dcae 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -31,6 +31,8 @@
#include <unistd.h>
#include <glib.h>
#include <gdbus.h>
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/rfcomm.h>
#define OFONO_API_SUBJECT_TO_CHANGE
#include <ofono/plugin.h>
@@ -1141,5 +1143,29 @@ void bluetooth_unregister_server(struct server *server)
bluetooth_unref();
}
+int bluetooth_get_address(int fd, char *adapter_address, char *device_address)
+{
+ struct sockaddr_rc saddr;
+ socklen_t alen;
+
+ alen = sizeof(saddr);
+
+ if (adapter_address) {
+ if (getsockname(fd, (struct sockaddr *)&saddr, &alen) < 0)
+ return -errno;
+
+ ba2str(&saddr.rc_bdaddr, adapter_address);
+ }
+
+ if (device_address) {
+ if (getpeername(fd, (struct sockaddr *)&saddr, &alen) < 0)
+ return -errno;
+
+ ba2str(&saddr.rc_bdaddr, device_address);
+ }
+
+ return 0;
+}
+
OFONO_PLUGIN_DEFINE(bluetooth, "Bluetooth Utils Plugins", VERSION,
OFONO_PLUGIN_PRIORITY_DEFAULT, NULL, NULL)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 5b4d9d4..c1c274d 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -90,3 +90,5 @@ void bluetooth_parse_properties(DBusMessageIter *array,
int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
struct ofono_modem *modem);
void bluetooth_sap_client_unregister(struct ofono_modem *modem);
+
+int bluetooth_get_address(int fd, char *adapter_address, char *device_address);
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 8dd8dd9..5d71558 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -79,6 +79,40 @@ static void hfp_data_free(gpointer user_data)
g_free(hfp_data);
}
+static struct hfp_data *hfp_data_new(const gchar *adapter_addr,
+ const gchar *device_addr,
+ const gchar *device_path,
+ const gchar *alias)
+{
+ struct hfp_data *hfp_data;
+
+ hfp_data = g_try_new0(struct hfp_data, 1);
+ if (hfp_data == NULL)
+ return NULL;
+
+ hfp_data->adapter_address = g_strdup(adapter_addr);
+ if (hfp_data->adapter_address == NULL)
+ goto free;
+
+ hfp_data->device_address = g_strdup(device_addr);
+ if (hfp_data->device_address == NULL)
+ goto free;
+
+ hfp_data->device_path = g_strdup(device_path);
+ if (hfp_data->device_path == NULL)
+ goto free;
+
+ hfp_data->device_alias = g_strdup(alias);
+ if (hfp_data->device_alias == NULL)
+ goto free;
+
+ return hfp_data;
+
+free:
+ hfp_data_free(hfp_data);
+ return NULL;
+}
+
static void parse_guint16(DBusMessageIter *iter, gpointer user_data)
{
guint16 *value = user_data;
@@ -222,34 +256,13 @@ static int hfp_hf_probe(const char *device, const char *dev_addr,
ofono_info("Using device: %s, devaddr: %s, adapter: %s",
device, dev_addr, adapter_addr);
- hfp_data = g_try_new0(struct hfp_data, 1);
+ hfp_data = hfp_data_new(adapter_addr, dev_addr, device, alias);
if (hfp_data == NULL)
- goto free;
-
- hfp_data->adapter_address = g_strdup(adapter_addr);
- if (hfp_data->adapter_address == NULL)
- goto free;
-
- hfp_data->device_address = g_strdup(dev_addr);
- if (hfp_data->device_address == NULL)
- goto free;
-
- hfp_data->device_path = g_strdup(device);
- if (hfp_data->device_path == NULL)
- goto free;
-
- hfp_data->device_alias = g_strdup(alias);
- if (hfp_data->device_alias == NULL)
- goto free;
+ return -ENOMEM;
g_hash_table_insert(hfp_hash, g_strdup(device), hfp_data);
return 0;
-
-free:
- hfp_data_free(hfp_data);
-
- return -ENOMEM;
}
static gboolean hfp_remove_modem(gpointer key, gpointer value,
@@ -315,12 +328,6 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
goto error;
dbus_message_iter_get_basic(&entry, &device);
- hfp_data = g_hash_table_lookup(hfp_hash, device);
- if (hfp_data == NULL) {
- DBG("%s: doesn't support HFP", device);
- goto error;
- }
-
dbus_message_iter_next(&entry);
if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_UNIX_FD)
goto error;
@@ -336,6 +343,25 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
"Features", parse_guint16, &features,
NULL);
+ hfp_data = g_hash_table_lookup(hfp_hash, device);
+ if (hfp_data == NULL) {
+ char adapter_address[18], device_address[18];
+
+ /*
+ * Incoming connection notification can arrive before
+ * the Bluetooth device creation finishes.
+ */
+ if (bluetooth_get_address(fd, adapter_address,
+ device_address) < 0)
+ return g_dbus_create_error(msg,
+ BLUEZ_ERROR_INTERFACE ".Rejected",
+ "Invalid arguments in method call");
+
+ hfp_data = hfp_data_new(adapter_address, device_address,
+ device, device_address);
+ g_hash_table_insert(hfp_hash, g_strdup(device), hfp_data);
+ }
+
DBG("hfp_data: %p SLC FD: %d Version: 0x%04x Features: 0x%04x",
hfp_data, fd, version, features);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* [PATCH v0 14/14] bluetooth: Fix memory leak of UUIDs list
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (12 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 13/14] hfp_hf: Handle connections before probe Claudio Takahasi
@ 2012-12-03 13:11 ` Claudio Takahasi
2012-12-17 14:28 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-03 13:11 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 587 bytes --]
---
plugins/bluetooth.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index ce6dcae..52bf71f 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -434,8 +434,10 @@ static gboolean properties_changed(DBusConnection *conn, DBusMessage *msg,
* create the modem properly, including Adapter and
* Alias, so refetch everything again
*/
- if (uuids)
+ if (uuids) {
get_device_properties(path);
+ g_slist_free(uuids);
+ }
if (alias) {
GHashTableIter hash_iter;
--
1.7.11.7
^ permalink raw reply related [flat|nested] 49+ messages in thread
* Re: [PATCH v0 00/14] External HFP Profile
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
` (13 preceding siblings ...)
2012-12-03 13:11 ` [PATCH v0 14/14] bluetooth: Fix memory leak of UUIDs list Claudio Takahasi
@ 2012-12-17 14:28 ` Claudio Takahasi
14 siblings, 0 replies; 49+ messages in thread
From: Claudio Takahasi @ 2012-12-17 14:28 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]
Hi Marcel:
On Mon, Dec 3, 2012 at 10:11 AM, Claudio Takahasi
<claudio.takahasi@openbossa.org> wrote:
> BlueZ supports now external profile registration, see:
> bluez/doc/profile-api.txt
>
> This patch series has the initial implementation of the HFP external
> profile in oFono. HandsfreeAgent and HandsfreeGateway interfaces were
> removed from BlueZ.
>
> Modem are being registered dinamically when the new connection is
> notified instead of registering the modem when the Bluetooth device
> is created/probed.
>
> * Needs to be applied after "[PATCH v0 1/4] bluetooth: Fix reading
> Bluetooth Adapters" series
>
> Changes from RFC v1:
> - Remove optional RequireAuthorization & RequireAuthentication to
> Register HFP profile.
>
> Next actions:
> - Implement MediaTransport
> - MediaEndpoint set configuration
>
> Development branch:
> git://git.infradead.org/users/cktakahasi/ofono.git hfp
Ignore this patch series also.
As discussed in the IRC, we will split the Bluetooth/HFP plugins to
keep the compatibility with BlueZ 4 and BlueZ 5.
Regards,
Claudio.
^ permalink raw reply [flat|nested] 49+ messages in thread
end of thread, other threads:[~2012-12-17 14:28 UTC | newest]
Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-22 17:53 [RFC v0 00/11] External HFP Profile Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 01/11] hfp_hf: Add HFP external Profile registration Claudio Takahasi
2012-11-26 11:08 ` Johan Hedberg
2012-11-26 11:24 ` Johan Hedberg
2012-11-22 17:53 ` [RFC v0 02/11] hfp_hf: Add BlueZ Profile handler Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 03/11] hfp_hf: Add parsing of Profile NewConnection call Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 04/11] hfp_hf: Add SLC setup Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 05/11] hfp_hf: Add Profile1 Release Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 06/11] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 07/11] hfp_hf: Register HFP modem dynamically Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 08/11] hfp_hf: Fix updating alias Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 09/11] bluetooth: Reuse D-Bus dictionary parser function Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 10/11] hfp_hf: Add Version and Features parsing Claudio Takahasi
2012-11-22 17:53 ` [RFC v0 11/11] bluetooth: Use generic function to parse dict Claudio Takahasi
2012-11-23 8:44 ` [RFC v0 00/11] External HFP Profile Johan Hedberg
2012-11-23 8:54 ` Johan Hedberg
2012-11-23 11:43 ` Johan Hedberg
2012-11-26 13:26 ` [RFC v1 00/15] " Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 01/15] hfp_hf: Add HFP external Profile registration Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 02/15] hfp_hf: Add BlueZ Profile handler Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 03/15] hfp_hf: Add parsing of Profile NewConnection call Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 04/15] hfp_hf: Add SLC setup Claudio Takahasi
2012-11-26 13:26 ` [RFC v1 05/15] hfp_hf: Add Profile1 Release Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 06/15] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 07/15] hfp_hf: Register HFP modem dynamically Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 08/15] hfp_hf: Fix updating alias Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 09/15] bluetooth: Reuse D-Bus dictionary parser function Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 10/15] hfp_hf: Add Version and Features parsing Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 11/15] bluetooth: Use generic function to parse dict Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 12/15] hfp_hf: Request secure connections Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 13/15] bluetooth: Fix memory leak of adapter_any_path Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 14/15] hfp_hf: Handle connections before probe Claudio Takahasi
2012-11-26 13:27 ` [RFC v1 15/15] bluetooth: Fix memory leak of UUIDs list Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 01/14] hfp_hf: Add HFP external Profile registration Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 02/14] hfp_hf: Add BlueZ Profile handler Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 03/14] hfp_hf: Add parsing of Profile NewConnection call Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 04/14] hfp_hf: Add SLC setup Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 05/14] hfp_hf: Add Profile1 Release Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 06/14] hfp_hf: Remove HandsfreeAgent and HandsfreeGateway Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 07/14] hfp_hf: Register HFP modem dynamically Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 08/14] hfp_hf: Fix updating alias Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 09/14] bluetooth: Reuse D-Bus dictionary parser function Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 10/14] hfp_hf: Add Version and Features parsing Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 11/14] bluetooth: Use generic function to parse dict Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 12/14] bluetooth: Fix memory leak of adapter_any_path Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 13/14] hfp_hf: Handle connections before probe Claudio Takahasi
2012-12-03 13:11 ` [PATCH v0 14/14] bluetooth: Fix memory leak of UUIDs list Claudio Takahasi
2012-12-17 14:28 ` [PATCH v0 00/14] External HFP Profile Claudio Takahasi
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.