Update powered status in the daemon 46/20946/1 tizen_3.0.m14.2_ivi accepted/tizen/common/20140519.224022 accepted/tizen/ivi/20140521.165031 submit/tizen/20140515.021553 submit/tizen_common/20140521.163740 submit/tizen_common/20140521.232441 submit/tizen_common/20140522.130648 submit/tizen_common/20140522.135644 submit/tizen_common/20140522.140947 tizen_3.0.m14.2_ivi_release
authorArron Wang <arron.wang@intel.com>
Tue, 13 May 2014 07:23:23 +0000 (15:23 +0800)
committerArron Wang <arron.wang@intel.com>
Wed, 14 May 2014 06:45:05 +0000 (14:45 +0800)
only the daemon have the privilege to change the vconf status

Change-Id: I234b8896536d284201349a5f6a0b073730549d4c

client/net_nfc_neard.c
daemon/net_nfc_server.c

index 25df3dc..c2eafe1 100644 (file)
@@ -275,8 +275,6 @@ static void _power_completed_cb(errorCode_t error_code, void *user_data)
 
        NFC_DBG("power completed %d", neard_adapter->powered);
        powered = (neard_adapter->powered) ? true : false;
-       if (vconf_set_bool(VCONFKEY_NFC_STATE, powered) != 0)
-               NFC_DBG("vconf_set_bool failed ");
 
        if (powered == true) {
                if (nfc_adapter_polling == false) {
index ef4bfb8..1d16359 100644 (file)
@@ -310,6 +310,23 @@ static void on_name_lost(GDBusConnection *connnection, const gchar *name,
        net_nfc_manager_quit();
 }
 
+static void _adapter_property_changed_cb(char *name, char *property,
+                                       void *value, void *user_data)
+{
+       bool powered;
+
+       if (!g_strcmp0(property, "Powered")) {
+               if ((int *) value == 0)
+                       powered = false;
+               else
+                       powered = true;
+
+               NFC_DBG("power changed %d", powered);
+               if (vconf_set_bool(VCONFKEY_NFC_STATE, powered) != 0)
+                       NFC_DBG("vconf_set_bool failed ");
+       }
+}
+
 static bool net_nfc_neard_nfc_support(void)
 {
        char **adapters = NULL;
@@ -331,6 +348,10 @@ static bool net_nfc_neard_nfc_support(void)
                                neard_adapter->powered) != 0)
                        NFC_ERR("VCONFKEY_NFC_STATE set to %d failed",
                                                neard_adapter->powered);
+
+               if (neardal_set_cb_adapter_property_changed(
+                       _adapter_property_changed_cb, NULL) != NEARDAL_SUCCESS)
+                       NFC_ERR("Failed to register property changed cb");
        }
 
        if (adapters)
@@ -341,7 +362,6 @@ static bool net_nfc_neard_nfc_support(void)
 
        adapters = NULL;
        neard_adapter = NULL;
-       neardal_destroy();
 
        return true;
 }