From d9558316f1edd92fbec5c8b816760d93db4aa197 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 30 Jun 2022 11:06:36 +0900 Subject: [PATCH 01/16] Reduce duplicate code in data_manager Change-Id: I91f33d3c2db2e72ff9f7061b1ab72d49f7ee4199 --- server/stickerd_data_manager.c | 118 ++++++++++------------------------------- 1 file changed, 27 insertions(+), 91 deletions(-) diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index ac976f2..79b65b5 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -1386,13 +1386,32 @@ static void _set_id_builder(char *id, GVariantBuilder *id_builder) g_variant_builder_add(id_builder, "(i)", atoi(id)); } +static int _set_reply_body(GList *list, GVariant **reply_body) +{ + int ret = STICKERD_SERVER_ERROR_NONE; + GVariantBuilder *builder = NULL; + + builder = g_variant_builder_new(G_VARIANT_TYPE("a(i)")); + g_list_foreach(list, (GFunc) _set_id_builder, builder); + + *reply_body = g_variant_new("(a(i))", builder); + if (*reply_body == NULL) { + LOGE("Failed to create reply_body"); + ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; + } + + if (builder) + g_variant_builder_unref(builder); + + return ret; +} + int stickerd_get_all_sticker_info(GVariant *parameters, GVariant **reply_body) { int ret; int offset, count; char *app_id = NULL; GList *id_list = NULL; - GVariantBuilder *id_builder = NULL; g_variant_get(parameters, "(&sii)", &app_id, &offset, &count); @@ -1404,21 +1423,10 @@ int stickerd_get_all_sticker_info(GVariant *parameters, GVariant **reply_body) return STICKERD_SERVER_ERROR_OPERATION_FAILED; } - id_builder = g_variant_builder_new(G_VARIANT_TYPE("a(i)")); - g_list_foreach(id_list, (GFunc) _set_id_builder, id_builder); - - *reply_body = g_variant_new("(a(i))", id_builder); - if (*reply_body == NULL) { - LOGE("Failed to create reply_body"); - ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; - } - + ret = _set_reply_body(id_list, reply_body); if (id_list) g_list_free_full(id_list, free); - if (id_builder) - g_variant_builder_unref(id_builder); - return ret; } @@ -1428,7 +1436,6 @@ int stickerd_get_sticker_info_by_app_id(GVariant *parameters, GVariant **reply_b GList *id_list = NULL; char *app_id = NULL; int offset, count; - GVariantBuilder *id_builder = NULL; g_variant_get(parameters, "(&sii)", &app_id, &offset, &count); @@ -1440,21 +1447,10 @@ int stickerd_get_sticker_info_by_app_id(GVariant *parameters, GVariant **reply_b return STICKERD_SERVER_ERROR_OPERATION_FAILED; } - id_builder = g_variant_builder_new(G_VARIANT_TYPE("a(i)")); - g_list_foreach(id_list, (GFunc) _set_id_builder, id_builder); - - *reply_body = g_variant_new("(a(i))", id_builder); - if (*reply_body == NULL) { - LOGE("Failed to create reply_body"); - ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; - } - + ret = _set_reply_body(id_list, reply_body); if (id_list) g_list_free_full(id_list, free); - if (id_builder) - g_variant_builder_unref(id_builder); - return ret; } @@ -1464,7 +1460,6 @@ int stickerd_get_sticker_info_by_type(GVariant *parameters, GVariant **reply_bod GList *id_list = NULL; char *app_id = NULL; int type, offset, count; - GVariantBuilder *id_builder = NULL; g_variant_get(parameters, "(&siii)", &app_id, &type, &offset, &count); @@ -1476,21 +1471,10 @@ int stickerd_get_sticker_info_by_type(GVariant *parameters, GVariant **reply_bod return STICKERD_SERVER_ERROR_OPERATION_FAILED; } - id_builder = g_variant_builder_new(G_VARIANT_TYPE("a(i)")); - g_list_foreach(id_list, (GFunc) _set_id_builder, id_builder); - - *reply_body = g_variant_new("(a(i))", id_builder); - if (*reply_body == NULL) { - LOGE("Failed to create reply_body"); - ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; - } - + ret = _set_reply_body(id_list, reply_body); if (id_list) g_list_free_full(id_list, free); - if (id_builder) - g_variant_builder_unref(id_builder); - return ret; } @@ -1501,7 +1485,6 @@ int stickerd_get_sticker_info_by_group(GVariant *parameters, GVariant **reply_bo char *app_id = NULL; char *group = NULL; int offset, count; - GVariantBuilder *id_builder = NULL; g_variant_get(parameters, "(&s&sii)", &app_id, &group, &offset, &count); @@ -1513,21 +1496,10 @@ int stickerd_get_sticker_info_by_group(GVariant *parameters, GVariant **reply_bo return STICKERD_SERVER_ERROR_OPERATION_FAILED; } - id_builder = g_variant_builder_new(G_VARIANT_TYPE("a(i)")); - g_list_foreach(id_list, (GFunc) _set_id_builder, id_builder); - - *reply_body = g_variant_new("(a(i))", id_builder); - if (*reply_body == NULL) { - LOGE("Failed to create reply_body"); - ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; - } - + ret = _set_reply_body(id_list, reply_body); if (id_list) g_list_free_full(id_list, free); - if (id_builder) - g_variant_builder_unref(id_builder); - return ret; } @@ -1538,7 +1510,6 @@ int stickerd_get_sticker_info_by_keyword(GVariant *parameters, GVariant **reply_ char *app_id = NULL; char *keyword = NULL; int offset, count; - GVariantBuilder *id_builder = NULL; g_variant_get(parameters, "(&s&sii)", &app_id, &keyword, &offset, &count); @@ -1550,21 +1521,10 @@ int stickerd_get_sticker_info_by_keyword(GVariant *parameters, GVariant **reply_ return STICKERD_SERVER_ERROR_OPERATION_FAILED; } - id_builder = g_variant_builder_new(G_VARIANT_TYPE("a(i)")); - g_list_foreach(id_list, (GFunc) _set_id_builder, id_builder); - - *reply_body = g_variant_new("(a(i))", id_builder); - if (*reply_body == NULL) { - LOGE("Failed to create reply_body"); - ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; - } - + ret = _set_reply_body(id_list, reply_body); if (id_list) g_list_free_full(id_list, free); - if (id_builder) - g_variant_builder_unref(id_builder); - return ret; } @@ -1574,7 +1534,6 @@ int stickerd_get_sticker_info_by_display_type(GVariant *parameters, GVariant **r GList *id_list = NULL; char *app_id = NULL; int type, offset, count; - GVariantBuilder *id_builder = NULL; g_variant_get(parameters, "(&siii)", &app_id, &type, &offset, &count); @@ -1586,21 +1545,10 @@ int stickerd_get_sticker_info_by_display_type(GVariant *parameters, GVariant **r return STICKERD_SERVER_ERROR_OPERATION_FAILED; } - id_builder = g_variant_builder_new(G_VARIANT_TYPE("a(i)")); - g_list_foreach(id_list, (GFunc) _set_id_builder, id_builder); - - *reply_body = g_variant_new("(a(i))", id_builder); - if (*reply_body == NULL) { - LOGE("Failed to create reply_body"); - ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; - } - + ret = _set_reply_body(id_list, reply_body); if (id_list) g_list_free_full(id_list, free); - if (id_builder) - g_variant_builder_unref(id_builder); - return ret; } @@ -1705,7 +1653,6 @@ int stickerd_get_recent_sticker_info(GVariant *parameters, GVariant **reply_body int ret; int count; GList *id_list = NULL; - GVariantBuilder *id_builder = NULL; g_variant_get(parameters, "(i)", &count); @@ -1717,21 +1664,10 @@ int stickerd_get_recent_sticker_info(GVariant *parameters, GVariant **reply_body return STICKERD_SERVER_ERROR_OPERATION_FAILED; } - id_builder = g_variant_builder_new(G_VARIANT_TYPE("a(i)")); - g_list_foreach(id_list, (GFunc) _set_id_builder, id_builder); - - *reply_body = g_variant_new("(a(i))", id_builder); - if (*reply_body == NULL) { - LOGE("Failed to create reply_body"); - ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; - } - + ret = _set_reply_body(id_list, reply_body); if (id_list) g_list_free_full(id_list, free); - if (id_builder) - g_variant_builder_unref(id_builder); - return ret; } -- 2.7.4 From 95868f12996dbaee3f4f7984a0660dc91e1644ca Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 30 Jun 2022 13:51:07 +0900 Subject: [PATCH 02/16] Reduce duplicate code in db_manager Change-Id: I704e77358480b564ba88847e600fef06cdc05cf4 --- server/stickerd_db_manager.c | 86 +++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 53 deletions(-) diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index dfa84c9..e299e6d 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -186,25 +186,10 @@ static const char *_db_get_query(sticker_info_db_type sticker_type, command_type return query; } -static int _recover_db(void) +static int _create_db_table(sqlite3 *db) { - int ret = STICKERD_SERVER_ERROR_NONE; - sqlite3 *db = NULL; char *err = NULL; - - LOGD("Start to recover sticker db"); - //Remove sticker database file - if (unlink(STICKER_DB_PATH) == -1) - LOGE("Failed to remove db file"); - - ret = sqlite3_open_v2(STICKER_DB_PATH, &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL); - if (ret != SQLITE_OK) { - LOGE("Failed to open db : %s", sqlite3_errmsg(db)); - if (unlink(STICKER_DB_PATH) == -1) - LOGE("Failed to remove db file"); - ret = STICKERD_SERVER_ERROR_DB_FAILED; - goto cleanup; - } + int ret = STICKERD_SERVER_ERROR_NONE; ret = sqlite3_exec(db, STICKER_INFO_CREATE_TABLE, NULL, NULL, &err); if (ret != SQLITE_OK) { @@ -238,15 +223,41 @@ static int _recover_db(void) if (ret != SQLITE_OK) { LOGE("Failed to create sticker_group_info table : %s", err); ret = STICKERD_SERVER_ERROR_DB_FAILED; - goto cleanup; } - is_corrupted = FALSE; - cleanup: if (err) sqlite3_free(err); + return ret; +} + +static int _recover_db(void) +{ + int ret = STICKERD_SERVER_ERROR_NONE; + sqlite3 *db = NULL; + + LOGD("Start to recover sticker db"); + //Remove sticker database file + if (unlink(STICKER_DB_PATH) == -1) + LOGE("Failed to remove db file"); + + ret = sqlite3_open_v2(STICKER_DB_PATH, &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL); + if (ret != SQLITE_OK) { + LOGE("Failed to open db : %s", sqlite3_errmsg(db)); + if (unlink(STICKER_DB_PATH) == -1) + LOGE("Failed to remove db file"); + ret = STICKERD_SERVER_ERROR_DB_FAILED; + goto cleanup; + } + + ret = _create_db_table(db); + if (ret != SQLITE_OK) + goto cleanup; + + is_corrupted = FALSE; + +cleanup: if (db) sqlite3_close(db); @@ -278,40 +289,9 @@ int stickerd_db_init(void) goto cleanup; } - ret = sqlite3_exec(db, STICKER_INFO_CREATE_TABLE, NULL, NULL, &err); - if (ret != SQLITE_OK) { - LOGE("Failed to create sticker_info table : %s" , err); - ret = STICKERD_SERVER_ERROR_DB_FAILED; - goto cleanup; - } - - ret = sqlite3_exec(db, STICKER_KEYWORD_INFO_CREATE_TABLE, NULL, NULL, &err); - if (ret != SQLITE_OK) { - LOGE("Failed to create sticker_keyword_info table : %s", err); - ret = STICKERD_SERVER_ERROR_DB_FAILED; - goto cleanup; - } - - ret = sqlite3_exec(db, STICKER_WHITELIST_INFO_CREATE_TABLE, NULL, NULL, &err); - if (ret != SQLITE_OK) { - LOGE("Failed to create sticker_whitelist_info table : %s", err); - ret = STICKERD_SERVER_ERROR_DB_FAILED; - goto cleanup; - } - - ret = sqlite3_exec(db, STICKER_RECENT_HISTORY_INFO_CREATE_TABLE, NULL, NULL, &err); - if (ret != SQLITE_OK) { - LOGE("Failed to create sticker_recent_history_info table : %s", err); - ret = STICKERD_SERVER_ERROR_DB_FAILED; - goto cleanup; - } - - ret = sqlite3_exec(db, STICKER_GROUP_INFO_CREATRE_TABLE, NULL, NULL, &err); - if (ret != SQLITE_OK) { - LOGE("Failed to create sticker_group_info table : %s", err); - ret = STICKERD_SERVER_ERROR_DB_FAILED; + ret = _create_db_table(db); + if (ret != SQLITE_OK) goto cleanup; - } ret = sqlite3_exec(db, "PRAGMA journal_mode = WAL", NULL, NULL, &err); if (ret != SQLITE_OK) { -- 2.7.4 From e54f1a8eda0cfe5e8144ce27ac4086800cbbee5e Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 1 Jul 2022 10:22:05 +0900 Subject: [PATCH 03/16] Fix typo in sqlite definition Change-Id: I64454070758f7f0237d57f1a51e11c4c543ea005 Signed-off-by: Jihoon Kim --- server/stickerd_db_manager.c | 10 +++++----- sticker-parser/sticker-parser.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index e299e6d..7240d04 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -72,7 +72,7 @@ #define STICKER_KEYWORD_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_keyword_info(keyword_id INTEGER PRIMARY KEY AUTOINCREMENT, sticker_info_id INTEGER, keyword TEXT NOT NULL, FOREIGN KEY (sticker_info_id) REFERENCES sticker_info(sticker_info_id) ON DELETE CASCADE)" #define STICKER_WHITELIST_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_whitelist_info(whitelist_id INTEGER PRIMARY KEY AUTOINCREMENT, provider_id TEXT NOT NULL, consumer_id TEXT NOT NULL)" #define STICKER_RECENT_HISTORY_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_recent_history_info(history_id INTEGER PRIMARY KEY AUTOINCREMENT, sticker_info_id INTEGER, count INTEGER NOT NULL, timestamp TEXT NOT NULL, FOREIGN KEY (sticker_info_id) REFERENCES sticker_info(sticker_info_id) ON DELETE CASCADE)" -#define STICKER_GROUP_INFO_CREATRE_TABLE "CREATE TABLE IF NOT EXISTS sticker_group_info(group_id INTEGER PRIMARY KEY AUTOINCREMENT, app_id TEXT NOT NULL, group_name TEXT NOT NULL, type INTEGER NOT NULL, uri TEXT NOT NULL)" +#define STICKER_GROUP_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_group_info(group_id INTEGER PRIMARY KEY AUTOINCREMENT, app_id TEXT NOT NULL, group_name TEXT NOT NULL, type INTEGER NOT NULL, uri TEXT NOT NULL)" #define STICKER_DB_INSERT_STICKER_INFO "INSERT INTO sticker_info (app_id, type, uri, thumbnail, description, group_name, date, display_type) VALUES (?, ?, ?, ?, ?, ?, DateTime('now','localtime'), ?)" #define STICKER_DB_INSERT_STICKER_KEYWORD_INFO "INSERT INTO sticker_keyword_info (sticker_info_id, keyword) VALUES (?, ?)" @@ -95,7 +95,7 @@ #define STICKER_DB_GET_LATEST_RECORD_ID "SELECT sticker_info_id FROM sticker_info ORDER BY sticker_info_id DESC LIMIT 1" #define STICKER_DB_GET_STICKER_INFO_BY_RECORD_ID "SELECT * FROM sticker_info WHERE sticker_info_id = ?" #define STICKER_DB_GET_KEYWORD_INFO_BY_RECORD_ID "SELECT keyword FROM sticker_keyword_info WHERE sticker_info_id = ?" -#define STICKER_DB_GET_IMAGE_INFO_BY_RECORED_ID "SELECT type, uri, thumbnail FROM sticker_info WHERE sticker_info_id = ?" +#define STICKER_DB_GET_IMAGE_INFO_BY_RECORD_ID "SELECT type, uri, thumbnail FROM sticker_info WHERE sticker_info_id = ?" #define STICKER_DB_GET_IMAGE_INFO_BY_URI "SELECT type, thumbnail FROM sticker_info WHERE uri = ?" #define STICKER_DB_GET_ALL_GROUP_LIST "SELECT DISTINCT group_name FROM sticker_info WHERE app_id NOT IN (SELECT DISTINCT provider_id FROM sticker_whitelist_info WHERE provider_id NOT IN (SELECT provider_id FROM sticker_whitelist_info WHERE consumer_id = ?))" #define STICKER_DB_GET_ALL_KEYWORD_LIST "SELECT DISTINCT keyword FROM sticker_keyword_info WHERE sticker_info_id IN (SELECT sticker_info_id from sticker_info WHERE app_id NOT IN (SELECT DISTINCT provider_id FROM sticker_whitelist_info WHERE provider_id NOT IN (SELECT provider_id FROM sticker_whitelist_info WHERE consumer_id = ?)))" @@ -219,7 +219,7 @@ static int _create_db_table(sqlite3 *db) goto cleanup; } - ret = sqlite3_exec(db, STICKER_GROUP_INFO_CREATRE_TABLE, NULL, NULL, &err); + ret = sqlite3_exec(db, STICKER_GROUP_INFO_CREATE_TABLE, NULL, NULL, &err); if (ret != SQLITE_OK) { LOGE("Failed to create sticker_group_info table : %s", err); ret = STICKERD_SERVER_ERROR_DB_FAILED; @@ -486,7 +486,7 @@ int stickerd_db_delete_sticker_info(int record_id) if (!db) return STICKERD_SERVER_ERROR_DB_FAILED; - ret = sqlite3_prepare_v2(db, STICKER_DB_GET_IMAGE_INFO_BY_RECORED_ID, -1, &stmt, NULL); + ret = sqlite3_prepare_v2(db, STICKER_DB_GET_IMAGE_INFO_BY_RECORD_ID, -1, &stmt, NULL); if (ret != SQLITE_OK) { LOGE("fail to get image files : %s", sqlite3_errmsg(db)); goto cleanup; @@ -1288,4 +1288,4 @@ cleanup: sqlite3_close(db); return STICKERD_SERVER_ERROR_DB_FAILED; -} \ No newline at end of file +} diff --git a/sticker-parser/sticker-parser.c b/sticker-parser/sticker-parser.c index 20bd406..f72286b 100644 --- a/sticker-parser/sticker-parser.c +++ b/sticker-parser/sticker-parser.c @@ -46,7 +46,7 @@ #define STICKER_KEYWORD_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_keyword_info(keyword_id INTEGER PRIMARY KEY AUTOINCREMENT, sticker_info_id INTEGER, keyword TEXT NOT NULL, FOREIGN KEY (sticker_info_id) REFERENCES sticker_info(sticker_info_id) ON DELETE CASCADE)" #define STICKER_WHITELIST_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_whitelist_info(whitelist_id INTEGER PRIMARY KEY AUTOINCREMENT, provider_id TEXT NOT NULL, consumer_id TEXT NOT NULL)" #define STICKER_RECENT_HISTORY_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_recent_history_info(history_id INTEGER PRIMARY KEY AUTOINCREMENT, sticker_info_id INTEGER, count INTEGER NOT NULL, timestamp TEXT NOT NULL, FOREIGN KEY (sticker_info_id) REFERENCES sticker_info(sticker_info_id) ON DELETE CASCADE)" -#define STICKER_GROUP_INFO_CREATRE_TABLE "CREATE TABLE IF NOT EXISTS sticker_group_info(group_id INTEGER PRIMARY KEY AUTOINCREMENT, app_id TEXT NOT NULL, group_name TEXT NOT NULL, type INTEGER NOT NULL, uri TEXT NOT NULL)" +#define STICKER_GROUP_INFO_CREATE_TABLE "CREATE TABLE IF NOT EXISTS sticker_group_info(group_id INTEGER PRIMARY KEY AUTOINCREMENT, app_id TEXT NOT NULL, group_name TEXT NOT NULL, type INTEGER NOT NULL, uri TEXT NOT NULL)" #define UIFW_ID 502 #define APPFW_ID 301 #define MAX_ERROR_BUFFER 256 @@ -139,7 +139,7 @@ static void __recover_db() goto cleanup; } - ret = sqlite3_exec(db, STICKER_GROUP_INFO_CREATRE_TABLE, NULL, NULL, &err); + ret = sqlite3_exec(db, STICKER_GROUP_INFO_CREATE_TABLE, NULL, NULL, &err); if (ret != SQLITE_OK) { LOGE("Failed to create sticker_recent_history_info table : %s", err); goto cleanup; @@ -207,7 +207,7 @@ static void __db_init() goto cleanup; } - ret = sqlite3_exec(db, STICKER_GROUP_INFO_CREATRE_TABLE, NULL, NULL, &err); + ret = sqlite3_exec(db, STICKER_GROUP_INFO_CREATE_TABLE, NULL, NULL, &err); if (ret != SQLITE_OK) { LOGE("Failed to create sticker_recent_history_info table : %s", err); goto cleanup; -- 2.7.4 From c120ed9763540cad48ab15511b8dd5075a458dd0 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 30 Jun 2022 14:37:14 +0900 Subject: [PATCH 04/16] Update package version to 1.2.6 Change-Id: I88d970095ee8b90fbe48352fa2890df12d8d058d --- packaging/capi-ui-sticker.spec | 2 +- receiver/tizen-manifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index f712f20..e6f82c4 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -1,6 +1,6 @@ Name: capi-ui-sticker Summary: Sticker client library and daemon -Version: 1.2.5 +Version: 1.2.6 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index e94020b..a832bf3 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 1b3844bcb40c90c7de3dcd48a19c5c9acbc9e276 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 11 Jul 2022 13:26:52 +0900 Subject: [PATCH 05/16] Use explicit unittest filename Change-Id: I54b2dbf28889c2611293aa05ad39a2b7770cd067 Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index e6f82c4..d501bd2 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -235,7 +235,7 @@ chsmack -a "User::App::Shared" /opt/usr/share/sticker-data %files unittests %license LICENSE %{_bindir}/capi-ui-sticker-unittest -%{_bindir}/tizen-unittests/* +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh %if 0%{?gcov:1} %files gcov -- 2.7.4 From dff9f1aeb5e4349facdf6178e003a6d9c7106ef0 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 22 Jul 2022 16:02:28 +0900 Subject: [PATCH 06/16] Reorganize directory for coverage automation Change-Id: I4ef843f52229917f55a28c3431b680af88e31b6a --- CMakeLists.txt | 2 +- client/CMakeLists.txt | 15 ++++++++------- client/{src => }/sticker_consumer.c | 0 client/{inc => }/sticker_consumer_main.h | 0 client/{src => }/sticker_data.c | 0 client/{inc => }/sticker_data_main.h | 0 client/{src => }/sticker_dbus.c | 0 client/{src => }/sticker_dbus.h | 0 client/{inc => }/sticker_defs.h | 0 client/{src => }/sticker_provider.c | 0 client/{inc => }/sticker_provider_main.h | 0 packaging/capi-ui-sticker.spec | 1 + tests/CMakeLists.txt | 2 +- 13 files changed, 11 insertions(+), 9 deletions(-) rename client/{src => }/sticker_consumer.c (100%) rename client/{inc => }/sticker_consumer_main.h (100%) rename client/{src => }/sticker_data.c (100%) rename client/{inc => }/sticker_data_main.h (100%) rename client/{src => }/sticker_dbus.c (100%) rename client/{src => }/sticker_dbus.h (100%) rename client/{inc => }/sticker_defs.h (100%) rename client/{src => }/sticker_provider.c (100%) rename client/{inc => }/sticker_provider_main.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22c7a24..fc4f40e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ ADD_DEFINITIONS("-Werror") ## Include common directory ## INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") -INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/client/inc") +INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/client") ## Dependent packages ## INCLUDE(FindPkgConfig) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index be848fc..8df7b70 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -1,16 +1,17 @@ SET(CONSUMER_SRCS - src/sticker_consumer.c - src/sticker_data.c - src/sticker_dbus.c + sticker_consumer.c + sticker_data.c + sticker_dbus.c ) SET(PROVIDER_SRCS - src/sticker_provider.c - src/sticker_data.c - src/sticker_dbus.c + sticker_provider.c + sticker_data.c + sticker_dbus.c ) -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/client/inc) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/client/src/sticker_consumer.c b/client/sticker_consumer.c similarity index 100% rename from client/src/sticker_consumer.c rename to client/sticker_consumer.c diff --git a/client/inc/sticker_consumer_main.h b/client/sticker_consumer_main.h similarity index 100% rename from client/inc/sticker_consumer_main.h rename to client/sticker_consumer_main.h diff --git a/client/src/sticker_data.c b/client/sticker_data.c similarity index 100% rename from client/src/sticker_data.c rename to client/sticker_data.c diff --git a/client/inc/sticker_data_main.h b/client/sticker_data_main.h similarity index 100% rename from client/inc/sticker_data_main.h rename to client/sticker_data_main.h diff --git a/client/src/sticker_dbus.c b/client/sticker_dbus.c similarity index 100% rename from client/src/sticker_dbus.c rename to client/sticker_dbus.c diff --git a/client/src/sticker_dbus.h b/client/sticker_dbus.h similarity index 100% rename from client/src/sticker_dbus.h rename to client/sticker_dbus.h diff --git a/client/inc/sticker_defs.h b/client/sticker_defs.h similarity index 100% rename from client/inc/sticker_defs.h rename to client/sticker_defs.h diff --git a/client/src/sticker_provider.c b/client/sticker_provider.c similarity index 100% rename from client/src/sticker_provider.c rename to client/sticker_provider.c diff --git a/client/inc/sticker_provider_main.h b/client/sticker_provider_main.h similarity index 100% rename from client/inc/sticker_provider_main.h rename to client/sticker_provider_main.h diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index d501bd2..9be2ba1 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -128,6 +128,7 @@ rm -rf %{buildroot} builddir=$(basename $PWD) gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir" mkdir -p "$gcno_obj_dir" +find ./server/ -name '*.gcno' -exec rm {} \; find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';' %endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7e877ef..193ffec 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,7 +16,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/mock) AUX_SOURCE_DIRECTORY(src SOURCES) -AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../client/src STICKER_CLIENT_SOURCES) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../client STICKER_CLIENT_SOURCES) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/mock MOCK_SRCS) ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"") -- 2.7.4 From 04ca8a2120e60cb90e3dee12d4eb1189d4920c4d Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 22 Jul 2022 16:35:41 +0900 Subject: [PATCH 07/16] Update package version to 1.2.7 Change-Id: I1a3d6bb38ca85ad158b3592299b022a05991b5a5 --- packaging/capi-ui-sticker.spec | 2 +- receiver/tizen-manifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 9be2ba1..98da82b 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -1,6 +1,6 @@ Name: capi-ui-sticker Summary: Sticker client library and daemon -Version: 1.2.6 +Version: 1.2.7 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index a832bf3..7ba9c98 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 4d5bc9c34bc1f74c641a0cea00b36987f624a8eb Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 20 Oct 2022 18:48:39 +0900 Subject: [PATCH 08/16] Modified to prevent frequent restart of Sticker daemon Change-Id: I64e1a40c250c4a2efcfc78a6b6a5a22a95b5ba9f --- server/stickerd_data_manager.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index 79b65b5..66915b6 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "stickerd_dbus.h" #include "stickerd_data_manager.h" @@ -40,6 +41,7 @@ #define LOG_TAG "STICKERD_DATA_MANAGER" #define MAX_ERROR_BUFFER 256 +#define TERMINATE_TIMER_INTERVAL 3000 enum { STICKER_URI_TYPE_NONE, @@ -50,17 +52,36 @@ enum { static GHashTable *_monitoring_hash = NULL; static char error_buffer[MAX_ERROR_BUFFER]; static GList *consumer_list = NULL; +static guint _terminate_timer_id = 0; extern GMainLoop *main_loop; +static void _terminate_daemon() +{ + LOGD("Terminate sticker daemon"); + g_hash_table_destroy(_monitoring_hash); + _monitoring_hash = NULL; + g_list_free_full(consumer_list, free); + consumer_list = NULL; + g_main_loop_quit(main_loop); +} + +static gboolean _terminate_timer_handler(gpointer user_data) +{ + _terminate_daemon(); + return TRUE; +} + static void _check_watcher_exist() { if (_monitoring_hash != NULL && g_hash_table_size(_monitoring_hash) == 0) { - LOGD("Terminate sticker daemon"); - g_hash_table_destroy(_monitoring_hash); - _monitoring_hash = NULL; - g_list_free_full(consumer_list, free); - consumer_list = NULL; - g_main_loop_quit(main_loop); + if (_terminate_timer_id != 0) { + g_source_remove(_terminate_timer_id); + _terminate_timer_id = 0; + } + + _terminate_timer_id = g_timeout_add(TERMINATE_TIMER_INTERVAL, _terminate_timer_handler, NULL); + if (_terminate_timer_id <= 0) + _terminate_daemon(); } } @@ -70,6 +91,10 @@ static void _on_name_appeared(GDBusConnection *connection, gpointer user_data) { LOGD("name: %s", name); + if (_terminate_timer_id != 0) { + g_source_remove(_terminate_timer_id); + _terminate_timer_id = 0; + } } static void _on_name_vanished(GDBusConnection *connection, -- 2.7.4 From 609072eab62ecf3836caffe997dd51e7256179a0 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 20 Oct 2022 18:49:34 +0900 Subject: [PATCH 09/16] Update package version to 1.2.8 Change-Id: If26879b78270b87e1f7ccf56ad7a9505d38e2d02 --- packaging/capi-ui-sticker.spec | 2 +- receiver/tizen-manifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 98da82b..fe8f48b 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -1,6 +1,6 @@ Name: capi-ui-sticker Summary: Sticker client library and daemon -Version: 1.2.7 +Version: 1.2.8 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 7ba9c98..51d8074 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From c01af2322b2bd6dbbb72d0b66b1d9ed7ef7c4861 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 10 Nov 2022 10:33:48 +0900 Subject: [PATCH 10/16] Exclude dbus file for coverage Change-Id: Ibf22ab08c31f7d6f68d46c0b346d7f2d7757c79c Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index fe8f48b..f390317 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -129,6 +129,7 @@ builddir=$(basename $PWD) gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir" mkdir -p "$gcno_obj_dir" find ./server/ -name '*.gcno' -exec rm {} \; +find . -name '*_dbus*.gcno' -exec rm {} \; find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';' %endif -- 2.7.4 From 2a51ef3d487f5a26325c77b787a02f2e7d1e946b Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 10 Nov 2022 10:34:24 +0900 Subject: [PATCH 11/16] Update package version to 1.2.9 Change-Id: I332e6b0731767fcb26d7dae52c178df0f08f2deb Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index f390317..f4a791a 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -1,6 +1,6 @@ Name: capi-ui-sticker Summary: Sticker client library and daemon -Version: 1.2.8 +Version: 1.2.9 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 -- 2.7.4 From 58c8943072ee676007b1b04ef7e98a3148392805 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 7 Dec 2022 16:54:17 +0900 Subject: [PATCH 12/16] Exclude tests directory for coverage Change-Id: I72acc327504655def62b69a7f6fde01c2e9b69b7 --- packaging/capi-ui-sticker.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index f4a791a..76c3328 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -129,6 +129,7 @@ builddir=$(basename $PWD) gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir" mkdir -p "$gcno_obj_dir" find ./server/ -name '*.gcno' -exec rm {} \; +find ./tests/ -name '*.gcno' -not -path "*/client/*" -exec rm {} \; find . -name '*_dbus*.gcno' -exec rm {} \; find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';' %endif -- 2.7.4 From 69553bc6138f4db96df23d96d8d627e34a108fc4 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 9 Dec 2022 17:00:41 +0900 Subject: [PATCH 13/16] Remove unnecessary memory allocation function Change-Id: I26800d69df15e3df89000fe287ea907a36dc09c1 --- server/stickerd_data_manager.c | 11 +++++------ server/stickerd_dbus.c | 9 ++++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index 66915b6..7ab5a7f 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -60,7 +60,7 @@ static void _terminate_daemon() LOGD("Terminate sticker daemon"); g_hash_table_destroy(_monitoring_hash); _monitoring_hash = NULL; - g_list_free_full(consumer_list, free); + g_list_free(consumer_list); consumer_list = NULL; g_main_loop_quit(main_loop); } @@ -110,8 +110,10 @@ static void _on_name_vanished(GDBusConnection *connection, delete_monitoring_list(&_monitoring_hash, info->bus_name, info->watcher_id); } - if (g_list_find(consumer_list, info->bus_name)) - consumer_list = g_list_remove(consumer_list, info->bus_name); + GList *node = g_list_find_custom(consumer_list, info->bus_name, (GCompareFunc) strcmp); + if (node) { + consumer_list = g_list_delete_link(consumer_list, node); + } if (info->bus_name) free(info->bus_name); @@ -131,9 +133,6 @@ static void _stickerd_client_dbus_method_call_handler(GDBusConnection *conn, con if (_monitoring_hash == NULL) _monitoring_hash = g_hash_table_new(g_direct_hash, g_direct_equal); - if (consumer_list == NULL) - consumer_list = g_list_alloc(); - GVariant *reply_body = NULL; int ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; diff --git a/server/stickerd_dbus.c b/server/stickerd_dbus.c index d125daf..96d22f0 100644 --- a/server/stickerd_dbus.c +++ b/server/stickerd_dbus.c @@ -84,7 +84,7 @@ int stickerd_server_register(GVariant *parameters, GVariant **reply_body, const } if ((CLIENT_LIB)c_lib == STICKER_CLIENT_LIB_CONSUMER) - *consumer_list = g_list_append(*consumer_list, strdup((const char *)sender)); + *consumer_list = g_list_append(*consumer_list, g_strdup((sender))); LOGD("sender: %s, watcher: %d", sender, m_info->watcher_id); monitoring_list = g_list_append(monitoring_list, list_bus_name); @@ -117,8 +117,11 @@ int stickerd_server_unregister(GVariant *parameters, GVariant **reply_body, cons g_variant_get(parameters, "(ii)", &c_lib, &watcher_id); - if ((CLIENT_LIB)c_lib == STICKER_CLIENT_LIB_CONSUMER) - *consumer_list = g_list_remove(*consumer_list, sender); + if ((CLIENT_LIB)c_lib == STICKER_CLIENT_LIB_CONSUMER) { + GList *node = g_list_find_custom(*consumer_list, sender, (GCompareFunc) strcmp); + if (node) + *consumer_list = g_list_delete_link(*consumer_list, node); + } if (g_hash_table_lookup(*monitoring_hash, GUINT_TO_POINTER(watcher_id)) != NULL) { g_bus_unwatch_name(watcher_id); -- 2.7.4 From 10171347828ee6cd8d906f006c323ba1df6b4579 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 9 Dec 2022 18:13:11 +0900 Subject: [PATCH 14/16] Update package version to 1.2.10 Change-Id: Icf62e304e12195fb4945d1f3b0dcc50c130e68de --- packaging/capi-ui-sticker.spec | 2 +- receiver/tizen-manifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 76c3328..33583b3 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -1,6 +1,6 @@ Name: capi-ui-sticker Summary: Sticker client library and daemon -Version: 1.2.9 +Version: 1.2.10 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 51d8074..c6318eb 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From ddab8293a8714ebf78ab7cf525a9e3bd3473f7af Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 23 Dec 2022 11:05:53 +0900 Subject: [PATCH 15/16] Fix issue detected by static analysis tool Change-Id: I5c7132c5aaa0a67fabac50e4fe8463cceaafec5a --- server/stickerd_db_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index 7240d04..5cbe566 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -504,7 +504,7 @@ int stickerd_db_delete_sticker_info(int record_id) uri = sqlite3_column_text(stmt, 1); thumbnail = sqlite3_column_text(stmt, 2); - if (uri_type == 1 && unlink((const char *)uri) == -1) + if (uri_type == 1 && uri && unlink((const char *)uri) == -1) LOGE("fail to delete sticker file"); if (thumbnail && unlink((const char *)thumbnail) == -1) -- 2.7.4 From 298a37f2cc87fa51aec717226f36f5997036115d Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 26 Dec 2022 14:33:15 +0900 Subject: [PATCH 16/16] Update package version to 1.2.11 Change-Id: Id93615bfc50af9fe8fd9abfd9b75ae190fcd06de --- packaging/capi-ui-sticker.spec | 2 +- receiver/tizen-manifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 33583b3..be2700d 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -1,6 +1,6 @@ Name: capi-ui-sticker Summary: Sticker client library and daemon -Version: 1.2.10 +Version: 1.2.11 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index c6318eb..a9f2ebc 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4