From 00ae77878b4c6ba82e687e8f2406af6e86f0d7c0 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 13 Feb 2020 10:53:14 +0900 Subject: [PATCH 01/16] Change accessory service profile ID Change-Id: I0b16d85be9c28b9970fd9a4a9ed2bfad874cec4d Signed-off-by: Jihoon Kim --- receiver/res/xml/accessoryservices.xml | 6 +++--- receiver/src/ft.cpp | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/receiver/res/xml/accessoryservices.xml b/receiver/res/xml/accessoryservices.xml index fee8e4c..9f501e5 100644 --- a/receiver/res/xml/accessoryservices.xml +++ b/receiver/res/xml/accessoryservices.xml @@ -3,10 +3,10 @@ + role="consumer" + version="1.0"> diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 1cc0c38..c9af50d 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -28,6 +28,8 @@ #include #include +#define ACCESSORY_SERVICE_PROFILE_ID "/sample/filetransfersender" + #include "sticker_info.h" using namespace std; @@ -325,7 +327,7 @@ gboolean agent_initialize() int result = 0; do { - result = sap_agent_initialize(priv_data.agent, "/sample/filetransfer", SAP_AGENT_ROLE_PROVIDER, + result = sap_agent_initialize(priv_data.agent, ACCESSORY_SERVICE_PROFILE_ID, SAP_AGENT_ROLE_CONSUMER, on_agent_initialized, NULL); dlog_print(DLOG_DEBUG, TAG, "SAP >>> getRegisteredServiceAgent() >>> %d", result); -- 2.7.4 From 68765f49c9221045f17f1154301dbec47bb6e871 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 13 Feb 2020 11:01:08 +0900 Subject: [PATCH 02/16] Update package version to 0.1.11 Change-Id: I1502e32bc3e98810cb315f99980ee546577dc81f Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 4565037..ed33df1 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.10 +Version: 0.1.11 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 -- 2.7.4 From 1db6fb682e7bd06b6ec10d60ed783aa618f4235a Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 20 Feb 2020 11:03:35 +0900 Subject: [PATCH 03/16] Fixed the crash issue when the file is received Change-Id: I1bd033d3cda4b16e537842929b6eccd035678b9d --- receiver/src/ft.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index c9af50d..b073de7 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -143,7 +144,7 @@ static void __set_file_transfer_cb(sap_file_transaction_h file_socket) void accept_file() { int ret; - char file_path[100]; + char file_path[PATH_MAX]; char *data_path = NULL; data_path = app_get_shared_data_path(); -- 2.7.4 From 2ba70694d120c01468e22eb2fdf70aa946a78ecf Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 20 Feb 2020 13:59:18 +0900 Subject: [PATCH 04/16] Remove sticker file after inserting DB Change-Id: I9dccbca14e1a90ee4d188456c65945e8c90f766e --- receiver/inc/sticker_info.h | 2 +- receiver/src/ft.cpp | 10 +++++++--- receiver/src/sticker_info.cpp | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/receiver/inc/sticker_info.h b/receiver/inc/sticker_info.h index e65c244..27f2206 100644 --- a/receiver/inc/sticker_info.h +++ b/receiver/inc/sticker_info.h @@ -4,7 +4,7 @@ #define TAG "STICKER_RECEIVER" void insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc); -void create_sticker_provider_handle(void); +int create_sticker_provider_handle(void); void destroy_sticker_provider_handle(void); #endif /* __STICKER_INF_H__ */ diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index b073de7..c5ccfbf 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -69,9 +69,13 @@ static void _on_send_completed(sap_file_transaction_h file_transaction, } else { dlog_print(DLOG_INFO, TAG, "Succeed to change permission : %s", recv_filepath.c_str()); - create_sticker_provider_handle(); - insert_sticker_data(recv_filepath.c_str(), "keyword", "group", "test icon"); - destroy_sticker_provider_handle(); + if (create_sticker_provider_handle() == STICKER_ERROR_NONE) { + insert_sticker_data(recv_filepath.c_str(), "keyword", "group", "test icon"); + destroy_sticker_provider_handle(); + + if (unlink(recv_filepath.c_str()) == -1) + dlog_print(DLOG_ERROR, TAG, "Failed to remove sticker file"); + } } } else { switch (result) { diff --git a/receiver/src/sticker_info.cpp b/receiver/src/sticker_info.cpp index 280b357..0282163 100644 --- a/receiver/src/sticker_info.cpp +++ b/receiver/src/sticker_info.cpp @@ -89,7 +89,7 @@ insert_sticker_data(const char *filepath, const char *keyword, const char *group } } -void create_sticker_provider_handle(void) +int create_sticker_provider_handle(void) { int ret; ret = sticker_provider_create(&sticker_provider); @@ -97,6 +97,8 @@ void create_sticker_provider_handle(void) /* Error handling */ dlog_print(DLOG_ERROR, TAG, "Failed to create sticker provider"); } + + return ret; } void destroy_sticker_provider_handle(void) -- 2.7.4 From 439452ff5e88014255b816fe7338c8faffd5dc93 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 20 Feb 2020 14:07:51 +0900 Subject: [PATCH 05/16] Add org.tizen.sticker-receiver as dependency Change-Id: I1e6f86460f9f26b2e275a03fe2819fff7abf81ac Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index ed33df1..2e744c0 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -31,6 +31,7 @@ BuildRequires: pkgconfig(sap-client-stub-api) BuildRequires: hash-signer Requires(post): signing-client +Requires: org.tizen.sticker-receiver %endif Requires: security-config -- 2.7.4 From 7901b7e447bf2f404750ed731dbf9053d2e45748 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 20 Feb 2020 14:01:39 +0900 Subject: [PATCH 06/16] Update package version to 0.1.12 Change-Id: I1c3894a7952856a8f09e5a33a9804b1795ae6778 --- packaging/capi-ui-sticker.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 2e744c0..b14c2c2 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.11 +Version: 0.1.12 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 -- 2.7.4 From 1882bd6caaadf9728f81b9e03d2cc603cfe938df Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 20 Feb 2020 15:54:11 +0900 Subject: [PATCH 07/16] Fix issue failed to install due to no base directory Change-Id: I73177635916e4f980f357d8b33cfccf65119006c Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index b14c2c2..5cae043 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -167,8 +167,12 @@ chsmack -a "System::Shared" %{TZ_SYS_SHARE}/sticker-data %{_includedir}/sticker_provider.h %if 0%{?sec_product_feature_profile_wearable} +%post -n %{_companion_app_name} +mkdir -p %{TZ_SYS_RO_APP}/%{_companion_app_name} + %files -n %{_companion_app_name} %manifest receiver/%{_companion_app_name}.manifest +%license LICENSE %{TZ_SYS_RO_PACKAGES}/%{_companion_app_name}.xml %{TZ_SYS_RO_APP}/%{_companion_app_name}/* %endif -- 2.7.4 From 23422a723afe9fb8df3c92b88428351cd6aaa3e4 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 20 Feb 2020 15:59:38 +0900 Subject: [PATCH 08/16] Update package version to 0.1.13 Change-Id: I1c3c03ef79ad85459d970fd17a58114799c45db1 Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 5cae043..75149e5 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.12 +Version: 0.1.13 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 -- 2.7.4 From 532005322b3bfd3ed780b97e39f2605a9cc42b5b Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 20 Feb 2020 19:47:57 +0900 Subject: [PATCH 09/16] Fix signing issue on wearable device Change-Id: If67e682df5da525ed44a883855706829c72f283d Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 75149e5..87df788 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -137,10 +137,6 @@ chown -R ui_fw:ui_fw %{TZ_SYS_SHARE}/sticker-data chsmack -t %{TZ_SYS_SHARE}/sticker-data chsmack -a "System::Shared" %{TZ_SYS_SHARE}/sticker-data -%if 0%{?sec_product_feature_profile_wearable} -/usr/bin/signing-client/hash-signer-client.sh -a -d -p platform %{TZ_SYS_RO_APP}/%{_companion_app_name} -%endif - %postun -p /sbin/ldconfig %files @@ -168,7 +164,7 @@ chsmack -a "System::Shared" %{TZ_SYS_SHARE}/sticker-data %if 0%{?sec_product_feature_profile_wearable} %post -n %{_companion_app_name} -mkdir -p %{TZ_SYS_RO_APP}/%{_companion_app_name} +/usr/bin/signing-client/hash-signer-client.sh -a -d -p platform %{TZ_SYS_RO_APP}/%{_companion_app_name} %files -n %{_companion_app_name} %manifest receiver/%{_companion_app_name}.manifest -- 2.7.4 From b45853c2b013cfc651a9b024a325b01423edde4d Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Thu, 20 Feb 2020 19:48:20 +0900 Subject: [PATCH 10/16] Update package version to 0.1.14 Change-Id: I0189865c1d58bcb461a0db2101b3cc96c2308db6 Signed-off-by: Jihoon Kim --- packaging/capi-ui-sticker.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 87df788..7e4cb25 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.13 +Version: 0.1.14 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 -- 2.7.4 From 119054284ae25a733a8d54fcac54800a146767ff Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 21 Feb 2020 20:04:14 +0900 Subject: [PATCH 11/16] Remove unused function Change-Id: I288a400ea7ef143a3337b12ee9596f7065682b2b Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index c5ccfbf..133f673 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -215,16 +215,6 @@ void conn_terminated(sap_peer_agent_h peer_agent, } void -on_message_received(sap_peer_agent_h peer_agent, unsigned int payload_length, void *buffer, - void *user_data) /* message exchange on_receive callback (sap_agent_data_received_cb) */ -{ - char *peer_app; - sap_peer_agent_get_app_name(peer_agent, &peer_app); - dlog_print(DLOG_INFO, TAG, "received data: %s, len:%d from %s", (char *)buffer, payload_length, peer_app); - g_free(peer_app); -} - -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) */ { -- 2.7.4 From 29f80e1fc8fd0b8d58645047709a5a488e7c7995 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 24 Feb 2020 17:12:56 +0900 Subject: [PATCH 12/16] Change log format in sticker-receiver Change-Id: Id5730c2353be61cfc35804e6e519269224e594b2 Signed-off-by: Jihoon Kim --- receiver/inc/log.h | 6 ++- receiver/inc/main.h | 2 - receiver/inc/sticker_info.h | 2 - receiver/src/ft.cpp | 87 ++++++++++++++++++++++--------------------- receiver/src/main.cpp | 3 +- receiver/src/sticker_info.cpp | 23 ++++++------ 6 files changed, 62 insertions(+), 61 deletions(-) diff --git a/receiver/inc/log.h b/receiver/inc/log.h index df3f0b2..3749cad 100644 --- a/receiver/inc/log.h +++ b/receiver/inc/log.h @@ -3,6 +3,9 @@ #include +#undef LOG_TAG +#define LOG_TAG "STICKER_RECEIVER" + #ifndef _LOG #define _LOG(logLevel, fmt, ...) do { \ dlog_print(logLevel, LOG_TAG, "%s : %s(%d) > " fmt, rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ @@ -29,5 +32,4 @@ #define LOGF(format, arg...) _LOG(DLOG_FATAL, format, ##arg) #endif -#endif /* __debug_H__ */ - +#endif /* __debug_H__ */ \ No newline at end of file diff --git a/receiver/inc/main.h b/receiver/inc/main.h index 473ac68..b6fac02 100644 --- a/receiver/inc/main.h +++ b/receiver/inc/main.h @@ -5,8 +5,6 @@ #ifndef __MAIN_H__ #define __MAIN_H__ -#define TAG "STICKER_RECEIVER" - #if !defined(PACKAGE) #define PACKAGE "org.tizen.sticker-receiver" #endif diff --git a/receiver/inc/sticker_info.h b/receiver/inc/sticker_info.h index 27f2206..7cf88fe 100644 --- a/receiver/inc/sticker_info.h +++ b/receiver/inc/sticker_info.h @@ -1,8 +1,6 @@ #ifndef __STICKER_INFO_H__ #define __STICKER_INFO_H__ -#define TAG "STICKER_RECEIVER" - void insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc); int create_sticker_provider_handle(void); void destroy_sticker_provider_handle(void); diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 133f673..a67c6d6 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -29,10 +29,11 @@ #include #include -#define ACCESSORY_SERVICE_PROFILE_ID "/sample/filetransfersender" - +#include "log.h" #include "sticker_info.h" +#define ACCESSORY_SERVICE_PROFILE_ID "/sample/filetransfersender" + using namespace std; struct priv { @@ -53,7 +54,7 @@ static void _on_send_completed(sap_file_transaction_h file_transaction, { char error_message[100]; - dlog_print(DLOG_INFO, TAG, "# transfer completed"); + LOGI("# transfer completed"); if (priv_data.socket) { sap_file_transfer_destroy(file_transaction); @@ -62,68 +63,68 @@ static void _on_send_completed(sap_file_transaction_h file_transaction, if (result == SAP_FT_TRANSFER_SUCCESS) { sprintf(error_message, "Transfer Completed"); - dlog_print(DLOG_INFO, TAG, "Transfer Completed"); + LOGI("Transfer Completed"); if (chmod(recv_filepath.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) == -1) { - dlog_print(DLOG_ERROR, TAG, "Failed to change permission : %s. error : %s", recv_filepath.c_str(), strerror(errno)); + LOGE("Failed to change permission : %s. error : %s", recv_filepath.c_str(), strerror(errno)); } else { - dlog_print(DLOG_INFO, TAG, "Succeed to change permission : %s", recv_filepath.c_str()); + LOGI("Succeed to change permission : %s", recv_filepath.c_str()); if (create_sticker_provider_handle() == STICKER_ERROR_NONE) { insert_sticker_data(recv_filepath.c_str(), "keyword", "group", "test icon"); destroy_sticker_provider_handle(); if (unlink(recv_filepath.c_str()) == -1) - dlog_print(DLOG_ERROR, TAG, "Failed to remove sticker file"); + LOGE("Failed to remove sticker file"); } } } else { switch (result) { case (SAP_FT_TRANSFER_FAIL_CHANNEL_IO): { sprintf(error_message, "Channel IO Error."); - dlog_print(DLOG_WARN, TAG, "Channel IO Error."); + LOGW("Channel IO Error."); break; } case (SAP_FT_TRANSFER_FAIL_FILE_IO): { sprintf(error_message, "File IO Error."); - dlog_print(DLOG_WARN, TAG, "File IO Error."); + LOGW("File IO Error."); break; } case (SAP_FT_TRANSFER_FAIL_CMD_DROPPED): { sprintf(error_message, "Transfer dropped."); - dlog_print(DLOG_WARN, TAG, "Transfer dropped."); + LOGW("Transfer dropped."); break; } case (SAP_FT_TRANSFER_FAIL_PEER_UNRESPONSIVE): { sprintf(error_message, "Peer Un Responsive."); - dlog_print(DLOG_WARN, TAG, "Peer Un Responsive."); + LOGW("Peer Un Responsive."); break; } case (SAP_FT_TRANSFER_FAIL_PEER_CONN_LOST): { sprintf(error_message, "Connection Lost."); - dlog_print(DLOG_WARN, TAG, "Connection Lost."); + LOGW("Connection Lost."); break; } case (SAP_FT_TRANSFER_FAIL_PEER_CANCELLED): { sprintf(error_message, "Peer Cancelled."); - dlog_print(DLOG_WARN, TAG, "Peer Cancelled."); + LOGW("Peer Cancelled."); break; } case (SAP_FT_TRANSFER_FAIL_SPACE_NOT_AVAILABLE): { sprintf(error_message, "No Space."); - dlog_print(DLOG_WARN, TAG, "No Space."); + LOGW("No Space."); break; } default: sprintf(error_message, "Unknown Error"); - dlog_print(DLOG_WARN, TAG, "Unknown Error"); + LOGW("Unknown Error"); } } @@ -134,12 +135,12 @@ static void _on_sending_file_in_progress(sap_file_transaction_h file_transaction unsigned short int percentage_progress, void *user_data) { - dlog_print(DLOG_INFO, TAG, "# progress %d", percentage_progress); + LOGI("# progress %d", percentage_progress); } static void __set_file_transfer_cb(sap_file_transaction_h file_socket) { - dlog_print(DLOG_INFO, TAG, "# set callbacks"); + LOGI("# set callbacks"); sap_file_transfer_set_progress_cb(file_socket, _on_sending_file_in_progress, NULL); sap_file_transfer_set_done_cb(file_socket, _on_send_completed, NULL); @@ -152,22 +153,22 @@ void accept_file() char *data_path = NULL; data_path = app_get_shared_data_path(); - dlog_print(DLOG_INFO, TAG, "Path : %s", data_path); + LOGI("Path : %s", data_path); sprintf(file_path, "%s/%s", data_path, incoming_file_name.c_str()); - dlog_print(DLOG_INFO, TAG, "Receive filepath : %s", file_path); + LOGI("Receive filepath : %s", file_path); recv_filepath = string(file_path); free(data_path); ret = sap_file_transfer_receive(priv_data.socket, file_path); switch(ret) { case SAP_RESULT_PERMISSION_DENIED: - dlog_print(DLOG_WARN, TAG, "permission denied"); + LOGW("permission denied"); break; case SAP_RESULT_FAILURE: - dlog_print(DLOG_WARN, TAG, "Fail"); + LOGW("Fail"); break; case SAP_RESULT_SUCCESS: - dlog_print(DLOG_INFO, TAG, "Success"); + LOGI("Success"); break; } @@ -182,7 +183,7 @@ void sap_file_transfer_get_receive_filepath(char **filepath) void reject_file() { int ret = sap_file_transfer_reject(priv_data.socket); - dlog_print(DLOG_INFO, TAG, "ret : %d", ret); + LOGI("ret : %d", ret); file_on_progress = 0; } @@ -194,14 +195,14 @@ static void _on_receive_file_cb(sap_peer_agent_h peer_agent_h, { file_on_progress = 1; priv_data.socket = socket; - dlog_print(DLOG_INFO, TAG, "# incoming file request."); + LOGI("# incoming file request."); __set_file_transfer_cb(priv_data.socket); incoming_file_name = file_path; std::size_t found = incoming_file_name.find_last_of("/"); incoming_file_name = incoming_file_name.substr(found+1); - dlog_print(DLOG_INFO, TAG, "# file path : %s, incoming file name : %s", file_path, incoming_file_name.c_str()); + LOGI("# file path : %s, incoming file name : %s", file_path, incoming_file_name.c_str()); accept_file(); } @@ -211,14 +212,14 @@ void conn_terminated(sap_peer_agent_h peer_agent, sap_service_connection_terminated_reason_e result, void *user_data) { - dlog_print(DLOG_INFO, TAG, "connection terminated"); + LOGI("connection terminated"); } 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) */ { - dlog_print(DLOG_INFO, TAG, "received data: %s, len:%d", (char *)buffer, payload_length); + LOGI("received data: %s, len:%d", (char *)buffer, payload_length); } static void on_conn_req(sap_peer_agent_h peer_agent, @@ -239,7 +240,7 @@ static void on_agent_initialized(sap_agent_h agent, switch (result) { case SAP_AGENT_INITIALIZED_RESULT_SUCCESS: - dlog_print(DLOG_DEBUG, TAG, "agent is initialized"); + LOGD("agent is initialized"); priv_data.agent = agent; @@ -249,22 +250,22 @@ static void on_agent_initialized(sap_agent_h agent, break; case SAP_AGENT_INITIALIZED_RESULT_DUPLICATED: - dlog_print(DLOG_ERROR, TAG, "duplicate registration"); + LOGE("duplicate registration"); break; case SAP_AGENT_INITIALIZED_RESULT_INVALID_ARGUMENTS: - dlog_print(DLOG_ERROR, TAG, "invalid arguments"); + LOGE("invalid arguments"); break; case SAP_AGENT_INITIALIZED_RESULT_INTERNAL_ERROR: - dlog_print(DLOG_ERROR, TAG, "internal sap error"); + LOGE("internal sap error"); break; default: - dlog_print(DLOG_ERROR, TAG, "unknown status (%d)", result); + LOGE("unknown status (%d)", result); break; } @@ -274,45 +275,45 @@ static void _on_device_status_changed(sap_device_status_e status, sap_transport_type_e transport_type, void *user_data) { - dlog_print(DLOG_DEBUG, TAG, "%s, status :%d", __func__, status); + LOGD("%s, status :%d", __func__, status); switch (transport_type) { case SAP_TRANSPORT_TYPE_BT: - dlog_print(DLOG_DEBUG, TAG, "transport_type (%d): bt", transport_type); + LOGD("transport_type (%d): bt", transport_type); break; case SAP_TRANSPORT_TYPE_BLE: - dlog_print(DLOG_DEBUG, TAG, "transport_type (%d): ble", transport_type); + LOGD("transport_type (%d): ble", transport_type); break; case SAP_TRANSPORT_TYPE_TCP: - dlog_print(DLOG_DEBUG, TAG, "transport_type (%d): tcp/ip", transport_type); + LOGD("transport_type (%d): tcp/ip", transport_type); break; case SAP_TRANSPORT_TYPE_USB: - dlog_print(DLOG_DEBUG, TAG, "transport_type (%d): usb", transport_type); + LOGD("transport_type (%d): usb", transport_type); break; case SAP_TRANSPORT_TYPE_MOBILE: - dlog_print(DLOG_DEBUG, TAG, "transport_type (%d): mobile", transport_type); + LOGD("transport_type (%d): mobile", transport_type); break; default: - dlog_print(DLOG_ERROR, TAG, "unknown transport_type (%d)", transport_type); + LOGE("unknown transport_type (%d)", transport_type); break; } switch (status) { case SAP_DEVICE_STATUS_DETACHED: - dlog_print(DLOG_DEBUG, TAG, "device is not connected."); + LOGD("device is not connected."); break; case SAP_DEVICE_STATUS_ATTACHED: - dlog_print(DLOG_DEBUG, TAG, "Attached calling find peer now"); + LOGD("Attached calling find peer now"); break; default: - dlog_print(DLOG_ERROR, TAG, "unknown status (%d)", status); + LOGE("unknown status (%d)", status); break; } } @@ -325,7 +326,7 @@ gboolean agent_initialize() result = sap_agent_initialize(priv_data.agent, ACCESSORY_SERVICE_PROFILE_ID, SAP_AGENT_ROLE_CONSUMER, on_agent_initialized, NULL); - dlog_print(DLOG_DEBUG, TAG, "SAP >>> getRegisteredServiceAgent() >>> %d", result); + LOGD("SAP >>> getRegisteredServiceAgent() >>> %d", result); } while (result != SAP_RESULT_SUCCESS); return TRUE; diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 3192e42..d99158b 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -1,5 +1,6 @@ #include "main.h" #include "ft.h" +#include "log.h" #include #include @@ -38,7 +39,7 @@ int main(int argc, char *argv[]) ret = service_app_main(argc, argv, &event_callback, NULL); if (ret != APP_ERROR_NONE) { - dlog_print(DLOG_ERROR, TAG, "app_main() is failed. err = %d", ret); + LOGE("app_main() is failed. err = %d", ret); } return ret; } diff --git a/receiver/src/sticker_info.cpp b/receiver/src/sticker_info.cpp index 0282163..37f11e8 100644 --- a/receiver/src/sticker_info.cpp +++ b/receiver/src/sticker_info.cpp @@ -1,10 +1,11 @@ #include "sticker_info.h" #include -#include #include #include #include +#include "log.h" + static sticker_provider_h sticker_provider = NULL; sticker_data_h @@ -19,14 +20,14 @@ int len, const char* group, const char* thumbnail, const char* description) ret = sticker_data_create(&sticker_data); if (ret != STICKER_ERROR_NONE) { /* Error handling */ - dlog_print(DLOG_ERROR, TAG, "Failed to create sticker data"); + LOGE("Failed to create sticker data"); } /* Sets the URI and URI type of the sticker */ ret = sticker_data_set_uri(sticker_data, type, uri); if (ret != STICKER_ERROR_NONE) { /* Error handling */ - dlog_print(DLOG_ERROR, TAG, "Failed to set uri"); + LOGE("Failed to set uri"); } //for (int i = 0; i < len; i++) @@ -35,7 +36,7 @@ int len, const char* group, const char* thumbnail, const char* description) ret = sticker_data_add_keyword(sticker_data, keyword); if (ret != STICKER_ERROR_NONE) { /* Error handling */ - dlog_print(DLOG_ERROR, TAG, "Failed to add keyword"); + LOGE("Failed to add keyword"); } } @@ -43,7 +44,7 @@ int len, const char* group, const char* thumbnail, const char* description) ret = sticker_data_set_group_name(sticker_data, group); if (ret != STICKER_ERROR_NONE) { /* Error handling */ - dlog_print(DLOG_ERROR, TAG, "Failed to set group name"); + LOGE("Failed to set group name"); } /* Sets the thumbnail local path of the sticker */ @@ -51,7 +52,7 @@ int len, const char* group, const char* thumbnail, const char* description) ret = sticker_data_set_thumbnail(sticker_data, thumbnail); if (ret != STICKER_ERROR_NONE) { /* Error handling */ - dlog_print(DLOG_ERROR, TAG, "Failed to set thumbnail"); + LOGE("Failed to set thumbnail"); } } @@ -59,7 +60,7 @@ int len, const char* group, const char* thumbnail, const char* description) ret = sticker_data_set_description(sticker_data, description); if (ret != STICKER_ERROR_NONE) { /* Error handling */ - dlog_print(DLOG_ERROR, TAG, "Failed to set description"); + LOGE("Failed to set description"); } return sticker_data; @@ -75,17 +76,17 @@ insert_sticker_data(const char *filepath, const char *keyword, const char *group ret = sticker_provider_insert_data(sticker_provider, data_handle); if (ret != STICKER_ERROR_NONE) { - dlog_print(DLOG_ERROR, TAG, "Failed to insert data. error code : %x. message : %s", ret, get_error_message(ret)); + LOGE("Failed to insert data. error code : %x. message : %s", ret, get_error_message(ret)); } else { - dlog_print(DLOG_INFO, TAG, "Succeeded to insert data"); + LOGI("Succeeded to insert data"); } /* Destroys a sticker data handle */ ret = sticker_data_destroy(data_handle); if (ret != STICKER_ERROR_NONE) { /* Error handling */ - dlog_print(DLOG_ERROR, TAG, "Failed to destroy sticker data"); + LOGE("Failed to destroy sticker data"); } } @@ -95,7 +96,7 @@ int create_sticker_provider_handle(void) ret = sticker_provider_create(&sticker_provider); if (ret != STICKER_ERROR_NONE) { /* Error handling */ - dlog_print(DLOG_ERROR, TAG, "Failed to create sticker provider"); + LOGE("Failed to create sticker provider"); } return ret; -- 2.7.4 From 7c50b342d94f258c7c2331df7b9b7ff81c1d6e52 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 21 Feb 2020 20:49:19 +0900 Subject: [PATCH 13/16] Terminate sticker-receiver when disconnected from mobile device Change-Id: I463ed46ba612b7a2521e26a242386bb283e946d3 Signed-off-by: Jihoon Kim --- receiver/inc/ft.h | 1 + receiver/src/ft.cpp | 33 +++++++++++++++++++++++++++++++++ receiver/src/main.cpp | 1 + 3 files changed, 35 insertions(+) diff --git a/receiver/inc/ft.h b/receiver/inc/ft.h index b64fa8d..bf25d8e 100644 --- a/receiver/inc/ft.h +++ b/receiver/inc/ft.h @@ -27,6 +27,7 @@ void reject_file(void); void accept_file(void); gboolean initialize_sap(void); +void deinitialize_sap(void); void sap_file_transfer_get_receive_filepath(char **filepath); diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index a67c6d6..ac09cf5 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -213,6 +214,7 @@ void conn_terminated(sap_peer_agent_h peer_agent, void *user_data) { LOGI("connection terminated"); + service_app_exit(); } void @@ -271,6 +273,13 @@ static void on_agent_initialized(sap_agent_h agent, } } +static void on_agent_deinitialized(sap_agent_h agent, + sap_agent_deinitialized_result_e result, + void *user_data) +{ + LOGD("result of deinitialize : %d", result); +} + static void _on_device_status_changed(sap_device_status_e status, sap_transport_type_e transport_type, void *user_data) @@ -346,3 +355,27 @@ gboolean initialize_sap(void) return TRUE; } + +void deinitialize_sap(void) +{ + if (priv_data.agent) { + int ret = sap_agent_deinitialize(priv_data.agent, on_agent_deinitialized, NULL); + switch (ret) { + case SAP_RESULT_FAILURE: + LOGW("Failed to deinitialize"); + break; + case SAP_RESULT_SUCCESS: + LOGD("Succeed to deinitialize"); + break; + case SAP_RESULT_PERMISSION_DENIED: + LOGW("permission denied: deinitialize "); + break; + default: + LOGD("deinitialize : %d", ret); + break; + } + + sap_agent_destroy(priv_data.agent); + priv_data.agent = NULL; + } +} diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index d99158b..6151d90 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -24,6 +24,7 @@ static void app_control(app_control_h app_control, void *data) static void app_terminate(void *data) { /* Release all resources. */ + deinitialize_sap(); } int main(int argc, char *argv[]) -- 2.7.4 From 57d90c68c33b22271da476dbb90a4943d246aedf Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 24 Feb 2020 18:57:29 +0900 Subject: [PATCH 14/16] Change indentation from tab to spaces Change-Id: I4f79da47ef7b6b05d096596230683a5582005cb5 Signed-off-by: Jihoon Kim --- receiver/src/ft.cpp | 500 +++++++++++++++++++++--------------------- receiver/src/main.cpp | 40 ++-- receiver/src/sticker_info.cpp | 3 +- 3 files changed, 266 insertions(+), 277 deletions(-) diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index ac09cf5..d03495d 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -38,8 +38,8 @@ using namespace std; struct priv { - sap_agent_h agent; - sap_file_transaction_h socket; + sap_agent_h agent; + sap_file_transaction_h socket; }; static struct priv priv_data = { 0 }; @@ -49,333 +49,323 @@ static string incoming_file_name; static string recv_filepath; static void _on_send_completed(sap_file_transaction_h file_transaction, - sap_ft_transfer_e result, - const char *file_path, - void *user_data) + sap_ft_transfer_e result, + const char *file_path, + void *user_data) { - char error_message[100]; - - LOGI("# transfer completed"); - - if (priv_data.socket) { - sap_file_transfer_destroy(file_transaction); - priv_data.socket = NULL; - } - - if (result == SAP_FT_TRANSFER_SUCCESS) { - sprintf(error_message, "Transfer Completed"); - LOGI("Transfer Completed"); - - if (chmod(recv_filepath.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) == -1) { - LOGE("Failed to change permission : %s. error : %s", recv_filepath.c_str(), strerror(errno)); - } - else { - LOGI("Succeed to change permission : %s", recv_filepath.c_str()); - if (create_sticker_provider_handle() == STICKER_ERROR_NONE) { - insert_sticker_data(recv_filepath.c_str(), "keyword", "group", "test icon"); - destroy_sticker_provider_handle(); - - if (unlink(recv_filepath.c_str()) == -1) - LOGE("Failed to remove sticker file"); - } - } - } else { - switch (result) { - case (SAP_FT_TRANSFER_FAIL_CHANNEL_IO): { - sprintf(error_message, "Channel IO Error."); - LOGW("Channel IO Error."); - break; - } - - case (SAP_FT_TRANSFER_FAIL_FILE_IO): { - sprintf(error_message, "File IO Error."); - LOGW("File IO Error."); - break; - } - - case (SAP_FT_TRANSFER_FAIL_CMD_DROPPED): { - sprintf(error_message, "Transfer dropped."); - LOGW("Transfer dropped."); - break; - } - - case (SAP_FT_TRANSFER_FAIL_PEER_UNRESPONSIVE): { - sprintf(error_message, "Peer Un Responsive."); - LOGW("Peer Un Responsive."); - break; - } - - case (SAP_FT_TRANSFER_FAIL_PEER_CONN_LOST): { - sprintf(error_message, "Connection Lost."); - LOGW("Connection Lost."); - break; - } - - case (SAP_FT_TRANSFER_FAIL_PEER_CANCELLED): { - sprintf(error_message, "Peer Cancelled."); - LOGW("Peer Cancelled."); - break; - } - - case (SAP_FT_TRANSFER_FAIL_SPACE_NOT_AVAILABLE): { - sprintf(error_message, "No Space."); - LOGW("No Space."); - break; - } - - default: - sprintf(error_message, "Unknown Error"); - LOGW("Unknown Error"); - } - } - - file_on_progress = 0; + char error_message[100]; + + LOGI("# transfer completed"); + + if (priv_data.socket) { + sap_file_transfer_destroy(file_transaction); + priv_data.socket = NULL; + } + + if (result == SAP_FT_TRANSFER_SUCCESS) { + sprintf(error_message, "Transfer Completed"); + LOGI("Transfer Completed"); + + if (chmod(recv_filepath.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) == -1) { + LOGE("Failed to change permission : %s. error : %s", recv_filepath.c_str(), strerror(errno)); + } + else { + LOGI("Succeed to change permission : %s", recv_filepath.c_str()); + if (create_sticker_provider_handle() == STICKER_ERROR_NONE) { + insert_sticker_data(recv_filepath.c_str(), "keyword", "group", "test icon"); + destroy_sticker_provider_handle(); + + if (unlink(recv_filepath.c_str()) == -1) + LOGE("Failed to remove sticker file"); + } + } + } else { + switch (result) { + case (SAP_FT_TRANSFER_FAIL_CHANNEL_IO): { + sprintf(error_message, "Channel IO Error."); + LOGW("Channel IO Error."); + break; + } + + case (SAP_FT_TRANSFER_FAIL_FILE_IO): { + sprintf(error_message, "File IO Error."); + LOGW("File IO Error."); + break; + } + + case (SAP_FT_TRANSFER_FAIL_CMD_DROPPED): + { + sprintf(error_message, "Transfer dropped."); + LOGW("Transfer dropped."); + break; + } + + case (SAP_FT_TRANSFER_FAIL_PEER_UNRESPONSIVE): + { + sprintf(error_message, "Peer Un Responsive."); + LOGW("Peer Un Responsive."); + break; + } + + case (SAP_FT_TRANSFER_FAIL_PEER_CONN_LOST): + { + sprintf(error_message, "Connection Lost."); + LOGW("Connection Lost."); + break; + } + + case (SAP_FT_TRANSFER_FAIL_PEER_CANCELLED): + { + sprintf(error_message, "Peer Cancelled."); + LOGW("Peer Cancelled."); + break; + } + + case (SAP_FT_TRANSFER_FAIL_SPACE_NOT_AVAILABLE): + { + sprintf(error_message, "No Space."); + LOGW("No Space."); + break; + } + + default: + sprintf(error_message, "Unknown Error"); + LOGW("Unknown Error"); + break; + } + } + + file_on_progress = 0; } static void _on_sending_file_in_progress(sap_file_transaction_h file_transaction, - unsigned short int percentage_progress, - void *user_data) + unsigned short int percentage_progress, + void *user_data) { - LOGI("# progress %d", percentage_progress); + LOGI("# progress %d", percentage_progress); } static void __set_file_transfer_cb(sap_file_transaction_h file_socket) { - LOGI("# set callbacks"); - sap_file_transfer_set_progress_cb(file_socket, _on_sending_file_in_progress, NULL); + LOGI("# set callbacks"); + sap_file_transfer_set_progress_cb(file_socket, _on_sending_file_in_progress, NULL); - sap_file_transfer_set_done_cb(file_socket, _on_send_completed, NULL); + sap_file_transfer_set_done_cb(file_socket, _on_send_completed, NULL); } void accept_file() { - int ret; - char file_path[PATH_MAX]; - char *data_path = NULL; - - data_path = app_get_shared_data_path(); - LOGI("Path : %s", data_path); - sprintf(file_path, "%s/%s", data_path, incoming_file_name.c_str()); - LOGI("Receive filepath : %s", file_path); - recv_filepath = string(file_path); - free(data_path); - - ret = sap_file_transfer_receive(priv_data.socket, file_path); - switch(ret) { - case SAP_RESULT_PERMISSION_DENIED: - LOGW("permission denied"); - break; - case SAP_RESULT_FAILURE: - LOGW("Fail"); - break; - case SAP_RESULT_SUCCESS: - LOGI("Success"); - break; - } - - file_on_progress = 1; + int ret; + char file_path[PATH_MAX]; + char *data_path = NULL; + + data_path = app_get_shared_data_path(); + LOGI("Path : %s", data_path); + sprintf(file_path, "%s/%s", data_path, incoming_file_name.c_str()); + LOGI("Receive filepath : %s", file_path); + recv_filepath = string(file_path); + free(data_path); + + ret = sap_file_transfer_receive(priv_data.socket, file_path); + switch(ret) { + case SAP_RESULT_PERMISSION_DENIED: + LOGW("permission denied"); + break; + case SAP_RESULT_FAILURE: + LOGW("Fail"); + break; + case SAP_RESULT_SUCCESS: + LOGI("Success"); + break; + } + + file_on_progress = 1; } void sap_file_transfer_get_receive_filepath(char **filepath) { - *filepath = strdup(recv_filepath.c_str()); + *filepath = strdup(recv_filepath.c_str()); } void reject_file() { - int ret = sap_file_transfer_reject(priv_data.socket); - LOGI("ret : %d", ret); + int ret = sap_file_transfer_reject(priv_data.socket); + LOGI("ret : %d", ret); - file_on_progress = 0; + file_on_progress = 0; } static void _on_receive_file_cb(sap_peer_agent_h peer_agent_h, - sap_file_transaction_h socket, - const char *file_path, - void *user_data) + sap_file_transaction_h socket, + const char *file_path, + void *user_data) { - file_on_progress = 1; - priv_data.socket = socket; - LOGI("# incoming file request."); - __set_file_transfer_cb(priv_data.socket); + file_on_progress = 1; + priv_data.socket = socket; + LOGI("# incoming file request."); + __set_file_transfer_cb(priv_data.socket); - incoming_file_name = file_path; - std::size_t found = incoming_file_name.find_last_of("/"); - incoming_file_name = incoming_file_name.substr(found+1); + incoming_file_name = file_path; + std::size_t found = incoming_file_name.find_last_of("/"); + incoming_file_name = incoming_file_name.substr(found+1); - LOGI("# file path : %s, incoming file name : %s", file_path, incoming_file_name.c_str()); + LOGI("# file path : %s, incoming file name : %s", file_path, incoming_file_name.c_str()); - accept_file(); + accept_file(); } void conn_terminated(sap_peer_agent_h peer_agent, - sap_socket_h socket, - sap_service_connection_terminated_reason_e result, - void *user_data) + sap_socket_h socket, + sap_service_connection_terminated_reason_e result, + void *user_data) { - LOGI("connection terminated"); - service_app_exit(); + LOGI("connection terminated"); + service_app_exit(); } 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) */ + void *user_data) /* message exchange on_receive callback (sap_agent_data_received_cb) */ { - LOGI("received data: %s, len:%d", (char *)buffer, payload_length); + LOGI("received data: %s, len:%d", (char *)buffer, payload_length); } static void on_conn_req(sap_peer_agent_h peer_agent, - sap_socket_h socket, - sap_service_connection_result_e result, - void *user_data) + sap_socket_h socket, + sap_service_connection_result_e result, + void *user_data) { - sap_peer_agent_accept_service_connection(peer_agent); - sap_peer_agent_set_service_connection_terminated_cb(peer_agent, conn_terminated, NULL); + sap_peer_agent_accept_service_connection(peer_agent); + sap_peer_agent_set_service_connection_terminated_cb(peer_agent, conn_terminated, NULL); - sap_socket_set_data_received_cb(socket, on_data_received, peer_agent); + sap_socket_set_data_received_cb(socket, on_data_received, peer_agent); } static void on_agent_initialized(sap_agent_h agent, - sap_agent_initialized_result_e result, - void *user_data) + sap_agent_initialized_result_e result, + void *user_data) { - switch (result) { - case SAP_AGENT_INITIALIZED_RESULT_SUCCESS: - - LOGD("agent is initialized"); - - priv_data.agent = agent; - - sap_file_transfer_set_incoming_file_cb(agent, _on_receive_file_cb, NULL); - sap_agent_set_service_connection_requested_cb(agent, on_conn_req, NULL); - - break; - - case SAP_AGENT_INITIALIZED_RESULT_DUPLICATED: - LOGE("duplicate registration"); - - break; - - case SAP_AGENT_INITIALIZED_RESULT_INVALID_ARGUMENTS: - LOGE("invalid arguments"); - - break; - - case SAP_AGENT_INITIALIZED_RESULT_INTERNAL_ERROR: - LOGE("internal sap error"); - - break; - - default: - LOGE("unknown status (%d)", result); - - break; - } + switch (result) { + case SAP_AGENT_INITIALIZED_RESULT_SUCCESS: + LOGD("agent is initialized"); + + priv_data.agent = agent; + + sap_file_transfer_set_incoming_file_cb(agent, _on_receive_file_cb, NULL); + sap_agent_set_service_connection_requested_cb(agent, on_conn_req, NULL); + + break; + case SAP_AGENT_INITIALIZED_RESULT_DUPLICATED: + LOGE("duplicate registration"); + break; + case SAP_AGENT_INITIALIZED_RESULT_INVALID_ARGUMENTS: + LOGE("invalid arguments"); + break; + case SAP_AGENT_INITIALIZED_RESULT_INTERNAL_ERROR: + LOGE("internal sap error"); + break; + default: + LOGE("unknown status (%d)", result); + break; + } } static void on_agent_deinitialized(sap_agent_h agent, - sap_agent_deinitialized_result_e result, - void *user_data) + sap_agent_deinitialized_result_e result, + void *user_data) { - LOGD("result of deinitialize : %d", result); + LOGD("result of deinitialize : %d", result); } static void _on_device_status_changed(sap_device_status_e status, - sap_transport_type_e transport_type, - void *user_data) + sap_transport_type_e transport_type, + void *user_data) { - LOGD("%s, status :%d", __func__, status); - - switch (transport_type) { - case SAP_TRANSPORT_TYPE_BT: - LOGD("transport_type (%d): bt", transport_type); - break; - - case SAP_TRANSPORT_TYPE_BLE: - LOGD("transport_type (%d): ble", transport_type); - break; - - case SAP_TRANSPORT_TYPE_TCP: - LOGD("transport_type (%d): tcp/ip", transport_type); - break; - - case SAP_TRANSPORT_TYPE_USB: - LOGD("transport_type (%d): usb", transport_type); - break; - - case SAP_TRANSPORT_TYPE_MOBILE: - LOGD("transport_type (%d): mobile", transport_type); - break; - - default: - LOGE("unknown transport_type (%d)", transport_type); - break; - } - - switch (status) { - case SAP_DEVICE_STATUS_DETACHED: - LOGD("device is not connected."); - break; - - case SAP_DEVICE_STATUS_ATTACHED: - LOGD("Attached calling find peer now"); - break; - - default: - LOGE("unknown status (%d)", status); - break; - } + LOGD("%s, status :%d", __func__, status); + + switch (transport_type) { + case SAP_TRANSPORT_TYPE_BT: + LOGD("transport_type (%d): bt", transport_type); + break; + case SAP_TRANSPORT_TYPE_BLE: + LOGD("transport_type (%d): ble", transport_type); + break; + case SAP_TRANSPORT_TYPE_TCP: + LOGD("transport_type (%d): tcp/ip", transport_type); + break; + case SAP_TRANSPORT_TYPE_USB: + LOGD("transport_type (%d): usb", transport_type); + break; + case SAP_TRANSPORT_TYPE_MOBILE: + LOGD("transport_type (%d): mobile", transport_type); + break; + default: + LOGE("unknown transport_type (%d)", transport_type); + break; + } + + switch (status) { + case SAP_DEVICE_STATUS_DETACHED: + LOGD("device is not connected."); + break; + case SAP_DEVICE_STATUS_ATTACHED: + LOGD("Attached calling find peer now"); + break; + default: + LOGE("unknown status (%d)", status); + break; + } } gboolean agent_initialize() { - int result = 0; + int result = 0; - do { - result = sap_agent_initialize(priv_data.agent, ACCESSORY_SERVICE_PROFILE_ID, SAP_AGENT_ROLE_CONSUMER, - on_agent_initialized, NULL); + do { + result = sap_agent_initialize(priv_data.agent, ACCESSORY_SERVICE_PROFILE_ID, SAP_AGENT_ROLE_CONSUMER, + on_agent_initialized, NULL); - LOGD("SAP >>> getRegisteredServiceAgent() >>> %d", result); - } while (result != SAP_RESULT_SUCCESS); + LOGD("SAP >>> getRegisteredServiceAgent() >>> %d", result); + } while (result != SAP_RESULT_SUCCESS); - return TRUE; + return TRUE; } gboolean initialize_sap(void) { - sap_agent_h agent = NULL; + sap_agent_h agent = NULL; - sap_agent_create(&agent); + sap_agent_create(&agent); - priv_data.agent = agent; + priv_data.agent = agent; - agent_initialize(); + agent_initialize(); - sap_set_device_status_changed_cb(_on_device_status_changed, NULL); + sap_set_device_status_changed_cb(_on_device_status_changed, NULL); - return TRUE; + return TRUE; } void deinitialize_sap(void) { - if (priv_data.agent) { - int ret = sap_agent_deinitialize(priv_data.agent, on_agent_deinitialized, NULL); - switch (ret) { - case SAP_RESULT_FAILURE: - LOGW("Failed to deinitialize"); - break; - case SAP_RESULT_SUCCESS: - LOGD("Succeed to deinitialize"); - break; - case SAP_RESULT_PERMISSION_DENIED: - LOGW("permission denied: deinitialize "); - break; - default: - LOGD("deinitialize : %d", ret); - break; - } - - sap_agent_destroy(priv_data.agent); - priv_data.agent = NULL; - } + if (priv_data.agent) { + int ret = sap_agent_deinitialize(priv_data.agent, on_agent_deinitialized, NULL); + switch (ret) { + case SAP_RESULT_FAILURE: + LOGW("Failed to deinitialize"); + break; + case SAP_RESULT_SUCCESS: + LOGD("Succeed to deinitialize"); + break; + case SAP_RESULT_PERMISSION_DENIED: + LOGW("permission denied: deinitialize "); + break; + default: + LOGD("deinitialize : %d", ret); + break; + } + + sap_agent_destroy(priv_data.agent); + priv_data.agent = NULL; + } } diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 6151d90..3bf6300 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -6,41 +6,41 @@ static bool app_create(void *data) { - /* Hook to take necessary actions before main event loop starts - Initialize UI resources and application's data - If this function returns true, the main loop of application starts - If this function returns false, the application is terminated */ + /* Hook to take necessary actions before main event loop starts + Initialize UI resources and application's data + If this function returns true, the main loop of application starts + If this function returns false, the application is terminated */ - initialize_sap(); + initialize_sap(); - return true; + return true; } static void app_control(app_control_h app_control, void *data) { - /* Handle the launch request. */ + /* Handle the launch request. */ } static void app_terminate(void *data) { - /* Release all resources. */ - deinitialize_sap(); + /* Release all resources. */ + deinitialize_sap(); } int main(int argc, char *argv[]) { - int ret = 0; + int ret = 0; - service_app_lifecycle_callback_s event_callback; - memset(&event_callback, 0x0, sizeof(service_app_lifecycle_callback_s)); + service_app_lifecycle_callback_s event_callback; + memset(&event_callback, 0x0, sizeof(service_app_lifecycle_callback_s)); - event_callback.create = (service_app_create_cb)app_create; - event_callback.terminate = (service_app_terminate_cb)app_terminate; - event_callback.app_control = (service_app_control_cb)app_control; + event_callback.create = (service_app_create_cb)app_create; + event_callback.terminate = (service_app_terminate_cb)app_terminate; + event_callback.app_control = (service_app_control_cb)app_control; - ret = service_app_main(argc, argv, &event_callback, NULL); - if (ret != APP_ERROR_NONE) { - LOGE("app_main() is failed. err = %d", ret); - } - return ret; + ret = service_app_main(argc, argv, &event_callback, NULL); + if (ret != APP_ERROR_NONE) { + LOGE("app_main() is failed. err = %d", ret); + } + return ret; } diff --git a/receiver/src/sticker_info.cpp b/receiver/src/sticker_info.cpp index 37f11e8..a391fc2 100644 --- a/receiver/src/sticker_info.cpp +++ b/receiver/src/sticker_info.cpp @@ -12,7 +12,6 @@ sticker_data_h set_sticker_data(sticker_data_uri_type_e type, const char* uri, const char* keyword, int len, const char* group, const char* thumbnail, const char* description) { - sticker_data_h sticker_data; int ret; @@ -106,4 +105,4 @@ void destroy_sticker_provider_handle(void) { sticker_provider_destroy(sticker_provider); sticker_provider = NULL; -} \ No newline at end of file +} -- 2.7.4 From 1f7fe8f256483a4afd7875e22aba692f317498c1 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 2 Mar 2020 10:39:22 +0900 Subject: [PATCH 15/16] Fix issues detected by static analysis tool Change-Id: Ifc206b696c03bff49baac3e048febca3348f212b --- server/stickerd_db_manager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index 02c4691..ab68092 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -616,14 +616,14 @@ int stickerd_db_get_keyword_list(GVariantBuilder *builder, char *app_id) if (!db) return STICKERD_SERVER_ERROR_DB_FAILED; - sqlite3_bind_text(stmt, 1, app_id, -1, SQLITE_TRANSIENT); - ret = sqlite3_prepare_v2(db, STICKER_DB_GET_ALL_KEYWORD_LIST, -1, &stmt, NULL); if (ret != SQLITE_OK) { LOGE("fail to get keyword list : %s", sqlite3_errmsg(db)); goto cleanup; } + sqlite3_bind_text(stmt, 1, app_id, -1, SQLITE_TRANSIENT); + while (sqlite3_step(stmt) == SQLITE_ROW) { const unsigned char *keyword = sqlite3_column_text(stmt, 0); if (keyword) -- 2.7.4 From b14f2f3415ef1b176f1522efc0fc3e566a5b5e4c Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 2 Mar 2020 10:40:38 +0900 Subject: [PATCH 16/16] Update package version to 0.1.15 Change-Id: I1026c72fdeae6e3bccae1e4e7fbcb8fe582b68b8 --- packaging/capi-ui-sticker.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index 7e4cb25..269d1fb 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.14 +Version: 0.1.15 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 -- 2.7.4