#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);
#include <json-glib/json-glib.h>
#include <vconf.h>
#include <queue>
+#include <thumbnail_util.h>
#include "ft.h"
#include "log.h"
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");
+ }
}
}
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) {
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;
}
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()
}
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) {