From: InHong Han Date: Fri, 27 Mar 2020 07:44:07 +0000 (+0900) Subject: Support to create thumbnail of the sticker X-Git-Tag: submit/tizen_5.5/20200330.104023~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=77471f8541f0a8b44e9e702f5122a5429d98d244;p=platform%2Fcore%2Fuifw%2Fcapi-ui-sticker.git Support to create thumbnail of the sticker Change-Id: I78df10b6422fe225910870640381ecd2cdead1fa --- diff --git a/packaging/capi-ui-sticker.spec b/packaging/capi-ui-sticker.spec index ee59659..4d158b4 100644 --- a/packaging/capi-ui-sticker.spec +++ b/packaging/capi-ui-sticker.spec @@ -32,6 +32,7 @@ BuildRequires: pkgconfig(capi-appfw-alarm) BuildRequires: pkgconfig(capi-system-device) BuildRequires: pkgconfig(sap-client-stub-api) BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(capi-media-thumbnail-util) BuildRequires: hash-signer Requires(post): signing-client diff --git a/receiver/CMakeLists.txt b/receiver/CMakeLists.txt index 4a875d9..49b6d42 100644 --- a/receiver/CMakeLists.txt +++ b/receiver/CMakeLists.txt @@ -22,6 +22,7 @@ pkg_check_modules(pkgs_test REQUIRED sap-client-stub-api json-glib-1.0 vconf + capi-media-thumbnail-util ) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/receiver/inc) diff --git a/receiver/inc/config.h b/receiver/inc/config.h index 88eee4d..454bd5d 100644 --- a/receiver/inc/config.h +++ b/receiver/inc/config.h @@ -28,4 +28,7 @@ #define MINIMUM_BATTERY 15 +#define THUMBNAIL_WIDTH 96 +#define THUMBNAIL_HEIGHT 96 + #endif /* __CONFIG_H__ */ diff --git a/receiver/inc/sticker_data.h b/receiver/inc/sticker_data.h index 97f82cc..2989c2b 100644 --- a/receiver/inc/sticker_data.h +++ b/receiver/inc/sticker_data.h @@ -32,6 +32,7 @@ struct sticker_info { string keyword; string disp_type; string description; + string thumbnail_path; }; #endif /* __STICKER_DATA_H__ */ diff --git a/receiver/inc/sticker_info.h b/receiver/inc/sticker_info.h index 2e20ad8..3a70556 100644 --- a/receiver/inc/sticker_info.h +++ b/receiver/inc/sticker_info.h @@ -17,7 +17,7 @@ #ifndef __STICKER_INFO_H__ #define __STICKER_INFO_H__ -void insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc); +void insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc, const char *thumbnail); int create_sticker_provider_handle(void); void destroy_sticker_provider_handle(void); void delete_sticker_data(const char *fileName); diff --git a/receiver/src/ft.cpp b/receiver/src/ft.cpp index 8f81c0a..8aa293f 100644 --- a/receiver/src/ft.cpp +++ b/receiver/src/ft.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "ft.h" #include "log.h" @@ -157,11 +158,31 @@ static void _on_send_completed(sap_file_transaction_h file_transaction, else { LOGI("Succeed to change permission : %s", sticker_data.file_path.c_str()); if (create_sticker_provider_handle() == STICKER_ERROR_NONE) { - insert_sticker_data(sticker_data.file_path.c_str(), sticker_data.keyword.c_str(), sticker_data.group.c_str(), sticker_data.description.c_str()); - destroy_sticker_provider_handle(); + char thumb_path[PATH_MAX]; + char *data_path = NULL; + data_path = app_get_shared_data_path(); + sprintf(thumb_path, "%s/thumbnail/%s", data_path, incoming_file_name.c_str()); + sticker_data.thumbnail_path = string(thumb_path); + + if (data_path) + free(data_path); + + int ret = thumbnail_util_extract_to_file(sticker_data.file_path.c_str(), THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, sticker_data.thumbnail_path.c_str()); + if (ret != THUMBNAIL_UTIL_ERROR_NONE) { + LOGE("Failed to create thumbnail. msg : %s", get_error_message(ret)); + sticker_data.thumbnail_path.clear(); + } else { + insert_sticker_data(sticker_data.file_path.c_str(), sticker_data.keyword.c_str(), sticker_data.group.c_str(), sticker_data.description.c_str(), sticker_data.thumbnail_path.c_str()); + destroy_sticker_provider_handle(); + } if (unlink(sticker_data.file_path.c_str()) == -1) LOGE("Failed to remove sticker file"); + + if (!sticker_data.thumbnail_path.empty()) { + if (unlink(sticker_data.thumbnail_path.c_str()) == -1) + LOGE("Failed to remove sticker thumbnail"); + } } } @@ -244,7 +265,9 @@ void accept_file() sprintf(file_path, "%s/%s", data_path, incoming_file_name.c_str()); LOGI("Receive filepath : %s", file_path); sticker_data.file_path = string(file_path); - free(data_path); + + if (data_path) + free(data_path); ret = sap_file_transfer_receive(priv_data.file_socket, file_path); switch(ret) { @@ -309,6 +332,19 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty return result; } +static int _create_directory(const char *path) +{ + if (access(path, F_OK) == 0) + return 0; + + if (mkdir(path, 0755) == -1) { + LOGE("directory create error"); + return -1; + } + + return 0; +} + void request_sticker_feature() { JsonObject *j_object = NULL; @@ -335,6 +371,14 @@ void request_sticker_feature() } json_object_unref(j_object); + + char thumb_path[PATH_MAX]; + char *data_path = NULL; + data_path = app_get_shared_data_path(); + sprintf(thumb_path, "%s/thumbnail", data_path); + + if (_create_directory(thumb_path) != 0) + LOGE("Failed to create thumbnail directory"); } void reject_file() diff --git a/receiver/src/sticker_data.cpp b/receiver/src/sticker_data.cpp index bd94ee5..df0792b 100644 --- a/receiver/src/sticker_data.cpp +++ b/receiver/src/sticker_data.cpp @@ -33,4 +33,5 @@ void sticker_info::reset() keyword.clear(); disp_type.clear(); description.clear(); + thumbnail_path.clear(); } \ No newline at end of file diff --git a/receiver/src/sticker_info.cpp b/receiver/src/sticker_info.cpp index 16ca72e..38c9709 100644 --- a/receiver/src/sticker_info.cpp +++ b/receiver/src/sticker_info.cpp @@ -82,12 +82,12 @@ int len, const char* group, const char* thumbnail, const char* description) } void -insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc) +insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc, const char *thumbnail) { sticker_data_h data_handle; int ret; - data_handle = set_sticker_data(STICKER_DATA_URI_LOCAL_PATH, filepath, keyword, 1, group, NULL, desc); + data_handle = set_sticker_data(STICKER_DATA_URI_LOCAL_PATH, filepath, keyword, 1, group, thumbnail, desc); ret = sticker_provider_insert_data(sticker_provider, data_handle); if (ret != STICKER_ERROR_NONE) { diff --git a/receiver/tizen-manifest.xml b/receiver/tizen-manifest.xml index 1d23be5..27a1454 100644 --- a/receiver/tizen-manifest.xml +++ b/receiver/tizen-manifest.xml @@ -13,6 +13,7 @@ http://developer.samsung.com/tizen/privilege/accessoryprotocol http://tizen.org/privilege/content.write http://tizen.org/privilege/mediastorage + http://tizen.org/privilege/externalstorage http://tizen.org/privilege/appdir.shareddata http://tizen.org/privilege/alarm.set http://tizen.org/privilege/alarm.get