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);
+void delete_sticker_data(const char *fileName);
#endif /* __STICKER_INF_H__ */
string file_name = string(json_filename ? json_filename : "");
if (file_len > 0) {
- LOGD("fileName : %s, len : %d", file_name.c_str(), file_len);
+ LOGD("Add file : %s, len : %d", file_name.c_str(), file_len);
total_file_count++;
} else {
- // Delete sticker
- LOGD("fileName : %s, len : %d", file_name.c_str(), file_len);
+ 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();
+ }
}
}
}
#include <app_common.h>
#include <stdio.h>
#include <stdlib.h>
+#include <iostream>
#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,
sticker_provider_destroy(sticker_provider);
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;
+ }
+ }
+}
\ No newline at end of file