summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2013-01-30 13:24:16 -0300
committerDenis Kenzior <denkenz@gmail.com>2013-01-30 21:36:49 -0600
commit5b56668f1eee62199a9c7ec5e416393a65db7bf5 (patch)
treeb73b7aa6c454e7ab2d5b9ca7a90082568b68f8aa
parent5185980fb0782f88d5f76db15f101969cf5d0ec0 (diff)
downloadofono-5b56668f1eee62199a9c7ec5e416393a65db7bf5.tar.bz2
hfp_hf_bluez5: Only register modems for Paired devices
When there are many devices around that support the HFP AG profile, we may have a lot of modems that the user will never use.
-rw-r--r--plugins/hfp_hf_bluez5.c61
1 files changed, 41 insertions, 20 deletions
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 653829b1..8cac9454 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -479,20 +479,18 @@ static gboolean has_hfp_ag_uuid(DBusMessageIter *array)
return FALSE;
}
-static void proxy_added(GDBusProxy *proxy, void *user_data)
+static void modem_register_from_proxy(GDBusProxy *proxy, const char *path)
{
- const char *interface, *path, *alias, *address;
+ const char *alias, *remote;
DBusMessageIter iter;
+ dbus_bool_t paired;
- interface = g_dbus_proxy_get_interface(proxy);
- path = g_dbus_proxy_get_path(proxy);
-
- if (g_str_equal(BLUEZ_DEVICE_INTERFACE, interface) == FALSE)
+ if (g_dbus_proxy_get_property(proxy, "Paired", &iter) == FALSE)
return;
- g_hash_table_insert(devices_proxies, g_strdup(path),
- g_dbus_proxy_ref(proxy));
- DBG("Device proxy: %s(%p)", path, proxy);
+ dbus_message_iter_get_basic(&iter, &paired);
+ if (paired == FALSE)
+ return;
if (g_dbus_proxy_get_property(proxy, "UUIDs", &iter) == FALSE)
return;
@@ -509,9 +507,26 @@ static void proxy_added(GDBusProxy *proxy, void *user_data)
if (g_dbus_proxy_get_property(proxy, "Address", &iter) == FALSE)
return;
- dbus_message_iter_get_basic(&iter, &address);
+ dbus_message_iter_get_basic(&iter, &remote);
+
+ modem_register(path, remote, alias);
+}
+
+static void proxy_added(GDBusProxy *proxy, void *user_data)
+{
+ const char *interface, *path;
+
+ interface = g_dbus_proxy_get_interface(proxy);
+ path = g_dbus_proxy_get_path(proxy);
- modem_register(path, address, alias);
+ if (g_str_equal(BLUEZ_DEVICE_INTERFACE, interface) == FALSE)
+ return;
+
+ g_hash_table_insert(devices_proxies, g_strdup(path),
+ g_dbus_proxy_ref(proxy));
+ DBG("Device proxy: %s(%p)", path, proxy);
+
+ modem_register_from_proxy(proxy, path);
}
static void proxy_removed(GDBusProxy *proxy, void *user_data)
@@ -538,27 +553,33 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data)
static void property_changed(GDBusProxy *proxy, const char *name,
DBusMessageIter *iter, void *user_data)
{
- const char *interface, *path, *alias;
+ const char *interface, *path;
struct ofono_modem *modem;
interface = g_dbus_proxy_get_interface(proxy);
path = g_dbus_proxy_get_path(proxy);
- DBG("path: %s interface: %s", path, interface);
-
if (g_str_equal(BLUEZ_DEVICE_INTERFACE, interface) == FALSE)
return;
- if (g_str_equal("Alias", name) == FALSE)
+ if (g_str_equal("Paired", name) == TRUE) {
+ modem_register_from_proxy(proxy, path);
return;
+ }
- dbus_message_iter_get_basic(iter, &alias);
+ if (g_str_equal("Alias", name) == TRUE) {
+ const char *alias;
- modem = g_hash_table_lookup(modem_hash, path);
- if (modem == NULL)
- return;
+ dbus_message_iter_get_basic(iter, &alias);
- ofono_modem_set_name(modem, alias);
+ modem = g_hash_table_lookup(modem_hash, path);
+ if (modem == NULL)
+ return;
+
+ DBG("path: %s Alias: %s", path, alias);
+
+ ofono_modem_set_name(modem, alias);
+ }
}
static int hfp_init(void)