From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 1/3] hfp: create modem for new devices paired on runtime
Date: Thu, 04 Feb 2010 15:58:05 -0600 [thread overview]
Message-ID: <201002041558.06215.denkenz@gmail.com> (raw)
In-Reply-To: <1265319021-28299-1-git-send-email-padovan@profusion.mobi>
[-- Attachment #1: Type: text/plain, Size: 4505 bytes --]
Hi Gustavo,
> It listens the Paired property to create a modem to the recently paired
> devices. It also renames added_watch to adapter_watch, a more proper
> name.
> ---
> plugins/hfp.c | 64
> ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files
changed,
> 59 insertions(+), 5 deletions(-)
>
> diff --git a/plugins/hfp.c b/plugins/hfp.c
> index 981b05b..cd43af7 100644
> --- a/plugins/hfp.c
> +++ b/plugins/hfp.c
> @@ -66,6 +66,7 @@ static const char *cmer_prefix[] = { "+CMER:", NULL };
> static const char *chld_prefix[] = { "+CHLD:", NULL };
>
> static DBusConnection *connection;
> +static GHashTable *uuid_hash = NULL;
>
> static void hfp_debug(const char *str, void *user_data)
> {
> @@ -410,6 +411,9 @@ static DBusMessage *hfp_agent_release(DBusConnection
> *conn, DBusMessage *msg, void *data)
> {
> struct ofono_modem *modem = data;
> + const char * path;
> +
> + path = dbus_message_get_path(msg);
Whats this part for?
>
> ofono_modem_remove(modem);
>
> @@ -427,6 +431,10 @@ static int hfp_create_modem(const char *device)
> {
> struct ofono_modem *modem;
> struct hfp_data *data;
> + const char *path;
> +
> + if (g_hash_table_lookup(uuid_hash, device))
> + return -EALREADY;
I suggest we move this check to parse_uuids.
>
> ofono_info("Using device: %s", device);
>
> @@ -451,6 +459,9 @@ static int hfp_create_modem(const char *device)
> ofono_modem_set_data(modem, data);
> ofono_modem_register(modem);
>
> + path = ofono_modem_get_path(modem);
> + g_hash_table_insert(uuid_hash, g_strdup(device), g_strdup(path));
> +
> return 0;
>
> free:
> @@ -624,6 +635,33 @@ static gboolean adapter_added(DBusConnection
> *connection, DBusMessage *message, return TRUE;
> }
>
> +static gboolean uuid_emitted(DBusConnection *connection, DBusMessage
> *message, + void *user_data)
> +{
> + const char *device, *property;
> + DBusMessageIter iter;
> +
> + dbus_message_iter_init(message, &iter);
> +
> + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
> + return FALSE;
> +
> + dbus_message_iter_get_basic(&iter, &property);
> + if (g_str_equal(property, "UUIDs") == FALSE)
> + return TRUE;
> +
> + if (!dbus_message_iter_next(&iter))
> + return FALSE;
> +
> + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_VARIANT)
> + return FALSE;
> +
> + device = dbus_message_get_path(message);
> + parse_uuids(&iter, device);
> +
> + return TRUE;
> +}
> +
> static void list_adapters_cb(DBusPendingCall *call, gpointer user_data)
> {
> DBusError err;
> @@ -725,6 +763,8 @@ static void hfp_remove(struct ofono_modem *modem)
>
> hfp_unregister_ofono_handsfree(modem);
>
> + g_hash_table_remove(uuid_hash, data->handsfree_path);
> +
> g_free(data->handsfree_path);
> g_free(data);
>
> @@ -798,7 +838,8 @@ static struct ofono_modem_driver hfp_driver = {
> .post_sim = hfp_post_sim,
> };
>
> -static guint added_watch;
> +static guint adapter_watch;
> +static guint uuid_watch;
>
> static int hfp_init(void)
> {
> @@ -809,12 +850,21 @@ static int hfp_init(void)
>
> connection = ofono_dbus_get_connection();
>
> - added_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
> + adapter_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
> BLUEZ_MANAGER_INTERFACE,
> "AdapterAdded",
> adapter_added, NULL, NULL);
>
> - if (added_watch == 0) {
> + uuid_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
> + BLUEZ_DEVICE_INTERFACE,
> + "PropertyChanged",
> + uuid_emitted, NULL, NULL);
> +
> +
> + uuid_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
> + g_free, g_free);
> +
> + if (adapter_watch == 0 || uuid_watch == 0) {
> err = -EIO;
> goto remove;
> }
> @@ -828,7 +878,9 @@ static int hfp_init(void)
> return 0;
>
> remove:
> - g_dbus_remove_watch(connection, added_watch);
> + g_dbus_remove_watch(connection, adapter_watch);
> + g_dbus_remove_watch(connection, uuid_watch);
> + g_hash_table_destroy(uuid_hash);
>
> dbus_connection_unref(connection);
>
> @@ -837,7 +889,9 @@ remove:
>
> static void hfp_exit(void)
> {
> - g_dbus_remove_watch(connection, added_watch);
> + g_dbus_remove_watch(connection, adapter_watch);
> + g_dbus_remove_watch(connection, uuid_watch);
> + g_hash_table_destroy(uuid_hash);
>
> ofono_modem_driver_unregister(&hfp_driver);
> }
>
next prev parent reply other threads:[~2010-02-04 21:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-04 21:30 [PATCH 1/3] hfp: create modem for new devices paired on runtime Gustavo F. Padovan
2010-02-04 21:30 ` [PATCH 2/3] hfp: Don't call UnregisterAgent if a Release was received Gustavo F. Padovan
2010-02-04 21:30 ` [PATCH 3/3] hfp: wait Disconnect reply to power down the modem Gustavo F. Padovan
2010-02-04 22:00 ` [PATCH 2/3] hfp: Don't call UnregisterAgent if a Release was received Denis Kenzior
2010-02-04 21:58 ` Denis Kenzior [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-02-05 18:47 [PATCH 1/3] hfp: create modem for new devices paired on runtime Gustavo F. Padovan
2010-02-05 19:36 ` Denis Kenzior
2010-07-08 7:03 ` =?unknown-8bit?q?R=C3=A9mi?= Denis-Courmont
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=201002041558.06215.denkenz@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 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.