From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 01/10] hfp_hf_bluez5: Initial GDBusClient for BlueZ
Date: Tue, 22 Jan 2013 22:30:21 -0600 [thread overview]
Message-ID: <50FF675D.5060005@gmail.com> (raw)
In-Reply-To: <1358891005-24688-2-git-send-email-vinicius.gomes@openbossa.org>
[-- Attachment #1: Type: text/plain, Size: 4598 bytes --]
Hi Vinicius,
On 01/22/2013 03:43 PM, Vinicius Costa Gomes wrote:
> This patch adds the initial callbacks to track when BlueZ connects or
> disconnects from the system bus. And tracks the interfaces added or
> removed.
> ---
> plugins/bluez5.h | 3 ++-
> plugins/hfp_hf_bluez5.c | 72 ++++++++++++++++++++++++++++++++++++++++++-------
> 2 files changed, 65 insertions(+), 10 deletions(-)
>
> diff --git a/plugins/bluez5.h b/plugins/bluez5.h
> index 01ecfe8..893072f 100644
> --- a/plugins/bluez5.h
> +++ b/plugins/bluez5.h
> @@ -19,7 +19,8 @@
> *
> */
>
> -#define BLUEZ_SERVICE "org.bluez"
> +#define BLUEZ_SERVICE "org.bluez"
> +#define BLUEZ_MANAGER_PATH "/"
> #define BLUEZ_PROFILE_INTERFACE BLUEZ_SERVICE ".Profile1"
> #define BLUEZ_ERROR_INTERFACE BLUEZ_SERVICE ".Error"
>
> diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
> index e024838..c5c5cd7 100644
> --- a/plugins/hfp_hf_bluez5.c
> +++ b/plugins/hfp_hf_bluez5.c
> @@ -42,6 +42,8 @@
>
> #define HFP_EXT_PROFILE_PATH "/bluetooth/profile/hfp_hf"
>
> +static GDBusClient *bluez = NULL;
> +
> static int hfp_probe(struct ofono_modem *modem)
> {
> DBG("modem: %p", modem);
> @@ -143,6 +145,60 @@ static const GDBusMethodTable profile_methods[] = {
> { }
> };
>
> +static void connect_handler(DBusConnection *conn, void *user_data)
> +{
> + DBG("Registering External Profile handler ...");
> +
> + if (!g_dbus_register_interface(conn, HFP_EXT_PROFILE_PATH,
> + BLUEZ_PROFILE_INTERFACE,
> + profile_methods, NULL,
> + NULL, NULL, NULL)) {
We just performed this operation in hfp_init, why are we doing it again
here?
> + ofono_error("Register Profile interface failed: %s",
> + HFP_EXT_PROFILE_PATH);
> + }
> +
> + bluetooth_register_profile(conn, HFP_HS_UUID, "hfp_hf",
> + HFP_EXT_PROFILE_PATH);
You have a whitespace violation here, mixing tabs & spaces.
> +}
> +
> +static void disconnect_handler(DBusConnection *conn, void *user_data)
> +{
> +
> + DBG("Unregistering External Profile handler ...");
> +
> + g_dbus_unregister_interface(conn, HFP_EXT_PROFILE_PATH,
> + BLUEZ_PROFILE_INTERFACE);
Why do we bother? Should we not leave this always registered?
> +}
> +
> +static void proxy_added(GDBusProxy *proxy, void *user_data)
> +{
> + const char *path;
> +
> + path = g_dbus_proxy_get_path(proxy);
> +
> + DBG("Device proxy: %s(%p)", path, proxy);
> +}
> +
> +static void proxy_removed(GDBusProxy *proxy, void *user_data)
> +{
> + const char *path;
> +
> + path = g_dbus_proxy_get_path(proxy);
> +
> + DBG("Device proxy: %s(%p)", path, proxy);
> +}
> +
> +static void property_changed(GDBusProxy *proxy, const char *name,
> + DBusMessageIter *iter, void *user_data)
> +{
> + const char *interface, *path;
> +
> + interface = g_dbus_proxy_get_interface(proxy);
> + path = g_dbus_proxy_get_path(proxy);
> +
> + DBG("path: %s interface: %s", path, interface);
> +}
> +
> static int hfp_init(void)
> {
> DBusConnection *conn = ofono_dbus_get_connection();
> @@ -161,19 +217,16 @@ static int hfp_init(void)
> return -EIO;
> }
>
> - err = ofono_modem_driver_register(&hfp_driver);
> - if (err< 0) {
> - g_dbus_unregister_interface(conn, HFP_EXT_PROFILE_PATH,
> - BLUEZ_PROFILE_INTERFACE);
> - return err;
> - }
> + bluez = g_dbus_client_new(conn, BLUEZ_SERVICE, BLUEZ_MANAGER_PATH);
> + g_dbus_client_set_connect_watch(bluez, connect_handler, NULL);
> + g_dbus_client_set_disconnect_watch(bluez, disconnect_handler, NULL);
> + g_dbus_client_set_proxy_handlers(bluez, proxy_added, proxy_removed,
> + property_changed, NULL);
Error handling here is all messed up. ofono_modem_driver_register
operation might still fail below and you never destroy the 'bluez'
object in that case.
>
> - err = bluetooth_register_profile(conn, HFP_HS_UUID, "hfp_hf",
> - HFP_EXT_PROFILE_PATH);
> + err = ofono_modem_driver_register(&hfp_driver);
> if (err< 0) {
> g_dbus_unregister_interface(conn, HFP_EXT_PROFILE_PATH,
> BLUEZ_PROFILE_INTERFACE);
> - ofono_modem_driver_unregister(&hfp_driver);
> return err;
> }
>
> @@ -188,6 +241,7 @@ static void hfp_exit(void)
> g_dbus_unregister_interface(conn, HFP_EXT_PROFILE_PATH,
> BLUEZ_PROFILE_INTERFACE);
> ofono_modem_driver_unregister(&hfp_driver);
> + g_dbus_client_unref(bluez);
> }
>
> OFONO_PLUGIN_DEFINE(hfp_bluez5, "External Hands-Free Profile Plugin", VERSION,
Regards,
-Denis
next prev parent reply other threads:[~2013-01-23 4:30 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-22 21:43 [PATCH 00/10] HFP Service Level Connection establishment Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 01/10] hfp_hf_bluez5: Initial GDBusClient for BlueZ Vinicius Costa Gomes
2013-01-23 4:30 ` Denis Kenzior [this message]
2013-01-23 14:16 ` Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 02/10] hfp_hf_bluez5: Add GDBusProxy for Bluetooth devices Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 03/10] hfp_hf_bluez5: Register modem for HFP AG capable devices Vinicius Costa Gomes
2013-01-23 4:59 ` Denis Kenzior
2013-01-23 14:22 ` Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 04/10] hfp_hf_bluez5: Keep track of changes of devices Aliases Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 05/10] hfp_hf_bluez5: Handle NewConnection from BlueZ Vinicius Costa Gomes
2013-01-23 4:54 ` Denis Kenzior
2013-01-23 12:03 ` AW: " Kling, Andreas
2013-01-23 14:49 ` Denis Kenzior
2013-01-23 16:39 ` Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 06/10] hfpmodem: Add dynamic hfp_slc_info allocation Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 07/10] hfpmodem: Implement hfp_slc_info_free Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 08/10] hfp_hf_bluez4: Use hfp_slc_info_free() Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 09/10] phonesim: " Vinicius Costa Gomes
2013-01-22 21:43 ` [PATCH 10/10] hfp_hf_bluez5: Add SLC establishment procedure Vinicius Costa Gomes
2013-01-23 5:26 ` Denis Kenzior
2013-01-23 18:27 ` [PATCH v1 00/10] HFP Service Level Connection establishment Vinicius Costa Gomes
2013-01-23 18:27 ` [PATCH v1 01/10] hfp_hf_bluez5: Initial GDBusClient for BlueZ Vinicius Costa Gomes
2013-01-23 20:31 ` Denis Kenzior
2013-01-23 18:27 ` [PATCH v1 02/10] hfp_hf_bluez5: Add GDBusProxy for Bluetooth devices Vinicius Costa Gomes
2013-01-23 20:31 ` Denis Kenzior
2013-01-23 18:27 ` [PATCH v1 03/10] hfp_hf_bluez5: Register modem for HFP AG capable devices Vinicius Costa Gomes
2013-01-23 20:32 ` Denis Kenzior
2013-01-23 18:27 ` [PATCH v1 04/10] hfp_hf_bluez5: Keep track of changes of devices Aliases Vinicius Costa Gomes
2013-01-23 20:32 ` Denis Kenzior
2013-01-23 18:27 ` [PATCH v1 05/10] hfp_hf_bluez5: Handle NewConnection from BlueZ Vinicius Costa Gomes
2013-01-23 20:32 ` Denis Kenzior
2013-01-23 18:27 ` [PATCH v1 06/10] hfpmodem: Add dynamic hfp_slc_info allocation Vinicius Costa Gomes
2013-01-23 20:34 ` Denis Kenzior
2013-01-23 23:04 ` Vinicius Costa Gomes
2013-01-23 18:27 ` [PATCH v1 07/10] hfpmodem: Implement hfp_slc_info_free() Vinicius Costa Gomes
2013-01-23 18:27 ` [PATCH v1 08/10] hfp_hf_bluez4: Use hfp_slc_info_free() Vinicius Costa Gomes
2013-01-23 18:28 ` [PATCH v1 09/10] phonesim: " Vinicius Costa Gomes
2013-01-23 18:28 ` [PATCH v1 10/10] hfp_hf_bluez5: Add SLC establishment procedure Vinicius Costa Gomes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50FF675D.5060005@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox