summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>2014-08-19 13:36:50 +0300
committerSamuel Ortiz <sameo@linux.intel.com>2014-09-08 00:38:53 +0200
commitc7f58a22f384dce76858ffdf1ab3a6a987c4e59f (patch)
treecaaae895f5794eab3a739778320670f0918a56f3 /lib
parent83742b781bef8cc160c2b1d055c7924c828d59e8 (diff)
downloadneardal-c7f58a22f384dce76858ffdf1ab3a6a987c4e59f.tar.gz
neardal-c7f58a22f384dce76858ffdf1ab3a6a987c4e59f.tar.bz2
neardal-c7f58a22f384dce76858ffdf1ab3a6a987c4e59f.zip
Handle device interface changes.
Diffstat (limited to 'lib')
-rw-r--r--lib/neardal_adapter.c4
-rw-r--r--lib/neardal_manager.c29
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)