From c7f58a22f384dce76858ffdf1ab3a6a987c4e59f Mon Sep 17 00:00:00 2001 From: Oleg Zhurakivskyy Date: Tue, 19 Aug 2014 13:36:50 +0300 Subject: Handle device interface changes. --- lib/neardal_adapter.c | 4 ++-- lib/neardal_manager.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/neardal_adapter.c b/lib/neardal_adapter.c index 2638423..9dd15d5 100644 --- a/lib/neardal_adapter.c +++ b/lib/neardal_adapter.c @@ -95,7 +95,7 @@ void neardal_adp_prv_cb_tag_lost(OrgNeardTag *proxy, * neardal_adp_prv_cb_dev_found: Callback called when a NFC dev is * found ****************************************************************************/ -static void neardal_adp_prv_cb_dev_found(OrgNeardDevice *proxy, +void neardal_adp_prv_cb_dev_found(OrgNeardDevice *proxy, const gchar *arg_unnamed_arg0, void *user_data) { @@ -125,7 +125,7 @@ static void neardal_adp_prv_cb_dev_found(OrgNeardDevice *proxy, * neardal_adp_prv_cb_dev_lost: Callback called when a NFC dev is * lost (removed) ****************************************************************************/ -static void neardal_adp_prv_cb_dev_lost(OrgNeardDevice *proxy, +void neardal_adp_prv_cb_dev_lost(OrgNeardDevice *proxy, const gchar *arg_unnamed_arg0, void *user_data) { diff --git a/lib/neardal_manager.c b/lib/neardal_manager.c index 547375d..f5e7de0 100644 --- a/lib/neardal_manager.c +++ b/lib/neardal_manager.c @@ -96,6 +96,20 @@ error: g_free(adapter); } +void neardal_adp_prv_cb_dev_found(OrgNeardDevice *proxy, + const gchar *arg_unnamed_arg0, void *user_data); +void neardal_adp_prv_cb_dev_lost(OrgNeardDevice *proxy, + const gchar *arg_unnamed_arg0, void *user_data); + +static AdpProp *neardal_adapter_find_by_child(const char *path) +{ + char *name = neardal_dirname(path); + AdpProp *adapter = NULL; + neardal_mgr_prv_get_adapter((char *) path, &adapter); + g_free(name); + return adapter; +} + static void neardal_mgr_interfaces_added(ObjectManager *om, const gchar *path, GVariant *interfaces) { @@ -112,6 +126,14 @@ static void neardal_mgr_interfaces_added(ObjectManager *om, return; } + if (g_variant_lookup(interfaces, "org.neard.Device", "*", + (void *) &v)) { + AdpProp *adp = neardal_adapter_find_by_child(path); + if (adp) + neardal_adp_prv_cb_dev_found(NULL, path, adp); + return; + } + if (g_variant_lookup(interfaces, "org.neard.Tag", "*", (void *) &v)) { neardal_mgr_tag_add(path, v); return; @@ -175,6 +197,13 @@ static void neardal_mgr_interfaces_removed(ObjectManager *om, continue; } + if (strcmp(s, "org.neard.Device") == 0) { + AdpProp *adp = neardal_adapter_find_by_child(path); + if (adp) + neardal_adp_prv_cb_dev_lost(NULL, path, adp); + continue; + } + if (strcmp(s, "org.freedesktop.DBus.Properties") == 0) continue; if (strcmp(s, "org.freedesktop.DBus.Introspectable") == 0) -- cgit v1.2.3