summaryrefslogtreecommitdiff
path: root/src/media-thumbnail.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/media-thumbnail.c')
-rwxr-xr-xsrc/media-thumbnail.c103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c
index 0796bec..1030279 100755
--- a/src/media-thumbnail.c
+++ b/src/media-thumbnail.c
@@ -116,6 +116,71 @@ int thumbnail_request_save_to_file(const char *origin_path, media_thumb_type thu
return MEDIA_THUMB_ERROR_NONE;
}
+int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_path, int max_length, int *origin_width, int *origin_height)
+{
+ int err = -1;
+ int need_update_db = 0;
+ int width, height = 0;
+ media_thumb_info thumb_info;
+
+ if (origin_path == NULL || thumb_path == NULL) {
+ thumb_err("Invalid parameter");
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ }
+
+ if (origin_width == NULL || origin_height == NULL) {
+ thumb_err("Invalid parameter ( width or height )");
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!g_file_test
+ (origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+ thumb_err("Original path(%s) doesn't exist.", origin_path);
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ }
+
+ if (max_length <= 0) {
+ thumb_err("Length is invalid");
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ }
+
+ int store_type = -1;
+ store_type = _media_thumb_get_store_type_by_path(origin_path);
+
+ if ((store_type != THUMB_PHONE) && (store_type != THUMB_MMC)) {
+ thumb_err("origin path(%s) is invalid", origin_path);
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ }
+
+ thumb_err("Path : %s", origin_path);
+
+ err = _media_thumb_db_connect();
+ if (err < 0) {
+ thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
+ return MEDIA_THUMB_ERROR_DB;
+ }
+
+ err = _media_thumb_get_thumb_from_db_with_size(origin_path, thumb_path, max_length, &need_update_db, &width, &height);
+ if (err == 0) {
+ _media_thumb_db_disconnect();
+ return MEDIA_THUMB_ERROR_NONE;
+ }
+
+ /* Request for thumb file to the daemon "Thumbnail generator" */
+ err = _media_thumb_request(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, thumb_path, max_length, &thumb_info);
+ if (err < 0) {
+ thumb_err("_media_thumb_request failed : %d", err);
+ _media_thumb_db_disconnect();
+ return err;
+ }
+
+ *origin_width = thumb_info.origin_width;
+ *origin_height = thumb_info.origin_height;
+
+ _media_thumb_db_disconnect();
+ return MEDIA_THUMB_ERROR_NONE;
+}
+
int thumbnail_request_extract_all_thumbs(void)
{
int err = -1;
@@ -135,3 +200,41 @@ int thumbnail_request_extract_all_thumbs(void)
return MEDIA_THUMB_ERROR_NONE;
}
+int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, void *user_data)
+{
+ int err = -1;
+
+ if (origin_path == NULL) {
+ thumb_err("Invalid parameter");
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!g_file_test
+ (origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+ thumb_err("Original path(%s) doesn't exist.", origin_path);
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ }
+
+ thumbUserData *userData = (thumbUserData*)malloc(sizeof(thumbUserData));
+ userData->func = (ThumbFunc)func;
+ userData->user_data = user_data;
+
+ int store_type = -1;
+ store_type = _media_thumb_get_store_type_by_path(origin_path);
+
+ if ((store_type != THUMB_PHONE) && (store_type != THUMB_MMC)) {
+ thumb_err("origin path(%s) is invalid", origin_path);
+ return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+ }
+
+ thumb_err("Path : %s", origin_path);
+
+ /* Request for thumb file to the daemon "Thumbnail generator" */
+ err = _media_thumb_request_async(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, userData);
+ if (err < 0) {
+ thumb_err("_media_thumb_request failed : %d", err);
+ return err;
+ }
+
+ return MEDIA_THUMB_ERROR_NONE;
+}