1fde9b6dd3cfd264fff4aa6250e008e0381df46f
[profile/tv/apps/native/filebrowser.git] / src / views / BaseView / FbBaseView.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 #include <Ecore.h>
20 #include <aul.h>
21 #include "i18n.h"
22 #include "define.h"
23
24 #include "AppCommon.h"
25 #include "ExtNameInfo.h"
26 #include "common.h"
27 #include "dbg.h"
28 #include <MediaContentDbListener.h>
29 #include <UsbConnectionListener.h>
30 #include "Popup.h"
31 #include "InputHandler.h"
32
33 #include <CtxPopup.h>
34
35 #include <BaseView.h>
36 #include "FbBaseView.h"
37 #include "Info.h"
38
39 #include "SourceCtxPopup.h"
40 #include "SortCtxPopup.h"
41
42 #include <ViewMgr.h>
43 #include <LayoutMgr.h>
44 #include <BaseLayout.h>
45 #include "FbAllLayout.h"
46 #include "FbPhotoLayout.h"
47 #include "FbVideoLayout.h"
48 #include "FbMusicLayout.h"
49
50 #define TOTAL_GROUP_BTNS        4
51 #define TOTAL_TOP_BTNS          2
52 #define TOTAL_UPDATE_CALLBACKS  2
53 #define PARAM_URI               "uri"
54 #define PARAM_SOURCE            "source"
55
56 struct _btn_info {
57         const char *txt;
58         const char *part;
59         const char *style;
60         const char *icon_path;
61 };
62
63 enum topbtns {
64         TOPBTN_SOURCE,
65         TOPBTN_SORT,
66 };
67
68 const char *source_arg[] = {
69         "all",
70         "tv",
71         "pUsb"
72 };
73
74 const char *linked_app[] = {
75         N_(""),
76         N_("org.tizen.gallery-tv-ref"),
77         N_("org.tizen.video-player-tv-ref"),
78         N_("org.tizen.music-player-tv-ref"),
79         N_(""),
80 };
81
82 struct SFbBaseView {
83         Evas_Object *eoWin;
84         Evas_Object *eoBase;
85         Evas_Object *eoBtnGroup[TOTAL_GROUP_BTNS];
86         Evas_Object *eoSelectedBtnGroup;//Evas_Object *c_grpbtn;
87         Evas_Object *eoBtnSource;
88         Evas_Object *eoBtnSort;
89
90         CCtxPopup   *pCtxPopup;
91         CPopup      *pPopup;
92
93         CLayoutMgr     *pLayoutMgr;
94
95         char*          *pCurrentLayoutId;
96         CFbAllLayout   *pFbAllLayout;
97         //CFbPhotoLayout *pFbPhotoLayout;
98         //CFbMusicLayout *pFbMusicLayout;
99         //CFbVideoLayout *pFbVideoLayout;
100
101         SFbBaseView() {
102                 int a;
103
104                 memset(eoBtnGroup, 0, sizeof(eoBtnGroup));
105                 pHandlerBase = new CHandlerBase(this);
106                 for (a = 0; a < TOTAL_TOP_BTNS; a++)
107                         pHandlerButton[a] = new CHandlerButton(this);
108                 for (a = 0; a < TOTAL_GROUP_BTNS; a++){
109                         pHandlerGroup[a] = new CHandlerGroup(this);
110                 }
111         }
112         virtual ~SFbBaseView() {
113                 int a;
114
115                 delete pHandlerBase;
116                 for (a = 0; a < TOTAL_TOP_BTNS; a++)
117                         delete pHandlerButton[a];
118                 for (a = 0; a < TOTAL_GROUP_BTNS; a++)
119                         delete pHandlerGroup[a];
120         }
121         
122         class CHandlerBase : public CListenerMgr, public IKeyDownListener {
123                 SFbBaseView *m;
124
125         public:
126                 CHandlerBase(SFbBaseView *ins) : IKeyDownListener(this) { m = ins; }
127
128                 virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) {
129                         if (!strcmp(ev->keyname, KEY_EXIT))
130                                 elm_exit();
131                         else if (!strcmp(ev->keyname, KEY_ENTER)) {
132                                 if (elm_object_focus_get(m->eoSelectedBtnGroup)) {
133                                         m->pFbAllLayout->SetFocus(EINA_TRUE);
134                                         // TODO: Each layout SetFocus???
135                                 }
136                         }
137                 }
138         } *pHandlerBase;
139
140         class CHandlerButton : public CListenerMgr, protected IKeyDownListener, IMouseMoveListener, IMouseClickedListener {
141         private:
142                 SFbBaseView *m;
143         private:
144                 static void sm_CbCtxPopupSelected(void* cookie, CCtxPopup* instance, const char* text)
145                 {
146                         SFbBaseView* m = (SFbBaseView*)cookie;
147                         if (!m)
148                                 return;
149
150                         _DBG(" instance->Type(): %d", instance->Type());
151                         switch (instance->Type()) {
152                         case CCtxPopup::TOPBTN_SORT:
153                                 elm_object_text_set(m->eoBtnSort, text);
154 #if 1
155                                 m->pFbAllLayout->Update(true);
156 #else
157                                 m->pLayoutMgr->Show(Current_layout);
158 #endif
159                                 break;
160
161                         case CCtxPopup::TOPBTN_SOURCE:
162                                 elm_object_text_set(m->eoBtnSource, text);
163 #if 1
164                                 m->pFbAllLayout->Update(false);
165 #else
166                                 m->pLayoutMgr->Show(Current_layout);
167 #endif
168                                 break;
169
170                         default:
171                                 break;
172                         }
173                 }
174
175         public:
176                 CHandlerButton(SFbBaseView *ins) : IKeyDownListener(this), IMouseMoveListener(this), IMouseClickedListener(this) { m = ins; }
177
178                 virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) {
179                         if (!strcmp(ev->keyname, KEY_BACK))
180                                 elm_object_focus_set(m->eoSelectedBtnGroup, EINA_TRUE);
181                 }
182                 virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev) {
183                         if (!elm_object_focus_get(obj))
184                                 elm_object_focus_set(obj, EINA_TRUE);
185                 }
186                 virtual void OnMouseClicked(int id, Evas_Object *obj) {
187                         CSourceCtxPopup::SCallback cb;
188                         cb.cookie = m;
189                         cb.onSelected = sm_CbCtxPopupSelected;
190
191                         if (obj == m->eoBtnSource) {
192                                 CSourceCtxPopup* pCtxPopup = new CSourceCtxPopup;
193                                 m->pCtxPopup = pCtxPopup;
194                                 pCtxPopup->Create(m->eoBase, &cb);
195                         }
196                         else if (obj == m->eoBtnSort) {
197                                 CSortCtxPopup* pCtxPopup = new CSortCtxPopup;
198                                 m->pCtxPopup = pCtxPopup;
199                                 pCtxPopup->Create(m->eoBase, &cb);
200                         }
201                 }
202         } *pHandlerButton[TOTAL_TOP_BTNS];
203
204         class CHandlerGroup : public CListenerMgr, IMouseMoveListener, IKeyDownListener, IMouseClickedListener {
205         private:
206                 SFbBaseView *m;
207         public:
208                 CHandlerGroup(SFbBaseView *ins) :
209                         IMouseMoveListener(this),
210                         IKeyDownListener(this),
211                         IMouseClickedListener(this) { m = ins; }
212
213                 virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev) {
214                         if (!elm_object_focus_get(obj))
215                                 elm_object_focus_set(obj, EINA_TRUE);
216                 }
217                 virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) {
218                         if (!strcmp(ev->keyname, KEY_BACK))
219                                 elm_exit();
220                 }
221                 virtual void OnMouseClicked(int id, Evas_Object *obj) {
222                         if (m->eoSelectedBtnGroup == obj)
223                                 return;
224
225                         elm_object_signal_emit(m->eoSelectedBtnGroup, FBR_SIGNAL_GROUP_UNSELECTED, "");
226                         m->eoSelectedBtnGroup = obj;
227                         elm_object_signal_emit(m->eoSelectedBtnGroup, FBR_SIGNAL_GROUP_SELECTED, "");
228
229 #if 1
230                         m->pFbAllLayout->Update(false);
231                         // TODO: not update, it should be "Show" as each layout
232 #else
233                         switch(id)
234                         {
235                                 case E_GRP_ALL:
236                                         m->pLayoutMgr->Show(FB_ALL_LAYOUT);
237                                         break;
238                                 case E_GRP_PHOTO:
239                                         m->pLayoutMgr->Show(FB_PHOTO_LAYOUT);
240                                         break;
241                                 case E_GRP_VIDEO:
242                                         m->pLayoutMgr->Show(FB_VIDEO_LAYOUT);
243                                         break;
244                                 case E_GRP_MUSIC:
245                                         m->pLayoutMgr->Show(FB_MUSIC_LAYOUT);
246                                         break;
247                                 default:
248                                         _DBG("Fix it: it can not make it , MouseClicked");
249                                         break;
250
251                         }
252 #endif
253                 }
254         } *pHandlerGroup[TOTAL_GROUP_BTNS];
255 };
256
257
258
259 Evas_Object *_add_button(Evas_Object *box)
260 {
261         Evas_Object *button;
262
263         if (!box)
264                 return NULL;
265
266         button = elm_button_add(box);
267         if (!button)
268                 return NULL;
269
270         evas_object_size_hint_weight_set(button,
271                 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
272         evas_object_show(button);
273
274         return button;
275 }
276
277 void CFbBaseView::UpdateEmptyFocusSequence(void)
278 {
279         int i;
280         _DBG("");
281
282         for (i = 0; i < TOTAL_GROUP_BTNS; i++)
283                 elm_object_focus_next_object_set(m->eoBtnGroup[i], m->eoBtnSort, ELM_FOCUS_RIGHT);
284
285         elm_object_focus_next_object_set(m->eoBtnGroup[E_GRP_ALL], m->eoBtnSort,              ELM_FOCUS_UP);
286         elm_object_focus_next_object_set(m->eoBtnSort,              m->eoBtnGroup[E_GRP_ALL], ELM_FOCUS_DOWN);
287         elm_object_focus_next_object_set(m->eoBtnSource,               m->eoBtnGroup[E_GRP_ALL], ELM_FOCUS_DOWN);
288
289         if (t_SelectedGroupButton() == m->eoBtnGroup[E_GRP_ALL]) {
290                 elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT,     _(NO_FILE_MESSAGE));
291                 elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT_SUB, _(NO_FILE_MESSAGE_SUB));
292         }
293         else if (t_SelectedGroupButton() == m->eoBtnGroup[E_GRP_PHOTO]) {
294                 elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT,     _(NO_PHOTO_MESSAGE));
295                 elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT_SUB, _(NO_PHOTO_MESSAGE_SUB));
296         }
297         else if (t_SelectedGroupButton() == m->eoBtnGroup[E_GRP_VIDEO]) {
298                 elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT,     _(NO_VIDEO_MESSAGE));
299                 elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT_SUB, _(NO_VIDEO_MESSAGE_SUB));
300         }
301         else if (t_SelectedGroupButton() == m->eoBtnGroup[E_GRP_MUSIC]) {
302                 elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT,     _(NO_MUSIC_MESSAGE));
303                 elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT_SUB, _(NO_MUSIC_MESSAGE_SUB));
304         }
305 }
306
307 void CFbBaseView::UnsetFocus(void)
308 {
309         elm_object_focus_set(t_SelectedGroupButton(), EINA_TRUE);
310 }
311
312 void CFbBaseView::CbLinkApp(int type, int source_type, char *path)
313 {
314         bundle *args;
315         int r;
316
317         args = bundle_create();
318         if (!args) {
319                 _ERR("unable to create bundle");
320                 return;
321         }
322
323         bundle_add(args, PARAM_SOURCE, source_arg[source_type]);
324         bundle_add(args, PARAM_URI, path);
325
326         r = aul_launch_app(linked_app[type], args);
327         if (args)
328                 bundle_free(args);
329         if (r < 0) {
330                 _ERR(" Unable to launch linked app");
331                 return;
332         }
333
334         return;
335 }
336
337 void CFbBaseView::UpdatedGrid(void)
338 {
339         int i;
340
341         for (i = 0; i < TOTAL_GROUP_BTNS; i++)
342                 elm_object_focus_next_object_set(m->eoBtnGroup[i],
343                 m->pFbAllLayout->Grid(), ELM_FOCUS_RIGHT);
344
345         elm_object_focus_next_object_set(m->eoBtnGroup[E_GRP_ALL],
346                 m->eoBtnSort, ELM_FOCUS_UP);
347         elm_object_focus_next_object_set(m->eoBtnSort,
348                 m->eoBtnGroup[E_GRP_ALL], ELM_FOCUS_LEFT);
349         elm_object_focus_next_object_set(m->eoBtnSort,
350                 m->pFbAllLayout->Grid(), ELM_FOCUS_DOWN);
351         elm_object_focus_next_object_set(m->eoBtnSource,
352                 m->pFbAllLayout->Grid(), ELM_FOCUS_DOWN);
353
354         elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT, "");
355         elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT_SUB, "");
356 }
357
358 void CFbBaseView::t_CreateTopSession(void)
359 {
360         _DBG();
361         int i;
362         Evas_Object *btn;
363         struct _btn_info btninfo[TOTAL_TOP_BTNS];
364         btninfo[TOPBTN_SOURCE].style = FBR_STYLE_SOURCE_BTN;
365         btninfo[TOPBTN_SOURCE].part  = FBR_PART_SOURCE_HOVERSEL;
366         
367         btninfo[TOPBTN_SORT].style = FBR_STYLE_SORT_BTN;
368         btninfo[TOPBTN_SORT].part  = FBR_PART_SORT_HOVERSEL;
369
370         elm_object_part_text_set(m->eoBase, FBR_PART_TITLE,
371                 _(FBR_TEXT_TITLE));
372
373         for (i = 0; i < TOTAL_TOP_BTNS; i++) {
374                 btn = _add_button(m->eoBase);
375                 if (!btn) {
376                         _ERR(" Adding btn failed ");
377                         return;
378                 }
379
380                 elm_object_style_set(btn, btninfo[i].style);
381                 elm_object_part_content_set(m->eoBase, btninfo[i].part, btn);
382
383                 m->pHandlerButton[i]->Connect(btn);
384
385                 if (i == TOPBTN_SOURCE)
386                         m->eoBtnSource = btn;
387                 else if (i == TOPBTN_SORT)
388                         m->eoBtnSort = btn;
389         }
390
391         elm_object_text_set(m->eoBtnSource, _(CSourceCtxPopup::SourceText(CInfo::SourceType())));
392         elm_object_text_set(m->eoBtnSort, _(CSortCtxPopup::SortText(CInfo::SortType())));
393 }
394
395 void CFbBaseView::t_CreateLeftSession(void)
396 {
397         _DBG();
398         Evas_Object *box, *ic;
399         int i;
400         char buf[MAX_LENGTH];
401         static struct _btn_info btninfo[TOTAL_GROUP_BTNS];
402         btninfo[E_GRP_ALL].txt = N_("ALL");
403         btninfo[E_GRP_ALL].icon_path = FBR_IMAGE_GRPBTN_ALL;
404         btninfo[E_GRP_PHOTO].txt = N_("PHOTO");
405         btninfo[E_GRP_PHOTO].icon_path = FBR_IMAGE_GRPBTN_PHOTO;
406         btninfo[E_GRP_VIDEO].txt = N_("VIDEO");
407         btninfo[E_GRP_VIDEO].icon_path = FBR_IMAGE_GRPBTN_VIDEO;
408         btninfo[E_GRP_MUSIC].txt = N_("MUSIC");
409         btninfo[E_GRP_MUSIC].icon_path = FBR_IMAGE_GRPBTN_MUSIC;
410
411         box = elm_box_add(m->eoBase);
412         if (!box)
413                 return;
414         evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
415         evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
416         evas_object_show(box);
417
418         for (i = 0; i < TOTAL_GROUP_BTNS; i++) {
419                 m->eoBtnGroup[i] = _add_button(box);
420                 if (!m->eoBtnGroup[i]) {
421                         _ERR(" failed to add button to box ");
422                         continue;
423                 }
424
425                 elm_box_pack_end(box, m->eoBtnGroup[i]);
426                 elm_object_style_set(m->eoBtnGroup[i], FBR_STYLE_GROUPBTN);
427                 elm_object_text_set(m->eoBtnGroup[i], _(btninfo[i].txt));
428                 
429                 m->pHandlerGroup[i]->Connect(m->eoBtnGroup[i], i);
430
431                 ic = elm_image_add(m->eoBtnGroup[i]);
432                 if (!ic)
433                         continue;
434                 _DBG("");
435
436                 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
437                         btninfo[i].icon_path);
438                 elm_image_file_set(ic, buf, NULL);
439                 elm_object_part_content_set(m->eoBtnGroup[i],
440                         FBR_PART_ELM_SWALLOWICON, ic);
441         }
442         _DBG("");
443
444         t_SetSelectedGroupButton(m->eoBtnGroup[E_GRP_ALL]);
445         _DBG("");
446
447         elm_object_signal_emit(m->eoBtnGroup[E_GRP_ALL],
448                 FBR_SIGNAL_GROUP_SELECTED, "");
449         elm_object_focus_set(m->eoBtnGroup[E_GRP_ALL], EINA_TRUE);
450         elm_object_part_content_set(m->eoBase, FBR_PART_GROUPBTN_BOX, box);
451 }
452
453 void CFbBaseView::t_CreateFullView(void)
454 {
455         t_CreateTopSession();
456         t_CreateLeftSession();
457         _DBG("UpdateLayout");
458 #if 1
459         m->pFbAllLayout->Update(false);
460 #else
461         m->pLayoutMgr->Show(Current_layout);
462 #endif
463 }
464
465 void CFbBaseView::t_SetSelectedGroupButton(Evas_Object* obj)
466 {
467         m->eoSelectedBtnGroup = obj;
468         int idx = -1;
469
470         int a;
471         for (a = 0; a < TOTAL_GROUP_BTNS; a++) {
472                 if (m->eoBtnGroup[a] == obj)
473                         idx = a;
474         }
475         CInfo::SetGroupIndex(idx);
476 }
477
478 Evas_Object* CFbBaseView::t_SelectedGroupButton(void)
479 {
480         return m->eoSelectedBtnGroup;
481 }
482
483 void CFbBaseView::t_OnShow(void)
484 {
485         _DBG();
486
487         evas_object_show(m->eoBase);
488
489         CBaseView::t_OnShow();
490 }
491
492 void CFbBaseView::t_OnUpdate(void *data)
493 {
494         // TODO: When does this function is called? If it don't be used, Remove it.
495         _DBG();
496         m->pFbAllLayout->Action();
497 }
498
499 void CFbBaseView::t_OnHide(void)
500 {
501         evas_object_hide(m->eoBase);
502
503         CBaseView::t_OnHide();
504 }
505
506 bool CFbBaseView::Create(void *data)
507 {
508         ASSERT(!m);
509
510         Evas_Object *eoWin = CViewMgr::GetInstance()->Window();
511         Evas_Object *eoBase = NULL;
512
513         int source_type = E_ALL;
514
515         _CREATE_BEGIN{
516                 _CHECK(m = new SFbBaseView)
517                 _CHECK(eoBase = elm_layout_add(eoWin))
518                 _CHECK(elm_layout_file_set(eoBase, EDJEFILE, FBR_BASE_VIEW))
519                 _COMMAND{
520                         evas_object_size_hint_weight_set(eoBase, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
521                         elm_win_resize_object_add(eoWin, eoBase);
522
523                         /* get the source_type using 'data' string */
524                         if (data) {
525                                 // Find Index
526                                 int i;
527                                 int arrsize = ARRAY_SIZE(source_arg);
528                                 for (i = 0; i < arrsize; i++) {
529                                         if (source_arg[i] && !strcmp(source_arg[i], (const char*)data)) {
530                                                 source_type = i;
531                                                 break;
532                                         }
533                                 }
534                                 if (source_type < E_ALL || source_type > E_USB)
535                                         source_type = E_ALL;
536                                 CInfo::SetSourceType(source_type);
537                                 m->eoWin = eoWin;
538                                 m->eoBase = eoBase;
539                         }
540                 }
541                 _CHECK(m->pLayoutMgr = new CLayoutMgr)
542                 _CHECK(m->pLayoutMgr->Create(eoBase, NULL))
543                 _CHECK(m->pFbAllLayout = new CFbAllLayout(FB_ALL_LAYOUT))
544                 //_CHECK(m->pFbPhotoLayout = new CFbPhotoLayout(FB_PHOTO_LAYOUT))
545                 //_CHECK(m->pFbVideoLayout = new CFbVideoLayout(FB_VIDEO_LAYOUT))
546                 //_CHECK(m->pFbMusicLayout = new CFbMusicLayout(FB_MUSIC_LAYOUT))
547                 _CHECK(m->pFbAllLayout->Create(m->pLayoutMgr, NULL))
548                 //_CHECK(m->pFbPhotoLayout->Create(m->pLayoutMgr, NULL))
549                 //_CHECK(m->pFbVideoLayout->Create(m->pLayoutMgr, NULL))
550                 //_CHECK(m->pFbMusicLayout->Create(m->pLayoutMgr, NULL))
551                 _CHECK(m->pLayoutMgr->AddLayout(m->pFbAllLayout))
552                 //_CHECK(m->pLayoutMgr->AddLayout(m->pFbPhotoLayout))
553                 //_CHECK(m->pLayoutMgr->AddLayout(m->pFbVideoLayout))
554                 //_CHECK(m->pLayoutMgr->AddLayout(m->pFbMusicLayout))
555                 _CHECK(CUsbConnectionListener::Create())
556                 _CHECK(CMediaContentDbUpdateListener::Create())
557
558                 _WHEN_SUCCESS{}
559
560                 _CHECK_FAIL{ CMediaContentDbUpdateListener::Destroy(); }
561                 _CHECK_FAIL{ CUsbConnectionListener::Destroy(); }
562                 //_CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbMusicLayout); }
563                 //_CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbVideoLayout); }
564                 //_CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbPhotoLayout); }
565                 _CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbAllLayout); }
566                 //_CHECK_FAIL{ m->pFbMusicLayout->Destroy(); }
567                 //_CHECK_FAIL{ m->pFbVideoLayout->Destroy(); }
568                 //_CHECK_FAIL{ m->pFbPhotoLayout->Destroy(); }
569                 _CHECK_FAIL{ m->pFbAllLayout->Destroy(); }
570                 //_CHECK_FAIL{ delete m->pFbMusicLayout; m->pFbMusicLayout = NULL; }
571                 //_CHECK_FAIL{ delete m->pFbVideoLayout; m->pFbVideoLayout = NULL; }
572                 //_CHECK_FAIL{ delete m->pFbPhotoLayout; m->pFbPhotoLayout = NULL; }
573                 _CHECK_FAIL{ delete m->pFbAllLayout; m->pFbAllLayout = NULL; }
574                 _CHECK_FAIL{ m->pLayoutMgr->Destroy(); }
575                 _CHECK_FAIL{ delete m->pLayoutMgr; m->pLayoutMgr = NULL; }
576                 _CHECK_FAIL{ /* elm_layout_file_set*/ }
577                 _CHECK_FAIL{ evas_object_del(eoBase); }
578                 _CHECK_FAIL{ delete m; m = NULL; }
579         } _CREATE_END_AND_CATCH{ return false; }
580
581
582         // original create grid
583         CInfo::SetSortType(0/*CSort::SORT_NAME_AZ*/);
584         evas_object_data_set(eoBase, BASE_VIEW_DATA, this);
585         m->pLayoutMgr->Show(FB_ALL_LAYOUT);
586         t_CreateFullView();
587         elm_object_focus_allow_set(eoBase, EINA_FALSE);
588         m->pHandlerBase->Connect(eoBase);
589         CBaseView::Create(NULL);
590         return true;
591 }
592
593 void CFbBaseView::Destroy(void)
594 {
595         ASSERT(m);
596
597         CBaseView::Destroy();
598         CMediaContentDbUpdateListener::Destroy();
599         CUsbConnectionListener::Destroy();
600
601 #if 0
602         m->pLayoutMgr->RemoveLayout(m->pFbMusicLayout);
603         m->pFbMusicLayout->Destroy();
604         delete m->pFbMusicLayout;
605         
606         m->pLayoutMgr->RemoveLayout(m->pFbVideoLayout);
607         m->pFbVideoLayout->Destroy();
608         delete m->pFbVideoLayout;
609
610         m->pLayoutMgr->RemoveLayout(m->pFbPhotoLayout);
611         m->pFbPhotoLayout->Destroy();
612         delete m->pFbPhotoLayout;
613 #endif
614
615         m->pLayoutMgr->RemoveLayout(m->pFbAllLayout);
616         m->pFbAllLayout->Destroy();
617         delete m->pFbAllLayout;
618
619         m->pLayoutMgr->Destroy();
620         delete m->pLayoutMgr;
621
622         evas_object_del(m->eoBase);
623
624         delete m;
625         m = NULL;
626 }
627
628
629 Evas_Object* CFbBaseView::Base(void)
630 {
631         ASSERT(m);
632
633         return m->eoBase;
634 }
635
636
637 void CFbBaseView::OnConnect(void)
638 {
639         m->pPopup = new CPopup;
640         if (!m->pPopup)
641                 return;
642         if (!m->pPopup->Create(m->eoBase)) {
643                 delete m->pPopup;
644                 m->pPopup = NULL;
645                 return;
646         }
647
648         if (CInfo::SourceType() == E_USB) {
649                 if (!FlagConnected()) {
650                         CInfo::SetSourceType(E_ALL);
651                         elm_object_text_set(m->eoBtnSource,
652                                 _(CSourceCtxPopup::SourceText(CInfo::SourceType())));
653                 }
654         }
655 }
656
657
658 void CFbBaseView::OnUpdated(const SEntity *entity)
659 {
660         _DBG();
661         m->pPopup->Destroy();
662         delete m->pPopup;
663         m->pPopup = NULL;
664
665         if (m->pCtxPopup) {
666                 m->pCtxPopup->Destroy();
667                 delete m->pCtxPopup;
668                 m->pCtxPopup = NULL;
669         }
670         if (CInfo::SourceType() != E_TV) {
671 #if 1
672                 m->pFbAllLayout->Update(false);
673 #else
674                 m->pLayoutMgr->Show(Current_layout);
675 #endif
676                 elm_object_focus_set(t_SelectedGroupButton(), EINA_TRUE);
677         }
678 }
679