Handle error return code
authorJiwan Kim <ji-wan.kim@samsung.com>
Wed, 14 Jun 2017 10:12:40 +0000 (19:12 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 17 Jul 2017 02:09:10 +0000 (11:09 +0900)
- 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

include/mesh.h
include/mesh_dbus.h
src/mesh.c
src/mesh_dbus.c
test/mesh_network.c

index ae8bf0919d6987fa76dc6a7ea55f64bcb6ae4090..681e2fe3f9a127db6d3e921d18a521892f4a4103 100644 (file)
@@ -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.
index b75e70487eb03fb7e82fa6a31b99d0c72d597f0a..6b579fcc9e6e96427f5ebef177d4320a8dcbd18d 100644 (file)
@@ -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);
index 8b9d55cd3a87c20030f723c4b3a55dd5052e81ee..9fe0c83ad5160f86c545d590d2d3b7289fd0174d 100644 (file)
@@ -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);
index 3c9f0b827a98d3f52f13d04cec21616983ffa261..0bd95b13353f3b03278ec3253db83dba4513e974 100644 (file)
@@ -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);
index 889d6df8948dab276ae563a104953886cd3ba64a..922b0549e85e26492605167457cc3f964cee5c7b 100644 (file)
@@ -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)]",