From cccab67025622346c9643bd1fe8e0205593def7a Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 20 Mar 2020 13:11:25 +0900 Subject: [PATCH 01/16] Fix wrong error value Change-Id: If4d58982b791dc064cc3b05d7e35d84caf9c661f --- include/sticker_error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sticker_error.h b/include/sticker_error.h index fea1302..2239809 100644 --- a/include/sticker_error.h +++ b/include/sticker_error.h @@ -47,7 +47,7 @@ typedef enum { STICKER_ERROR_OPERATION_FAILED = TIZEN_ERROR_STICKER | 0x0001, /**< Operation failed */ STICKER_ERROR_FILE_EXISTS = TIZEN_ERROR_FILE_EXISTS, /**< File exists */ STICKER_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available */ - STICKER_ERROR_NO_SUCH_FILE = TIZEN_ERROR_FILE_EXISTS, /**< No such file */ + STICKER_ERROR_NO_SUCH_FILE = TIZEN_ERROR_NO_SUCH_FILE, /**< No such file */ } sticker_error_e; /** -- 2.7.4 From 80dc4d119819af92f77c49771f0dfe2e8e8c0ece Mon Sep 17 00:00:00 2001 From: InHong Han Date: Tue, 24 Mar 2020 13:45:10 +0900 Subject: [PATCH 02/16] Update package version to 0.1.24 Change-Id: Ia2d82f6d9e7397b97dd7155c6f72f143d42fbb2d --- 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 cc07b17..442c769 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.23 +Version: 0.1.24 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index b01d8c2..aeaa201 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 6c03a6605febb89590e3355138b6917429cc19ca Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 24 Mar 2020 20:28:57 +0900 Subject: [PATCH 03/16] Fix issue request sending fail log is displayed before connection is established Change-Id: I655ef74f51c62c82a4c476b9b2fabb2faee774f3 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 4a2ec79..cc821a9 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -273,7 +273,18 @@ void accept_file() void request_sticker_data(const char *mode, const char *category, const char *type) { - JsonObject *j_object = json_object_new(); + JsonObject *j_object = NULL; + if (!priv_data.socket) { + pending_request.req_type = REQUEST_TYPE_SYNC; + pending_request.mode = string(mode ? mode : "manual"); + pending_request.category = string(category? category : "arsticker"); + pending_request.type = string(type ? type : "input"); + + LOGI("Push sync request"); + return; + } + + j_object = json_object_new(); if (j_object == NULL) { LOGE("json object create error"); return; @@ -286,12 +297,7 @@ void request_sticker_data(const char *mode, const char *category, const char *ty json_object_set_string_member(j_object, "type", type); if (_send_json_data(j_object) == FALSE) { - pending_request.req_type = REQUEST_TYPE_SYNC; - pending_request.mode = string(mode ? mode : "manual"); - pending_request.category = string(category? category : "arsticker"); - pending_request.type = string(type ? type : "input"); - - LOGI("Push sync request"); + LOGE("Failed to send STICKER_SYNC_START_REQ"); } else { current_request.req_type = REQUEST_TYPE_SYNC; @@ -305,7 +311,15 @@ void request_sticker_data(const char *mode, const char *category, const char *ty void request_sticker_feature() { - JsonObject *j_object = json_object_new(); + JsonObject *j_object = NULL; + + if (!priv_data.socket) { + pending_request.req_type = REQUEST_TYPE_FEATURE_REQ; + LOGI("Push sync feature request"); + return; + } + + j_object = json_object_new(); if (j_object == NULL) { LOGE("json object create error"); return; @@ -315,7 +329,6 @@ void request_sticker_feature() json_object_set_int_member(j_object, "tID", ++t_id); if (_send_json_data(j_object) == FALSE) { - pending_request.req_type = REQUEST_TYPE_FEATURE_REQ; LOGE("Failed to send STICKER_SYNC_FEATURE_REQ"); } -- 2.7.4 From 5a67afed3e35ce14a9f675b0a6d6faabe1ec22b2 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 24 Mar 2020 20:49:43 +0900 Subject: [PATCH 04/16] Fix coding style Change-Id: I277099b06973fe4306ad95e869a20ce12f2ff0e3 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index cc821a9..9a8addd 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -277,7 +277,7 @@ void request_sticker_data(const char *mode, const char *category, const char *ty if (!priv_data.socket) { pending_request.req_type = REQUEST_TYPE_SYNC; pending_request.mode = string(mode ? mode : "manual"); - pending_request.category = string(category? category : "arsticker"); + pending_request.category = string(category ? category : "arsticker"); pending_request.type = string(type ? type : "input"); LOGI("Push sync request"); @@ -302,7 +302,7 @@ void request_sticker_data(const char *mode, const char *category, const char *ty else { current_request.req_type = REQUEST_TYPE_SYNC; current_request.mode = string(mode ? mode : "manual"); - current_request.category = string(category? category : "arsticker"); + current_request.category = string(category ? category : "arsticker"); current_request.type = string(type ? type : "input"); } -- 2.7.4 From 1f5ca3b282adbf20ced43e8c140767b1d69099c4 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 18 Mar 2020 20:11:41 +0900 Subject: [PATCH 05/16] Use request queue Change-Id: I707e5b8bc720659afefc04f1c4cc5adc54ed0f44 Signed-off-by: Jihoon Kim --- receiver/inc/ft.h | 2 +- receiver/inc/sticker_request.h | 34 +++++++++++++ receiver/src/ft.cpp | 113 ++++++++++++++++++++++++----------------- receiver/src/main.cpp | 4 +- 4 files changed, 104 insertions(+), 49 deletions(-) create mode 100644 receiver/inc/sticker_request.h diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index a95204c..10ccb0e 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -29,7 +29,7 @@ void accept_file(void); gboolean initialize_sap(void); void deinitialize_sap(void); -void request_sticker_data(const char *mode, const char *category, const char *type); +bool request_sticker_data(const char *mode, const char *category, const char *type); void request_sticker_feature(); #endif /* __FT_H__ */ diff --git a/receiver/inc/sticker_request.h b/receiver/inc/sticker_request.h new file mode 100644 index 0000000..9c8089f --- /dev/null +++ b/receiver/inc/sticker_request.h @@ -0,0 +1,34 @@ +/* + * 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 __STICKER_REQUEST_H__ +#define __STICKER_REQUEST_H__ + +#include + +using namespace std; + +typedef enum { + REQUEST_TYPE_SYNC, + REQUEST_TYPE_FEATURE_REQ +} request_type; + +struct StickerRequest { + request_type req_type; + string mode; + string category; + string type; +}; +#endif /* __STICKER_REQUEST_H__ */ diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 9a8addd..e2b703d 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -31,11 +31,13 @@ #include #include #include +#include #include "ft.h" #include "log.h" #include "sticker_info.h" #include "../inc/sticker_data.h" +#include "sticker_request.h" #include "message.h" #include "sync_alarm.h" @@ -54,11 +56,6 @@ using namespace std; -typedef enum { - REQUEST_TYPE_SYNC, - REQUEST_TYPE_FEATURE_REQ -} request_type; - enum { SYNC_START_RSP_SUCCESS = 1000, SYNC_START_RSP_NO_STICKER = 1001 @@ -71,22 +68,17 @@ struct sap_info_s { sap_file_transaction_h file_socket; }; -struct request { - request_type req_type; - string mode; - string category; - string type; -}; - static struct sap_info_s priv_data = { 0 }; static struct sticker_info sticker_data; -static struct request pending_request, current_request; +static queue ReqQueue; +static StickerRequest current_request; gboolean file_on_progress = 0; static string incoming_file_name; static int t_id = 0; static int rec_file_cnt = 0; static int total_file_count = 0; +static int sync_success_cnt = 0; static gboolean _send_json_data(JsonObject *obj) { @@ -271,23 +263,28 @@ void accept_file() file_on_progress = 1; } -void request_sticker_data(const char *mode, const char *category, const char *type) +bool request_sticker_data(const char *mode, const char *category, const char *type) { + bool result = false; JsonObject *j_object = NULL; + if (!priv_data.socket) { + StickerRequest pending_request; pending_request.req_type = REQUEST_TYPE_SYNC; pending_request.mode = string(mode ? mode : "manual"); pending_request.category = string(category ? category : "arsticker"); pending_request.type = string(type ? type : "input"); + ReqQueue.push(pending_request); LOGI("Push sync request"); - return; + + return false; } j_object = json_object_new(); if (j_object == NULL) { LOGE("json object create error"); - return; + return false; } json_object_set_string_member(j_object, "msgId", STICKER_SYNC_START_REQ); @@ -298,15 +295,19 @@ void request_sticker_data(const char *mode, const char *category, const char *ty if (_send_json_data(j_object) == FALSE) { LOGE("Failed to send STICKER_SYNC_START_REQ"); + result = false; } else { current_request.req_type = REQUEST_TYPE_SYNC; current_request.mode = string(mode ? mode : "manual"); current_request.category = string(category ? category : "arsticker"); current_request.type = string(type ? type : "input"); + result = true; } json_object_unref(j_object); + + return result; } void request_sticker_feature() @@ -314,7 +315,9 @@ void request_sticker_feature() JsonObject *j_object = NULL; if (!priv_data.socket) { + StickerRequest pending_request; pending_request.req_type = REQUEST_TYPE_FEATURE_REQ; + ReqQueue.push(pending_request); LOGI("Push sync feature request"); return; } @@ -392,6 +395,29 @@ void conn_terminated(sap_peer_agent_h peer_agent, service_app_exit(); } +static bool process_request_queue() +{ + if (ReqQueue.empty()) + return false; + + StickerRequest request = ReqQueue.front(); + + if (request.req_type == REQUEST_TYPE_FEATURE_REQ) { + LOGD("[Request feature exchange]"); + request_sticker_feature(); + ReqQueue.pop(); + } + else if (request.req_type == REQUEST_TYPE_SYNC) { + LOGD("[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(); + } + + return true; +} void on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned int payload_length, void *buffer, @@ -448,7 +474,9 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in LOGW("Fail to set supported feature"); #endif - service_app_exit(); + if (!process_request_queue()) { + service_app_exit(); + } } else if (msg_id == STICKER_SYNC_START_RSP) { LOGD("msg : %s", msg_id.c_str()); const char *json_result = json_object_get_string_member(root_obj, "result"); @@ -471,8 +499,11 @@ 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) - service_app_exit(); + if (result_code != SYNC_START_RSP_SUCCESS) { + if (!process_request_queue()) { + service_app_exit(); + } + } } else if (msg_id == STICKER_SEND_START_REQ) { LOGD("msg : %s", msg_id.c_str()); total_file_count = 0; @@ -542,8 +573,9 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in json_object_set_string_member(j_object, "msgId", STICKER_SEND_STOP_RSP); json_object_set_int_member(j_object, "tID", t_id); - if (reason == "complete" && rec_file_cnt != file_len) + if (reason == "complete" && rec_file_cnt != file_len) { json_object_set_string_member(j_object, "result", "failure"); + } else { int complete_flags = 0; if (vconf_get_int(VCONFKEY_STICKER_SYNC_COMPLETE, &complete_flags) == 0) { @@ -564,25 +596,30 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in } json_object_set_string_member(j_object, "result", "success"); - - if (current_request.mode == string("manual")) { - if (!sync_alarm_exist()) - sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL); - } + sync_success_cnt++; } if (_send_json_data(j_object) == FALSE) LOGE("Failed to send message"); + json_object_unref(j_object); + send_message("sync_stop_result", reason.c_str()); - json_object_unref(j_object); + if (!process_request_queue()) { + if (sync_success_cnt > 0 && current_request.mode == string("manual")) { + if (!sync_alarm_exist()) + sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL); + } + + sync_success_cnt = 0; + + service_app_exit(); + } current_request.mode.clear(); current_request.category.clear(); current_request.type.clear(); - - service_app_exit(); } else LOGW("unknown msg id : %s", msg_id.c_str()); @@ -655,25 +692,7 @@ _on_service_connection_created(sap_peer_agent_h peer_agent, priv->socket = socket; LOGI("Connection Established"); - LOGD("pending_request : %d", pending_request.req_type); - - if (pending_request.req_type == REQUEST_TYPE_FEATURE_REQ) { - LOGD("[Request feature exchange]"); - request_sticker_feature(); - } - else if (pending_request.req_type == REQUEST_TYPE_SYNC) { - if (!pending_request.mode.empty()) { - LOGD("[Request to sync sticker] mode: %s, category: %s, type : %s", pending_request.mode.c_str(), - pending_request.category.c_str(), - pending_request.type.c_str()); - - request_sticker_data(pending_request.mode.c_str(), pending_request.category.c_str(), pending_request.type.c_str()); - - pending_request.mode.clear(); - pending_request.category.clear(); - pending_request.type.clear(); - } - } + process_request_queue(); break; diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 7a5e20d..3fd98e1 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -117,8 +117,10 @@ static void app_control(app_control_h app_control, void *data) if (param_error) goto cleanup; - if (mode && type) + if (mode && type) { request_sticker_data(mode, "arsticker", type); + request_sticker_data(mode, "bitmoji", type); + } } else if (strcmp(request, "oobe") == 0) { LOGI("[OOBE] register sync alarm"); -- 2.7.4 From 5201478930848f51eeff0a48217cb28a9acc0be8 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 13 Mar 2020 17:01:02 +0900 Subject: [PATCH 06/16] Change the sync progress method from total to each group Change-Id: I11bf1a405cd8e69cb9b62e416c7ac45fca9b3c6e Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 24 ++++++++++-------------- receiver/src/message.cpp | 5 +++-- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index e2b703d..e6f085b 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -76,8 +76,8 @@ static StickerRequest current_request; gboolean file_on_progress = 0; static string incoming_file_name; static int t_id = 0; -static int rec_file_cnt = 0; -static int total_file_count = 0; +static int rec_file_cnt_in_group = 0; +static int total_file_count_in_group = 0; static int sync_success_cnt = 0; static gboolean _send_json_data(JsonObject *obj) @@ -129,15 +129,11 @@ cleanup: static void notify_sync_progress(unsigned int file_progress) { - if (total_file_count == 0) + if (total_file_count_in_group == 0) return; - double total_progress = (((double)rec_file_cnt / (double)total_file_count) + (1.0/(double)total_file_count*file_progress/100))*100; - - LOGI("(%2d / %2d), file progress : %3u%%, total progress : %3u%%", rec_file_cnt, total_file_count, file_progress, (unsigned int)total_progress); - char progress_str[32]; - snprintf(progress_str, sizeof(progress_str), "%u", (unsigned int)total_progress); - send_message("sync_progress", progress_str); + LOGI("(%2d / %2d), file progress : %3u%%", rec_file_cnt_in_group+1, total_file_count_in_group, file_progress); + send_message("sync_progress", NULL); } static void _on_send_completed(sap_file_transaction_h file_transaction, @@ -167,7 +163,7 @@ static void _on_send_completed(sap_file_transaction_h file_transaction, } } - rec_file_cnt++; + rec_file_cnt_in_group++; } else { switch (result) { case (SAP_FT_TRANSFER_FAIL_CHANNEL_IO): { @@ -506,8 +502,8 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in } } else if (msg_id == STICKER_SEND_START_REQ) { LOGD("msg : %s", msg_id.c_str()); - total_file_count = 0; - rec_file_cnt = 0; + total_file_count_in_group = 0; + rec_file_cnt_in_group = 0; t_id = json_object_get_int_member(root_obj, "tID"); JsonArray *file_list = json_object_get_array_member(root_obj, "list"); if (file_list) { @@ -520,7 +516,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in if (file_len > 0) { LOGD("Add file : %s, len : %d", file_name.c_str(), file_len); - total_file_count++; + total_file_count_in_group++; } else { LOGD("Delete file : %s, len : %d", file_name.c_str(), file_len); if (create_sticker_provider_handle() == STICKER_ERROR_NONE) { @@ -573,7 +569,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in json_object_set_string_member(j_object, "msgId", STICKER_SEND_STOP_RSP); json_object_set_int_member(j_object, "tID", t_id); - if (reason == "complete" && rec_file_cnt != file_len) { + if (reason == "complete" && rec_file_cnt_in_group != file_len) { json_object_set_string_member(j_object, "result", "failure"); } else { diff --git a/receiver/src/message.cpp b/receiver/src/message.cpp index f67b29e..8dde6a6 100644 --- a/receiver/src/message.cpp +++ b/receiver/src/message.cpp @@ -72,7 +72,8 @@ bool send_message(const char *cmd, const char *data) bundle *b = bundle_create(); bundle_add_str(b, "command", cmd); - bundle_add_str(b, "data", data); + if (data) + bundle_add_str(b, "data", data); ret = message_port_send_message(REMOTE_APP_ID, MESSAGE_PORT_REMOTE_NAME, b); if (ret != MESSAGE_PORT_ERROR_NONE) { LOGW("message port send message error. err : %d", ret); @@ -87,4 +88,4 @@ bool send_message(const char *cmd, const char *data) bundle_free(b); return result; -} \ No newline at end of file +} -- 2.7.4 From b4f75db5f90c042630cc950a7d6d494e6ec92772 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 26 Mar 2020 12:12:09 +0900 Subject: [PATCH 07/16] Update package version to 0.1.25 Change-Id: I572cea0f5e4f90bc58fba9f4a08c148dbd6d7f96 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 442c769..ee59659 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.24 +Version: 0.1.25 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index aeaa201..71b376e 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 00fc02d1298495261ce9a3b4e22578827b570cd0 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 27 Mar 2020 11:09:46 +0900 Subject: [PATCH 08/16] Modified to not initialize the file_path to null before inserting sticker data Change-Id: I5473c0ea2d6dae2a9c68d3c641f8cc76108491de --- receiver/src/ft.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index e6f085b..1b03c03 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -213,6 +213,7 @@ static void _on_send_completed(sap_file_transaction_h file_transaction, } file_on_progress = 0; + sticker_data.reset(); } static void _on_sending_file_in_progress(sap_file_transaction_h file_transaction, @@ -543,8 +544,6 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in json_object_unref(j_object); } else if (msg_id == STICKER_SEND_FACE_DATA) { LOGD("msg : %s", msg_id.c_str()); - sticker_data.reset(); - const char *type_data = json_object_get_string_member(root_obj, "type"); if (type_data) sticker_data.disp_type = string(type_data); -- 2.7.4 From f5afe2482017b66ca67993cb4f7fb9be6b52b043 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 27 Mar 2020 13:34:15 +0900 Subject: [PATCH 09/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 10/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 11/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 12/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 13/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 14/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 15/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 16/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