From 548d71a5e1edeabd2dcdc45efbbd457ae4a56970 Mon Sep 17 00:00:00 2001 From: Jiansong Jin Date: Fri, 31 Aug 2012 15:27:11 +0900 Subject: [PATCH] Modify media-content CAPI Change-Id: Iffef5c925a9a83cac9e2d7ef4782430b6a4a26f6 --- CMakeLists.txt | 1 - include/data/gl-data.h | 2 ++ include/util/gl-strings.h | 4 ++-- include/util/gl-util.h | 3 +-- packaging/org.tizen.gallery.spec | 3 +-- src/data/gl-data.c | 19 +++++++++++++++++++ src/data/gl-local-data.c | 3 +-- src/features/gl-gridview.c | 33 ++++++++++++++++++++++++++------ src/util/gl-ui-util.c | 10 ++++++++++ src/util/gl-util.c | 38 ------------------------------------- ug/ug-gallery-efl/CMakeLists.txt | 1 - ug/ug-gallery-efl/include/ge-data.h | 2 ++ ug/ug-gallery-efl/include/ge-util.h | 4 +++- ug/ug-gallery-efl/src/ge-data.c | 19 +++++++++++++++++++ ug/ug-gallery-efl/src/ge-gridview.c | 33 ++++++++++++++++++++++++++------ ug/ug-gallery-efl/src/ge-util.c | 37 ------------------------------------ 16 files changed, 114 insertions(+), 98 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b2b3f7..76c26e7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,6 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/features) INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED - media-thumbnail capi-content-media-content drm-client ui-gadget-1 diff --git a/include/data/gl-data.h b/include/data/gl-data.h index 95c8774..eee5d9f 100755 --- a/include/data/gl-data.h +++ b/include/data/gl-data.h @@ -138,6 +138,8 @@ bool _gl_data_is_default_album(const char *match_folder, gl_album_s *album); int gl_db_free_cluster(gl_cluster *gcluster); int _gl_data_get_item_by_fullpath(void *data, char *path, gl_media_s **mitem); int _gl_data_delete_media(void *data, gl_media_s *media_item); +int _gl_data_create_thumb(gl_item *gitem, media_thumbnail_completed_cb callback, + void *user_data); #ifdef _cplusplus } diff --git a/include/util/gl-strings.h b/include/util/gl-strings.h index 3c98d54..af42a2c 100755 --- a/include/util/gl-strings.h +++ b/include/util/gl-strings.h @@ -42,8 +42,8 @@ extern "C" #ifdef _USE_ROTATE_BG #define GL_STR_MORE dgettext("sys_string", "IDS_COM_BODY_MORE") -#define GL_STR_ROTATE_LEFT _("Rotate left") -#define GL_STR_ROTATE_RIGHT _("Rotate right") +#define GL_STR_ROTATE_LEFT _("IDS_MEDIABR_OPT_ROTATE_LEFT") +#define GL_STR_ROTATE_RIGHT _("IDS_MEDIABR_OPT_ROTATE_RIGHT") #define GL_STR_ROTATING _("Rotating") #define GL_STR_ROTATED _("Rotated") #endif diff --git a/include/util/gl-util.h b/include/util/gl-util.h index 66ac07b..84664ea 100755 --- a/include/util/gl-util.h +++ b/include/util/gl-util.h @@ -21,7 +21,7 @@ #include "gallery.h" #define GL_FILE_EXISTS(path) \ - ((1 == ecore_file_exists(path)) && (ecore_file_size(path) > 0)) + (path && (1 == ecore_file_exists(path)) && (ecore_file_size(path) > 0)) #define GL_IF_DEL_TIMER(timer) if(timer){ecore_timer_del(timer); timer = NULL;} #define GL_IF_DEL_IDLER(idler) if(idler){ecore_idler_del(idler); idler = NULL;} @@ -132,6 +132,5 @@ int gl_pop_to_ctrlbar_ly(void *data, bool b_update_albums_list); int gl_play_vibration(void *data); char *_gl_get_duration_string(unsigned int v_dur); -int _gl_get_thumb(void *data, const char *file_path, char **thumb_path); #endif /* _GL_UTIL_H_ */ diff --git a/packaging/org.tizen.gallery.spec b/packaging/org.tizen.gallery.spec index bc7480b..8fce5c4 100755 --- a/packaging/org.tizen.gallery.spec +++ b/packaging/org.tizen.gallery.spec @@ -4,7 +4,7 @@ Name: org.tizen.gallery Summary: org.tizen.gallery UX -Version: 1.1.30 +Version: 1.1.31 Release: 1 Group: Applications License: Flora Software License @@ -12,7 +12,6 @@ Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: gettext-tools BuildRequires: edje-tools -BuildRequires: pkgconfig(media-thumbnail) BuildRequires: pkgconfig(capi-content-media-content) BuildRequires: pkgconfig(drm-client) BuildRequires: pkgconfig(ui-gadget-1) diff --git a/src/data/gl-data.c b/src/data/gl-data.c index faa2e8a..680a55b 100755 --- a/src/data/gl-data.c +++ b/src/data/gl-data.c @@ -1546,3 +1546,22 @@ int _gl_data_delete_media(void *data, gl_media_s *media_item) return ret; } +/* Creates a thumbnail image for given the media, asynchronously */ +int _gl_data_create_thumb(gl_item *gitem, media_thumbnail_completed_cb callback, + void *user_data) +{ + GL_CHECK_VAL(gitem, -1); + GL_CHECK_VAL(gitem->item, -1); + GL_CHECK_VAL(gitem->item->media_h, -1); + int ret = -1; + gl_dbg("File[%s]", gitem->item->file_url); + + ret = media_info_create_thumbnail(gitem->item->media_h, callback, + user_data); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + gl_dbgE("Failed to create thumbnail!"); + return -1; + } + return 0; +} + diff --git a/src/data/gl-local-data.c b/src/data/gl-local-data.c index 64480f5..1ff3457 100755 --- a/src/data/gl-local-data.c +++ b/src/data/gl-local-data.c @@ -800,12 +800,11 @@ int _gl_local_data_move_media(gl_media_s *mitem, const char *dst) GL_CHECK_VAL(mitem, -1); GL_CHECK_VAL(mitem->media_h, -1); - if (media_info_move_media_to_db(mitem->media_h, dst) != MEDIA_CONTENT_ERROR_NONE) { + if (media_info_move_to_db(mitem->media_h, dst) != MEDIA_CONTENT_ERROR_NONE) { gl_dbgE("Move media thumbnail failed!"); return -1; } - gl_dbgW("Checkme: use correct api!"); return 0; } diff --git a/src/features/gl-gridview.c b/src/features/gl-gridview.c index 8b1ca97..865f963 100755 --- a/src/features/gl-gridview.c +++ b/src/features/gl-gridview.c @@ -96,6 +96,25 @@ _gl_grid_shrink_resp_cb(void *data, Evas_Object *obj, } +static void __gl_grid_thumb_created_cb(media_content_error_e error, + const char *path, void *user_data) +{ + GL_CHECK(user_data); + gl_item *gitem = (gl_item *)user_data; + GL_CHECK(gitem->item); + + if (GL_FILE_EXISTS(path)) { + gl_dbg("Update item with new thumb path[%s]", path); + /* Update thumb path */ + if (gitem->item->thumb_url) + free(gitem->item->thumb_url); + gitem->item->thumb_url = strdup(path); + elm_gengrid_item_update(gitem->elm_item); + } else { + gl_dbgE("Invalid thumb path!"); + } +} + static Evas_Object *__gl_grid_get_content(void *data, Evas_Object *obj, const char *part) { GL_CHECK_NULL(part); @@ -137,14 +156,16 @@ static Evas_Object *__gl_grid_get_content(void *data, Evas_Object *obj, const ch #endif } } else { - int ret = -1; - ret = _gl_get_thumb(ad, gitem->item->file_url, - &gitem->item->thumb_url); /* Use default image */ - if (ret < 0) - path = GL_DEFAULT_THUMB_ICON; - else + if (GL_FILE_EXISTS(gitem->item->thumb_url)) { path = gitem->item->thumb_url; + } else { + path = GL_DEFAULT_THUMB_ICON; + if (GL_FILE_EXISTS(gitem->item->file_url)) + _gl_data_create_thumb(gitem, + __gl_grid_thumb_created_cb, + gitem); + } } if (gitem->item->type == MEDIA_CONTENT_TYPE_VIDEO) { diff --git a/src/util/gl-ui-util.c b/src/util/gl-ui-util.c index e13e09c..da74d95 100755 --- a/src/util/gl-ui-util.c +++ b/src/util/gl-ui-util.c @@ -587,6 +587,15 @@ static void _gl_ui_selall_check_changed(void *data, Evas_Object *obj, gl_dbgE("Invalid item data!"); continue; } + + if (album->checked == state){ + /* Get next item */ + next_it = elm_gengrid_item_next_get(first_it); + first_it = next_it; + album = NULL; + continue; + } + /* Update checkbox state */ album->checked = state; /* Update selected list */ @@ -608,6 +617,7 @@ static void _gl_ui_selall_check_changed(void *data, Evas_Object *obj, } album = NULL; } + sel_all_cnt = item_cnt; } else { /* Get all medias count of current album */ item_cnt = ad->maininfo.medias_cnt; diff --git a/src/util/gl-util.c b/src/util/gl-util.c index f39dbb3..7c54653 100755 --- a/src/util/gl-util.c +++ b/src/util/gl-util.c @@ -20,7 +20,6 @@ #include #include #include -#include #include "gl-debug.h" #include "gallery.h" #include "gl-albums.h" @@ -2114,40 +2113,3 @@ char *_gl_get_duration_string(unsigned int v_dur) return dur_str; } -/* Fetch thumbnail from media-service, if it's invalid, generate new one */ -int _gl_get_thumb(void *data, const char *file_path, char **thumb_path) -{ - GL_CHECK_VAL(thumb_path, -1); - GL_CHECK_VAL(file_path, -1); - GL_CHECK_VAL(data, -1); - /* Return if thumbnail is valid */ - if (*thumb_path && ecore_file_exists(*thumb_path) && - (ecore_file_size(*thumb_path) > 0)) { - return 0; - } - - /* Free allocated memory first */ - if (*thumb_path) { - gl_dbgW("Wrong thumb path[%s]", *thumb_path); - free(*thumb_path); - *thumb_path = NULL; - } - gl_dbg("File[%s]", file_path); - - char *new_path = calloc(1, GL_FILE_PATH_LEN_MAX); - GL_CHECK_VAL(new_path, -1); - - /* Generate thumbnail via thumbnail-service */ - int ret = -1; - ret = thumbnail_request_from_db(file_path, new_path, - GL_FILE_PATH_LEN_MAX); - if (ret < 0) { - gl_dbgE("thumbnail_request_from_db failed!"); - return -1; - } - - *thumb_path = new_path; - gl_dbg("Request thumbnail[%s]", new_path); - return 0; -} - diff --git a/ug/ug-gallery-efl/CMakeLists.txt b/ug/ug-gallery-efl/CMakeLists.txt index 186eeb8..6b13ee3 100755 --- a/ug/ug-gallery-efl/CMakeLists.txt +++ b/ug/ug-gallery-efl/CMakeLists.txt @@ -52,7 +52,6 @@ pkg_check_modules(pkgs REQUIRED capi-appfw-application capi-content-media-content ui-gadget-1 - media-thumbnail drm-client ) diff --git a/ug/ug-gallery-efl/include/ge-data.h b/ug/ug-gallery-efl/include/ge-data.h index 55b3abf..6968ca5 100755 --- a/ug/ug-gallery-efl/include/ge-data.h +++ b/ug/ug-gallery-efl/include/ge-data.h @@ -54,6 +54,8 @@ int _ge_data_selected_list_remove(ge_item* gitem); int _ge_data_selected_list_finalize(void); bool _ge_data_is_default_album(const char *match_folder, ge_album_s *mcluster); bool _ge_data_is_root_path(const char *path); +int _ge_data_create_thumb(ge_item *gitem, media_thumbnail_completed_cb callback, + void *user_data); int _ge_data_init(ge_ugdata* ugd); int _ge_data_finalize(ge_ugdata* ugd); diff --git a/ug/ug-gallery-efl/include/ge-util.h b/ug/ug-gallery-efl/include/ge-util.h index 9eb4ba4..124e0b6 100755 --- a/ug/ug-gallery-efl/include/ge-util.h +++ b/ug/ug-gallery-efl/include/ge-util.h @@ -19,6 +19,9 @@ #include "gallery-efl.h" +#define GE_FILE_EXISTS(path) \ + (path && (1 == ecore_file_exists(path)) && (ecore_file_size(path) > 0)) + ge_item* _ge_get_current_item(void); void _ge_set_current_item(ge_item* gitem); int ge_reg_db_update_noti(ge_ugdata* ugd); @@ -29,7 +32,6 @@ void _ge_ug_iv_set(int ug_iv_state); ge_cluster* _ge_get_current_album(void); void _ge_set_current_album(ge_cluster* album_item); bool _ge_is_image_valid(void *data, char *filepath); -int _ge_get_thumb(const char *file_path, char **thumb_path); char *_ge_get_duration_string(unsigned int v_dur); #endif /* _GE_EXT_EXEC_H_ */ diff --git a/ug/ug-gallery-efl/src/ge-data.c b/ug/ug-gallery-efl/src/ge-data.c index ea553e8..a57adf1 100755 --- a/ug/ug-gallery-efl/src/ge-data.c +++ b/ug/ug-gallery-efl/src/ge-data.c @@ -923,6 +923,25 @@ bool _ge_data_is_root_path(const char *path) return false; } +/* Creates a thumbnail image for given the media, asynchronously */ +int _ge_data_create_thumb(ge_item *gitem, media_thumbnail_completed_cb callback, + void *user_data) +{ + GE_CHECK_VAL(gitem, -1); + GE_CHECK_VAL(gitem->item, -1); + GE_CHECK_VAL(gitem->item->media_h, -1); + int ret = -1; + ge_dbg("File[%s]", gitem->item->file_url); + + ret = media_info_create_thumbnail(gitem->item->media_h, callback, + user_data); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + ge_dbgE("Failed to create thumbnail!"); + return -1; + } + return 0; +} + int _ge_data_init(ge_ugdata* ugd) { ge_dbg("Connect to DB!"); diff --git a/ug/ug-gallery-efl/src/ge-gridview.c b/ug/ug-gallery-efl/src/ge-gridview.c index 2000eb6..905651e 100755 --- a/ug/ug-gallery-efl/src/ge-gridview.c +++ b/ug/ug-gallery-efl/src/ge-gridview.c @@ -283,6 +283,25 @@ static void _ge_grid_check_changed(void *data, Evas_Object *obj, void *event_inf } } +static void __ge_grid_thumb_created_cb(media_content_error_e error, + const char *path, void *user_data) +{ + GE_CHECK(user_data); + ge_item *gitem = (ge_item *)user_data; + GE_CHECK(gitem->item); + + if (GE_FILE_EXISTS(path)) { + ge_dbg("Update item with new thumb path[%s]", path); + /* Update thumb path */ + if (gitem->item->thumb_url) + free(gitem->item->thumb_url); + gitem->item->thumb_url = strdup(path); + elm_gengrid_item_update(gitem->elm_item); + } else { + ge_dbgE("Invalid thumb path!"); + } +} + static Evas_Object *__ge_grid_get_content(void *data, Evas_Object *obj, const char *part) { GE_CHECK_NULL(data); @@ -329,14 +348,16 @@ static Evas_Object *__ge_grid_get_content(void *data, Evas_Object *obj, const ch #endif } } else { - int ret = -1; - ret = _ge_get_thumb(gitem->item->file_url, - &gitem->item->thumb_url); /* Use default image */ - if (ret < 0) - path = GE_DEFAULT_THUMB_ICON; - else + if (GE_FILE_EXISTS(gitem->item->thumb_url)) { path = gitem->item->thumb_url; + } else { + path = GE_DEFAULT_THUMB_ICON; + if (GE_FILE_EXISTS(gitem->item->file_url)) + _ge_data_create_thumb(gitem, + __ge_grid_thumb_created_cb, + gitem); + } } if(gitem->item->type == MEDIA_CONTENT_TYPE_VIDEO){ diff --git a/ug/ug-gallery-efl/src/ge-util.c b/ug/ug-gallery-efl/src/ge-util.c index a7d9fda..c3e9f80 100755 --- a/ug/ug-gallery-efl/src/ge-util.c +++ b/ug/ug-gallery-efl/src/ge-util.c @@ -18,7 +18,6 @@ #include #include #include -#include #include "ge-debug.h" #include "ge-albums.h" #include "ge-gridview.h" @@ -273,42 +272,6 @@ bool _ge_is_image_valid(void *data, char *filepath) return true; } -/* Fetch thumbnail from media-service, if it's invalid, generate new one */ -int _ge_get_thumb(const char *file_path, char **thumb_path) -{ - GE_CHECK_VAL(thumb_path, -1); - GE_CHECK_VAL(file_path, -1); - /* Return if thumbnail is valid */ - if (*thumb_path && ecore_file_exists(*thumb_path) && - (ecore_file_size(*thumb_path) > 0)) { - return 0; - } - - /* Free allocated memory first */ - if (*thumb_path) { - ge_dbgW("Wrong thumb path[%s]", *thumb_path); - free(*thumb_path); - *thumb_path = NULL; - } - ge_dbg("File[%s]", file_path); - - char *new_path = calloc(1, GE_FILE_PATH_LEN_MAX); - GE_CHECK_VAL(new_path, -1); - - /* Generate thumbnail via thumbnail-service */ - int ret = -1; - ret = thumbnail_request_from_db(file_path, new_path, - GE_FILE_PATH_LEN_MAX); - if (ret < 0) { - ge_dbgE("thumbnail_request_from_db failed!"); - return -1; - } - - *thumb_path = new_path; - ge_dbg("Request thumbnail[%s]", new_path); - return 0; -} - /* Change int to char * of video duration, caller need to free the allocated memory */ char *_ge_get_duration_string(unsigned int v_dur) { -- 2.7.4