#endif
int _wifi_aware_peer_create(wifi_aware_peer_h *peer, unsigned int peer_id);
+void _wifi_aware_peer_destroy(wifi_aware_peer_h peer);
int _wifi_aware_peer_add(GHashTable *peer_map, wifi_aware_peer_h peer);
int _wifi_aware_peer_remove(GHashTable *peer_map, wifi_aware_peer_h peer);
wifi_aware_peer_h _wifi_aware_get_peer(GHashTable *peer_map, unsigned int peer_id);
bool _wifi_aware_is_initialized();
int _wifi_aware_init();
+int _wifi_aware_deinit();
void _add_enabled_callback(wifi_aware_enabled_cb callback, void *user_data);
int _wifi_aware_enable_request();
int _wifi_aware_is_enabled();
int _wifi_aware_disable_request();
int _wifi_aware_session_handle_create(wifi_aware_session_type_e session_type, wifi_aware_session_h *session_handle);
-int _wifi_aware_session_handle_destroy(wifi_aware_session_h session_handle);
+void _wifi_aware_session_handle_destroy(wifi_aware_session_h session_handle);
wifi_aware_session_type_e _wifi_aware_session_get_type(wifi_aware_session_h session_handle);
int _wifi_aware_publish_handle_create(wifi_aware_publish_h *publish);
return WIFI_AWARE_ERROR_OPERATION_FAILED;
}
+ g_object_unref(gdbus_data.cancellable);
+ gdbus_data.cancellable = NULL;
- /* TODO: unsubscribe signal */
+ // TODO: How to unsubscribe all signals
g_object_unref(gdbus_data.connection);
gdbus_data.connection = NULL;
return WIFI_AWARE_ERROR_NONE;
}
+void _wifi_aware_peer_destroy(wifi_aware_peer_h peer)
+{
+ g_free((wifi_aware_peer_s *)peer);
+}
+
int _wifi_aware_peer_add(GHashTable *peer_map, wifi_aware_peer_h peer)
{
wifi_aware_peer_s *peer_handle = (wifi_aware_peer_s *)peer;
return "Not supported";
case WIFI_AWARE_ERROR_OPERATION_FAILED:
return "Operation failed";
+ case WIFI_AWARE_ERROR_NOT_INITIALIZED:
+ return "Not Initialized";
+ case WIFI_AWARE_ERROR_ALREADY_INITIALIZED:
+ return "Already Initialized";
default:
return "Unknown error";
}
return WIFI_AWARE_ERROR_OUT_OF_MEMORY;
}
- g_wifi_aware->peer_map = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
+ g_wifi_aware->peer_map =
+ g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, _wifi_aware_peer_destroy);
WIFI_AWARE_LOGI("Create wifi_aware_s [%p]", g_wifi_aware);
return WIFI_AWARE_ERROR_NONE;
}
+static void __wifi_aware_destroy()
+{
+ g_hash_table_remove_all(g_wifi_aware->peer_map);
+ g_hash_table_unref(g_wifi_aware->peer_map);
+ g_free(g_wifi_aware);
+ g_wifi_aware = NULL;
+}
+
bool _wifi_aware_is_initialized()
{
return __is_init;
return WIFI_AWARE_ERROR_NONE;
}
+int _wifi_aware_deinit()
+{
+ if (!__is_init) {
+ WIFI_AWARE_LOGE("Already initialized");
+ return WIFI_AWARE_ERROR_NOT_INITIALIZED;
+ }
+
+ __wifi_aware_destroy();
+ wifi_aware_gdbus_deinit();
+
+ __is_init = false;
+
+ return WIFI_AWARE_ERROR_NONE;
+}
+
void _add_enabled_callback(wifi_aware_enabled_cb callback, void *user_data)
{
g_wifi_aware->enabled_cb = callback;
return WIFI_AWARE_ERROR_NONE;
}
-int _wifi_aware_session_handle_destroy(wifi_aware_session_h session_handle)
+void _wifi_aware_session_handle_destroy(wifi_aware_session_h session_handle)
{
// TODO
+ // publish_config and subscribe_config should be destroyed by
+ // wifi_aware_publish_destroy and wifi_aware_subscribe_destroy
g_free(session_handle);
- return WIFI_AWARE_ERROR_NONE;
}
int _wifi_aware_publish_handle_create(wifi_aware_publish_h *publish)
API int wifi_aware_deinitialize()
{
+ int ret = WIFI_AWARE_ERROR_NONE;
+
__WIFI_AWARE_FUNC_ENTER__;
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
- RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
- // TODO
+ ret = _wifi_aware_deinit();
+ RET_VAL_IF(ret != WIFI_AWARE_ERROR_NONE, ret, "_wifi_aware_deinit failed [%s]",
+ _wifi_aware_convert_error_type_to_string(ret));
__WIFI_AWARE_FUNC_EXIT__;
return WIFI_AWARE_ERROR_NONE;
API int wifi_aware_session_destroy(wifi_aware_session_h session)
{
- int ret = WIFI_AWARE_ERROR_NONE;
-
__WIFI_AWARE_FUNC_ENTER__;
CHECK_FEATURE_SUPPORTED(TIZEN_FEATURE_WIFI_AWARE);
RET_VAL_IF(!_wifi_aware_is_initialized(), WIFI_AWARE_ERROR_NOT_INITIALIZED, "Not initialized");
RET_VAL_IF(session == NULL, WIFI_AWARE_ERROR_INVALID_PARAMETER, "wifi_aware_session_h is NULL");
- ret = _wifi_aware_session_handle_destroy(session);
- RET_VAL_IF(ret != WIFI_AWARE_ERROR_NONE, ret, "Fail to destroy session handle");
+ _wifi_aware_session_handle_destroy(session);
return WIFI_AWARE_ERROR_NONE;
}