Modification due to the change of CBaseView
[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        6
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         btninfo[GROUP_BTN_PLAYLIST].txt = MUSIC_TEXT_PLAYLIST;
643         btninfo[GROUP_BTN_PLAYLIST].icon_path = MUSIC_IMAGE_GRPBTN_PLAYLISTS;
644         btninfo[GROUP_BTN_PLAYLIST].type = BASE_VIEW_GROUP_PLAYLIST;
645
646         box = CCommonUI::AddBox(Base());
647         if (!box)
648                 return;
649
650         for (i = 0; i < TOTAL_GROUP_BTNS; i++) {
651                 m->group_btn[i] = s_AddButton(box);
652                 if (!m->group_btn[i]) {
653                         _ERR(" failed to add button to box ");
654                         continue;
655                 }
656
657                 elm_box_pack_end(box, m->group_btn[i]);
658                 elm_object_style_set(m->group_btn[i], MUSIC_STYLE_GROUPBTN);
659                 elm_object_text_set(m->group_btn[i], _(btninfo[i].txt));
660
661                 Connect(m->group_btn[i], btninfo[i].type,
662                         TYPE_KEY_DOWN | TYPE_MOUSE_MOVE | TYPE_CLICKED | TYPE_FOCUSED);
663
664                 ic = elm_image_add(m->group_btn[i]);
665                 if (ic) {
666                         snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
667                                 btninfo[i].icon_path);
668                         elm_image_file_set(ic, buf, NULL);
669                         elm_object_part_content_set(m->group_btn[i],
670                                 MUSIC_PART_ELM_SWALLOWICON, ic);
671                 }
672         }
673
674         elm_object_part_content_set(Base(), MUSIC_PART_GROUPBTN_BOX, box);
675 }
676
677
678 void CMusicBaseView::m_CreateFullView(void)
679 {
680         m_CreateTopSection();
681         m_CreateLeftSection();
682 }
683
684
685 void CMusicBaseView::m_SetSourceType(void)
686 {
687         if (!m->arglist || !m->arglist->source || !m->pController)
688                 return;
689
690         if (!strcmp(g_sourceArg[SOURCE_TYPE_USB], m->arglist->source))
691                 CInfo::SetSourceType(SOURCE_TYPE_USB);
692         else if (!strcmp(g_sourceArg[SOURCE_TYPE_TV], m->arglist->source))
693                 CInfo::SetSourceType(SOURCE_TYPE_TV);
694         else
695                 CInfo::SetSourceType(SOURCE_TYPE_ALL);
696 }
697
698
699 void CMusicBaseView::m_UpdateCurrentLayout(bool focusFlag)
700 {
701         ((CExtBaseLayout*)m->lmgr->Layout())->Update(focusFlag);
702 }
703
704
705 char *CMusicBaseView::m_Argument(void *data)
706 {
707         SArgList *arglist = (SArgList *)data;
708         char *arg = NULL;
709
710         if (arglist && arglist->uri)
711                 arg = arglist->uri;
712         else if (arglist && arglist->album_id)
713                 arg = arglist->album_id;
714
715         return arg;
716 }
717
718
719 bool CMusicBaseView::Create(void *data, Evas_Object *eoBase)
720 {
721         ASSERT(!m);
722
723         _CREATE_BEGIN{
724                 Evas_Object *eoBase;
725
726                 _CHECK(m = new SMusicBaseView)
727                 _CHECK(m->win = CViewMgr::GetInstance()->Window())
728                 _CHECK(m->pController = new CMusicController)
729                 _CHECK(m->pController->Create())
730                 _CHECK(eoBase = CCommonUI::AddBase(m->win, MUSIC_BASE_VIEW))
731                 _CHECK(CBaseView::Create(NULL, eoBase))
732                 _CHECK(m->lmgr = new CLayoutMgr)
733                 _CHECK(m->lmgr->Create(eoBase, NULL))
734                 _CHECK(m->layoutSong = new CSongLayout(MUSIC_SONG_LAYOUT))
735                 _CHECK(m->layoutSong->Create(m->lmgr, m_Argument(data)))
736                 _CHECK(m->lmgr->AddLayout(m->layoutSong))
737                 _CHECK(m->layoutAlbum = new CAlbumLayout(MUSIC_ALBUM_LAYOUT))
738                 _CHECK(m->layoutAlbum->Create(m->lmgr, m_Argument(data)))
739                 _CHECK(m->lmgr->AddLayout(m->layoutAlbum))
740                 _CHECK(m->layoutArtist = new CArtistLayout(MUSIC_CATEGORY_ARTIST_LAYOUT))
741                 _CHECK(m->layoutArtist->Create(m->lmgr))
742                 _CHECK(m->lmgr->AddLayout(m->layoutArtist))
743                 _CHECK(m->layoutGenre = new CGenreLayout(MUSIC_CATEGORY_GENRE_LAYOUT))
744                 _CHECK(m->layoutGenre->Create(m->lmgr))
745                 _CHECK(m->lmgr->AddLayout(m->layoutGenre))
746                 _CHECK(m->layoutPlaylists = new CPlaylistLayout(MUSIC_CATEGORY_PLAYLISTS_LAYOUT))
747                 _CHECK(m->layoutPlaylists->Create(m->lmgr))
748                 _CHECK(m->lmgr->AddLayout(m->layoutPlaylists))
749                 _CHECK(m->layoutFolder = new CFolderLayout(MUSIC_FOLDER_LAYOUT))
750                 _CHECK(m->layoutFolder->Create(m->lmgr))
751                 _CHECK(m->lmgr->AddLayout(m->layoutFolder))
752                 _CHECK(m->pHandleVolume = new CHandleVolume)
753                 _CHECK(m->pHandleVolume->Create(eoBase))
754                 _CHECK(m->pController->AddListener(this))
755
756                 _WHEN_SUCCESS{
757                         m->fresh_view = true;
758                         m->arglist = (SArgList *)data;
759
760                         m->layoutAlbum->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
761                         m->layoutArtist->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
762                         m->layoutGenre->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
763                         m->layoutPlaylists->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
764
765                         elm_object_part_content_unset(eoBase, MUSIC_PART_CONTENT);
766                         m_SetSourceType();
767                         evas_object_data_set(eoBase, BASE_VIEW_DATA, m);
768
769                         m_CreateFullView();
770                         m_UpdateFocusSequence();
771
772                         Connect(eoBase, BASE_VIEW, TYPE_KEY_DOWN | TYPE_KEY_UP);
773                 }
774
775                 _CHECK_FAIL{ m->pController->RemoveListener(this); }
776                 _CHECK_FAIL{ m->pHandleVolume->Destroy(); }
777                 _CHECK_FAIL{ delete m->pHandleVolume; }
778                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutFolder); }
779                 _CHECK_FAIL{ m->layoutFolder->Destroy(); }
780                 _CHECK_FAIL{ delete m->layoutFolder; }
781                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutPlaylists); }
782                 _CHECK_FAIL{ m->layoutPlaylists->Destroy(); }
783                 _CHECK_FAIL{ delete m->layoutPlaylists; }
784                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutGenre); }
785                 _CHECK_FAIL{ m->layoutGenre->Destroy(); }
786                 _CHECK_FAIL{ delete m->layoutGenre; }
787                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutArtist); }
788                 _CHECK_FAIL{ m->layoutArtist->Destroy(); }
789                 _CHECK_FAIL{ delete m->layoutArtist; }
790                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutAlbum); }
791                 _CHECK_FAIL{ m->layoutAlbum->Destroy(); }
792                 _CHECK_FAIL{ delete m->layoutAlbum; }
793                 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutSong); }
794                 _CHECK_FAIL{ m->layoutSong->Destroy(); }
795                 _CHECK_FAIL{ delete m->layoutSong; }
796                 _CHECK_FAIL{ m->lmgr->Destroy(); }
797                 _CHECK_FAIL{ delete m->lmgr; }
798                 _CHECK_FAIL{ CBaseView::Destroy(); }
799                 _CHECK_FAIL{ evas_object_del(eoBase); }
800                 _CHECK_FAIL{ m->pController->Destroy(); }
801                 _CHECK_FAIL{ delete m->pController; }
802                 _CHECK_FAIL{ /* win */ }
803                 _CHECK_FAIL{ delete m; m = NULL; }
804         } _CREATE_END_AND_CATCH{ return false; }
805
806         return true;
807 }
808
809
810 void CMusicBaseView::Destroy(void)
811 {
812         ASSERT(m);
813
814         Evas_Object *eoBase = Base();
815
816         Disconnect(eoBase);
817
818         m->pController->RemoveListener(this);
819         m->pHandleVolume->Destroy();
820
821         m->lmgr->RemoveLayout(m->layoutFolder);
822         m->layoutFolder->Destroy();
823         delete m->layoutFolder;
824
825         m->lmgr->RemoveLayout(m->layoutArtist);
826         m->layoutArtist->Destroy();
827         delete m->layoutArtist;
828
829         m->lmgr->RemoveLayout(m->layoutGenre);
830         m->layoutGenre->Destroy();
831         delete m->layoutGenre;
832
833         m->lmgr->RemoveLayout(m->layoutPlaylists);
834         m->layoutPlaylists->Destroy();
835         delete m->layoutPlaylists;
836
837         m->lmgr->RemoveLayout(m->layoutAlbum);
838         m->layoutAlbum->Destroy();
839         delete m->layoutAlbum;
840
841         m->lmgr->RemoveLayout(m->layoutSong);
842         m->layoutSong->Destroy();
843         delete m->layoutSong;
844
845         m->lmgr->Destroy();
846         delete m->lmgr;
847
848         CBaseView::Destroy();
849         evas_object_del(eoBase);
850
851         m->pController->Destroy();
852         delete m->pController;
853         delete m;
854         m = NULL;
855 }
856
857
858 void CMusicBaseView::t_OnShow(void)
859 {
860         ASSERT(m);
861
862         evas_object_show(Base());
863
864         if (!m->fresh_view) {
865                 elm_object_focus_set(m->plbackbtn, EINA_TRUE);
866                 m_UpdatePlaysongLabel();
867                 return;
868         }
869
870         if (m->arglist && m->arglist->album_id)
871                 m->c_grpbtn = m->group_btn[GROUP_BTN_ALBUM];
872         else
873                 m->c_grpbtn = m->group_btn[GROUP_BTN_SONG];
874
875         elm_object_signal_emit(m->c_grpbtn,
876                 MUSIC_SIGNAL_GROUP_SELECTED, MUSIC_BASE_VIEW);
877         elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
878         m_UpdatePlaysongLabel();
879
880         m_ShowCurrentLayout();
881
882         m->arglist = NULL;
883         m->fresh_view = false;
884 }
885
886
887 void CMusicBaseView::t_OnUpdate(void *data)
888 {
889         ASSERT(m);
890
891         if (!data) {
892                 m_ShowCurrentLayout();
893                 return;
894         }
895
896         SParcel *parcel = (SParcel *)data;
897
898         if (parcel->updateType == E_FOCUS_UPDATE) {
899                 if (parcel->keyEvent == SKEY_UP) {
900                         Evas_Object *focus = NULL;
901
902                         if (!strcmp(parcel->focusedBtn, MUSIC_FIRST_BTN)) {
903                                 m->srcBtnFocusedBySecondBtn = false;
904                                 focus = m->plbackbtn;
905                         }
906                         else if (!strcmp(parcel->focusedBtn, MUSIC_SECOND_BTN)) {
907                                 if (elm_object_disabled_get(m->sortbtn)) {
908                                         m->srcBtnFocusedBySecondBtn = true;
909                                         focus = m->srcbtn;
910                                 }
911                                 else {
912                                         m->srcBtnFocusedBySecondBtn = false;
913                                         focus = m->sortbtn;
914                                 }
915                         }
916                         else if (!strcmp(parcel->focusedBtn, MUSIC_THIRD_BTN)) {
917                                 m->srcBtnFocusedBySecondBtn = false;
918                                 focus = m->srcbtn;
919                         }
920
921                         elm_object_focus_set(focus, EINA_TRUE);
922                 }
923                 else
924                         elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
925         }
926         else if (parcel->updateType == E_LAYOUT_UPDATE) {
927                 if (!parcel->layoutId)
928                         return;
929
930                 if (!strcmp(parcel->layoutId, MUSIC_ALBUM_SONGS_LAYOUT) ||
931                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_SONGS_LAYOUT) ||
932                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_ALBUM_LAYOUT) ||
933                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_SELECTLIST_LAYOUT)) {
934                         elm_object_disabled_set(m->sortbtn, EINA_TRUE);
935                         elm_object_focus_next_object_set(m->plbackbtn, m->srcbtn, ELM_FOCUS_RIGHT);
936                         elm_object_focus_next_object_set(m->srcbtn, m->plbackbtn, ELM_FOCUS_LEFT);
937                 }
938                 else {
939                         elm_object_disabled_set(m->sortbtn, EINA_FALSE);
940                         elm_object_focus_next_object_set(m->plbackbtn, m->sortbtn, ELM_FOCUS_RIGHT);
941                         elm_object_focus_next_object_set(m->sortbtn, m->srcbtn, ELM_FOCUS_RIGHT);
942                         elm_object_focus_next_object_set(m->srcbtn, m->sortbtn, ELM_FOCUS_LEFT);
943                         elm_object_focus_next_object_set(m->sortbtn, m->plbackbtn, ELM_FOCUS_LEFT);
944                 }
945         }
946         else if (parcel->updateType == E_DEPTH_UPDATE) {
947                 if (!parcel->layoutId)
948                         return;
949
950                 if (!strcmp(parcel->layoutId, MUSIC_ALBUM_SONGS_LAYOUT) ||
951                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_ARTIST_SONGS_LAYOUT) ||
952                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_GENRE_SONGS_LAYOUT) ||
953                         !strcmp(parcel->layoutId, MUSIC_CATEGORY_PLAYLISTS_SONGS_LAYOUT)) {
954                         m_ShowCurrentLayout();
955                         m_UpdateCurrentLayout(true);
956                 }
957         }
958 }
959
960
961 void CMusicBaseView::t_OnHide(void)
962 {
963         ASSERT(m);
964
965         evas_object_hide(Base());
966 }
967
968
969 void CMusicBaseView::OnSKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_SKey_Down *ev)
970 {
971         switch (id) {
972         case BASE_VIEW:
973                 switch (ev->skey) {
974                 case SKEY_EXIT:
975                         m->pController->Stop();
976                         elm_exit();
977                         break;
978
979                 case SKEY_ENTER:
980                         if (elm_object_focus_get(m->c_grpbtn)) {
981                                 m_UpdateCurrentLayout(true);
982                         }
983                         break;
984
985                 case SKEY_VOLUME_UP:
986                         m->pHandleVolume->Up();
987                         break;
988
989                 case SKEY_VOLUME_DOWN:
990                         m->pHandleVolume->Down();
991                         break;
992
993                 case SKEY_MUTE:
994                         m->pHandleVolume->Mute();
995                         break;
996
997                 case SKEY_PLAY:
998                 case SKEY_PAUSE:
999                 case SKEY_PREVIOUS:
1000                 case SKEY_NEXT:
1001                         SParcel parcel;
1002                         memset(&parcel, 0, sizeof(SParcel));
1003                         parcel.updateType = E_KEY_PRESS;
1004                         parcel.keyEvent = ev->skey;
1005                         CViewMgr::GetInstance()->UpdateView((const char *)MUSIC_PLAYBACK_VIEW, &parcel);
1006                         break;
1007
1008                 case SKEY_LEFT:
1009                         m->eiShowLayout = ecore_idler_add(sm_CbShowLayoutIdler, this);
1010                         break;
1011
1012                 default:
1013                         break;
1014                 }
1015                 break;
1016
1017         case BASE_VIEW_PLAY_BUTTON:
1018         case BASE_VIEW_SORT_BUTTON:
1019         case BASE_VIEW_SOURCE_BUTTON:
1020                 switch (ev->skey) {
1021                 case SKEY_BACK:
1022                         elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
1023                         break;
1024
1025                 case SKEY_DOWN:
1026                         if (!((CExtBaseLayout *)m->lmgr->Layout())->EmptyStatus()) {
1027                                 const char *btnText = NULL;
1028
1029                                 if (id == BASE_VIEW_PLAY_BUTTON)
1030                                         btnText = MUSIC_FIRST_BTN;
1031                                 else if (id == BASE_VIEW_SORT_BUTTON)
1032                                         btnText = MUSIC_SECOND_BTN;
1033                                 else { //BASE_VIEW_SOURCE_BUTTON
1034                                         if (m->srcBtnFocusedBySecondBtn)
1035                                                 btnText = MUSIC_SECOND_BTN;
1036                                         else
1037                                                 btnText = MUSIC_THIRD_BTN;
1038                                 }
1039
1040                                 CExtBaseLayout *layout = (CExtBaseLayout *)m->lmgr->Layout();
1041                                 layout->SetFocus(btnText);
1042                         }
1043                         break;
1044
1045                 default:
1046                         break;
1047                 }
1048                 break;
1049
1050         case BASE_VIEW_GROUP_SONG:
1051         case BASE_VIEW_GROUP_ALBUM:
1052         case BASE_VIEW_GROUP_ARTIST:
1053         case BASE_VIEW_GROUP_GENRE:
1054         case BASE_VIEW_GROUP_FOLDER:
1055         case BASE_VIEW_GROUP_PLAYLIST:
1056                 switch (ev->skey) {
1057                 case SKEY_BACK:
1058                         m->pController->Stop();
1059                         elm_exit();
1060                         break;
1061
1062                 default:
1063                         break;
1064                 }
1065                 break;
1066
1067         default:
1068                 break;
1069         }
1070 }
1071
1072
1073 void CMusicBaseView::OnSKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_SKey_Up *ev)
1074 {
1075         switch (id) {
1076         case BASE_VIEW:
1077                 switch (ev->skey) {
1078                 case SKEY_NEXT:
1079                 case SKEY_PREVIOUS:
1080                         SParcel parcel;
1081                         memset(&parcel, 0, sizeof(SParcel));
1082                         parcel.updateType = E_KEY_RELEASE;
1083                         parcel.keyEvent = ev->skey;
1084                         CViewMgr::GetInstance()->UpdateView((const char *)MUSIC_PLAYBACK_VIEW, &parcel);
1085                         m_UpdatePlaysongLabel();
1086                         break;
1087
1088                 default:
1089                         break;
1090                 }
1091                 break;
1092
1093         default:
1094                 break;
1095         }
1096 }
1097
1098
1099 void CMusicBaseView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
1100 {
1101         switch (id) {
1102         case BASE_VIEW_PLAY_BUTTON:
1103         case BASE_VIEW_SORT_BUTTON:
1104         case BASE_VIEW_SOURCE_BUTTON:
1105         case BASE_VIEW_GROUP_SONG:
1106         case BASE_VIEW_GROUP_ALBUM:
1107         case BASE_VIEW_GROUP_ARTIST:
1108         case BASE_VIEW_GROUP_GENRE:
1109         case BASE_VIEW_GROUP_FOLDER:
1110         case BASE_VIEW_GROUP_PLAYLIST:
1111                 if (!elm_object_focus_get(obj))
1112                         elm_object_focus_set(obj, EINA_TRUE);
1113                 break;
1114
1115         default:
1116                 break;
1117         }
1118 }
1119
1120
1121 void CMusicBaseView::OnMouseClicked(int id, Evas_Object *obj)
1122 {
1123         switch (id) {
1124         case BASE_VIEW_PLAY_BUTTON:
1125                 {
1126                         Eina_List *list = NULL;
1127                         bool r;
1128                         int state;
1129
1130                         state = m->pController->PlayState();
1131
1132                         if (state != PLAY_STATUS_INITIAL) {
1133                                 t_OnHide();
1134
1135                                 if (!CViewMgr::GetInstance()->UpdateView(MUSIC_PLAYBACK_VIEW, NULL))
1136                                         _ERR("CViewMgr::UpdateView failed");
1137
1138                                 if (!CViewMgr::GetInstance()->ShowView(MUSIC_PLAYBACK_VIEW))
1139                                         _ERR("CViewMgr::ShowView failed");
1140
1141                                 return;
1142                         }
1143
1144                         r = m->pController->MediaGetList(LIST_TYPE_SONG, NULL, &list);
1145                         if (r == false || eina_list_count(list) == 0) {
1146                                 _ERR(" No songs ");
1147                                 return;
1148                         }
1149
1150                         m->pController->Stop();
1151                         m->pController->UpdatePlaylist(list, ADD_TYPE_FRESH);
1152                         eina_list_free(list);
1153
1154                         m_GotoPlayback();
1155                 }
1156                 break;
1157
1158         case BASE_VIEW_SOURCE_BUTTON:
1159                 m_CreateCtxPopup(BTN_SOURCE);
1160                 break;
1161
1162         case BASE_VIEW_SORT_BUTTON:
1163                 m_CreateCtxPopup(BTN_SORT);
1164                 break;
1165
1166         case BASE_VIEW_GROUP_SONG:
1167         case BASE_VIEW_GROUP_ALBUM:
1168         case BASE_VIEW_GROUP_ARTIST:
1169         case BASE_VIEW_GROUP_GENRE:
1170         case BASE_VIEW_GROUP_FOLDER:
1171         case BASE_VIEW_GROUP_PLAYLIST:
1172                 {
1173                         if (m->c_grpbtn == obj)
1174                                 return;
1175
1176                         elm_object_signal_emit(m->c_grpbtn,
1177                                 MUSIC_SIGNAL_GROUP_UNSELECTED, MUSIC_BASE_VIEW);
1178                         m->c_grpbtn = obj;
1179                         elm_object_signal_emit(m->c_grpbtn,
1180                                 MUSIC_SIGNAL_GROUP_SELECTED, MUSIC_BASE_VIEW);
1181
1182                         if (obj == m->group_btn[GROUP_BTN_FOLDER])
1183                                 elm_object_text_set(m->sortbtn, _(g_sortTextFolder[0]));
1184                         else if (obj == m->group_btn[GROUP_BTN_PLAYLIST])
1185                                 elm_object_text_set(m->sortbtn, _(g_sortTextPlaylists[0]));
1186                         else if (obj == m->group_btn[GROUP_BTN_ALBUM])
1187                                 elm_object_text_set(m->sortbtn, _(g_sortTextAlbum[0]));
1188                         else if (obj == m->group_btn[GROUP_BTN_ARTIST])
1189                                 elm_object_text_set(m->sortbtn, _(g_sortTextArtist[0]));
1190                         else if (obj == m->group_btn[GROUP_BTN_GENRE])
1191                                 elm_object_text_set(m->sortbtn, _(g_sortTextGenre[0]));
1192                         else
1193                                 elm_object_text_set(m->sortbtn, _(g_sortText[0]));
1194
1195                         CInfo::SetSortType(0);
1196
1197                         m_ShowCurrentLayout();
1198                 }
1199                 break;
1200
1201         default:
1202                 break;
1203         }
1204 }
1205
1206
1207 void CMusicBaseView::OnComplete(void)
1208 {
1209         m_UpdatePlaysongLabel();
1210 }
1211
1212
1213 void CMusicBaseView::OnError(void)
1214 {
1215 }
1216
1217
1218 void CMusicBaseView::OnUsbStatusChanged(SUsbStorageStatus status)
1219 {
1220         switch (status) {
1221                 case USB_STORAGE_CONNECTED:
1222                         m_DestroyPopup();
1223                         m->popup = m_CreateLoadingPopup();
1224                         break;
1225
1226                 case USB_STORAGE_DISCONNECTED:
1227                         m_DestroyPopup();
1228                         break;
1229
1230                 default:
1231                         ASSERT(!"Invalid Status");
1232                         break;
1233         }
1234 }
1235
1236
1237 void CMusicBaseView::OnUpdateContent(void)
1238 {
1239         int source;
1240
1241         m_DestroyPopup();
1242         m_DestroyCtxPopup();
1243         source = CInfo::SourceType();
1244         elm_object_text_set(m->srcbtn, _(g_sourceText[source]));
1245
1246         if (source != SOURCE_TYPE_TV)
1247                 m_ShowCurrentLayout();
1248 }