Modification due to the EFL update
[profile/tv/apps/native/musicplayer.git] / src / views / playback-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 <Elementary.h>
18 #include <Eina.h>
19
20 #include "AppCommon.h"
21 #include <InputHandler.h>
22
23 #include "define.h"
24 #include "common.h"
25 #include "dbg.h"
26 #include "song_info.h"
27 #include "album_info.h"
28 #include "music-controller.h"
29 #include "volume-control.h"
30 #include "i18n.h"
31 #include "common-ui.h"
32 #include "BaseView.h"
33 #include "ViewMgr.h"
34 #include "playback-view.h"
35 #include "context-view.h"
36 #include "HandleVolume.h"
37 #include <app-res-defines.h>
38 #include "PlaySettingCtxPopup.h"
39 #include "Info.h"
40
41
42 #define ARRAY_SIZE(array)       (sizeof(array) / sizeof(array[0]))
43 #define TITLE_FONT_SIZE         50
44 #define ARTIST_FONT_SIZE        30
45 #define TOTAL_CONTROL_BTNS      6
46 #define TOTAL_EDIT_BTNS         3
47 #define S_INTERVAL              1       /* seconds */
48 #define LP_INTERVAL             0.5     /* seconds */
49 #define WAIT_INTERVAL           0.5     /* seconds */
50 #define SLIDER_STEP             5000    /* milli seconds */
51 #define LP_CHANGE               10000   /* milli seconds */
52 #define S_INCREMENT             1000    /* milli seconds */
53
54
55 enum EEvasObject {
56         EO_BASE,
57
58         EO_ERROR_POPUP_BUTTON,
59
60         EO_CANCEL,
61         EO_DESELECT,
62         EO_DELETE,           // TOTAL_EDIT_BTNS
63
64         EO_BTN_SETTINGS,
65         EO_BTN_SHUFFLE,
66         EO_BTN_REPEAT,
67         EO_BTN_REWIND,
68         EO_BTN_PLAY,
69         EO_BTN_FORWARD,   // TOTAL_CONTROL_BTNS
70
71         EO_SLIDER,
72
73         EO_PLAYLIST,
74
75         EO_BOX,
76 };
77
78
79 struct SItemInfo {
80         Elm_Object_Item *item;
81         CSongInfo *sinfo;
82         bool edit_mode;
83         bool check_status;
84         bool select_status;
85 };
86
87 struct SPlaybackView {
88         Evas_Object *eoWin;
89
90         Evas_Object *eoBase;
91         CPlaySettingCtxPopup *eoCtxPopup;
92         Evas_Object *eoErrPopup;
93         Evas_Object *eoPlaylist;
94
95         Elm_Object_Item *focused_item;
96
97         Evas_Object *eoBtnControl[TOTAL_CONTROL_BTNS];
98         Evas_Object *eoBtnEdit[TOTAL_EDIT_BTNS];
99
100         Evas_Object *eoAlbumCover;
101         Evas_Object *eoSlider;
102         Evas_Object *eoPressedObj;
103
104         Eina_List   *elInfo;
105         Ecore_Timer *etSlider;
106         Ecore_Timer *etLongPress;
107         Ecore_Timer *etWait;
108         CMusicController *hMusicController; //! NOT NULL
109         CSongInfo *csinfo;
110         CViewMgr *mgr;
111         SItemInfo *cs_itinfo;
112         SContentInfo *ctxtinfo;
113         int press_status;
114
115         CHandleVolume *pHandleVolume;
116
117         SPlaybackView() {
118                 memset(this, 0, sizeof(SPlaybackView));
119                 pHandleVolume = new CHandleVolume;
120         }
121         ~SPlaybackView() {
122                 delete pHandleVolume;
123         }
124 };
125
126 struct SBtnInfo {
127         const char *txt;
128         const char *part;
129         EEvasObject type;
130 };
131
132 enum EPressTypes {
133         PRESS_SHORT,
134         PRESS_SHORT_PAUSE,
135         PRESS_LONG,
136         PRESS_LONG_PAUSE,
137 };
138
139 enum EControlBtns {
140         BTN_SETTINGS,
141         BTN_SHUFFLE,
142         BTN_REPEAT,
143         BTN_REWIND,
144         BTN_PLAY,
145         BTN_FORWARD
146 };
147
148 enum ESettingBtns {
149         BTN_EDIT,
150         BTN_CLEAR
151 };
152
153 enum EEditBtns {
154         BTN_CANCEL,
155         BTN_DESELECT,
156         BTN_DELETE
157 };
158
159 enum ETimers {
160         TIMER_SLIDER,
161         TIMER_WAIT,
162         TIMER_LONGPRESS,
163         TIMER_VOLUME
164 };
165
166
167 Eina_Bool CPlaybackView::sm_CbUpdateSlider(void *dt)
168 {
169         SPlaybackView *m = (SPlaybackView *)dt;
170         char *timestr = NULL;
171         int value;
172         int duration;
173
174         if (!m)
175                 return ECORE_CALLBACK_CANCEL;
176
177         if (!m->hMusicController->GetPosition(&value)) {
178                 m->etSlider = NULL;
179                 return ECORE_CALLBACK_CANCEL;
180         }
181
182         duration = m->csinfo->Duration();
183
184         value = value + S_INCREMENT;
185         if (value > duration) {
186                 m->etSlider = NULL;
187                 return ECORE_CALLBACK_CANCEL;
188         }
189
190         elm_slider_value_set(m->eoSlider, value);
191         timestr = CCommonUI::TimeStrFromMilSeconds(value);
192         if (timestr) {
193                 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
194                         timestr);
195                 free(timestr);
196         }
197
198         return ECORE_CALLBACK_RENEW;
199 }
200
201
202 Eina_Bool CPlaybackView::sm_CbLongpressTimer(void *dt)
203 {
204         CPlaybackView *root = (CPlaybackView *)dt;
205         if (root)
206                 root->m_OnLongpressTimer();
207
208         return ECORE_CALLBACK_RENEW;
209 }
210
211
212 void CPlaybackView::m_OnLongpressTimer(void)
213 {
214         m_HandleOnRepeated();
215 }
216
217
218 Eina_Bool CPlaybackView::sm_CbWaitTimer(void *dt)
219 {
220         CPlaybackView *root = (CPlaybackView *)dt;
221         if (root)
222                 root->m_OnWaitTimer();
223
224         return ECORE_CALLBACK_CANCEL;
225 }
226
227
228 void CPlaybackView::m_OnWaitTimer(void)
229 {
230         m->press_status = PRESS_LONG;
231         if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
232                 /* Handle long press */
233                 m_PlaybackPause();
234                 m->etLongPress = ecore_timer_add(LP_INTERVAL, sm_CbLongpressTimer, this);
235         }
236         else {
237                 m->press_status = PRESS_LONG_PAUSE;
238         }
239
240         m->etWait = NULL;
241 }
242
243
244 void CPlaybackView::sm_CbItemSelect(void *data, Evas_Object *obj, void *event_info)
245 {
246 }
247
248
249 void CPlaybackView::sm_CbGenlistItemCheckClicked(void *data, Elm_Object_Item *it, const char *emission, const char *source)
250 {
251         CPlaybackView *root = (CPlaybackView*)data;
252         if (root)
253                 root->m_OnGenlistItemCheckClicked(it, emission, source);
254 }
255
256
257 void CPlaybackView::m_OnGenlistItemCheckClicked(Elm_Object_Item *it, const char *emission, const char *source)
258 {
259         SItemInfo *itinfo = NULL;
260
261         if (!it || !emission)
262                 return;
263
264         itinfo = m_FindItemInfoFromItem(m->elInfo, it);
265         if (!itinfo) {
266                 _ERR(" no item info found ");
267                 return;
268         }
269
270         if (itinfo->edit_mode) {
271                 m_UpdateItemCheck(itinfo);
272                 m_DisableEditButtons(false);
273         }
274 }
275
276
277 void CPlaybackView::sm_CbCtxtUpdate(void *dt, enum EActionType type, int lid)
278 {
279         CPlaybackView *root = (CPlaybackView *)dt;
280         if (root)
281                 root->m_OnCtxtUpdate(type, lid);
282 }
283
284
285 void CPlaybackView::m_OnCtxtUpdate(EActionType type, int lid)
286 {
287         SItemInfo *itinfo = NULL;
288         Elm_Object_Item *focusedItem = NULL;
289
290         if (!m->ctxtinfo || !m->ctxtinfo->context)
291                 return;
292
293         itinfo = m_FindItemInfoFromSong(m->elInfo,
294                 (CSongInfo *)m->ctxtinfo->context);
295         if (!itinfo) {
296                 _ERR(" Unable to find song in the list ");
297                 return;
298         }
299
300         if (type == ACTION_TYPE_DELETE) {
301                 itinfo->check_status = true;
302                 m_DeleteSelectedItems();
303
304                 if (!m->mgr->PopView()) {
305                         _ERR("CViewMgr::PopView failed");
306                         return;
307                 }
308
309                 SParcel parcel;
310                 memset(&parcel, 0, sizeof(SParcel));
311                 parcel.updateType = E_PLAYLIST_UPDATE;
312                 t_OnUpdate(&parcel);
313
314                 focusedItem = m->cs_itinfo->item;
315         }
316         else { // ACTION_TYPE_PLAY
317                 if (m->ctxtinfo->status == PLAY_STATUS_PLAY)
318                         m_KeyPausePress();
319                 else {
320                         if (itinfo == m->cs_itinfo)
321                                 m_KeyPlayPress();
322                         else
323                                 m_HandleGenlistItemActivated(m->eoPlaylist, itinfo->item);
324                 }
325
326                 if (!m->mgr->PopView()) {
327                         _ERR("CViewMgr::PopView failed");
328                         return;
329                 }
330
331                 focusedItem = m->focused_item;
332         }
333
334         if (focusedItem) {
335                 elm_genlist_item_show(focusedItem, ELM_GENLIST_ITEM_SCROLLTO_IN);
336                 elm_object_item_focus_set(focusedItem, EINA_TRUE);
337         }
338 }
339
340
341 void CPlaybackView::sm_CbCtxtClose(void *dt)
342 {
343         CPlaybackView *root = (CPlaybackView *)dt;
344         if (root)
345                 root->m_OnCtxtClose();
346 }
347
348
349 void CPlaybackView::m_OnCtxtClose(void)
350 {
351         if (!m->mgr->PopView()) {
352                 _ERR("CViewMgr::PopView failed");
353                 return;
354         }
355
356         elm_object_item_focus_set(m->focused_item, EINA_TRUE);
357 }
358
359
360 void CPlaybackView::sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text)
361 {
362         CPlaybackView *root = (CPlaybackView *)cookie;
363         if (root)
364                 root->m_CbCtxPopupBtnSelected(instance, text);
365 }
366
367
368 void CPlaybackView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text)
369 {
370         int type = CInfo::PlaybackSettingType();
371
372         switch (type) {
373         case BTN_EDIT:
374                 m_FromPlaybackToEditMode();
375                 break;
376
377         case BTN_CLEAR:
378                 m->hMusicController->Stop();
379                 m->hMusicController->EmptyPlaylist();
380                 eina_list_free(m->elInfo);
381                 m->elInfo = NULL;
382                 elm_genlist_clear(m->eoPlaylist);
383                 m_UpdateEmptySongInfo();
384                 break;
385
386         default:
387                 break;
388         }
389 }
390
391
392 void CPlaybackView::m_RemoveTimer(int timer_code)
393 {
394         ETimers timerCode = (ETimers)timer_code;
395
396         switch (timerCode) {
397         case TIMER_SLIDER:
398                 if (m->etSlider) {
399                         ecore_timer_del(m->etSlider);
400                         m->etSlider = NULL;
401                 }
402                 break;
403
404         case TIMER_WAIT:
405                 if (m->etWait) {
406                         ecore_timer_del(m->etWait);
407                         m->etWait = NULL;
408                 }
409                 break;
410
411         case TIMER_LONGPRESS:
412                 if (m->etLongPress) {
413                         ecore_timer_del(m->etLongPress);
414                         m->etLongPress = NULL;
415                 }
416                 break;
417
418         case TIMER_VOLUME:
419                 m->pHandleVolume->RemoveTimer();
420                 break;
421
422         default:
423                 _ERR(" invalid value ");
424                 break;
425         }
426 }
427
428
429 void CPlaybackView::m_PlaybackPause(void)
430 {
431         m->hMusicController->Pause();
432
433         if (m->etSlider)
434                 ecore_timer_freeze(m->etSlider);
435 }
436
437
438 void CPlaybackView::m_PlaybackResume(void)
439 {
440         m->hMusicController->Resume();
441
442         if (m->etSlider)
443                 ecore_timer_thaw(m->etSlider);
444 }
445
446
447 void CPlaybackView::m_ChangeEditmodeAll(Eina_List *list, bool flag)
448 {
449         SItemInfo *itinfo = NULL;
450         void *obj = NULL;
451         Eina_List *l = NULL;
452
453         EINA_LIST_FOREACH(list, l, obj) {
454                 itinfo = (SItemInfo *)obj;
455                 itinfo->edit_mode = flag;
456         }
457 }
458
459
460 void CPlaybackView::m_DisableCheckAll(Eina_List *list)
461 {
462         SItemInfo *itinfo = NULL;
463         void *obj = NULL;
464         Eina_List *l = NULL;
465
466         EINA_LIST_FOREACH(list, l, obj) {
467                 itinfo = (SItemInfo *)obj;
468                 itinfo->check_status = false;
469         }
470 }
471
472
473 void CPlaybackView::m_SelectItem(SItemInfo *pItemInfo)
474 {
475         if (!pItemInfo || !pItemInfo->item)
476                 return;
477
478         elm_genlist_item_bring_in(pItemInfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN);
479         elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
480
481         pItemInfo->select_status = true;
482 }
483
484
485 void CPlaybackView::m_UnselectItem(SItemInfo *pItemInfo)
486 {
487         if (!pItemInfo || !pItemInfo->item)
488                 return;
489
490         elm_object_item_signal_emit(pItemInfo->item, MUSIC_SIGNAL_UNSELECT_ITEM,
491                 MUSIC_PLAYBACK_VIEW);
492
493         pItemInfo->select_status = false;
494 }
495
496
497 void CPlaybackView::m_UpdateControlBtns(void)
498 {
499         int state;
500
501         state = m->hMusicController->PlayState();
502         if (state != PLAY_STATUS_STOP) {
503                 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
504                 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND],  EINA_FALSE);
505         }
506         else {
507                 if (!m->eoErrPopup)
508                         elm_object_focus_set(m->eoBtnControl[BTN_PLAY],   EINA_TRUE);
509                 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
510                 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND],  EINA_TRUE);
511         }
512
513         if (state == PLAY_STATUS_PLAY) {
514                 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
515         }
516         else {
517                 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
518         }
519
520         state = m->hMusicController->ShuffleState();
521         if (state == SHUFFLE_STATUS_OFF) {
522                 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
523         }
524         else {
525                 elm_object_signal_emit(m->eoBtnControl[BTN_SHUFFLE], MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
526         }
527
528         state = m->hMusicController->RepeatState();
529         if (state == REPEAT_STATUS_NONE) {
530                 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
531         }
532         else if (state == REPEAT_STATUS_ALL) {
533                 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
534         }
535         else {
536                 elm_object_signal_emit(m->eoBtnControl[BTN_REPEAT], MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
537         }
538 }
539
540
541 void CPlaybackView::m_UpdateCurrentSongProgressbar(void)
542 {
543         int duration;
544         char *timestr = NULL;
545         double step;
546         int state;
547
548         if (!m->csinfo)
549                 return;
550
551         elm_slider_value_set(m->eoSlider, 0);
552         elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
553
554         state = m->hMusicController->PlayState();
555
556         if (state == PLAY_STATUS_STOP) {
557                 elm_object_disabled_set(m->eoSlider, EINA_TRUE);
558                 m_RemoveTimer(TIMER_SLIDER);
559                 return;
560         }
561
562         elm_object_disabled_set(m->eoSlider, EINA_FALSE);
563
564         duration = m->csinfo->Duration();
565         {
566                 m_RemoveTimer(TIMER_SLIDER);
567                 m->etSlider = ecore_timer_add(S_INTERVAL,
568                         sm_CbUpdateSlider, m);
569
570                 elm_slider_min_max_set(m->eoSlider, 0, duration);
571                 timestr = CCommonUI::TimeStrFromMilSeconds(duration);
572                 if (timestr) {
573                         elm_object_part_text_set(m->eoBase,
574                                 MUSIC_PART_FULLTIME, timestr);
575                         free(timestr);
576                 }
577
578                 step = (double)SLIDER_STEP / (double)duration;
579                 elm_slider_step_set(m->eoSlider, step);
580         }
581 }
582
583
584 void CPlaybackView::m_UpdateCurrentSongThumbnail(void)
585 {
586         char *path = NULL;
587         char buf[MAX_LENGTH];
588
589         if (!m->cs_itinfo || !m->cs_itinfo->sinfo)
590                 return;
591
592         path = m->cs_itinfo->sinfo->ThumbnailPath();
593         if (path)
594                 elm_image_file_set(m->eoAlbumCover, path, NULL);
595         else {
596                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
597                         MUSIC_IMAGE_DEFAULT_THUMB_450);
598                 elm_image_file_set(m->eoAlbumCover, buf, NULL);
599         }
600 }
601
602
603 void CPlaybackView::m_UpdateCurrentSongLabels(void)
604 {
605         char buf[MAX_LENGTH];
606
607         if (!m->csinfo)
608                 return;
609
610         elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
611                 m->csinfo->Name());
612
613         snprintf(buf, sizeof(buf), "%s - %s", m->csinfo->Artist(),
614                 m->csinfo->Album());
615
616         elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM, buf);
617 }
618
619
620 void CPlaybackView::m_UpdateEmptySongInfo(void)
621 {
622         char buf[MAX_LENGTH];
623
624         elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
625                 MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
626         elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
627         elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
628                 m->eoBtnControl[BTN_REPEAT], ELM_FOCUS_RIGHT);
629         elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_TRUE);
630         elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_TRUE);
631         elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
632         elm_object_disabled_set(m->eoSlider, EINA_TRUE);
633         elm_object_part_text_set(m->eoBase, MUSIC_PART_FULLTIME, "00:00");
634         elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME, "00:00");
635         elm_slider_value_set(m->eoSlider, 0);
636         elm_object_part_text_set(m->eoBase, MUSIC_PART_SONG_TITLE,
637                 _(NO_PLAYLIST_MESSAGE));
638         elm_object_part_text_set(m->eoBase, MUSIC_PART_ARTIST_ALBUM,
639                 _(NO_PLAYLIST_MESSAGE_SUB));
640         snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
641                 MUSIC_IMAGE_DEFAULT_THUMB_450);
642         elm_image_file_set(m->eoAlbumCover, buf, NULL);
643         m->hMusicController->SetPlayState(PLAY_STATUS_INITIAL);
644 }
645
646
647 void CPlaybackView::m_UpdateCtxtView(int playStatus)
648 {
649         if (!m->cs_itinfo || !m->ctxtinfo)
650                 return;
651
652         if (!m->mgr->CheckTop(MUSIC_CONTEXT_VIEW))
653                 return;
654
655         if (m->cs_itinfo->sinfo == m->ctxtinfo->context) {
656                 m->ctxtinfo->status = (EPlayStatus)playStatus;
657
658                 SParcel parcel;
659                 memset(&parcel, 0, sizeof(SParcel));
660                 parcel.updateType = E_SONG_UPDATE;
661                 m->mgr->UpdateView((const char *)MUSIC_CONTEXT_VIEW, &parcel);
662         }
663 }
664
665
666 void CPlaybackView::m_UpdateCurrentSongItem(int index)
667 {
668         SItemInfo *pItemInfo = NULL;
669
670         if (m->cs_itinfo) {
671                 m_UnselectItem(m->cs_itinfo);
672                 m_UpdateCtxtView(PLAY_STATUS_PAUSE);
673         }
674
675         pItemInfo = (SItemInfo *)eina_list_nth(m->elInfo, index);
676
677         if (pItemInfo) {
678                 m->cs_itinfo = pItemInfo;
679                 if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
680                         elm_genlist_item_bring_in(pItemInfo->item,
681                                 ELM_GENLIST_ITEM_SCROLLTO_IN);
682                 }
683                 else {
684                         m_SelectItem(pItemInfo);
685                         m_UpdateCtxtView(PLAY_STATUS_PLAY);
686                 }
687         }
688 }
689
690
691 void CPlaybackView::m_UpdateEditmodeFocusSequence(void)
692 {
693         elm_object_focus_next_object_set(m->eoPlaylist,
694                 m->eoBtnEdit[BTN_CANCEL], ELM_FOCUS_LEFT);
695         elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
696                 m->eoPlaylist, ELM_FOCUS_RIGHT);
697         elm_object_focus_next_object_set(m->eoSlider, m->eoBtnEdit[BTN_CANCEL],
698                 ELM_FOCUS_DOWN);
699 }
700
701
702 void CPlaybackView::m_UpdatePlaymodeFocusSequence(void)
703 {
704         elm_object_focus_next_object_set(m->eoSlider, m->eoPlaylist,
705                 ELM_FOCUS_UP);
706         elm_object_focus_next_object_set(m->eoSlider, m->eoBtnControl[BTN_PLAY],
707                 ELM_FOCUS_DOWN);
708         if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
709                 elm_object_focus_next_object_set(m->eoPlaylist,
710                         m->eoBtnControl[BTN_PLAY], ELM_FOCUS_LEFT);
711                 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
712                         m->eoPlaylist, ELM_FOCUS_RIGHT);
713         }
714         else {
715                 elm_object_focus_next_object_set(m->eoPlaylist,
716                         m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_LEFT);
717                 elm_object_focus_next_object_set(m->eoBtnControl[BTN_FORWARD],
718                         m->eoPlaylist, ELM_FOCUS_RIGHT);
719                 elm_object_focus_next_object_set(m->eoBtnControl[BTN_PLAY],
720                         m->eoBtnControl[BTN_FORWARD], ELM_FOCUS_RIGHT);
721         }
722 }
723
724
725 void CPlaybackView::m_UpdateCurrentSongInfo(void)
726 {
727         CSongInfo *sinfo = NULL;
728         int index;
729
730         if (eina_list_count(m->elInfo) == 0) {
731                 m_UpdateEmptySongInfo();
732                 return;
733         }
734
735         if (!m->hMusicController->GetCurrentSongIndex(&index)) {
736                 _ERR(" music get current song index failed ");
737                 return;
738         }
739
740         if (!m->hMusicController->GetSonginfoFromIndex(index, &sinfo)) {
741                 _ERR(" music get songinfo failed ");
742                 return;
743         }
744         m->csinfo = sinfo;
745
746         m_UpdateCurrentSongItem(index);
747         m_UpdateCurrentSongLabels();
748         m_UpdateCurrentSongThumbnail();
749         m_UpdateCurrentSongProgressbar();
750         m_UpdateControlBtns();
751         m_UpdatePlaymodeFocusSequence();
752 }
753
754
755 void CPlaybackView::m_DisableEditButtons(bool flag)
756 {
757         /* flag - 1 means disable edit buttons and 0 means enable */
758         if (flag)
759                 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
760
761         elm_object_disabled_set(m->eoBtnEdit[BTN_DELETE], (Eina_Bool)flag);
762         elm_object_disabled_set(m->eoBtnEdit[BTN_DESELECT], (Eina_Bool)flag);
763         if (flag) {
764                 m_UpdateEditmodeFocusSequence();
765                 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
766         }
767         else {
768                 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_CANCEL],
769                         m->eoBtnEdit[BTN_DESELECT], ELM_FOCUS_RIGHT);
770                 elm_object_focus_next_object_set(m->eoBtnEdit[BTN_DELETE],
771                         m->eoPlaylist, ELM_FOCUS_RIGHT);
772                 elm_object_focus_next_object_set(m->eoPlaylist,
773                         m->eoBtnEdit[BTN_DELETE], ELM_FOCUS_LEFT);
774         }
775 }
776
777
778 void CPlaybackView::m_CreateErrorPopup(void)
779 {
780         Evas_Object *popup = NULL, *btn = NULL, *label = NULL;
781
782         popup = elm_popup_add(m->eoBase);
783         if (!popup)
784                 return;
785
786         elm_object_style_set(popup, MUSIC_STYLE_ERROR_POPUP);
787         evas_object_show(popup);
788
789         label = elm_label_add(popup);
790         if (!label) {
791                 evas_object_del(popup);
792                 return;
793         }
794
795         elm_object_style_set(label, MUSIC_STYLE_ERROR_LABEL);
796         elm_object_text_set(label, MUSIC_TEXT_PLAYBACK_ERROR);
797         elm_object_content_set(popup, label);
798
799         btn = elm_button_add(popup);
800         if (!btn) {
801                 evas_object_del(popup);
802                 return;
803         }
804
805         elm_object_style_set(btn, MUSIC_STYLE_EDIT_BTN);
806         elm_object_text_set(btn, MUSIC_TEXT_OK);
807         elm_object_part_content_set(popup, MUSIC_PART_POPUP_BUTTON, btn);
808
809         m->eoErrPopup = popup;
810
811         Connect(btn, EO_ERROR_POPUP_BUTTON, TYPE_CLICKED | TYPE_KEY_DOWN);
812
813         elm_object_focus_set(btn, EINA_TRUE);
814
815         return;
816 }
817
818
819 void CPlaybackView::m_DestroyErrorPopup(void)
820 {
821         if (!m->eoErrPopup)
822                 return;
823
824         evas_object_del(m->eoErrPopup);
825         m->eoErrPopup = NULL;
826 }
827
828
829 void CPlaybackView::m_CreateSettingsPopup(void)
830 {
831         CPlaySettingCtxPopup *eoCtxPopup = new CPlaySettingCtxPopup;
832         CCtxPopup::SCallback cb;
833         cb.cookie = this;
834         cb.onSelected = sm_CbCtxPopupBtnSelected;
835
836         eoCtxPopup->Create(m->eoWin, &cb);
837
838         m->eoCtxPopup = eoCtxPopup;
839 }
840
841
842 void CPlaybackView::m_DestroySettingsPopup(void)
843 {
844         if (!m->eoCtxPopup)
845                 return;
846
847         if (m->eoCtxPopup->FlagCreate())
848                 m->eoCtxPopup->Destroy();
849
850         delete m->eoCtxPopup;
851         m->eoCtxPopup = NULL;
852 }
853
854
855 void CPlaybackView::m_FromEditToPlaybackMode(void)
856 {
857         if (m->hMusicController->PlayState() == PLAY_STATUS_STOP) {
858                 elm_genlist_item_bring_in(m->cs_itinfo->item,
859                         ELM_GENLIST_ITEM_SCROLLTO_IN);
860         }
861         else
862                 m_SelectItem(m->cs_itinfo);
863
864         elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
865                 MUSIC_PLAYBACK_VIEW);
866         elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
867
868         m_ChangeEditmodeAll(m->elInfo, false);
869
870         elm_genlist_realized_items_update(m->eoPlaylist);
871
872         m_UpdatePlaymodeFocusSequence();
873 }
874
875
876 void CPlaybackView::m_FromPlaybackToEditMode(void)
877 {
878         elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_EDIT_MODE,
879                 MUSIC_PLAYBACK_VIEW);
880
881         m_DisableEditButtons(true);
882
883         elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
884
885         m_ChangeEditmodeAll(m->elInfo, true);
886
887         elm_genlist_realized_items_update(m->eoPlaylist);
888
889         m_UpdateEditmodeFocusSequence();
890 }
891
892
893 void CPlaybackView::m_HandleOnRepeated(void)
894 {
895         Evas_Object *obj = NULL;
896         int value;
897         int duration;
898         char *timestr = NULL;
899
900         if (!m->eoPressedObj)
901                 return;
902
903         obj = m->eoPressedObj;
904
905         value = elm_slider_value_get(m->eoSlider);
906         duration = m->cs_itinfo->sinfo->Duration();
907
908         if (obj == m->eoBtnControl[BTN_REWIND]) {
909                 if (value == 0) {
910                         m_RemoveTimer(TIMER_LONGPRESS);
911                         return;
912                 }
913                 value = value - LP_CHANGE;
914                 if (value <= 0)
915                         value = 0;
916         }
917         else {
918                 if (value == duration) {
919                         if (m->hMusicController->PlayNextSong())
920                                 m_UpdateCurrentSongInfo();
921                         else
922                                 _ERR(" music play next song failed ");
923
924                         m->press_status = PRESS_LONG_PAUSE;
925                         elm_object_signal_emit(m->eoBtnControl[BTN_PLAY], MUSIC_SIGNAL_PAUSE,
926                                 MUSIC_PLAYBACK_VIEW);
927                         m_PlaybackPause();
928                         m_RemoveTimer(TIMER_LONGPRESS);
929
930                         return;
931                 }
932                 value = value + LP_CHANGE;
933                 if (value >= duration)
934                         value = duration;
935         }
936
937         m->hMusicController->SetPosition(value);
938         elm_slider_value_set(m->eoSlider, value);
939         timestr = CCommonUI::TimeStrFromMilSeconds(value);
940         if (timestr) {
941                 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
942                         timestr);
943                 free(timestr);
944         }
945
946         return;
947 }
948
949
950 void CPlaybackView::m_DeleteSelectedItems(void)
951 {
952         Eina_List *l = NULL, *l_next = NULL;
953         SItemInfo *pItemInfo = NULL;
954         void *obj = NULL;
955         int index;
956         bool flag = false;
957
958         m_DisableEditButtons(true);
959         EINA_LIST_FOREACH_SAFE(m->elInfo, l, l_next, obj) {
960                 pItemInfo = (SItemInfo *)obj;
961                 if (pItemInfo->check_status) {
962                         if (m->cs_itinfo == pItemInfo) {
963                                 flag = true;
964                                 m_UnselectItem(m->cs_itinfo);
965                                 m_RemoveTimer(TIMER_SLIDER);
966                                 m->cs_itinfo = NULL;
967                                 m->hMusicController->SetPlayState(PLAY_STATUS_STOP);
968                                 m->hMusicController->Stop();
969                         }
970                         index = elm_genlist_item_index_get(pItemInfo->item);
971                         m->hMusicController->RemoveSong(pItemInfo->sinfo, index);
972
973                         m->elInfo = eina_list_remove(m->elInfo,
974                                 pItemInfo);
975                         elm_object_item_del(pItemInfo->item);
976                 }
977         }
978
979         if (eina_list_count(m->elInfo) == 0) {
980                 m_UpdateEmptySongInfo();
981                 elm_genlist_realized_items_update(m->eoPlaylist);
982                 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
983                 return;
984         }
985
986         if (flag)
987                 m_UpdateCurrentSongInfo();
988
989         elm_genlist_realized_items_update(m->eoPlaylist);
990         elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
991 }
992
993
994 void CPlaybackView::m_KeyBackPress(void)
995 {
996         if (m->eoCtxPopup) {
997                 m_DestroySettingsPopup();
998                 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_FALSE);
999                 elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1000                 return;
1001         }
1002
1003         t_OnHide();
1004         m->mgr->PopView();
1005 }
1006
1007
1008 void CPlaybackView::m_KeyExitPress(void)
1009 {
1010         m_RemoveTimer(TIMER_SLIDER);
1011         m->hMusicController->Stop();
1012         elm_exit();
1013 }
1014
1015
1016 void CPlaybackView::m_KeyPlayPress(void)
1017 {
1018         int state;
1019
1020         if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1021                 return;
1022
1023         state = m->hMusicController->PlayState();
1024         if (state == PLAY_STATUS_PAUSE) {
1025                 m_PlaybackResume();
1026                 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1027                         MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1028         }
1029         else if (state != PLAY_STATUS_PLAY) {
1030                 if (m->hMusicController)
1031                         m->hMusicController->Start();
1032
1033                 m_UpdateCurrentSongInfo();
1034         }
1035 }
1036
1037
1038 void CPlaybackView::m_KeyPausePress(void)
1039 {
1040         int state;
1041
1042         if (elm_object_disabled_get(m->eoBtnControl[BTN_PLAY]))
1043                 return;
1044
1045         state = m->hMusicController->PlayState();
1046         if (state == PLAY_STATUS_PLAY) {
1047                 elm_object_signal_emit(m->eoBtnControl[BTN_PLAY],
1048                         MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1049                 m_PlaybackPause();
1050         }
1051 }
1052
1053
1054 void CPlaybackView::m_KeyNextPress(void)
1055 {
1056         if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1057                 return;
1058
1059         m_HandleOnPressed(m->eoBtnControl[BTN_FORWARD]);
1060 }
1061
1062
1063 void CPlaybackView::m_KeyPreviousPress(void)
1064 {
1065         if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1066                 return;
1067
1068         m_HandleOnPressed(m->eoBtnControl[BTN_REWIND]);
1069 }
1070
1071
1072 void CPlaybackView::m_KeyNextUnpress(void)
1073 {
1074         if (elm_object_disabled_get(m->eoBtnControl[BTN_FORWARD]))
1075                 return;
1076
1077         m_HandleOnUnpressed(m->eoBtnControl[BTN_FORWARD]);
1078 }
1079
1080
1081 void CPlaybackView::m_KeyPreviousUnpress(void)
1082 {
1083         if (elm_object_disabled_get(m->eoBtnControl[BTN_REWIND]))
1084                 return;
1085
1086         m_HandleOnUnpressed(m->eoBtnControl[BTN_REWIND]);
1087 }
1088
1089
1090 void CPlaybackView::m_HandleKeyPress(char *keyname)
1091 {
1092         if (!strcmp(keyname, (char *)KEY_EXIT))
1093                 m_KeyExitPress();
1094         else if (!strcmp(keyname, (char *)KEY_BACK) ||
1095                 !strcmp(keyname, (char *)KEY_BACK_REMOTE))
1096                 m_KeyBackPress();
1097         else if (!strcmp(keyname, (char *)KEY_PLAY))
1098                 m_KeyPlayPress();
1099         else if (!strcmp(keyname, (char *)KEY_PAUSE))
1100                 m_KeyPausePress();
1101         else if (!strcmp(keyname, (char *)KEY_NEXT))
1102                 m_KeyNextPress();
1103         else if (!strcmp(keyname, (char *)KEY_PREVIOUS))
1104                 m_KeyPreviousPress();
1105         else if (!strcmp(keyname, (char *)KEY_VOLUMEUP))
1106                 m->pHandleVolume->Up();
1107         else if (!strcmp(keyname, (char *)KEY_VOLUMEDOWN))
1108                 m->pHandleVolume->Down();
1109         else if (!strcmp(keyname, (char *)KEY_MUTE))
1110                 m->pHandleVolume->Mute();
1111 }
1112
1113
1114 void CPlaybackView::m_HandleKeyUnpress(char *keyname)
1115 {
1116         if (!strcmp(keyname, KEY_PREVIOUS))
1117                 m_KeyPreviousUnpress();
1118         else if (!strcmp(keyname, KEY_NEXT))
1119                 m_KeyNextUnpress();
1120 }
1121
1122
1123 void CPlaybackView::m_AddSlider(void)
1124 {
1125         Evas_Object *eoSlider = NULL;
1126
1127         eoSlider = elm_slider_add(m->eoBase);
1128         if (!eoSlider)
1129                 return;
1130
1131         elm_slider_indicator_show_set(eoSlider, EINA_FALSE);
1132         elm_slider_indicator_show_on_focus_set(eoSlider, EINA_FALSE);
1133         elm_object_style_set(eoSlider, MUSIC_STYLE_SLIDER);
1134         elm_slider_horizontal_set(eoSlider, EINA_TRUE);
1135         elm_object_part_content_set(m->eoBase, MUSIC_PART_PROGRESSBAR, eoSlider);
1136
1137         Connect(eoSlider, EO_SLIDER, TYPE_CHANGED | TYPE_MOUSE_MOVE);
1138
1139         evas_object_show(eoSlider);
1140         m->eoSlider = eoSlider;
1141 }
1142
1143
1144 void CPlaybackView::m_AddAlbumCover(void)
1145 {
1146         Evas_Object *eoAlbumCover = NULL;
1147
1148         eoAlbumCover = elm_image_add(m->eoBase);
1149         if (!eoAlbumCover)
1150                 return;
1151
1152         evas_object_size_hint_weight_set(eoAlbumCover, EVAS_HINT_EXPAND,
1153                         EVAS_HINT_EXPAND);
1154         elm_image_aspect_fixed_set(eoAlbumCover, EINA_FALSE);
1155
1156         elm_object_part_content_set(m->eoBase, MUSIC_PART_ALBUMCOVER,
1157                         eoAlbumCover);
1158         evas_object_show(eoAlbumCover);
1159         m->eoAlbumCover = eoAlbumCover;
1160
1161 }
1162
1163
1164 void CPlaybackView::m_AddCurrentSonginfo(void)
1165 {
1166         m_AddAlbumCover();
1167         m_AddSlider();
1168 }
1169
1170
1171 void CPlaybackView::m_AddEditPlaylistButtons(void)
1172 {
1173         Evas_Object *box = NULL;
1174         int i;
1175         SBtnInfo btninfo[TOTAL_EDIT_BTNS];
1176
1177         btninfo[BTN_CANCEL].txt = MUSIC_TEXT_CANCEL;
1178         btninfo[BTN_CANCEL].type = EO_CANCEL;
1179
1180         btninfo[BTN_DESELECT].txt = MUSIC_TEXT_DESELECT;
1181         btninfo[BTN_DESELECT].type = EO_DESELECT;
1182
1183         btninfo[BTN_DELETE].txt = MUSIC_TEXT_DELETE;
1184         btninfo[BTN_DELETE].type = EO_DELETE;
1185
1186         box = CCommonUI::AddBox(m->eoBase);
1187         if (!box)
1188                 return;
1189
1190         elm_box_horizontal_set(box, EINA_TRUE);
1191         elm_box_padding_set(box,
1192                 MUSIC_EDIT_BTNS_PADDING * elm_config_scale_get(), 0);
1193
1194         for (i = 0; i < TOTAL_EDIT_BTNS; i++) {
1195                 m->eoBtnEdit[i] = elm_button_add(m->eoBase);
1196                 if (!m->eoBtnEdit[i])
1197                         continue;
1198
1199                 elm_object_style_set(m->eoBtnEdit[i],
1200                         MUSIC_STYLE_EDIT_BTN);
1201                 evas_object_size_hint_weight_set(m->eoBtnEdit[i],
1202                         EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1203                 elm_box_pack_end(box, m->eoBtnEdit[i]);
1204                 elm_object_text_set(m->eoBtnEdit[i], _(btninfo[i].txt));
1205
1206                 Connect(m->eoBtnEdit[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1207
1208                 evas_object_show(m->eoBtnEdit[i]);
1209         }
1210         elm_object_part_content_set(m->eoBase, MUSIC_PART_EDITBTNS, box);
1211         elm_object_signal_emit(m->eoBase, MUSIC_SIGNAL_PLAYBACK_MODE,
1212                 MUSIC_PLAYBACK_VIEW);
1213 }
1214
1215
1216 void CPlaybackView::m_AddControlButtons(void)
1217 {
1218         Evas_Object *box = NULL;
1219         int i;
1220         SBtnInfo btninfo[TOTAL_CONTROL_BTNS];
1221
1222         btninfo[BTN_SETTINGS].txt = MUSIC_STYLE_BTN_SETTINGS;
1223         btninfo[BTN_SETTINGS].type = EO_BTN_SETTINGS;
1224
1225         btninfo[BTN_SHUFFLE].txt = MUSIC_STYLE_BTN_SHUFFLE;
1226         btninfo[BTN_SHUFFLE].type = EO_BTN_SHUFFLE;
1227
1228         btninfo[BTN_REPEAT].txt = MUSIC_STYLE_BTN_REPEAT;
1229         btninfo[BTN_REPEAT].type = EO_BTN_REPEAT;
1230
1231         btninfo[BTN_REWIND].txt = MUSIC_STYLE_BTN_REWIND;
1232         btninfo[BTN_REWIND].type = EO_BTN_REWIND;
1233
1234         btninfo[BTN_PLAY].txt = MUSIC_STYLE_BTN_PLAY;
1235         btninfo[BTN_PLAY].type = EO_BTN_PLAY;
1236
1237         btninfo[BTN_FORWARD].txt = MUSIC_STYLE_BTN_FORWARD;
1238         btninfo[BTN_FORWARD].type = EO_BTN_FORWARD;
1239
1240         box = elm_box_add(m->eoBase);
1241         if (!box)
1242                 return;
1243
1244         evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
1245         evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0);
1246         elm_box_horizontal_set(box, EINA_TRUE);
1247         elm_box_padding_set(box,
1248                 MUSIC_CONTROL_BTNS_PADDING * elm_config_scale_get(), 0);
1249
1250         for (i = 0; i < TOTAL_CONTROL_BTNS; i++) {
1251                 m->eoBtnControl[i] = elm_button_add(m->eoBase);
1252                 if (!m->eoBtnControl[i])
1253                         continue;
1254
1255                 elm_object_style_set(m->eoBtnControl[i], btninfo[i].txt);
1256                 evas_object_size_hint_weight_set(m->eoBtnControl[i],
1257                         EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1258                 elm_box_pack_end(box, m->eoBtnControl[i]);
1259
1260                 if (i == BTN_REWIND || i == BTN_FORWARD) {
1261                         Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_PRESSED | TYPE_UNPRESSED | TYPE_MOUSE_MOVE);
1262                 }
1263                 else {
1264                         Connect(m->eoBtnControl[i], btninfo[i].type, TYPE_CLICKED | TYPE_MOUSE_MOVE);
1265                 }
1266                 evas_object_show(m->eoBtnControl[i]);
1267         }
1268
1269         elm_object_part_content_set(m->eoBase, MUSIC_PART_CONTROLBTNS, box);
1270 }
1271
1272
1273 SItemInfo *CPlaybackView::m_FindItemInfoFromSong(Eina_List *list, CSongInfo *sinfo)
1274 {
1275         Eina_List *l = NULL;
1276         SItemInfo *itinfo = NULL;
1277         void *obj = NULL;
1278
1279         EINA_LIST_FOREACH(list, l, obj) {
1280                 itinfo = (SItemInfo *)obj;
1281                 if (itinfo->sinfo == sinfo)
1282                         return itinfo;
1283         }
1284
1285         return NULL;
1286 }
1287
1288
1289 SItemInfo *CPlaybackView::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item)
1290 {
1291         Eina_List *l = NULL;
1292         SItemInfo *itinfo = NULL;
1293         void *obj = NULL;
1294
1295         EINA_LIST_FOREACH(list, l, obj) {
1296                 itinfo = (SItemInfo *)obj;
1297                 if (itinfo->item == item)
1298                         return itinfo;
1299         }
1300
1301         return NULL;
1302 }
1303
1304
1305 void CPlaybackView::m_UpdateItemCheck(SItemInfo *itinfo)
1306 {
1307         if (!itinfo) {
1308                 _ERR(" No item info to Update check ");
1309                 return;
1310         }
1311
1312         if (itinfo->check_status) {
1313                 elm_object_item_signal_emit(itinfo->item,
1314                         MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
1315                 itinfo->check_status = false;
1316                 return;
1317         }
1318
1319         elm_object_item_signal_emit(itinfo->item,
1320                 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
1321         itinfo->check_status = true;
1322 }
1323
1324
1325 class CElmGenlistItemClass {
1326 public:
1327         static char *sm_CbTextGet(void *data, Evas_Object *obj, const char *part)
1328         {
1329                 CSongInfo *sinfo = NULL;
1330                 SItemInfo *pItemInfo = (SItemInfo *)data;
1331                 char buf[MAX_LENGTH];
1332                 char *timestr = NULL;
1333                 int duration;
1334                 int index;
1335
1336                 if (!pItemInfo || !obj)
1337                         return NULL;
1338
1339                 sinfo = pItemInfo->sinfo;
1340
1341                 snprintf(buf, sizeof(buf), "%s", MUSIC_STR_EMPTY);
1342
1343                 if (!strcmp(part, "elm.text0")) {
1344                         index = elm_genlist_item_index_get(pItemInfo->item);
1345                         snprintf(buf, sizeof(buf), "%d", index);
1346                 }
1347                 else if (!strcmp(part, "elm.text1"))
1348                         snprintf(buf, sizeof(buf), "%s", sinfo->Name());
1349                 else if (!strcmp(part, "elm.text2"))
1350                         snprintf(buf, sizeof(buf), "%s - %s",
1351                         sinfo->Artist(),
1352                         sinfo->Album());
1353                 else if (!strcmp(part, "elm.text3")) {
1354                         duration = sinfo->Duration();
1355                         timestr = CCommonUI::TimeStrFromMilSeconds(duration);
1356                         if (timestr) {
1357                                 snprintf(buf, sizeof(buf), "%s", timestr);
1358                                 free(timestr);
1359                         }
1360                 }
1361
1362                 if (strcmp(buf, MUSIC_STR_EMPTY))
1363                         return strdup(buf);
1364
1365                 return NULL;
1366         }
1367         static Evas_Object *sm_CbContentGet(void *data, Evas_Object *obj, const char *part)
1368         {
1369                 CSongInfo *sinfo = NULL;
1370                 SItemInfo *pItemInfo = (SItemInfo *)data;
1371                 Evas_Object *img = NULL;
1372                 char *path = NULL;
1373                 char buf[MAX_LENGTH];
1374
1375                 if (!pItemInfo || !obj)
1376                         return NULL;
1377
1378                 sinfo = pItemInfo->sinfo;
1379
1380                 img = elm_image_add(obj);
1381                 if (!img)
1382                         return NULL;
1383
1384                 elm_image_aspect_fixed_set(img, EINA_FALSE);
1385
1386                 if (!strcmp(part, "elm.swallow.icon")) {
1387                         path = sinfo->ThumbnailPath();
1388                         if (path)
1389                                 elm_image_file_set(img, path, "NULL");
1390                         else {
1391                                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
1392                                         MUSIC_IMAGE_DEFAULT_THUMB_126);
1393                                 elm_image_file_set(img, buf, "NULL");
1394                         }
1395                 }
1396
1397                 return img;
1398
1399         }
1400         static void         sm_CbDel(void *data, Evas_Object *obj)
1401         {
1402                 free(data);
1403         }
1404 };
1405
1406
1407 Elm_Genlist_Item_Class *CPlaybackView::m_GetItemClass(void)
1408 {
1409         Elm_Genlist_Item_Class *list_item = NULL;
1410
1411         list_item = elm_genlist_item_class_new();
1412         if (!list_item) {
1413                 _ERR(" elm_genlist_item_class_new failed ");
1414                 return NULL;
1415         }
1416
1417         list_item->item_style       = MUSIC_STYLE_PLAYLIST;
1418         list_item->func.text_get    = CElmGenlistItemClass::sm_CbTextGet;
1419         list_item->func.content_get = CElmGenlistItemClass::sm_CbContentGet;
1420         list_item->func.state_get   = NULL;
1421         list_item->func.del         = CElmGenlistItemClass::sm_CbDel;
1422
1423         return list_item;
1424 }
1425
1426
1427 void CPlaybackView::m_AddGenlist(void)
1428 {
1429         Evas_Object *genlist = NULL;
1430         Evas_Object *eoBase = NULL;
1431
1432         eoBase = m->eoBase;
1433         genlist = elm_genlist_add(eoBase);
1434         if (!genlist)
1435                 return;
1436
1437         elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1438         evas_object_size_hint_weight_set(genlist,
1439                 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1440         elm_object_part_content_set(eoBase, MUSIC_PART_PLAYLIST, genlist);
1441         elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS);
1442         elm_genlist_multi_select_set(genlist, EINA_FALSE);
1443
1444         Connect(genlist, EO_PLAYLIST, TYPE_REALIZED | TYPE_UNREALIZED |
1445                 TYPE_MOUSE_MOVE | TYPE_KEY_DOWN | TYPE_ACTIVATED);
1446
1447         evas_object_show(genlist);
1448         m->eoPlaylist = genlist;
1449 }
1450
1451
1452 void CPlaybackView::m_AddPlaylist(void)
1453 {
1454         Elm_Genlist_Item_Class *list_item = NULL;
1455         int ts = 0;
1456         int i, index = -1;
1457         CSongInfo *sinfo = NULL;
1458         Elm_Object_Item *item = NULL;
1459         SItemInfo *pItemInfo = NULL;
1460
1461         m_AddGenlist();
1462         if (!m->eoPlaylist)
1463                 return;
1464
1465         list_item = m_GetItemClass();
1466         if (!list_item) {
1467                 evas_object_del(m->eoPlaylist);
1468                 return;
1469         }
1470
1471         if (!m->hMusicController->GetTotalSongs(&ts)) {
1472                 _ERR(" music get total songs failed ");
1473                 return;
1474         }
1475
1476         if (!m->hMusicController->GetCurrentSongIndex(&index))
1477                 _ERR(" music get current song index failed ");
1478
1479         for (i = 0; i < ts; i++) {
1480                 if (!m->hMusicController->GetSonginfoFromIndex(i, &sinfo)) {
1481                         _ERR(" music get songinfo failed ");
1482                         continue;
1483                 }
1484                 pItemInfo = (SItemInfo *)calloc(1, sizeof(*pItemInfo));
1485                 if (!pItemInfo)
1486                         return;
1487                 pItemInfo->sinfo = sinfo;
1488                 pItemInfo->edit_mode = false;
1489                 pItemInfo->check_status = false;
1490                 pItemInfo->select_status = false;
1491
1492                 item = elm_genlist_item_append(m->eoPlaylist, list_item,
1493                         pItemInfo, NULL, ELM_GENLIST_ITEM_NONE,
1494                         sm_CbItemSelect, m);
1495                 pItemInfo->item = item;
1496
1497                 if (i == index) {
1498                         pItemInfo->select_status = true;
1499                         m->cs_itinfo = pItemInfo;
1500                 }
1501                 m->elInfo = eina_list_append(m->elInfo, pItemInfo);
1502         }
1503 }
1504
1505
1506 void CPlaybackView::m_RemovePlaylist(void)
1507 {
1508         if (m->eoPlaylist) {
1509                 elm_genlist_clear(m->eoPlaylist);
1510                 m->eoPlaylist = NULL;
1511         }
1512
1513         if (m->elInfo) {
1514                 eina_list_free(m->elInfo);
1515                 m->elInfo = NULL;
1516         }
1517 }
1518
1519
1520 void CPlaybackView::m_HandleRewindBtnClicked(Evas_Object *obj)
1521 {
1522         elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1523                 MUSIC_PLAYBACK_VIEW);
1524
1525         if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1526                 return;
1527
1528         if (!m->hMusicController->PlayPreviousSong()){
1529                 _ERR(" music play previous song failed ");
1530                 return;
1531         }
1532
1533         m_UpdateCurrentSongInfo();
1534 }
1535
1536
1537 void CPlaybackView::m_HandleForwardBtnClicked(Evas_Object *obj)
1538 {
1539         elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED,
1540                 MUSIC_PLAYBACK_VIEW);
1541
1542         if (m->hMusicController->PlayState() == PLAY_STATUS_STOP)
1543                 return;
1544
1545         if (!m->hMusicController->PlayNextSong()) {
1546                 _ERR(" music play next song failed ");
1547                 return;
1548         }
1549
1550         m_UpdateCurrentSongInfo();
1551 }
1552
1553
1554 void CPlaybackView::m_HandleOnPressed(Evas_Object *obj)
1555 {
1556         m->press_status = PRESS_SHORT;
1557         m->eoPressedObj = obj;
1558
1559         m->etWait = ecore_timer_add(WAIT_INTERVAL, sm_CbWaitTimer, this);
1560 }
1561
1562
1563 void CPlaybackView::m_HandleOnUnpressed(Evas_Object *obj)
1564 {
1565         m_RemoveTimer(TIMER_WAIT);
1566         m_RemoveTimer(TIMER_LONGPRESS);
1567
1568         if (m->press_status == PRESS_SHORT) {
1569                 /* Handle song change */
1570                 if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY)
1571                         m_PlaybackPause();
1572
1573                 if (obj == m->eoBtnControl[BTN_FORWARD])
1574                         m_HandleForwardBtnClicked(obj);
1575                 else
1576                         m_HandleRewindBtnClicked(obj);
1577
1578                 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1579                         m_PlaybackResume();
1580         }
1581         else if (m->press_status == PRESS_LONG) {
1582                 if (m->hMusicController->PlayState() != PLAY_STATUS_PLAY)
1583                         m_PlaybackResume();
1584         }
1585
1586         m->press_status = PRESS_SHORT;
1587 }
1588
1589
1590 void CPlaybackView::m_HandleGenlistItemActivated(Evas_Object *obj, Elm_Object_Item *genListItem)
1591 {
1592         int index;
1593         SItemInfo *itinfo = NULL;
1594
1595         if (!obj || !genListItem)
1596                 return;
1597
1598         itinfo = m_FindItemInfoFromItem(m->elInfo, genListItem);
1599         if (!itinfo) {
1600                 _ERR(" no item info found ");
1601                 return;
1602         }
1603
1604         if (itinfo->edit_mode) {
1605                 m_UpdateItemCheck(itinfo);
1606                 m_DisableEditButtons(false);
1607                 return;
1608         }
1609
1610         index = elm_genlist_item_index_get(genListItem);
1611
1612         m->hMusicController->PlayIndexSong(--index);
1613         m_UpdateCurrentSongInfo();
1614 }
1615
1616
1617 bool CPlaybackView::Create(void *data)
1618 {
1619         ASSERT(!m);
1620
1621         _CREATE_BEGIN{
1622                 _CHECK(m = new SPlaybackView)
1623                 _CHECK(m->mgr = CViewMgr::GetInstance())
1624                 _CHECK(m->eoWin = m->mgr->Window())
1625                 _CHECK(m->hMusicController = CMusicController::GetInstance())
1626                 _CHECK(m->eoBase = CCommonUI::AddBase(m->eoWin, MUSIC_PLAYBACK_VIEW))
1627                 _CHECK(CBaseView::Create(data))
1628                 _CHECK(m->hMusicController->AddListener(this))
1629
1630                 _WHEN_SUCCESS{
1631                         m->press_status = PRESS_SHORT;
1632                         evas_object_data_set(m->eoBase, PLAYBACK_VIEW_DATA, m);
1633
1634                         m_AddControlButtons();
1635                         m_AddEditPlaylistButtons();
1636                         m_AddCurrentSonginfo();
1637                         m_AddPlaylist();
1638
1639                         m->pHandleVolume->Create(m->eoBase);
1640                         m_UpdatePlaymodeFocusSequence();
1641
1642                         Connect(m->eoBase, EO_BASE, TYPE_KEY_DOWN | TYPE_KEY_UP);
1643                 }
1644
1645                 _CHECK_FAIL{ m->hMusicController->RemoveListener(this); }
1646                 _CHECK_FAIL{ CBaseView::Destroy(); }
1647                 _CHECK_FAIL{ evas_object_del(m->eoBase); }
1648                 _CHECK_FAIL{ /* CMusicController::GetInstance())*/ }
1649                 _CHECK_FAIL{ /* mgr->Window() */ }
1650                 _CHECK_FAIL{ /* CViewerMgr::GetInstance() */}
1651                 _CHECK_FAIL{ delete m; m = NULL; }
1652         }_CREATE_END_AND_CATCH{ return false; }
1653
1654         return true;
1655 }
1656
1657
1658 void CPlaybackView::Destroy(void)
1659 {
1660         ASSERT(m);
1661
1662         Disconnect(m->eoBase);
1663         m->hMusicController->RemoveListener(this);
1664
1665         m_DestroyErrorPopup();
1666
1667         m_RemoveTimer(TIMER_SLIDER);
1668         m_RemoveTimer(TIMER_WAIT);
1669         m_RemoveTimer(TIMER_LONGPRESS);
1670         m_DestroySettingsPopup();
1671
1672         m->pHandleVolume->Destroy();
1673         CBaseView::Destroy();
1674         evas_object_del(m->eoBase);
1675
1676         free(m->ctxtinfo);
1677         delete m;
1678         m = NULL;
1679 }
1680
1681
1682 Evas_Object* CPlaybackView::Base(void)
1683 {
1684         ASSERT(m);
1685
1686         return m->eoBase;
1687 }
1688
1689
1690 void CPlaybackView::t_OnClickedSettings(Evas_Object *obj)
1691 {
1692         elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1693
1694         if (eina_list_count(m->elInfo) == 0)
1695                 return;
1696
1697         elm_object_signal_emit(obj, MUSIC_SIGNAL_CONTROL_SELECTED, MUSIC_PLAYBACK_VIEW);
1698         m_DestroySettingsPopup();
1699         m_CreateSettingsPopup();
1700 }
1701
1702
1703 void CPlaybackView::t_OnClickedShuffle(Evas_Object *obj)
1704 {
1705         elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1706
1707         switch (m->hMusicController->ShuffleState()) {
1708         case SHUFFLE_STATUS_OFF:
1709                 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_ON);
1710                 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_ON, MUSIC_PLAYBACK_VIEW);
1711                 break;
1712
1713         default:
1714                 m->hMusicController->SetShuffleState(SHUFFLE_STATUS_OFF);
1715                 elm_object_signal_emit(obj, MUSIC_SIGNAL_SHUFFLE_OFF, MUSIC_PLAYBACK_VIEW);
1716                 break;
1717         }
1718 }
1719
1720
1721 void CPlaybackView::t_OnClickedRepeat(Evas_Object *obj)
1722 {
1723         elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1724
1725         switch (m->hMusicController->RepeatState()) {
1726         case REPEAT_STATUS_NONE:
1727                 m->hMusicController->SetRepeatState(REPEAT_STATUS_ALL);
1728                 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ALL, MUSIC_PLAYBACK_VIEW);
1729                 break;
1730
1731         case REPEAT_STATUS_ALL:
1732                 m->hMusicController->SetRepeatState(REPEAT_STATUS_ONE);
1733                 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_ONE, MUSIC_PLAYBACK_VIEW);
1734                 break;
1735
1736         default:
1737                 m->hMusicController->SetRepeatState(REPEAT_STATUS_NONE);
1738                 elm_object_signal_emit(obj, MUSIC_SIGNAL_REPEAT_OFF, MUSIC_PLAYBACK_VIEW);
1739                 break;
1740         }
1741 }
1742
1743
1744 void CPlaybackView::t_OnClickedPlay(Evas_Object *obj)
1745 {
1746         elm_object_signal_emit(obj, MUSIC_SIGNAL_BTN_CLICKED, MUSIC_PLAYBACK_VIEW);
1747
1748         switch (m->hMusicController->PlayState()) {
1749         case PLAY_STATUS_PAUSE:
1750                 m_PlaybackResume();
1751                 elm_object_signal_emit(obj, MUSIC_SIGNAL_PLAY, MUSIC_PLAYBACK_VIEW);
1752                 break;
1753
1754         case PLAY_STATUS_PLAY:
1755                 elm_object_signal_emit(obj, MUSIC_SIGNAL_PAUSE, MUSIC_PLAYBACK_VIEW);
1756                 m_PlaybackPause();
1757                 break;
1758
1759         default:
1760                 if (m->hMusicController)
1761                         m->hMusicController->Start();
1762                 m_UpdateCurrentSongInfo();
1763                 break;
1764         }
1765 }
1766
1767
1768 void CPlaybackView::t_OnShow(void)
1769 {
1770         ASSERT(m);
1771
1772         int state;
1773
1774         m_UpdateCurrentSongInfo();
1775
1776         state = m->hMusicController->PlayState();
1777         if (state == PLAY_STATUS_INITIAL || state == PLAY_STATUS_STOP) {
1778                 m_RemovePlaylist();
1779                 m_AddPlaylist();
1780                 m->hMusicController->Start();
1781                 m_UpdateCurrentSongInfo();
1782         }
1783
1784         if (m->cs_itinfo) {
1785                 elm_genlist_item_show(m->cs_itinfo->item,
1786                         ELM_GENLIST_ITEM_SCROLLTO_IN);
1787                 elm_object_item_focus_set(m->cs_itinfo->item, EINA_TRUE);
1788         }
1789
1790         evas_object_show(m->eoBase);
1791 }
1792
1793
1794 void CPlaybackView::t_OnUpdate(void *data)
1795 {
1796         ASSERT(m);
1797
1798         SParcel *parcel = (SParcel *)data;
1799         int updateType;
1800         char *keyEvent = NULL;
1801
1802         if (!parcel)
1803                 updateType = E_PLAYLIST_UPDATE;
1804         else {
1805                 updateType = parcel->updateType;
1806                 keyEvent = (char *)parcel->keyEvent;
1807         }
1808
1809         switch (updateType) {
1810         case E_PLAYLIST_UPDATE:
1811                 m_RemovePlaylist();
1812                 m_AddPlaylist();
1813                 elm_object_disabled_set(m->eoBtnControl[BTN_FORWARD], EINA_FALSE);
1814                 elm_object_disabled_set(m->eoBtnControl[BTN_REWIND], EINA_FALSE);
1815                 elm_object_disabled_set(m->eoBtnControl[BTN_PLAY], EINA_FALSE);
1816                 elm_object_focus_next_object_set(m->eoBtnControl[BTN_REPEAT],
1817                         m->eoBtnControl[BTN_REWIND], ELM_FOCUS_RIGHT);
1818                 m_FromEditToPlaybackMode();
1819                 break;
1820
1821         case E_KEY_PRESS:
1822                 m_HandleKeyPress(keyEvent);
1823                 break;
1824
1825         case E_KEY_RELEASE:
1826                 m_HandleKeyUnpress(keyEvent);
1827                 break;
1828
1829         default:
1830                 break;
1831         }
1832 }
1833
1834
1835 void CPlaybackView::t_OnHide(void)
1836 {
1837         ASSERT(m);
1838
1839         evas_object_hide(m->eoBase);
1840 }
1841
1842
1843 void CPlaybackView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
1844 {
1845         switch (id) {
1846         case EO_BASE:
1847                 m_HandleKeyPress(ev->keyname);
1848                 break;
1849
1850         case EO_ERROR_POPUP_BUTTON:
1851                 if (!strcmp(ev->keyname, KEY_BACK) ||
1852                         !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1853                         m_DestroyErrorPopup();
1854                         elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1855                 }
1856                 break;
1857
1858         case EO_PLAYLIST:
1859                 {
1860                         Elm_Object_Item *it = NULL;
1861                         SContentInfo *ctxtinfo = NULL;
1862                         SItemInfo *itinfo = NULL;
1863
1864                         if (strcmp(ev->keyname, KEY_MENU) &&
1865                                 strcmp(ev->keyname, KEY_MENU_REMOTE))
1866                                 return;
1867
1868                         it = elm_object_focused_item_get(obj);
1869                         if (!it) {
1870                                 _ERR(" unable to get focused item ");
1871                                 return;
1872                         }
1873                         m->focused_item = it;
1874
1875                         if (m->ctxtinfo) {
1876                                 free(m->ctxtinfo);
1877                                 m->ctxtinfo = NULL;
1878                         }
1879
1880                         ctxtinfo = (SContentInfo *)calloc(1, sizeof(*ctxtinfo));
1881                         if (!ctxtinfo)
1882                                 return;
1883
1884                         itinfo = m_FindItemInfoFromItem(m->elInfo, it);
1885                         if (!itinfo) {
1886                                 free(ctxtinfo);
1887                                 return;
1888                         }
1889
1890                         if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY &&
1891                                 itinfo == m->cs_itinfo)
1892                                 ctxtinfo->status = PLAY_STATUS_PLAY;
1893                         else
1894                                 ctxtinfo->status = PLAY_STATUS_PAUSE;
1895
1896                         ctxtinfo->cbdata = this;
1897                         ctxtinfo->update = sm_CbCtxtUpdate;
1898                         ctxtinfo->close = sm_CbCtxtClose;
1899                         ctxtinfo->type = CONTEXT_TYPE_PLAYSONG;
1900                         ctxtinfo->context = itinfo->sinfo;
1901
1902                         m->ctxtinfo = ctxtinfo;
1903
1904                         SParcel parcel;
1905                         memset(&parcel, 0, sizeof(SParcel));
1906                         parcel.ctxtInfo = ctxtinfo;
1907                         if (!m->mgr->PushView(MUSIC_CONTEXT_VIEW, &parcel))
1908                                 _ERR("viewmgr push view MUSIC_CONTEXT_VIEW failed");
1909                 }
1910
1911         case EO_BOX:
1912                 if (!strcmp(ev->keyname, KEY_BACK) ||
1913                         !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
1914                         _ERR("eoCtxPopup BACK key pressed ");
1915                         m_DestroySettingsPopup();
1916                         elm_object_focus_set(m->eoBtnControl[BTN_SETTINGS], EINA_TRUE);
1917
1918                 }
1919                 else if (!strcmp(ev->keyname, KEY_EXIT)) {
1920                         _ERR("eoCtxPopup EXIT key pressed ");
1921                         m_DestroySettingsPopup();
1922                         m_RemoveTimer(TIMER_SLIDER);
1923                         m->hMusicController->Stop();
1924                         elm_exit();
1925                 }
1926                 break;
1927
1928         default:
1929                 break;
1930         }
1931 }
1932
1933
1934 void CPlaybackView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
1935 {
1936         switch (id) {
1937         case EO_BASE:
1938                 m_HandleKeyUnpress(ev->keyname);
1939                 break;
1940
1941         default:
1942                 break;
1943         }
1944 }
1945
1946
1947 void CPlaybackView::OnMouseClicked(int id, Evas_Object *obj)
1948 {
1949         switch (id) {
1950         case EO_ERROR_POPUP_BUTTON:
1951                 m_DestroyErrorPopup();
1952                 elm_object_focus_set(m->eoBtnControl[BTN_PLAY], EINA_TRUE);
1953                 break;
1954
1955         case EO_CANCEL:
1956                 m_DisableCheckAll(m->elInfo);
1957                 m_DisableEditButtons(true);
1958                 m_FromEditToPlaybackMode();
1959                 break;
1960
1961         case EO_DESELECT:
1962                 m_DisableCheckAll(m->elInfo);
1963                 m_DisableEditButtons(true);
1964                 elm_genlist_realized_items_update(m->eoPlaylist);
1965                 elm_object_focus_set(m->eoBtnEdit[BTN_CANCEL], EINA_TRUE);
1966                 break;
1967
1968         case EO_DELETE:
1969                 m_DeleteSelectedItems();
1970                 break;
1971
1972         case EO_BTN_SETTINGS:
1973                 t_OnClickedSettings(obj);
1974                 break;
1975
1976         case EO_BTN_SHUFFLE:
1977                 t_OnClickedShuffle(obj);
1978                 break;
1979
1980         case EO_BTN_REPEAT:
1981                 t_OnClickedRepeat(obj);
1982                 break;
1983
1984         case EO_BTN_PLAY:
1985                 t_OnClickedPlay(obj);
1986                 break;
1987
1988         default:
1989                 break;
1990         }
1991 }
1992
1993
1994 void CPlaybackView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
1995 {
1996         switch (id) {
1997         case EO_CANCEL:
1998         case EO_DESELECT:
1999         case EO_DELETE:
2000         case EO_SLIDER:
2001         case EO_BTN_FORWARD:
2002         case EO_BTN_PLAY:
2003         case EO_BTN_REPEAT:
2004         case EO_BTN_REWIND:
2005         case EO_BTN_SETTINGS:
2006         case EO_BTN_SHUFFLE:
2007                 if (!elm_object_focus_get(obj))
2008                         elm_object_focus_set(obj, EINA_TRUE);
2009                 break;
2010
2011         case EO_PLAYLIST:
2012                 {
2013                         Elm_Object_Item *item;
2014
2015                         item = elm_genlist_at_xy_item_get(obj, ev->cur.canvas.x,
2016                                 ev->cur.canvas.y, NULL);
2017                         if (!item)
2018                                 return;
2019
2020                         if (!elm_object_item_focus_get(item))
2021                                 elm_object_item_focus_set(item, EINA_TRUE);
2022                 }
2023                 break;
2024
2025         default:
2026                 break;
2027         }
2028 }
2029
2030
2031 void CPlaybackView::OnPressed(int id, Evas_Object *obj)
2032 {
2033         switch (id) {
2034         case EO_BTN_FORWARD:
2035         case EO_BTN_REWIND:
2036                 m_HandleOnPressed(obj);
2037                 break;
2038
2039         default:
2040                 break;
2041         }
2042 }
2043
2044
2045 void CPlaybackView::OnUnpressed(int id, Evas_Object *obj)
2046 {
2047         switch (id) {
2048         case EO_BTN_FORWARD:
2049         case EO_BTN_REWIND:
2050                 m_HandleOnUnpressed(obj);
2051                 break;
2052
2053         default:
2054                 break;
2055         }
2056 }
2057
2058
2059 void CPlaybackView::OnChanged(int id, Evas_Object *obj)
2060 {
2061         switch (id) {
2062         case EO_SLIDER:
2063                 {
2064                         char *timestr = NULL;
2065                         int value;
2066
2067                         if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2068                                 if (m->etSlider)
2069                                         ecore_timer_freeze(m->etSlider);
2070                         }
2071
2072                         value = elm_slider_value_get(obj);
2073                         m->hMusicController->SetPosition(value);
2074                         timestr = CCommonUI::TimeStrFromMilSeconds(value);
2075                         if (timestr) {
2076                                 elm_object_part_text_set(m->eoBase, MUSIC_PART_PROGRESSTIME,
2077                                         timestr);
2078                                 free(timestr);
2079                         }
2080
2081                         if (m->hMusicController->PlayState() == PLAY_STATUS_PLAY) {
2082                                 if (m->etSlider)
2083                                         ecore_timer_thaw(m->etSlider);
2084                         }
2085                 }
2086                 break;
2087
2088         default:
2089                 break;
2090         }
2091 }
2092
2093
2094 void CPlaybackView::OnRealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2095 {
2096         switch (id) {
2097         case EO_PLAYLIST:
2098                 {
2099                         elm_object_item_signal_callback_add(item,
2100                                 MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2101                                 sm_CbGenlistItemCheckClicked, this);
2102
2103                         int index = elm_genlist_item_index_get(item);
2104                         if ((index & 1) == 1)
2105                                 elm_object_item_signal_emit(item,
2106                                         MUSIC_SIGNAL_EVEN_ROW, MUSIC_PLAYBACK_VIEW);
2107                         else
2108                                 elm_object_item_signal_emit(item,
2109                                         MUSIC_SIGNAL_ODD_ROW, MUSIC_PLAYBACK_VIEW);
2110
2111                         SItemInfo *itInfo = m_FindItemInfoFromItem(m->elInfo, item);
2112                         if (itInfo->select_status)
2113                                 elm_object_item_signal_emit(item,
2114                                         MUSIC_SIGNAL_SELECT_ITEM, MUSIC_PLAYBACK_VIEW);
2115                         else
2116                                 elm_object_item_signal_emit(item,
2117                                         MUSIC_SIGNAL_UNSELECT_ITEM, MUSIC_PLAYBACK_VIEW);
2118
2119                         if (itInfo->edit_mode) {
2120                                 elm_object_item_signal_emit(item,
2121                                         MUSIC_SIGNAL_EDITMODE_ON, MUSIC_PLAYBACK_VIEW);
2122                                 if (itInfo->check_status) {
2123                                         elm_object_item_signal_emit(item,
2124                                                 MUSIC_SIGNAL_CHECK_ON, MUSIC_PLAYBACK_VIEW);
2125                                 }
2126                                 else
2127                                         elm_object_item_signal_emit(item,
2128                                                 MUSIC_SIGNAL_CHECK_OFF, MUSIC_PLAYBACK_VIEW);
2129                         }
2130                         else
2131                                 elm_object_item_signal_emit(item,
2132                                         MUSIC_SIGNAL_EDITMODE_OFF, MUSIC_PLAYBACK_VIEW);
2133                 }
2134                 break;
2135
2136         default:
2137                 break;
2138         }
2139 }
2140
2141
2142 void CPlaybackView::OnUnrealized(int id, Evas_Object *obj, Elm_Object_Item *item)
2143 {
2144         switch (id) {
2145         case EO_PLAYLIST:
2146                 elm_object_item_signal_callback_del(item,
2147                         MUSIC_SIGNAL_CHECK_CLICKED, MUSIC_PLAYBACK_VIEW,
2148                         sm_CbGenlistItemCheckClicked);
2149                 break;
2150
2151         default:
2152                 break;
2153         }
2154 }
2155
2156
2157 void CPlaybackView::OnActivated(int id, Evas_Object *obj, Elm_Object_Item *item)
2158 {
2159         switch (id) {
2160         case EO_PLAYLIST:
2161                 m_HandleGenlistItemActivated(obj, item);
2162                 break;
2163
2164         default:
2165                 break;
2166         }
2167 }
2168
2169
2170 void CPlaybackView::OnComplete(void)
2171 {
2172         m_UpdateCurrentSongInfo();
2173 }
2174
2175
2176 void CPlaybackView::OnError(void)
2177 {
2178         m_CreateErrorPopup();
2179 }
2180
2181
2182 void CPlaybackView::OnUsbConnected(void)
2183 {
2184 }
2185
2186
2187 void CPlaybackView::OnUpdateContent(void)
2188 {
2189 }