From: Nishant Chaprana Date: Tue, 29 Sep 2020 08:31:59 +0000 (+0530) Subject: Use connman's StateChangedProperties to process service state X-Git-Tag: submit/tizen_6.0/20201118.063037~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=08dd3f252f12ee9f4ff92d67ebb9fdb8066bb9a2;p=platform%2Fcore%2Fapi%2Fwifi-manager.git Use connman's StateChangedProperties to process service state Change-Id: I7c1dfa8205807998626cec4f6a1aeb56c38aaba8 Signed-off-by: Nishant Chaprana --- diff --git a/include/network_interface.h b/include/network_interface.h index 2ade4b0..8ed508d 100755 --- a/include/network_interface.h +++ b/include/network_interface.h @@ -264,6 +264,10 @@ int net_get_profile_info(network_info_s *network_info, const char *profile_name, net_profile_info_s *prof_info); int net_get_profile_list(network_info_s *network_info, GSList **profile_list); +int _net_extract_service_info(network_info_s *network_info, + const char* ProfileName, GVariantIter *iter, + net_profile_info_s* ProfInfo); + int net_modify_profile(network_info_s *network_info, const char *profile_name, net_profile_info_s *prof_info); int net_delete_profile(network_info_s *network_info, const char *profile_name); diff --git a/include/network_internal.h b/include/network_internal.h index f015bdd..73b5f33 100755 --- a/include/network_internal.h +++ b/include/network_internal.h @@ -79,6 +79,7 @@ extern "C" { #define SUPPLICANT_INTERFACE_SIGNAL_FILTER "type='signal',interface='fi.w1.wpa_supplicant1.Interface'" #define SIGNAL_PROPERTY_CHANGED "PropertyChanged" +#define SIGNAL_STATE_CHANGED_PROPERTIES "StateChangedProperties" #define SIGNAL_PROPERTIES_CHANGED "PropertiesChanged" #define SIGNAL_TECHNOLOGY_ADDED "TechnologyAdded" #define SIGNAL_TECHNOLOGY_REMOVED "TechnologyRemoved" diff --git a/src/network_interface.c b/src/network_interface.c index 5334926..0e6a471 100755 --- a/src/network_interface.c +++ b/src/network_interface.c @@ -1089,7 +1089,7 @@ static int __net_extract_wifi_info(GVariantIter *array, net_profile_info_s* Prof return Error; } -static int __net_extract_service_info(network_info_s *network_info, +int _net_extract_service_info(network_info_s *network_info, const char* ProfileName, GVariantIter *iter, net_profile_info_s* ProfInfo) { @@ -1243,7 +1243,7 @@ static int __net_get_profile_info(network_info_s *network_info, } g_variant_get(message, "(a{sv})", &service); - Error = __net_extract_service_info(network_info, ProfileName, + Error = _net_extract_service_info(network_info, ProfileName, service, ProfInfo); g_variant_iter_free(service); @@ -3072,7 +3072,7 @@ static void _net_delete_profile_async_reply(GObject *source_object, while (g_variant_iter_loop(iter, "(oa{sv})", &path, &service)) { if (g_strcmp0(request_table[NETWORK_REQUEST_TYPE_FORGET_AP].ProfileName, path) == 0) { - Error = __net_extract_service_info(network_info, + Error = _net_extract_service_info(network_info, path, service, &prof_info); g_variant_iter_free(service); g_free(path); diff --git a/src/network_signal.c b/src/network_signal.c index bb1f686..69814f6 100755 --- a/src/network_signal.c +++ b/src/network_signal.c @@ -43,26 +43,6 @@ static int __net_dbus_get_bssid_list(); static int __net_dbus_get_technology_states(network_info_s *network_info); //LCOV_EXCL_START -static int string2state(const char *state) -{ - if (g_strcmp0(state, "idle") == 0) - return NET_STATE_TYPE_IDLE; - else if (g_strcmp0(state, "association") == 0) - return NET_STATE_TYPE_ASSOCIATION; - else if (g_strcmp0(state, "configuration") == 0) - return NET_STATE_TYPE_CONFIGURATION; - else if (g_strcmp0(state, "ready") == 0) - return NET_STATE_TYPE_READY; - else if (g_strcmp0(state, "online") == 0) - return NET_STATE_TYPE_ONLINE; - else if (g_strcmp0(state, "disconnect") == 0) - return NET_STATE_TYPE_DISCONNECT; - else if (g_strcmp0(state, "failure") == 0) - return NET_STATE_TYPE_FAILURE; - - return NET_STATE_TYPE_UNKNOWN; -} - static int string2error(const char *error) { if (g_strcmp0(error, "out-of-range") == 0) @@ -777,7 +757,7 @@ static void __net_handle_disconnect_ind(network_info_s *network_info, } static int __net_handle_service_state_changed(network_info_s *network_info, - const gchar *sig_path, const char *key, const char *state) + const gchar *sig_path, net_state_type_e state, net_profile_info_s *prof_info) { net_err_e Error = NET_ERR_NONE; net_state_type_e old_state, new_state; @@ -798,7 +778,7 @@ static int __net_handle_service_state_changed(network_info_s *network_info, } old_state = network_info->service_state; - new_state = string2state(state); + new_state = state; WIFI_LOG(WIFI_INFO, "old state [%s], new state [%s]", _convert_net_state_to_string(old_state), _convert_net_state_to_string(new_state)); @@ -860,16 +840,12 @@ static int __net_handle_service_state_changed(network_info_s *network_info, WIFI_LOG(WIFI_INFO, "Sending NET_EVENT_OPEN_IND"); } - net_profile_info_s prof_info; - if ((Error = net_get_profile_info(network_info, sig_path, &prof_info)) != NET_ERR_NONE) { - WIFI_LOG(WIFI_ERROR, "net_get_profile_info() failed [%s]", - _net_print_error(Error)); - + if (prof_info == NULL) { event_data->Datalength = 0; event_data->Data = NULL; } else { event_data->Datalength = sizeof(net_profile_info_s); - event_data->Data = &prof_info; + event_data->Data = prof_info; } event_data->Error = Error; @@ -1069,22 +1045,19 @@ static void __net_connman_service_signal_filter(GDBusConnection *conn, { __NETWORK_FUNC_ENTER__; - const char *key = NULL; - const char *value = NULL; - GVariant *var; network_info_s *network_info = (network_info_s *)user_data; if (g_strcmp0(sig, SIGNAL_PROPERTY_CHANGED) == 0) { + const char *key = NULL; + const char *value = NULL; + GVariant *var; + g_variant_get(param, "(sv)", &key, &var); if (g_str_has_prefix(path, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE) { - if (g_strcmp0(key, "State") == 0) { - g_variant_get(var, "s", &value); - - __net_handle_service_state_changed(network_info, path, key, value); - } else if (g_strcmp0(key, "Error") == 0) { + if (g_strcmp0(key, "Error") == 0) { g_variant_get(var, "s", &value); __net_handle_service_set_error(network_info, key, value); @@ -1095,6 +1068,31 @@ static void __net_connman_service_signal_filter(GDBusConnection *conn, g_free((gchar *)key); if (NULL != var) g_variant_unref(var); + + } else if (g_strcmp0(sig, SIGNAL_STATE_CHANGED_PROPERTIES) == 0) { + net_profile_info_s prof_info; + net_err_e sig_error = NET_ERR_NONE; + GVariantIter *iter = NULL; + const gchar *object_path = NULL; + + memset(&prof_info, 0, sizeof(net_profile_info_s)); + + g_variant_get(param, "((&oa{sv}))", &object_path, &iter); + + sig_error = _net_extract_service_info(network_info, object_path, iter, &prof_info); + + if (sig_error == NET_ERR_NONE) + __net_handle_service_state_changed(network_info, object_path, + prof_info.ProfileState, &prof_info); + + /* Free internal GSList */ + if (prof_info.vsie_list) + g_slist_free_full(prof_info.vsie_list, g_free); + + if (prof_info.bssid_list) + g_slist_free_full(prof_info.bssid_list, g_free); + + g_variant_iter_free(iter); } __NETWORK_FUNC_EXIT__; @@ -2091,9 +2089,9 @@ int _net_register_signal(network_info_s *network_info) network_info->connection, CONNMAN_SERVICE, CONNMAN_SERVICE_INTERFACE, - SIGNAL_PROPERTY_CHANGED, + SIGNAL_STATE_CHANGED_PROPERTIES, + NULL, NULL, - "State", G_DBUS_SIGNAL_FLAGS_NONE, __net_connman_service_signal_filter, network_info,