f740ce30ac459562c51fa333cd34bc64f74e2834
[apps/core/preloaded/music-player.git] / src / include / music.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 #ifndef __DEF_music_H_
19 #define __DEF_music_H_
20
21 #include <Elementary.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <stdbool.h>
25 #include <unistd.h>
26 #include <glib.h>
27 #include <vconf.h>
28 #include <Ecore_IMF.h>
29 #include <Ecore_X.h>
30 #include <app.h>
31 #include <Edje.h>
32 #include <errno.h>
33 #include <libintl.h>
34 #include <ui-gadget.h>
35
36 #include <sys/times.h>
37
38 #include "mp-define.h"
39 #include "mp-player-debug.h"
40 #include "mp-player-drm.h"
41
42 #include "mp-define.h"
43 #include "mp-playlist-mgr.h"
44
45 #include "mp-http-mgr.h"
46 #include "mp-ta.h"
47 #include "mp-language-mgr.h"
48 #include "mp-media-info.h"
49
50 #include "mp-lyric-view.h"
51 #include "mp-lyric-mgr.h"
52 #include "mp-play-view.h"
53
54
55 #ifdef MP_SOUND_PLAYER
56 #include "sp-view-manager.h"
57 #endif
58
59 E_DBus_Connection *EDBusHandle;
60
61 typedef struct
62 {
63
64         /* controlbar tab item */
65         Elm_Object_Item *ctltab_songs;
66         Elm_Object_Item *ctltab_plist;
67         Elm_Object_Item *ctltab_album;
68         Elm_Object_Item *ctltab_artist;
69         Elm_Object_Item *ctltab_genres;
70         Elm_Object_Item *ctltab_year;
71         Elm_Object_Item *ctltab_composer;
72         Elm_Object_Item *ctltab_folder;
73
74
75
76         bool allshare;
77
78         bool first_append;
79 } mp_library;
80
81
82 #define MP_VIEW_DATA_MAGIC      0x801211aa
83 #define MP_SET_VIEW_DATA_MAGIC(view_data)       ((view_data_t *)view_data)->magic = MP_VIEW_DATA_MAGIC
84 #define MP_CHECK_VIEW_DATA(view_data)   \
85 do {                                                  \
86         if (((view_data_t *)view_data)->magic != MP_VIEW_DATA_MAGIC) {        \
87                 ERROR_TRACE("\n###########      ERROR   CHECK  #############\nPARAM is not view_data\n###########      ERROR   CHECK  #############\n"); \
88                 mp_assert(FALSE);}            \
89 } while (0)
90
91
92 typedef struct
93 {
94         Evas_Object *layout;
95         void *EvasPlugin;
96         Evas_Object *box;
97         Evas_Object *dali_obj;
98
99         Ecore_Timer *mouse_up_timer;
100         Ecore_Timer *now_playing_timer;
101
102         Evas_Object *track_list;
103         Evas_Object *track_genlist;
104         bool show_track_list;
105
106         int        track_count;
107
108         Evas_Object *now_playing;
109         Evas_Object *now_playing_icon;
110         Evas_Object *all_tracks;
111         bool all_tracks_click;
112         Evas_Object* ctxpopup;
113         int all_tracks_type;
114
115         Evas_Object *back_button;
116
117         int now_playing_album_seq;
118
119         char *cur_artist;
120         char *cur_album;
121
122         Ecore_Job *refresh_job;
123
124         struct appdata *ad;
125 } mp_coverflow_view;
126
127 typedef struct
128 {
129         char *uri;
130         char *title;
131         char *artist;
132         char *album;
133         char *genre;
134         char *location;
135         char *format;
136
137         int duration;
138
139         char *thumbnail_path;
140         char *copyright;
141
142         char *author;
143         char *track_num;
144         bool favorite;
145 }mp_track_info_t;
146
147 enum
148 {
149         MP_CREATE_PLAYLIST_MODE_NONE,
150         MP_CREATE_PLAYLIST_MODE_NEW,
151         MP_CREATE_PLAYLIST_MODE_WITHMUSICS,
152         MP_CREATE_PLAYLIST_MODE_SAVEAS,
153         MP_CREATE_PLAYLIST_MODE_SWEEP
154 };
155
156 typedef enum
157 {
158         MP_LAUNCH_DEFAULT = 0,  //normal case
159         MP_LAUNCH_BY_PATH,              //ug case
160         MP_LAUNCH_ADD_TO_HOME,  //add to home
161         MP_LAUNCH_PLAY_RECENT,
162         MP_LAUNCH_LIVE_BOX,
163
164
165 } mp_launch_type;
166
167 typedef enum
168 {
169         LOAD_DEFAULT,
170         LOAD_TRACK,             //load by path
171         LOAD_GROUP,             //load by shortcut
172         LOAD_PLAYLIST,          //load by shortcut
173         LOAD_MM_KEY,
174
175 } mp_load_type;
176
177 typedef enum
178 {
179         MP_SPLIT_VIEW_TYPE_NORMAL = 0,
180         MP_SPLIT_VIEW_TYPE_FULL,
181 } mp_split_view_type;
182
183 typedef struct mp_split_view
184 {
185         Evas_Object *layout;
186         Evas_Object *left_layout;
187         Evas_Object *right_layout;
188         Evas_Object *list;
189         Evas_Object *fast_index;
190         mp_split_view_type current_split_view_type;
191         Ecore_Timer *idle_timer;
192         Ecore_Idler *idle_idler;
193 } mp_split_view;
194
195
196 typedef enum
197 {
198         MP_POPUP_NORMAL = 0,
199         MP_POPUP_GENLIST,
200         MP_POPUP_CTX,
201         MP_POPUP_PROGRESS,
202         MP_POPUP_NOTIFY,        // NOT destroyed by mp_popup_destroy()
203         MP_POPUP_MAX,
204 } mp_popup_type;
205
206 typedef enum
207 {
208         PLAY_STATE_NONE,
209         PLAY_STATE_CREATED,
210         PLAY_STATE_PREPARING,
211         PLAY_STATE_READY,
212         PLAY_STATE_PLAYING,
213         PLAY_STATE_PAUSED,
214 } mp_player_state;
215
216 typedef enum {
217         MP_SEND_TYPE_MESSAGE,
218         MP_SEND_TYPE_EMAIL,
219         MP_SEND_TYPE_BLUETOOTH,
220         MP_SEND_TYPE_WIFI,
221         MP_SEND_TYPE_NFC,
222         MP_SEND_TYPE_NUM,
223 } mp_send_type_e;
224
225 typedef enum {
226         MP_MORE_BUTTON_TYPE_DEFAULT,
227         MP_MORE_BUTTON_TYPE_TRACK_LIST,
228         MP_MORE_BUTTON_TYPE_MAX,
229 } mp_more_button_type_e;
230
231 struct appdata
232 {
233
234         Evas *evas;
235         Evas_Object *win_main;
236         Evas_Object *bg;
237         Evas_Object *popup[MP_POPUP_MAX];
238         Ecore_Idler *popup_del_idler;
239         int win_angle;
240
241         Ecore_X_Window xwin;
242
243 #ifdef MP_FEATURE_EXIT_ON_BACK
244         Ecore_Event_Handler *callerWinEventHandler;
245         unsigned int caller_win_id;
246 #endif
247         /* Layout for each view */
248         Evas_Object *conformant;
249         Evas_Object *base_layout_main;          //layout for transparent indicator area
250         Evas_Object *naviframe;
251         Evas_Object *controlbar_layout;         //layout for show hide controlbar.
252
253         bool show_optional_menu;
254         double music_pos;
255         double music_length;
256         //int isDragging;
257         Ecore_Timer *progressbar_timer;
258
259         mp_playing_view *playing_view;
260
261
262         // for Plalying Control
263         bool can_play_drm_contents;
264         bool show_now_playing;
265
266         mp_player_state player_state;
267
268         Evas_Object *bgimage;
269
270         mp_drm drm_info;
271         mp_constraints_info_s drm_constraints_info;
272         char * latest_playing_key_id;
273
274         mp_plst_mgr *playlist_mgr;
275
276         mp_launch_type launch_type;     // Support Play from outside
277         mp_load_type loadtype;  // Support Add to home
278         mp_track_type_e track_type;     // Support voice ui
279         mp_group_type_e group_type;     // Support voice ui
280
281         char *request_group_name;
282         char *request_playing_path;
283         mp_group_type_e request_group_type;
284         int request_play_id;
285         // update default view layout if this flag set. set true when album/artist/genre short cut pressed.
286         bool update_default_view;
287
288         Ecore_IMF_Context *imf_context;
289 #ifdef MP_SOUND_PLAYER
290         Sp_View_Manager *view_mgr;
291 #else
292         mp_library *library;
293         GList *view_history;
294 #endif
295         Evas_Object *tabbar;
296         Evas_Object *genlist_edit;
297
298         Evas_Object *editfiled_new_playlist;
299         Evas_Object *editfiled_entry;
300         char *new_playlist_name;
301
302         bool b_add_tracks;
303
304         int new_playlist_id;
305
306         struct {
307                 bool  downed;
308                 bool  moving;
309                 Evas_Coord sx;
310                 Evas_Coord sy;
311         } mouse;
312
313         Evas_Object *radio_group;
314
315         Evas_Object *popup_delete;
316         Evas_Object *notify_delete;
317
318         bool b_search_mode;
319         Evas_Object *isf_entry;
320         Evas_Object *editfield;
321
322         bool freeze_indicator_icon;     //set it true to prevent flickering play icon of indicator.
323
324         int ear_key_press_cnt;
325         Ecore_Timer *ear_key_timer;
326
327         Evas_Object *win_minicon;
328         Evas_Object *minicontroller_layout;
329         Evas_Object *minicon_icon;
330         Ecore_Timer *minicon_timer;
331         Ecore_Timer *minicon_progress_timer;
332         bool b_minicontroller_show;
333         bool minicon_visible;
334
335         mp_playing_view *backup_playing_view;
336         Evas_Object *backup_layout_play_view;   //Used to swap the Playing layout from Landscape and Portrait.
337         mp_split_view *split_view;
338         double latest_moved_left_size;
339
340         int current_appcore_rm;
341         mp_screen_mode screen_mode;
342
343         int screen_height;      //current screen height
344         int screen_width;       //current screen width
345
346         Evas_Object *edit_ctrl_bar;
347
348         Ecore_Pipe *inotify_pipe;
349
350         // for add to playlist
351         void *layout_data;
352         mp_media_info_h group_item_handler;
353         char *fid;
354
355         bool paused_by_user;
356
357         mp_http_mgr_t *http_mgr;
358
359         bool navi_effect_in_progress;   // Use this not to excute button callbacks while transition effect
360
361         bool app_is_foreground; // relaunch only available when music is in pause state
362         bool is_lcd_off;
363
364         bool is_focus_out;      // update minicontroller in bgm mode.
365
366         mp_snd_path snd_path;   // indicate sound path;
367
368         Ecore_Event_Handler *key_down;
369         Ecore_Event_Handler *key_up;
370         Ecore_Event_Handler *mouse_button_down;
371         Ecore_Event_Handler *focus_in;
372         Ecore_Event_Handler *focus_out;
373         Ecore_Event_Handler *visibility_change;
374         Ecore_Event_Handler *client_msg;
375         Ecore_Event_Handler *mouse_button_up;
376         Ecore_Event_Handler *mouse_move;
377         Ecore_Event_Handler *property;
378
379         int motion_handle;
380
381         Evas_Object *buffering_popup;
382
383         ui_gadget_h ug;
384         ui_gadget_h setting_ug;
385         ui_gadget_h info_ug;    //info ug handle - Do not destory info ug.
386         Evas_Object *info_ug_base;      //if thist is not null, info ug is visible. use this to determine info view is exist or not.
387         Evas_Object *info_ug_layout; //do not del this object. if it is deleted, info ug layout will not be displayed properly.
388         bool info_click_flag;     //flag for click info button in play view
389         bool info_back_play_view_flag;     //flag for info view back  play view
390
391         bool edit_in_progress;  // don't update view in inotify callback while delete operation.
392
393         Ecore_Timer *volume_down_timer;
394         Ecore_Timer *mute_popup_show_timer;     //timer for showing mute popup
395         bool volume_long_pressed;
396         bool mute_flag;         //flag for mute
397
398         double ff_rew;          // for ff and rew when there is no play view
399
400         bool music_setting_change_flag; //true for change music setting data, false for not
401
402         bool load_play_view; /*set it true if play view must be displayed directly when app is launching*/
403
404         bool is_Longpress;
405         bool is_ff;
406
407         Ecore_Idler *mss_startup_idler;
408         Ecore_Idler *bt_pause_idler;
409         Ecore_Idler *setting_idler;
410         Ecore_Idler *app_init_idler;
411         Ecore_Idler *playview_show_idler;
412
413         Ecore_Timer *longpress_timer;
414         bool seek_off;
415
416         mp_lyric_mgr_t *lyric_mgr;
417         mp_lyric_view_t *lyric_view;
418         bool b_show_lyric;
419         bool vertical_scroll;
420
421         char *shortcut_descrition;
422
423         Ecore_Animator *minfo_ani;
424         GList *minfo_list;
425         Evas_Object *minfo_genlist;
426
427         bool direct_win_minimize;
428
429         int album_image_w;
430         int album_image_h;
431
432         bool paused_by_other_player;
433
434         mp_track_info_t *current_track_info;
435
436
437
438
439 #ifdef MP_FEATURE_AUTO_OFF
440         Ecore_Timer *auto_off_timer;
441         Ecore_Timer *pause_off_timer;
442 #endif
443
444
445         Evas_Object *more_btn_popup;
446         mp_more_button_type_e more_btn_type;
447
448 };
449
450
451 typedef void (*mpOptCallBack) (void *, Evas_Object *, void *);
452
453 typedef struct
454 {
455         const char *name;
456         mpOptCallBack cb;
457 } MpOptItemType;
458
459 typedef struct
460 {
461         MpOptItemType *l_opt;
462         MpOptItemType *m_opt;
463         MpOptItemType *r_opt;
464 } MpOptGroupType;
465
466 #endif /* __DEF_music_H__ */