Merge branch 'tizen_5.5' into tizen 02/234902/1 accepted/tizen/unified/20200601.051802 submit/tizen/20200529.121610 submit/tizen/20200529.122143
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 29 May 2020 12:10:44 +0000 (21:10 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 29 May 2020 12:10:51 +0000 (21:10 +0900)
Change-Id: Idb9a3cc77ba66a11e61957eea433c2d7f21d1653

packaging/capi-ui-sticker.spec
receiver/inc/config.h
receiver/inc/sticker_info.h
receiver/src/ft.cpp
receiver/src/main.cpp
receiver/src/sticker_info.cpp
receiver/tizen-manifest.xml

index 6020f8a..ffe6b82 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-ui-sticker
 Summary:    Sticker client library and daemon
-Version:    0.1.49
+Version:    0.1.51
 Release:    1
 Group:      Graphics & UI Framework/Input
 License:    Apache-2.0
index ecc3c10..bafee30 100644 (file)
@@ -31,4 +31,6 @@
 #define THUMBNAIL_WIDTH 96
 #define THUMBNAIL_HEIGHT 96
 
+#define STICKER_DIRECTORY "/opt/usr/share/sticker-data"
+
 #endif /* __CONFIG_H__ */
index 8deac5e..bad7dc3 100644 (file)
@@ -18,9 +18,9 @@
 #define __STICKER_INFO_H__
 
 void insert_sticker_data(const char *filepath, const char *keyword, const char *group, const char *desc, const char *thumbnail, const char *disp_type);
-int create_sticker_provider_handle(void);
+void create_sticker_provider_handle(void);
 void destroy_sticker_provider_handle(void);
 void delete_sticker_data(const char *fileName);
-void delete_all_bitmoji_stickers();
+void delete_all_stickers(const char *groupName);
 
 #endif /* __STICKER_INFO_H__ */
index 1ab77b0..ebf7e92 100644 (file)
@@ -67,7 +67,8 @@ using namespace std;
 enum {
     SYNC_START_RSP_SUCCESS = 1000,
     SYNC_START_RSP_NO_STICKER = 1001,
-    SYNC_START_RSP_BITMOJI_ALL_DELETE = 1002
+    SYNC_START_RSP_BITMOJI_ALL_DELETE = 1002,
+    SYNC_START_RSP_AREMOJI_ALL_DELETE = 1003
 };
 
 struct sap_info_s {
@@ -209,33 +210,30 @@ static void _on_transfer_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) {
-                char thumb_path[PATH_MAX];
-                char *data_path = NULL;
-                data_path = app_get_shared_data_path();
-                snprintf(thumb_path, sizeof(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();
-                }
+            char thumb_path[PATH_MAX];
+            char *data_path = NULL;
+            data_path = app_get_shared_data_path();
+            snprintf(thumb_path, sizeof(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();
+            }
 
-                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(), sticker_data.disp_type.c_str());
-                destroy_sticker_provider_handle();
+            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(), sticker_data.disp_type.c_str());
 
-                if (unlink(sticker_data.file_path.c_str()) == -1)
-                    LOGE("Failed to remove sticker file");
+            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");
-                }
+            if (!sticker_data.thumbnail_path.empty()) {
+                if (unlink(sticker_data.thumbnail_path.c_str()) == -1)
+                    LOGE("Failed to remove sticker thumbnail");
             }
         }
 
@@ -619,6 +617,7 @@ void conn_terminated(sap_peer_agent_h peer_agent,
     priv->socket = NULL;
 
     set_sync_progressing(FALSE);
+    send_message("sync_stop_result", "cancel");
     service_app_exit();
 }
 
@@ -658,6 +657,9 @@ static void send_sync_start_response(int result_code)
                 response_to_app = "success";
             break;
         }
+        case SYNC_START_RSP_AREMOJI_ALL_DELETE:
+            response_to_app = "success";
+            break;
         default:
             response_to_app = "unknown_error";
             break;
@@ -768,18 +770,15 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
             send_sync_start_response(result_code);
             if (current_request.category == string("bitmoji")) {
                 LOGD("Delete all bitmoji stickers");
-                if (create_sticker_provider_handle() == STICKER_ERROR_NONE) {
-                    delete_all_bitmoji_stickers();
-                    destroy_sticker_provider_handle();
-                }
+                delete_all_stickers("bitmoji");
             }
         } else {
             if (result_code == SYNC_START_RSP_BITMOJI_ALL_DELETE) {
                 LOGD("Delete all bitmoji stickers");
-                if (create_sticker_provider_handle() == STICKER_ERROR_NONE) {
-                    delete_all_bitmoji_stickers();
-                    destroy_sticker_provider_handle();
-                }
+                delete_all_stickers("bitmoji");
+            } else if (result_code == SYNC_START_RSP_AREMOJI_ALL_DELETE) {
+                LOGD("Delete all AR Emoji stickers");
+                delete_all_stickers("arsticker");
             }
 
             if (!process_request_queue()) {
@@ -832,11 +831,21 @@ on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned in
                     LOGD("Add file : %s, len : %d", file_name.c_str(), file_len);
                     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) {
-                        delete_sticker_data(file_name.c_str());
-                        destroy_sticker_provider_handle();
-                    }
+                    char *app_id = NULL;
+                    char file_path[PATH_MAX];
+                    char del_path[PATH_MAX];
+                    std::size_t found = file_name.find_last_of("/");
+                    string del_file_name = file_name.substr(found+1);
+                    char *data_path = app_get_shared_data_path();
+                    app_get_id(&app_id);
+                    snprintf(file_path, sizeof(file_path), "%s/%s", data_path, del_file_name.c_str());
+                    snprintf(del_path, sizeof(del_path), "%s/%s%s",STICKER_DIRECTORY, app_id, file_path);
+
+                    LOGD("Delete file : %s, len : %d", del_path, file_len);
+                    delete_sticker_data(del_path);
+
+                    if (app_id)
+                        free(app_id);
                 }
             }
         }
@@ -1188,6 +1197,7 @@ static void _on_device_status_changed(sap_device_status_e status,
     switch (status) {
         case SAP_DEVICE_STATUS_DETACHED:
             LOGD("device is not connected.");
+            send_message("sync_stop_result", "cancel");
             break;
         case SAP_DEVICE_STATUS_ATTACHED:
             LOGD("Attached calling find peer now");
index 34b9837..dc105d0 100644 (file)
@@ -29,6 +29,7 @@
 #include "log.h"
 #include "config.h"
 #include "receiver_preference.h"
+#include "sticker_info.h"
 
 using namespace std;
 
@@ -55,6 +56,8 @@ static bool app_create(void *data)
         }
     }
 
+    create_sticker_provider_handle();
+
     return true;
 }
 
@@ -241,6 +244,7 @@ static void app_terminate(void *data)
 {
     /* Release all resources. */
     LOGD("");
+    destroy_sticker_provider_handle();
     deinitialize_sap();
 }
 
index 2b59d57..650d880 100644 (file)
@@ -118,16 +118,14 @@ insert_sticker_data(const char *filepath, const char *keyword, const char *group
     }
 }
 
-int create_sticker_provider_handle(void)
+void create_sticker_provider_handle(void)
 {
     int ret;
     ret = sticker_provider_create(&sticker_provider);
     if (ret != STICKER_ERROR_NONE) {
         /* Error handling */
-        LOGE("Failed to create sticker provider");
+        LOGE("Failed to create sticker provider. ret : %d", ret);
     }
-
-    return ret;
 }
 
 void destroy_sticker_provider_handle(void)
@@ -144,23 +142,24 @@ void delete_sticker_data(const char *fileName)
         LOGE("Failed to delete sticker. ret : %d", ret);
 }
 
-static void _delete_all_bitmoji_stickers_cb(sticker_data_h data_handle, void *user_data)
+static void _delete_all_stickers_cb(sticker_data_h data_handle, void *user_data)
 {
     int ret;
-    char *group = NULL;
+    char *sticker_group = NULL;
+    char *del_group = (char *) user_data;
 
-    ret = sticker_data_get_group_name(data_handle, &group);
+    ret = sticker_data_get_group_name(data_handle, &sticker_group);
     if (ret != STICKER_ERROR_NONE)
         LOGE("Failed to get group name. ret : %d", ret);
 
-    if (strcmp(group, "bitmoji") == 0) {
+    if (strcmp(sticker_group, del_group) == 0) {
         ret = sticker_provider_delete_data(sticker_provider, data_handle);
         if (ret != STICKER_ERROR_NONE)
             LOGE("Failed to delete sticker. ret : %d", ret);
     }
 }
 
-void delete_all_bitmoji_stickers()
+void delete_all_stickers(const char *groupName)
 {
     int ret;
     int total_cnt;
@@ -170,7 +169,7 @@ void delete_all_bitmoji_stickers()
     if (ret != STICKER_ERROR_NONE)
         LOGE("Failed to get sticker count. ret : %d", ret);
 
-    ret = sticker_provider_data_foreach_all(sticker_provider, 0, total_cnt, &result, _delete_all_bitmoji_stickers_cb, NULL);
+    ret = sticker_provider_data_foreach_all(sticker_provider, 0, total_cnt, &result, _delete_all_stickers_cb, (void *)groupName);
     if (ret != STICKER_ERROR_NONE)
         LOGE("Failed to retrieve all sticker data. ret : %d", ret);
 }
\ No newline at end of file
index 4eeb56e..843df8c 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns="http://tizen.org/ns/packages" api-version="5.5" package="org.tizen.sticker-receiver" version="1.0.49">
+<manifest xmlns="http://tizen.org/ns/packages" api-version="5.5" package="org.tizen.sticker-receiver" version="1.0.51">
         <profile name="wearable" />
         <service-application appid="org.tizen.sticker-receiver" exec="sticker-receiver" type="capp" multiple="false" taskmanage="false" nodisplay="true" launch_mode="single">
             <label>sticker-receiver</label>