From: Jiwan Kim Date: Wed, 14 Jun 2017 10:12:40 +0000 (+0900) Subject: Handle error return code X-Git-Tag: submit/tizen/20170828.225740~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a2a8159d35d08dcb85b633d5b6d6e2220e977bc8;p=platform%2Fcore%2Fapi%2Fwifi-mesh.git Handle error return code - Change to return valid return code on repeated call. mesh_enable_mesh mesh_disable_mesh - Change policy of return code mesh_cancel_scan mesh_disable_softap - Add method mesh_is_joined --- diff --git a/include/mesh.h b/include/mesh.h index ae8bf09..681e2fe 100644 --- a/include/mesh.h +++ b/include/mesh.h @@ -891,7 +891,7 @@ int mesh_disable_mesh(mesh_h handle); * @see mesh_found_mesh_network_cb() * */ -int mesh_is_joined(mesh_h handle, int* is_joined); +int mesh_is_joined(mesh_h handle, bool* is_joined); /** * @brief Gets current joined mesh network information. diff --git a/include/mesh_dbus.h b/include/mesh_dbus.h index b75e704..6b579fc 100644 --- a/include/mesh_dbus.h +++ b/include/mesh_dbus.h @@ -50,7 +50,7 @@ int _mesh_foreach_connected_peers(mesh_h handle, mesh_connected_peer_cb cb, void *user_data); int _mesh_enable_mesh(mesh_h handle); int _mesh_disable_mesh(mesh_h handle); -int _mesh_is_joined(mesh_h handle, int* is_joined); +int _mesh_is_joined(mesh_h handle, bool* is_joined); int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network); int _mesh_set_gate(mesh_h handle, bool stp, bool gate_announce); int _mesh_unset_gate(mesh_h handle); diff --git a/src/mesh.c b/src/mesh.c index 8b9d55c..9fe0c83 100644 --- a/src/mesh.c +++ b/src/mesh.c @@ -584,7 +584,7 @@ EXPORT_API int mesh_disable_mesh(mesh_h handle) return rv; } -EXPORT_API int mesh_is_joined(mesh_h handle, int* is_joined) +EXPORT_API int mesh_is_joined(mesh_h handle, bool* is_joined) { int rv = 0; CHECK_FEATURE_SUPPORTED(MESH_FEATURE); diff --git a/src/mesh_dbus.c b/src/mesh_dbus.c index 3c9f0b8..0bd95b1 100644 --- a/src/mesh_dbus.c +++ b/src/mesh_dbus.c @@ -797,25 +797,27 @@ int _mesh_disable_mesh(mesh_h handle) } /* TODO: Parameter verification required */ -int _mesh_is_joined(mesh_h handle, int* is_joined) +int _mesh_is_joined(mesh_h handle, bool* is_joined) { GVariant *variant = NULL; int result = MESH_ERROR_NONE; GError *error = NULL; + gboolean state; struct mesh_handle *h = handle; RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "is_joined", - g_variant_new("(b)", (is_joined == 0) ? FALSE : TRUE), + NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); if (variant) { - g_variant_get(variant, "(i)", &result); + g_variant_get(variant, "(bi)", &state, &result); LOGD("Mesh is_joined status 0x%x", result); result = __convert_service_error_type(result); + *is_joined = ((state) ? true : false); } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); diff --git a/test/mesh_network.c b/test/mesh_network.c index 889d6df..922b054 100644 --- a/test/mesh_network.c +++ b/test/mesh_network.c @@ -249,12 +249,20 @@ static int run_get_joined_mesh_network(MManager *mm, struct menu_data *menu) char *_meshid = NULL; char *_bssid = NULL; int _channel = -1; + bool joined = false; mesh_connection_state_e _state = MESH_CONNECTION_STATE_DISCONNECTED; mesh_security_type_e _security = MESH_SECURITY_NONE; mesh_network_h network = NULL; msg("Get Joined Mesh Network Information"); + ret = mesh_is_joined(mesh, &joined); + if (MESH_ERROR_NONE != ret) { + msgr("Failed to check network join status: [%s(0x%X)]", + mesh_error_to_string(ret), ret); + return RET_FAILURE; + } + ret = mesh_get_joined_network(mesh, &network); if (MESH_ERROR_NONE != ret) { msgr("Failed to get joined mesh network: [%s(0x%X)]",