From ac5dfc1d4595dfeb4697143246c769d60ab9fce9 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 9 Mar 2020 17:18:19 +0900 Subject: [PATCH 01/16] Update package version to 0.1.19 Change-Id: I0976c20df26b65d3151f579ab9cc36bf1c6da6ec --- 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 1abd1c0..97e6304 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.18 +Version: 0.1.19 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 8309056..0d73867 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 072b486a1a6e8211835ebd70d0243f3ec6e91dd9 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 26 Feb 2020 16:37:45 +0900 Subject: [PATCH 02/16] Support to request sticker sync periodically Change-Id: I73467303f4a1cfec69b02a6c1ee4a4410cde0e58 Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 2 + receiver/CMakeLists.txt | 4 ++ receiver/inc/sync_alarm.h | 28 +++++++++++ receiver/src/ft.cpp | 22 ++++++++- receiver/src/main.cpp | 67 +++++++++++++++++++++----- receiver/src/sync_alarm.cpp | 107 +++++++++++++++++++++++++++++++++++++++++ receiver/tizen-manifest.xml | 5 ++ 7 files changed, 221 insertions(+), 14 deletions(-) create mode 100644 receiver/inc/sync_alarm.h create mode 100644 receiver/src/sync_alarm.cpp diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 97e6304..967fe41 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -28,6 +28,8 @@ BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-appfw-service-application) BuildRequires: pkgconfig(capi-message-port) +BuildRequires: pkgconfig(capi-appfw-alarm) +BuildRequires: pkgconfig(capi-system-device) BuildRequires: pkgconfig(sap-client-stub-api) BuildRequires: pkgconfig(vconf) BuildRequires: hash-signer diff --git a/receiver/CMakeLists.txt b/receiver/CMakeLists.txt index 9cd44fb..73d4503 100644 --- a/receiver/CMakeLists.txt +++ b/receiver/CMakeLists.txt @@ -6,6 +6,7 @@ SET(SRCS src/ft.cpp src/sticker_info.cpp src/message.cpp + src/sync_alarm.cpp ) INCLUDE(FindPkgConfig) @@ -14,6 +15,9 @@ pkg_check_modules(pkgs_test REQUIRED dlog capi-appfw-service-application capi-message-port + capi-appfw-app-common + capi-appfw-alarm + capi-system-device sap-client-stub-api json-glib-1.0 vconf diff --git a/receiver/inc/sync_alarm.h b/receiver/inc/sync_alarm.h new file mode 100644 index 0000000..e46515c --- /dev/null +++ b/receiver/inc/sync_alarm.h @@ -0,0 +1,28 @@ +/* + * 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. + */ +#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(); + +#endif /* __ALARM_H__ */ diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index fae0991..c8c7bdb 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -36,6 +36,7 @@ #include "log.h" #include "sticker_info.h" #include "message.h" +#include "sync_alarm.h" #define ACCESSORY_SERVICE_PROFILE_ID "/sample/filetransfersender" #define ACCESSORY_SERVICE_CHANNEL_ID 107 @@ -80,7 +81,7 @@ struct sticker_info { static struct sap_info_s priv_data = { 0 }; static struct sticker_info sticker_data; -static struct sync_request pending_sync_request; +static struct sync_request pending_sync_request, current_sync_request; enum { SYNC_START_RSP_SUCCESS = 1000, @@ -303,6 +304,11 @@ void request_sticker_data(const char *mode, const char *category, const char *ty LOGI("Push sync request"); } + else { + current_sync_request.mode = string(mode ? mode : "manual"); + current_sync_request.category = string(category? category : "arsticker"); + current_sync_request.type = string(type ? type : "input"); + } json_object_unref(j_object); } @@ -522,6 +528,15 @@ 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_sync_request.mode == string("oobe")) { + LOGD("alarm exist : %d", sync_alarm_exist()); + sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL); + } + else if (current_sync_request.mode == string("manual")) { + if (!sync_alarm_exist()) + sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL); + } } if (_send_json_data(j_object) == FALSE) @@ -530,6 +545,10 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in send_message("sync_stop_result", reason.c_str()); json_object_unref(j_object); + + current_sync_request.mode.clear(); + current_sync_request.category.clear(); + current_sync_request.type.clear(); } else LOGW("unknown msg id : %s", msg_id.c_str()); @@ -608,6 +627,7 @@ _on_service_connection_created(sap_peer_agent_h peer_agent, pending_sync_request.type.c_str()); request_sticker_data(pending_sync_request.mode.c_str(), pending_sync_request.category.c_str(), pending_sync_request.type.c_str()); + pending_sync_request.mode.clear(); pending_sync_request.category.clear(); pending_sync_request.type.clear(); diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 6f728fe..1a2ad84 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -1,10 +1,15 @@ #include #include #include +#include +#include #include "main.h" #include "ft.h" #include "log.h" +#include "sync_alarm.h" + +#define MINIMUM_BATTERY 15 static bool app_create(void *data) { @@ -25,35 +30,68 @@ static void app_control(app_control_h app_control, void *data) char* mode = NULL; char* category = NULL; char* type = NULL; + char* operation = NULL; + char* alarm_data = NULL; int res; + // operation + int ret = app_control_get_operation(app_control, &operation); + if (ret == APP_CONTROL_ERROR_NONE) { + LOGD("operation: %s", operation); + + if (operation && (strncmp(operation, APP_CONTROL_OPERATION_SYNC_ALARM, strlen(APP_CONTROL_OPERATION_SYNC_ALARM)) == 0)) { + ret = app_control_get_extra_data(app_control, APP_CONTROL_DATA_ALARM_ID, &alarm_data); + if (ret != APP_CONTROL_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "Function app_control_get_extra_data() failed."); + goto cleanup; + } + + LOGD("alarm data : %s", alarm_data); + + int battery_percentage = 0; + int ret = device_battery_get_percent(&battery_percentage); + if (ret == DEVICE_ERROR_NONE) { + LOGD("battery percent : %d", battery_percentage); + if (battery_percentage >= MINIMUM_BATTERY) { + request_sticker_data("auto", "arsticker", "input"); + request_sticker_data("auto", "bitmoji", "input"); + } + else { + LOGD("No sync request due to insufficient battery"); + } + } + else { + LOGW("Failed to get battery percent. error : %d", ret); + } + + goto cleanup; + } + } + else { + LOGW("Failed to get operation. error : %d", ret); + } + // sync request res = app_control_get_extra_data(app_control, "request", &request); - if (APP_CONTROL_ERROR_NONE == res && NULL != request) - { - if (strcmp(request, "sync") == 0) - { - if (app_control_get_extra_data(app_control, "mode", &mode) != APP_CONTROL_ERROR_NONE) - { + if (APP_CONTROL_ERROR_NONE == res && NULL != request) { + if (strcmp(request, "sync") == 0) { + LOGI("[sync request] mode : %s, category : %s, type : %s", mode, category, type); + if (app_control_get_extra_data(app_control, "mode", &mode) != APP_CONTROL_ERROR_NONE) { LOGE("No given mode"); goto cleanup; } - if (app_control_get_extra_data(app_control, "category", &category) != APP_CONTROL_ERROR_NONE) - { + if (app_control_get_extra_data(app_control, "category", &category) != APP_CONTROL_ERROR_NONE) { LOGE("No given category"); goto cleanup; } - if (app_control_get_extra_data(app_control, "type", &type) != APP_CONTROL_ERROR_NONE) - { + if (app_control_get_extra_data(app_control, "type", &type) != APP_CONTROL_ERROR_NONE) { LOGE("No given type"); goto cleanup; } - LOGI("[sync request] mode : %s, category : %s, type : %s", mode, category, type); - if (mode && category && type) request_sticker_data(mode, category, type); } @@ -61,9 +99,12 @@ static void app_control(app_control_h app_control, void *data) { LOGW("Unknown command : %s", request); } - } + cleanup: + if (NULL != operation) + free(operation); + if (NULL != request) free(request); diff --git a/receiver/src/sync_alarm.cpp b/receiver/src/sync_alarm.cpp new file mode 100644 index 0000000..d4879d8 --- /dev/null +++ b/receiver/src/sync_alarm.cpp @@ -0,0 +1,107 @@ +/* + * 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. + */ + +#include +#include +#include + +#include "log.h" + +static int recurring_alarm_id = -1; + +static bool +on_foreach_registered_alarm(int alarm_id, void *user_data) +{ + bool *result = (bool *)user_data; + + LOGD("alarm id : %d", alarm_id); + + *result = *result | 0x1; + + return false; +} + +bool sync_alarm_register(const char *operation, int delay, int period) +{ + int ret; + app_control_h app_control = NULL; + char *app_id = NULL; + bool result = false; + + ret = app_control_create(&app_control); + if (ret != APP_CONTROL_ERROR_NONE) + { + LOGE("Function app_control_create() failed."); + return false; + } + + ret = app_control_set_operation(app_control, operation); + if (ret != APP_CONTROL_ERROR_NONE) + { + LOGE("Function app_control_set_operation() failed."); + goto cleanup; + } + + if (app_get_id(&app_id) != APP_ERROR_NONE) { + goto cleanup; + } + + LOGD("app id : %s", app_id); + if (!app_id) { + goto cleanup; + } + + ret = app_control_set_app_id(app_control, app_id); + if (ret != APP_CONTROL_ERROR_NONE) + { + LOGE("Function app_control_set_app_id() failed."); + goto cleanup; + } + + alarm_cancel_all(); + + ret = alarm_schedule_after_delay(app_control, delay, period, &recurring_alarm_id); + if (ret != ALARM_ERROR_NONE) + LOGE("Function alarm_schedule_after_delay() failed."); + else + LOGD("Function alarm_schedule_after_delay() succeed. delay : %d, interval : %d", delay, period); + + result = true; + +cleanup: + if (app_id) + free(app_id); + + if (app_control) { + ret = app_control_destroy(app_control); + if (ret != APP_CONTROL_ERROR_NONE) + LOGE("Function app_control_destroy() failed."); + else + LOGD("Set recurring alarm with id: %i", recurring_alarm_id); + } + + return result; +} + +bool sync_alarm_exist() +{ + bool result = false; + int ret = alarm_foreach_registered_alarm(on_foreach_registered_alarm, &result); + if (ret != ALARM_ERROR_NONE) + LOGD("Listing error : %d", ret); + + return result; +} \ No newline at end of file diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 0d73867..b53fdc6 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -5,6 +5,8 @@ + + @@ -12,6 +14,9 @@ http://tizen.org/privilege/content.write http://tizen.org/privilege/mediastorage http://tizen.org/privilege/appdir.shareddata + http://tizen.org/privilege/alarm.set + http://tizen.org/privilege/alarm.get + http://tizen.org/privilege/appmanager.launch -- 2.7.4 From f971508dcec80337abb1e2d90ae1f1caae2045c6 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 10 Mar 2020 19:32:20 +0900 Subject: [PATCH 03/16] Fix wrong log to display mode, category, and type Change-Id: I3aa7aac680e1902726acebc7b1ee2644aa8fcec8 Signed-off-by: Jihoon Kim --- receiver/src/main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 1a2ad84..3ad20b5 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -76,22 +76,26 @@ static void app_control(app_control_h app_control, void *data) res = app_control_get_extra_data(app_control, "request", &request); if (APP_CONTROL_ERROR_NONE == res && NULL != request) { if (strcmp(request, "sync") == 0) { - LOGI("[sync request] mode : %s, category : %s, type : %s", mode, category, type); + bool param_error = false; if (app_control_get_extra_data(app_control, "mode", &mode) != APP_CONTROL_ERROR_NONE) { LOGE("No given mode"); - goto cleanup; + param_error = true; } if (app_control_get_extra_data(app_control, "category", &category) != APP_CONTROL_ERROR_NONE) { LOGE("No given category"); - goto cleanup; + param_error = true; } if (app_control_get_extra_data(app_control, "type", &type) != APP_CONTROL_ERROR_NONE) { LOGE("No given type"); - goto cleanup; + param_error = true; } + LOGI("[sync request] mode : %s, category : %s, type : %s", mode, category, type); + if (param_error) + goto cleanup; + if (mode && category && type) request_sticker_data(mode, category, type); } -- 2.7.4 From 85be69d04adab2258bc4caad5ee7c15d53699836 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 10 Mar 2020 17:07:18 +0900 Subject: [PATCH 04/16] Add oobe mode for initializing Change-Id: Ib8921c4517ddfd85611fa65731a9a724745b4721 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 6 +----- receiver/src/main.cpp | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index c8c7bdb..53427fb 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -529,11 +529,7 @@ 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_sync_request.mode == string("oobe")) { - LOGD("alarm exist : %d", sync_alarm_exist()); - sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL); - } - else if (current_sync_request.mode == string("manual")) { + if (current_sync_request.mode == string("manual")) { if (!sync_alarm_exist()) sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL); } diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 3ad20b5..394f38f 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -99,6 +99,11 @@ static void app_control(app_control_h app_control, void *data) if (mode && category && type) request_sticker_data(mode, category, type); } + else if (strcmp(request, "oobe") == 0) { + LOGI("[OOBE] register sync alarm"); + sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL); + service_app_exit(); + } else { LOGW("Unknown command : %s", request); -- 2.7.4 From 19b7e372fb1cc17a60ae84b7d43271fb5057df23 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 11 Mar 2020 15:14:34 +0900 Subject: [PATCH 05/16] Remove category in app_control Change-Id: I1f88218aff1e8534167a0aea335cd4bc1c6e01ac Signed-off-by: Jihoon Kim --- receiver/src/main.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 394f38f..115d278 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -28,7 +28,6 @@ static void app_control(app_control_h app_control, void *data) /* Handle the launch request. */ char* request = NULL; char* mode = NULL; - char* category = NULL; char* type = NULL; char* operation = NULL; char* alarm_data = NULL; @@ -82,22 +81,17 @@ static void app_control(app_control_h app_control, void *data) param_error = true; } - if (app_control_get_extra_data(app_control, "category", &category) != APP_CONTROL_ERROR_NONE) { - LOGE("No given category"); - param_error = true; - } - if (app_control_get_extra_data(app_control, "type", &type) != APP_CONTROL_ERROR_NONE) { LOGE("No given type"); param_error = true; } - LOGI("[sync request] mode : %s, category : %s, type : %s", mode, category, type); + LOGI("[sync request] mode : %s, type : %s", mode, type); if (param_error) goto cleanup; - if (mode && category && type) - request_sticker_data(mode, category, type); + if (mode && type) + request_sticker_data(mode, "arsticker", type); } else if (strcmp(request, "oobe") == 0) { LOGI("[OOBE] register sync alarm"); @@ -120,9 +114,6 @@ cleanup: if (NULL != mode) free(mode); - if (NULL != category) - free(category); - if (NULL != type) free(type); } -- 2.7.4 From cb91fa6fbccd6a5dd8c32c1c3b5f3c08c2d148a6 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 11 Mar 2020 18:23:46 +0900 Subject: [PATCH 06/16] Update package version to 0.1.20 Change-Id: Ic1cc1ff1362b67c0c589c43db03ee88c72f278dc 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 967fe41..c562a85 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.19 +Version: 0.1.20 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index b53fdc6..cbd4cfe 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 72a304a21fd2fcd1b91eb8ddb4df6440bd49281c Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 12 Mar 2020 14:21:50 +0900 Subject: [PATCH 07/16] Set sticker feature flag Change-Id: Ibf6b8dd884a450101f3300b3ff5414523aa549ec --- receiver/inc/ft.h | 1 + receiver/src/ft.cpp | 111 ++++++++++++++++++++++++++++++++++++++------------ receiver/src/main.cpp | 2 +- 3 files changed, 86 insertions(+), 28 deletions(-) diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index 271a98f..c6cbb63 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -31,5 +31,6 @@ void deinitialize_sap(void); void sap_file_transfer_get_receive_filepath(char **filepath); void request_sticker_data(const char *mode, const char *category, const char *type); +void request_sticker_feature(); #endif /* __FT_H__ */ diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 53427fb..4e26d73 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -41,6 +41,8 @@ #define ACCESSORY_SERVICE_PROFILE_ID "/sample/filetransfersender" #define ACCESSORY_SERVICE_CHANNEL_ID 107 +#define STICKER_SYNC_FEATURE_REQ "sticker-sync-feature-req" +#define STICKER_SYNC_FEATURE_RSP "sticker-sync-feature-rsp" #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" @@ -51,6 +53,17 @@ 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, + SYNC_START_RSP_EXIST_STICKER = 1002 +}; + struct sap_info_s { sap_agent_h agent; sap_socket_h socket; @@ -58,7 +71,8 @@ struct sap_info_s { sap_file_transaction_h file_socket; }; -struct sync_request { +struct request { + request_type req_type; string mode; string category; string type; @@ -81,13 +95,7 @@ struct sticker_info { static struct sap_info_s priv_data = { 0 }; static struct sticker_info sticker_data; -static struct sync_request pending_sync_request, current_sync_request; - -enum { - SYNC_START_RSP_SUCCESS = 1000, - SYNC_START_RSP_NO_STICKER = 1001, - SYNC_START_RSP_EXIST_STICKER = 1002 -}; +static struct request pending_request, current_request; gboolean file_on_progress = 0; static string incoming_file_name; @@ -298,16 +306,37 @@ 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_sync_request.mode = string(mode ? mode : "manual"); - pending_sync_request.category = string(category? category : "arsticker"); - pending_sync_request.type = string(type ? type : "input"); + 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"); } else { - current_sync_request.mode = string(mode ? mode : "manual"); - current_sync_request.category = string(category? category : "arsticker"); - current_sync_request.type = string(type ? type : "input"); + 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"); + } + + json_object_unref(j_object); +} + +void request_sticker_feature() +{ + JsonObject *j_object = json_object_new(); + if (j_object == NULL) { + LOGE("json object create error"); + return; + } + + json_object_set_string_member(j_object, "msgId", STICKER_SYNC_FEATURE_REQ); + 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"); } json_object_unref(j_object); @@ -412,7 +441,27 @@ 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_START_RSP) { + if (msg_id == STICKER_SYNC_FEATURE_RSP) { + LOGD("msg : %s", msg_id.c_str()); + const char *json_aremoji = json_object_get_string_member(root_obj, "arEmoji"); + const char *json_bitmoji = json_object_get_string_member(root_obj, "bitmoji"); + string support_aremoji = string(json_aremoji ? json_aremoji : ""); + string support_bitmoji = string(json_bitmoji ? json_bitmoji : ""); + int supported_feature = VCONFKEY_STICKER_FEATURE_NONE; + + if (support_aremoji == "support") + supported_feature |= VCONFKEY_STICKER_FEATURE_AREMOJI; + + if (support_bitmoji == "support") + supported_feature |= VCONFKEY_STICKER_FEATURE_BITMOJI; + + if (vconf_set_int(VCONFKEY_STICKER_SUPPORTED_FEATURE, supported_feature) == 0) + LOGD("Succeed to set supported feature"); + else + LOGW("Fail to set supported feature"); + + 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"); string result = string(json_result ? json_result : ""); @@ -529,7 +578,7 @@ 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_sync_request.mode == string("manual")) { + if (current_request.mode == string("manual")) { if (!sync_alarm_exist()) sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL); } @@ -542,9 +591,9 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in json_object_unref(j_object); - current_sync_request.mode.clear(); - current_sync_request.category.clear(); - current_sync_request.type.clear(); + current_request.mode.clear(); + current_request.category.clear(); + current_request.type.clear(); } else LOGW("unknown msg id : %s", msg_id.c_str()); @@ -617,16 +666,24 @@ _on_service_connection_created(sap_peer_agent_h peer_agent, priv->socket = socket; LOGI("Connection Established"); - if (!pending_sync_request.mode.empty()) { - LOGD("[Request to sync sticker] mode: %s, category: %s, type : %s", pending_sync_request.mode.c_str(), - pending_sync_request.category.c_str(), - pending_sync_request.type.c_str()); + 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_sync_request.mode.c_str(), pending_sync_request.category.c_str(), pending_sync_request.type.c_str()); + request_sticker_data(pending_request.mode.c_str(), pending_request.category.c_str(), pending_request.type.c_str()); - pending_sync_request.mode.clear(); - pending_sync_request.category.clear(); - pending_sync_request.type.clear(); + pending_request.mode.clear(); + pending_request.category.clear(); + pending_request.type.clear(); + } } break; diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 115d278..3799557 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -96,7 +96,7 @@ static void app_control(app_control_h app_control, void *data) else if (strcmp(request, "oobe") == 0) { LOGI("[OOBE] register sync alarm"); sync_alarm_register(APP_CONTROL_OPERATION_SYNC_ALARM, SYNC_ALARM_DELAY, SYNC_ALARM_INTERVAL); - service_app_exit(); + request_sticker_feature(); } else { -- 2.7.4 From 0e7c92077e14d8fff12384077db979b33611927f Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 12 Mar 2020 21:25:57 +0900 Subject: [PATCH 08/16] Update package version to 0.1.21 Change-Id: I27e93064365f1c900e470cae8005c07461566733 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 c562a85..cedf01b 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.20 +Version: 0.1.21 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index cbd4cfe..db360d0 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From b7bb55fa84f79bf5696df1f48169d201fcc404b3 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 11 Mar 2020 19:43:43 +0900 Subject: [PATCH 09/16] Remove temporary code to handle wrong member name in json Change-Id: I6cfaefb93eaa51ff0fd0f784f124295ceeda4b42 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 4e26d73..7e8926b 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -495,9 +495,6 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in JsonObject *file_obj = json_array_get_object_element(file_list, i); int file_len = json_object_get_int_member(file_obj, "size"); const char *json_filename = json_object_get_string_member(file_obj, "fileName"); - if (!json_filename) { - json_filename = json_object_get_string_member(file_obj, "filename"); - } string file_name = string(json_filename ? json_filename : ""); if (file_len > 0) { -- 2.7.4 From cea833b0fd6219441950055b3782a29b4f30de4d Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 13 Mar 2020 16:44:04 +0900 Subject: [PATCH 10/16] Remove unused code Change-Id: I3498174ececa2b2f0f14accbd63298d02f549e4f Signed-off-by: Jihoon Kim --- receiver/inc/ft.h | 1 - receiver/src/ft.cpp | 5 ----- 2 files changed, 6 deletions(-) diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index c6cbb63..a95204c 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -29,7 +29,6 @@ void accept_file(void); gboolean initialize_sap(void); void deinitialize_sap(void); -void sap_file_transfer_get_receive_filepath(char **filepath); void request_sticker_data(const char *mode, const char *category, const char *type); void request_sticker_feature(); diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 7e8926b..02ee53f 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -286,11 +286,6 @@ void accept_file() file_on_progress = 1; } -void sap_file_transfer_get_receive_filepath(char **filepath) -{ - *filepath = strdup(sticker_data.file_path.c_str()); -} - void request_sticker_data(const char *mode, const char *category, const char *type) { JsonObject *j_object = json_object_new(); -- 2.7.4 From 853ebb4e2fdf7641a07540403b28ec9d31640e42 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 17 Mar 2020 17:48:02 +0900 Subject: [PATCH 11/16] Add boilerplate Change-Id: I9ef5ed62a4461b34cb38c5bc302a24d2d0bb58cf Signed-off-by: Jihoon Kim --- receiver/inc/log.h | 15 +++++++++++++++ receiver/inc/main.h | 15 +++++++++++++++ receiver/inc/sticker_info.h | 15 +++++++++++++++ receiver/src/main.cpp | 15 +++++++++++++++ receiver/src/sticker_info.cpp | 15 +++++++++++++++ 5 files changed, 75 insertions(+) diff --git a/receiver/inc/log.h b/receiver/inc/log.h index 3749cad..07ee738 100644 --- a/receiver/inc/log.h +++ b/receiver/inc/log.h @@ -1,3 +1,18 @@ +/* + * 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 __debug_H__ #define __debug_H__ diff --git a/receiver/inc/main.h b/receiver/inc/main.h index b6fac02..e32a820 100644 --- a/receiver/inc/main.h +++ b/receiver/inc/main.h @@ -1,3 +1,18 @@ +/* + * 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. + */ #include #include #include diff --git a/receiver/inc/sticker_info.h b/receiver/inc/sticker_info.h index bda6616..86b6c88 100644 --- a/receiver/inc/sticker_info.h +++ b/receiver/inc/sticker_info.h @@ -1,3 +1,18 @@ +/* + * 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_INFO_H__ #define __STICKER_INFO_H__ diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 3799557..9968b91 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -1,3 +1,18 @@ +/* + * 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. + */ #include #include #include diff --git a/receiver/src/sticker_info.cpp b/receiver/src/sticker_info.cpp index 1ac2247..89aedfb 100644 --- a/receiver/src/sticker_info.cpp +++ b/receiver/src/sticker_info.cpp @@ -1,3 +1,18 @@ +/* + * 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. + */ #include "sticker_info.h" #include #include -- 2.7.4 From 1811c4ec1666ad81d786195238416a2cfb742566 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 17 Mar 2020 19:03:04 +0900 Subject: [PATCH 12/16] Terminate sticker-receiver after sending result Change-Id: I27f5f04e2cc964cfcc29925800f6d47070f051a5 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 02ee53f..f471b55 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -60,8 +60,7 @@ typedef enum { enum { SYNC_START_RSP_SUCCESS = 1000, - SYNC_START_RSP_NO_STICKER = 1001, - SYNC_START_RSP_EXIST_STICKER = 1002 + SYNC_START_RSP_NO_STICKER = 1001 }; struct sap_info_s { @@ -466,7 +465,6 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in string response_to_app; switch (result_code) { case SYNC_START_RSP_SUCCESS: - case SYNC_START_RSP_EXIST_STICKER: response_to_app = "success"; break; case SYNC_START_RSP_NO_STICKER: @@ -478,6 +476,9 @@ 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(); } else if (msg_id == STICKER_SEND_START_REQ) { LOGD("msg : %s", msg_id.c_str()); total_file_count = 0; @@ -586,6 +587,8 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in 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()); -- 2.7.4 From a5b9e3c2154ac5673199a866cd0a3b5db48569f8 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 17 Mar 2020 19:10:17 +0900 Subject: [PATCH 13/16] Fix json parsing error due to trailing trash character Change-Id: I3bce228b55b0ef16828783f15e3bc1c89af78dfa Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index f471b55..3f56506 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -406,7 +406,8 @@ void on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned int payload_length, void *buffer, void *user_data) /* message exchange on_receive callback (sap_agent_data_received_cb) */ { - LOGI("received data: %s, len:%d", (char *)buffer, payload_length); + unsigned int buf_len = strlen((char *)buffer); + LOGI("received data: %s, len: %d, buffer len : %d", (char *)buffer, payload_length, buf_len); JsonParser *parser = json_parser_new(); GError *err_msg = NULL; @@ -415,7 +416,7 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in string msg_id; const char *json_msgid = NULL; - json_parser_load_from_data(parser, (char *)buffer, -1, &err_msg); + json_parser_load_from_data(parser, (char *)buffer, payload_length, &err_msg); if (err_msg) { LOGE("failed to load json file. error message: %s", err_msg->message); goto cleanup; -- 2.7.4 From dfd48fd5ee154781ce88b2c1e3f575a40ff8b89b Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 17 Mar 2020 20:04:03 +0900 Subject: [PATCH 14/16] Add vconf define temporarily Change-Id: I2d63113a8523ca0dbebb3d93e001568023a6078d Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 3f56506..9d42623 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -51,6 +51,16 @@ #define STICKER_SEND_STOP_REQ "sticker-send-stop-req" #define STICKER_SEND_STOP_RSP "sticker-send-stop-rsp" +#ifndef VCONFKEY_STICKER_SUPPORTED_FEATURE +#define VCONFKEY_STICKER_SUPPORTED_FEATURE "db/sticker/supported_feature" + +enum { + VCONFKEY_STICKER_FEATURE_NONE = 0x00, + VCONFKEY_STICKER_FEATURE_AREMOJI = 0x01, + VCONFKEY_STICKER_FEATURE_BITMOJI = 0x02 +}; +#endif + using namespace std; typedef enum { -- 2.7.4 From 918c619c21da07219f8be47554ca118a9d47f62e Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Tue, 17 Mar 2020 19:52:18 +0900 Subject: [PATCH 15/16] Update package version to 0.1.22 Change-Id: Iafe24998ee5ac3fff6a12734e8b7ac44e5b7a1e9 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 cedf01b..d36c513 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.21 +Version: 0.1.22 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index db360d0..6726d6d 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 1103a02281292296c671363d44fc13fffd9003c8 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 18 Mar 2020 09:43:06 +0900 Subject: [PATCH 16/16] Revert "Add vconf define temporarily" This reverts commit dfd48fd5ee154781ce88b2c1e3f575a40ff8b89b. Change-Id: Ifd945d7e422ea73ffeaed176d44c5177d3aa962b --- receiver/src/ft.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 9d42623..3f56506 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -51,16 +51,6 @@ #define STICKER_SEND_STOP_REQ "sticker-send-stop-req" #define STICKER_SEND_STOP_RSP "sticker-send-stop-rsp" -#ifndef VCONFKEY_STICKER_SUPPORTED_FEATURE -#define VCONFKEY_STICKER_SUPPORTED_FEATURE "db/sticker/supported_feature" - -enum { - VCONFKEY_STICKER_FEATURE_NONE = 0x00, - VCONFKEY_STICKER_FEATURE_AREMOJI = 0x01, - VCONFKEY_STICKER_FEATURE_BITMOJI = 0x02 -}; -#endif - using namespace std; typedef enum { -- 2.7.4