Improve log
[platform/core/uifw/capi-ui-sticker.git] / receiver / src / sticker_info.cpp
index 2b59d57..4ef95b4 100644 (file)
@@ -35,14 +35,14 @@ int len, const char* group, const char* thumbnail, const char* description, stic
     ret = sticker_data_create(&sticker_data);
     if (ret != STICKER_ERROR_NONE) {
         /* Error handling */
-        LOGE("Failed to create sticker data");
+        STLOGE("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 */
-        LOGE("Failed to set uri");
+        STLOGE("Failed to set uri");
     }
 
     //for (int i = 0; i < len; i++)
@@ -51,7 +51,7 @@ int len, const char* group, const char* thumbnail, const char* description, stic
         ret = sticker_data_add_keyword(sticker_data, keyword);
         if (ret != STICKER_ERROR_NONE) {
             /* Error handling */
-            LOGE("Failed to add keyword");
+            STLOGE("Failed to add keyword");
         }
     }
 
@@ -59,7 +59,7 @@ int len, const char* group, const char* thumbnail, const char* description, stic
     ret = sticker_data_set_group_name(sticker_data, group);
     if (ret != STICKER_ERROR_NONE) {
         /* Error handling */
-        LOGE("Failed to set group name");
+        STLOGE("Failed to set group name");
     }
 
     /* Sets the thumbnail local path of the sticker */
@@ -67,7 +67,7 @@ int len, const char* group, const char* thumbnail, const char* description, stic
         ret = sticker_data_set_thumbnail(sticker_data, thumbnail);
         if (ret != STICKER_ERROR_NONE) {
             /* Error handling */
-            LOGE("Failed to set thumbnail");
+            STLOGE("Failed to set thumbnail");
         }
     }
 
@@ -75,14 +75,14 @@ int len, const char* group, const char* thumbnail, const char* description, stic
     ret = sticker_data_set_description(sticker_data, description);
     if (ret != STICKER_ERROR_NONE) {
         /* Error handling */
-        LOGE("Failed to set description");
+        STLOGE("Failed to set description");
     }
 
     /* Sets the display type of the sticker.*/
     ret = sticker_data_set_display_type(sticker_data, disp_type);
     if (ret != STICKER_ERROR_NONE) {
         /* Error handling */
-        LOGE("Failed to set display type");
+        STLOGE("Failed to set display type");
     }
 
     return sticker_data;
@@ -104,30 +104,28 @@ 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) {
-        LOGE("Failed to insert data. error code : %x. message : %s", ret, get_error_message(ret));
+        STLOGE("Failed to insert data. error code : %x. message : '%s'", ret, get_error_message(ret));
     }
     else {
-        LOGI("Succeeded to insert data");
+        STLOGI("Succeeded to insert data");
     }
 
     /* Destroys a sticker data handle */
     ret = sticker_data_destroy(data_handle);
     if (ret != STICKER_ERROR_NONE) {
         /* Error handling */
-        LOGE("Failed to destroy sticker data");
+        STLOGE("Failed to destroy sticker data");
     }
 }
 
-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");
+        STLOGE("Failed to create sticker provider. error code : 0x%X, message : '%s'", ret, get_error_message(ret));
     }
-
-    return ret;
 }
 
 void destroy_sticker_provider_handle(void)
@@ -141,26 +139,27 @@ void delete_sticker_data(const char *fileName)
     int ret;
     ret = sticker_provider_delete_data_by_uri(sticker_provider, fileName);
     if (ret != STICKER_ERROR_NONE)
-        LOGE("Failed to delete sticker. ret : %d", ret);
+        STLOGE("Failed to delete sticker. error code : 0x%X, message : '%s'", ret, get_error_message(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);
+        STLOGE("Failed to get group name. error code : 0x%X, message : '%s'", ret, get_error_message(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);
+            STLOGE("Failed to delete sticker. error code : 0x%X, message : '%s'", ret, get_error_message(ret));
     }
 }
 
-void delete_all_bitmoji_stickers()
+bool delete_all_stickers(const char *groupName)
 {
     int ret;
     int total_cnt;
@@ -168,9 +167,11 @@ void delete_all_bitmoji_stickers()
 
     ret = sticker_provider_get_sticker_count(sticker_provider, &total_cnt);
     if (ret != STICKER_ERROR_NONE)
-        LOGE("Failed to get sticker count. ret : %d", ret);
+        STLOGE("Failed to get sticker count. error code : 0x%X, message : '%s'", ret, get_error_message(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
+        STLOGE("Failed to retrieve all sticker data. error code : 0x%X, message : '%s'", ret, get_error_message(ret));
+
+    return (ret == STICKER_ERROR_NONE);
+}