From: Hyunho Kang Date: Mon, 24 Jul 2017 11:08:40 +0000 (+0900) Subject: Add id exist check logic for toolkit add api X-Git-Tag: accepted/tizen/4.0/unified/20170816.013859~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F36%2F141736%2F3;p=platform%2Fcore%2Fappfw%2Fscreen-connector.git Add id exist check logic for toolkit add api ID should be unique. Change-Id: I154e9abf832a8415d71d452636c804a581292882 Signed-off-by: Hyunho Kang --- diff --git a/screen_connector_watcher/include/screen_connector_toolkit.h b/screen_connector_watcher/include/screen_connector_toolkit.h index 7fe718c..e061079 100644 --- a/screen_connector_watcher/include/screen_connector_toolkit.h +++ b/screen_connector_watcher/include/screen_connector_toolkit.h @@ -83,6 +83,7 @@ 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(const char *id, screen_connector_screen_type_e type); #ifdef __cplusplus } diff --git a/screen_connector_watcher/src/screen_connector_toolkit.c b/screen_connector_watcher/src/screen_connector_toolkit.c index c79e6b5..4242721 100644 --- a/screen_connector_watcher/src/screen_connector_toolkit.c +++ b/screen_connector_watcher/src/screen_connector_toolkit.c @@ -351,6 +351,27 @@ EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_add_with_surface( return toolkit_h; } +EXPORT_API bool screen_connector_toolkit_is_exist(const char *id, screen_connector_screen_type_e type) +{ + screen_connector_type_h type_h; + + 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 +384,14 @@ EXPORT_API screen_connector_toolkit_h screen_connector_toolkit_add(screen_connec return NULL; } + 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(type)); if (type_h == NULL) { - LOGE("type %d is not initialized !!", type); + LOGE("Type(%s) is not initializaed", type); return NULL; } diff --git a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c index fce15d4..7a8f925 100644 --- a/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c +++ b/screen_connector_watcher_evas/src/screen_connector_toolkit_evas.c @@ -902,6 +902,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);