From 20bb66aa2c1c8df0a32d52861288a54039688374 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Sat, 10 Oct 2020 13:40:49 +0900 Subject: [PATCH 01/16] Support to request sticker sync when BT connects after disconnecting Change-Id: I9d0b876024eab482fbe3ac38c73f4dbcfcab07dd Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 4467722..9a684cb 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -449,16 +449,13 @@ static bool process_request_queue() case REQUEST_TYPE_FEATURE_REQ: STLOGD("[Request feature exchange]"); request_sticker_feature(); - ReqQueue.pop(); break; case REQUEST_TYPE_SYNC: - STLOGD("[Request to sync sticker] mode: %s, category: %s, type : %s", request.mode.c_str(), + STLOGD("[Request to sync sticker] mode: %s, category: %s, type: %s", request.mode.c_str(), request.category.c_str(), request.type.c_str()); - if (request_sticker_data(request.mode.c_str(), request.category.c_str(), request.type.c_str())) - ReqQueue.pop(); - + request_sticker_data(request.mode.c_str(), request.category.c_str(), request.type.c_str()); break; case REQUEST_TYPE_SHOW_NOTIFICATION: STLOGD("[Request to show notification]"); @@ -662,7 +659,6 @@ static void _on_connection_terminated(sap_peer_agent_h peer_agent, set_sync_progressing(FALSE); send_message("sync_stop_result", "cancel"); - sticker_service_quit(); } static void sticker_service_quit() @@ -745,6 +741,19 @@ static void send_sync_start_response(int result_code) #endif } +static void pop_sticker_request(request_type req_type) +{ + if (ReqQueue.empty()) + return; + + StickerRequest request = ReqQueue.front(); + STLOGD ("request type : %d", request.req_type); + if (request.req_type == req_type) { + STLOGD ("pop sync request"); + ReqQueue.pop(); + } +} + void on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned int payload_length, void *buffer, void *user_data) /* message exchange on_receive callback (sap_agent_data_received_cb) */ @@ -805,6 +814,8 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in STLOGW("No vconf supported feature"); #endif + pop_sticker_request(REQUEST_TYPE_FEATURE_REQ); + if (!process_request_queue()) { sticker_service_quit(); } @@ -865,6 +876,8 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in sticker_service_quit(); } + + pop_sticker_request(REQUEST_TYPE_SYNC); } } else if (msg_id == STICKER_SEND_START_REQ) { STLOGD("msg : %s", msg_id.c_str()); -- 2.7.4 From bed9e5b6117d870d182b5c1367951f9aed396720 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Sat, 10 Oct 2020 14:07:05 +0900 Subject: [PATCH 02/16] Revert "Fix to request sticker feature only once" Sticker sync feature can be changed after synchronization. This reverts commit 3eab9e95c212ccf8887363781d8d0deda1eafce3. Change-Id: I3bb0e0bcd1216ea2e0b15b06a8a69e06e10e9aa4 --- receiver/inc/ft.h | 2 -- receiver/inc/receiver_preference.h | 1 - receiver/src/ft.cpp | 22 ---------------------- receiver/src/main.cpp | 16 +--------------- 4 files changed, 1 insertion(+), 40 deletions(-) diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index 55a4ffa..afab92e 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -40,6 +40,4 @@ void request_show_sync_notification(); bool get_job_progress(); -bool get_receive_sticker_feature(); - #endif /* __FT_H__ */ diff --git a/receiver/inc/receiver_preference.h b/receiver/inc/receiver_preference.h index aae2c88..02fc7e3 100644 --- a/receiver/inc/receiver_preference.h +++ b/receiver/inc/receiver_preference.h @@ -19,6 +19,5 @@ #define LAST_SYNC_TIME "LastSyncTime" #define LAST_LOG_FILE_INDEX "LastLogFileIndex" -#define RECEIVED_STICKER_FEATURE "ReceivedStickerFeature" #endif /* __RECEIVER_PREFERENCE_H__ */ diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 9a684cb..26883b3 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -107,27 +107,6 @@ static void save_last_sync_time() } } -static void save_receive_sticker_feature(bool received) -{ - // received sticker feature or not - if (preference_set_boolean(RECEIVED_STICKER_FEATURE, received) == PREFERENCE_ERROR_NONE) { - STLOGI("Succeed to set the flag of receive sticker feature : %d", received); - } - else { - STLOGW("Failed to set the flag of receive sticker feature"); - } -} - -bool get_receive_sticker_feature() -{ - bool result = false; - if (preference_get_boolean(RECEIVED_STICKER_FEATURE, &result) != PREFERENCE_ERROR_NONE) { - STLOGW("Failed to get receive sticker feature"); - } - - return result; -} - static void set_sync_first_complete() { int complete_flags = 0; @@ -792,7 +771,6 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in request_all_sticker_data("manual", "input"); } else if (msg_id == STICKER_SYNC_FEATURE_RSP) { STLOGD("msg : %s", msg_id.c_str()); - save_receive_sticker_feature(true); #ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE const char *json_aremoji = json_object_get_string_member(root_obj, "arEmoji"); const char *json_bitmoji = json_object_get_string_member(root_obj, "bitmoji"); diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index aeefd28..aa196e1 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -209,13 +209,7 @@ static void process_auto_sync() if (check_battery_condition()) { STLOGD("Starting auto synchronization"); initialize_sap(); - if (get_receive_sticker_feature()) { - STLOGI("Already sticker feature is received"); - } - else { - request_sticker_feature(); - } - + request_sticker_feature(); request_auto_sync(); } else { @@ -236,14 +230,6 @@ static void process_auto_sync() static void get_sticker_feature() { - if (get_receive_sticker_feature()) { - STLOGI("Already sticker feature is received"); - if (!is_init_sap()) - service_app_exit(); - - return; - } - #ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE // Check whether oobe has been done int feature_flag = 0; -- 2.7.4 From 45906621bc3d16b6ba02ff159775b573a9e6c9dc Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Sat, 10 Oct 2020 14:45:50 +0900 Subject: [PATCH 03/16] Update package version to 0.1.64 Change-Id: Iae5d517d45a996cf1934abed18e39a53a4423c84 Signed-off-by: Jihoon Kim --- 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 e5f5d4a..8b4618e 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: 0.1.63 +Version: 0.1.64 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index b8c75ad..e1ecb31 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 43029bd2900c771165f6f6e94d0a7791fedd96ba Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 24 Sep 2020 17:21:47 +0900 Subject: [PATCH 04/16] Rename from whitelist to allowlist Change-Id: Ia7b03469aeddf9972a0a5087ba73f6ee8ce2d8e7 Signed-off-by: Jihoon Kim --- sticker-parser/sticker-parser.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sticker-parser/sticker-parser.c b/sticker-parser/sticker-parser.c index a54e9ab..1dc1a48 100644 --- a/sticker-parser/sticker-parser.c +++ b/sticker-parser/sticker-parser.c @@ -506,7 +506,7 @@ static void __insert_sticker_keyword_info(const char *keyword) return; } -static void __insert_sticker_whitelist_info(const char *provider, const char *consumer) { +static void __insert_sticker_allowlist_info(const char *provider, const char *consumer) { int ret; sqlite3 *db = NULL; sqlite3_stmt *stmt = NULL; @@ -532,7 +532,7 @@ static void __insert_sticker_whitelist_info(const char *provider, const char *co sqlite3_finalize(stmt); sqlite3_close(db); } else { - LOGE("fail to insert sticker whiltelist : %s", sqlite3_errmsg(db)); + LOGE("fail to insert sticker allowlist : %s", sqlite3_errmsg(db)); sqlite3_finalize(stmt); sqlite3_close(db); } @@ -574,10 +574,10 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path goto cleanup; } - JsonArray *whitelist_arr = json_object_get_array_member(root_obj, "whitelist"); - if (whitelist_arr != NULL) { - for (int i = 0; i < json_array_get_length(whitelist_arr); i++) { - __insert_sticker_whitelist_info(appid, json_array_get_string_element(whitelist_arr, i)); + JsonArray *allowlist_arr = json_object_get_array_member(root_obj, "whitelist"); + if (allowlist_arr != NULL) { + for (int i = 0; i < json_array_get_length(allowlist_arr); i++) { + __insert_sticker_allowlist_info(appid, json_array_get_string_element(allowlist_arr, i)); } } @@ -706,7 +706,7 @@ cleanup: return ret; } -static void __delete_sticker_whitelist(const char *db_path, const char *app_id) +static void __delete_sticker_allowlist(const char *db_path, const char *app_id) { int ret; sqlite3 *db = NULL; @@ -718,7 +718,7 @@ static void __delete_sticker_whitelist(const char *db_path, const char *app_id) ret = sqlite3_prepare_v2(db, "DELETE FROM sticker_whitelist_info WHERE provider_id = ?", -1, &stmt, NULL); if (ret != SQLITE_OK) { - LOGE("failed to delete sticker whitelist : %s", sqlite3_errmsg(db)); + LOGE("failed to delete sticker allowlist : %s", sqlite3_errmsg(db)); sqlite3_finalize(stmt); sqlite3_close(db); goto cleanup; @@ -931,7 +931,7 @@ int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList sqlite3_close(db); } - __delete_sticker_whitelist(db_path, appid); + __delete_sticker_allowlist(db_path, appid); return 0; } -- 2.7.4 From 087aac2ab6d6d9e3a76a7818ebea9f075bd21766 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 29 Oct 2020 10:28:04 +0900 Subject: [PATCH 05/16] Fixed issue regarding not able to check for the existence of the sticker Change-Id: Id684199f552d04e6d3c865eeafe5f49089d533fd --- client/sticker_defs.h | 1 + provider/sticker_provider.c | 29 +++++++++++++++++++++++------ server/stickerd_data_manager.c | 1 - 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/client/sticker_defs.h b/client/sticker_defs.h index 69167ec..f00e7da 100644 --- a/client/sticker_defs.h +++ b/client/sticker_defs.h @@ -49,6 +49,7 @@ extern "C" { } \ } \ } while (0) +#define STICKER_DIRECTORY "/opt/usr/share/sticker-data" typedef enum { STICKER_CLIENT_LIB_NONE, diff --git a/provider/sticker_provider.c b/provider/sticker_provider.c index 82e32c8..8b5ef32 100644 --- a/provider/sticker_provider.c +++ b/provider/sticker_provider.c @@ -136,26 +136,43 @@ EXPORT_API int sticker_provider_insert_data(sticker_provider_h provider_handle, if (!provider_handle || !data_handle || (data_handle->sticker_info_id > 0) || !data_handle->uri) return STICKER_ERROR_INVALID_PARAMETER; - ret = sticker_dbus_check_file_exists(provider_handle->gdbus_connection, data_handle->uri, &is_exist); + int len = strlen(STICKER_DIRECTORY) + strlen(data_handle->app_id) + strlen(data_handle->uri) + 3; + char *new_path = (char *)calloc(len, sizeof(char)); + + if (data_handle->uri[0] == '/') + snprintf(new_path, len, "%s/%s%s",STICKER_DIRECTORY, data_handle->app_id, data_handle->uri); + else + snprintf(new_path, len, "%s/%s/%s",STICKER_DIRECTORY, data_handle->app_id, data_handle->uri); + + ret = sticker_dbus_check_file_exists(provider_handle->gdbus_connection, new_path, &is_exist); if (ret != STICKER_ERROR_NONE) { LOGE("Failed to check file exists : %d", ret); - return STICKER_ERROR_OPERATION_FAILED; + ret = STICKER_ERROR_OPERATION_FAILED; + goto cleanup; } if (is_exist) { LOGE("Sticker already exists"); - return STICKER_ERROR_FILE_EXISTS; + ret = STICKER_ERROR_FILE_EXISTS; + goto cleanup; } ret = sticker_dbus_insert_sticker_info(provider_handle->gdbus_connection, data_handle); if (ret != STICKER_ERROR_NONE) { LOGE("Failed to insert sticker information : %d", ret); if (ret == STICKER_CLIENT_ERROR_NO_SUCH_FILE) - return STICKER_ERROR_NO_SUCH_FILE; + ret = STICKER_ERROR_NO_SUCH_FILE; else - return STICKER_ERROR_OPERATION_FAILED; + ret = STICKER_ERROR_OPERATION_FAILED; } - return STICKER_ERROR_NONE; + +cleanup: + if (new_path) { + free(new_path); + new_path = NULL; + } + + return ret; } EXPORT_API int sticker_provider_insert_data_by_json_file(sticker_provider_h provider_handle, const char *json_path, sticker_provider_insert_finished_cb callback, void *user_data) diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index 1be9971..c9b8f8b 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -39,7 +39,6 @@ #endif #define LOG_TAG "STICKERD_DATA_MANAGER" -#define STICKER_DIRECTORY "/opt/usr/share/sticker-data" #define MAX_ERROR_BUFFER 256 static GHashTable *_monitoring_hash = NULL; -- 2.7.4 From 6f27f39935b01d05de6beefe0c13d68102398bee Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 29 Oct 2020 10:07:11 +0900 Subject: [PATCH 06/16] Update package version to 0.1.65 Change-Id: Ic26ef97758bd7436f773aab5fe60ad46c570cc6b --- 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 8b4618e..ff54d1a 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: 0.1.64 +Version: 0.1.65 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index e1ecb31..d6ffeb2 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 04f498b5312540cb744eebe27546f9c8f8c3fc8f Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 13 Nov 2020 17:35:30 +0900 Subject: [PATCH 07/16] Fix defect detected by static analysis tool Change-Id: I2c85677795cf9157f825d51440119fa031060b40 Signed-off-by: Jihoon Kim --- provider/sticker_provider.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/provider/sticker_provider.c b/provider/sticker_provider.c index 8b5ef32..bbac999 100644 --- a/provider/sticker_provider.c +++ b/provider/sticker_provider.c @@ -138,6 +138,9 @@ EXPORT_API int sticker_provider_insert_data(sticker_provider_h provider_handle, int len = strlen(STICKER_DIRECTORY) + strlen(data_handle->app_id) + strlen(data_handle->uri) + 3; char *new_path = (char *)calloc(len, sizeof(char)); + if (!new_path) { + return STICKER_ERROR_OUT_OF_MEMORY; + } if (data_handle->uri[0] == '/') snprintf(new_path, len, "%s/%s%s",STICKER_DIRECTORY, data_handle->app_id, data_handle->uri); @@ -416,4 +419,4 @@ EXPORT_API int sticker_provider_delete_data_by_uri(sticker_provider_h provider_h } return STICKER_ERROR_NONE; -} \ No newline at end of file +} -- 2.7.4 From 770a3ba32e0563ecb6f826315a35a68e4214d101 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 13 Nov 2020 17:44:20 +0900 Subject: [PATCH 08/16] Update package version to 0.1.66 Change-Id: Ic0d7d6f17690a7c0012b5514e563ffea6cf6a1e4 Signed-off-by: Jihoon Kim --- 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 ff54d1a..a3827dc 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: 0.1.65 +Version: 0.1.66 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index d6ffeb2..38098cf 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 2f7915496f6c431d38dfcfb10fa40c9cc3607245 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 4 Jan 2021 18:29:23 +0900 Subject: [PATCH 09/16] Fix issue that fail to insert stickers when using json file Change-Id: I158c0b78195aba31b8e53c712a8f1ac211d192f2 --- sticker-parser/sticker-parser.c | 48 +++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/sticker-parser/sticker-parser.c b/sticker-parser/sticker-parser.c index 1dc1a48..063aa87 100644 --- a/sticker-parser/sticker-parser.c +++ b/sticker-parser/sticker-parser.c @@ -30,6 +30,7 @@ #include #include #include +#include #ifndef EXPORT_API #define EXPORT_API __attribute__((visibility("default"))) @@ -364,12 +365,21 @@ cleanup: static char* __convert_sticker_uri(char *uri, const char *appid, const char *app_path) { int ret; + char *copy_uri = (char *)calloc(PATH_MAX, sizeof(char)); + if (copy_uri == NULL) { + LOGE("failed to allocate memory"); + return NULL; + } + strncpy(copy_uri, uri, PATH_MAX - 1); __remove_app_path(uri, app_path); int len = strlen(STICKER_DIRECTORY) + strlen(appid) + strlen(uri) + 2; char *new_path = (char *)calloc(len, sizeof(char)); - if (new_path == NULL) - return NULL; + if (new_path == NULL) { + LOGE("failed to allocate memory"); + ret = -1; + goto cleanup; + } snprintf(new_path, len, "%s/%s%s",STICKER_DIRECTORY, appid, uri); @@ -385,14 +395,14 @@ static char* __convert_sticker_uri(char *uri, const char *appid, const char *app goto cleanup; } - if (__file_copy(uri, new_path) == -1) { + if (__file_copy(copy_uri, new_path) == -1) { strerror_r(errno, error_buffer, MAX_ERROR_BUFFER); LOGE("failed to copy sticker file : %s", error_buffer); ret = -1; goto cleanup; } - ret = unlink(uri); + ret = unlink(copy_uri); if (ret != 0) { strerror_r(errno, error_buffer, MAX_ERROR_BUFFER); LOGE("failed to remove sticker file : %s", error_buffer); @@ -402,11 +412,16 @@ static char* __convert_sticker_uri(char *uri, const char *appid, const char *app LOGE("failed to change ownership"); cleanup: + free(copy_uri); + copy_uri = NULL; + if (ret == 0) { return new_path; } else { - free(new_path); - new_path = NULL; + if (new_path) { + free(new_path); + new_path = NULL; + } return NULL; } } @@ -605,10 +620,25 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path goto free_memory; char *rel_thumbnail = __get_string_from_object(info_object, "thumbnail"); - if (rel_thumbnail) { - if (rel_thumbnail[0] != '\0') + if (rel_thumbnail && rel_thumbnail[0] != '\0') { + if (access(rel_thumbnail, F_OK) == 0) { thumbnail_path = __convert_sticker_uri(rel_thumbnail, appid, app_path); - + } else { + int len = strlen(app_path) + strlen(rel_thumbnail) + 2; + char *new_thumbnail_path = (char *)calloc(len, sizeof(char)); + if (new_thumbnail_path) { + if (rel_thumbnail[0] == '/') + snprintf(new_thumbnail_path, len, "%s%s",app_path, rel_thumbnail); + else + snprintf(new_thumbnail_path, len, "%s%s%s",app_path, "/", rel_thumbnail); + + if (access(new_thumbnail_path, F_OK) == 0) + thumbnail_path = __convert_sticker_uri(new_thumbnail_path, appid, app_path); + + free(new_thumbnail_path); + new_thumbnail_path = NULL; + } + } free(rel_thumbnail); } -- 2.7.4 From a6f3f24a4a8a0625e98b6d0e26e666ddf8f35cbc Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 4 Jan 2021 18:44:42 +0900 Subject: [PATCH 10/16] Update package version to 0.1.67 Change-Id: Iad7010d13c4be5b53b3fca4feaf38f897ff57d5a --- 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 a3827dc..86d61dc 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: 0.1.66 +Version: 0.1.67 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 38098cf..55240db 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 65da3e6c1c604259bf81ad0191379f7cb89ea3ca Mon Sep 17 00:00:00 2001 From: InHong Han Date: Tue, 5 Jan 2021 16:14:33 +0900 Subject: [PATCH 11/16] Fix defect detected by static analysis tool Change-Id: If2fdcb684b69c968d1b8add326cb35e0414bffdb --- sticker-parser/sticker-parser.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/sticker-parser/sticker-parser.c b/sticker-parser/sticker-parser.c index 063aa87..71b7a0d 100644 --- a/sticker-parser/sticker-parser.c +++ b/sticker-parser/sticker-parser.c @@ -620,26 +620,30 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path goto free_memory; char *rel_thumbnail = __get_string_from_object(info_object, "thumbnail"); - if (rel_thumbnail && rel_thumbnail[0] != '\0') { - if (access(rel_thumbnail, F_OK) == 0) { - thumbnail_path = __convert_sticker_uri(rel_thumbnail, appid, app_path); - } else { - int len = strlen(app_path) + strlen(rel_thumbnail) + 2; - char *new_thumbnail_path = (char *)calloc(len, sizeof(char)); - if (new_thumbnail_path) { - if (rel_thumbnail[0] == '/') - snprintf(new_thumbnail_path, len, "%s%s",app_path, rel_thumbnail); - else - snprintf(new_thumbnail_path, len, "%s%s%s",app_path, "/", rel_thumbnail); - - if (access(new_thumbnail_path, F_OK) == 0) - thumbnail_path = __convert_sticker_uri(new_thumbnail_path, appid, app_path); - - free(new_thumbnail_path); - new_thumbnail_path = NULL; + if (rel_thumbnail) { + if (rel_thumbnail[0] != '\0') { + if (access(rel_thumbnail, F_OK) == 0) { + thumbnail_path = __convert_sticker_uri(rel_thumbnail, appid, app_path); + } else { + int len = strlen(app_path) + strlen(rel_thumbnail) + 2; + char *new_thumbnail_path = (char *)calloc(len, sizeof(char)); + if (new_thumbnail_path) { + if (rel_thumbnail[0] == '/') + snprintf(new_thumbnail_path, len, "%s%s",app_path, rel_thumbnail); + else + snprintf(new_thumbnail_path, len, "%s%s%s",app_path, "/", rel_thumbnail); + + if (access(new_thumbnail_path, F_OK) == 0) + thumbnail_path = __convert_sticker_uri(new_thumbnail_path, appid, app_path); + + free(new_thumbnail_path); + new_thumbnail_path = NULL; + } } } + free(rel_thumbnail); + rel_thumbnail = NULL; } description = __get_string_from_object(info_object, "description"); -- 2.7.4 From a145da27604a6941c32fee17d2cb557a0a988b80 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Tue, 5 Jan 2021 16:28:11 +0900 Subject: [PATCH 12/16] Update package version to 0.1.68 Change-Id: Iae9e70234de366d90ceb0b5e98efc546816fc457 --- 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 86d61dc..d83c2bb 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: 0.1.67 +Version: 0.1.68 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 55240db..55273cc 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 8b8934a6a0d690b8504e8fa6bc382f031b9aaf8b Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 25 Mar 2021 10:44:45 +0900 Subject: [PATCH 13/16] Change API description by API review Change-Id: I60ef9bf6887c3fb17e10ed43622ba3f765295bbc --- include/sticker_provider.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sticker_provider.h b/include/sticker_provider.h index 65a4d78..ead39f0 100644 --- a/include/sticker_provider.h +++ b/include/sticker_provider.h @@ -202,7 +202,7 @@ int sticker_provider_delete_data(sticker_provider_h provider_handle, sticker_dat /** * @brief Deletes a sticker with the given @a uri from the sticker database. - * @details If the database does not have a sticker that matches the given @a uri, the STICKER_ERROR_NO_SUCH_FILE error is returned. + * @details If the database does not have a sticker that matches the given @a uri, the #STICKER_ERROR_NO_SUCH_FILE error is returned. * @since_tizen 5.5 * @param[in] provider_handle The sticker provider handle * @param[in] uri The URI of the sticker data to be deleted -- 2.7.4 From 22e3fd3acfd34e6a93df5499a105b07e51f6e872 Mon Sep 17 00:00:00 2001 From: "jay.ho.park" Date: Tue, 5 Jan 2021 10:28:10 +0900 Subject: [PATCH 14/16] Init/Deinit sync when BT attached/detached Change-Id: I46031dc5378c971258234d92cec6fd00c62ad7fa --- receiver/inc/receiver_preference.h | 4 ++++ receiver/src/ft.cpp | 20 +++++++++------- receiver/src/main.cpp | 49 ++++++++++++++++++++++++++++++++++---- receiver/tizen-manifest.xml | 2 +- 4 files changed, 60 insertions(+), 15 deletions(-) diff --git a/receiver/inc/receiver_preference.h b/receiver/inc/receiver_preference.h index 02fc7e3..820e725 100644 --- a/receiver/inc/receiver_preference.h +++ b/receiver/inc/receiver_preference.h @@ -20,4 +20,8 @@ #define LAST_SYNC_TIME "LastSyncTime" #define LAST_LOG_FILE_INDEX "LastLogFileIndex" +#define LAST_SYNC_STATUS "LastSyncStatus" +#define LAST_SYNC_STATUS_SYNC_SUCCESS 1 +#define LAST_SYNC_STATUS_SYNC_NEEDED 0 + #endif /* __RECEIVER_PREFERENCE_H__ */ diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 26883b3..4d24be9 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -95,16 +95,18 @@ static int sync_complete_flags = 0; static void sticker_service_quit(); -static void save_last_sync_time() +static void save_last_sync_info() { - // save last sync time in preference double current_time = ecore_time_unix_get(); - if (preference_set_double(LAST_SYNC_TIME, current_time) == PREFERENCE_ERROR_NONE) { - STLOGI("Succeed to set last sync time : %f", current_time); - } - else { + STLOGI("Need to set last sync time as %f, last sync status as SUCCESS", current_time); + + if (preference_set_double(LAST_SYNC_TIME, current_time) != PREFERENCE_ERROR_NONE) { STLOGW("Failed to set last sync time"); } + + if (preference_set_int(LAST_SYNC_STATUS, LAST_SYNC_STATUS_SYNC_SUCCESS) != PREFERENCE_ERROR_NONE) { + STLOGE("Failed to set sync status as SUCCESS"); + } } static void set_sync_first_complete() @@ -122,7 +124,7 @@ static void set_sync_first_complete() static void set_sync_complete() { set_sync_first_complete(); - save_last_sync_time(); + save_last_sync_info(); } static void set_sync_progressing(gboolean flag) @@ -850,8 +852,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in send_sync_start_response(result_code); set_sync_progressing(FALSE); - save_last_sync_time(); - + save_last_sync_info(); sticker_service_quit(); } @@ -1244,6 +1245,7 @@ static void _on_device_status_changed(sap_device_status_e status, case SAP_DEVICE_STATUS_DETACHED: STLOGD("device is detached."); send_message("sync_stop_result", "cancel"); + sticker_service_quit(); break; case SAP_DEVICE_STATUS_ATTACHED: STLOGD("Attached calling find peer now"); diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index aa196e1..6ba29ed 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -173,9 +173,33 @@ static void process_request(app_control_h app_control, char *request) goto cleanup; if (mode && type) { - if (!is_init_sap()) { - initialize_sap(); - request_all_sticker_data(mode, type); + if (check_battery_condition()) { + if (check_sync_time_condition()) { + if (preference_set_int(LAST_SYNC_STATUS, LAST_SYNC_STATUS_SYNC_NEEDED) != PREFERENCE_ERROR_NONE) + STLOGE("Failed to set sync status as NEEDED"); + + if (!is_init_sap()) + initialize_sap(); + request_all_sticker_data(mode, type); + } else { // Under the sync interval time. Need to check whether last sync was succeded or not. + int last_sync_status = 0; + + if (preference_get_int(LAST_SYNC_STATUS, &last_sync_status) != PREFERENCE_ERROR_NONE) { + STLOGE("Failed to get sync status. Default action is exit."); + goto cleanup; + } + + if (last_sync_status == LAST_SYNC_STATUS_SYNC_NEEDED) { + STLOGD("Last sync status is NEEDED(code: %d). Retrying to sync.", last_sync_status); + if (!is_init_sap()) + initialize_sap(); + request_all_sticker_data(mode, type); + } else { + STLOGD("Last sync status is SUCCESS(code: %d). Don't have to retrying sync", last_sync_status); + } + } + } else { + STLOGD("Not enough battery."); } } } @@ -208,6 +232,8 @@ static void process_auto_sync() if (check_sync_time_condition()) { if (check_battery_condition()) { STLOGD("Starting auto synchronization"); + if (preference_set_int(LAST_SYNC_STATUS, LAST_SYNC_STATUS_SYNC_NEEDED) != PREFERENCE_ERROR_NONE) + STLOGE("Failed to set sync status as NEEDED"); initialize_sap(); request_sticker_feature(); request_auto_sync(); @@ -222,8 +248,21 @@ static void process_auto_sync() } else { if (!get_job_progress()) { - STLOGD("exit"); - service_app_exit(); + int last_sync_status = 0; + if (preference_get_int(LAST_SYNC_STATUS, &last_sync_status) != PREFERENCE_ERROR_NONE) { + STLOGE("Failed to get sync status. Default action is exit."); + service_app_exit(); + } + + if (last_sync_status == LAST_SYNC_STATUS_SYNC_NEEDED) { + STLOGD("Last sync status is NEEDED(code: %d). Retrying to sync.", last_sync_status); + initialize_sap(); + request_sticker_feature(); + request_auto_sync(); + } else { + STLOGD("Last sync status is SUCCESS(code: %d). Don't have to retrying sync", last_sync_status); + service_app_exit(); + } } } } diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 55273cc..af921e8 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -4,7 +4,7 @@ - + -- 2.7.4 From a47417b5e25e5ab9529d73f489561a66c34571a8 Mon Sep 17 00:00:00 2001 From: "jay.ho.park" Date: Tue, 5 Jan 2021 10:35:50 +0900 Subject: [PATCH 15/16] Pop item from queue to prevent duplicated request Change-Id: I04f4d7d7f07aa74e94b7a85ece4a29ed0f3501ea --- receiver/inc/ft.h | 5 +-- receiver/src/ft.cpp | 116 ++++++++++++++++++++++---------------------------- receiver/src/main.cpp | 25 ++++++++--- 3 files changed, 71 insertions(+), 75 deletions(-) diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index afab92e..f3a735c 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -33,10 +33,9 @@ gboolean is_init_sap(); void request_all_sticker_data(const char *mode, const char *type); bool request_sticker_data(const char *mode, const char *category, const char *type); -void request_auto_sync(); -void request_sticker_feature(); +bool request_sticker_feature(); void send_disconnect_message(); -void request_show_sync_notification(); +bool request_show_sync_notification(); bool get_job_progress(); diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 4d24be9..9a717ee 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -93,6 +93,26 @@ static int sync_success_cnt = 0; static gboolean job_progress = FALSE; static int sync_complete_flags = 0; +void push_sticker_request(request_type req_type, const char *mode, const char *category, const char *type) +{ + StickerRequest pending_request; + + pending_request.req_type = req_type; + + if (mode != NULL) + pending_request.mode = string(mode); + + if (category != NULL) + pending_request.category = string(category); + + if (type != NULL) + pending_request.type = string(type); + + ReqQueue.push(pending_request); + STLOGI("Push sticker request: req_type[%d], mode[%s], category[%s], type[%s]", + pending_request.req_type, pending_request.mode.c_str(), pending_request.category.c_str(), pending_request.type.c_str()); +} + static void sticker_service_quit(); static void save_last_sync_info() @@ -374,14 +394,6 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty if (!priv_data.socket) { job_progress = TRUE; - StickerRequest pending_request; - pending_request.req_type = REQUEST_TYPE_SYNC; - pending_request.mode = string(mode ? mode : "manual"); - pending_request.category = string(category ? category : "arsticker"); - pending_request.type = string(type ? type : "input"); - - ReqQueue.push(pending_request); - STLOGI("Push sync request"); return false; } @@ -403,6 +415,7 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty if (_send_json_data(j_object) == FALSE) { STLOGE("Failed to send STICKER_SYNC_START_REQ"); + result = false; } else { @@ -429,19 +442,26 @@ static bool process_request_queue() switch (request.req_type) { case REQUEST_TYPE_FEATURE_REQ: STLOGD("[Request feature exchange]"); - request_sticker_feature(); + + if (true == request_sticker_feature()) + ReqQueue.pop(); + break; case REQUEST_TYPE_SYNC: STLOGD("[Request to sync sticker] mode: %s, category: %s, type: %s", request.mode.c_str(), request.category.c_str(), request.type.c_str()); - request_sticker_data(request.mode.c_str(), request.category.c_str(), request.type.c_str()); + if (true == request_sticker_data(request.mode.c_str(), request.category.c_str(), request.type.c_str())) + ReqQueue.pop(); + break; case REQUEST_TYPE_SHOW_NOTIFICATION: STLOGD("[Request to show notification]"); - request_show_sync_notification(); - ReqQueue.pop(); + + if (true == request_show_sync_notification()) + ReqQueue.pop(); + break; case REQUEST_TYPE_AUTOSYNC: STLOGD("[Request to sync automatically]"); @@ -455,65 +475,45 @@ static bool process_request_queue() return true; } -void request_auto_sync() -{ - STLOGD("Add request to sync automatically"); - StickerRequest pending_request; - pending_request.req_type = REQUEST_TYPE_AUTOSYNC; - ReqQueue.push(pending_request); -} - void request_all_sticker_data(const char *mode, const char *type) { - StickerRequest pending_request; - pending_request.req_type = REQUEST_TYPE_SYNC; - pending_request.mode = string(mode); - pending_request.type = string(type); - #ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE int feature_flag = 0; if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0) { if (feature_flag & VCONFKEY_STICKER_FEATURE_AREMOJI) { - pending_request.category = string("arsticker"); - ReqQueue.push(pending_request); + push_sticker_request(REQUEST_TYPE_SYNC, mode, "arsticker", type); } if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) { - pending_request.category = string("bitmoji"); - ReqQueue.push(pending_request); + push_sticker_request(REQUEST_TYPE_SYNC, mode, "bitmoji", type); } } else STLOGW("Failed to get value of VCONFKEY_STICKER_SUPPORTED_FEATURE"); #else - pending_request.category = string("arsticker"); - ReqQueue.push(pending_request); - pending_request.category = string("bitmoji"); - ReqQueue.push(pending_request); + push_sticker_request(REQUEST_TYPE_SYNC, mode, "arsticker", type); + push_sticker_request(REQUEST_TYPE_SYNC, mode, "bitmoji", type); #endif if (priv_data.socket) process_request_queue(); } -void request_sticker_feature() +bool request_sticker_feature() { + bool result = false; JsonObject *j_object = NULL; if (!priv_data.socket) { job_progress = TRUE; - StickerRequest pending_request; - pending_request.req_type = REQUEST_TYPE_FEATURE_REQ; - ReqQueue.push(pending_request); - STLOGI("Push sync feature request"); - return; + return false; } j_object = json_object_new(); if (j_object == NULL) { STLOGE("json object create error"); - return; + return false; } json_object_set_string_member(j_object, "msgId", STICKER_SYNC_FEATURE_REQ); @@ -521,15 +521,19 @@ void request_sticker_feature() if (_send_json_data(j_object) == FALSE) { STLOGE("Failed to send STICKER_SYNC_FEATURE_REQ"); + result = false; } else { job_progress = TRUE; + result = true; } json_object_unref(j_object); if (_create_thumbnail_directory() != 0) STLOGE("Failed to create thumbnail directory"); + + return result; } void send_disconnect_message() @@ -551,23 +555,20 @@ void send_disconnect_message() json_object_unref(j_object); } -void request_show_sync_notification() +bool request_show_sync_notification() { + bool result = false; JsonObject *j_object = NULL; if (!priv_data.socket) { job_progress = TRUE; - StickerRequest pending_request; - pending_request.req_type = REQUEST_TYPE_SHOW_NOTIFICATION; - ReqQueue.push(pending_request); - STLOGI("Push show notification request"); - return; + return false; } j_object = json_object_new(); if (j_object == NULL) { STLOGE("json object create error"); - return; + return false; } json_object_set_string_member(j_object, "msgId", STICKER_REQUEST_NOTI_REQ); @@ -575,11 +576,14 @@ void request_show_sync_notification() if (_send_json_data(j_object) == FALSE) { STLOGE("Failed to send STICKER_REQUEST_NOTI_REQ"); + result = false; } else { job_progress = TRUE; + result = true; } json_object_unref(j_object); + return result; } void reject_file() @@ -722,19 +726,6 @@ static void send_sync_start_response(int result_code) #endif } -static void pop_sticker_request(request_type req_type) -{ - if (ReqQueue.empty()) - return; - - StickerRequest request = ReqQueue.front(); - STLOGD ("request type : %d", request.req_type); - if (request.req_type == req_type) { - STLOGD ("pop sync request"); - ReqQueue.pop(); - } -} - void on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned int payload_length, void *buffer, void *user_data) /* message exchange on_receive callback (sap_agent_data_received_cb) */ @@ -793,9 +784,6 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in #else STLOGW("No vconf supported feature"); #endif - - pop_sticker_request(REQUEST_TYPE_FEATURE_REQ); - if (!process_request_queue()) { sticker_service_quit(); } @@ -855,8 +843,6 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in save_last_sync_info(); sticker_service_quit(); } - - pop_sticker_request(REQUEST_TYPE_SYNC); } } else if (msg_id == STICKER_SEND_START_REQ) { STLOGD("msg : %s", msg_id.c_str()); diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 6ba29ed..968b4f4 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -114,7 +114,8 @@ static bool check_sync_time_condition() if (timediff > MAX_WAIT_TIME) { STLOGD("Starting manual synchronization"); initialize_sap(); - request_show_sync_notification(); + if (false == request_show_sync_notification()) + push_sticker_request(REQUEST_TYPE_SHOW_NOTIFICATION, NULL, NULL, NULL); result = false; } else { if (timediff > SYNC_INTERVAL) @@ -205,7 +206,9 @@ static void process_request(app_control_h app_control, char *request) } else if (strcmp(request, "oobe") == 0) { initialize_sap(); - request_sticker_feature(); + + if (false == request_sticker_feature()) + push_sticker_request(REQUEST_TYPE_FEATURE_REQ, NULL, NULL, NULL); } else { STLOGW("Unknown command : %s", request); @@ -235,8 +238,11 @@ static void process_auto_sync() if (preference_set_int(LAST_SYNC_STATUS, LAST_SYNC_STATUS_SYNC_NEEDED) != PREFERENCE_ERROR_NONE) STLOGE("Failed to set sync status as NEEDED"); initialize_sap(); - request_sticker_feature(); - request_auto_sync(); + + if (false == request_sticker_feature()) + push_sticker_request(REQUEST_TYPE_FEATURE_REQ, NULL, NULL, NULL); + + push_sticker_request(REQUEST_TYPE_AUTOSYNC, NULL, NULL, NULL); } else { STLOGI("The status of battery is low"); @@ -257,8 +263,11 @@ static void process_auto_sync() if (last_sync_status == LAST_SYNC_STATUS_SYNC_NEEDED) { STLOGD("Last sync status is NEEDED(code: %d). Retrying to sync.", last_sync_status); initialize_sap(); - request_sticker_feature(); - request_auto_sync(); + + if (false == request_sticker_feature()) + push_sticker_request(REQUEST_TYPE_FEATURE_REQ, NULL, NULL, NULL); + + push_sticker_request(REQUEST_TYPE_AUTOSYNC, NULL, NULL, NULL); } else { STLOGD("Last sync status is SUCCESS(code: %d). Don't have to retrying sync", last_sync_status); service_app_exit(); @@ -275,7 +284,9 @@ static void get_sticker_feature() if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0 && feature_flag == 0) { STLOGD("Request to get sticker feature"); initialize_sap(); - request_sticker_feature(); + + if (false == request_sticker_feature()) + push_sticker_request(REQUEST_TYPE_FEATURE_REQ, NULL, NULL, NULL); } else { if (!is_init_sap()) -- 2.7.4 From 4ac6b3a221dee2c474f9dda554ae62e629cc1b0b Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 12 Oct 2021 13:57:35 +0900 Subject: [PATCH 16/16] Fix build error in sticker-receiver Change-Id: I8131bc527af046aaff894ea8884a8e38167106e2 Signed-off-by: Jihoon Kim --- receiver/inc/ft.h | 4 ++++ receiver/src/main.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index f3a735c..7421840 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -16,6 +16,8 @@ #include +#include "sticker_request.h" + #ifndef __FT_H__ #define __FT_H__ @@ -39,4 +41,6 @@ bool request_show_sync_notification(); bool get_job_progress(); +void push_sticker_request(request_type req_type, const char *mode, const char *category, const char *type); + #endif /* __FT_H__ */ diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 968b4f4..12cf6a2 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -30,6 +30,7 @@ #include "config.h" #include "receiver_preference.h" #include "sticker_info.h" +#include "sticker_request.h" using namespace std; -- 2.7.4