Add id exist check logic for toolkit add api 09/140309/2 submit/tizen_3.0/20170725.224529
authorHyunho Kang <hhstark.kang@samsung.com>
Mon, 24 Jul 2017 11:08:40 +0000 (20:08 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Tue, 25 Jul 2017 10:19:30 +0000 (19:19 +0900)
ID should be unique.

Change-Id: I3d4a5e58cce59d03a32a0cf78c0f006783aafe67
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
screen_connector_watcher/include/screen_connector_toolkit.h
screen_connector_watcher/src/screen_connector_toolkit.c
screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c

index 7fe718c..a614720 100644 (file)
@@ -83,6 +83,8 @@ screen_connector_toolkit_h screen_connector_toolkit_add_with_surface(screen_conn
 
 int screen_connector_toolkit_bind(screen_connector_toolkit_h h, struct wl_surface *surface);
 int screen_connector_toolkit_unbind(screen_connector_toolkit_h h);
+bool screen_connector_toolkit_is_exist(char *id,
+               screen_connector_screen_type_e type);
 
 #ifdef __cplusplus
 }
index c79e6b5..4e5b043 100644 (file)
@@ -351,6 +351,28 @@ EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_add_with_surface(
        return toolkit_h;
 }
 
+EXPORT_API bool screen_connector_toolkit_is_exist(char *id,
+               screen_connector_screen_type_e type)
+{
+       screen_connector_type_h type_h = NULL;
+
+       if (id == NULL) {
+               LOGE("Invalid param");
+               return false;
+       }
+
+       type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type));
+       if (type_h == NULL) {
+               LOGE("type %d is not initialized !!", type);
+               return false;
+       }
+
+       if (type_h->toolkit_table == NULL)
+               return false;
+
+       return (g_hash_table_lookup(type_h->toolkit_table, id) != NULL);
+}
+
 EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_add(screen_connector_toolkit_ops *ops, char *id,
        screen_connector_screen_type_e type, void *data)
 {
@@ -363,9 +385,8 @@ EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_add(screen_connec
                return NULL;
        }
 
-       type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(type));
-       if (type_h == NULL) {
-               LOGE("type %d is not initialized !!", type);
+       if (screen_connector_toolkit_is_exist(id, type)) {
+               LOGE("Already exist ID : %s", id);
                return NULL;
        }
 
index 8c2342b..b32c04f 100644 (file)
@@ -844,6 +844,11 @@ EXPORT_API screen_connector_toolkit_evas_h screen_connector_toolkit_evas_add(scr
        screen_connector_type_evas_h type_h;
        int int_type = type;
 
+       if (screen_connector_toolkit_is_exist(id, type)) {
+               LOGE("Already exist ID : %s", id);
+               return NULL;
+       }
+
        type_h = g_hash_table_lookup(__type_table, GINT_TO_POINTER(int_type));
        if (type_h == NULL) {
                LOGE("type %d is not initialized !!", type);