Removing depricated API for thumbnail creation. 13/293313/1 tizen tizen_8.0 tizen_8.0_m2_release
authorShivam Varshney/Core S/W Group /SRI-Delhi/Engineer/Samsung Electronics <shivam.v2@samsung.com>
Wed, 24 May 2023 09:14:16 +0000 (14:44 +0530)
committerShivam Varshney/Core S/W Group /SRI-Delhi/Engineer/Samsung Electronics <shivam.v2@samsung.com>
Wed, 24 May 2023 09:14:16 +0000 (14:44 +0530)
Change-Id: Idcd1321c37a6e8eff4e5be534d8e9d4c65117d10
Signed-off-by: Shivam Varshney/Core S/W Group /SRI-Delhi/Engineer/Samsung Electronics <shivam.v2@samsung.com>
inc/data/gl-data-type.h
inc/data/gl-data.h
src/2dview/gl-albums.c
src/2dview/gl-thumbs.c
src/2dview/gl-timeline.c
src/data/gl-data-type.c
src/data/gl-data.c

index b151ed1506703e4467773d6d6a657f07b6bfc48e..24bb91cf5f82b529673915d6e98a50a70faca397 100644 (file)
@@ -94,7 +94,6 @@ extern "C" {
                int mode;                               /* Show icon indicates different camera shot mode */
                char *ext;
                gl_store_type_e storage_type;   /* Storage type got from DB */
-               bool b_create_thumb;    /* Request DB to create thumbnail */
                bool check_state;               /* store check state */
                Elm_Object_Item *elm_item;      /*store item handle */
 
index c1783de0002338bd8499dc245ecd2a6c1bfbc48a..3e19927bd9061e1915afa8a9af94506440988b46 100644 (file)
@@ -68,10 +68,7 @@ extern "C" {
        bool _gl_data_is_screenshot_album(const char *match_folder,
                                                                          gl_album_s * album);
        bool _gl_data_is_camera_album(gl_album_s * album);
-       int _gl_data_create_thumb(gl_media_s * item,
-                                                         media_thumbnail_completed_cb callback,
-                                                         void *user_data);
-       int _gl_data_cancel_thumb(gl_media_s * item);
+       int _gl_data_create_thumb(gl_media_s * item);
        int _gl_data_save_selected_str_ids(void *data, Eina_List ** elist);
        int _gl_data_restore_selected(Eina_List * sel_ids, gl_item * gitem);
        bool _gl_data_check_selected_id(Eina_List * sel_id_list,
index 2c0347157ee3ed4342e529128911c91fce4605c1..1f5ed7022d5082b4ed01e04abd4fe828d0f9c94e 100755 (executable)
@@ -68,6 +68,7 @@ static void __gl_albums_realized(void *data, Evas_Object * obj, void *ei)
                 album->cluster->type == GL_STORE_T_MMC ||
                 album->cluster->type == GL_STORE_T_ALL)) {
                __gl_albums_create_thumb(album->cover, album);
+               elm_gengrid_item_update(album->item);
        }
 }
 
@@ -89,14 +90,6 @@ static void __gl_albums_unrealized(void *data, Evas_Object * obj, void *ei)
        GL_CHECK(album->cover);
        GL_CHECK(album->cover->item);
 
-       /* Checking for local files only */
-       if (album->cluster->type == GL_STORE_T_PHONE ||
-               album->cluster->type == GL_STORE_T_MMC ||
-               album->cluster->type == GL_STORE_T_ALL) {
-               if (album->cover->item->b_create_thumb) {
-                       _gl_data_cancel_thumb(album->cover->item);
-               }
-       }
 }
 
 /**
@@ -341,40 +334,6 @@ static char *__gl_albums_get_text(void *data, Evas_Object * obj,
        return strdup(buf);
 }
 
-/**
- * CB function is called when thumbnail is created for media
- * @param error
- * @param path
- * @param user_data
- */
-static void __gl_albums_create_thumb_cb(media_content_error_e error,
-                                                                               const char *path, void *user_data)
-{
-       GL_CHECK(user_data);
-       gl_album_data_s *album_data = (gl_album_data_s *) user_data;
-       GL_CHECK(album_data->album);
-       gl_appdata *ad = (gl_appdata *)_gl_get_app_data();
-       GL_CHECK(ad);
-       gl_cluster *album = album_data->album;
-       GL_FREE(album_data);
-       album->album_data = NULL;
-
-       if (gl_get_view_mode(ad) != GL_VIEW_ALBUMS &&
-               gl_get_view_mode(ad) != GL_VIEW_ALBUMS_EDIT &&
-               gl_get_view_mode(ad) != GL_VIEW_ALBUMS_SELECT) {
-               return;
-       }
-
-       if (error == MEDIA_CONTENT_ERROR_NONE && GL_FILE_EXISTS(path) &&
-               g_strcmp0(path, GL_ICON_DB_DEFAULT_THUMB)) {
-               GL_CHECK(album);
-               GL_CHECK(album->item);
-               elm_gengrid_item_update(album->item);
-       } else {
-               gl_sdbgE("[%d]Invalid path[%s]!", error, path);
-       }
-}
-
 /**
  * Sends request to create thumbnail for media
  * @param gitem : media item data
@@ -395,8 +354,7 @@ static int __gl_albums_create_thumb(gl_item * gitem, gl_cluster * album)
                GL_CHECK_VAL(album_data, -1);
                album_data->album = album;
                album->album_data = album_data;
-               _gl_data_create_thumb(gitem->item, __gl_albums_create_thumb_cb,
-                                                         album_data);
+               _gl_data_create_thumb(gitem->item);
                return 0;
        }
        return -1;
index f8fee7a7e1b28ed383191b54d885140799978963..b0d76bb37f710e2a33cf30f7711c81b9dafcbce7 100755 (executable)
@@ -151,6 +151,7 @@ static void __gl_thumbs_realized(void *data, Evas_Object * obj, void *ei)
                /* Use default image */
                if (!GL_FILE_EXISTS(gitem->item->thumb_url)) {
                        _gl_thumbs_create_thumb(gitem);
+                       elm_gengrid_item_update(gitem->elm_item);
                }
        }
 }
@@ -177,14 +178,6 @@ static void __gl_thumbs_unrealized(void *data, Evas_Object * obj, void *ei)
        gl_item *gitem = elm_object_item_data_get(it);
        GL_CHECK(gitem);
        GL_CHECK(gitem->item);
-       /* Checking for local files only */
-       if (gitem->store_type == GL_STORE_T_MMC ||
-               gitem->store_type == GL_STORE_T_ALL ||
-               gitem->store_type == GL_STORE_T_PHONE) {
-               if (gitem->item->b_create_thumb) {
-                       _gl_data_cancel_thumb(gitem->item);
-               }
-       }
 }
 
 /**
@@ -372,44 +365,6 @@ static void __gl_thumbs_check_changed(void *data, Evas_Object * obj,
 
 }
 
-/**
- * CB function is called when thumbnail is created for media
- * @param error : thumbnail server error type
- * @param path : thumbnail path
- * @param user_data : Thumb data
- */
-static void __gl_thumbs_create_thumb_cb(media_content_error_e error,
-                                                                               const char *path, void *user_data)
-{
-       GL_CHECK(user_data);
-       gl_thumb_data_s *thumb_data = (gl_thumb_data_s *) user_data;
-       gl_appdata *ad = (gl_appdata *)_gl_get_app_data();
-       GL_CHECK(ad);
-       gl_item *gitem = thumb_data->item;
-       GL_FREE(thumb_data);
-       GL_CHECK(gitem);
-       gitem->thumb_data = NULL;
-
-       if (gl_get_view_mode(ad) != GL_VIEW_THUMBS &&
-               gl_get_view_mode(ad) != GL_VIEW_THUMBS_EDIT &&
-               gl_get_view_mode(ad) != GL_VIEW_THUMBS_SELECT) {
-               return;
-       }
-
-       if (error == MEDIA_CONTENT_ERROR_NONE && GL_FILE_EXISTS(path) &&
-               g_strcmp0(path, GL_ICON_DB_DEFAULT_THUMB)) {
-               GL_CHECK(gitem);
-               GL_CHECK(gitem->item);
-               gl_dbg("Update item with new thumb path[%s]", path);
-               /* Update thumb path */
-               GL_FREEIF(gitem->item->thumb_url);
-               gitem->item->thumb_url = strdup(path);
-               elm_gengrid_item_update(gitem->elm_item);
-       } else {
-               gl_dbgE("[%d]Invalid path[%s]!", error, path);
-       }
-}
-
 /**
  * ends request to create thumbnail for media
  * @param gitem : item data
@@ -428,8 +383,7 @@ int _gl_thumbs_create_thumb(gl_item * gitem)
                GL_CHECK_VAL(thumb_data, -1);
                thumb_data->item = gitem;
                gitem->thumb_data = thumb_data;
-               _gl_data_create_thumb(gitem->item, __gl_thumbs_create_thumb_cb,
-                                                         thumb_data);
+               _gl_data_create_thumb(gitem->item);
                return 0;
        }
        return -1;
index 5b46370e47582480566da317aac408d398ac44c7..dcff4b6f4a628606ca9fbb57802f399fe581c298 100755 (executable)
@@ -1073,31 +1073,6 @@ Evas_Object *_gl_timeline_thumbs_get_content(void *data,
        return layout;
 }
 
-/**
- * thumbnail generation request CB
- * @param error : thumbnail server error code
- * @param path : thumbnail path
- * @param user_data : media data
- */
-static void __gl_timeline_thumbs_create_thumb_cb(media_content_error_e
-                                                                                                error, const char *path,
-                                                                                                void *user_data)
-{
-       GL_CHECK(user_data);
-       gl_media_s *thumb_data = (gl_media_s *) user_data;
-
-       thumb_data->b_create_thumb = false;
-       if (error == MEDIA_CONTENT_ERROR_NONE && GL_FILE_EXISTS(path) &&
-               g_strcmp0(path, GL_ICON_DB_DEFAULT_THUMB)) {
-               /* Update thumb path */
-               GL_FREEIF(thumb_data->thumb_url);
-               thumb_data->thumb_url = strdup(path);
-               elm_gengrid_item_update(thumb_data->elm_item);
-       } else {
-               gl_dbgE("[%d]Invalid path[%s]!", error, path);
-       }
-}
-
 /* Use file to create new thumb if possible */
 /**
  * send thumbnail creation request for media
@@ -1110,8 +1085,7 @@ int _gl_timeline_thumbs_create_thumb(gl_media_s * gitem)
        GL_CHECK_VAL(gitem->file_url, -1);
 
        if (GL_FILE_EXISTS(gitem->file_url)) {
-               _gl_data_create_thumb(gitem, __gl_timeline_thumbs_create_thumb_cb,
-                                                         gitem);
+               _gl_data_create_thumb(gitem);
                return 0;
        }
        return -1;
@@ -1142,6 +1116,7 @@ static void __gl_timeline_thumbs_realized(void *data, Evas_Object * obj,
                /* Use default image */
                if (!GL_FILE_EXISTS(gitem->thumb_url)) {
                        _gl_timeline_thumbs_create_thumb(gitem);
+                       elm_gengrid_item_update(gitem->elm_item);
                }
        }
 }
@@ -1162,14 +1137,6 @@ static void __gl_timeline_thumbs_unrealized(void *data, Evas_Object * obj,
 
        gl_media_s *gitem = elm_object_item_data_get(it);
        GL_CHECK(gitem);
-       /* Checking for local files only */
-       if (gitem->storage_type == GL_STORE_T_MMC ||
-               gitem->storage_type == GL_STORE_T_ALL ||
-               gitem->storage_type == GL_STORE_T_PHONE) {
-               if (gitem->b_create_thumb) {
-                       _gl_data_cancel_thumb(gitem);
-               }
-       }
 }
 
 /**
index d2b801dc5f9a590bae7594907e52c848fa0e6df2..46d1326fed9535ee98080c7551edf4be1f8fbe2b 100644 (file)
@@ -45,10 +45,6 @@ static int __gl_data_type_free_media(gl_media_s ** item)
 
        /* For local medias */
        if (tmp_item->media_h) {
-               if (tmp_item->b_create_thumb) {
-                       media_info_cancel_thumbnail(tmp_item->media_h);
-                       tmp_item->b_create_thumb = false;
-               }
                media_info_destroy(tmp_item->media_h);
                tmp_item->media_h = NULL;
        }
index 882389e1d82338ab73801448e2e51e2988623c6e..34a91338ec9f6b7e7480d94233435ebd6bc8d224 100755 (executable)
@@ -22,6 +22,7 @@
 #include "gl-strings.h"
 #include "gl-db-update.h"
 #include "gl-file-util.h"
+#include "gl-icons.h"
 
 /**
  * Append the album cluster to the list
@@ -1729,36 +1730,41 @@ int _gl_data_finalize(void *data)
  * @param user_data : user data to be passed to callback
  * @return
  */
-int _gl_data_create_thumb(gl_media_s * item,
-                                                 media_thumbnail_completed_cb callback,
-                                                 void *user_data)
+int _gl_data_create_thumb(gl_media_s * item)
 {
        GL_CHECK_VAL(item, -1);
        GL_CHECK_VAL(item->media_h, -1);
        int ret = -1;
        gl_sdbg("File[%s]", item->file_url);
 
-       ret = media_info_create_thumbnail(item->media_h, callback, user_data);
-       if (ret != MEDIA_CONTENT_ERROR_NONE) {
+       ret = media_info_generate_thumbnail(item->media_h);
+       if (ret == MEDIA_CONTENT_ERROR_NONE)
+       {
+               char* path;
+               int error = media_info_get_thumbnail_path(item->media_h, &path);
+               if (GL_FILE_EXISTS(path) && error == MEDIA_CONTENT_ERROR_NONE)
+               {
+                       gl_dbg("Update item with new thumb path[%s]", path);
+                       GL_FREEIF(item->thumb_url);
+                       item->thumb_url = strdup(path);                 /* Update thumb path */
+               }
+               else if(error == MEDIA_CONTENT_ERROR_INVALID_PARAMETER)
+               {
+                       GL_FREEIF(item->thumb_url);
+                       item->thumb_url = strdup(GL_ICON_DB_DEFAULT_THUMB);
+                       gl_dbg("File corrupted, change to broken thumbnail %s", path);
+               }
+               else
+               {
+                       gl_dbgE("Invalid thumb path! Error number[%d]", error);
+               }
+               GL_FREEIF(path);
+       }
+       else
+       {
                gl_dbgE("Failed to create thumbnail[%d]!", ret);
                return -1;
        }
-       item->b_create_thumb = true;
-       return 0;
-}
-
-/**
- * Cancel the thumbnail generation request
- * @param item : media item data
- * @return
- */
-int _gl_data_cancel_thumb(gl_media_s * item)
-{
-       GL_CHECK_VAL(item, -1);
-       GL_CHECK_VAL(item->media_h, -1);
-
-       media_info_cancel_thumbnail(item->media_h);
-       item->b_create_thumb = false;
        return 0;
 }