Remove WPA2 and WPA3 service together 36/310236/2 accepted/tizen/unified/20240508.124544 accepted/tizen/unified/20240508.150732 accepted/tizen/unified/toolchain/20240513.061333 accepted/tizen/unified/x/20240509.044739
authorJaehyun Kim <jeik01.kim@samsung.com>
Wed, 24 Apr 2024 08:27:27 +0000 (17:27 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Thu, 25 Apr 2024 07:02:21 +0000 (16:02 +0900)
Change-Id: I8ca4010821194027d95d1b99a9f468b464381a32
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
src/service.c

index dbd36f3..9f7c469 100755 (executable)
@@ -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);