diff options
-rwxr-xr-x | src/service.c | 79 |
1 files changed, 78 insertions, 1 deletions
diff --git a/src/service.c b/src/service.c index dbd36f33..9f7c4690 100755 --- a/src/service.c +++ b/src/service.c @@ -7344,13 +7344,90 @@ bool __connman_service_remove(struct connman_service *service) return true; } +#if defined TIZEN_EXT +static char *__connman_service_get_wpa_id_to_remove(struct connman_service *service) +{ + char *identifier; + char *ptr; + + if (service->type != CONNMAN_SERVICE_TYPE_WIFI) + return NULL; + + if (service->security != CONNMAN_SERVICE_SECURITY_SAE && + service->security != CONNMAN_SERVICE_SECURITY_PSK) + return NULL; + + identifier = g_strdup(service->identifier); + if (!identifier) + return NULL; + + if (service->security == CONNMAN_SERVICE_SECURITY_SAE) { + ptr = strstr(identifier, "_sae"); + if (!ptr) { + g_free(identifier); + return NULL; + } + + memcpy(ptr, "_psk", strlen("_psk")); + } else if (service->security == CONNMAN_SERVICE_SECURITY_PSK) { + ptr = strstr(identifier, "_psk"); + if (!ptr) { + g_free(identifier); + return NULL; + } + + memcpy(ptr, "_sae", strlen("_sae")); + } + + return identifier; +} + + +static void __connman_service_remove_wpa_service(struct connman_service *service) +{ + gchar *dir; + GList *list; + char *identifier = __connman_service_get_wpa_id_to_remove(service); + + if (!identifier) + return; + + dir = g_strdup_printf("%s/%s", STORAGEDIR, identifier); + if (!dir) + goto done; + + if (g_file_test(dir, G_FILE_TEST_EXISTS) != TRUE) + goto done; + + for (list = service_list; list; list = list->next) { + struct connman_service *dst_service = list->data; + + if (dst_service->type != CONNMAN_SERVICE_TYPE_WIFI) + continue; + + if (g_strcmp0(dst_service->identifier, identifier) == 0) { + __connman_service_remove(dst_service); + goto done; + } + } + + __connman_storage_remove_service(identifier); + +done: + g_free(identifier); + g_free(dir); +} +#endif + static DBusMessage *remove_service(DBusConnection *conn, DBusMessage *msg, void *user_data) { struct connman_service *service = user_data; DBG("service %p", service); - +#if defined TIZEN_EXT + __connman_service_remove_wpa_service(service); +#endif if (!__connman_service_remove(service)) return __connman_error_not_supported(msg); |