[SR][Nabi-se][Nabi_SEN_SE-32480] Unable to select more then one file for attachment...
[apps/core/preloaded/ug-myfile-efl.git] / src / include / mf-ug-util.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://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
21 #ifndef __DEF_MF_UG_UTIL_H_
22 #define __DEF_MF_UG_UTIL_H_
23
24 #include <Elementary.h>
25 #include <stdbool.h>
26 #include <glib.h>
27
28 #include "mf-ug-main.h"
29
30 #define UG_SAFE_FREE_CHAR(x) do {\
31                                         if ((x) != NULL) {\
32                                                 free(x); \
33                                                 x = NULL;\
34                                         } \
35                              } while (0)
36
37 #define UG_SAFE_FREE_GSTRING(x) do {\
38                                         if ((x) != NULL) {\
39                                                 g_string_free(x, TRUE); \
40                                                 x = NULL;\
41                                         } \
42                                 } while (0)
43
44 #define UG_CHAR_CHECK_NULL_GOTO(arg, dest) do {\
45                                                 if ((arg) == NULL) {\
46                                                         goto dest;\
47                                                 } \
48                                            } while (0)
49
50 #define UG_GSTRING_CHECK_NULL_GOTO(arg, dest) do {\
51                                                 if ((arg) == NULL || (arg->str) == NULL) {\
52                                                         goto dest;\
53                                                 } \
54                                            } while (0)
55
56
57 #define UG_SAFE_DEL_NAVI_ITEM(x) do {\
58                                         if ((x) != NULL) {\
59                                                 elm_object_item_del(x); \
60                                                 x = NULL;\
61                                         } \
62                                   } while (0)
63
64
65 #define UG_SAFE_FREE_OBJ(x) do {\
66                                 if ((x) != NULL) {\
67                                         evas_object_del(x); \
68                                         x = NULL;\
69                                 } \
70                           } while (0)
71
72 #define UG_SAFE_STRCPY(dest, src) \
73                                 do{if(!dest||!src)break;\
74                                         strncpy (dest , src, sizeof(dest)-1);\
75                                         dest[sizeof(dest)-1] = 0;       }while(0)
76
77 #define UG_SAFE_DEL_ECORE_TIMER(timer) do { \
78                                                 if (timer) { \
79                                                         ecore_timer_del(timer);\
80                                                         timer = NULL; \
81                                                 } \
82                                         } while (0)
83
84 #define goto_if(x, dest) do { \
85                                 if (x) {\
86                                         goto dest;\
87                                 }\
88                         } while (0)
89
90 #define ug_ecore_idler_del(idler) do { \
91                                         if(idler) { \
92                                                 ecore_idler_del(idler);\
93                                                 idler = NULL; \
94                                         } \
95                                 } while (0)
96
97 typedef enum _mf_ug_list_play_state mf_ug_list_play_state;
98
99 enum _mf_ug_list_play_state {
100         PLAY_STATE_INIT = 0,
101         PLAY_STATE_READY,
102         PLAY_STATE_PLAYING,
103         PLAY_STATE_PAUSED,
104         PLAY_STATE_STOP,
105         PLAY_STATE_MAX
106 };
107
108
109 typedef enum _mf_ug_select_mode mf_ug_select_mode;
110 enum _mf_ug_select_mode {
111         SELECT_MODE = 0,
112         SINGLE_FILE_MODE,
113         SINGLE_ALL_MODE,
114         MULTI_FILE_MODE,
115         MULTI_ALL_MODE,
116         EXPORT_MODE,
117         IMPORT_MODE,
118         IMPORT_SINGLE,
119         IMPORT_PATH_SELECT_MODE,
120         SAVE_MODE,
121         SELECT_MODE_MAX
122 };
123
124 typedef enum _mf_ug_drm_mode mf_ug_drm_mode;
125 enum _mf_ug_drm_mode {
126         DRM_FILTER_NONE = 0,
127         DRM_FILTER_ALL,
128         DRM_FILTER_WITHOUT_FL,
129         DRM_FILTER_IMAGE,
130         DRM_FILTER_RINGTONE,
131         DRM_FILTER_MAX
132 };
133
134 typedef enum _mf_ug_marked_switch mf_ug_marked_switch;
135 enum _mf_ug_marked_switch {
136         MARKED_OFF = 0,
137         MARKED_ON,
138 };
139
140 typedef enum _mf_ug_file_filter_type mf_ug_file_filter_type;
141 enum _mf_ug_file_filter_type {
142         SHOW_ALL_LIST = 0,
143         SHOW_IMAGE_LIST,
144         SHOW_SOUND_LIST,
145         SHOW_VIDEO_LIST,
146         SHOW_FLASH_LIST,
147         SHOW_FOLDER_LIST,
148         SHOW_IMAGE_VIDEO_LIST,
149         SHOW_IMAGE_SOUND_LIST,
150         SHOW_VIDEO_SOUND_LIST,
151         SHOW_BY_EXTENSION
152 };
153
154
155
156 typedef enum _mf_ug_state_mode mf_ug_state_mode;
157 enum _mf_ug_state_mode {
158         STATE_PHONE = 0,
159         STATE_MEMORY,
160         STATE_MODE_MAX
161 };
162
163 typedef enum _mf_ug_mmc_insert_state mf_ug_mmc_insert_state;
164 enum _mf_ug_mmc_insert_state {
165         MMC_OFF = 0,
166         MMC_ON
167 };
168
169 typedef enum _mf_ug_launch_type mf_ug_launch_type;
170 enum _mf_ug_launch_type {
171         LAUNCH_TYPE_FORK = 0,
172         LAUNCH_TYPE_FAIL,
173         LAUNCH_TYPE_DIR,
174         LAUNCH_TYPE_IMAGE,
175         LAUNCH_TYPE_MUSIC,
176         LAUNCH_TYPE_VIDEO,
177         LAUNCH_TYPE_UNSUPPORT,
178         LAUNCH_TYPE_MAX
179 };
180
181 typedef enum _mf_ug_eina_list_node_type mf_ug_eina_list_node_type;
182 enum _mf_ug_eina_list_node_type {
183         NODE_TYPE_NONE = 0,
184         NODE_TYPE_CHAR,
185         NODE_TYPE_PNODE,
186         NODE_TYPE_GSTRING,
187         NODE_TYPE_MAX
188 };
189
190 typedef enum _mf_ug_ctrl_bar_type mf_ug_ctrl_bar_type;
191 enum _mf_ug_ctrl_bar_type {
192         CTRL_BAR_NORMAL = 0,
193         CTRL_BAR_MUSIC,
194         CTRL_BAR_RINGTONE,
195         CTRL_BAR_MULTI,
196         CTR_BAR_MAX
197 };
198
199 typedef enum _mf_ug_view_type mf_ug_view_type;
200 enum _mf_ug_view_type {
201         mf_ug_view_root = 0,
202         mf_ug_view_normal,
203         mf_ug_view_max
204 };
205
206 typedef struct _ugListItemData ugListItemData;
207 struct _ugListItemData {
208         Evas_Object *ug_pCheckBox;
209         Evas_Object *ug_pRadioBox;
210         Evas_Object *ug_pPlaybtn;
211         Elm_Object_Item *ug_pItem;
212         char *ug_pThumbPath;
213         GString *ug_pItemName;
214         ugData *ug_pData;
215         bool ug_bChecked;
216         int ug_iGroupValue;
217         bool ug_bRealThumbFlag;
218 };
219
220 typedef struct _ug_dir_event_t ug_dir_event_t;
221 struct _ug_dir_event_t {
222         int event;
223         char *name;
224 };
225
226 typedef enum _mf_ug_theme_type  mf_ug_theme_type;
227 enum _mf_ug_theme_type {
228         UG_THEME_INVALID = -1,
229         UG_THEME_NBEAT = 0,
230         UG_THEME_NBEAT_BLACK = 1,
231         UG_THEME_ERROR
232 };
233
234 typedef enum _mf_ug_more_type_e mf_ug_more_type_e;
235
236 enum _mf_ug_more_type_e{                        /* softkey / contextual popup */
237         UG_MORE_DEFAULT = 0,
238         UG_MORE_CREATE_FOLDER,
239         UG_MORE_SEARCH,
240         UG_MORE_TYPE_MAX
241 };
242
243 typedef enum _mf_ug_file_name_type_e mf_ug_file_name_type_e;
244 enum _mf_ug_file_name_type_e {
245         FILE_NAME_WITH_BRACKETS,
246         FILE_NAME_WITH_UNDERLINE,
247         FILE_NAME_NONE,
248 };
249
250 typedef enum __mf_ug_thumbnail_type_e mf_ug_thumbnail_type_e;
251 enum __mf_ug_thumbnail_type_e {
252         MF_UG_THUMBNAIL_TYPE_DEFAULT,
253         MF_UG_THUMBNAIL_TYPE_THUMBNAIL,
254         MF_UG_THUMBNAIL_TYPE_MAX
255 };
256
257 bool mf_ug_util_is_mass_storage_on();
258 int mf_ug_util_create_dir_monitor(void *data);
259 int mf_ug_util_set_mmc_state_cb(void *data);
260 int mf_ug_util_get_mmc_state(int *mmc_card);
261 char *mf_ug_util_get_send_result(void *data);
262 bool mf_ug_util_is_genlist_selected(void *data);
263
264 void mf_ug_list_play_play_music_item(ugListItemData *data);
265 void mf_ug_list_play_destory_playing_file(void *data);
266 void mf_ug_list_play_update_item_icon(void *data);
267
268 void mf_ug_util_storage_insert_action(void *data, char *pItemLabel);
269 void mf_ug_util_destory_mmc_state_cb();
270 void mf_ug_util_destory_dir_monitor(void *data);
271 void mf_ug_util_get_params_path(Eina_List **dest_list, const char *path_list);
272 void mf_ug_util_free_eina_list_data(Eina_List **list, mf_ug_eina_list_node_type node_type);
273 void mf_ug_util_set_current_state(void *data, int state);
274 int mf_ug_util_add_dir_watch(const char *path, void *data);
275 mf_ug_launch_type mf_ug_util_get_file_launch_type(char *path);
276
277 void mf_ug_util_destory_mass_storage_callback();
278 mf_ug_theme_type mf_ug_util_get_theme(void);
279 int mf_ug_file_attr_get_parent_path(const char *path, char **parent_path);
280 char *mf_ug_util_upper_folder_name_get(void *data, GString *fullpath);
281 void mf_ug_util_operation_alloc_failed(void *data);
282 int mf_ug_util_remove_dir_watch(void);
283 void mf_ug_util_sort_the_file_list(void *data);
284 int mf_ug_util_check_disk_space(void *data);
285 long mf_ug_util_character_count_get(const char *original);
286
287 #endif /* __DEF_MYFILE_UTIL_H_ */