initial upload for tizen 2.0 beta
[apps/home/gallery.git] / include / gallery.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 #ifndef _GALLERY_H_
18 #define _GALLERY_H_
19
20 #include <Elementary.h>
21 #include <Ecore_X.h>
22 #include <pthread.h>
23 #include <app.h>
24 #include <ui-gadget.h>
25 #include "gl-data.h"
26
27 #ifdef _cplusplus
28 extern "C"
29 {
30 #endif
31
32 #if !defined(APPDIR)
33 #  define APPDIR "/opt/apps/org.tizen.gallery"
34 #endif
35
36 #if !defined(PACKAGE)
37 #  define PACKAGE "gallery"
38 #endif
39
40 #if !defined(LOCALEDIR)
41 #  define LOCALEDIR APPDIR"/res/locale"
42 #endif
43
44 #if !defined(EDJDIR)
45 #  define EDJDIR APPDIR"/res/edje"
46 #endif
47
48 #if !defined(IMAGEDIR)
49 #  define IMAGEDIR APPDIR"/res/images/"
50 #endif
51
52 #define PKGNAME_GALLERY "org.tizen.gallery"
53
54 /******** EDJ File path ********/
55
56 #define GL_EDJ_FILE EDJDIR "/" PACKAGE ".edj"
57
58 /******** Groups name ********/
59
60 #define GL_GRP_VIEW_LAYOUT "gallery/view_layout"
61 #define GL_GRP_SEGMENT "gallery/segment_layout"
62 #define GL_GRP_GRIDVIEW "gallery/gridview"
63 #define GL_GRP_ENTRY "gallery/entry"
64 #define GL_GRP_PHOTOFRAME "photoframe"
65
66 /******* Part name ***********/
67
68 #define GL_NAVIFRAME_PREB_BTN "prev_btn"
69 #define GL_NAVIFRAME_TITLE_RIGHT_BTN "title_right_btn"
70 #define GL_NAVIFRAME_TITLE_LEFT_BTN "title_left_btn"
71 #define GL_NAVIFRAME_CONTROLBAR "controlbar"
72 #ifdef _USE_ROTATE_BG
73 #define GL_NAVIFRAME_TITLE_MORE_BTN "title_more_btn"
74 #define GL_NAVIFRAME_OPTIONHEAD "optionheader"
75 #endif
76 #define GL_POPUP_TEXT "title,text"
77 #define GL_NOCONTENTS_TEXT "elm.text"
78 #define GL_GRID_TEXT "elm.text"
79 #define GL_NAAVIFRAME_TEXT "elm.text.title"
80
81 /******** Style name ********/
82
83 #define GL_CLASS_GENGRID "gengrid"
84 #define GL_BUTTON_STYLE_RENAME "rename"
85
86 #define GL_BUTTON_STYLE_NAVI_MORE "naviframe/more/default"
87 #define GL_BUTTON_STYLE_NAVI_SLIDESHOW "naviframe/slideshow/gallery"
88 #define GL_BUTTON_STYLE_NAVI_DONE "naviframe/done/gallery"
89 #define GL_BUTTON_STYLE_NAVI_CANCEL "naviframe/cancel/gallery"
90 #define GL_BUTTON_STYLE_SWEEP "sweep"
91 #define GL_BUTTON_STYLE_SWEEP_DELETE "sweep/delete"
92 /* Button object style of previous button of naviframe */
93 #define GL_BUTTON_STYLE_NAVI_PRE "naviframe/back_btn/default"
94 #ifdef _USE_ROTATE_BG
95 #define GL_BUTTON_STYLE_NAVI_CTRL "naviframe_control"
96 #endif
97
98 #define GL_CHECKBOX_STYLE_GRID "gallery/grid"
99 #define GL_GENLIST_STYLE_DEFAULT "gallery/default"
100 #define GL_CONTROLBAR_STYLE_NAVI "naviframe"
101
102 #define GL_GENLIST_ITEM_STYLE_SWEEP3 "mode/gallery/slide3"
103
104 /******** Image path ********/
105
106 #define GL_DEFAULT_THUMB_ICON IMAGEDIR"T01_Nocontents_broken.png"
107 #define GL_DB_DEFAULT_THUMB "/opt/data/file-manager-service/.thumb/thumb_default.png"
108 #define GL_LOCK_ICON IMAGEDIR"T01_icon_lock.png"
109
110 #define Gl_VIDEO_PLAY_ICON IMAGEDIR"T01_btn_thumbnail_play.png"
111 #define GL_THUMB_BOOKMARK IMAGEDIR"T01_icon_thumbnail_bookmark.png"
112 #define GL_LIST_BOOKMARK IMAGEDIR"T01_list_icon_bookmark.png"
113
114 #define GL_CBAR_ICON_EDIT IMAGEDIR"T01_controlbar_icon_edit.png"
115 #define GL_CBAR_ICON_CANCEL IMAGEDIR"T01_controlbar_icon_cancel.png"
116 #define GL_CBAR_ICON_DONE IMAGEDIR"T01_controlbar_icon_done.png"
117 #define GL_CBAR_ICON_DELETE IMAGEDIR"T01_controlbar_icon_delete.png"
118 #define GL_CBAR_ICON_SHARE IMAGEDIR"T01_controlbar_icon_share02.png"
119 #define GL_CBAR_ICON_MOVE IMAGEDIR"T01_controlbar_icon_move.png"
120 #define GL_CBAR_ICON_CAMERA IMAGEDIR"T01_controlbar_icon_camera.png"
121
122 /******** String ********/
123
124 /* MIME type */
125 #define GL_MIME_IMAGE_ALL       "image/*"
126 #define GL_MIME_VIDEO_ALL       "video/*"
127
128 /******** Numerical value ********/
129
130 /* Window width and height */
131 #define GL_WIN_WIDTH    720
132 #define GL_WIN_HEIGHT   1280
133
134 /* Specified ID for customed items, which don't exist in DB */
135 #define GL_ALBUM_ALL_ID "GALLERY_ALBUM_ALL_ALBUMS_ID"
136 /* There are 7 thumbnails of 'Camera shots' and 'All' cover, but 4 for normal albums */
137 #define GL_ALBUM_COVER_THUMB_NUM 7
138 /* Normal albums cover have maximum 4 thumbnails */
139 #define GL_ALBUM_COVER_THUMB_NUM_SEC 4
140
141 /* Size of thumbnails in gridview */
142 #define GL_GRID_ITEM_SIZE_W 178
143 #define GL_GRID_ITEM_SIZE_H     182
144 /* Thumbnail would be enlarged if medias count is less than 7 */
145 #define GL_GRID_ITEM_ZOOM_LEVEL_01              4
146 #define GL_GRID_ITEM_ZOOM_LEVEL_02              2
147 #define GL_GRID_ITEM_ZOOM_LEVEL_03 (1.35)
148 #define GL_GRID_ITEM_ZOOM_LEVEL_01_CNT  1
149 #define GL_GRID_ITEM_ZOOM_LEVEL_02_CNT  6
150
151 /* String length of mtye item id */
152 #define GL_MTYPE_ITEN_ID_LEN_MAX 37
153
154 /* String length of album name */
155 #define GL_ALBUM_NAME_LEN_MAX GL_FILE_NAME_LEN_MAX
156
157 #define GL_DATE_INFO_LEN_MAX 256
158 #define GL_POPUP_DESC_LEN_MAX 256
159 #define GL_EXT_STR_COUNT_LEN 20
160
161 /* Maximum number of entry string, 255 Chars of album name (linux system) */
162 #define GL_ENTRY_STR_CHAR_MAX 255
163
164 /* 1900 */
165 #define GL_DEFAULT_YEAR 1900
166 /* 1s=1000ms */
167 #define GL_TIME_MSEC_PER_SEC 1000
168 /*1s = 1000000us*/
169 #define GL_TIME_USEC_PER_SEC 1000000L
170 /* 1ms=1000us */
171 #define GL_TIME_USEC_PER_MSEC 1000
172 /* 1min=60s */
173 #define GL_TIME_SEC_PER_MIN 60
174 /* 1h=60min */
175 #define GL_TIME_MIN_PER_HOUR 60
176 /* 1h=(60x60)s */
177 #define GL_TIME_SEC_PER_HOUR (GL_TIME_MIN_PER_HOUR * GL_TIME_SEC_PER_MIN)
178
179 /* itoa length max  --  1(sign) + 10(2^31) + 1(NULL) */
180 #define GL_INTERGER_LEN_MAX 12
181
182 /* File system related String definition        */
183 #define GL_ROOT_PATH_PHONE              "/opt/media"
184 #define GL_ROOT_PATH_MMC        "/opt/storage/sdcard"
185 #define GL_DEFAULT_PATH_IMAGES      "/Images and videos"
186
187 /******** Enumeration ********/
188
189 typedef enum _gl_aul_launch_type
190 {
191         GL_AUL_T_NONE,
192         GL_AUL_T_SELECT_ONE,
193         GL_AUL_T_SELECT_MULTIPLE,
194         GL_AUL_T_SELECT_IMFT,
195         GL_AUL_T_SELECT_SETAS,
196         GL_AUL_T_SELECT_ALBUM,
197         /* Launching from live-magazine, show 'All album' */
198         GL_AUL_T_VIEW_ALBUM,
199 } gl_aul_launch_type;
200
201 typedef enum {
202         GL_AUL_SETAS_T_NONE,
203         GL_AUL_SETAS_T_WALLPAPER,
204         GL_AUL_SETAS_T_CROP_WALLPAPER,
205         GL_AUL_SETAS_T_CALLER_ID,
206 } gl_aul_setas_type;
207
208 typedef enum _gl_aul_file_type
209 {
210         GL_AUL_FILE_T_NONE,
211         GL_AUL_FILE_T_IMAGE,
212         GL_AUL_FILE_T_VIDEO,
213         GL_AUL_FILE_T_ALL,
214 } gl_aul_file_type;
215
216 typedef enum _gl_view_mode
217 {
218         GL_VIEW_NONE,
219         GL_VIEW_ALBUMS,
220         GL_VIEW_ALBUMS_EDIT,
221         GL_VIEW_ALBUMS_RENAME,
222         GL_VIEW_THUMBS,
223         GL_VIEW_THUMBS_EDIT,
224         GL_VIEW_VIDEOLIST,
225         GL_VIEW_VIDEOLIST_EDIT,
226 } gl_view_mode;
227
228 typedef enum _gl_ctrl_seg_mode
229 {
230         GL_CTRL_SEG_ALL,
231         GL_CTRL_SEG_IMAGES,
232         GL_CTRL_SEG_VIDEOS,
233         GL_CTRL_SEG_CNT
234 } gl_ctrl_seg_mode;
235
236 typedef enum _gl_entry_mode
237 {
238         GL_ENTRY_NONE,
239         GL_ENTRY_NEW_ALBUM,
240         GL_ENTRY_RENAME_ALBUM,
241 } gl_entry_mode;
242
243
244 /******** Structure ********/
245
246 typedef struct
247 {
248         Elm_Genlist_Item_Class videolic;        /* Genlist item class of list view */
249         /* Genlist item class of video list view for sweep */
250         Elm_Genlist_Item_Class sweeplic;
251         Evas_Object *videos_view;
252         Evas_Object *videos_nocontents;
253         int videos_cnt;                         /* Media items count append to listview */
254         /* Sweep item */
255         char *sweep_file_path;
256         /* UUID of item selected for playing */
257         char *played_uuid;
258         Evas_Object *share_btn;
259         Evas_Object *del_btn;
260 } gl_list_info;
261
262 typedef struct
263 {
264         Evas_Coord x;
265         Evas_Coord y;
266         bool b_pressed;
267 } gl_grid_touch_info;
268
269 typedef struct
270 {
271         Elm_Gengrid_Item_Class thumbgic; /* Gengrid item class of thumbnails view */
272         Evas_Object *edit_view;
273         Evas_Object *edit_layout;
274         Evas_Object *layout;
275         Evas_Object *all_view;
276         Evas_Object *all_nocontents;
277         Evas_Object *images_view;
278         Evas_Object *images_nocontents;
279         /* edit item */
280         Elm_Object_Item *edit_it;
281         /* Naviframe item pushed to stack */
282         Elm_Object_Item *nf_it;
283         Elm_Object_Item *nf_it_edit;
284         Elm_Object_Item *nf_it_select;
285         Evas_Object *segment;
286         gl_grid_touch_info grid_touch_info; /* Added for shrink effect while select thumbnail */
287         /* It's thumbnails icon size, not grid item size */
288         int icon_size;
289         Ecore_Idler *grid_append_idler; /* Use idler to append other medias to gridview */
290                                         /* if album contains more than (GL_FIRST_VIEW_END_POS+1) medias */
291         int grid_view_mode;             /* Types: gl_grid_mode; */
292                                         /* 1. Indicate grid view mode of thumbnails view */
293                                         /* 2. Set types for creating nocontents view */
294         int thumbs_cnt;                 /* Media items count appended to gridview */
295         int updated_thumbs_cnt;         /* Media items count appended to gridview while refreshing */
296         bool back_to_normal;            /* When back from edit mode, reset checkbox state */
297
298 #ifdef _USE_ROTATE_BG
299         Evas_Object *more_btn;
300         Evas_Object *left_btn;
301         Evas_Object *right_btn;
302 #endif
303 } gl_grid_info;
304
305 typedef struct
306 {
307         bool app_called_by_me;   /* Indicates if any application invoked by Gallery */
308         ui_gadget_h ug_called_by_me;
309         int ug_type;
310         void *ug_login_data;
311         int sort_type;   /* Types: wminfo_media_sort_type; pass it to imageviewer */
312         ui_gadget_h gallery_ug_called_by_me;    /* The gallery-ug called by Gallery for appsvc */
313 } gl_ug_info;
314
315 typedef struct
316 {
317         Elm_Gengrid_Item_Class albumgic;        /* Gengrid item class of albums view */
318         Elm_Gengrid_Item_Class albumgic_blue;   /* Gengrid item class of albums view */
319         Evas_Object *layout;                    /* Albums view layout object */
320         Evas_Object *view;              /* Albums view object */
321         Evas_Object *edit_layout;       /* Albums view layout object */
322         Evas_Object *edit_view;         /* Albums view object */
323
324         Evas_Object *nocontents;        /* Nocontents object */
325         /* Naviframe item pushed to stack */
326         Elm_Object_Item *nf_it;
327         Elm_Object_Item *nf_it_edit;
328         /* edit item */
329         Elm_Object_Item *edit_it;
330         /* camera item */
331         Elm_Object_Item *camera_it;
332         gl_item *cover_thumbs[GL_ALBUM_COVER_THUMB_NUM]; /* Media items of album cover */
333         gl_cluster *current_album;                      /* Album selected for showing thumbnails view/list view */
334         /* Album selected for rename/open locked album */
335         gl_cluster *selected_album;
336         /* Save destination album id while move/save */
337         char *path;
338         char new_album_name[GL_ALBUM_NAME_LEN_MAX];
339         Eina_List *selected_albums_elist;       /* List of all selected albums */
340         gl_cluster_list *cluster_list;          /* List of all albums */
341         int albums_cnt;                         /* Albums count appended to gridview */
342         int album_medias_cnt;                   /* Media items count of a album, it is showed in album cover */
343         bool update_albums_list;                /* Flag indicate to update albums list when back to normal view. */
344                                                 /* 1. MMC Inserted/Removed in thumbnails edit mode; */
345         char dest_folder[GL_DIR_PATH_LEN_MAX];  /* The full path of destination album of movement */
346         bool move_new_album;                    /* True: move medias to album newly created, */
347                                                 /* False: move to album already created */
348                                                 /* Variables below are related to gallery launching */
349         service_h recv_service;                 /* The service received when app_reset */
350         bool gallery_launched;
351         /* Launching from shotcut(album added to home) */
352         bool aul_launch_by_mime;
353         int aul_launch_type;
354         int aul_file_type;
355         int aul_setas_type;
356         char *aul_id;
357         char *aul_type;
358         char* aul_homescreen_path;
359         char* aul_lockscreen_path;
360         char* aul_callid_size;
361         char* aul_callid_path;
362
363         Ecore_Idler *create_albums_idler;       /* Use idler to append albums to albums view */
364         /* Use idler to activate window when launching Gallery UG */
365         Ecore_Idler *activate_win_idler;
366 } gl_album_info;
367
368 typedef struct
369 {
370         Evas_Object *editfield;
371         Evas_Object *imf_entry;
372         Ecore_IMF_Context *imf_context;
373         int entry_mode;         /* Type: gl_entry_mode; Indicate usage of entry */
374         /* Button 'Done' in new album view */
375         Evas_Object *done_btn;
376         Evas_Object *cancel_btn;
377         Elm_Object_Item *nf_it;
378         /* Handle for play vibration */
379         int haptic_handle;
380         /* Timer for closing vibration */
381         Ecore_Timer *vibration_timer;
382 } gl_entry_info;
383
384 typedef struct
385 {
386         Elm_Genlist_Item_Class popuplit;/* Genlist item class of list view in popupinfo.popup */
387         Evas_Object *popup;
388         int popup_mode;
389         char popup_item_label[GL_ALBUM_NAME_LEN_MAX];/* Selected item label of list in popupinfo.popup */
390         /* Selectioninfo popup */
391         Evas_Object *selinfo;
392         Evas_Object *selinfo_ly;
393         Ecore_Timer *del_timer;
394 } gl_popup_info;
395
396 typedef struct {
397         Eina_List *medias_elist;/* List of all selected medias of a album */
398         int images_cnt; /* Images count selected */
399         int drms_cnt;   /* DRM files count selected */
400         int jpeg_cnt;   /* JEPG files count selected */
401         /* All media count */
402         int sel_cnt;
403 } gl_selected_info;
404
405 typedef struct {
406         Evas_Object *pbar_popup;
407         Evas_Object *pbar;
408         Evas_Object *status_label;
409         /**
410         * After progressbar showed completely, use timer to
411         * emit next signal to write pipe to continue to operate medias.
412         */
413         Ecore_Timer *start_thread_timer;
414         /**
415         * After thread operation done, use idler to
416         * delete progressbar after it's showed completely(status is 100%).
417         */
418         Ecore_Idler *del_pbar_idler;
419         Ecore_Pipe *sync_pipe;          /* Pipe for communication between main and child thread */
420         pthread_mutex_t pbar_lock;      /* Lock for state of 'Cancel' button */
421         pthread_mutex_t refresh_lock;   /* Lock for progressbar refreshing */
422         pthread_cond_t refresh_cond;    /* Condition for progressbar refreshing */
423         int refresh_flag;               /* Indicates progressbar updated or not while moving or deleting */
424         int pbar_cancel;                /* State of 'Cancel' button on progressbar popup */
425         /* Medias count already operated */
426         int finished_cnt;
427 } gl_pbar_info;
428
429 typedef struct
430 {
431         Evas_Object *win;
432         double win_scale;
433         Evas_Object *main_layout;
434         Evas_Object *naviframe;
435         Evas_Object *bg;
436         int rotate_mode;        /* Type: appcore_rm; Indicate rotation mode of whole application */
437         int view_mode;          /* Type: gl_view_mode; Indicate view mode of whole application */
438         bool reentrant;
439         int all_medias_cnt;
440         time_t last_mtime;
441         Eina_List *medias_elist;/* List of all medias of a album */
442         int medias_cnt;         /* Count of all medias of a album */
443         int medias_op_type;     /* Type: Move or Delete medias */
444         int mmc_state;          /* MMC state(Inserted, Removed) */
445         int seg_mode;           /* State of active segment: all, image or video */
446         Ecore_Job *rename_album_job;
447 } gl_main_info;
448
449 struct _gl_appdata
450 {
451         gl_main_info maininfo;          /* Global variables about webalbum */
452         gl_album_info albuminfo;        /* Global variables about albums view */
453         gl_grid_info gridinfo;          /* Global variables about thumbnails view */
454         gl_list_info listinfo;          /* Global variables about videos list view */
455         gl_entry_info entryinfo;        /* Global variables about entry */
456         gl_popup_info popupinfo;        /* Global variables about popup */
457         gl_pbar_info pbarinfo;          /* Global variables about progressbar */
458         gl_ug_info uginfo;              /* Global variables about ug */
459         gl_selected_info selectedinfo;  /* Global variables about files selected */
460 };
461
462 typedef struct _gl_appdata gl_appdata;
463
464 int gallery_reset_app(void *data);
465
466 #ifdef _cplusplus
467 }
468 #endif
469
470 #endif                          /* _GALLERY_H_ */