From 3cc8a7cddca9cbeb85ae83f31073b7392cb401e1 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 10 Sep 2020 17:56:10 +0900 Subject: [PATCH 01/16] Update package version to 0.1.63 Change-Id: I8d5a78e18c77a98134bde228ae5916222a0164a9 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 db80dc6..e5f5d4a 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.62 +Version: 0.1.63 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index d4cdf2e..b8c75ad 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 10a1f2965ad89781c710508d3f708334c5434d43 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 24 Sep 2020 18:01:46 +0900 Subject: [PATCH 02/16] Rename function names Change-Id: I1cfc3c0c90d339e31e9a22e783b1f15249aae09e Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index d0e0b7f..f797447 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -93,6 +93,8 @@ static int sync_success_cnt = 0; static gboolean job_progress = FALSE; static int sync_complete_flags = 0; +static void sticker_service_quit(); + static void save_last_sync_time() { // save last sync time in preference @@ -629,10 +631,10 @@ static void _on_transfer_file_cb(sap_peer_agent_h peer_agent_h, accept_file(); } -void conn_terminated(sap_peer_agent_h peer_agent, - sap_socket_h socket, - sap_service_connection_terminated_reason_e result, - void *user_data) +static void _on_connection_terminated(sap_peer_agent_h peer_agent, + sap_socket_h socket, + sap_service_connection_terminated_reason_e result, + void *user_data) { sap_info_s *priv = NULL; priv = (sap_info_s *)user_data; @@ -658,13 +660,14 @@ void conn_terminated(sap_peer_agent_h peer_agent, set_sync_progressing(FALSE); send_message("sync_stop_result", "cancel"); - service_app_exit(); + sticker_service_quit(); } -static void quit() +static void sticker_service_quit() { job_progress = FALSE; send_disconnect_message(); + STLOGI("Terminate sticker service"); service_app_exit(); } @@ -801,7 +804,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in #endif if (!process_request_queue()) { - quit(); + sticker_service_quit(); } } else if (msg_id == STICKER_SYNC_START_RSP) { STLOGD("msg : %s", msg_id.c_str()); @@ -858,7 +861,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in set_sync_progressing(FALSE); save_last_sync_time(); - quit(); + sticker_service_quit(); } } } else if (msg_id == STICKER_SEND_START_REQ) { @@ -995,7 +998,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in if (!process_request_queue()) { sync_success_cnt = 0; - quit(); + sticker_service_quit(); } } else STLOGW("unknown msg id : %s", msg_id.c_str()); @@ -1019,7 +1022,7 @@ static void on_conn_req(sap_peer_agent_h peer_agent, STLOGI("Connection success"); priv_data.socket = socket; sap_peer_agent_accept_service_connection(peer_agent); - sap_peer_agent_set_service_connection_terminated_cb(peer_agent, conn_terminated, &priv_data); + sap_peer_agent_set_service_connection_terminated_cb(peer_agent, _on_connection_terminated, &priv_data); sap_socket_set_data_received_cb(socket, on_data_received, peer_agent); break; case SAP_CONNECTION_ALREADY_EXIST: @@ -1062,7 +1065,7 @@ _on_service_connection_created(sap_peer_agent_h peer_agent, { case SAP_CONNECTION_SUCCESS: sap_peer_agent_set_service_connection_terminated_cb(priv->peer_agent, - conn_terminated, + _on_connection_terminated, priv); sap_socket_set_data_received_cb(socket, on_data_received, peer_agent); -- 2.7.4 From de3b67b664320f1955350612e3fb5ede43ce5eee Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Sat, 10 Oct 2020 13:00:45 +0900 Subject: [PATCH 03/16] Destroy receiver when launching in case that BT is not connected Change-Id: I5413d0a17683d7b189b331d0a65c269e87366515 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index f797447..4467722 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -655,7 +655,9 @@ static void _on_connection_terminated(sap_peer_agent_h peer_agent, break; } - sap_socket_destroy(priv->socket); + if (priv->socket) + sap_socket_destroy(priv->socket); + priv->socket = NULL; set_sync_progressing(FALSE); @@ -1222,6 +1224,7 @@ static void _on_device_status_changed(sap_device_status_e status, sap_transport_type_e transport_type, void *user_data) { + bool unknown_transport_type = false; STLOGD("%s, status :%d", __func__, status); switch (transport_type) { @@ -1242,12 +1245,13 @@ static void _on_device_status_changed(sap_device_status_e status, break; default: STLOGE("unknown transport_type (%d)", transport_type); + unknown_transport_type = true; break; } switch (status) { case SAP_DEVICE_STATUS_DETACHED: - STLOGD("device is not connected."); + STLOGD("device is detached."); send_message("sync_stop_result", "cancel"); break; case SAP_DEVICE_STATUS_ATTACHED: @@ -1258,6 +1262,9 @@ static void _on_device_status_changed(sap_device_status_e status, STLOGE("unknown status (%d)", status); break; } + + if (unknown_transport_type && status == SAP_DEVICE_STATUS_DETACHED) + sticker_service_quit(); } gboolean agent_initialize() -- 2.7.4 From 20bb66aa2c1c8df0a32d52861288a54039688374 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Sat, 10 Oct 2020 13:40:49 +0900 Subject: [PATCH 04/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 05/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 06/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 07/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 08/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 09/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 10/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 11/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 12/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 13/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 14/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 15/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 16/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