Add tethering handle list 83/132883/1 accepted/tizen/unified/20170612.171439 submit/tizen/20170612.082510
authorSeonah Moon <seonah1.moon@samsung.com>
Thu, 8 Jun 2017 06:59:11 +0000 (15:59 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Thu, 8 Jun 2017 06:59:11 +0000 (15:59 +0900)
Change-Id: I178cc28ed14eeb3c9e6e05c5e0d9cc71e00bc18a

include/tethering_private.h
packaging/capi-network-tethering.spec
src/tethering.c
src/tethering_private.c

index f05706f..7576e43 100644 (file)
@@ -325,6 +325,10 @@ typedef struct {
        int channel;
 } _softap_settings_t;
 
+void _tethering_add_handle(tethering_h handle);
+void _tethering_remove_handle(tethering_h handle);
+bool _tethering_check_handle(tethering_h handle);
+
 #ifdef __cplusplus
 }
 #endif
index fde2a89..03873ae 100644 (file)
@@ -1,6 +1,6 @@
 Name:          capi-network-tethering
 Summary:       Tethering Framework
-Version:       1.0.49
+Version:       1.0.50
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index b190125..d159e5a 100755 (executable)
@@ -765,6 +765,9 @@ static void __wifi_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        tethering_enabled_cb ecb = th->enabled_cb[TETHERING_TYPE_WIFI];
        void *data = th->enabled_user_data[TETHERING_TYPE_WIFI];
 
+       if (!_tethering_check_handle((tethering_h)user_data))
+               return;
+
        g_var  = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
        if (g_error) {
                //LCOV_EXCL_START
@@ -816,6 +819,9 @@ static void __bt_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        tethering_enabled_cb ecb = th->enabled_cb[TETHERING_TYPE_BT];
        void *data = th->enabled_user_data[TETHERING_TYPE_BT];
 
+       if (!_tethering_check_handle((tethering_h)user_data))
+               return;
+
        g_var  = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
        if (g_error) {
                //LCOV_EXCL_START
@@ -869,6 +875,9 @@ static void __usb_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        tethering_enabled_cb ecb = th->enabled_cb[TETHERING_TYPE_USB];
        void *data = th->enabled_user_data[TETHERING_TYPE_USB];
 
+       if (!_tethering_check_handle((tethering_h)user_data))
+               return;
+
        g_var  = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
        if (g_error) {
                ERR("DBus error [%s]\n", g_error->message);
@@ -920,6 +929,9 @@ static void __p2p_enabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        tethering_enabled_cb ecb = th->enabled_cb[TETHERING_TYPE_P2P];
        void *data = th->enabled_user_data[TETHERING_TYPE_P2P];
 
+       if (!_tethering_check_handle((tethering_h)user_data))
+               return;
+
        g_var  = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
        if (g_error) {
                ERR("DBus error [%s]\n", g_error->message);
@@ -968,6 +980,9 @@ static void __disabled_cfm_cb(GObject *source_object, GAsyncResult *res,
        tethering_disabled_cb dcb = NULL;
        void *data = NULL;
 
+       if (!_tethering_check_handle((tethering_h)user_data))
+               return;
+
        g_var  = g_dbus_proxy_call_finish(th->client_bus_proxy, res, &g_error);
        if (g_error) {
                //LCOV_EXCL_START
@@ -1485,6 +1500,7 @@ API int tethering_create(tethering_h *tethering)
        __connect_signals((tethering_h)th);
 
        *tethering = (tethering_h)th;
+       _tethering_add_handle(th);
        INFO("Tethering Handle : 0x%X\n", th);
        INFO("-\n");
        return TETHERING_ERROR_NONE;
@@ -1522,6 +1538,8 @@ API int tethering_destroy(tethering_h tethering)
        g_object_unref(th->client_bus_proxy);
        g_object_unref(th->client_bus);
        memset(th, 0x00, sizeof(__tethering_h));
+
+       _tethering_remove_handle(th);
        free(th);
 
        INFO("-\n");
index 5bacc30..5d11cb2 100755 (executable)
@@ -21,6 +21,7 @@
 
 static __thread bool is_feature_checked[TETHERING_SUPPORTED_FEATURE_MAX] = {0, };
 static __thread bool feature_supported[TETHERING_SUPPORTED_FEATURE_MAX] = {0, };
+static __thread GSList *tethering_handle_list = NULL;
 
 bool __check_feature_supported(const char *key, tethering_supported_feature_e feature)
 {
@@ -75,3 +76,22 @@ int _tethering_check_feature_supported(const char* feature, ...)
 
        return TETHERING_ERROR_NONE;
 }
+
+void _tethering_add_handle(tethering_h handle)
+{
+       tethering_handle_list = g_slist_append(tethering_handle_list, handle);
+}
+
+void _tethering_remove_handle(tethering_h handle)
+{
+       tethering_handle_list = g_slist_remove(tethering_handle_list, handle);
+}
+
+bool _tethering_check_handle(tethering_h handle)
+{
+       if (g_slist_find(tethering_handle_list, handle) != NULL)
+               return true;
+       else
+               return false;
+}
+