4a6429dcdad8ef44de9af10840b3602e4a4adfa0
[apps/home/gallery.git] / libug / libug-gallery-efl / include / gallery-efl.h
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *     http://www.tizenopensource.org/license
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16
17 /*
18 * About invoking gallery UG view. F.E.
19 *
20 * struct ug_cbs cbs = {0, };
21 * bundle* param = NULL;
22 *
23 * cbs.layout_cb = test_ug_layout_cb;
24 * cbs.result_cb = test_ug_return_cb;
25 * cbs.destroy_cb = test_ug_closed_cb;
26 *
27 * param = bundle_create();
28 *
29 * bundle_add( param, "launch-type", "select-one" );
30 * bundle_add( param, "return-type", "vconf");
31 * bundle_add( param, "file-type", "all" );
32 *
33 * struct ui_gadget *ext_ug = ug_create( NULL, "gallery-efl", UG_MODE_FULLVIEW, param, &cbs );
34 *
35 *
36 *
37 * About parameter.
38 *       (1)"select-setas"
39 *       It's added for wallpaper setting and contact caller ID setting.
40 *       If caller pass "select-setas", after image tapped, image viewer would be invoke, then user can
41 *       apply setting in image viewer.
42 *       It's unnecessary to pass parameter of return-type in set-as case..
43 *
44 *       A)"setas-type"
45 *       And for set-as case, bundle parameter "setas-type" is used to specify different kind of setting, there are two set-as types:
46 *               a)"wallpaper"
47 *               This is for wallpaper setting.
48 *               b)"callerid"
49 *               This is for contact caller ID setting.
50 *               And there are another two bundle parameters for callerid, both of them are optional , that is:
51 *                       b1)"callerid-size"
52 *                               It's added to set the size of caller ID, f.e.
53 *                               If you want to set the size as 200x200, you can set bundler parameter like :
54 *                                       bundle_add( param, "callerid-size", "200" );
55 *                       b2)"callerid-path"
56 *                               It's added to specify the saved path of call ID, and note that this is a full path, f.e..
57 *                               You can pass path string like :
58 *                                       bundle_add( param, "callerid-path", "/opt/media/test_folder/test_caller_id_1.jpg");
59 *
60 *       B) comand
61 *       Launching ug comand: ug-launcher -F -n gallery-efl -d "launch-type,select-setas" -d "file-type,image" -d "setas-type,wallpaper"
62 *       Launching ug comand: ug-launcher -F -n gallery-efl -d "launch-type,select-setas" -d "file-type,image" -d "setas-type,callerid" \
63 *                                                       -d "callerid-size,200" -d "callerid-path,/opt/media/test_folder/test_caller_id_1.jpg"
64 *
65 *       (2)"select-one" and "select-multiple"
66 *       In this case, after image(s) tapped, it will be added to list and return path(s) to caller if done button tapped.
67 *       Note that, caller must pass return-type, ug will return path(s) strings of selected image(s).
68 *
69 *       Launching ug comand: ug-launcher -F -n gallery-efl -d "launch-type,select-one" -d "return-type,vconf" -d "file-type,all"
70 *                                                ug-launcher -F -n gallery-efl -d "launch-type,select-multiple" -d "return-type,vconf" -d "file-type,all"
71 *
72 *       Note that, file-type is optional while select-type is select-one or select-multiple.
73 *
74 *       (3)"file-type"
75 *       User can set file type via parameter "file-type", there are "image", "video" and "all", here, "all" including image and video.
76 *       But for now in imageviewer, wallpaper setting only support image type.
77 *
78 */
79
80
81 #ifndef __GALLERY_EFL_H__
82 #define __GALLERY_EFL_H__
83
84
85 #include <glib.h>
86 #include <Elementary.h>
87 #include <stdio.h>
88 #include <vconf.h>
89 #include <vconf-keys.h>
90 #include <bundle.h>
91 #include <ui-gadget-module.h>
92 #include <visual-svc.h>
93 #include <Eina.h>
94 #include <Ecore_X.h>
95 #include <Ethumb.h>
96
97 #ifdef __cplusplus
98 extern "C" {
99 #endif /* __cplusplus */
100
101 #define GALLERY_RES_DIR "/opt/apps/org.tizen.gallery/res/"
102 #define GALLERY_ICON_DIR GALLERY_RES_DIR"icons/default/small/"
103 #define GALLERY_EDJ_DIR GALLERY_RES_DIR"edje/"
104 #define GALLERY_BLACK_EDJ_FILE GALLERY_EDJ_DIR"gl-black-theme.edj"
105 #define GE_UG_RES_DIR "/opt/ug/res/"
106 #define GE_IMAGES_DIR GE_UG_RES_DIR"images/gallery-efl/images/"
107 #define GE_EDJ_DIR GE_UG_RES_DIR"edje/gallery-efl/"
108 #define GE_EDJ_FILE GE_EDJ_DIR"gallery-efl.edj"
109
110 #define GE_GRP_GRIDVIEW "gallery_efl/gridview"
111 #define GE_GRP_ALBUMVIEW "gallery_efl/albumview"
112 #define GE_GRP_NOCONTENTS "gallery_efl/nocontents"
113
114 #define GE_CBAR_STYLE_DEFAULT "gallery/default"
115 #define GE_NAVIFRAME_STYLE_DEFAULT "gallery/default"
116 #define GE_CHECKBOX_STYLE_GRID "gallery_efl/grid"
117
118 #define DEFAULT_ICON GALLERY_ICON_DIR"org.tizen.gallery.png"
119 #define GE_LOCK_ICON GE_IMAGES_DIR"T01_icon_lock.png"
120 #define GE_THUMB_BOOKMARK GE_IMAGES_DIR"T01_icon_thumbnail_bookmark.png"
121 #define GE_DEFAULT_THUMB_ICON GE_IMAGES_DIR"T01_Nocontents_broken.png"
122 #define GE_CBAR_ICON_DONE GE_IMAGES_DIR"T01_controlbar_icon_done.png"
123
124 #define GE_ROOT_PATH_PHONE      "/opt/media"
125 #define GE_ROOT_PATH_MMC        "/opt/storage/sdcard"
126
127 #define GE_ALBUM_ALL_ID "GALLERY_ALBUM_ALL_ALBUMS_ID"
128 /* String length of mtye item id */
129 #define GE_MTYPE_ITEN_ID_LEN_MAX 37
130
131 #define GE_BASE_WIN_WIDTH       720
132 #define GE_BASE_WIN_HEIGHT      1280
133
134 #define GE_GRID_ITEM_SIZE_W 178
135 #define GE_GRID_ITEM_SIZE_H 182
136
137 #define GE_GRID_ITEM_ZOOM_LEVEL_01 4
138 #define GE_GRID_ITEM_ZOOM_LEVEL_02 2
139 #define GE_GRID_ITEM_ZOOM_LEVEL_01_CNT 1
140 #define GE_GRID_ITEM_ZOOM_LEVEL_02_CNT 6
141
142 #define GE_LIST_ICON_WIDTH 133
143 #define GE_LIST_ICON_HEIGHT 100
144
145 #define GE_ALBUM_COVER_THUMB_NUM 7 /* There are 7 thumbnails of 'Camera shots' and 'All' cover*/
146 #define GE_ALBUM_COVER_THUMB_NUM_SEC 4 /* Other albums cover have maximum 4 thumbnails */
147 #define GE_ALBUM_ITEM_WIDTH 358
148 #define GE_ALBUM_ITEM_HEIGHT 360
149 #define GE_COVER_SIZE 318
150 #define GE_COVER_PAD 3
151 #define GE_COVER_ICON_S (GE_COVER_SIZE - 2 * GE_COVER_PAD)
152 #define GE_COVER_GRID_S 102
153 #define GE_COVER_2X_GRID_S (GE_COVER_ICON_S - GE_COVER_GRID_S - GE_COVER_PAD)
154
155 #define GE_SELINFO_TEXT_LEN_MAX 64
156 #define GE_ALBUM_DATE_LEN_MAX 256
157 #define GE_MAX_BYTES_FOR_CHAR 3
158 #define GE_ALBUM_NAME_LEN_MAX (255 * GE_MAX_BYTES_FOR_CHAR + 1)
159 #define GE_VIDEO_DURATION_MAX 256
160 #define GE_NOCONTENTS_LABEL_LEN_MAX 512
161 #define GE_FILE_PATH_LEN_MAX (4095 * GE_MAX_BYTES_FOR_CHAR + 1)
162 #define GE_DIR_PATH_LEN_MAX GE_FILE_PATH_LEN_MAX
163
164 #define GE_TIME_SECOND_MILLISECOND 1000 // 1s=1000ms
165 #define GE_TIME_USEC_PER_SEC 1000000L
166 #define GE_TIME_MINUTE_SECOND 60 // 1min=60s
167 #define GE_TIME_HOUR_MINUTE 60 // 1h=60min
168 #define GE_TIME_HOUR_SECOND (GE_TIME_HOUR_MINUTE * GE_TIME_MINUTE_SECOND) // 1h=(60x60)s
169
170 #define GE_FIRST_VIEW_START_POS 0
171 #define GE_FIRST_VIEW_END_POS 47
172 #define GE_GET_UNTIL_LAST_RECORD 65536  /* Fixme: Do not use 65536. */
173 #define GE_GET_ALL_RECORDS -1
174
175 #define GE_BUNDLE_LAUNCH_TYPE                           "launch-type"
176 #define GE_BUNDLE_FILE_TYPE                             "file-type"
177 #define GE_BUNDLE_SETAS_TYPE                            "setas-type"
178 #define GE_BUNDLE_CALLERID_SIZE                         "callerid-size"
179 #define GE_BUNDLE_CALLERID_PATH                         "callerid-path"
180 #define GE_BUNDLE_HOMESCREEN_PATH                       "homescreen-path"
181 #define GE_BUNDLE_LOCKSCREEN_PATH                       "lockscreen-path"
182
183 #define GE_ALBUM_SELECT_ONE                             "select-album"
184 #define GE_ALBUM_SELECT_RETURN_ID                       "album-id"
185 #define GE_ALBUM_SELECT_RETURN_PATH                     "folder-path"
186
187 #define GE_FILE_SELECT_ONE                              "select-one"
188 #define GE_FILE_SELECT_MULTIPLE                         "select-multiple"
189 #define GE_FILE_SELECT_SETAS                            "select-setas"
190 #define GE_FILE_SELECT_IMFT                             "select-imft"
191
192 #define GE_FILE_SELECT_TYPE_IMAGE                       "image"
193 #define GE_FILE_SELECT_TYPE_VIDEO                       "video"
194 #define GE_FILE_SELECT_TYPE_ALL                         "all"
195
196 #define GE_FILE_SELECT_SETAS_WALLPALER          "wallpaper"
197 #define GE_FILE_SELECT_SETAS_CALLERID           "callerid"
198
199 #define GE_FILE_SELECT_RETURN_COUNT             "count"
200 #define GE_FILE_SELECT_RETURN_PATH                      "path"
201
202 #define GE_FILE_SELECT_RETURN_QUIT                      "ug-quit"
203 #define GE_FILE_SELECT_QUIT_STATE                       "normal"
204
205 #define GE_SETAS_CALLERID_CROP_IMAGE_PATH       "crop-image-path"
206 #define GE_SETAS_IMAGE_PATH                                     "image-path"
207
208 /*Image viewer UG bundle parameters*/
209 #define GE_IMAGEVIEWER_CALLERID_SIZE            "Area size"
210 #define GE_IMAGEVIEWER_CALLERID_PATH            "CallerID path"
211
212 #define GE_IMAGEVIEWER_CROP_IMAGE_PATH          "crop_image_path"
213 #define GE_IMAGEVIEWER_IMAGE_PATH                       "image_path"
214
215 #define GE_IMAGEVIEWER_HOMESCREEN_PATH          "Wallpaper path"
216 #define GE_IMAGEVIEWER_LOCKSCREEN_PATH          "Lockscreen path"
217 #define GE_IMAGEVIEWER_RETURN_ERROR             "Error"
218 /*Image viewer UG bundle parameters-End*/
219
220 typedef enum {
221         GE_Album_Select_None,
222         GE_Album_Select_One,
223 } ge_album_select;
224
225 typedef enum {
226         GE_File_Select_None,
227         GE_File_Select_One,
228         GE_File_Select_Multiple,
229         GE_File_Select_Setas,
230         GE_File_Select_Imft,
231 } ge_file_select;
232
233 typedef enum {
234         GE_File_Select_Setas_None,
235         GE_File_Select_Setas_Wallpaper,
236         GE_File_Select_Setas_CallerID,
237 } ge_file_select_setas;
238
239 typedef enum {
240         GE_File_Select_Type_None,
241         GE_File_Select_Type_Image,
242         GE_File_Select_Type_Video,
243         GE_File_Select_Type_All,
244 } ge_file_type;
245
246 typedef enum view_by_mode_e
247 {
248         GE_AlbumsView_Mode,
249         GE_ThumbnailView_Mode,
250         GE_ThumbnailEdit_Mode,
251 } ge_view_mode;
252
253 typedef enum _ge_ug_exit_mode {
254         GE_UG_EXIT_NONE,
255         GE_UG_EXIT_MASS_STORAGE,
256 } ge_ug_exit_mode;
257
258 typedef enum {
259         GE_UPDATE_NONE,
260         GE_UPDATE_NORMAL,
261         GE_UPDATE_MMC_REMOVED,
262         GE_UPDATE_MMC_ADDED,
263 }ge_update_mode;
264
265 typedef struct _ge_ugdata ge_ugdata;
266
267 typedef struct {
268         Mcluster* cluster;
269         ge_ugdata* ugd;
270         int index;
271
272         time_t item_mtime;
273         Elm_Object_Item *griditem;
274         void* _reserved;
275 }ge_cluster;
276
277 typedef struct {
278         Eina_List* clist;
279         int cur_pos;
280 }ge_cluster_list;
281
282 typedef struct _gl_item {
283         Mitem* item;
284         ge_ugdata* ugd;
285         Elm_Object_Item *elm_item;
286         Evas_Object* check_obj;
287     bool checked;
288         char* drm_filepath;
289
290         void* _reserved;
291 }ge_item;
292
293 struct _ge_ugdata {
294         Evas_Object *win;
295         int win_w;
296         int win_h;
297         double win_scale;
298         Evas_Object *ly_main;
299         Evas_Object *bg;
300         Elm_Theme *th;
301         /* add more variables here */
302         Evas_Object *navi_bar;
303
304         Evas_Object *albums_view;
305         Evas_Object *albums_view_ly;
306         Evas_Object *thumbs_view;
307         Evas_Object *thumbs_view_ly;
308         Elm_Object_Item *thumbs_nf_it;
309         Evas_Object *thumbs_nocontents;
310         Ecore_Idler* grid_append_idler;
311         Evas_Object *nocontents;
312         Ecore_Event_Handler* event_handler;
313         Evas_Object *popup;
314         Ecore_Timer *del_timer;
315         int popup_mode;
316
317         MediaSvcHandle *db_handle;
318         ge_cluster_list* cluster_list;
319         struct ui_gadget *ug_called_by_me;
320         struct ui_gadget *ug;
321         bundle *bundle;         /*added for "ug_send_result"*/
322         /* It's thumbnails icon size, not grid item size */
323         int icon_size;
324         Ecore_Timer *thumbs_clicked_timer;
325
326         int album_select_mode;
327         int file_select_mode;
328         int file_type_mode;
329         int file_select_contact_id;
330         int file_select_setas_mode;
331         char* file_setas_callid_size;
332         char* file_setas_callid_path;
333         char* file_setas_image_path;
334         char* file_setas_crop_image_path;
335         char albums_view_title[GE_ALBUM_NAME_LEN_MAX];
336         char* file_setas_homescreen_path;
337         char* file_setas_lockscreen_path;
338
339         Evas_Object *selectioninfo_ly;
340         Evas_Object *selectioninfo;
341
342         int ug_exit_mode;
343         bool b_inited_view;             /* true: show albums view; false: show popup */
344         /* Update view in timer if UMS OFF */
345         Ecore_Timer *ums_update_timer;
346 };
347
348
349 #define GE_DEL_TIMER(timer) if(timer){ecore_timer_del(timer); timer = NULL;}
350 #define GE_DEL_IDLER(idler) if(idler){ecore_idler_del(idler); idler = NULL;}
351 #define GE_DEL_OBJ(obj) if(obj){evas_object_del(obj); obj = NULL;}
352 #define GE_FREE_MEM(mem) if(mem){free(mem); mem = NULL;}
353
354
355 ge_view_mode _ge_get_view_mode(void);
356 void _ge_set_view_mode(ge_view_mode mode);
357
358
359 #ifdef __cplusplus
360 }
361 #endif /* __cplusplus */
362
363
364 #endif /* __GALLERY_EFL_H__ */
365