From: Jiwan Kim Date: Thu, 1 Jun 2017 05:41:28 +0000 (+0900) Subject: Remove internal error enumeration X-Git-Tag: submit/tizen/20170828.225740~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4239dbbcf6f8f8eb15094cddaf9291dbbc7da272;p=platform%2Fcore%2Fapi%2Fwifi-mesh.git Remove internal error enumeration - Remove 'MESH_ITNL_ERR_*' as it is not useless now. - Adjust mesh_error_e enum values to support internal errors. --- diff --git a/include/mesh.h b/include/mesh.h index ce9876e..4879f7f 100644 --- a/include/mesh.h +++ b/include/mesh.h @@ -55,12 +55,13 @@ typedef enum { MESH_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */ MESH_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ MESH_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */ - MESH_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Now in progress */ - MESH_ERROR_OPERATION_FAILED = TIZEN_ERROR_MESH|0x01, /**< Operation failed */ - MESH_ERROR_OPERATION_ABORTED = TIZEN_ERROR_MESH|0x02, /**< Operation is aborted */ + MESH_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Operation already in progress */ + MESH_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /**< Operation now in progress */ MESH_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission Denied */ MESH_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< DBus error */ - MESH_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not Supported */ + MESH_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not Supported */ + MESH_ERROR_OPERATION_FAILED = TIZEN_ERROR_MESH | 0x01, /**< Operation failed */ + MESH_ERROR_OPERATION_ABORTED = TIZEN_ERROR_MESH | 0x02, /**< Operation is aborted */ } mesh_error_e; /** diff --git a/include/mesh_private.h b/include/mesh_private.h index d7dcba1..73e10d3 100644 --- a/include/mesh_private.h +++ b/include/mesh_private.h @@ -47,26 +47,10 @@ } #else #define CHECK_FEATURE_SUPPORTED(feature_name) { \ - LOGE("Should be check !"); \ + LOGE("[Feature] Should be check !"); \ } #endif -/** - * Enumeration for the Mesh internal error types. - */ -typedef enum { - MESH_ITNL_ERR_NONE = 0x0, - - MESH_ITNL_ERR_UNKNOWN = -0xFF, /**< Unknown error */ - - MESH_ITNL_ERR_ALREADY_REGISTERED = -0xF0, /**< Application is already registered */ - MESH_ITNL_ERR_OUT_OF_MEMORY = -0xF1, /**< Out of memory */ - MESH_ITNL_ERR_OPERATION_FAILED = -0xF2, /**< Operation failed */ - MESH_ITNL_ERR_NOT_SUPPORTED = -0xF3, /**< Not Supported */ - MESH_ITNL_ERR_INVALID_PARAM = -0xF4, /** Invalid value of API parameter */ - MESH_ITNL_ERR_IO_ERROR = -0xF5, /** DBus error */ -} mesh_internal_err_e; - typedef struct mesh_handle { gpointer dbus_connection; GCancellable *ca; @@ -146,6 +130,4 @@ struct mesh_mpath_dump_s { #define NOTUSED(var) (var = var) -const char* _mesh_internal_error_to_string(mesh_internal_err_e err); - #endif /* __CAPI_MESH_PRIVATE_H__ */ diff --git a/src/mesh.c b/src/mesh.c index c78e344..593b09f 100644 --- a/src/mesh.c +++ b/src/mesh.c @@ -302,7 +302,7 @@ EXPORT_API int mesh_initialize(mesh_h *mesh) rv = _mesh_dbus_start(*mesh); if (rv != MESH_ERROR_NONE) { - LOGD("D-Bus init: [%s](0x%X)", _mesh_internal_error_to_string(rv), rv); + LOGD("D-Bus init: (0x%X)", rv); } return MESH_ERROR_NONE; @@ -327,11 +327,7 @@ EXPORT_API int mesh_set_event_cb(mesh_h handle, mesh_event_cb event_handler) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_set_event_cb(handle, event_handler); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_enable(mesh_h handle) @@ -342,11 +338,7 @@ EXPORT_API int mesh_enable(mesh_h handle) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_enable(handle); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_disable(mesh_h handle) @@ -357,11 +349,7 @@ EXPORT_API int mesh_disable(mesh_h handle) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_disable(handle); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_scan(mesh_h handle) @@ -372,11 +360,7 @@ EXPORT_API int mesh_scan(mesh_h handle) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_scan(handle); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_cancel_scan(mesh_h handle) @@ -387,11 +371,7 @@ EXPORT_API int mesh_cancel_scan(mesh_h handle) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_cancel_scan(handle); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_specific_scan(mesh_h handle, const char* ssid, int channel) @@ -403,11 +383,7 @@ EXPORT_API int mesh_specific_scan(mesh_h handle, const char* ssid, int channel) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_specific_scan(handle, ssid, channel); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_foreach_found_mesh_network(mesh_h handle, @@ -420,16 +396,12 @@ EXPORT_API int mesh_foreach_found_mesh_network(mesh_h handle, RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_get_scan_result(handle); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; + if (MESH_ERROR_NONE != rv) { + return rv; } rv = _mesh_foreach_found_mesh_network(handle, cb, user_data); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_enable_mesh(mesh_h handle) @@ -440,11 +412,7 @@ EXPORT_API int mesh_enable_mesh(mesh_h handle) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_enable_mesh(handle); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_disable_mesh(mesh_h handle) @@ -455,11 +423,7 @@ EXPORT_API int mesh_disable_mesh(mesh_h handle) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_disable_mesh(handle); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_is_joined(mesh_h handle, int* is_joined) @@ -470,11 +434,7 @@ EXPORT_API int mesh_is_joined(mesh_h handle, int* is_joined) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_is_joined(handle, is_joined); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_get_joined_network(mesh_h handle, mesh_network_h *network) @@ -485,11 +445,7 @@ EXPORT_API int mesh_get_joined_network(mesh_h handle, mesh_network_h *network) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_get_joined_mesh_network(handle, network); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_set_gate(mesh_h handle, bool stp, bool gate_announce) @@ -500,11 +456,7 @@ EXPORT_API int mesh_set_gate(mesh_h handle, bool stp, bool gate_announce) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_set_gate(handle, stp, gate_announce); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_unset_gate(mesh_h handle) @@ -515,11 +467,7 @@ EXPORT_API int mesh_unset_gate(mesh_h handle) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_unset_gate(handle); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_set_softap(mesh_h handle, const char* ssid, @@ -541,11 +489,7 @@ EXPORT_API int mesh_set_softap(mesh_h handle, const char* ssid, rv = _mesh_set_softap(handle, ssid, key, buf, channel, visibility, max_stations, security); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_enable_softap(mesh_h handle) @@ -556,11 +500,7 @@ EXPORT_API int mesh_enable_softap(mesh_h handle) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_enable_softap(handle); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_disable_softap(mesh_h handle) @@ -571,11 +511,7 @@ EXPORT_API int mesh_disable_softap(mesh_h handle) RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_disable_softap(handle); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_create_mesh_network(mesh_h handle, mesh_network_h network) @@ -587,11 +523,7 @@ EXPORT_API int mesh_create_mesh_network(mesh_h handle, mesh_network_h network) RETV_IF(NULL == network, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_create_network(handle, network); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_connect_mesh_network(mesh_h handle, mesh_network_h network) @@ -603,11 +535,7 @@ EXPORT_API int mesh_connect_mesh_network(mesh_h handle, mesh_network_h network) RETV_IF(NULL == network, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_connect_network(handle, network); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_disconnect_mesh_network(mesh_h handle, mesh_network_h network) @@ -619,11 +547,7 @@ EXPORT_API int mesh_disconnect_mesh_network(mesh_h handle, mesh_network_h networ RETV_IF(NULL == network, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_disconnect_network(handle, network); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_forget_mesh_network(mesh_h handle, mesh_network_h network) @@ -635,11 +559,7 @@ EXPORT_API int mesh_forget_mesh_network(mesh_h handle, mesh_network_h network) RETV_IF(NULL == network, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_forget_network(handle, network); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_data) @@ -650,11 +570,7 @@ EXPORT_API int mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, v RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_get_stations_info(handle, cb, user_data); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data) @@ -665,11 +581,7 @@ EXPORT_API int mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void * RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_get_mpath_info(handle, cb, user_data); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } EXPORT_API int mesh_set_interfaces(mesh_h handle, @@ -682,10 +594,5 @@ EXPORT_API int mesh_set_interfaces(mesh_h handle, RETV_IF(NULL == handle, MESH_ERROR_INVALID_PARAMETER); rv = _mesh_set_interfaces(handle, mesh, gate, softap); - if (rv == MESH_ITNL_ERR_IO_ERROR) { - return MESH_ERROR_IO_ERROR; - } - - return MESH_ERROR_NONE; + return rv; } - diff --git a/src/mesh_dbus.c b/src/mesh_dbus.c index 16cfd4b..b1f64e0 100644 --- a/src/mesh_dbus.c +++ b/src/mesh_dbus.c @@ -62,10 +62,10 @@ static int _mesh_create_gdbus_call(mesh_h handle) struct mesh_handle *h = handle; if (NULL == h) - return MESH_ITNL_ERR_INVALID_PARAM; + return MESH_ERROR_INVALID_PARAMETER; if (h->dbus_connection != NULL) - return MESH_ITNL_ERR_ALREADY_REGISTERED; + return MESH_ERROR_ALREADY_IN_PROGRESS; h->dbus_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); if (h->dbus_connection == NULL) { @@ -73,7 +73,7 @@ static int _mesh_create_gdbus_call(mesh_h handle) LOGE("Failed to connect to the D-BUS daemon [%s]", error->message); g_error_free(error); } - return MESH_ITNL_ERR_UNKNOWN; + return MESH_ERROR_IO_ERROR; } id = g_signal_connect(h->dbus_connection, "notify::g-name-owner", @@ -82,10 +82,10 @@ static int _mesh_create_gdbus_call(mesh_h handle) LOGE("g_signal_connect() Fail"); g_object_unref(h->dbus_connection); h->dbus_connection = NULL; - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } static int _mesh_close_gdbus_call(mesh_h handle) @@ -96,7 +96,7 @@ static int _mesh_close_gdbus_call(mesh_h handle) g_object_unref(h->dbus_connection); h->dbus_connection = NULL; - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } struct mesh_network_list_s { @@ -144,8 +144,8 @@ int _mesh_get_scan_result(mesh_h handle) /* Clear previous scan results */ _mesh_remove_networks(); - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "get_found_mesh_networks", NULL, @@ -187,10 +187,10 @@ int _mesh_get_scan_result(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } static void _mesh_signal_handler(GDBusConnection *connection, @@ -313,7 +313,7 @@ int _mesh_dbus_start(mesh_h handle) int rv; rv = _mesh_create_gdbus_call(handle); - if (MESH_ITNL_ERR_NONE != rv) + if (MESH_ERROR_NONE != rv) return rv; h->ca = g_cancellable_new(); @@ -321,14 +321,14 @@ int _mesh_dbus_start(mesh_h handle) /* Create all proxies here */ _gproxy_mesh_service = _proxy_get_mesh_service(h); RETVM_IF(NULL == _gproxy_mesh_service, - MESH_ITNL_ERR_IO_ERROR, "Couldn't get _gproxy_mesh_service"); + MESH_ERROR_IO_ERROR, "Couldn't get _gproxy_mesh_service"); g_dbus_proxy_set_default_timeout( G_DBUS_PROXY(_gproxy_mesh_service), MESH_DBUS_PROXY_TIMEOUT); /* Subscribe events */ _mesh_subscribe_event(handle); - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_dbus_stop(mesh_h handle) @@ -337,7 +337,7 @@ int _mesh_dbus_stop(mesh_h handle) int rv; if (NULL == h) - return MESH_ITNL_ERR_INVALID_PARAM; + return MESH_ERROR_INVALID_PARAMETER; /* Unref all proxies here */ if (_gproxy_mesh_service) { @@ -390,9 +390,9 @@ static void _mesh_remove_mpath() int _mesh_set_event_cb(mesh_h handle, mesh_event_cb event_handler) { struct mesh_handle *h = handle; - RETV_IF(NULL == h, MESH_ITNL_ERR_INVALID_PARAM); + RETV_IF(NULL == h, MESH_ERROR_INVALID_PARAMETER); h->event_handler = event_handler; - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_enable(mesh_h handle) @@ -402,7 +402,7 @@ int _mesh_enable(mesh_h handle) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); variant = g_dbus_connection_call_sync(h->dbus_connection, MESH_MANAGER_NAME, @@ -418,10 +418,10 @@ int _mesh_enable(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_disable(mesh_h handle) @@ -434,7 +434,7 @@ int _mesh_disable(mesh_h handle) _mesh_remove_networks(); _mesh_remove_mpath(); - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); variant = g_dbus_connection_call_sync(h->dbus_connection, MESH_MANAGER_NAME, @@ -450,11 +450,11 @@ int _mesh_disable(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } h->event_handler = NULL; - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_scan(mesh_h handle) @@ -464,8 +464,8 @@ int _mesh_scan(mesh_h handle) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "scan", NULL, @@ -478,10 +478,10 @@ int _mesh_scan(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_specific_scan(mesh_h handle, const char* ssid, int channel) @@ -491,8 +491,8 @@ int _mesh_specific_scan(mesh_h handle, const char* ssid, int channel) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "specific_scan", g_variant_new("(si)", ssid, channel), @@ -505,10 +505,10 @@ int _mesh_specific_scan(mesh_h handle, const char* ssid, int channel) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_cancel_scan(mesh_h handle) @@ -518,8 +518,8 @@ int _mesh_cancel_scan(mesh_h handle) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "cancel_scan", NULL, @@ -532,10 +532,10 @@ int _mesh_cancel_scan(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_foreach_found_mesh_network(mesh_h handle, @@ -546,13 +546,13 @@ int _mesh_foreach_found_mesh_network(mesh_h handle, struct mesh_network_s *data = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == cb, MESH_ITNL_ERR_INVALID_PARAM); + RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == cb, MESH_ERROR_INVALID_PARAMETER); if (0 >= g_list_length(g_networks.list)) { LOGD("No scan result"); - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } /* Get a first item */ @@ -569,7 +569,7 @@ int _mesh_foreach_found_mesh_network(mesh_h handle, i++; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_enable_mesh(mesh_h handle) @@ -579,8 +579,8 @@ int _mesh_enable_mesh(mesh_h handle) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "enable_mesh", NULL, @@ -593,10 +593,10 @@ int _mesh_enable_mesh(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_disable_mesh(mesh_h handle) @@ -606,8 +606,8 @@ int _mesh_disable_mesh(mesh_h handle) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "disable_mesh", NULL, @@ -620,10 +620,10 @@ int _mesh_disable_mesh(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } /* TODO: Parameter verification required */ @@ -634,8 +634,8 @@ int _mesh_is_joined(mesh_h handle, int* is_joined) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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), @@ -648,10 +648,10 @@ int _mesh_is_joined(mesh_h handle, int* is_joined) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } struct mesh_network_s g_joined_network; @@ -662,9 +662,9 @@ int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _network, MESH_ITNL_ERR_INVALID_PARAM); + RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _network, MESH_ERROR_INVALID_PARAMETER); variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "get_joined_mesh_network", NULL, @@ -681,7 +681,7 @@ int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network) g_variant_get(variant, "(ssiu)", &meshid, &bssid, &channel, &result); LOGD("get_joined_mesh_network status 0x%x", result); - if (MESH_ITNL_ERR_NONE != result) + if (MESH_ERROR_NONE != result) return (int)result; if (meshid) { @@ -702,10 +702,10 @@ int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_set_gate(mesh_h handle, bool stp, bool gate_announce) @@ -715,8 +715,8 @@ int _mesh_set_gate(mesh_h handle, bool stp, bool gate_announce) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "set_gate", g_variant_new("(bb)", stp, gate_announce), @@ -729,10 +729,10 @@ int _mesh_set_gate(mesh_h handle, bool stp, bool gate_announce) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_unset_gate(mesh_h handle) @@ -742,8 +742,8 @@ int _mesh_unset_gate(mesh_h handle) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "unset_gate", NULL, @@ -756,10 +756,10 @@ int _mesh_unset_gate(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_set_softap(mesh_h handle, const char* ssid, @@ -772,8 +772,8 @@ int _mesh_set_softap(mesh_h handle, const char* ssid, GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "set_softap", g_variant_new("(sssiiii)", ssid, key, mode, @@ -787,10 +787,10 @@ int _mesh_set_softap(mesh_h handle, const char* ssid, } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_enable_softap(mesh_h handle) @@ -800,8 +800,8 @@ int _mesh_enable_softap(mesh_h handle) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "enable_softap", NULL, @@ -814,10 +814,10 @@ int _mesh_enable_softap(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_disable_softap(mesh_h handle) @@ -827,8 +827,8 @@ int _mesh_disable_softap(mesh_h handle) GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "disable_softap", NULL, @@ -841,10 +841,10 @@ int _mesh_disable_softap(mesh_h handle) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_create_network(mesh_h handle, mesh_network_h _network) @@ -855,8 +855,8 @@ int _mesh_create_network(mesh_h handle, mesh_network_h _network) struct mesh_handle *h = handle; struct mesh_network_s *n = _network; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "create_mesh_network", g_variant_new("(sii)", n->meshid, n->channel, n->security), @@ -869,10 +869,10 @@ int _mesh_create_network(mesh_h handle, mesh_network_h _network) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_connect_network(mesh_h handle, mesh_network_h _network) @@ -883,8 +883,8 @@ int _mesh_connect_network(mesh_h handle, mesh_network_h _network) struct mesh_handle *h = handle; struct mesh_network_s *n = _network; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "connect_mesh_network", g_variant_new("(sii)", n->meshid, n->channel, n->security), @@ -897,10 +897,10 @@ int _mesh_connect_network(mesh_h handle, mesh_network_h _network) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_disconnect_network(mesh_h handle, mesh_network_h _network) @@ -911,8 +911,8 @@ int _mesh_disconnect_network(mesh_h handle, mesh_network_h _network) struct mesh_handle *h = handle; struct mesh_network_s *n = _network; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "disconnect_mesh_network", g_variant_new("(sii)", n->meshid, n->channel, n->security), @@ -925,10 +925,10 @@ int _mesh_disconnect_network(mesh_h handle, mesh_network_h _network) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_forget_network(mesh_h handle, mesh_network_h _network) @@ -939,8 +939,8 @@ int _mesh_forget_network(mesh_h handle, mesh_network_h _network) struct mesh_handle *h = handle; struct mesh_network_s *n = _network; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + RETV_IF(NULL == h->dbus_connection, MESH_ERROR_IO_ERROR); + RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR); LOGD("mesid=%s channel=%d security=%d", n->meshid, n->channel, n->security); @@ -955,10 +955,10 @@ int _mesh_forget_network(mesh_h handle, mesh_network_h _network) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } @@ -978,8 +978,8 @@ int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_ GVariant *val; gsize len = 0; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "get_station_info", NULL, @@ -1102,10 +1102,10 @@ int _mesh_get_stations_info(mesh_h handle, mesh_found_station_cb cb, void *user_ } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data) @@ -1122,8 +1122,8 @@ int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data) GVariant *val; gsize len = 0; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "get_mpath_info", NULL, @@ -1190,10 +1190,10 @@ int _mesh_get_mpath_info(mesh_h handle, mesh_found_mpath_cb cb, void *user_data) } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } int _mesh_set_interfaces(mesh_h handle, const char *mesh, const char *gate, const char *softap) @@ -1203,8 +1203,8 @@ int _mesh_set_interfaces(mesh_h handle, const char *mesh, const char *gate, cons GError *error = NULL; struct mesh_handle *h = handle; - RETV_IF(NULL == h->dbus_connection, MESH_ITNL_ERR_IO_ERROR); - RETV_IF(NULL == _gproxy_mesh_service, MESH_ITNL_ERR_IO_ERROR); + 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, "set_interfaces", g_variant_new("(sss)", mesh, gate, softap), @@ -1217,9 +1217,9 @@ int _mesh_set_interfaces(mesh_h handle, const char *mesh, const char *gate, cons } else if (error) { LOGE("Failed DBus call [%s]", error->message); g_error_free(error); - return MESH_ITNL_ERR_IO_ERROR; + return MESH_ERROR_IO_ERROR; } - return MESH_ITNL_ERR_NONE; + return MESH_ERROR_NONE; } diff --git a/src/mesh_internal.c b/src/mesh_internal.c index cc2789d..8e851bc 100644 --- a/src/mesh_internal.c +++ b/src/mesh_internal.c @@ -37,22 +37,3 @@ int _mesh_deinit(mesh_h mesh) return MESH_ERROR_NONE; } - -#define CASE_TO_STR(x) case x: return #x; - -const char* _mesh_internal_error_to_string(mesh_internal_err_e err) -{ - switch (err) { - /* CHECK: List all enum values here */ - CASE_TO_STR(MESH_ITNL_ERR_NONE) - CASE_TO_STR(MESH_ITNL_ERR_UNKNOWN) - CASE_TO_STR(MESH_ITNL_ERR_ALREADY_REGISTERED) - CASE_TO_STR(MESH_ITNL_ERR_OUT_OF_MEMORY) - CASE_TO_STR(MESH_ITNL_ERR_OPERATION_FAILED) - CASE_TO_STR(MESH_ITNL_ERR_NOT_SUPPORTED) - CASE_TO_STR(MESH_ITNL_ERR_INVALID_PARAM) - CASE_TO_STR(MESH_ITNL_ERR_IO_ERROR) - default : - return "MESH_ITNL_ERROR_UNKNOWN"; - } -}