summaryrefslogtreecommitdiffstats
path: root/plugins/hfp_hf_bluez5.c
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2013-01-23 15:27:52 -0300
committerDenis Kenzior <denkenz@gmail.com>2013-01-23 14:13:37 -0600
commit63cd9a740afbb4fa05ecc3110bee0dc7e389d63b (patch)
tree14144706cd0664420fe1b5d03d083226c36eaf2e /plugins/hfp_hf_bluez5.c
parentcdd99c3d5fd40bb6bf63440bcd027f8b6432cc53 (diff)
downloadofono-63cd9a740afbb4fa05ecc3110bee0dc7e389d63b.tar.bz2
hfp_hf_bluez5: Initial GDBusClient for BlueZ
This patch adds the initial callbacks to track when BlueZ connects so we can register our HFP external profile handler. And tracks the interfaces added or removed.
Diffstat (limited to 'plugins/hfp_hf_bluez5.c')
-rw-r--r--plugins/hfp_hf_bluez5.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index e0248384..61e66690 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,43 @@ static const GDBusMethodTable profile_methods[] = {
{ }
};
+static void connect_handler(DBusConnection *conn, void *user_data)
+{
+ DBG("Registering External Profile handler ...");
+
+ bluetooth_register_profile(conn, HFP_HS_UUID, "hfp_hf",
+ HFP_EXT_PROFILE_PATH);
+}
+
+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();
@@ -168,15 +207,18 @@ static int hfp_init(void)
return err;
}
- err = bluetooth_register_profile(conn, HFP_HS_UUID, "hfp_hf",
- HFP_EXT_PROFILE_PATH);
- if (err < 0) {
+ bluez = g_dbus_client_new(conn, BLUEZ_SERVICE, BLUEZ_MANAGER_PATH);
+ if (bluez == NULL) {
g_dbus_unregister_interface(conn, HFP_EXT_PROFILE_PATH,
BLUEZ_PROFILE_INTERFACE);
ofono_modem_driver_unregister(&hfp_driver);
- return err;
+ return -ENOMEM;
}
+ g_dbus_client_set_connect_watch(bluez, connect_handler, NULL);
+ g_dbus_client_set_proxy_handlers(bluez, proxy_added, proxy_removed,
+ property_changed, NULL);
+
return 0;
}
@@ -188,6 +230,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,