summaryrefslogtreecommitdiff
path: root/src/include/mf-ug-util.h
blob: e8e9bc3cb4d94fc50d765f97f73aa64dbb0014b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*
 * myfile
 *
 * Copyright 2012  Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.tizenopensource.org/license
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */




#ifndef __DEF_MF_UG_UTIL_H_
#define __DEF_MF_UG_UTIL_H_

#include <Elementary.h>
#include <stdbool.h>
#include <glib.h>

#include "mf-ug-main.h"

#define UG_SAFE_FREE_CHAR(x) do {\
					if ((x) != NULL) {\
						free(x); \
						x = NULL;\
					} \
			     } while (0)

#define UG_SAFE_FREE_GSTRING(x) do {\
					if ((x) != NULL) {\
						g_string_free(x, TRUE); \
						x = NULL;\
					} \
				} while (0)

#define UG_CHAR_CHECK_NULL_GOTO(arg, dest) do {\
						if ((arg) == NULL) {\
							goto dest;\
						} \
					   } while (0)

#define UG_GSTRING_CHECK_NULL_GOTO(arg, dest) do {\
						if ((arg) == NULL || (arg->str) == NULL) {\
							goto dest;\
						} \
					   } while (0)


#define UG_SAFE_DEL_NAVI_ITEM(x) do {\
					if ((x) != NULL) {\
						elm_object_item_del(x); \
						x = NULL;\
					} \
				  } while (0)


#define UG_SAFE_FREE_OBJ(x) do {\
				if ((x) != NULL) {\
					evas_object_del(x); \
					x = NULL;\
				} \
			  } while (0)

#define UG_SAFE_STRCPY(dest, src) \
				do{if(!dest||!src)break;\
					strncpy (dest , src, sizeof(dest)-1);\
					dest[sizeof(dest)-1] = 0;	}while(0)

#define UG_SAFE_DEL_ECORE_TIMER(timer) do { \
						if (timer) { \
							ecore_timer_del(timer);\
							timer = NULL; \
						} \
					} while (0)

#define goto_if(x, dest) do { \
				if (x) {\
					goto dest;\
				}\
			} while (0)
typedef enum _mf_ug_list_play_state mf_ug_list_play_state;

enum _mf_ug_list_play_state {
	PLAY_STATE_INIT = 0,
	PLAY_STATE_READY,
	PLAY_STATE_PLAYING,
	PLAY_STATE_PAUSED,
	PLAY_STATE_STOP,
	PLAY_STATE_MAX
};


typedef enum _mf_ug_select_mode mf_ug_select_mode;
enum _mf_ug_select_mode {
	SELECT_MODE = 0,
	SINGLE_FILE_MODE,
	SINGLE_ALL_MODE,
	MULTI_FILE_MODE,
	MULTI_ALL_MODE,
	EXPORT_MODE,
	IMPORT_MODE,
	SELECT_MODE_MAX
};

typedef enum _mf_ug_drm_mode mf_ug_drm_mode;
enum _mf_ug_drm_mode {
	DRM_FILTER_NONE = 0,
	DRM_FILTER_ALL,
	DRM_FILTER_WITHOUT_FL,
	DRM_FILTER_IMAGE,
	DRM_FILTER_RINGTONE,
	DRM_FILTER_MAX
};

typedef enum _mf_ug_marked_switch mf_ug_marked_switch;
enum _mf_ug_marked_switch {
	MARKED_OFF = 0,
	MARKED_ON,
};

typedef enum _mf_ug_file_filter_type mf_ug_file_filter_type;
enum _mf_ug_file_filter_type {
	SHOW_ALL_LIST = 0,
	SHOW_IMAGE_LIST,
	SHOW_SOUND_LIST,
	SHOW_VIDEO_LIST,
	SHOW_FLASH_LIST,
	SHOW_FOLDER_LIST,
	SHOW_IMAGE_VIDEO_LIST,
	SHOW_IMAGE_SOUND_LIST,
	SHOW_VIDEO_SOUND_LIST,
	SHOW_BY_EXTENSION
};



typedef enum _mf_ug_state_mode mf_ug_state_mode;
enum _mf_ug_state_mode {
	STATE_PHONE = 0,
	STATE_MEMORY,
	STATE_MODE_MAX
};

typedef enum _mf_ug_mmc_insert_state mf_ug_mmc_insert_state;
enum _mf_ug_mmc_insert_state {
	MMC_OFF = 0,
	MMC_ON
};

typedef enum _mf_ug_launch_type mf_ug_launch_type;
enum _mf_ug_launch_type {
	LAUNCH_TYPE_FORK = 0,
	LAUNCH_TYPE_FAIL,
	LAUNCH_TYPE_DIR,
	LAUNCH_TYPE_IMAGE,
	LAUNCH_TYPE_MUSIC,
	LAUNCH_TYPE_VIDEO,
	LAUNCH_TYPE_UNSUPPORT,
	LAUNCH_TYPE_MAX
};

typedef enum _mf_ug_eina_list_node_type mf_ug_eina_list_node_type;
enum _mf_ug_eina_list_node_type {
	NODE_TYPE_NONE = 0,
	NODE_TYPE_CHAR,
	NODE_TYPE_PNODE,
	NODE_TYPE_GSTRING,
	NODE_TYPE_MAX
};

typedef enum _mf_ug_ctrl_bar_type mf_ug_ctrl_bar_type;
enum _mf_ug_ctrl_bar_type {
	CTRL_BAR_NORMAL = 0,
	CTRL_BAR_MUSIC,
	CTRL_BAR_RINGTONE,
	CTRL_BAR_MULTI,
	CTR_BAR_MAX
};

typedef struct _ugListItemData ugListItemData;
struct _ugListItemData {
	Evas_Object *ug_pCheckBox;
	Evas_Object *ug_pRadioBox;
	Elm_Object_Item *ug_pItem;
	char *ug_pThumbPath;
	GString *ug_pItemName;
	ugData *ug_pData;
	bool ug_bChecked;
	int ug_iGroupValue;
	bool ug_bRealThumbFlag;
};

typedef struct _ug_dir_event_t ug_dir_event_t;
struct _ug_dir_event_t {
	int event;
	char *name;
};

typedef enum _mf_ug_theme_type	mf_ug_theme_type;
enum _mf_ug_theme_type {
	UG_THEME_INVALID = -1,
	UG_THEME_NBEAT = 0,
	UG_THEME_NBEAT_BLACK = 1,
	UG_THEME_ERROR
};

typedef enum _mf_ug_more_type_e	mf_ug_more_type_e;

enum _mf_ug_more_type_e{			/* softkey / contextual popup */
	UG_MORE_DEFAULT = 0,
	UG_MORE_CREATE_FOLDER,
	UG_MORE_SEARCH,
	UG_MORE_TYPE_MAX
};

typedef enum _mf_ug_file_name_type_e mf_ug_file_name_type_e;
enum _mf_ug_file_name_type_e {
	FILE_NAME_WITH_BRACKETS,
	FILE_NAME_WITH_UNDERLINE,
	FILE_NAME_NONE,
};

bool mf_ug_util_is_mass_storage_on();
int mf_ug_util_create_dir_monitor(void *data);
int mf_ug_util_set_mmc_state_cb(void *data);
int mf_ug_util_get_mmc_state(int *mmc_card);
char *mf_ug_util_get_send_result(void *data);
bool mf_ug_util_is_genlist_selected(void *data);

void mf_ug_list_play_play_music_item(ugListItemData *data);
void mf_ug_list_play_destory_playing_file(void *data);
void mf_ug_list_play_update_item_icon(void *data);

void mf_ug_util_storage_insert_action(void *data, char *pItemLabel);
void mf_ug_util_destory_mmc_state_cb();
void mf_ug_util_destory_dir_monitor(void *data);
void mf_ug_util_get_params_path(Eina_List **dest_list, const char *path_list);
void mf_ug_util_free_eina_list_data(Eina_List **list, mf_ug_eina_list_node_type node_type);
int mf_ug_util_set_main_layout_by_tab_item_count(void *data);
void mf_ug_util_set_current_state(void *data, int state);
int mf_ug_util_add_dir_watch(const char *path, void *data);
mf_ug_launch_type mf_ug_util_get_file_launch_type(char *path);

void mf_ug_util_destory_mass_storage_callback();
mf_ug_theme_type mf_ug_util_get_theme(void);
int mf_ug_file_attr_get_parent_path(const char *path, char **parent_path);
char *mf_ug_util_upper_folder_name_get(void *data, GString *fullpath);
void mf_ug_util_operation_alloc_failed(void *data);
int mf_ug_util_remove_dir_watch(void);
void mf_ug_util_sort_the_file_list(void *data);
bool mf_ug_util_play_vibration(void *data, float duration);
int mf_ug_util_check_disk_space(void *data);

#endif /* __DEF_MYFILE_UTIL_H_ */