From f5afe2482017b66ca67993cb4f7fb9be6b52b043 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 27 Mar 2020 13:34:15 +0900 Subject: [PATCH 01/16] Improve code for human readability Change-Id: I3ba1efb2012761a4d98928e2156bcaeba56b6cc7 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 1b03c03..a6cba2f 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -73,7 +73,7 @@ static struct sticker_info sticker_data; static queue ReqQueue; static StickerRequest current_request; -gboolean file_on_progress = 0; +static gboolean file_on_progress = FALSE; static string incoming_file_name; static int t_id = 0; static int rec_file_cnt_in_group = 0; @@ -212,7 +212,7 @@ static void _on_send_completed(sap_file_transaction_h file_transaction, } } - file_on_progress = 0; + file_on_progress = FALSE; sticker_data.reset(); } @@ -257,7 +257,7 @@ void accept_file() break; } - file_on_progress = 1; + file_on_progress = TRUE; } bool request_sticker_data(const char *mode, const char *category, const char *type) @@ -340,7 +340,7 @@ void reject_file() int ret = sap_file_transfer_reject(priv_data.file_socket); LOGI("ret : %d", ret); - file_on_progress = 0; + file_on_progress = FALSE; } static void _on_receive_file_cb(sap_peer_agent_h peer_agent_h, @@ -348,7 +348,7 @@ static void _on_receive_file_cb(sap_peer_agent_h peer_agent_h, const char *file_path, void *user_data) { - file_on_progress = 1; + file_on_progress = TRUE; priv_data.file_socket = socket; LOGI("# incoming file request."); __set_file_transfer_cb(priv_data.file_socket); -- 2.7.4 From e3ae2adc6b24c98cd684049dfcb4a5ab16955bd2 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 27 Mar 2020 14:44:01 +0900 Subject: [PATCH 02/16] Create configuration header Change-Id: I8e909a05e42cfcc76b025f07baec87c879362f7c Signed-off-by: Jihoon Kim --- receiver/inc/config.h | 31 +++++++++++++++++++++++++++++++ receiver/inc/ft.h | 1 + receiver/inc/log.h | 1 + receiver/inc/main.h | 1 + receiver/inc/message.h | 1 + receiver/inc/sticker_info.h | 1 + receiver/inc/sticker_request.h | 1 + receiver/inc/sync_alarm.h | 3 +-- receiver/src/ft.cpp | 4 +--- receiver/src/main.cpp | 4 ++-- receiver/src/message.cpp | 4 +--- receiver/src/sticker_info.cpp | 1 + receiver/src/sync_alarm.cpp | 1 + 13 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 receiver/inc/config.h diff --git a/receiver/inc/config.h b/receiver/inc/config.h new file mode 100644 index 0000000..88eee4d --- /dev/null +++ b/receiver/inc/config.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CONFIG_H__ +#define __CONFIG_H__ + +#define ACCESSORY_SERVICE_PROFILE_ID "/sample/filetransfersender" +#define ACCESSORY_SERVICE_CHANNEL_ID 107 + +#define SYNC_ALARM_DELAY 0 +#define SYNC_ALARM_INTERVAL 12*60*60 + +#define REMOTE_APP_ID "com.samsung.w-input-selector" +#define MESSAGE_PORT_REMOTE_NAME REMOTE_APP_ID"_msg_port_rcv" + +#define MINIMUM_BATTERY 15 + +#endif /* __CONFIG_H__ */ diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index 10ccb0e..0a022a6 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include #ifndef __FT_H__ diff --git a/receiver/inc/log.h b/receiver/inc/log.h index 07ee738..763f6cb 100644 --- a/receiver/inc/log.h +++ b/receiver/inc/log.h @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef __debug_H__ #define __debug_H__ diff --git a/receiver/inc/main.h b/receiver/inc/main.h index e32a820..27883e4 100644 --- a/receiver/inc/main.h +++ b/receiver/inc/main.h @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include #include #include diff --git a/receiver/inc/message.h b/receiver/inc/message.h index 392f1cd..791a9aa 100644 --- a/receiver/inc/message.h +++ b/receiver/inc/message.h @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include #include diff --git a/receiver/inc/sticker_info.h b/receiver/inc/sticker_info.h index 8231585..2e20ad8 100644 --- a/receiver/inc/sticker_info.h +++ b/receiver/inc/sticker_info.h @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef __STICKER_INFO_H__ #define __STICKER_INFO_H__ diff --git a/receiver/inc/sticker_request.h b/receiver/inc/sticker_request.h index 9c8089f..583bd9a 100644 --- a/receiver/inc/sticker_request.h +++ b/receiver/inc/sticker_request.h @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef __STICKER_REQUEST_H__ #define __STICKER_REQUEST_H__ diff --git a/receiver/inc/sync_alarm.h b/receiver/inc/sync_alarm.h index e46515c..8f025ca 100644 --- a/receiver/inc/sync_alarm.h +++ b/receiver/inc/sync_alarm.h @@ -13,14 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include #ifndef __ALARM_H__ #define __ALARM_H__ #define APP_CONTROL_OPERATION_SYNC_ALARM "http://tizen.org/appcontrol/operation/sticker_sync_alarm" -#define SYNC_ALARM_DELAY 0 -#define SYNC_ALARM_INTERVAL 12*60*60 bool sync_alarm_register(const char *operation, int delay, int period); bool sync_alarm_exist(); diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index a6cba2f..1408aa7 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -40,9 +40,7 @@ #include "sticker_request.h" #include "message.h" #include "sync_alarm.h" - -#define ACCESSORY_SERVICE_PROFILE_ID "/sample/filetransfersender" -#define ACCESSORY_SERVICE_CHANNEL_ID 107 +#include "config.h" #define STICKER_SYNC_FEATURE_REQ "sticker-sync-feature-req" #define STICKER_SYNC_FEATURE_RSP "sticker-sync-feature-rsp" diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 3fd98e1..969f575 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include #include #include @@ -22,10 +23,9 @@ #include "main.h" #include "ft.h" #include "log.h" +#include "config.h" #include "sync_alarm.h" -#define MINIMUM_BATTERY 15 - static bool app_create(void *data) { /* Hook to take necessary actions before main event loop starts diff --git a/receiver/src/message.cpp b/receiver/src/message.cpp index 8dde6a6..0ca7d32 100644 --- a/receiver/src/message.cpp +++ b/receiver/src/message.cpp @@ -18,9 +18,7 @@ #include "message.h" #include "log.h" - -#define REMOTE_APP_ID "com.samsung.w-input-selector" -#define MESSAGE_PORT_REMOTE_NAME REMOTE_APP_ID"_msg_port_rcv" +#include "config.h" static int port_id = -1; diff --git a/receiver/src/sticker_info.cpp b/receiver/src/sticker_info.cpp index 57ace21..16ca72e 100644 --- a/receiver/src/sticker_info.cpp +++ b/receiver/src/sticker_info.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "sticker_info.h" #include #include diff --git a/receiver/src/sync_alarm.cpp b/receiver/src/sync_alarm.cpp index d4879d8..ec7079e 100644 --- a/receiver/src/sync_alarm.cpp +++ b/receiver/src/sync_alarm.cpp @@ -19,6 +19,7 @@ #include #include "log.h" +#include "config.h" static int recurring_alarm_id = -1; -- 2.7.4 From 2899271cb48c0597c433835afdd4f0799757efbb Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 27 Mar 2020 14:47:18 +0900 Subject: [PATCH 03/16] Modified to request sticker sync using sticker feature Change-Id: Iacf7c5fb7524aaaa6d76fde548dfff17fc32bedb --- receiver/src/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 969f575..aa65584 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "main.h" #include "ft.h" @@ -118,8 +119,20 @@ static void app_control(app_control_h app_control, void *data) goto cleanup; if (mode && 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) + request_sticker_data(mode, "arsticker", type); + + if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) + request_sticker_data(mode, "bitmoji", type); + } else + LOGW("Failed to get value of VCONFKEY_STICKER_SUPPORTED_FEATURE"); +#else request_sticker_data(mode, "arsticker", type); request_sticker_data(mode, "bitmoji", type); +#endif } } else if (strcmp(request, "oobe") == 0) { -- 2.7.4 From ff069d1debde7c14b3e64e614670e24f53357e26 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 27 Mar 2020 18:52:46 +0900 Subject: [PATCH 04/16] Fix indentation in manifest file Change-Id: I281de93c075efb6df8c7b96338ddb7113736cdd7 Signed-off-by: Jihoon Kim --- receiver/tizen-manifest.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 71b376e..1d23be5 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -2,12 +2,12 @@ - - - - - - + + + + + + http://developer.samsung.com/tizen/privilege/accessoryprotocol -- 2.7.4 From e747f6793fa9b99c5e6627e0036beb9d994b156b Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 30 Mar 2020 14:46:28 +0900 Subject: [PATCH 05/16] Set first sync complete Change-Id: I71eebf7c1caa0667f283da1bf042238488116f98 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 1408aa7..8f81c0a 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -52,6 +52,10 @@ #define STICKER_SEND_STOP_REQ "sticker-send-stop-req" #define STICKER_SEND_STOP_RSP "sticker-send-stop-rsp" +#ifndef VCONFKEY_STICKER_SYNC_COMPLETE_DONE +#define VCONFKEY_STICKER_SYNC_COMPLETE_DONE 0x1 +#endif + using namespace std; enum { @@ -571,21 +575,30 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in } else { int complete_flags = 0; - if (vconf_get_int(VCONFKEY_STICKER_SYNC_COMPLETE, &complete_flags) == 0) { - if (sticker_data.group == string("arsticker")) - complete_flags |= 0x1; - else if (sticker_data.group == string("bitmoji")) - complete_flags |= 0x2; - - LOGD("sync complete flag : %x", complete_flags); - - if (vconf_set_int(VCONFKEY_STICKER_SYNC_COMPLETE, complete_flags) == 0) - LOGD("Succeed to set sync complete"); - else - LOGW("Fail to set sync complete"); - } - else { - LOGW("Failed to get sticker sync flags"); + + int feature_flag = 0; + if (vconf_get_int(VCONFKEY_STICKER_SYNC_COMPLETE, &complete_flags) == 0 && complete_flags == 0) { +#ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE + if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0) { + if (feature_flag == VCONFKEY_STICKER_FEATURE_AREMOJI) { + if (sticker_data.group == string("arsticker")) { + complete_flags = VCONFKEY_STICKER_SYNC_COMPLETE_DONE; + } + } + else if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) { + if (sticker_data.group == string("bitmoji")) { + complete_flags = VCONFKEY_STICKER_SYNC_COMPLETE_DONE; + } + } + + LOGD("sync complete flag : %x", complete_flags); + + if (vconf_set_int(VCONFKEY_STICKER_SYNC_COMPLETE, complete_flags) == 0) + LOGD("Succeed to set sync complete"); + else + LOGW("Fail to set sync complete"); + } +#endif /* VCONFKEY_STICKER_SUPPORTED_FEATURE */ } json_object_set_string_member(j_object, "result", "success"); -- 2.7.4 From c1df278dc2aa54a1411028583c37125eb0f5ab0b Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 27 Mar 2020 18:53:03 +0900 Subject: [PATCH 06/16] Support to copy thumbnail to RW directory Change-Id: I0a590cbccbca31453898c762baf27309b9980f7c --- client/sticker_dbus.c | 2 +- server/stickerd_data_manager.c | 40 +++++++++++++++++++++++++++++++++++++--- sticker-parser/sticker-parser.c | 3 +++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/client/sticker_dbus.c b/client/sticker_dbus.c index 13eef77..633089c 100644 --- a/client/sticker_dbus.c +++ b/client/sticker_dbus.c @@ -718,7 +718,7 @@ int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_ if (sticker_data->thumbnail && strcmp(sticker_data->thumbnail, origin_data->thumbnail) != 0) { LOGD("origin_thumbnail : %s, new_thumbnail : %s", origin_data->thumbnail, sticker_data->thumbnail); - ret = _send_sync_message(gdbus_connection, g_variant_new("(is)", sticker_data->sticker_info_id, sticker_data->thumbnail), &reply, "update_sticker_thumbnail"); + ret = _send_sync_message(gdbus_connection, g_variant_new("(iss)", sticker_data->sticker_info_id, sticker_data->app_id, sticker_data->thumbnail), &reply, "update_sticker_thumbnail"); if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker thumbnail"); goto cleanup; diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index 4f0b5b2..fc5492b 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -214,6 +214,7 @@ int stickerd_register_dbus_interface(void) " " " " + " " " " " " @@ -595,6 +596,21 @@ int stickerd_insert_sticker_info(GVariant *parameters, GVariant **reply_body) } } + if (sticker_info->thumbnail) { + if (_check_file_exist(sticker_info->app_id, sticker_info->thumbnail) == 0) { + sticker_info->thumbnail = _convert_sticker_uri(sticker_info->thumbnail, sticker_info->app_id); + if (!sticker_info->thumbnail) { + LOGE("failed to copy sticker thumbnail"); + ret = STICKERD_SERVER_ERROR_FILE_EXISTS; + goto cleanup; + } + } else { + LOGE("sticker thumbnail does not exist"); + ret = STICKERD_SERVER_ERROR_NO_SUCH_FILE; + goto cleanup; + } + } + ret = stickerd_db_insert_sticker_info(&record_id, sticker_info); if (ret != STICKERD_SERVER_ERROR_NONE) { LOGE("Failed to insert sticker info"); @@ -738,8 +754,15 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_ goto free_memory; sticker_info->thumbnail = _get_string_from_object(info_object, "thumbnail"); - if (!sticker_info->thumbnail) - goto free_memory; + if (sticker_info->thumbnail) { + if (_check_file_exist(sticker_info->app_id, sticker_info->thumbnail) == 0) { + sticker_info->thumbnail = _convert_sticker_uri(sticker_info->thumbnail, sticker_info->app_id); + if (!sticker_info->thumbnail) + goto free_memory; + } else { + goto free_memory; + } + } sticker_info->description = _get_string_from_object(info_object, "description"); @@ -892,6 +915,7 @@ int stickerd_update_sticker_thumbnail(GVariant *parameters, GVariant **reply_bod { int ret; int record_id; + char *app_id; char *thumbnail; *reply_body = g_variant_new("()"); @@ -900,7 +924,17 @@ int stickerd_update_sticker_thumbnail(GVariant *parameters, GVariant **reply_bod return STICKERD_SERVER_ERROR_OPERATION_FAILED; } - g_variant_get(parameters, "(i&s)", &record_id, &thumbnail); + g_variant_get(parameters, "(i&s&s)", &record_id, &app_id, &thumbnail); + + if (_check_file_exist(app_id, thumbnail) == 0) { + thumbnail = _convert_sticker_uri(thumbnail, app_id); + if (!thumbnail) { + LOGE("failed to copy sticker thumbnail"); + return STICKERD_SERVER_ERROR_FILE_EXISTS; + } + } else { + return STICKERD_SERVER_ERROR_NO_SUCH_FILE; + } ret = stickerd_db_update_sticker_info(record_id, STICKER_DB_STICKER_THUMBNAIL, (void *)thumbnail); if (ret != STICKERD_SERVER_ERROR_NONE) { diff --git a/sticker-parser/sticker-parser.c b/sticker-parser/sticker-parser.c index 6910d6b..d5a3bd4 100644 --- a/sticker-parser/sticker-parser.c +++ b/sticker-parser/sticker-parser.c @@ -599,6 +599,9 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path goto free_memory; thumbnail = __get_string_from_object(info_object, "thumbnail"); + if (thumbnail) + thumbnail = __convert_sticker_uri(thumbnail, appid, app_path); + description = __get_string_from_object(info_object, "description"); int disp_type = __get_int_from_object(info_object, "display_type"); -- 2.7.4 From 77471f8541f0a8b44e9e702f5122a5429d98d244 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 27 Mar 2020 16:44:07 +0900 Subject: [PATCH 07/16] Support to create thumbnail of the sticker Change-Id: I78df10b6422fe225910870640381ecd2cdead1fa --- packaging/capi-ui-sticker.spec | 1 + receiver/CMakeLists.txt | 1 + receiver/inc/config.h | 3 +++ receiver/inc/sticker_data.h | 1 + receiver/inc/sticker_info.h | 2 +- receiver/src/ft.cpp | 50 +++++++++++++++++++++++++++++++++++++++--- receiver/src/sticker_data.cpp | 1 + receiver/src/sticker_info.cpp | 4 ++-- receiver/tizen-manifest.xml | 1 + 9 files changed, 58 insertions(+), 6 deletions(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index ee59659..4d158b4 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -32,6 +32,7 @@ BuildRequires: pkgconfig(capi-appfw-alarm) BuildRequires: pkgconfig(capi-system-device) BuildRequires: pkgconfig(sap-client-stub-api) BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(capi-media-thumbnail-util) BuildRequires: hash-signer Requires(post): signing-client diff --git a/receiver/CMakeLists.txt b/receiver/CMakeLists.txt index 4a875d9..49b6d42 100644 --- a/receiver/CMakeLists.txt +++ b/receiver/CMakeLists.txt @@ -22,6 +22,7 @@ pkg_check_modules(pkgs_test REQUIRED sap-client-stub-api json-glib-1.0 vconf + capi-media-thumbnail-util ) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/receiver/inc) diff --git a/receiver/inc/config.h b/receiver/inc/config.h index 88eee4d..454bd5d 100644 --- a/receiver/inc/config.h +++ b/receiver/inc/config.h @@ -28,4 +28,7 @@ #define MINIMUM_BATTERY 15 +#define THUMBNAIL_WIDTH 96 +#define THUMBNAIL_HEIGHT 96 + #endif /* __CONFIG_H__ */ diff --git a/receiver/inc/sticker_data.h b/receiver/inc/sticker_data.h index 97f82cc..2989c2b 100644 --- a/receiver/inc/sticker_data.h +++ b/receiver/inc/sticker_data.h @@ -32,6 +32,7 @@ struct sticker_info { string keyword; string disp_type; string description; + string thumbnail_path; }; #endif /* __STICKER_DATA_H__ */ diff --git a/receiver/inc/sticker_info.h b/receiver/inc/sticker_info.h index 2e20ad8..3a70556 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); +void insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc, const char *thumbnail); 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 8f81c0a..8aa293f 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "ft.h" #include "log.h" @@ -157,11 +158,31 @@ static void _on_send_completed(sap_file_transaction_h file_transaction, else { LOGI("Succeed to change permission : %s", sticker_data.file_path.c_str()); if (create_sticker_provider_handle() == STICKER_ERROR_NONE) { - insert_sticker_data(sticker_data.file_path.c_str(), sticker_data.keyword.c_str(), sticker_data.group.c_str(), sticker_data.description.c_str()); - destroy_sticker_provider_handle(); + 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()); + sticker_data.thumbnail_path = string(thumb_path); + + if (data_path) + free(data_path); + + int ret = thumbnail_util_extract_to_file(sticker_data.file_path.c_str(), THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, sticker_data.thumbnail_path.c_str()); + if (ret != THUMBNAIL_UTIL_ERROR_NONE) { + LOGE("Failed to create thumbnail. msg : %s", get_error_message(ret)); + sticker_data.thumbnail_path.clear(); + } else { + 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()); + destroy_sticker_provider_handle(); + } if (unlink(sticker_data.file_path.c_str()) == -1) LOGE("Failed to remove sticker file"); + + if (!sticker_data.thumbnail_path.empty()) { + if (unlink(sticker_data.thumbnail_path.c_str()) == -1) + LOGE("Failed to remove sticker thumbnail"); + } } } @@ -244,7 +265,9 @@ void accept_file() sprintf(file_path, "%s/%s", data_path, incoming_file_name.c_str()); LOGI("Receive filepath : %s", file_path); sticker_data.file_path = string(file_path); - free(data_path); + + if (data_path) + free(data_path); ret = sap_file_transfer_receive(priv_data.file_socket, file_path); switch(ret) { @@ -309,6 +332,19 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty return result; } +static int _create_directory(const char *path) +{ + if (access(path, F_OK) == 0) + return 0; + + if (mkdir(path, 0755) == -1) { + LOGE("directory create error"); + return -1; + } + + return 0; +} + void request_sticker_feature() { JsonObject *j_object = NULL; @@ -335,6 +371,14 @@ void request_sticker_feature() } json_object_unref(j_object); + + char thumb_path[PATH_MAX]; + char *data_path = NULL; + data_path = app_get_shared_data_path(); + sprintf(thumb_path, "%s/thumbnail", data_path); + + if (_create_directory(thumb_path) != 0) + LOGE("Failed to create thumbnail directory"); } void reject_file() diff --git a/receiver/src/sticker_data.cpp b/receiver/src/sticker_data.cpp index bd94ee5..df0792b 100644 --- a/receiver/src/sticker_data.cpp +++ b/receiver/src/sticker_data.cpp @@ -33,4 +33,5 @@ void sticker_info::reset() keyword.clear(); disp_type.clear(); description.clear(); + thumbnail_path.clear(); } \ No newline at end of file diff --git a/receiver/src/sticker_info.cpp b/receiver/src/sticker_info.cpp index 16ca72e..38c9709 100644 --- a/receiver/src/sticker_info.cpp +++ b/receiver/src/sticker_info.cpp @@ -82,12 +82,12 @@ int len, const char* group, const char* thumbnail, const char* description) } void -insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc) +insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc, const char *thumbnail) { sticker_data_h data_handle; int ret; - data_handle = set_sticker_data(STICKER_DATA_URI_LOCAL_PATH, filepath, keyword, 1, group, NULL, desc); + data_handle = set_sticker_data(STICKER_DATA_URI_LOCAL_PATH, filepath, keyword, 1, group, thumbnail, desc); ret = sticker_provider_insert_data(sticker_provider, data_handle); if (ret != STICKER_ERROR_NONE) { diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 1d23be5..27a1454 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -13,6 +13,7 @@ http://developer.samsung.com/tizen/privilege/accessoryprotocol http://tizen.org/privilege/content.write http://tizen.org/privilege/mediastorage + http://tizen.org/privilege/externalstorage http://tizen.org/privilege/appdir.shareddata http://tizen.org/privilege/alarm.set http://tizen.org/privilege/alarm.get -- 2.7.4 From 4ff01569240451fd6dc7bacf420f74f1914f08f5 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 30 Mar 2020 17:42:40 +0900 Subject: [PATCH 08/16] Update package version to 0.1.26 Change-Id: Ibaa8c4918235187545ee45e5989f1fb8f621da04 --- 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 4d158b4..dcb311b 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.25 +Version: 0.1.26 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 27a1454..8f4cac2 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 99e89c21766159d9faafbddd1711f0022f8c5dd1 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Tue, 31 Mar 2020 18:30:03 +0900 Subject: [PATCH 09/16] Modified to delete image files when sticker data is deleted from DB Change-Id: I6c27cee243833a93ce280f97964e3e2c1e8a9ab6 --- client/sticker_dbus.c | 74 ++++++++++++++++++++++++++++-------------- server/stickerd_data_manager.c | 2 +- server/stickerd_db_manager.c | 55 +++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 26 deletions(-) diff --git a/client/sticker_dbus.c b/client/sticker_dbus.c index 633089c..318782b 100644 --- a/client/sticker_dbus.c +++ b/client/sticker_dbus.c @@ -23,6 +23,8 @@ #endif #define LOG_TAG "STICKER_DBUS" +#define STICKER_DIRECTORY tzplatform_mkpath(TZ_SYS_SHARE, "sticker-data") + static int is_server_started = 0; static void _server_appeared_cb(GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer user_data) @@ -682,29 +684,44 @@ int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_ return ret; } - if (sticker_data->uri && strcmp(sticker_data->uri, origin_data->uri) != 0) { - LOGD("origin_uri : %s, new_uri : %s", origin_data->uri, sticker_data->uri); - int is_exist = 0; - ret = _send_sync_message(gdbus_connection, g_variant_new("(s)", sticker_data->uri), &reply, "check_file_exists"); - if (ret == STICKER_CLIENT_ERROR_NONE) { - reply_body = g_dbus_message_get_body(reply); - g_variant_get(reply_body, "(i)", &is_exist); - - if (is_exist) { - LOGE("file already exists"); - ret = STICKER_CLIENT_ERROR_FILE_EXISTS; + if (sticker_data->uri) { + int len; + char *conv_path = NULL; + if (sticker_data->type == STICKER_DATA_URI_LOCAL_PATH) { + len = strlen(STICKER_DIRECTORY) + strlen(sticker_data->app_id) + strlen(sticker_data->uri) + 2; + conv_path = (char *)calloc(len, sizeof(char)); + snprintf(conv_path, len, "%s/%s%s", STICKER_DIRECTORY, sticker_data->app_id, sticker_data->uri); + } else + conv_path = strdup(sticker_data->uri); + + if (strcmp(conv_path, origin_data->uri) != 0) { + LOGD("origin_uri : %s, new_uri : %s", origin_data->uri, conv_path); + int is_exist = 0; + ret = _send_sync_message(gdbus_connection, g_variant_new("(s)", sticker_data->uri), &reply, "check_file_exists"); + if (ret == STICKER_CLIENT_ERROR_NONE) { + reply_body = g_dbus_message_get_body(reply); + g_variant_get(reply_body, "(i)", &is_exist); + + if (is_exist) { + LOGE("file already exists"); + ret = STICKER_CLIENT_ERROR_FILE_EXISTS; + free(conv_path); + goto cleanup; + } + } else { + LOGE("failed to check file exists"); + free(conv_path); goto cleanup; } - } else { - LOGE("failed to check file exists"); - goto cleanup; - } - ret = _send_sync_message(gdbus_connection, g_variant_new("(isis)", sticker_data->sticker_info_id, sticker_data->app_id, sticker_data->type, sticker_data->uri), &reply, "update_sticker_uri"); - if (ret != STICKER_CLIENT_ERROR_NONE) { - LOGE("failed to update sticker uri"); - goto cleanup; + ret = _send_sync_message(gdbus_connection, g_variant_new("(isis)", sticker_data->sticker_info_id, sticker_data->app_id, sticker_data->type, sticker_data->uri), &reply, "update_sticker_uri"); + if (ret != STICKER_CLIENT_ERROR_NONE) { + LOGE("failed to update sticker uri"); + free(conv_path); + goto cleanup; + } } + free(conv_path); } if (sticker_data->type != 0 && sticker_data->type != origin_data->type) { @@ -716,13 +733,20 @@ int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_ } } - if (sticker_data->thumbnail && strcmp(sticker_data->thumbnail, origin_data->thumbnail) != 0) { - LOGD("origin_thumbnail : %s, new_thumbnail : %s", origin_data->thumbnail, sticker_data->thumbnail); - ret = _send_sync_message(gdbus_connection, g_variant_new("(iss)", sticker_data->sticker_info_id, sticker_data->app_id, sticker_data->thumbnail), &reply, "update_sticker_thumbnail"); - if (ret != STICKER_CLIENT_ERROR_NONE) { - LOGE("failed to update sticker thumbnail"); - goto cleanup; + if (sticker_data->thumbnail) { + int len = strlen(STICKER_DIRECTORY) + strlen(sticker_data->app_id) + strlen(sticker_data->thumbnail) + 2; + char *conv_path = (char *)calloc(len, sizeof(char)); + snprintf(conv_path, len, "%s/%s%s", STICKER_DIRECTORY, sticker_data->app_id, sticker_data->thumbnail); + if (strcmp(conv_path, origin_data->thumbnail) != 0) { + LOGD("origin_thumbnail : %s, new_thumbnail : %s", origin_data->thumbnail, conv_path); + ret = _send_sync_message(gdbus_connection, g_variant_new("(iss)", sticker_data->sticker_info_id, sticker_data->app_id, sticker_data->thumbnail), &reply, "update_sticker_thumbnail"); + if (ret != STICKER_CLIENT_ERROR_NONE) { + LOGE("failed to update sticker thumbnail"); + free(conv_path); + goto cleanup; + } } + free(conv_path); } if (sticker_data->description && strcmp(sticker_data->description, origin_data->description) != 0) { diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index fc5492b..3585b8d 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -497,7 +497,7 @@ static char* _convert_sticker_uri(const char *uri, const char *appid) snprintf(new_path, len, "%s/%s/%s",STICKER_DIRECTORY, appid, uri); if (access(new_path, F_OK) == 0) { - LOGE("sticker file already exists"); + LOGE("sticker file already exists : %s", new_path); ret = -1; goto cleanup; } diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index 52a177c..dbefbb7 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -75,6 +75,8 @@ #define STICKER_DB_GET_LATEST_RECORD_ID "SELECT sticker_info_id FROM sticker_info ORDER BY sticker_info_id DESC LIMIT 1" #define STICKER_DB_GET_STICKER_INFO_BY_RECORD_ID "SELECT * FROM sticker_info WHERE sticker_info_id = ?" #define STICKER_DB_GET_KEYWORD_INFO_BY_RECORD_ID "SELECT keyword FROM sticker_keyword_info WHERE sticker_info_id = ?" +#define STICKER_DB_GET_IMAGE_INFO_BY_RECORED_ID "SELECT type, uri, thumbnail FROM sticker_info WHERE sticker_info_id = ?" +#define STICKER_DB_GET_IMAGE_INFO_BY_URI "SELECT type, thumbnail FROM sticker_info WHERE uri = ?" #define STICKER_DB_GET_ALL_GROUP_LIST "SELECT DISTINCT group_name FROM sticker_info WHERE app_id NOT IN (SELECT DISTINCT provider_id FROM sticker_whitelist_info WHERE provider_id NOT IN (SELECT provider_id FROM sticker_whitelist_info WHERE consumer_id = ?))" #define STICKER_DB_GET_ALL_KEYWORD_LIST "SELECT DISTINCT keyword FROM sticker_keyword_info WHERE sticker_info_id IN (SELECT sticker_info_id from sticker_info WHERE app_id NOT IN (SELECT DISTINCT provider_id FROM sticker_whitelist_info WHERE provider_id NOT IN (SELECT provider_id FROM sticker_whitelist_info WHERE consumer_id = ?)))" #define STICKER_DB_GET_STICKER_COUNT "SELECT count(*) FROM sticker_info WHERE app_id = ?" @@ -398,6 +400,33 @@ int stickerd_db_delete_sticker_info(int record_id) if (!db) return STICKERD_SERVER_ERROR_DB_FAILED; + ret = sqlite3_prepare_v2(db, STICKER_DB_GET_IMAGE_INFO_BY_RECORED_ID, -1, &stmt, NULL); + if (ret != SQLITE_OK) { + LOGE("fail to get image files : %s", sqlite3_errmsg(db)); + goto cleanup; + } + + sqlite3_bind_int(stmt, 1, record_id); + + ret = sqlite3_step(stmt); + if (ret == SQLITE_ERROR) { + LOGE("sqlite3_step() failed : ret(%d)", ret); + goto cleanup; + } + + int uri_type = sqlite3_column_int(stmt, 0); + const unsigned char *uri = sqlite3_column_text(stmt, 1); + const unsigned char *thumbnail = sqlite3_column_text(stmt, 2); + + if (uri_type == 1 && unlink((const char *)uri) == -1) + LOGE("fail to delete sticker file"); + + if (thumbnail && unlink((const char *)thumbnail) == -1) + LOGE("fail to delete thumbnail image"); + + sqlite3_finalize(stmt); + stmt = NULL; + ret = sqlite3_prepare_v2(db, STICKER_DB_DELETE_STICKER_INFO, -1, &stmt, NULL); if (ret != SQLITE_OK) { LOGE("fail to delete sticker information : %s", sqlite3_errmsg(db)); @@ -437,6 +466,32 @@ int stickerd_db_delete_sticker_info_by_uri(char *uri) if (!db) return STICKERD_SERVER_ERROR_DB_FAILED; + ret = sqlite3_prepare_v2(db, STICKER_DB_GET_IMAGE_INFO_BY_URI, -1, &stmt, NULL); + if (ret != SQLITE_OK) { + LOGE("fail to delete sticker information : %s", sqlite3_errmsg(db)); + goto cleanup; + } + + sqlite3_bind_text(stmt, 1, uri, -1, SQLITE_TRANSIENT); + + ret = sqlite3_step(stmt); + if (ret == SQLITE_ERROR) { + LOGE("sqlite3_step() failed : ret(%d)", ret); + goto cleanup; + } + + int uri_type = sqlite3_column_int(stmt, 0); + const unsigned char *thumbnail = sqlite3_column_text(stmt, 1); + + if (uri_type == 1 && unlink((const char *)uri) == -1) + LOGE("fail to delete sticker file"); + + if (thumbnail && unlink((const char *)thumbnail) == -1) + LOGE("fail to delete thumbnail image"); + + sqlite3_finalize(stmt); + stmt = NULL; + ret = sqlite3_prepare_v2(db, STICKER_DB_DELETE_STICKER_INFO_BY_URI, -1, &stmt, NULL); if (ret != SQLITE_OK) { LOGE("fail to delete sticker information : %s", sqlite3_errmsg(db)); -- 2.7.4 From 9d5407709a6b133124432087f8d81f8a08282af7 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 31 Mar 2020 20:40:26 +0900 Subject: [PATCH 10/16] Fix issues detected by static analysis tool Change-Id: I19d0a8dd76c0b4f9e58ce1541a995ca6a2e3f020 Signed-off-by: Jihoon Kim --- server/stickerd_db_manager.c | 2 ++ sticker-parser/sticker-parser.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index dbefbb7..3adda1b 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -188,6 +188,7 @@ static int _recover_db(void) if (ret != SQLITE_OK) { LOGE("Failed to create sticker_keyword_info table : %s", err); ret = STICKERD_SERVER_ERROR_DB_FAILED; + goto cleanup; } ret = sqlite3_exec(db, STICKER_WHITELIST_INFO_CREATE_TABLE, NULL, NULL, &err); @@ -251,6 +252,7 @@ int stickerd_db_init(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, "PRAGMA journal_mode = WAL", NULL, NULL, &err); diff --git a/sticker-parser/sticker-parser.c b/sticker-parser/sticker-parser.c index d5a3bd4..2c3eb73 100644 --- a/sticker-parser/sticker-parser.c +++ b/sticker-parser/sticker-parser.c @@ -599,8 +599,10 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path goto free_memory; thumbnail = __get_string_from_object(info_object, "thumbnail"); - if (thumbnail) + if (thumbnail) { + free(thumbnail); thumbnail = __convert_sticker_uri(thumbnail, appid, app_path); + } description = __get_string_from_object(info_object, "description"); int disp_type = __get_int_from_object(info_object, "display_type"); -- 2.7.4 From 07bbe18d5cd222da82f344462629e2e3a6e5b6d3 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Tue, 31 Mar 2020 20:45:43 +0900 Subject: [PATCH 11/16] Update package version to 0.1.27 Change-Id: I5792b659a02db981e43eb5b0c22c2dac265faf55 --- 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 dcb311b..69d6aab 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.26 +Version: 0.1.27 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 8f4cac2..99f33fb 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From a532f47ebbace5a3b4c299ec4fb4c31895f94720 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 1 Apr 2020 14:41:30 +0900 Subject: [PATCH 12/16] Fix bug not to set sync complete vconf value Change-Id: Ie69f9ccac30158ce3eae6c202ada09fe863d36ac Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 8aa293f..4431be7 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -625,12 +625,12 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in #ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0) { if (feature_flag == VCONFKEY_STICKER_FEATURE_AREMOJI) { - if (sticker_data.group == string("arsticker")) { + if (current_request.category == string("arsticker")) { complete_flags = VCONFKEY_STICKER_SYNC_COMPLETE_DONE; } } else if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) { - if (sticker_data.group == string("bitmoji")) { + if (current_request.category == string("bitmoji")) { complete_flags = VCONFKEY_STICKER_SYNC_COMPLETE_DONE; } } @@ -642,6 +642,8 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in else LOGW("Fail to set sync complete"); } +#else + LOGW("No vconf supported feature"); #endif /* VCONFKEY_STICKER_SUPPORTED_FEATURE */ } -- 2.7.4 From e1c3e431243c75fd609a2dcde745ae0e8ad567e9 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 1 Apr 2020 14:44:32 +0900 Subject: [PATCH 13/16] Support to set sync status in vconf Change-Id: Icf738f01b50128e6d8085b2d56e83e79eacc9ad7 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 71 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 4431be7..f9400ed 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -83,6 +83,30 @@ static int rec_file_cnt_in_group = 0; static int total_file_count_in_group = 0; static int sync_success_cnt = 0; +static void set_first_sync_complete() +{ + int complete_flags = 0; + if (vconf_get_int(VCONFKEY_STICKER_SYNC_COMPLETE, &complete_flags) == 0 && complete_flags == 0) { + if (vconf_set_int(VCONFKEY_STICKER_SYNC_COMPLETE, VCONFKEY_STICKER_SYNC_COMPLETE_DONE) == 0) + LOGD("Succeed to set sync complete"); + else + LOGW("Fail to set sync complete"); + } +} + +static void set_sync_progressing(gboolean flag) +{ +#ifdef VCONFKEY_STICKER_SYNC_STATE + LOGD("sync progressing : %d", flag); + if (vconf_set_int(VCONFKEY_STICKER_SYNC_STATE, flag ? VCONFKEY_STICKER_SYNC_STATE_IN_PROGRESS : VCONFKEY_STICKER_SYNC_STATE_WAITING) == 0) + LOGD("Succeed to set sync state"); + else + LOGW("Fail to set sync state"); +#else + LOGW("No vconf sync state definition"); +#endif +} + static gboolean _send_json_data(JsonObject *obj) { JsonGenerator *j_generator = NULL; @@ -324,6 +348,7 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty current_request.mode = string(mode ? mode : "manual"); current_request.category = string(category ? category : "arsticker"); current_request.type = string(type ? type : "input"); + set_sync_progressing(TRUE); result = true; } @@ -515,6 +540,8 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in LOGD("Succeed to set supported feature"); else LOGW("Fail to set supported feature"); +#else + LOGW("No vconf supported feature"); #endif if (!process_request_queue()) { @@ -543,6 +570,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in send_message("sync_start_response", response_to_app.c_str()); if (result_code != SYNC_START_RSP_SUCCESS) { + set_sync_progressing(FALSE); if (!process_request_queue()) { service_app_exit(); } @@ -618,34 +646,35 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in json_object_set_string_member(j_object, "result", "failure"); } else { - int complete_flags = 0; - int feature_flag = 0; - if (vconf_get_int(VCONFKEY_STICKER_SYNC_COMPLETE, &complete_flags) == 0 && complete_flags == 0) { + #ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE - if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0) { - if (feature_flag == VCONFKEY_STICKER_FEATURE_AREMOJI) { - if (current_request.category == string("arsticker")) { - complete_flags = VCONFKEY_STICKER_SYNC_COMPLETE_DONE; - } + if (vconf_get_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, &feature_flag) == 0) + { + LOGD("feature : %d, current request category : %s", feature_flag, current_request.category.c_str()); + if (feature_flag == VCONFKEY_STICKER_FEATURE_AREMOJI) + { + if (current_request.category == string("arsticker")) + { + set_first_sync_complete(); + set_sync_progressing(FALSE); } - else if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) { - if (current_request.category == string("bitmoji")) { - complete_flags = VCONFKEY_STICKER_SYNC_COMPLETE_DONE; - } + } + else if (feature_flag & VCONFKEY_STICKER_FEATURE_BITMOJI) + { + if (current_request.category == string("bitmoji")) + { + set_first_sync_complete(); + set_sync_progressing(FALSE); } - - LOGD("sync complete flag : %x", complete_flags); - - if (vconf_set_int(VCONFKEY_STICKER_SYNC_COMPLETE, complete_flags) == 0) - LOGD("Succeed to set sync complete"); - else - LOGW("Fail to set sync complete"); } + } + else { + LOGW("Failed to read support feature"); + } #else - LOGW("No vconf supported feature"); + LOGW("No vconf supported feature"); #endif /* VCONFKEY_STICKER_SUPPORTED_FEATURE */ - } json_object_set_string_member(j_object, "result", "success"); sync_success_cnt++; -- 2.7.4 From fbd183658649f34ff64196a2274624ba7996a0ae Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 1 Apr 2020 15:42:04 +0900 Subject: [PATCH 14/16] Set sync status in case of disconnect Change-Id: I26d5a635acc433908f70677b988b67e7e624b24d Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index f9400ed..9797d68 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -460,6 +460,7 @@ void conn_terminated(sap_peer_agent_h peer_agent, sap_socket_destroy(priv->socket); priv->socket = NULL; + set_sync_progressing(FALSE); service_app_exit(); } -- 2.7.4 From 51bf85bc240f0ea46f53a55d950a5b5bb41e1109 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 30 Mar 2020 21:19:07 +0900 Subject: [PATCH 15/16] Request sticker sync again when sticker-request-sync-req message is received Change-Id: I418887a4adb019ad8c77ed4467a913d7f15a8959 --- receiver/src/ft.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 9797d68..461b596 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -45,6 +45,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_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" @@ -522,7 +523,10 @@ 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_SYNC_FEATURE_RSP) { + if (msg_id == STICKER_REQUEST_SYNC_REQ) { + if (!request_sticker_data(current_request.mode.c_str(), current_request.category.c_str(), current_request.type.c_str())) + LOGW("Failed to request sticker sync"); + } else if (msg_id == STICKER_SYNC_FEATURE_RSP) { LOGD("msg : %s", msg_id.c_str()); #ifdef VCONFKEY_STICKER_SUPPORTED_FEATURE const char *json_aremoji = json_object_get_string_member(root_obj, "arEmoji"); -- 2.7.4 From af39de46d5ca75991ffaa03c88db544fbc36a034 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Tue, 31 Mar 2020 21:02:17 +0900 Subject: [PATCH 16/16] Remove unnecessary privileges Change-Id: I593db0d467d5ac1cda186cb7b792d7ac47f4f382 --- receiver/tizen-manifest.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 99f33fb..ec008e2 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -12,8 +12,6 @@ http://developer.samsung.com/tizen/privilege/accessoryprotocol http://tizen.org/privilege/content.write - http://tizen.org/privilege/mediastorage - http://tizen.org/privilege/externalstorage http://tizen.org/privilege/appdir.shareddata http://tizen.org/privilege/alarm.set http://tizen.org/privilege/alarm.get -- 2.7.4