disable playlist menu
[profile/tv/apps/native/musicplayer.git] / src / views / base-view.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
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 #include <AppCommon.h>
18 #include "i18n.h"
19 #include "define.h"
20 #include "common.h"
21 #include "song_info.h"
22 #include "album_info.h"
23 #include "folder_info.h"
24 #include "category_info.h"
25 #include "music-controller.h"
26 #include "ExtBaseLayout.h"
27 #include "Info.h"
28 #include "SourceCtxPopup.h"
29 #include "SortCtxPopup.h"
30 #include "base-view.h"
31 #include "common-ui.h"
32 #include "volume-control.h"
33 #include "song-layout.h"
34 #include "album-layout.h"
35 #include "category-layout.h"
36 #include "folder-layout.h"
37 #include "album-songs-layout.h"
38 #include "playback-view.h"
39 #include "artist-layout.h"
40 #include "genre-layout.h"
41 #include "playlist-layout.h"
42 #include "HandleVolume.h"
43
44 #define ARRAY_SIZE(array)       (sizeof(array) / sizeof(array[0]))
45 #define PLAYSONG_FONT_SIZE      30
46 #define TOTAL_GROUP_BTNS        5
47 #define TOTAL_TOP_BTNS          3
48 #define VOLUME_TIMER_INTERVAL   5       /* seconds */
49 #define MAX_SHOW_TIME           10
50 #define MUSIC_SLIDE_DURATION    15
51 #define MUSIC_WRAP_WIDTH        400
52
53
54 const char *g_sourceText[] = {
55         N_("All Source"), // SOURCE_TYPE_ALL
56         N_("TV"),         // SOURCE_TYPE_TV
57         N_("USB")         // SOURCE_TYPE_USB
58 };
59
60 const char *g_sortText[] = {
61         N_("Title A-Z"),  // E_SORT_TITLE_A_Z
62         N_("Title Z-A"),  // E_SORT_TITLE_Z_A
63         N_("Artist A-Z"), // E_SORT_ARTIST_A_Z
64         N_("Artist Z-A"), // E_SORT_ARTIST_Z_A
65         N_("Album A-Z"),  // E_SORT_ALBUM_A_Z
66         N_("Album Z-A")   // E_SORT_ALBUM_Z_A
67 };
68
69 const char *g_sortTextAlbum[] = {
70         N_("Album A-Z"),
71         N_("Album Z-A")
72 };
73
74 const char *g_sortTextArtist[] = {
75         N_("Artist A-Z"),
76         N_("Artist Z-A")
77 };
78
79 const char *g_sortTextGenre[] = {
80         N_("Genre A-Z"),
81         N_("Genre Z-A")
82 };
83
84 const char *g_sortTextFolder[] = {
85         N_("Title A-Z"),
86         N_("Title Z-A")
87 };
88
89 const char *g_sortTextPlaylists[] = {
90         N_("Playlist A-Z"),
91         N_("Playlist Z-A")
92 };
93
94 const char *g_sourceArg[] = {
95         "all", // SOURCE_TYPE_ALL
96         "tv",  // SOURCE_TYPE_TV
97         "usb"  // SOURCE_TYPE_USB
98 };
99
100 enum EObjectType {
101         BASE_VIEW,
102
103         BASE_VIEW_PLAY_BUTTON,
104         BASE_VIEW_SOURCE_BUTTON,
105         BASE_VIEW_SORT_BUTTON,
106
107         BASE_VIEW_GROUP_SONG,
108         BASE_VIEW_GROUP_ALBUM,
109         BASE_VIEW_GROUP_ARTIST,
110         BASE_VIEW_GROUP_GENRE,
111         BASE_VIEW_GROUP_FOLDER,
112         BASE_VIEW_GROUP_PLAYLIST,
113 };
114
115 enum EBtnType {
116         BTN_PLAY,
117         BTN_SOURCE,
118         BTN_SORT
119 };
120
121 enum EGroupBtnType {
122         GROUP_BTN_SONG,
123         GROUP_BTN_ALBUM,
124         GROUP_BTN_ARTIST,
125         GROUP_BTN_GENRE,
126         GROUP_BTN_FOLDER,
127         GROUP_BTN_PLAYLIST
128 };
129
130 struct SMusicBaseView {
131         Evas_Object *win;
132         Evas_Object *base;
133         Evas_Object *content;
134         Evas_Object *plbackbtn;
135         Evas_Object *plsonglbl;
136         Evas_Object *group_btn[TOTAL_GROUP_BTNS];
137         Evas_Object *srcbtn;
138         Evas_Object *sortbtn;
139         CSortCtxPopup *sortCtxPopup;
140         CSourceCtxPopup *srcCtxPopup;
141         Evas_Object *popup;
142         Elm_Transit *transit;
143         Evas_Object *c_grpbtn;
144         CMusicController *pController;
145         CLayoutMgr *lmgr;
146         SArgList *arglist;
147         int btntype;
148         bool fresh_view;
149         bool srcBtnFocusedBySecondBtn;
150
151         CSongLayout   *layoutSong;
152         CAlbumLayout  *layoutAlbum;
153         CArtistLayout *layoutArtist;
154         CGenreLayout  *layoutGenre;
155         CPlaylistLayout *layoutPlaylists;
156         CFolderLayout *layoutFolder;
157
158         CHandleVolume *pHandleVolume;
159
160         Ecore_Idler *eiShowLayout;
161
162         SMusicBaseView() {
163                 memset(this, 0, sizeof(SMusicBaseView));
164                 pHandleVolume = new CHandleVolume;
165         }
166         ~SMusicBaseView() {
167                 delete pHandleVolume;
168         }
169 };
170
171 struct SBtnInfo {
172         const char *txt;
173         const char *part;
174         const char *style;
175         const char *icon_path;
176         EObjectType type;
177 };
178
179
180 Evas_Object *s_AddButton(Evas_Object *box)
181 {
182         Evas_Object *button;
183
184         if (!box)
185                 return NULL;
186
187         button = elm_button_add(box);
188         if (!button)
189                 return NULL;
190
191         evas_object_size_hint_weight_set(button,
192                 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
193         evas_object_show(button);
194
195         return button;
196 }
197
198 void CMusicBaseView::sm_CbHandleEmptyStatus(void *cookie, bool emptyStatus)
199 {
200         CMusicBaseView *root = (CMusicBaseView*)cookie;
201         if (root)
202                 root->m_OnHandleEmptyStatus(emptyStatus);
203 }
204
205
206 void CMusicBaseView::m_OnHandleEmptyStatus(bool emptyStatus)
207 {
208         if (emptyStatus)
209                 m_UpdateEmptyFocusSequence();
210         else
211                 m_UpdateFocusSequence();
212 }
213
214
215 void CMusicBaseView::m_UpdateFocusSequence(void)
216 {
217         int i;
218
219         for (i = 0; i < TOTAL_GROUP_BTNS; i++)
220                 elm_object_focus_next_object_set(m->group_btn[i],
221                 m->content, ELM_FOCUS_RIGHT);
222
223         elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_SONG], m->group_btn[GROUP_BTN_PLAYLIST], ELM_FOCUS_UP);
224         elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_PLAYLIST], m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN);
225
226         if (m->c_grpbtn != NULL)
227                 elm_object_focus_next_object_set(m->plbackbtn, m->c_grpbtn, ELM_FOCUS_LEFT);
228         else
229                 elm_object_focus_next_object_set(m->plbackbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_LEFT);
230
231         elm_object_focus_next_object_set(m->plbackbtn, m->plbackbtn, ELM_FOCUS_DOWN);
232         elm_object_focus_next_object_set(m->srcbtn, m->srcbtn, ELM_FOCUS_DOWN);
233         elm_object_focus_next_object_set(m->sortbtn, m->sortbtn, ELM_FOCUS_DOWN);
234
235         elm_object_part_text_set(Base(), MUSIC_PART_NO_CONTENT,     MUSIC_STR_EMPTY);
236         elm_object_part_text_set(Base(), MUSIC_PART_NO_CONTENT_SUB, MUSIC_STR_EMPTY);
237 }
238
239
240 void CMusicBaseView::m_UpdateEmptyFocusSequence(void)
241 {
242         int i;
243
244         for (i = 0; i < TOTAL_GROUP_BTNS; i++)
245                 elm_object_focus_next_object_set(m->group_btn[i],
246                 m->plbackbtn, ELM_FOCUS_RIGHT);
247
248         elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_SONG], m->group_btn[GROUP_BTN_PLAYLIST], ELM_FOCUS_UP);
249         elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_PLAYLIST], m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN);
250         elm_object_focus_next_object_set(m->plbackbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_LEFT);
251         elm_object_focus_next_object_set(m->plbackbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN);
252         elm_object_focus_next_object_set(m->srcbtn,    m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN);
253         elm_object_focus_next_object_set(m->sortbtn,   m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN);
254
255         elm_object_part_text_set(Base(), MUSIC_PART_NO_CONTENT,     _(NO_MUSIC_MESSAGE));
256         elm_object_part_text_set(Base(), MUSIC_PART_NO_CONTENT_SUB, _(NO_MUSIC_MESSAGE_SUB));
257 }
258
259
260 void CMusicBaseView::m_ShowCurrentLayout(void)
261 {
262         const char *layoutId = NULL;
263         Evas_Object *evasLayout = NULL;
264
265         elm_object_part_content_unset(Base(), MUSIC_PART_CONTENT);
266
267         if (m->c_grpbtn == m->group_btn[GROUP_BTN_SONG]) {
268                 layoutId = MUSIC_SONG_LAYOUT;
269                 evasLayout = m->layoutSong->Layout();
270         }
271         else if (m->c_grpbtn == m->group_btn[GROUP_BTN_ALBUM]) {
272                 layoutId = MUSIC_ALBUM_LAYOUT;
273                 evasLayout = m->layoutAlbum->Layout();
274         }
275         else if (m->c_grpbtn == m->group_btn[GROUP_BTN_ARTIST]) {
276                 layoutId = MUSIC_CATEGORY_ARTIST_LAYOUT;
277                 evasLayout = m->layoutArtist->Layout();
278         }
279         else if (m->c_grpbtn == m->group_btn[GROUP_BTN_GENRE]) {
280                 layoutId = MUSIC_CATEGORY_GENRE_LAYOUT;
281                 evasLayout = m->layoutGenre->Layout();
282         }
283         else if (m->c_grpbtn == m->group_btn[GROUP_BTN_PLAYLIST]) {
284                 layoutId = MUSIC_CATEGORY_PLAYLISTS_LAYOUT;
285                 evasLayout = m->layoutPlaylists->Layout();
286         }
287         else if (m->c_grpbtn == m->group_btn[GROUP_BTN_FOLDER]) {
288                 layoutId = MUSIC_FOLDER_LAYOUT;
289                 evasLayout = m->layoutFolder->Layout();
290         }
291
292         CExtBaseLayout *layout = (CExtBaseLayout*)m->lmgr->Layout();
293         if (layout && layout->EmptyStatus() == true) {
294                 m_UpdateEmptyFocusSequence();
295         }
296         else {
297                 elm_object_part_content_set(Base(), MUSIC_PART_CONTENT, evasLayout);
298                 m->lmgr->Show(layoutId);
299                 m_UpdateFocusSequence();
300         }
301 }
302
303
304 void CMusicBaseView::m_GotoPlayback(void)
305 {
306         SParcel parcel;
307         memset(&parcel, 0, sizeof(SParcel));
308         parcel.updateType = E_PLAYLIST_UPDATE;
309
310         t_OnHide();
311
312         if (!CViewMgr::GetInstance()->UpdateView(MUSIC_PLAYBACK_VIEW, &parcel))
313                 _ERR("CViewMgr::UpdateView MUSIC_PLAYBACK_VIEW failed ");
314
315         if (!CViewMgr::GetInstance()->ShowView(MUSIC_PLAYBACK_VIEW))
316                 _ERR("CViewMgr::ShowView MUSIC_PLAYBACK_VIEW failed ");
317 }
318
319
320 void CMusicBaseView::m_CreateCtxPopup(int btnType)
321 {
322         const char *layout_id = NULL;
323         CContextPopup::SCallback cb;
324         cb.onSelected = sm_CbCtxPopupBtnSelected;
325         cb.cookie = this;
326
327         if (btnType == BTN_SOURCE) {
328                 CSourceCtxPopup *srcCtxPopup = NULL;
329                 m->btntype = btnType;
330                 srcCtxPopup = new CSourceCtxPopup;
331                 srcCtxPopup->Create(Base(), &cb);
332
333                 m->srcCtxPopup = srcCtxPopup;
334         }
335         else if (btnType == BTN_SORT) {
336                 CSortCtxPopup *sortCtxPopup = NULL;
337                 CSortCtxPopup::ESortBtnType sortBtnType = CSortCtxPopup::TYPE_SONG;
338                 m->btntype = btnType;
339                 layout_id = m->lmgr->Layout()->LayoutId();
340                 sortCtxPopup = new CSortCtxPopup;
341                 if (layout_id) {
342                         if (!strcmp(layout_id, MUSIC_SONG_LAYOUT)) {
343                                 sortBtnType = CSortCtxPopup::TYPE_SONG;
344                         }
345                         else if (!strcmp(layout_id, MUSIC_ALBUM_LAYOUT)) {
346                                 sortBtnType = CSortCtxPopup::TYPE_ALBUM;
347                         }
348                         else if (!strcmp(layout_id, MUSIC_FOLDER_LAYOUT)) {
349                                 sortBtnType = CSortCtxPopup::TYPE_FOLDER;
350                         }
351                         else if (!strcmp(layout_id, MUSIC_CATEGORY_PLAYLISTS_LAYOUT)) {
352                                 sortBtnType = CSortCtxPopup::TYPE_PLAYLIST;
353                         }
354                         else if (!strcmp(layout_id, MUSIC_CATEGORY_ARTIST_LAYOUT)) {
355                                 sortBtnType = CSortCtxPopup::TYPE_ARTIST;
356                         }
357                         else if (!strcmp(layout_id, MUSIC_CATEGORY_GENRE_LAYOUT)) {
358                                 sortBtnType = CSortCtxPopup::TYPE_GENRE;
359                         }
360                 }
361
362                 sortCtxPopup->Create(Base(), &cb, sortBtnType);
363                 m->sortCtxPopup = sortCtxPopup;
364         }
365         else {
366                 _ERR("MUST NOT BE HERE!!");
367                 ASSERT(0);
368                 return;
369         }
370 }
371
372
373 void CMusicBaseView::m_DestroyCtxPopup(void)
374 {
375         if (m->sortCtxPopup && m->sortCtxPopup->FlagCreate())
376                 m->sortCtxPopup->Destroy();
377
378         delete m->sortCtxPopup;
379         m->sortCtxPopup = NULL;
380
381         if (m->srcCtxPopup && m->srcCtxPopup->FlagCreate())
382                 m->srcCtxPopup->Destroy();
383
384         delete m->srcCtxPopup;
385         m->srcCtxPopup = NULL;
386 }
387
388
389 void CMusicBaseView::sm_CbCtxPopupBtnSelected(void* cookie, CContextPopup* instance, const char* text)
390 {
391         CMusicBaseView *root = (CMusicBaseView*)cookie;
392         if (root)
393                 root->m_CbCtxPopupBtnSelected(instance, text);
394 }
395
396
397 void CMusicBaseView::m_CbCtxPopupBtnSelected(CContextPopup* instance, const char* text)
398 {
399         if (m->btntype == BTN_SOURCE) {
400                 elm_object_text_set(m->srcbtn, _(text));
401                 if (m->c_grpbtn != m->group_btn[GROUP_BTN_PLAYLIST])
402                         m_ShowCurrentLayout();
403         }
404         else {
405                 elm_object_text_set(m->sortbtn, _(text));
406                 m_UpdateCurrentLayout(false);
407         }
408 }
409
410
411 Eina_Bool CMusicBaseView::sm_CbShowLayoutIdler(void *cookie)
412 {
413         CMusicBaseView *root = (CMusicBaseView*)cookie;
414         if (root)
415                 root->m_OnShowLayoutIdler();
416
417         return ECORE_CALLBACK_CANCEL;
418 }
419
420
421 void CMusicBaseView::m_OnShowLayoutIdler(void)
422 {
423         m->eiShowLayout = NULL;
424
425         if (elm_object_focus_get(m->c_grpbtn))
426                 m_ShowCurrentLayout();
427 }
428
429
430 Evas_Object *CMusicBaseView::m_CreateLoadingPopup(void)
431 {
432         Evas_Object *popup = NULL, *label = NULL, *icon = NULL, *box = NULL;
433         double scale;
434         char buf[MAX_LENGTH];
435
436         scale = elm_config_scale_get();
437
438         popup = elm_popup_add(Base());
439         if (!popup)
440                 return NULL;
441
442         elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP_RIGHT);
443         elm_popup_timeout_set(popup, MAX_SHOW_TIME);
444         evas_object_show(popup);
445
446         box = CCommonUI::AddBox(popup);
447         if (!box) {
448                 evas_object_del(popup);
449                 return NULL;
450         }
451
452         label = elm_label_add(popup);
453         if (!label) {
454                 evas_object_del(popup);
455                 return NULL;
456         }
457
458         elm_object_text_set(label, _(MUSIC_TEXT_LOADING));
459
460         icon = elm_icon_add(popup);
461         if (!icon) {
462                 evas_object_del(popup);
463                 return NULL;
464         }
465
466         snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, MUSIC_IMAGE_LOADING);
467         elm_image_file_set(icon, buf, NULL);
468         evas_object_size_hint_min_set(icon, 48 * scale, 48 * scale);
469
470         elm_box_horizontal_set(box, EINA_TRUE);
471         elm_box_padding_set(box,
472                 MUSIC_EDIT_BTNS_PADDING * elm_config_scale_get(), 0);
473
474         elm_box_pack_end(box, icon);
475         evas_object_show(icon);
476
477         elm_box_pack_end(box, label);
478         evas_object_show(label);
479
480         elm_object_content_set(popup, box);
481
482         m->transit = elm_transit_add();
483         if (!m->transit) {
484                 evas_object_del(popup);
485                 return NULL;
486         }
487
488         elm_transit_object_add(m->transit, icon);
489         elm_transit_effect_rotation_add(m->transit, 0, 360);
490         elm_transit_duration_set(m->transit, 1);
491         elm_transit_repeat_times_set(m->transit, MAX_SHOW_TIME);
492         elm_transit_objects_final_state_keep_set(m->transit, EINA_TRUE);
493         elm_transit_go(m->transit);
494
495         return popup;
496 }
497
498
499 void CMusicBaseView::m_DestroyPopup(void)
500 {
501         if (!m->popup)
502                 return;
503
504         if (m->transit) {
505                 elm_transit_del(m->transit);
506                 m->transit = NULL;
507         }
508         evas_object_del(m->popup);
509         m->popup = NULL;
510 }
511
512
513 void CMusicBaseView::m_UpdatePlaysongLabel(void)
514 {
515         CSongInfo *sinfo = NULL;
516         char buf[MAX_LENGTH];
517         int state;
518
519         state = m->pController->PlayState();
520
521         if (state != PLAY_STATUS_INITIAL && state != PLAY_STATUS_STOP) {
522
523                 if (!m->pController->GetCurrentSong(&sinfo)) {
524                         _ERR(" failed to find song info ");
525                         return;
526                 }
527
528                 snprintf(buf, sizeof(buf), "%s - %s", sinfo->Name(), sinfo->Artist());
529
530                 CCommonUI::SetObjectText(m->plsonglbl, buf, PLAYSONG_FONT_SIZE,
531                         FONT_STYLE_REGULAR);
532                 elm_label_slide_go(m->plsonglbl);
533         }
534         else {
535                 CCommonUI::SetObjectText(m->plsonglbl, (char *)MUSIC_STR_EMPTY,
536                         PLAYSONG_FONT_SIZE, (const char *)FONT_STYLE_REGULAR);
537         }
538 }
539
540
541 void CMusicBaseView::m_AddPlaysongLabel(void)
542 {
543         double scale = elm_config_scale_get();
544
545         m->plsonglbl = elm_label_add(Base());
546         if (!m->plsonglbl)
547                 return;
548
549         elm_object_style_set(m->plsonglbl, MUSIC_STYLE_PLAYSONG_LBL);
550         elm_label_wrap_width_set(m->plsonglbl, MUSIC_WRAP_WIDTH * scale);
551         elm_label_slide_duration_set(m->plsonglbl, MUSIC_SLIDE_DURATION);
552         elm_label_slide_mode_set(m->plsonglbl, ELM_LABEL_SLIDE_MODE_AUTO);
553         elm_label_slide_go(m->plsonglbl);
554         evas_object_size_hint_weight_set(m->plsonglbl, EVAS_HINT_EXPAND,
555                 EVAS_HINT_EXPAND);
556         elm_object_part_content_set(Base(), MUSIC_PART_PLAYSONG_LBL,
557                 m->plsonglbl);
558         evas_object_show(m->plsonglbl);
559 }
560
561
562 void CMusicBaseView::m_CreateTopSection(void)
563 {
564         int type;
565         int i;
566         Evas_Object *btn = NULL;
567         SBtnInfo btninfo[TOTAL_TOP_BTNS];
568
569         btninfo[BTN_PLAY].part = MUSIC_PART_PLAYBACK_BTN;
570         btninfo[BTN_PLAY].style = MUSIC_STYLE_PLAYBACK_BTN;
571         btninfo[BTN_PLAY].type = BASE_VIEW_PLAY_BUTTON;
572
573         btninfo[BTN_SOURCE].part = MUSIC_PART_SOURCE_HOVERSEL;
574         btninfo[BTN_SOURCE].style = MUSIC_STYLE_SOURCE_BTN;
575         btninfo[BTN_SOURCE].type = BASE_VIEW_SOURCE_BUTTON;
576
577         btninfo[BTN_SORT].part = MUSIC_PART_SORT_HOVERSEL;
578         btninfo[BTN_SORT].style = MUSIC_STYLE_SORT_BTN;
579         btninfo[BTN_SORT].type = BASE_VIEW_SORT_BUTTON;
580
581         elm_object_part_text_set(Base(), MUSIC_PART_TITLE,
582                 _(MUSIC_TEXT_TITLE));
583
584         m_AddPlaysongLabel();
585
586         for (i = 0; i < TOTAL_TOP_BTNS; i++) {
587                 btn = s_AddButton(Base());
588                 if (!btn) {
589                         _ERR(" Adding btn failed ");
590                         return;
591                 }
592
593                 elm_object_style_set(btn, btninfo[i].style);
594                 elm_object_part_content_set(Base(), btninfo[i].part, btn);
595
596                 Connect(btn, btninfo[i].type,
597                         TYPE_KEY_DOWN | TYPE_KEY_UP | TYPE_MOUSE_MOVE | TYPE_CLICKED);
598
599                 if (i == BTN_PLAY)
600                         m->plbackbtn = btn;
601                 else if (i == BTN_SOURCE)
602                         m->srcbtn = btn;
603                 else if (i == BTN_SORT)
604                         m->sortbtn = btn;
605         }
606
607         type = CInfo::SourceType();
608         elm_object_text_set(m->srcbtn, _(g_sourceText[type]));
609
610         type = CInfo::SortType();
611         elm_object_text_set(m->sortbtn, _(g_sortText[type]));
612 }
613
614
615 void CMusicBaseView::m_CreateLeftSection(void)
616 {
617         Evas_Object *box = NULL, *ic = NULL;
618         int i;
619         char buf[MAX_LENGTH];
620         static struct SBtnInfo btninfo[TOTAL_GROUP_BTNS];
621
622         btninfo[GROUP_BTN_SONG].txt = MUSIC_TEXT_SONG;
623         btninfo[GROUP_BTN_SONG].icon_path = MUSIC_IMAGE_GRPBTN_SONG;
624         btninfo[GROUP_BTN_SONG].type = BASE_VIEW_GROUP_SONG;
625
626         btninfo[GROUP_BTN_ALBUM].txt = MUSIC_TEXT_ALBUM;
627         btninfo[GROUP_BTN_ALBUM].icon_path = MUSIC_IMAGE_GRPBTN_ALBUM;
628         btninfo[GROUP_BTN_ALBUM].type = BASE_VIEW_GROUP_ALBUM;
629
630         btninfo[GROUP_BTN_ARTIST].txt = MUSIC_TEXT_ARTIST;
631         btninfo[GROUP_BTN_ARTIST].icon_path = MUSIC_IMAGE_GRPBTN_ARTIST;
632         btninfo[GROUP_BTN_ARTIST].type = BASE_VIEW_GROUP_ARTIST;
633
634         btninfo[GROUP_BTN_GENRE].txt = MUSIC_TEXT_GENRE;
635         btninfo[GROUP_BTN_GENRE].icon_path = MUSIC_IMAGE_GRPBTN_GENRE;
636         btninfo[GROUP_BTN_GENRE].type = BASE_VIEW_GROUP_GENRE;
637
638         btninfo[GROUP_BTN_FOLDER].txt = MUSIC_TEXT_FOLDER;
639         btninfo[GROUP_BTN_FOLDER].icon_path = MUSIC_IMAGE_GRPBTN_FOLDER;
640         btninfo[GROUP_BTN_FOLDER].type = BASE_VIEW_GROUP_FOLDER;
641
642         box = CCommonUI::AddBox(Base());
643         if (!box)
644                 return;
645
646         for (i = 0; i < TOTAL_GROUP_BTNS; i++) {
647                 m->group_btn[i] = s_AddButton(box);
648                 if (!m->group_btn[i]) {
649                         _ERR(" failed to add button to box ");
650                         continue;
651                 }
652
653                 elm_box_pack_end(box, m->group_btn[i]);
654                 elm_object_style_set(m->group_btn[i], MUSIC_STYLE_GROUPBTN);
655                 elm_object_text_set(m->group_btn[i], _(btninfo[i].txt));
656
657                 Connect(m->group_btn[i], btninfo[i].type,
658                         TYPE_KEY_DOWN | TYPE_MOUSE_MOVE | TYPE_CLICKED | TYPE_FOCUSED);
659
660                 ic = elm_image_add(m->group_btn[i]);
661                 if (ic) {
662                         snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
663                                 btninfo[i].icon_path);
664                         elm_image_file_set(ic, buf, NULL);
665                         elm_object_part_content_set(m->group_btn[i],
666                                 MUSIC_PART_ELM_SWALLOWICON, ic);
667                 }
668         }
669
670         elm_object_part_content_set(Base(), MUSIC_PART_GROUPBTN_BOX, box);
671 }
672
673
674 void CMusicBaseView::m_CreateFullView(void)
675 {
676         m_CreateTopSection();
677         m_CreateLeftSection();
678 }
679
680
681 void CMusicBaseView::m_SetSourceType(void)
682 {
683         if (!m->arglist || !m->arglist->source || !m->pController)
684                 return;
685
686         if (!strcmp(g_sourceArg[SOURCE_TYPE_USB], m->arglist->source))
687                 CInfo::SetSourceType(SOURCE_TYPE_USB);
688         else if (!strcmp(g_sourceArg[SOURCE_TYPE_TV], m->arglist->source))
689                 CInfo::SetSourceType(SOURCE_TYPE_TV);
690         else
691                 CInfo::SetSourceType(SOURCE_TYPE_ALL);
692 }
693
694
695 void CMusicBaseView::m_UpdateCurrentLayout(bool focusFlag)
696 {
697         ((CExtBaseLayout*)m->lmgr->Layout())->Update(focusFlag);
698 }
699
700
701 char *CMusicBaseView::m_Argument(void *data)
702 {
703         SArgList *arglist = (SArgList *)data;
704         char *arg = NULL;
705
706         if (arglist && arglist->uri)
707                 arg = arglist->uri;
708         else if (arglist && arglist->album_id)
709                 arg = arglist->album_id;
710
711         return arg;
712 }
713
714
715 bool CMusicBaseView::Create(void *data, Evas_Object *eoBase)
716 {
717         ASSERT(!m);
718
719         _CREATE_BEGIN{
720                 Evas_Object *eoBase;
721
722                 _CHECK(m = new SMusicBaseView)
723                 _CHECK(m->win = CViewMgr::GetInstance()->Window())
724                 _CHECK(m->pController = new CMusicController)
725                 _CHECK(m->pController->Create())
726                 _CHECK(eoBase = CCommonUI::AddBase(m->win, MUSIC_BASE_VIEW))
727                 _CHECK(CBaseView::Create(NULL, eoBase))
728                 _CHECK(m->lmgr = new CLayoutMgr)
729                 _CHECK(m->lmgr->Create(eoBase, NULL))
730                 _CHECK(m->layoutSong = new CSongLayout(MUSIC_SONG_LAYOUT))
731                 _CHECK(m->layoutSong->Create(m->lmgr, m_Argument(data)))
732                 _CHECK(m->lmgr->AddLayout(m->layoutSong))
733                 _CHECK(m->layoutAlbum = new CAlbumLayout(MUSIC_ALBUM_LAYOUT))
734                 _CHECK(m->layoutAlbum->Create(m->lmgr, m_Argument(data)))
735                 _CHECK(m->lmgr->AddLayout(m->layoutAlbum))
736                 _CHECK(m->layoutArtist = new CArtistLayout(MUSIC_CATEGORY_ARTIST_LAYOUT))
737                 _CHECK(m->layoutArtist->Create(m->lmgr))
738                 _CHECK(m->lmgr->AddLayout(m->layoutArtist))
739                 _CHECK(m->layoutGenre = new CGenreLayout(MUSIC_CATEGORY_GENRE_LAYOUT))
740                 _CHECK(m->layoutGenre->Create(m->lmgr))
741                 _CHECK(m->lmgr->AddLayout(m->layoutGenre))
742                 _CHECK(m->layoutPlaylists = new CPlaylistLayout(MUSIC_CATEGORY_PLAYLISTS_LAYOUT))
743                 _CHECK(m->layoutPlaylists->Create(m->lmgr))
744                 _CHECK(m->lmgr->AddLayout(m->layoutPlaylists))
745                 _CHECK(m->layoutFolder = new CFolderLayout(MUSIC_FOLDER_LAYOUT))
746                 _CHECK(m->layoutFolder->Create(m->lmgr))
747                 _CHECK(m->lmgr->AddLayout(m->layoutFolder))
748                 _CHECK(m->pHandleVolume = new CHandleVolume)
749                 _CHECK(m->pHandleVolume->Create(eoBase))
750                 _CHECK(m->pController->AddListener(this))
751
752                 _WHEN_SUCCESS{
753                         m->fresh_view = true;
754                         m->arglist = (SArgList *)data;
755
756                         m->layoutAlbum->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
757                         m->layoutArtist->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
758                         m->layoutGenre->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
759                         m->layoutPlaylists->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
760
761                         elm_object_part_content_unset(eoBase, MUSIC_PART_CONTENT);
762                         m_SetSourceType();
763                         evas_object_data_set(eoBase, BASE_VIEW_DATA, m);
764
765                         m_CreateFullView();
766                         m_UpdateFocusSequence();
767
768                         Connect(eoBase, BASE_VIEW, TYPE_KEY_DOWN | TYPE_KEY_UP);
769                 }
770
771                 _CHECK_FAIL{ m->pController->RemoveListener(this); }
772                 _CHECK_FAIL{ m->pHandleVolume->Destroy(); }
773                 _CHECK_FAIL{ delete m->pHandleVolume; }
774                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutFolder); }
775                 _CHECK_FAIL{ m->layoutFolder->Destroy(); }
776                 _CHECK_FAIL{ delete m->layoutFolder; }
777                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutPlaylists); }
778                 _CHECK_FAIL{ m->layoutPlaylists->Destroy(); }
779                 _CHECK_FAIL{ delete m->layoutPlaylists; }
780                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutGenre); }
781                 _CHECK_FAIL{ m->layoutGenre->Destroy(); }
782                 _CHECK_FAIL{ delete m->layoutGenre; }
783                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutArtist); }
784                 _CHECK_FAIL{ m->layoutArtist->Destroy(); }
785                 _CHECK_FAIL{ delete m->layoutArtist; }
786                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutAlbum); }
787                 _CHECK_FAIL{ m->layoutAlbum->Destroy(); }
788                 _CHECK_FAIL{ delete m->layoutAlbum; }
789                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutSong); }
790                 _CHECK_FAIL{ m->layoutSong->Destroy(); }
791                 _CHECK_FAIL{ delete m->layoutSong; }
792                 _CHECK_FAIL{ m->lmgr->Destroy(); }
793                 _CHECK_FAIL{ delete m->lmgr; }
794                 _CHECK_FAIL{ CBaseView::Destroy(); }
795                 _CHECK_FAIL{ evas_object_del(eoBase); }
796                 _CHECK_FAIL{ m->pController->Destroy(); }
797                 _CHECK_FAIL{ delete m->pController; }
798                 _CHECK_FAIL{ /* win */ }
799                 _CHECK_FAIL{ delete m; m = NULL; }
800         } _CREATE_END_AND_CATCH{ return false; }
801
802         return true;
803 }
804
805
806 void CMusicBaseView::Destroy(void)
807 {
808         ASSERT(m);
809
810         Evas_Object *eoBase = Base();
811
812         Disconnect(eoBase);
813
814         m->pController->RemoveListener(this);
815         m->pHandleVolume->Destroy();
816
817         m->lmgr->RemoveLayout(m->layoutFolder);
818         m->layoutFolder->Destroy();
819         delete m->layoutFolder;
820
821         m->lmgr->RemoveLayout(m->layoutArtist);
822         m->layoutArtist->Destroy();
823         delete m->layoutArtist;
824
825         m->lmgr->RemoveLayout(m->layoutGenre);
826         m->layoutGenre->Destroy();
827         delete m->layoutGenre;
828
829         m->lmgr->RemoveLayout(m->layoutPlaylists);
830         m->layoutPlaylists->Destroy();
831         delete m->layoutPlaylists;
832
833         m->lmgr->RemoveLayout(m->layoutAlbum);
834         m->layoutAlbum->Destroy();
835         delete m->layoutAlbum;
836
837         m->lmgr->RemoveLayout(m->layoutSong);
838         m->layoutSong->Destroy();
839         delete m->layoutSong;
840
841         m->lmgr->Destroy();
842         delete m->lmgr;
843
844         CBaseView::Destroy();
845         evas_object_del(eoBase);
846
847         m->pController->Destroy();
848         delete m->pController;
849         delete m;
850         m = NULL;
851 }
852
853
854 void CMusicBaseView::t_OnShow(void)
855 {
856         ASSERT(m);
857
858         evas_object_show(Base());
859
860         if (!m->fresh_view) {
861                 elm_object_focus_set(m->plbackbtn, EINA_TRUE);
862                 m_UpdatePlaysongLabel();
863                 return;
864         }
865
866         if (m->arglist && m->arglist->album_id)
867                 m->c_grpbtn = m->group_btn[GROUP_BTN_ALBUM];
868         else
869                 m->c_grpbtn = m->group_btn[GROUP_BTN_SONG];
870
871         elm_object_signal_emit(m->c_grpbtn,
872                 MUSIC_SIGNAL_GROUP_SELECTED, MUSIC_BASE_VIEW);
873         elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
874         m_UpdatePlaysongLabel();
875
876         m_ShowCurrentLayout();
877
878         m->arglist = NULL;
879         m->fresh_view = false;
880 }
881
882
883 void CMusicBaseView::t_OnUpdate(void *data)
884 {
885         ASSERT(m);
886
887         if (!data) {
888                 m_ShowCurrentLayout();
889                 return;
890         }
891
892         SParcel *parcel = (SParcel *)data;
893
894         if (parcel->updateType == E_FOCUS_UPDATE) {
895                 if (parcel->keyEvent == SKEY_UP) {
896                         Evas_Object *focus = NULL;
897
898                         if (!strcmp(parcel->focusedBtn, MUSIC_FIRST_BTN)) {
899                                 m->srcBtnFocusedBySecondBtn = false;
900                                 focus = m->plbackbtn;
901                         }
902                         else if (!strcmp(parcel->focusedBtn, MUSIC_SECOND_BTN)) {
903                                 if (elm_object_disabled_get(m->sortbtn)) {
904                                         m->srcBtnFocusedBySecondBtn = true;
905                                         focus = m->srcbtn;
906                                 }
907                                 else {
908                                         m->srcBtnFocusedBySecondBtn = false;
909                                         focus = m->sortbtn;
910                                 }
911                         }
912                         else if (!strcmp(parcel->focusedBtn, MUSIC_THIRD_BTN)) {
913                                 m->srcBtnFocusedBySecondBtn = false;
914                                 focus = m->srcbtn;
915                         }
916
917                         elm_object_focus_set(focus, EINA_TRUE);
918                 }
919                 else
920                         elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
921         }
922         else if (parcel->updateType == E_LAYOUT_UPDATE) {
923                 if (!parcel->layoutId)
924                         return;
925
926                 if (!strcmp(parcel->layoutId, MUSIC_ALBUM_SONGS_LAYOUT) ||
927                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_SONGS_LAYOUT) ||
928                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_ALBUM_LAYOUT) ||
929                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_SELECTLIST_LAYOUT)) {
930                         elm_object_disabled_set(m->sortbtn, EINA_TRUE);
931                         elm_object_focus_next_object_set(m->plbackbtn, m->srcbtn, ELM_FOCUS_RIGHT);
932                         elm_object_focus_next_object_set(m->srcbtn, m->plbackbtn, ELM_FOCUS_LEFT);
933                 }
934                 else {
935                         elm_object_disabled_set(m->sortbtn, EINA_FALSE);
936                         elm_object_focus_next_object_set(m->plbackbtn, m->sortbtn, ELM_FOCUS_RIGHT);
937                         elm_object_focus_next_object_set(m->sortbtn, m->srcbtn, ELM_FOCUS_RIGHT);
938                         elm_object_focus_next_object_set(m->srcbtn, m->sortbtn, ELM_FOCUS_LEFT);
939                         elm_object_focus_next_object_set(m->sortbtn, m->plbackbtn, ELM_FOCUS_LEFT);
940                 }
941         }
942         else if (parcel->updateType == E_DEPTH_UPDATE) {
943                 if (!parcel->layoutId)
944                         return;
945
946                 if (!strcmp(parcel->layoutId, MUSIC_ALBUM_SONGS_LAYOUT) ||
947                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_ARTIST_SONGS_LAYOUT) ||
948                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_GENRE_SONGS_LAYOUT) ||
949                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_PLAYLISTS_SONGS_LAYOUT)) {
950                         m_ShowCurrentLayout();
951                         m_UpdateCurrentLayout(true);
952                 }
953         }
954 }
955
956
957 void CMusicBaseView::t_OnHide(void)
958 {
959         ASSERT(m);
960
961         evas_object_hide(Base());
962 }
963
964
965 void CMusicBaseView::OnSKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_SKey_Down *ev)
966 {
967         switch (id) {
968         case BASE_VIEW:
969                 switch (ev->skey) {
970                 case SKEY_EXIT:
971                         m->pController->Stop();
972                         elm_exit();
973                         break;
974
975                 case SKEY_ENTER:
976                         if (elm_object_focus_get(m->c_grpbtn)) {
977                                 m_UpdateCurrentLayout(true);
978                         }
979                         break;
980
981                 case SKEY_VOLUME_UP:
982                         m->pHandleVolume->Up();
983                         break;
984
985                 case SKEY_VOLUME_DOWN:
986                         m->pHandleVolume->Down();
987                         break;
988
989                 case SKEY_MUTE:
990                         m->pHandleVolume->Mute();
991                         break;
992
993                 case SKEY_PLAY:
994                 case SKEY_PAUSE:
995                 case SKEY_PREVIOUS:
996                 case SKEY_NEXT:
997                         SParcel parcel;
998                         memset(&parcel, 0, sizeof(SParcel));
999                         parcel.updateType = E_KEY_PRESS;
1000                         parcel.keyEvent = ev->skey;
1001                         CViewMgr::GetInstance()->UpdateView((const char *)MUSIC_PLAYBACK_VIEW, &parcel);
1002                         break;
1003
1004                 case SKEY_LEFT:
1005                         m->eiShowLayout = ecore_idler_add(sm_CbShowLayoutIdler, this);
1006                         break;
1007
1008                 default:
1009                         break;
1010                 }
1011                 break;
1012
1013         case BASE_VIEW_PLAY_BUTTON:
1014         case BASE_VIEW_SORT_BUTTON:
1015         case BASE_VIEW_SOURCE_BUTTON:
1016                 switch (ev->skey) {
1017                 case SKEY_BACK:
1018                         elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
1019                         break;
1020
1021                 case SKEY_DOWN:
1022                         if (!((CExtBaseLayout *)m->lmgr->Layout())->EmptyStatus()) {
1023                                 const char *btnText = NULL;
1024
1025                                 if (id == BASE_VIEW_PLAY_BUTTON)
1026                                         btnText = MUSIC_FIRST_BTN;
1027                                 else if (id == BASE_VIEW_SORT_BUTTON)
1028                                         btnText = MUSIC_SECOND_BTN;
1029                                 else { //BASE_VIEW_SOURCE_BUTTON
1030                                         if (m->srcBtnFocusedBySecondBtn)
1031                                                 btnText = MUSIC_SECOND_BTN;
1032                                         else
1033                                                 btnText = MUSIC_THIRD_BTN;
1034                                 }
1035
1036                                 CExtBaseLayout *layout = (CExtBaseLayout *)m->lmgr->Layout();
1037                                 layout->SetFocus(btnText);
1038                         }
1039                         break;
1040
1041                 default:
1042                         break;
1043                 }
1044                 break;
1045
1046         case BASE_VIEW_GROUP_SONG:
1047         case BASE_VIEW_GROUP_ALBUM:
1048         case BASE_VIEW_GROUP_ARTIST:
1049         case BASE_VIEW_GROUP_GENRE:
1050         case BASE_VIEW_GROUP_FOLDER:
1051         case BASE_VIEW_GROUP_PLAYLIST:
1052                 switch (ev->skey) {
1053                 case SKEY_BACK:
1054                         m->pController->Stop();
1055                         elm_exit();
1056                         break;
1057
1058                 default:
1059                         break;
1060                 }
1061                 break;
1062
1063         default:
1064                 break;
1065         }
1066 }
1067
1068
1069 void CMusicBaseView::OnSKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_SKey_Up *ev)
1070 {
1071         switch (id) {
1072         case BASE_VIEW:
1073                 switch (ev->skey) {
1074                 case SKEY_NEXT:
1075                 case SKEY_PREVIOUS:
1076                         SParcel parcel;
1077                         memset(&parcel, 0, sizeof(SParcel));
1078                         parcel.updateType = E_KEY_RELEASE;
1079                         parcel.keyEvent = ev->skey;
1080                         CViewMgr::GetInstance()->UpdateView((const char *)MUSIC_PLAYBACK_VIEW, &parcel);
1081                         m_UpdatePlaysongLabel();
1082                         break;
1083
1084                 default:
1085                         break;
1086                 }
1087                 break;
1088
1089         default:
1090                 break;
1091         }
1092 }
1093
1094
1095 void CMusicBaseView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
1096 {
1097         switch (id) {
1098         case BASE_VIEW_PLAY_BUTTON:
1099         case BASE_VIEW_SORT_BUTTON:
1100         case BASE_VIEW_SOURCE_BUTTON:
1101         case BASE_VIEW_GROUP_SONG:
1102         case BASE_VIEW_GROUP_ALBUM:
1103         case BASE_VIEW_GROUP_ARTIST:
1104         case BASE_VIEW_GROUP_GENRE:
1105         case BASE_VIEW_GROUP_FOLDER:
1106         case BASE_VIEW_GROUP_PLAYLIST:
1107                 if (!elm_object_focus_get(obj))
1108                         elm_object_focus_set(obj, EINA_TRUE);
1109                 break;
1110
1111         default:
1112                 break;
1113         }
1114 }
1115
1116
1117 void CMusicBaseView::OnMouseClicked(int id, Evas_Object *obj)
1118 {
1119         switch (id) {
1120         case BASE_VIEW_PLAY_BUTTON:
1121                 {
1122                         Eina_List *list = NULL;
1123                         bool r;
1124                         int state;
1125
1126                         state = m->pController->PlayState();
1127
1128                         if (state != PLAY_STATUS_INITIAL) {
1129                                 t_OnHide();
1130
1131                                 if (!CViewMgr::GetInstance()->UpdateView(MUSIC_PLAYBACK_VIEW, NULL))
1132                                         _ERR("CViewMgr::UpdateView failed");
1133
1134                                 if (!CViewMgr::GetInstance()->ShowView(MUSIC_PLAYBACK_VIEW))
1135                                         _ERR("CViewMgr::ShowView failed");
1136
1137                                 return;
1138                         }
1139
1140                         r = m->pController->MediaGetList(LIST_TYPE_SONG, NULL, &list);
1141                         if (r == false || eina_list_count(list) == 0) {
1142                                 _ERR(" No songs ");
1143                                 return;
1144                         }
1145
1146                         m->pController->Stop();
1147                         m->pController->UpdatePlaylist(list, ADD_TYPE_FRESH);
1148                         eina_list_free(list);
1149
1150                         m_GotoPlayback();
1151                 }
1152                 break;
1153
1154         case BASE_VIEW_SOURCE_BUTTON:
1155                 m_CreateCtxPopup(BTN_SOURCE);
1156                 break;
1157
1158         case BASE_VIEW_SORT_BUTTON:
1159                 m_CreateCtxPopup(BTN_SORT);
1160                 break;
1161
1162         case BASE_VIEW_GROUP_SONG:
1163         case BASE_VIEW_GROUP_ALBUM:
1164         case BASE_VIEW_GROUP_ARTIST:
1165         case BASE_VIEW_GROUP_GENRE:
1166         case BASE_VIEW_GROUP_FOLDER:
1167         case BASE_VIEW_GROUP_PLAYLIST:
1168                 {
1169                         if (m->c_grpbtn == obj)
1170                                 return;
1171
1172                         elm_object_signal_emit(m->c_grpbtn,
1173                                 MUSIC_SIGNAL_GROUP_UNSELECTED, MUSIC_BASE_VIEW);
1174                         m->c_grpbtn = obj;
1175                         elm_object_signal_emit(m->c_grpbtn,
1176                                 MUSIC_SIGNAL_GROUP_SELECTED, MUSIC_BASE_VIEW);
1177
1178                         if (obj == m->group_btn[GROUP_BTN_FOLDER])
1179                                 elm_object_text_set(m->sortbtn, _(g_sortTextFolder[0]));
1180                         else if (obj == m->group_btn[GROUP_BTN_PLAYLIST])
1181                                 elm_object_text_set(m->sortbtn, _(g_sortTextPlaylists[0]));
1182                         else if (obj == m->group_btn[GROUP_BTN_ALBUM])
1183                                 elm_object_text_set(m->sortbtn, _(g_sortTextAlbum[0]));
1184                         else if (obj == m->group_btn[GROUP_BTN_ARTIST])
1185                                 elm_object_text_set(m->sortbtn, _(g_sortTextArtist[0]));
1186                         else if (obj == m->group_btn[GROUP_BTN_GENRE])
1187                                 elm_object_text_set(m->sortbtn, _(g_sortTextGenre[0]));
1188                         else
1189                                 elm_object_text_set(m->sortbtn, _(g_sortText[0]));
1190
1191                         CInfo::SetSortType(0);
1192
1193                         m_ShowCurrentLayout();
1194                 }
1195                 break;
1196
1197         default:
1198                 break;
1199         }
1200 }
1201
1202
1203 void CMusicBaseView::OnComplete(void)
1204 {
1205         m_UpdatePlaysongLabel();
1206 }
1207
1208
1209 void CMusicBaseView::OnError(void)
1210 {
1211 }
1212
1213
1214 void CMusicBaseView::OnUsbStatusChanged(SUsbStorageStatus status)
1215 {
1216         switch (status) {
1217                 case USB_STORAGE_CONNECTED:
1218                         m_DestroyPopup();
1219                         m->popup = m_CreateLoadingPopup();
1220                         break;
1221
1222                 case USB_STORAGE_DISCONNECTED:
1223                         m_DestroyPopup();
1224                         break;
1225
1226                 default:
1227                         ASSERT(!"Invalid Status");
1228                         break;
1229         }
1230 }
1231
1232
1233 void CMusicBaseView::OnUpdateContent(void)
1234 {
1235         int source;
1236
1237         m_DestroyPopup();
1238         m_DestroyCtxPopup();
1239         source = CInfo::SourceType();
1240         elm_object_text_set(m->srcbtn, _(g_sourceText[source]));
1241
1242         if (source != SOURCE_TYPE_TV)
1243                 m_ShowCurrentLayout();
1244 }