From b6a60aea32fb77a347eeee9be430b444f2c2a8f5 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 16 Mar 2020 19:53:59 +0900 Subject: [PATCH 01/16] Add error codes Change-Id: Ibdde0b8c7ed6f1068bc80ccb950e05e3b0925d50 --- client/sticker_data.c | 10 +++++----- client/sticker_dbus.c | 37 +++++++++++++++++++++++++------------ client/sticker_dbus.h | 3 +++ include/sticker_data.h | 11 +++++------ include/sticker_error.h | 3 +++ include/sticker_provider.h | 4 ++++ provider/sticker_provider.c | 14 ++++++++++++-- server/stickerd_data_manager.c | 10 +++++++--- server/stickerd_error.h | 4 +++- 9 files changed, 67 insertions(+), 29 deletions(-) diff --git a/client/sticker_data.c b/client/sticker_data.c index b76e7a8..555a23a 100644 --- a/client/sticker_data.c +++ b/client/sticker_data.c @@ -223,7 +223,7 @@ EXPORT_API int sticker_data_get_app_id(sticker_data_h data_handle, char **app_id return STICKER_ERROR_INVALID_PARAMETER; if (!data_handle->app_id) - return STICKER_ERROR_OPERATION_FAILED; + return STICKER_ERROR_NO_DATA; *app_id = strdup(data_handle->app_id); @@ -268,7 +268,7 @@ EXPORT_API int sticker_data_get_uri(sticker_data_h data_handle, sticker_data_uri return STICKER_ERROR_INVALID_PARAMETER; if (!data_handle->type || !data_handle->uri) - return STICKER_ERROR_OPERATION_FAILED; + return STICKER_ERROR_NO_DATA; *type = data_handle->type; *uri = strdup(data_handle->uri); @@ -284,7 +284,7 @@ EXPORT_API int sticker_data_foreach_keyword(sticker_data_h data_handle, sticker_ return STICKER_ERROR_INVALID_PARAMETER; if (!data_handle->keyword) - return STICKER_ERROR_OPERATION_FAILED; + return STICKER_ERROR_NO_DATA; GList *list = NULL; for(list = g_list_first(data_handle->keyword); list != NULL; list=list->next) { @@ -357,7 +357,7 @@ EXPORT_API int sticker_data_get_group_name(sticker_data_h data_handle, char **gr return STICKER_ERROR_INVALID_PARAMETER; if (!data_handle->group) - return STICKER_ERROR_OPERATION_FAILED; + return STICKER_ERROR_NO_DATA; *group = strdup(data_handle->group); @@ -440,7 +440,7 @@ EXPORT_API int sticker_data_get_date(sticker_data_h data_handle, char **date) return STICKER_ERROR_INVALID_PARAMETER; if (!data_handle->date) - return STICKER_ERROR_OPERATION_FAILED; + return STICKER_ERROR_NO_DATA; *date = strdup(data_handle->date); diff --git a/client/sticker_dbus.c b/client/sticker_dbus.c index 242e978..8902922 100644 --- a/client/sticker_dbus.c +++ b/client/sticker_dbus.c @@ -667,46 +667,58 @@ int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_ return ret; } - if (sticker_data->type != 0 && sticker_data->type != origin_data->type) { - LOGD("origin_type : %d, new_type : %d", origin_data->type, sticker_data->type); - ret = _send_sync_message(gdbus_connection, g_variant_new("(ii)", sticker_data->sticker_info_id, sticker_data->type), &reply, "update_sticker_type"); - if (ret != STICKER_CLIENT_ERROR_NONE) - LOGE("failed to update sticker type"); - } - if (sticker_data->uri && strcmp(sticker_data->uri, origin_data->uri) != 0) { LOGD("origin_uri : %s, new_uri : %s", origin_data->uri, sticker_data->uri); ret = _send_sync_message(gdbus_connection, g_variant_new("(isis)", sticker_data->sticker_info_id, sticker_data->app_id, sticker_data->type, sticker_data->uri), &reply, "update_sticker_uri"); - if (ret != STICKER_CLIENT_ERROR_NONE) + if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker uri"); + goto cleanup; + } + } + + if (sticker_data->type != 0 && sticker_data->type != origin_data->type) { + LOGD("origin_type : %d, new_type : %d", origin_data->type, sticker_data->type); + ret = _send_sync_message(gdbus_connection, g_variant_new("(ii)", sticker_data->sticker_info_id, sticker_data->type), &reply, "update_sticker_type"); + if (ret != STICKER_CLIENT_ERROR_NONE) { + LOGE("failed to update sticker type"); + goto cleanup; + } } 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"); - if (ret != STICKER_CLIENT_ERROR_NONE) + if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker thumbnail"); + goto cleanup; + } } if (sticker_data->description && strcmp(sticker_data->description, origin_data->description) != 0) { LOGD("origin_description : %s, new_description : %s", origin_data->description, sticker_data->description); ret = _send_sync_message(gdbus_connection, g_variant_new("(is)", sticker_data->sticker_info_id, sticker_data->description), &reply, "update_sticker_description"); - if (ret != STICKER_CLIENT_ERROR_NONE) + if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker description"); + goto cleanup; + } } if (sticker_data->group && strcmp(sticker_data->group, origin_data->group) != 0) { LOGD("origin_group : %s, new_group : %s", origin_data->group, sticker_data->group); ret = _send_sync_message(gdbus_connection, g_variant_new("(is)", sticker_data->sticker_info_id, sticker_data->group), &reply, "update_sticker_group"); - if (ret != STICKER_CLIENT_ERROR_NONE) + if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker group"); + goto cleanup; + } } if (sticker_data->disp_type != 0 && sticker_data->disp_type != origin_data->disp_type) { LOGD("origin_disp_type : %d, new_disp_type : %d", origin_data->disp_type, sticker_data->disp_type); ret = _send_sync_message(gdbus_connection, g_variant_new("(ii)", sticker_data->sticker_info_id, sticker_data->disp_type), &reply, "update_sticker_disp_type"); - if (ret != STICKER_CLIENT_ERROR_NONE) + if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker display type"); + goto cleanup; + } } if (sticker_data->keyword) { @@ -719,6 +731,7 @@ int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_ g_variant_builder_unref(keyword_builder); } +cleanup: _free_sticker_data(origin_data); if (reply_body) diff --git a/client/sticker_dbus.h b/client/sticker_dbus.h index 4ef7234..7640435 100644 --- a/client/sticker_dbus.h +++ b/client/sticker_dbus.h @@ -40,6 +40,9 @@ enum sticker_client_error { STICKER_CLIENT_ERROR_SERVICE_NOT_READY, STICKER_CLIENT_ERROR_OPERATION_FAILED, STICKER_CLIENT_ERROR_IO_ERROR, + STICKER_CLIENT_ERROR_DB_FAILED, + STICKER_CLIENT_ERROR_FILE_EXISTS, + STICKER_CLIENT_ERROR_NO_SUCH_FILE, }; int sticker_dbus_init(GDBusConnection **gdbus_connection, int *server_watcher_id, diff --git a/include/sticker_data.h b/include/sticker_data.h index fc1f8c3..e27197c 100644 --- a/include/sticker_data.h +++ b/include/sticker_data.h @@ -123,7 +123,7 @@ int sticker_data_clone(sticker_data_h origin_handle, sticker_data_h *target_hand * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_NO_DATA No data available */ int sticker_data_get_app_id(sticker_data_h data_handle, char **app_id); @@ -139,7 +139,6 @@ int sticker_data_get_app_id(sticker_data_h data_handle, char **app_id); * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed * @see sticker_data_get_uri() */ int sticker_data_set_uri(sticker_data_h data_handle, sticker_data_uri_type_e type, const char *uri); @@ -155,7 +154,7 @@ int sticker_data_set_uri(sticker_data_h data_handle, sticker_data_uri_type_e typ * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_NO_DATA No data available * @see sticker_data_set_uri() */ int sticker_data_get_uri(sticker_data_h data_handle, sticker_data_uri_type_e *type, char **uri); @@ -170,7 +169,7 @@ int sticker_data_get_uri(sticker_data_h data_handle, sticker_data_uri_type_e *ty * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_NO_DATA No data available * @post This function invokes sticker_data_keyword_foreach_cb() repeatedly for getting keywords. * @see sticker_data_keyword_foreach_cb() * @see sticker_data_add_keyword() @@ -234,7 +233,7 @@ int sticker_data_set_group_name(sticker_data_h data_handle, const char *group); * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_NO_DATA No data available * @see sticker_data_set_group() */ int sticker_data_get_group_name(sticker_data_h data_handle, char **group); @@ -309,7 +308,7 @@ int sticker_data_get_description(sticker_data_h data_handle, char **description) * @retval #STICKER_ERROR_NONE Successful * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_NO_DATA No data available */ int sticker_data_get_date(sticker_data_h data_handle, char **date); diff --git a/include/sticker_error.h b/include/sticker_error.h index a38b9c6..fea1302 100644 --- a/include/sticker_error.h +++ b/include/sticker_error.h @@ -45,6 +45,9 @@ typedef enum { STICKER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ STICKER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ 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_e; /** diff --git a/include/sticker_provider.h b/include/sticker_provider.h index 6ea0234..e7367b3 100644 --- a/include/sticker_provider.h +++ b/include/sticker_provider.h @@ -107,6 +107,8 @@ int sticker_provider_destroy(sticker_provider_h provider_handle); * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_FILE_EXISTS File exists + * @retval #STICKER_ERROR_NO_SUCH_FILE No such file * @see sticker_provider_update_data() * @see sticker_provider_delete_data() */ @@ -175,6 +177,8 @@ int sticker_provider_insert_data_by_json_file(sticker_provider_h provider_handle * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_FILE_EXISTS File exists + * @retval #STICKER_ERROR_NO_SUCH_FILE No such file * @see sticker_provider_insert_data() * @see sticker_provider_delete_data() */ diff --git a/provider/sticker_provider.c b/provider/sticker_provider.c index a271ca6..9ef5b60 100644 --- a/provider/sticker_provider.c +++ b/provider/sticker_provider.c @@ -133,7 +133,12 @@ EXPORT_API int sticker_provider_insert_data(sticker_provider_h provider_handle, ret = sticker_dbus_insert_sticker_info(provider_handle->gdbus_connection, data_handle); if (ret != STICKER_ERROR_NONE) { LOGE("Failed to insert sticker information : %d", ret); - return STICKER_ERROR_OPERATION_FAILED; + if (ret == STICKER_CLIENT_ERROR_FILE_EXISTS) + return STICKER_ERROR_FILE_EXISTS; + else if (ret == STICKER_CLIENT_ERROR_NO_SUCH_FILE) + return STICKER_ERROR_NO_SUCH_FILE; + else + return STICKER_ERROR_OPERATION_FAILED; } return STICKER_ERROR_NONE; @@ -233,7 +238,12 @@ EXPORT_API int sticker_provider_update_data(sticker_provider_h provider_handle, ret = sticker_dbus_update_sticker_info(provider_handle->gdbus_connection, data_handle); if (ret != STICKER_ERROR_NONE) { LOGE("Failed to update sticker information : %d", ret); - return STICKER_ERROR_OPERATION_FAILED; + if (ret == STICKER_CLIENT_ERROR_FILE_EXISTS) + return STICKER_ERROR_FILE_EXISTS; + else if (ret == STICKER_CLIENT_ERROR_NO_SUCH_FILE) + return STICKER_ERROR_NO_SUCH_FILE; + else + return STICKER_ERROR_OPERATION_FAILED; } return STICKER_ERROR_NONE; diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index 414fc12..f30cd8e 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -572,12 +572,12 @@ int stickerd_insert_sticker_info(GVariant *parameters, GVariant **reply_body) sticker_info->uri = _convert_sticker_uri(sticker_info->uri, sticker_info->app_id); if (!sticker_info->uri) { LOGE("failed to copy sticker file"); - ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; + ret = STICKERD_SERVER_ERROR_FILE_EXISTS; goto cleanup; } } else { LOGE("sticker file does not exist"); - ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; + ret = STICKERD_SERVER_ERROR_NO_SUCH_FILE; goto cleanup; } } @@ -715,6 +715,8 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_ sticker_info->uri = _convert_sticker_uri(sticker_info->uri, sticker_info->app_id); if (!sticker_info->uri) goto free_memory; + } else { + goto free_memory; } } @@ -835,8 +837,10 @@ int stickerd_update_sticker_uri(GVariant *parameters, GVariant **reply_body) uri = _convert_sticker_uri(uri, app_id); if (!uri) { LOGE("failed to copy sticker file"); - return STICKERD_SERVER_ERROR_OPERATION_FAILED; + return STICKERD_SERVER_ERROR_FILE_EXISTS; } + } else { + return STICKERD_SERVER_ERROR_NO_SUCH_FILE; } } diff --git a/server/stickerd_error.h b/server/stickerd_error.h index 2afea16..6d1b444 100644 --- a/server/stickerd_error.h +++ b/server/stickerd_error.h @@ -31,13 +31,15 @@ extern "C" { */ enum stickerd_server_error { STICKERD_SERVER_ERROR_NONE, - STICKERD_SERVER_ERROR_IO_ERROR, STICKERD_SERVER_ERROR_INVALID_PARAMETER, STICKERD_SERVER_ERROR_PERMISSION_DENIED, STICKERD_SERVER_ERROR_OUT_OF_MEMORY, STICKERD_SERVER_ERROR_SERVICE_NOT_READY, STICKERD_SERVER_ERROR_OPERATION_FAILED, + STICKERD_SERVER_ERROR_IO_ERROR, STICKERD_SERVER_ERROR_DB_FAILED, + STICKERD_SERVER_ERROR_FILE_EXISTS, + STICKERD_SERVER_ERROR_NO_SUCH_FILE, }; /** -- 2.7.4 From 002014050cc15255d4334685f94462c89d6b51d6 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 18 Mar 2020 16:50:30 +0900 Subject: [PATCH 02/16] Split sticker data into another file Change-Id: I3c23542e657757e0250fea67effb196677ae08c7 Signed-off-by: Jihoon Kim --- receiver/CMakeLists.txt | 1 + receiver/inc/sticker_data.h | 37 +++++++++++++++++++++++++++++++++++++ receiver/inc/sticker_info.h | 2 +- receiver/src/ft.cpp | 26 ++------------------------ receiver/src/sticker_data.cpp | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 77 insertions(+), 25 deletions(-) create mode 100644 receiver/inc/sticker_data.h create mode 100644 receiver/src/sticker_data.cpp diff --git a/receiver/CMakeLists.txt b/receiver/CMakeLists.txt index 73d4503..4a875d9 100644 --- a/receiver/CMakeLists.txt +++ b/receiver/CMakeLists.txt @@ -3,6 +3,7 @@ PROJECT(sticker-receiver CXX) SET(SRCS src/main.cpp + src/sticker_data.cpp src/ft.cpp src/sticker_info.cpp src/message.cpp diff --git a/receiver/inc/sticker_data.h b/receiver/inc/sticker_data.h new file mode 100644 index 0000000..97f82cc --- /dev/null +++ b/receiver/inc/sticker_data.h @@ -0,0 +1,37 @@ +/* + * 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_DATA_H__ +#define __STICKER_DATA_H__ + +#include + +using namespace std; + +struct sticker_info { + sticker_info(); + ~sticker_info(); + + void reset(); + + string file_path; + string group; + string keyword; + string disp_type; + string description; +}; + +#endif /* __STICKER_DATA_H__ */ diff --git a/receiver/inc/sticker_info.h b/receiver/inc/sticker_info.h index 86b6c88..8231585 100644 --- a/receiver/inc/sticker_info.h +++ b/receiver/inc/sticker_info.h @@ -21,4 +21,4 @@ int create_sticker_provider_handle(void); void destroy_sticker_provider_handle(void); void delete_sticker_data(const char *fileName); -#endif /* __STICKER_INF_H__ */ +#endif /* __STICKER_INFO_H__ */ diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 61afdc0..4a2ec79 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -35,6 +35,7 @@ #include "ft.h" #include "log.h" #include "sticker_info.h" +#include "../inc/sticker_data.h" #include "message.h" #include "sync_alarm.h" @@ -77,21 +78,6 @@ struct request { string type; }; -static void _reset_sticker_data(); - -struct sticker_info { - string file_path; - string group; - string keyword; - string disp_type; - string description; - - sticker_info() - { - _reset_sticker_data(); - } -}; - static struct sap_info_s priv_data = { 0 }; static struct sticker_info sticker_data; static struct request pending_request, current_request; @@ -393,14 +379,6 @@ void conn_terminated(sap_peer_agent_h peer_agent, service_app_exit(); } -static void _reset_sticker_data() -{ - sticker_data.file_path.clear(); - sticker_data.group.clear(); - sticker_data.keyword.clear(); - sticker_data.disp_type.clear(); - sticker_data.description.clear(); -} void on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned int payload_length, void *buffer, @@ -525,7 +503,7 @@ 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()); - _reset_sticker_data(); + sticker_data.reset(); const char *type_data = json_object_get_string_member(root_obj, "type"); if (type_data) diff --git a/receiver/src/sticker_data.cpp b/receiver/src/sticker_data.cpp new file mode 100644 index 0000000..bd94ee5 --- /dev/null +++ b/receiver/src/sticker_data.cpp @@ -0,0 +1,36 @@ +/* + * 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 "../inc/sticker_data.h" + +sticker_info::sticker_info() +{ + reset(); +} + +sticker_info::~sticker_info() +{ + +} + +void sticker_info::reset() +{ + file_path.clear(); + group.clear(); + keyword.clear(); + disp_type.clear(); + description.clear(); +} \ No newline at end of file -- 2.7.4 From d6b90adf54fef9e70ebccef6e74b6c80dad3ed31 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 19 Mar 2020 11:08:54 +0900 Subject: [PATCH 03/16] Add interface to check file exists Change-Id: I6af83ab05e00efaf014c9cc52543b7e620306ce2 --- client/sticker_dbus.c | 37 +++++++++++++++++++++++++++++++++++++ client/sticker_dbus.h | 1 + provider/sticker_provider.c | 19 +++++++++++++++---- server/stickerd_data_manager.c | 30 ++++++++++++++++++++++++++++++ server/stickerd_data_manager.h | 1 + server/stickerd_db_manager.c | 39 +++++++++++++++++++++++++++++++++++++++ server/stickerd_db_manager.h | 1 + 7 files changed, 124 insertions(+), 4 deletions(-) diff --git a/client/sticker_dbus.c b/client/sticker_dbus.c index 8902922..6af66b4 100644 --- a/client/sticker_dbus.c +++ b/client/sticker_dbus.c @@ -669,6 +669,22 @@ int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_ if (sticker_data->uri && strcmp(sticker_data->uri, origin_data->uri) != 0) { LOGD("origin_uri : %s, new_uri : %s", origin_data->uri, sticker_data->uri); + int is_exist = 0; + ret = _send_sync_message(gdbus_connection, g_variant_new("(s)", sticker_data->uri), &reply, "check_file_exists"); + if (ret == STICKER_CLIENT_ERROR_NONE) { + reply_body = g_dbus_message_get_body(reply); + g_variant_get(reply_body, "(i)", &is_exist); + + if (is_exist) { + LOGE("file already exists"); + ret = STICKER_CLIENT_ERROR_FILE_EXISTS; + goto cleanup; + } + } else { + LOGE("failed to check file exists"); + goto cleanup; + } + ret = _send_sync_message(gdbus_connection, g_variant_new("(isis)", sticker_data->sticker_info_id, sticker_data->app_id, sticker_data->type, sticker_data->uri), &reply, "update_sticker_uri"); if (ret != STICKER_CLIENT_ERROR_NONE) { LOGE("failed to update sticker uri"); @@ -1027,4 +1043,25 @@ int sticker_dbus_get_group_list_by_display_type(GDBusConnection *gdbus_connectio g_object_unref(reply); return ret; +} + +int sticker_dbus_check_file_exists(GDBusConnection *gdbus_connection, const char *uri, int *result) +{ + int ret; + GDBusMessage *reply = NULL; + GVariant *reply_body = NULL; + + ret = _send_sync_message(gdbus_connection, g_variant_new("(s)", uri), &reply, "check_file_exists"); + if (ret == STICKER_CLIENT_ERROR_NONE) { + reply_body = g_dbus_message_get_body(reply); + g_variant_get(reply_body, "(i)", result); + } + + if (reply_body) + g_variant_unref(reply_body); + + if (reply) + g_object_unref(reply); + + return ret; } \ No newline at end of file diff --git a/client/sticker_dbus.h b/client/sticker_dbus.h index 7640435..1982d46 100644 --- a/client/sticker_dbus.h +++ b/client/sticker_dbus.h @@ -63,6 +63,7 @@ int sticker_dbus_get_sticker_info_by_group(GDBusConnection *gdbus_connection, co int sticker_dbus_get_sticker_info_by_keyword(GDBusConnection *gdbus_connection, const char *app_id, const char *keyword, int offset, int count, GVariantIter **id_iter); int sticker_dbus_get_sticker_info_by_display_type(GDBusConnection *gdbus_connection, const char *app_id, sticker_data_display_type_e type, int offset, int count, GVariantIter **id_iter); int sticker_dbus_get_group_list_by_display_type(GDBusConnection *gdbus_connection, const char *app_id, sticker_data_display_type_e type, GList **group_list); +int sticker_dbus_check_file_exists(GDBusConnection *gdbus_connection, const char *uri, int *result); #ifdef __cplusplus } diff --git a/provider/sticker_provider.c b/provider/sticker_provider.c index 9ef5b60..7dfca80 100644 --- a/provider/sticker_provider.c +++ b/provider/sticker_provider.c @@ -127,15 +127,26 @@ EXPORT_API int sticker_provider_insert_data(sticker_provider_h provider_handle, CHECK_STICKER_FEATURE(); int ret; - if (!provider_handle || !data_handle || (data_handle->sticker_info_id > 0)) + int is_exist = 0; + + if (!provider_handle || !data_handle || (data_handle->sticker_info_id > 0) || !data_handle->uri) return STICKER_ERROR_INVALID_PARAMETER; + ret = sticker_dbus_check_file_exists(provider_handle->gdbus_connection, data_handle->uri, &is_exist); + if (ret != STICKER_ERROR_NONE) { + LOGE("Failed to check file exists : %d", ret); + return STICKER_ERROR_OPERATION_FAILED; + } + + if (is_exist) { + LOGE("Sticker already exists"); + return STICKER_ERROR_FILE_EXISTS; + } + ret = sticker_dbus_insert_sticker_info(provider_handle->gdbus_connection, data_handle); if (ret != STICKER_ERROR_NONE) { LOGE("Failed to insert sticker information : %d", ret); - if (ret == STICKER_CLIENT_ERROR_FILE_EXISTS) - return STICKER_ERROR_FILE_EXISTS; - else if (ret == STICKER_CLIENT_ERROR_NO_SUCH_FILE) + if (ret == STICKER_CLIENT_ERROR_NO_SUCH_FILE) return STICKER_ERROR_NO_SUCH_FILE; else return STICKER_ERROR_OPERATION_FAILED; diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index f30cd8e..8d0d604 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -145,6 +145,8 @@ static void _stickerd_client_dbus_method_call_handler(GDBusConnection *conn, con ret = stickerd_get_group_list_by_disp_type(parameters, &reply_body); } else if (g_strcmp0(method_name, "update_sticker_disp_type") == 0) { ret = stickerd_update_sticker_disp_type(parameters, &reply_body); + } else if (g_strcmp0(method_name, "check_file_exists") == 0) { + ret = stickerd_check_file_exists(parameters, &reply_body); } if (ret == STICKERD_SERVER_ERROR_NONE) { @@ -301,6 +303,11 @@ int stickerd_register_dbus_interface(void) " " " " " " + + " " + " " + " " + " " " " " "; @@ -1466,4 +1473,27 @@ int stickerd_update_sticker_disp_type(GVariant *parameters, GVariant **reply_bod } return ret; +} + +int stickerd_check_file_exists(GVariant *parameters, GVariant **reply_body) +{ + int ret; + int result; + char *uri = NULL; + + g_variant_get(parameters, "(&s)", &uri); + + ret = stickerd_db_check_file_exists(&result, uri); + if (ret != STICKERD_SERVER_ERROR_NONE) { + LOGE("Failed to get sticker count"); + return STICKERD_SERVER_ERROR_OPERATION_FAILED; + } + + *reply_body = g_variant_new("(i)", result); + if (*reply_body == NULL) { + LOGE("Failed to create reply_body"); + return STICKERD_SERVER_ERROR_OPERATION_FAILED; + } + + return ret; } \ No newline at end of file diff --git a/server/stickerd_data_manager.h b/server/stickerd_data_manager.h index e8e3a9e..d102573 100644 --- a/server/stickerd_data_manager.h +++ b/server/stickerd_data_manager.h @@ -46,6 +46,7 @@ int stickerd_get_sticker_info_by_keyword(GVariant *parameters, GVariant **reply_ int stickerd_get_sticker_info_by_display_type(GVariant *parameters, GVariant **reply_body); int stickerd_get_group_list_by_disp_type(GVariant *parameters, GVariant **reply_body); int stickerd_update_sticker_disp_type(GVariant *parameters, GVariant **reply_body); +int stickerd_check_file_exists(GVariant *parameters, GVariant **reply_body); #ifdef __cplusplus } diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index 3b54fb4..6680905 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -84,6 +84,7 @@ #define STICKER_DB_GET_RECORD_ID_BY_KEYWORD "SELECT sticker_info_id FROM sticker_keyword_info WHERE keyword = ? INTERSECT SELECT sticker_info_id from sticker_info WHERE app_id NOT IN (SELECT DISTINCT provider_id FROM sticker_whitelist_info WHERE provider_id NOT IN (SELECT provider_id FROM sticker_whitelist_info WHERE consumer_id = ?)) LIMIT ?, ?" #define STICKER_DB_GET_RECORD_ID_BY_DISP_TYPE "SELECT sticker_info_id FROM sticker_info WHERE display_type = ? AND app_id NOT IN (SELECT DISTINCT provider_id FROM sticker_whitelist_info WHERE provider_id NOT IN (SELECT provider_id FROM sticker_whitelist_info WHERE consumer_id = ?)) LIMIT ?, ?" #define STICKER_DB_GET_GROUP_LIST_BY_DISP_TYPE "SELECT DISTINCT group_name FROM sticker_info WHERE display_type = ? AND app_id NOT IN (SELECT DISTINCT provider_id FROM sticker_whitelist_info WHERE provider_id NOT IN (SELECT provider_id FROM sticker_whitelist_info WHERE consumer_id = ?))" +#define STICKER_DB_CHECK_FILE_EXISTS "SELECT EXISTS(SELECT 1 FROM sticker_info WHERE uri = ? LIMIT 1)" typedef enum { @@ -777,4 +778,42 @@ cleanup: sqlite3_close(db); return STICKERD_SERVER_ERROR_DB_FAILED; +} + +int stickerd_db_check_file_exists(int *result, char *uri) +{ + int ret; + sqlite3 *db = NULL; + sqlite3_stmt *stmt = NULL; + + db = _db_open(); + if (!db) + return STICKERD_SERVER_ERROR_DB_FAILED; + + ret = sqlite3_prepare_v2(db, STICKER_DB_CHECK_FILE_EXISTS, -1, &stmt, NULL); + if (ret != SQLITE_OK) { + LOGE("fail to check file exists : %s", sqlite3_errmsg(db)); + goto cleanup; + } + + sqlite3_bind_text(stmt, 1, uri, -1, SQLITE_TRANSIENT); + + ret = sqlite3_step(stmt); + if (ret == SQLITE_ERROR) { + LOGE("sqlite3_step() failed : ret(%d)", ret); + goto cleanup; + } + + *result = sqlite3_column_int(stmt, 0); + + sqlite3_finalize(stmt); + sqlite3_close(db); + + return STICKERD_SERVER_ERROR_NONE; + +cleanup: + sqlite3_finalize(stmt); + sqlite3_close(db); + + return STICKERD_SERVER_ERROR_DB_FAILED; } \ No newline at end of file diff --git a/server/stickerd_db_manager.h b/server/stickerd_db_manager.h index 2ef2fd5..2c260f4 100644 --- a/server/stickerd_db_manager.h +++ b/server/stickerd_db_manager.h @@ -58,6 +58,7 @@ int stickerd_db_get_keyword_list(GVariantBuilder *builder, char *app_id); int stickerd_db_get_sticker_count(int *count, char *app_id); int stickerd_db_get_record_id(sticker_info_db_type type, GList **id_list, void *data, char *app_id, int offset, int count); int stickerd_db_get_group_list_by_display_type(GVariantBuilder *builder, char *app_id, int disp_type); +int stickerd_db_check_file_exists(int *result, char *uri); #ifdef __cplusplus } -- 2.7.4 From d7a4f06eec2bd30fd450df1e063cbce05b2c3ef4 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 19 Mar 2020 11:09:27 +0900 Subject: [PATCH 04/16] Add a new API to delete sticker using URI Change-Id: I16e910c6135199018da711c7684a699ea36d9b44 --- client/sticker_dbus.c | 15 +++++++++++++++ client/sticker_dbus.h | 1 + include/sticker_provider.h | 16 ++++++++++++++++ provider/sticker_provider.c | 30 ++++++++++++++++++++++++++++++ server/stickerd_data_manager.c | 28 ++++++++++++++++++++++++++++ server/stickerd_data_manager.h | 1 + server/stickerd_db_manager.c | 40 ++++++++++++++++++++++++++++++++++++++++ server/stickerd_db_manager.h | 1 + 8 files changed, 132 insertions(+) diff --git a/client/sticker_dbus.c b/client/sticker_dbus.c index 6af66b4..13eef77 100644 --- a/client/sticker_dbus.c +++ b/client/sticker_dbus.c @@ -643,6 +643,21 @@ int sticker_dbus_delete_sticker_info(GDBusConnection *gdbus_connection, int reco return ret; } +int sticker_dbus_delete_sticker_info_by_uri(GDBusConnection *gdbus_connection, const char *uri) +{ + int ret; + GDBusMessage *reply = NULL; + + ret = _send_sync_message(gdbus_connection, g_variant_new("(s)", uri), &reply, "delete_sticker_info_by_uri"); + if (ret != STICKER_CLIENT_ERROR_NONE) + LOGE("failed to delete sticker info"); + + if (reply) + g_object_unref(reply); + + return ret; +} + int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_data_h sticker_data) { int ret; diff --git a/client/sticker_dbus.h b/client/sticker_dbus.h index 1982d46..610cfe1 100644 --- a/client/sticker_dbus.h +++ b/client/sticker_dbus.h @@ -51,6 +51,7 @@ int sticker_dbus_shutdown(GDBusConnection *gdbus_connection, int *server_watcher int sticker_dbus_insert_sticker_info(GDBusConnection *gdbus_connection, sticker_data_h sticker_data); int sticker_dbus_insert_sticker_info_by_json(GDBusConnection *gdbus_connection, const char *app_id, const char *json_path); int sticker_dbus_delete_sticker_info(GDBusConnection *gdbus_connection, int record_id); +int sticker_dbus_delete_sticker_info_by_uri(GDBusConnection *gdbus_connection, const char *uri); int sticker_dbus_update_sticker_info(GDBusConnection *gdbus_connection, sticker_data_h sticker_data); int sticker_dbus_get_sticker_info_by_record_id(GDBusConnection *gdbus_connection, sticker_data_h sticker_data, int record_id); int sticker_dbus_get_group_list(GDBusConnection *gdbus_connection, const char *app_id, GList **group_list); diff --git a/include/sticker_provider.h b/include/sticker_provider.h index e7367b3..8271ad7 100644 --- a/include/sticker_provider.h +++ b/include/sticker_provider.h @@ -201,6 +201,22 @@ int sticker_provider_update_data(sticker_provider_h provider_handle, sticker_dat int sticker_provider_delete_data(sticker_provider_h provider_handle, sticker_data_h data_handle); /** + * @brief Deletes a sticker data in the sticker database using URI. + * @since_tizen 5.5 + * @param[in] provider_handle The sticker provider handle + * @param[in] uri The URI of the sticker data to be deleted + * @return 0 on success, otherwise a negative error value + * @retval #STICKER_ERROR_NONE Successful + * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported + * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed + * @retval #STICKER_ERROR_NO_SUCH_FILE No such file + * @see sticker_provider_insert_data() + * @see sticker_provider_delete_data() + */ +int sticker_provider_delete_data_by_uri(sticker_provider_h provider_handle, const char *uri); + +/** * @brief Gets the count of stickers stored by the provider application. * @since_tizen 5.5 * @param[in] provider_handle The sticker provider handle diff --git a/provider/sticker_provider.c b/provider/sticker_provider.c index 7dfca80..98f1005 100644 --- a/provider/sticker_provider.c +++ b/provider/sticker_provider.c @@ -364,4 +364,34 @@ cleanup: g_variant_iter_free(id_iter); return ret; +} + +EXPORT_API int sticker_provider_delete_data_by_uri(sticker_provider_h provider_handle, const char *uri) +{ + CHECK_STICKER_FEATURE(); + + int ret; + int is_exist = 0; + + if (!provider_handle || !uri) + return STICKER_ERROR_INVALID_PARAMETER; + + ret = sticker_dbus_check_file_exists(provider_handle->gdbus_connection, uri, &is_exist); + if (ret != STICKER_ERROR_NONE) { + LOGE("Failed to check file exists : %d", ret); + return STICKER_ERROR_OPERATION_FAILED; + } + + if (!is_exist) { + LOGE("Sticker does not exist"); + return STICKER_ERROR_NO_SUCH_FILE; + } + + ret = sticker_dbus_delete_sticker_info_by_uri(provider_handle->gdbus_connection, uri); + if (ret != STICKER_ERROR_NONE) { + LOGE("Failed to delete sticker information : %d", ret); + return STICKER_ERROR_OPERATION_FAILED; + } + + return STICKER_ERROR_NONE; } \ No newline at end of file diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index 8d0d604..4f0b5b2 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -109,6 +109,8 @@ static void _stickerd_client_dbus_method_call_handler(GDBusConnection *conn, con ret = stickerd_insert_sticker_info_by_json(parameters, &reply_body, sender); } else if (g_strcmp0(method_name, "delete_sticker_info") == 0) { ret = stickerd_del_sticker_info(parameters, &reply_body); + } else if (g_strcmp0(method_name, "delete_sticker_info_by_uri") == 0) { + ret = stickerd_del_sticker_info_by_uri(parameters, &reply_body); } else if (g_strcmp0(method_name, "update_sticker_type") == 0) { ret = stickerd_update_sticker_type(parameters, &reply_body); } else if (g_strcmp0(method_name, "update_sticker_uri") == 0) { @@ -194,6 +196,10 @@ int stickerd_register_dbus_interface(void) " " " " + " " + " " + " " + " " " " " " @@ -800,6 +806,28 @@ int stickerd_del_sticker_info(GVariant *parameters, GVariant **reply_body) return ret; } +int stickerd_del_sticker_info_by_uri(GVariant *parameters, GVariant **reply_body) +{ + int ret; + char *uri = NULL; + + *reply_body = g_variant_new("()"); + if (*reply_body == NULL) { + LOGE("Failed to create reply_body"); + return STICKERD_SERVER_ERROR_OPERATION_FAILED; + } + + g_variant_get(parameters, "(&s)", &uri); + + ret = stickerd_db_delete_sticker_info_by_uri(uri); + if (ret != STICKERD_SERVER_ERROR_NONE) { + LOGE("Failed to delete sticker info"); + return STICKERD_SERVER_ERROR_OPERATION_FAILED; + } + + return ret; +} + int stickerd_update_sticker_type(GVariant *parameters, GVariant **reply_body) { int ret; diff --git a/server/stickerd_data_manager.h b/server/stickerd_data_manager.h index d102573..e09e91d 100644 --- a/server/stickerd_data_manager.h +++ b/server/stickerd_data_manager.h @@ -28,6 +28,7 @@ int stickerd_register_dbus_interface(void); int stickerd_insert_sticker_info(GVariant *parameters, GVariant **reply_body); int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_body, const char *sender); int stickerd_del_sticker_info(GVariant *parameters, GVariant **reply_body); +int stickerd_del_sticker_info_by_uri(GVariant *parameters, GVariant **reply_body); int stickerd_update_sticker_type(GVariant *parameters, GVariant **reply_body); int stickerd_update_sticker_uri(GVariant *parameters, GVariant **reply_body); int stickerd_update_sticker_thumbnail(GVariant *parameters, GVariant **reply_body); diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index 6680905..52a177c 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -63,6 +63,7 @@ #define STICKER_DB_DELETE_STICKER_INFO "DELETE FROM sticker_info WHERE sticker_info_id = ?" #define STICKER_DB_DELETE_STICKER_KEYWORD_INFO "DELETE FROM sticker_keyword_info WHERE sticker_info_id = ?" +#define STICKER_DB_DELETE_STICKER_INFO_BY_URI "DELETE FROM sticker_info WHERE uri = ?" #define STICKER_DB_UPDATE_STICKER_TYPE "UPDATE sticker_info SET type = ?, date = DateTime('now','localtime') WHERE sticker_info_id = ?" #define STICKER_DB_UPDATE_STICKER_URI "UPDATE sticker_info SET uri = ?, date = DateTime('now','localtime') WHERE sticker_info_id = ?" @@ -426,6 +427,45 @@ cleanup: return STICKERD_SERVER_ERROR_DB_FAILED; } +int stickerd_db_delete_sticker_info_by_uri(char *uri) +{ + int ret; + sqlite3 *db = NULL; + sqlite3_stmt *stmt = NULL; + + db = _db_open(); + if (!db) + return STICKERD_SERVER_ERROR_DB_FAILED; + + ret = sqlite3_prepare_v2(db, STICKER_DB_DELETE_STICKER_INFO_BY_URI, -1, &stmt, NULL); + if (ret != SQLITE_OK) { + LOGE("fail to delete sticker information : %s", sqlite3_errmsg(db)); + goto cleanup; + } + + sqlite3_bind_text(stmt, 1, uri, -1, SQLITE_TRANSIENT); + + ret = sqlite3_step(stmt); + if (ret != SQLITE_OK && ret != SQLITE_DONE) { + LOGE("sqlite3_step() failed : ret(%d)", ret); + goto cleanup; + } else if (sqlite3_changes(db) == 0) { + LOGE("No changes to DB"); + goto cleanup; + } + + sqlite3_finalize(stmt); + sqlite3_close(db); + + return STICKERD_SERVER_ERROR_NONE; + +cleanup: + sqlite3_finalize(stmt); + sqlite3_close(db); + + return STICKERD_SERVER_ERROR_DB_FAILED; +} + int stickerd_db_update_sticker_info(int record_id, sticker_info_db_type type, void *data) { int ret; diff --git a/server/stickerd_db_manager.h b/server/stickerd_db_manager.h index 2c260f4..4a14e50 100644 --- a/server/stickerd_db_manager.h +++ b/server/stickerd_db_manager.h @@ -51,6 +51,7 @@ typedef struct { int stickerd_db_init(void); int stickerd_db_insert_sticker_info(int *record_id, sticker_info_db *sticker_info); int stickerd_db_delete_sticker_info(int record_id); +int stickerd_db_delete_sticker_info_by_uri(char *uri); int stickerd_db_update_sticker_info(int record_id, sticker_info_db_type type, void *data); int stickerd_db_get_sticker_info_by_record_id(int record_id, sticker_info_db *sticker_info); int stickerd_db_get_group_list(GVariantBuilder *builder, char *app_id); -- 2.7.4 From e8bc0cb40e08a9a6a8b32949909c7bbf1cf8c75f Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 19 Mar 2020 19:12:40 +0900 Subject: [PATCH 05/16] Modified to use the new API to delete sticker Change-Id: I4867a69a865bc291b30ef6b867cbc88bd780f7a6 --- receiver/src/sticker_info.cpp | 42 +++--------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/receiver/src/sticker_info.cpp b/receiver/src/sticker_info.cpp index 89aedfb..b71c149 100644 --- a/receiver/src/sticker_info.cpp +++ b/receiver/src/sticker_info.cpp @@ -126,46 +126,10 @@ void destroy_sticker_provider_handle(void) sticker_provider = NULL; } -static void _sticker_foreach_cb(sticker_data_h data_handle, void *user_data) -{ - int ret; - char *del_file = (char *)user_data; - sticker_data_uri_type_e type; - char *uri = NULL; - - if (!need_to_retrive) - return; - - ret = sticker_data_get_uri(data_handle, &type, &uri); - if (ret != STICKER_ERROR_NONE) - LOGE("Failed to get sticker uri"); - - int result = (string(uri)).find(del_file); - if (result >= 0) { - LOGI("Delete sticker (%s)", uri); - need_to_retrive = false; - - ret = sticker_provider_delete_data(sticker_provider, data_handle); - if (ret != STICKER_ERROR_NONE) - LOGE("Failed to delete sticker"); - } -} - void delete_sticker_data(const char *fileName) { int ret; - int offset = 0; - int count = 0; - int result = 0; - need_to_retrive = true; - - while (result == count && need_to_retrive) { - count = 20; - ret = sticker_provider_data_foreach_all(sticker_provider, offset, count, &result, _sticker_foreach_cb, (void *)fileName); - offset += result; - if (ret != STICKER_ERROR_NONE) { - LOGE("Failed to retrieve sticker"); - return; - } - } + ret = sticker_provider_delete_data_by_uri(sticker_provider, fileName); + if (ret != STICKER_ERROR_NONE) + LOGE("Failed to delete sticker. ret : %d", ret); } \ No newline at end of file -- 2.7.4 From 4d7cec539fecfe222d9c89bb9faae02b0396ec55 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Thu, 19 Mar 2020 19:14:19 +0900 Subject: [PATCH 06/16] Update package version to 0.1.23 Change-Id: I0c9b9a4745bdf1bcf01b645d3762a42060339973 --- 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 d36c513..cc07b17 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.22 +Version: 0.1.23 Release: 1 Group: Graphics & UI Framework/Input License: Apache-2.0 diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 6726d6d..b01d8c2 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 58558b88fb7aebee2a03722378bbbf31ca9aead9 Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 20 Mar 2020 14:56:40 +0900 Subject: [PATCH 07/16] Remove unused variable Change-Id: Iaa0a0b6744e091ab9c761363de5e1edcc21d27e0 --- receiver/src/sticker_info.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/receiver/src/sticker_info.cpp b/receiver/src/sticker_info.cpp index b71c149..57ace21 100644 --- a/receiver/src/sticker_info.cpp +++ b/receiver/src/sticker_info.cpp @@ -18,14 +18,10 @@ #include #include #include -#include #include "log.h" -using namespace std; - static sticker_provider_h sticker_provider = NULL; -static bool need_to_retrive = false; sticker_data_h set_sticker_data(sticker_data_uri_type_e type, const char* uri, const char* keyword, -- 2.7.4 From c55a6705b7f6f38b46ec00a749d23484b99538df Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 20 Mar 2020 15:36:15 +0900 Subject: [PATCH 08/16] Check battery charging status for sync condition Change-Id: I07450a60edef785e197bac03f85d3f13855465b8 Signed-off-by: Jihoon Kim --- receiver/src/main.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/receiver/src/main.cpp b/receiver/src/main.cpp index 9968b91..7a5e20d 100644 --- a/receiver/src/main.cpp +++ b/receiver/src/main.cpp @@ -48,6 +48,8 @@ static void app_control(app_control_h app_control, void *data) char* alarm_data = NULL; int res; + int battery_percentage = 0; + bool battery_charging = false; // operation int ret = app_control_get_operation(app_control, &operation); @@ -63,20 +65,30 @@ static void app_control(app_control_h app_control, void *data) 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"); - } + int ret = device_battery_is_charging(&battery_charging); + if (ret != DEVICE_ERROR_NONE) { + LOGW("No sync. Can't get battery charging status"); + goto cleanup; + } + + if (!battery_charging) { + LOGI("No sync due to no battery charging status"); + goto cleanup; + } + + ret = device_battery_get_percent(&battery_percentage); + if (ret != DEVICE_ERROR_NONE) { + LOGW("No sync. Failed to get battery percent. error : %d", ret); + goto cleanup; + } + + LOGI("battery percent : %d", battery_percentage); + if (battery_percentage >= MINIMUM_BATTERY) { + request_sticker_data("auto", "arsticker", "input"); + request_sticker_data("auto", "bitmoji", "input"); } else { - LOGW("Failed to get battery percent. error : %d", ret); + LOGI("No sync due to insufficient battery"); } goto cleanup; -- 2.7.4 From cccab67025622346c9643bd1fe8e0205593def7a Mon Sep 17 00:00:00 2001 From: InHong Han Date: Fri, 20 Mar 2020 13:11:25 +0900 Subject: [PATCH 09/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 10/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 11/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 12/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 13/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 14/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 15/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 16/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