From b93c3268d6af1edb6c50c4b0c6ca64b864d084e3 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 16 Apr 2020 13:39:38 +0900 Subject: [PATCH 01/16] Set the display type of the sticker Change-Id: I86ecc4aa8c13e5d1f0f64d0b9ba5551447a7f00f --- receiver/inc/sticker_info.h | 2 +- receiver/src/ft.cpp | 3 ++- receiver/src/sticker_info.cpp | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/receiver/inc/sticker_info.h b/receiver/inc/sticker_info.h index 3a70556..9784b5a 100644 --- a/receiver/inc/sticker_info.h +++ b/receiver/inc/sticker_info.h @@ -17,7 +17,7 @@ #ifndef __STICKER_INFO_H__ #define __STICKER_INFO_H__ -void insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc, const char *thumbnail); +void insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc, const char *thumbnail, const char *disp_type); int create_sticker_provider_handle(void); void destroy_sticker_provider_handle(void); void delete_sticker_data(const char *fileName); diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index eb4e297..2d231d0 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -223,7 +223,8 @@ static void _on_transfer_completed(sap_file_transaction_h file_transaction, sticker_data.thumbnail_path.clear(); } - insert_sticker_data(sticker_data.file_path.c_str(), sticker_data.keyword.c_str(), sticker_data.group.c_str(), sticker_data.description.c_str(), sticker_data.thumbnail_path.c_str()); + insert_sticker_data(sticker_data.file_path.c_str(), sticker_data.keyword.c_str(), sticker_data.group.c_str(), sticker_data.description.c_str(), + sticker_data.thumbnail_path.c_str(), sticker_data.disp_type.c_str()); destroy_sticker_provider_handle(); if (unlink(sticker_data.file_path.c_str()) == -1) diff --git a/receiver/src/sticker_info.cpp b/receiver/src/sticker_info.cpp index 38c9709..2d5e58d 100644 --- a/receiver/src/sticker_info.cpp +++ b/receiver/src/sticker_info.cpp @@ -26,7 +26,7 @@ static sticker_provider_h sticker_provider = NULL; sticker_data_h set_sticker_data(sticker_data_uri_type_e type, const char* uri, const char* keyword, -int len, const char* group, const char* thumbnail, const char* description) +int len, const char* group, const char* thumbnail, const char* description, sticker_data_display_type_e disp_type) { sticker_data_h sticker_data; int ret; @@ -78,16 +78,29 @@ int len, const char* group, const char* thumbnail, const char* description) LOGE("Failed to set description"); } + /* Sets the display type of the sticker.*/ + ret = sticker_data_set_display_type(sticker_data, disp_type); + if (ret != STICKER_ERROR_NONE) { + /* Error handling */ + LOGE("Failed to set display type"); + } + return sticker_data; } void -insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc, const char *thumbnail) +insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc, const char *thumbnail, const char *disp_type) { sticker_data_h data_handle; int ret; + sticker_data_display_type_e display_type; + + if (strcmp(disp_type, "input") == 0) + display_type = STICKER_DATA_DISP_EMOJI; + else + display_type = STICKER_DATA_DISP_WALLPAPER; - data_handle = set_sticker_data(STICKER_DATA_URI_LOCAL_PATH, filepath, keyword, 1, group, thumbnail, desc); + data_handle = set_sticker_data(STICKER_DATA_URI_LOCAL_PATH, filepath, keyword, 1, group, thumbnail, desc, display_type); ret = sticker_provider_insert_data(sticker_provider, data_handle); if (ret != STICKER_ERROR_NONE) { -- 2.7.4 From 95678ac2cbfa3fec8ae61f60d342f0100ab855f0 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 16 Apr 2020 14:21:55 +0900 Subject: [PATCH 02/16] Add missing break Change-Id: I81a8f3db9dc0667ba94fcc4b66e61b54c14e5d4d --- server/stickerd_db_manager.c | 1 + 1 file changed, 1 insertion(+) diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index ecf8f33..f3acdbd 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -160,6 +160,7 @@ static const char *_db_get_query(sticker_info_db_type sticker_type, command_type break; case STICKER_DB_STICKER_DISP_TYPE: query = STICKER_DB_GET_RECORD_ID_BY_DISP_TYPE; + break; case STICKER_DB_STICKER_RECENT_HISTORY: query = STICKER_DB_GET_RECENT_HISTORY; break; -- 2.7.4 From 549a87a10673bd7f83d7d1e89a992794f04f2b05 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Tue, 14 Apr 2020 13:18:52 +0900 Subject: [PATCH 03/16] Prevent memory leak Change-Id: I89922a5fbe23851036c8633d285a9ca473ad31aa --- server/stickerd_data_manager.c | 108 +++++++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 41 deletions(-) diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index 23c09e0..2bb0012 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -619,6 +619,49 @@ static void _send_sticker_changed_event(STICKER_EVENT_TYPE type, sticker_info_db g_variant_unref(body); } +static void _free_sticker_data(sticker_info_db *sticker_data) +{ + if (!sticker_data) + return; + + if (sticker_data->app_id) { + free(sticker_data->app_id); + sticker_data->app_id = NULL; + } + + if (sticker_data->uri) { + free(sticker_data->uri); + sticker_data->uri = NULL; + } + + if (sticker_data->thumbnail) { + free(sticker_data->thumbnail); + sticker_data->thumbnail = NULL; + } + + if (sticker_data->keyword) { + g_list_free_full(sticker_data->keyword, free); + sticker_data->keyword = NULL; + } + + if (sticker_data->group) { + free(sticker_data->group); + sticker_data->group = NULL; + } + + if (sticker_data->description) { + free(sticker_data->description); + sticker_data->description = NULL; + } + + if (sticker_data->date) { + free(sticker_data->date); + sticker_data->date = NULL; + } + + free(sticker_data); +} + int stickerd_insert_sticker_info(GVariant *parameters, GVariant **reply_body) { int ret; @@ -825,7 +868,7 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_ continue; } - sticker_info->app_id = app_id; + sticker_info->app_id = strdup(app_id); sticker_info->type = _get_int_from_object(info_object, "type"); if (sticker_info->type < 1) goto free_memory; @@ -880,7 +923,7 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_ _send_sticker_changed_event(STICKER_EVENT_TYPE_INSERT, sticker_info); free_memory: - free(sticker_info); + _free_sticker_data(sticker_info); sticker_info = NULL; } } @@ -923,13 +966,15 @@ int stickerd_del_sticker_info(GVariant *parameters, GVariant **reply_body) ret = stickerd_db_delete_sticker_info(record_id); if (ret != STICKERD_SERVER_ERROR_NONE) { LOGE("Failed to delete sticker info"); - return STICKERD_SERVER_ERROR_OPERATION_FAILED; + ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; } else { - if (sticker_info && sticker_info->uri) { + if (sticker_info && sticker_info->uri) _send_sticker_changed_event(STICKER_EVENT_TYPE_DELETE, sticker_info); - free(sticker_info); - sticker_info = NULL; - } + } + + if (sticker_info) { + _free_sticker_data(sticker_info); + sticker_info = NULL; } return ret; @@ -955,13 +1000,15 @@ int stickerd_del_sticker_info_by_uri(GVariant *parameters, GVariant **reply_body ret = stickerd_db_delete_sticker_info_by_uri(uri); if (ret != STICKERD_SERVER_ERROR_NONE) { LOGE("Failed to delete sticker info"); - return STICKERD_SERVER_ERROR_OPERATION_FAILED; + ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; } else { - if (sticker_info && sticker_info->uri) { + if (sticker_info && sticker_info->uri) _send_sticker_changed_event(STICKER_EVENT_TYPE_DELETE, sticker_info); - free(sticker_info); - sticker_info = NULL; - } + } + + if (sticker_info) { + _free_sticker_data(sticker_info); + sticker_info = NULL; } return ret; @@ -1159,29 +1206,7 @@ int stickerd_get_sticker_info(GVariant *parameters, GVariant **reply_body) ret = stickerd_db_get_sticker_info_by_record_id(record_id, sticker_info); if (ret != STICKERD_SERVER_ERROR_NONE) { LOGE("Failed to get sticker info"); - - if (sticker_info->app_id) - free(sticker_info->app_id); - - if (sticker_info->uri) - free(sticker_info->uri); - - if (sticker_info->thumbnail) - free(sticker_info->thumbnail); - - if (sticker_info->keyword) - free(sticker_info->keyword); - - if (sticker_info->group) - free(sticker_info->group); - - if (sticker_info->description) - free(sticker_info->description); - - if (sticker_info->date) - free(sticker_info->date); - - free(sticker_info); + _free_sticker_data(sticker_info); sticker_info = NULL; return STICKERD_SERVER_ERROR_OPERATION_FAILED; } @@ -1205,13 +1230,14 @@ int stickerd_get_sticker_info(GVariant *parameters, GVariant **reply_body) if (*reply_body == NULL) { LOGE("Failed to create reply_body"); - free(sticker_info); + _free_sticker_data(sticker_info); sticker_info = NULL; return STICKERD_SERVER_ERROR_OPERATION_FAILED; } - free(sticker_info); + _free_sticker_data(sticker_info); sticker_info = NULL; + return ret; } @@ -1739,11 +1765,11 @@ int stickerd_send_update_event(GVariant *parameters, GVariant **reply_body) sticker_info_db *sticker_info = (sticker_info_db *)calloc(1, sizeof(sticker_info_db)); if (sticker_info) { ret = stickerd_db_get_sticker_info_by_record_id(record_id, sticker_info); - if (ret == STICKERD_SERVER_ERROR_NONE) { + if (ret == STICKERD_SERVER_ERROR_NONE) _send_sticker_changed_event(STICKER_EVENT_TYPE_UPDATE, sticker_info); - free(sticker_info); - sticker_info = NULL; - } + + _free_sticker_data(sticker_info); + sticker_info = NULL; } return ret; -- 2.7.4 From 375c08bbe56fb3faf5e3ce78d11dec8601a3bfa3 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 16 Apr 2020 19:42:01 +0900 Subject: [PATCH 04/16] Fix issue detected by static analysis tool Change-Id: I1f9c417f1c11bc72d214d45a27ffe78695371301 --- server/stickerd_data_manager.c | 2 +- server/stickerd_db_manager.c | 2 ++ sticker-parser/sticker-parser.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index 2bb0012..9e6455c 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -874,7 +874,7 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_ goto free_memory; sticker_info->uri = _get_string_from_object(info_object, "uri"); - if (!sticker_info->uri) + if (!sticker_info->uri || sticker_info->uri[0] != '\0') goto free_memory; if (sticker_info->type == 1) { diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index f3acdbd..ad78560 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -211,12 +211,14 @@ static int _recover_db(void) 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; } is_corrupted = FALSE; diff --git a/sticker-parser/sticker-parser.c b/sticker-parser/sticker-parser.c index a3f96b5..9d73dd3 100644 --- a/sticker-parser/sticker-parser.c +++ b/sticker-parser/sticker-parser.c @@ -605,7 +605,7 @@ 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 && rel_thumbnail[0] != '\0') { thumbnail_path = __convert_sticker_uri(rel_thumbnail, appid, app_path); free(rel_thumbnail); } -- 2.7.4 From a4bcf716d4504a4808e4f2dcf24ed9a09e1698ea Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 16 Apr 2020 20:03:36 +0900 Subject: [PATCH 05/16] Add code for the DB recovery Change-Id: Iea229d68322b3c45affbaadea9aa556db4e9a6cc --- server/stickerd_db_manager.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index ad78560..6e3ace3 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -318,6 +318,9 @@ static sqlite3 *_db_open(void) sqlite3 *db = NULL; char *err = NULL; + if (is_corrupted && _recover_db() != SQLITE_OK) + return NULL; + ret = sqlite3_open(STICKER_DB_PATH, &db); if (ret != SQLITE_OK) { LOGE("Failed to open db : %s", sqlite3_errmsg(db)); -- 2.7.4 From e01c8f0e27241603a1d08fa6e0763bd3f6bb9522 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 16 Apr 2020 16:12:23 +0900 Subject: [PATCH 06/16] Update package version to 0.1.35 Change-Id: Ib2f937c77c6eef1e4dfa2979561c1a5547d3dbf0 --- 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 4df16d5..d8a7044 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.34 +Version: 0.1.35 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 124cd9c..083dee3 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From d6dac8b4ddc23c04ea5a648063fe21e0ac206bab Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 13 Apr 2020 12:28:03 +0900 Subject: [PATCH 07/16] Change API description by API review Change-Id: I18a16d9cdc031af5fae04ff8d7e5dd4ae6b20526 --- doc/sticker_doc.h | 2 ++ include/sticker_consumer.h | 16 ++++++++-------- include/sticker_data.h | 7 ++++++- include/sticker_provider.h | 15 ++++++++------- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/doc/sticker_doc.h b/doc/sticker_doc.h index 4c3b325..9938252 100644 --- a/doc/sticker_doc.h +++ b/doc/sticker_doc.h @@ -25,6 +25,8 @@ * * @section CAPI_UIX_STICKER_MODULE_OVERVIEW Overview * Using sticker library, a sticker application can provide sticker information to applications that want to read the sticker information as the standard specification. + * A sticker is an image (possibly animated) that is used in an IM conversation. + * The Sticker API covers the exchange of sticker data between applications. How the images are used depends on a particular sticker consumer application. * * @section CAPI_UIX_STICKER_MODULE_FEATURE Related Feature * This API is related with the following feature:\n diff --git a/include/sticker_consumer.h b/include/sticker_consumer.h index 7231f26..8ac5845 100644 --- a/include/sticker_consumer.h +++ b/include/sticker_consumer.h @@ -40,9 +40,9 @@ extern "C" { * @since_tizen 5.5 */ typedef enum { - STICKER_CONSUMER_EVENT_TYPE_INSERT, /**< Insert event type */ - STICKER_CONSUMER_EVENT_TYPE_DELETE, /**< Delete event type */ - STICKER_CONSUMER_EVENT_TYPE_UPDATE, /**< Update event type */ + STICKER_CONSUMER_EVENT_TYPE_INSERT, /**< A sticker data has been added */ + STICKER_CONSUMER_EVENT_TYPE_DELETE, /**< A sticker data has been removed */ + STICKER_CONSUMER_EVENT_TYPE_UPDATE, /**< A sticker data has been updated */ } sticker_consumer_event_type_e; /** @@ -100,9 +100,9 @@ typedef void (*sticker_consumer_keyword_list_foreach_cb)(const char *keyword, vo * @since_tizen 5.5 * @remarks @a data_handle should not be freed and can be used only in the callback. * If you want to use it outside of the callback, you need to use a clone which can be obtained sticker_data_clone(). - * When the @a event_type is STICKER_CONSUMER_EVENT_TYPE_DELETE, sticker data can be obtained using @a data_handle, - * but unable to access file because it has been deleted. - * @param[in] event_type The event type of sticker + * When the @a event_type is #STICKER_CONSUMER_EVENT_TYPE_DELETE, sticker data can be obtained using @a data_handle, + * but the files have been already deleted. + * @param[in] event_type The event type * @param[in] data_handle The sticker data handle * @param[in] user_data The user data passed from sticker_consumer_set_event_callback() * @pre The callback can be registered using sticker_consumer_set_event_callback() @@ -289,7 +289,7 @@ int sticker_consumer_keyword_list_foreach_all(sticker_consumer_h consumer_handle int sticker_consumer_data_foreach_by_display_type(sticker_consumer_h consumer_handle, int offset, int count, int *result, sticker_data_display_type_e type, sticker_consumer_data_foreach_cb callback, void *user_data); /** - * @brief Retrieves all group name in the sticker database using display type. + * @brief Retrieves all group names assigned to stickers with a matching display @a type. * @since_tizen 5.5 * @param[in] consumer_handle The sticker consumer handle * @param[in] type The display type of the sticker for getting sticker data @@ -306,7 +306,7 @@ int sticker_consumer_data_foreach_by_display_type(sticker_consumer_h consumer_ha int sticker_consumer_group_list_foreach_by_display_type(sticker_consumer_h consumer_handle, sticker_data_display_type_e type, sticker_consumer_group_list_foreach_cb callback, void *user_data); /** - * @brief Add history to recently used stickers list + * @brief Adds entry to recently used stickers list. * @since_tizen 5.5 * @param[in] consumer_handle The sticker consumer handle * @param[in] data_handle The sticker data handle diff --git a/include/sticker_data.h b/include/sticker_data.h index e27197c..088c386 100644 --- a/include/sticker_data.h +++ b/include/sticker_data.h @@ -50,7 +50,12 @@ typedef enum { */ typedef enum { STICKER_DATA_DISP_EMOJI = 1, /**< Emoji type */ - STICKER_DATA_DISP_WALLPAPER, /**< Wallpaper type */ + /** + * @brief Wallpaper type + * @details The stickers of the wallpaper type are intended to be used by + * a wallpaper application and usually have larger size. + */ + STICKER_DATA_DISP_WALLPAPER, } sticker_data_display_type_e; /** diff --git a/include/sticker_provider.h b/include/sticker_provider.h index 8271ad7..cdfbac4 100644 --- a/include/sticker_provider.h +++ b/include/sticker_provider.h @@ -98,7 +98,7 @@ int sticker_provider_destroy(sticker_provider_h provider_handle); * @brief Inserts a sticker data to the sticker database. * @since_tizen 5.5 * @remarks All data except thumbnail, description, display_type must be set in the @a data_handle to insert the sticker data. - * If the uri type is #STICKER_DATA_URI_LOCAL_PATH, the sticker file is copied to a sticker directory. + * If the URI type is #STICKER_DATA_URI_LOCAL_PATH, the sticker file is copied to a sticker directory. * It is recommended to delete your sticker file after inserting a sticker data. * @param[in] provider_handle The sticker provider handle * @param[in] data_handle The sticker data handle to be saved @@ -115,15 +115,15 @@ int sticker_provider_destroy(sticker_provider_h provider_handle); int sticker_provider_insert_data(sticker_provider_h provider_handle, sticker_data_h data_handle); /** - * @brief Inserts a sticker data using json file. + * @brief Inserts a sticker data using JSON file. * @details @a json_path must be a relative path like '/data/message_sticker.json'. * @since_tizen 5.5 - * @remarks All data except thumbnail, description, display_type must be set in the json file to insert the sticker data. + * @remarks All data except thumbnail, description, display_type must be set in the JSON file to insert the sticker data. * @a json_path must have a non-null value and must be an existing file. If not, the error as invalid parameter will be returned. - * If the uri type is #STICKER_DATA_URI_LOCAL_PATH, the sticker file is copied to a sticker directory. + * If the URI type is #STICKER_DATA_URI_LOCAL_PATH, the sticker file is copied to a sticker directory. * It is recommended to delete your sticker files after inserting a sticker data. * @param[in] provider_handle The sticker provider handle - * @param[in] json_path The path of json file containing sticker information to be saved + * @param[in] json_path The path of JSON file containing sticker information to be saved * @param[in] callback The callback function to invoke * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value @@ -135,7 +135,7 @@ int sticker_provider_insert_data(sticker_provider_h provider_handle, sticker_dat * @see sticker_provider_insert_finished_cb() * * @code - //json file format + //JSON file format { "sticker": [ @@ -201,7 +201,8 @@ int sticker_provider_update_data(sticker_provider_h provider_handle, sticker_dat int sticker_provider_delete_data(sticker_provider_h provider_handle, sticker_data_h data_handle); /** - * @brief Deletes a sticker data in the sticker database using URI. + * @brief Deletes a sticker data 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. * @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 b4afaa38da9381afd44996131a02552ced299628 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Tue, 21 Apr 2020 13:12:40 +0900 Subject: [PATCH 08/16] Update package version to 0.1.36 Change-Id: I7124c7d00b2e329a82344f799ea55d3d0d32874b --- 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 d8a7044..79937e3 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.35 +Version: 0.1.36 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 083dee3..f8cea18 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From bc99d11407a14e79e6cd27535a1bbb95f08103f4 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 22 Apr 2020 14:13:36 +0900 Subject: [PATCH 09/16] Modify API name and doxygen comments Change-Id: Ic76c33ddaae755dbdc73cb32bcf92d929c87e0f7 --- consumer/sticker_consumer.c | 4 ++-- include/sticker_consumer.h | 18 +++++++++--------- include/sticker_data.h | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/consumer/sticker_consumer.c b/consumer/sticker_consumer.c index 91de924..8f6c03f 100644 --- a/consumer/sticker_consumer.c +++ b/consumer/sticker_consumer.c @@ -599,7 +599,7 @@ cleanup: return ret; } -EXPORT_API int sticker_consumer_set_event_callback(sticker_consumer_h consumer_handle, sticker_consumer_event_cb callback, void *user_data) +EXPORT_API int sticker_consumer_set_event_cb(sticker_consumer_h consumer_handle, sticker_consumer_event_cb callback, void *user_data) { CHECK_STICKER_FEATURE(); @@ -612,7 +612,7 @@ EXPORT_API int sticker_consumer_set_event_callback(sticker_consumer_h consumer_h return STICKER_ERROR_NONE; } -EXPORT_API int sticker_consumer_unset_event_callback(sticker_consumer_h consumer_handle) +EXPORT_API int sticker_consumer_unset_event_cb(sticker_consumer_h consumer_handle) { CHECK_STICKER_FEATURE(); diff --git a/include/sticker_consumer.h b/include/sticker_consumer.h index 8ac5845..322379c 100644 --- a/include/sticker_consumer.h +++ b/include/sticker_consumer.h @@ -104,10 +104,10 @@ typedef void (*sticker_consumer_keyword_list_foreach_cb)(const char *keyword, vo * but the files have been already deleted. * @param[in] event_type The event type * @param[in] data_handle The sticker data handle - * @param[in] user_data The user data passed from sticker_consumer_set_event_callback() - * @pre The callback can be registered using sticker_consumer_set_event_callback() - * @see sticker_consumer_set_event_callback() - * @see sticker_consumer_unset_event_callback() + * @param[in] user_data The user data passed from sticker_consumer_set_event_cb() + * @pre The callback can be registered using sticker_consumer_set_event_cb() + * @see sticker_consumer_set_event_cb() + * @see sticker_consumer_unset_event_cb() */ typedef void (*sticker_consumer_event_cb)(sticker_consumer_event_type_e event_type, sticker_data_h data_handle, void *user_data); @@ -315,7 +315,7 @@ int sticker_consumer_group_list_foreach_by_display_type(sticker_consumer_h consu * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed - * @see sticker_consumer_get_recent_list() + * @see sticker_consumer_get_recent_data_list() */ int sticker_consumer_add_recent_data(sticker_consumer_h consumer_handle, sticker_data_h data_handle); @@ -354,9 +354,9 @@ int sticker_consumer_get_recent_data_list(sticker_consumer_h consumer_handle, in * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed * @see sticker_consumer_event_cb() - * @see sticker_consumer_unset_event_callback() + * @see sticker_consumer_unset_event_cb() */ -int sticker_consumer_set_event_callback(sticker_consumer_h consumer_handle, sticker_consumer_event_cb callback, void *user_data); +int sticker_consumer_set_event_cb(sticker_consumer_h consumer_handle, sticker_consumer_event_cb callback, void *user_data); /** * @brief Unregisters a callback function. @@ -368,9 +368,9 @@ int sticker_consumer_set_event_callback(sticker_consumer_h consumer_handle, stic * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed * @see sticker_consumer_event_cb() - * @see sticker_consumer_set_event_callback() + * @see sticker_consumer_set_event_cb() */ -int sticker_consumer_unset_event_callback(sticker_consumer_h consumer_handle); +int sticker_consumer_unset_event_cb(sticker_consumer_h consumer_handle); /** * @} diff --git a/include/sticker_data.h b/include/sticker_data.h index 088c386..2a59af1 100644 --- a/include/sticker_data.h +++ b/include/sticker_data.h @@ -224,7 +224,7 @@ int sticker_data_remove_keyword(sticker_data_h data_handle, const char *keyword) * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @see sticker_data_get_group() + * @see sticker_data_get_group_name() */ int sticker_data_set_group_name(sticker_data_h data_handle, const char *group); @@ -239,7 +239,7 @@ int sticker_data_set_group_name(sticker_data_h data_handle, const char *group); * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #STICKER_ERROR_NO_DATA No data available - * @see sticker_data_set_group() + * @see sticker_data_set_group_name() */ int sticker_data_get_group_name(sticker_data_h data_handle, char **group); -- 2.7.4 From d766d5cfe4dd19280d9b35a2e02c53ec5f819266 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 22 Apr 2020 15:05:40 +0900 Subject: [PATCH 10/16] Update package version to 0.1.37 Change-Id: Iff694c6f4fe855055c49058394b57cb97f6f79eb --- 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 79937e3..37f6025 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.36 +Version: 0.1.37 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index f8cea18..f14bb80 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 06197b95967017919204a47b1fa048d2259de804 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 22 Apr 2020 20:46:23 +0900 Subject: [PATCH 11/16] Modified to send valid sync_mode Change-Id: I7afc7da579288e05a91afd595fe1f29aa0d88a7f --- receiver/src/ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 2d231d0..723c8f2 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -666,7 +666,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in json_msgid = json_object_get_string_member(root_obj, "msgId"); msg_id = string(json_msgid ? json_msgid : ""); if (msg_id == STICKER_REQUEST_SYNC_REQ) { - request_all_sticker_data("auto", "input"); + request_all_sticker_data("manual", "input"); } else if (msg_id == STICKER_SYNC_FEATURE_RSP) { LOGD("msg : %s", msg_id.c_str()); #ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE -- 2.7.4 From 23ee42119b4613aacaef80a8c4f0940c7b0b0a34 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 24 Apr 2020 20:35:11 +0900 Subject: [PATCH 12/16] Fix invalid condition check Change-Id: Ifccd8a1252d05c160d88192594f00c8100dae770 --- consumer/sticker_consumer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consumer/sticker_consumer.c b/consumer/sticker_consumer.c index 8f6c03f..1c11f19 100644 --- a/consumer/sticker_consumer.c +++ b/consumer/sticker_consumer.c @@ -539,7 +539,7 @@ EXPORT_API int sticker_consumer_add_recent_data(sticker_consumer_h consumer_hand int ret; - if (!consumer_handle || !data_handle || (data_handle->sticker_info_id > 0) || !data_handle->uri) + if (!consumer_handle || !data_handle || (data_handle->sticker_info_id <= 0) || !data_handle->uri) return STICKER_ERROR_INVALID_PARAMETER; ret = sticker_dbus_insert_recent_sticker_info(consumer_handle->gdbus_connection, data_handle->sticker_info_id); -- 2.7.4 From 6d405cff562ce00105ba8aabf60639e937deff54 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 24 Apr 2020 20:36:13 +0900 Subject: [PATCH 13/16] Update package version to 0.1.38 Change-Id: Ia1688a1ad27d65008b89c12b28250c69f3b5ae7f --- 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 37f6025..05b11c7 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.37 +Version: 0.1.38 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index f14bb80..d169a2e 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From c6361adaaabf0c4db39fa589a58f2a70930c45ae Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 27 Apr 2020 09:52:24 +0900 Subject: [PATCH 14/16] Fix issue detected by static analysis tool Use of vulnerable function 'sprintf'. This function is unsafe, use snprintf instead. Change-Id: Ie3eba653e1a0986979b411814fbe19adc7da8504 --- receiver/src/ft.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 723c8f2..7fbbffb 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -211,7 +211,7 @@ static void _on_transfer_completed(sap_file_transaction_h file_transaction, char thumb_path[PATH_MAX]; char *data_path = NULL; data_path = app_get_shared_data_path(); - sprintf(thumb_path, "%s/thumbnail/%s", data_path, incoming_file_name.c_str()); + snprintf(thumb_path, sizeof(thumb_path), "%s/thumbnail/%s", data_path, incoming_file_name.c_str()); sticker_data.thumbnail_path = string(thumb_path); if (data_path) @@ -318,7 +318,7 @@ void accept_file() data_path = app_get_shared_data_path(); LOGI("Path : %s", data_path); - sprintf(file_path, "%s/%s", data_path, incoming_file_name.c_str()); + snprintf(file_path, sizeof(file_path), "%s/%s", data_path, incoming_file_name.c_str()); LOGI("Receive filepath : %s", file_path); sticker_data.file_path = string(file_path); @@ -346,7 +346,7 @@ static int _create_thumbnail_directory() char thumb_path[PATH_MAX]; char *data_path = NULL; data_path = app_get_shared_data_path(); - sprintf(thumb_path, "%s/thumbnail", data_path); + snprintf(thumb_path, sizeof(thumb_path), "%s/thumbnail", data_path); if (data_path) free(data_path); -- 2.7.4 From 94196a2f18b8ef7ee2d987a35003cffb59eb99db Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 27 Apr 2020 13:41:35 +0900 Subject: [PATCH 15/16] Only manual sync is possible after sync fails for 48hours Change-Id: I1e0683e4231cf9b99e32bcc5a8f3b5961015955a --- receiver/inc/config.h | 1 + receiver/inc/ft.h | 1 + receiver/src/ft.cpp | 20 ++++++++++++++++++++ receiver/src/main.cpp | 12 +++++++++--- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/receiver/inc/config.h b/receiver/inc/config.h index 10b742f..ecc3c10 100644 --- a/receiver/inc/config.h +++ b/receiver/inc/config.h @@ -21,6 +21,7 @@ #define ACCESSORY_SERVICE_CHANNEL_ID 107 #define SYNC_INTERVAL 12*60*60 +#define MAX_WAIT_TIME 48*60*60 #define REMOTE_APP_ID "com.samsung.w-input-selector" #define MESSAGE_PORT_REMOTE_NAME REMOTE_APP_ID"_msg_port_rcv" diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index 90d506f..6c91c66 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -35,6 +35,7 @@ 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_sticker_feature(); void send_disconnect_message(); +void request_show_sync_notification(); bool get_job_progress(); diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 7fbbffb..ae52546 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -48,6 +48,7 @@ #define STICKER_SYNC_FEATURE_REQ "sticker-sync-feature-req" #define STICKER_SYNC_FEATURE_RSP "sticker-sync-feature-rsp" #define STICKER_REQUEST_SYNC_REQ "sticker-request-sync-req" +#define STICKER_REQUEST_NOTI_REQ "sticker-request-noti-req" #define STICKER_SYNC_START_REQ "sticker-sync-start-req" #define STICKER_SYNC_START_RSP "sticker-sync-start-rsp" #define STICKER_SEND_START_REQ "sticker-send-start-req" @@ -488,6 +489,25 @@ void send_disconnect_message() json_object_unref(j_object); } +void request_show_sync_notification() +{ + JsonObject *j_object = NULL; + j_object = json_object_new(); + if (j_object == NULL) { + LOGE("json object create error"); + return; + } + + json_object_set_string_member(j_object, "msgId", STICKER_REQUEST_NOTI_REQ); + json_object_set_int_member(j_object, "tID", ++t_id); + + if (_send_json_data(j_object) == FALSE) { + LOGE("Failed to send STICKER_REQUEST_NOTI_REQ"); + } + + json_object_unref(j_object); +} + void reject_file() { int ret = sap_file_transfer_reject(priv_data.file_socket); diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 0de1ef9..c959151 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -99,10 +99,16 @@ static bool check_sync_time_condition() // compare time LOGD("current time : %f, last_sync_time : %f", ecore_time_get(), last_sync_time); - if (ecore_time_get() - last_sync_time > SYNC_INTERVAL) - result = true; - else + + if (ecore_time_get() - last_sync_time > MAX_WAIT_TIME) { + request_show_sync_notification(); result = false; + } else { + if (ecore_time_get() - last_sync_time > SYNC_INTERVAL) + result = true; + else + result = false; + } } else { -- 2.7.4 From 399d356d660fefbf3f04b586f461c6cff66a8e39 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 27 Apr 2020 13:51:47 +0900 Subject: [PATCH 16/16] Update package version to 0.1.39 Change-Id: I7e05e31de765f90496e0e153c02a1ab22db08fb0 --- 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 05b11c7..c4ca5cf 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.38 +Version: 0.1.39 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index d169a2e..33d9343 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4