2 * Copyright 2012 Samsung Electronics Co., Ltd
\r
4 * Licensed under the Flora License, Version 1.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.tizenopensource.org/license
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 #include <media_info.h>
\r
18 #include "gl-data-type.h"
\r
19 #include "gl-debug.h"
\r
21 int _gl_data_type_new_media(gl_media_s **item)
\r
23 GL_CHECK_VAL(item, -1);
\r
24 gl_media_s *tmp_item = (gl_media_s *)calloc(1, sizeof(gl_media_s));
\r
25 GL_CHECK_VAL(tmp_item, -1);
\r
26 tmp_item->gtype = GL_TYPE_MEDIA;
\r
31 int _gl_data_type_new_album(gl_album_s **album)
\r
33 GL_CHECK_VAL(album, -1);
\r
34 gl_album_s *tmp_item = (gl_album_s *)calloc(1, sizeof(gl_album_s));
\r
35 GL_CHECK_VAL(tmp_item, -1);
\r
36 tmp_item->gtype = GL_TYPE_ALBUM;
\r
42 static int __gl_data_type_free_media(gl_media_s **item)
\r
44 GL_CHECK_VAL(item, -1);
\r
45 GL_CHECK_VAL(*item, -1);
\r
46 gl_media_s *tmp_item = *item;
\r
48 /* For local medias */
\r
49 if (tmp_item->media_h)
\r
50 media_info_destroy(tmp_item->media_h);
\r
52 FREE_DATA(tmp_item->uuid);
\r
53 FREE_DATA(tmp_item->thumb_url);
\r
54 FREE_DATA(tmp_item->file_url);
\r
55 FREE_DATA(tmp_item->album_uuid);
\r
56 FREE_DATA(tmp_item->display_name);
\r
57 FREE_DATA(tmp_item->ext);
\r
59 if (MEDIA_CONTENT_TYPE_IMAGE == tmp_item->type &&
\r
60 tmp_item->image_info) {
\r
61 /* For local medias */
\r
62 if (tmp_item->image_info->image_h)
\r
63 image_meta_destroy(tmp_item->image_info->image_h);
\r
65 FREE_DATA(tmp_item->image_info->media_uuid);
\r
66 free(tmp_item->image_info);
\r
67 } else if (MEDIA_CONTENT_TYPE_VIDEO == tmp_item->type &&
\r
68 tmp_item->video_info) {
\r
69 /* For local medias */
\r
70 if (tmp_item->video_info->video_h)
\r
71 video_meta_destroy(tmp_item->video_info->video_h);
\r
73 FREE_DATA(tmp_item->video_info->media_uuid);
\r
74 FREE_DATA(tmp_item->video_info->title);
\r
82 int _gl_data_type_free_media_list(Eina_List **list)
\r
84 GL_CHECK_VAL(list, -1);
\r
85 GL_CHECK_VAL(*list, -1);
\r
86 gl_media_s *item = NULL;
\r
87 Eina_List *tmp_list = *list;
\r
88 EINA_LIST_FREE(tmp_list, item) {
\r
90 __gl_data_type_free_media(&item);
\r
92 eina_list_free(*list);
\r
97 static int __gl_data_type_free_album(gl_album_s **album)
\r
99 GL_CHECK_VAL(album, -1);
\r
100 GL_CHECK_VAL(*album, -1);
\r
101 gl_album_s *tmp_album = *album;
\r
103 FREE_DATA(tmp_album->uuid);
\r
104 FREE_DATA(tmp_album->display_name);
\r
105 FREE_DATA(tmp_album->path);
\r
107 if (tmp_album->folder_h)
\r
108 media_folder_destroy(tmp_album->folder_h);
\r
114 int _gl_data_type_free_album_list(Eina_List **list)
\r
116 GL_CHECK_VAL(list, -1);
\r
117 GL_CHECK_VAL(*list, -1);
\r
118 gl_album_s *item = NULL;
\r
119 Eina_List *tmp_list = *list;
\r
120 EINA_LIST_FREE(tmp_list, item) {
\r
122 __gl_data_type_free_album(&item);
\r
124 eina_list_free(*list);
\r
129 int _gl_data_type_free_glitem(void **item)
\r
131 GL_CHECK_VAL(item, -1);
\r
132 GL_CHECK_VAL(*item, -1);
\r
135 if(((gl_album_s *)*item)->gtype == GL_TYPE_ALBUM)
\r
136 ret = __gl_data_type_free_album((gl_album_s **)item);
\r
137 else if (((gl_media_s *)*item)->gtype == GL_TYPE_MEDIA)
\r
138 ret = __gl_data_type_free_media((gl_media_s **)item);
\r