Tizen 2.1 base
[apps/home/myfiles.git] / src / include / mf-main.h
1 /*
2  * Copyright 2013         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://floralicense.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
19
20 #ifndef __DEF_MYFILE_H_
21 #define __DEF_MYFILE_H_
22
23 #include <Ethumb.h>
24 #include <glib.h>
25 #include <Ecore.h>
26 #include <Ecore_X.h>
27 #include <Evas.h>
28 #include <stdbool.h>
29 #include <media_content.h>
30 #include <Elementary.h>
31 //#include <media-svc-types.h>
32
33 /* for SG */
34 #include <ui-gadget.h>
35 #include <app.h>
36
37 /* for dlog */
38 #include "mf-dlog.h"
39 #include "mf-util.h"
40 #include "mf-search.h"
41 #include "mf-copy.h"
42
43 #define CTRL_DISABLE_NONE                                       0x0000
44 #define CTRL_DISABLE_MOVE                                       0x0001
45 #define CTRL_DISABLE_COPY                                       0x0002
46 #define CTRL_DISABLE_DELETE                                     0x0004
47 #define CTRL_DISABLE_SEND                                       0x0008
48 #define CTRL_DISABLE_LIST_BY                                    0x0010
49 #define CTRL_DISABLE_CREATE                                     0x0020
50 #define CTRL_DISABLE_EDIT                                       0x0040
51 #define CTRL_DISABLE_COPY_MOVE                                  0x0080
52 #define CTRL_DISABLE_SEARCH                                     0x0100
53 #define CTRL_DISABLE_MOVE_HERE                          0x0200
54 #define CTRL_DISABLE_COPY_HERE                          0x0400
55 #define CTRL_DISABLE_CANCEL                             0x0800
56 #define CTRL_DISABLE_MORE                               0x1000
57
58 #define CTRL_DISABLE_EDIT_ALL                           (CTRL_DISABLE_DELETE | CTRL_DISABLE_SEND | CTRL_DISABLE_MORE)
59 #define CTRL_DISABLE_DEFAULT_SEL                        (CTRL_DISABLE_COPY)
60 #define CTRL_DISABLE_NOCONTENT_VIEW                     (CTRL_DISABLE_EDIT | CTRL_DISABLE_LIST_BY | CTRL_DISABLE_SEARCH)
61 #define CTRL_DISABLE_USER_FOLDER_SEL                    (CTRL_DISABLE_DELETE | CTRL_DISABLE_MORE)
62 #define CTRL_DISABLE_DEFAULT_ALL                        (CTRL_DISABLE_LIST_BY | CTRL_DISABLE_MORE | CTRL_DISABLE_EDIT | CTRL_DISABLE_SEARCH)
63 #define CTRL_DISABLE_OTG_ROOT                           ~CTRL_DISABLE_SEARCH
64 #define CTRL_DISABLE_SYSFOLDER_SELECT                   (CTRL_DISABLE_MOVE_HERE)
65 #define CTRL_DISABLE_OTG_OPT_ROOT                       (CTRL_DISABLE_MOVE_HERE | CTRL_DISABLE_COPY_HERE | CTRL_DISABLE_CREATE)
66
67
68 #define myfile_ret_if(expr) do { \
69         if (expr) { \
70                 mf_debug("!!! CHECK ERROR !!! (%s) -> %s() return!!!", #expr, __FUNCTION__); \
71                 return; \
72         } \
73 } while (0)
74 #define myfile_retv_if(expr, val) do { \
75         if (expr) { \
76                 mf_debug("!!! CHECK ERROR !!! (%s) -> %s() return !!!", #expr, __FUNCTION__); \
77                 return (val); \
78         } \
79 } while (0)
80 #define myfile_retm_if(expr, fmt, arg...) do { \
81         if (expr) { \
82                 mf_debug(fmt, ##arg); \
83                 mf_debug("!!! CHECK ERROR !!! (%s) -> %s() return !!!", #expr, __FUNCTION__); \
84                 return; \
85         } \
86 } while (0)
87 #define myfile_retvm_if(expr, val, fmt, arg...) do { \
88         if (expr) { \
89                 mf_debug(fmt, ##arg); \
90                 mf_debug("!!! CHECK ERROR !!! (%s) -> %s() return !!!", #expr, __FUNCTION__); \
91                 return (val); \
92         } \
93 } while (0)
94
95 /***********    Global Definitions              ***********/
96 typedef void (*mfCallBack) (void *, Evas_Object *, void *);
97
98 typedef struct _oper_record oper_record;
99
100 struct _oper_record {
101         GString *path;
102 };
103
104 typedef struct _myfileNaviBar myfileNaviBar;
105
106 struct _myfileNaviBar {
107         char *pNaviTitle;
108         char *pNaviLabel;       /*indicate which storage is pointed by this navibar*/
109         oper_record pre_operation;
110         char *pCurrentPath;
111         MORE_TYPE pre_more;     /*for tab function only*/
112         bool naviFlagInUse;
113         bool naviFlagEditStart;
114         bool naviFlagEditJoin;  /*to indicate if pop in refresh needed*/
115 };
116
117 typedef struct _mfEditView mfEditView;
118 struct _mfEditView {
119         Evas_Object *pBox;
120         Evas_Object *pGenlist;
121         Evas_Object *pGengrid;
122         //Evas_Object *pSelectAllCheckBox;
123         //Evas_Object *pSelectAllLayout;
124         Evas_Object *pPathInfo;
125         Evas_Object *pInfoBox;
126         Eina_Bool bSelectAllChecked;
127         int iTotalCount;
128         int iCheckedCount;
129 };
130 #ifdef MYFILE_SPLIT_VIEW
131 typedef struct __mfSplitData mfSplitData;
132 struct __mfSplitData {
133         Evas_Object *pMainLayout;
134         Evas_Object *pPanes;
135
136         Evas_Object *pSplitLeftGenlist;
137         //Evas_Object *pSelectAllLayout;
138         //Evas_Object *pSelectAllCheckBox;
139         Elm_Object_Item *phone_item;
140         Elm_Object_Item *mmc_item;
141         Elm_Object_Item *otg_item;
142         bool bFlagSplitViewCreate;
143         bool bFlagPortraitViewCreate;
144 };
145 #endif
146
147 typedef struct _myfileMainWindow myfileMainWindow;
148 struct _myfileMainWindow {
149         /* root window size */
150         int root_w;
151         int root_h;
152         int root_x;
153         int root_y;
154
155         /* graphic data */
156         Evas *evas;
157         Evas_Object *pWindow;
158         Evas_Object *pBackGround;
159         Evas_Object *pConformant;
160         Evas_Object *pMainLayout;
161         Evas_Object *pTabBar;
162         Eina_List *plistNaviBar;
163
164         Evas_Object *pNormalPopup;
165         Evas_Object *pContextPopup;
166         Evas_Object *pEntry;
167         Evas_Object *pEditField;
168         Evas_Object *pBox;
169         Ecore_Event_Handler *event;
170         Ecore_Event_Handler *font_event;
171         Evas_Object *pLabel;
172         Evas_Object *pLabelLayout;
173         Evas_Object *pProgressPopup;
174         Evas_Object *pFinishPopup;
175         Evas_Object *pMmcRemovedPopup;
176         Evas_Object *pProgressLayout;
177         Evas_Object *pOperationNotify;
178         Evas_Object *pSearchEntry;
179         Evas_Object *pSearchLabel;
180
181
182         Evas_Object *pNaviBar;
183         Evas_Object *pNaviLayout;
184         Evas_Object *pNaviLeftBtn;
185         Evas_Object *pNaviCtrlBar;
186         Evas_Object *pNaviSearchBar;
187         Evas_Object *pNaviBox;
188         Evas_Object *pNaviGenlist;
189         Evas_Object *pNaviGengrid;
190         Evas_Object *pNaviPathInfo;
191         Evas_Object *pNaviInfoBox;
192         Evas_Object *pTrayBox;
193
194         const Elm_Object_Item *pSearchViewSweepItem;
195         const Elm_Object_Item *pPreSearchViewSweepItem;
196         Ecore_Timer *pSearchViewTimer;
197         Ecore_Timer *pPopupTimer;
198
199 #ifdef MYFILE_SPLIT_VIEW
200
201         Evas_Object *pNaviSplitContent;
202 #endif
203         Elm_Object_Item *pNaviItem;
204
205 #ifdef MYFILE_SPLIT_VIEW
206         mfSplitData   sSplitData;
207 #endif
208         mfEditView pEditView;
209 };
210
211 typedef struct _myfileStatus myfileStatus;
212
213 struct _myfileStatus {
214
215         int more;               /** current mode **/
216         int preMore;            /** the mode before operation **/
217         int rotation_type;      /** current rotation type **/
218         int pre_rotate_type;
219         int folder_count;       /** current new created folders count **/
220         int theme_type;         /** current theme type **/
221         int iRadioValue;        /** current the radio box selected item value **/
222         int flagViewType;       /** current view type, List view or Thumbnail view **/
223         int iFolderSortType;    /* for list by operation */
224         int iStorageState;      /** current storage state **/
225         int iCtrlDisableItem;
226         int iNFCState;
227         int iSelectedSortType;
228         int iExtensionState;
229         int view_type;
230         int preViewType;
231
232         Eina_Bool flagRootView;
233         Eina_Bool flagNoContent;
234         Eina_Bool flagFolderSelect;
235         Eina_Bool flagFileSelect;
236         Eina_Bool flagStorageRemoved;
237         Eina_Bool flagNaviPush;
238         Eina_Bool flagIcuInit;
239         Eina_Bool flagLCDLock;          /*lcd lock status*/
240         Eina_Bool flagCtxPopShow;
241         Eina_Bool flagSearchAll;
242         Eina_Bool flagTabbarShow;
243         Eina_Bool flagIME;
244
245         Evas_Object *pRadioGroup;
246         GString *path;          /* current path */
247         char *upper_folder;
248         char *search_filter;
249         int navi_item_selected;
250         char *monitor_path;
251         Elm_Object_Item *pPreNaviItem;
252         /* icu related */
253         UDateTimePatternGenerator *generator;
254         UDateFormat *formatter;
255
256         mf_search_handle search_handler;
257
258 #ifdef MYFILE_SPLIT_VIEW
259         bool flagNofiles;
260         bool flagUpperSet;
261         /* rotate related*/
262         bool view_mode_start;
263         bool view_mode_end;
264         int rotation_angle;
265         Ecore_Timer *rotation_timer;
266 #endif
267
268 #ifdef MYFILE_MOTION_FEATURE
269         void (*doubletab_event_handler)(Evas_Object *data);
270 #endif
271         Ecore_Idler *app_init_idler;
272         Ecore_Idler *popup_del_idler;
273         Ecore_Idler *navi_content_idler;
274         Evas_Object *old_content;
275
276         bool b_run_background; /* 20121008 added for fix PLM P121001-0404 temporary */
277 };
278
279
280 typedef struct _myfileFileOperation myfileFileOperation;
281 struct _myfileFileOperation {
282         /* to rename */
283         GString *to_rename;
284         char *file_name_suffix;
285
286         /*clicked item name */
287         GString *clicked_item;
288
289         /*mmc operation flag */
290         gboolean bmmc_is_removing;
291
292         /*image viewer SG */
293         ui_gadget_h ugImageViewer;
294
295         /*      operation error number  */
296         int error_number;
297         int error_code;
298
299         /* pipe for inotify */
300         void *conn;
301         Ecore_Pipe *sync_pipe;
302         gboolean same_storage;
303
304         /*      refresh type */
305         GString *source;
306         GString *destination;
307         gboolean refresh_type;
308
309         Ecore_Pipe *inotify_pipe;
310
311         /*  progress bar data record    */
312         Evas_Object *progress_bar;
313         Evas_Object *persent_label;
314         Evas_Object *count_label;
315         unsigned int current_count;
316         unsigned long total_file_size;
317         unsigned long finished_size;
318         int progress_cancel;
319
320         /**drm file path*/
321         char *drm_file_path;
322         Eina_List *search_result_list;
323         Eina_List *default_dir_list;
324         Eina_List *user_dir_list;
325         Eina_List *folder_list;
326         Eina_List *file_list;
327         Eina_List *category_list;
328
329
330         mf_cancel *pCancel;
331         mf_fo_request *pRequest;
332         mf_fo_msg *pMessage;
333         GList *pSourceList;
334
335         Elm_Object_Item *pGenlistItem;
336         int iTotalCount;
337         int iRequestType;
338         Ecore_Timer *search_IME_hide_timer;
339         Elm_Object_Item *rename_item;
340
341 #ifdef  MYFILE_USB_OTG
342         Eina_List *otg_dev_list;
343         Eina_List *otg_dev_removed_list;
344 #endif
345         /**job handler**/
346         Eina_List *job_pop_list;        /*to record the job handler for to_content_pop*/
347         Ecore_Job *job_push;    /*to record the job handler for push a new view*/
348         bool iOperationSuccessFlag;     /*used for confirm whether the operation fininsh successfully, not canceled and failed*/
349         char *pOperationMsg;
350         Elm_Object_Item *idle_delete_item;
351 };
352
353 typedef struct _myfileFileRecord myfileFileRecord;
354
355 struct _myfileFileRecord {
356         /* operation property */
357         Eina_List *operation_property;
358
359         /* value saver for bluetooth / protection */
360         Eina_List *value_saver;
361         Eina_List *selected_files;
362         Eina_List *selected_dest_files;
363         Eina_List *backup_file_list;
364 };
365
366 typedef struct _myfileSharedGadget myfileSharedGadget;
367 struct _myfileSharedGadget {
368         int is_password_correct;
369         ui_gadget_h ug;
370         /*SGController  *sg_controller;for privacy lock*/
371 };
372
373 struct _myfileOtg {
374         Evas_Object *rootpath_box;
375         Evas_Object *rootpath_layout;
376         Elm_Object_Item *rootpath_navi_item;
377 };
378 typedef struct _myfileOtg myfileOtg;
379
380 struct _myfileBundle {
381         service_h recv_service;
382         char *path;
383         char *select_type;
384         char *file_type;
385         char *marked_mode;
386         char *drm_type;
387 };
388
389 typedef struct _myfileBundle myfileBundle;
390
391 struct appdata {
392         myfileMainWindow mf_MainWindow;
393         myfileStatus mf_Status;
394         myfileFileOperation mf_FileOperation;
395         myfileFileRecord mf_FileRecordList;
396         myfileSharedGadget mf_SharedGadget;
397         myfileOtg mf_Otg;
398         myfileBundle mf_Bundle;
399 };
400
401
402 /*handler list node struct*/
403 typedef struct _myfileEcoreHandleNode   myfileEcoreHandleNode;
404 struct _myfileEcoreHandleNode {
405         Ecore_Job *handler;
406         char *navi_label;
407 };
408
409
410 typedef enum _MF_ACTION mfAction;
411
412 enum _MF_ACTION {
413         MFACTION_CLICK,
414         MFACTION_FLICK
415 };
416
417 #define _EDJ(o) elm_layout_edje_get(o)
418 Evas_Object *mf_main_load_edj(Evas_Object * parent, const char *file, const char *group);
419 #define GET_SYS_STR(str) dgettext("sys_string", str)
420 #define GET_STR(str) _(str)
421
422 #endif /* __DEF_MYFILE_H_ */