dbg.h file is removed.
[profile/tv/apps/native/filebrowser.git] / src / views / BaseView / FbBaseView.cpp
index eaadef9..88393e3 100644 (file)
 * limitations under the License.
 */
 
-#include <Elementary.h>
-#include <Eina.h>
 #include <Ecore.h>
 #include <aul.h>
-#include "i18n.h"
 #include "define.h"
-
-#include "AppCommon.h"
-#include "ExtNameInfo.h"
 #include "common.h"
-#include "dbg.h"
-#include <MediaContentDbListener.h>
-#include <UsbConnectionListener.h>
-#include "Popup.h"
-#include "InputHandler.h"
 
-#include <CtxPopup.h>
-
-#include <BaseView.h>
+#include <AppCommon.h>
 #include "FbBaseView.h"
+#include "i18n.h"
 #include "Info.h"
-
+#include "Popup.h"
 #include "SourceCtxPopup.h"
 #include "SortCtxPopup.h"
-
-#include <ViewMgr.h>
-#include <LayoutMgr.h>
-#include <BaseLayout.h>
 #include "FbAllLayout.h"
 #include "FbPhotoLayout.h"
 #include "FbVideoLayout.h"
@@ -109,7 +93,7 @@ struct SFbBaseView {
        Evas_Object *eoBtnSource;
        Evas_Object *eoBtnSort;
 
-       CCtxPopup   *pCtxPopup;
+       CContextPopup   *pCtxPopup;
        CPopup      *pPopup;
 
        CLayoutMgr     *pLayoutMgr;
@@ -182,7 +166,7 @@ struct SFbBaseView {
        private:
                SFbBaseView *m;
        private:
-               static void sm_CbCtxPopupSelected(void* cookie, CCtxPopup* instance, const char* text)
+               static void sm_CbCtxPopupSelected(void* cookie, CContextPopup* instance, const char* text)
                {
                        SFbBaseView* m = (SFbBaseView*)cookie;
                        if (!m)
@@ -190,7 +174,7 @@ struct SFbBaseView {
 
                        _DBG(" instance->Type(): %d", instance->Type());
                        switch (instance->Type()) {
-                       case CCtxPopup::TOPBTN_SORT:
+                       case CContextPopup::TOPBTN_SORT:
                                elm_object_text_set(m->eoBtnSort, text);
                                switch(m->curLayoutId)
                                {
@@ -210,7 +194,7 @@ struct SFbBaseView {
                                m->pLayoutMgr->Show(_get_layout_id(m->curLayoutId));
                                break;
 
-                       case CCtxPopup::TOPBTN_SOURCE:
+                       case CContextPopup::TOPBTN_SOURCE:
                                elm_object_text_set(m->eoBtnSource, text);
                                switch(m->curLayoutId)
                                {
@@ -600,13 +584,14 @@ bool CFbBaseView::Create(void *data)
                _CHECK(m->pLayoutMgr->AddLayout(m->pFbPhotoLayout))
                _CHECK(m->pLayoutMgr->AddLayout(m->pFbVideoLayout))
                _CHECK(m->pLayoutMgr->AddLayout(m->pFbMusicLayout))
-               _CHECK(CUsbConnectionListener::Create())
-               _CHECK(CMediaContentDbUpdateListener::Create())
-
+               _COMMAND{
+                       if(!CUsbListener::Create())
+                               _ERR("Fail to create CUsbListener()");
+                       if(!CMediaContentListener::Create())
+                               _ERR("Fail to create CMediaContentListener()");
+               }
                _WHEN_SUCCESS{}
 
-               _CHECK_FAIL{ CMediaContentDbUpdateListener::Destroy(); }
-               _CHECK_FAIL{ CUsbConnectionListener::Destroy(); }
                _CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbMusicLayout); }
                _CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbVideoLayout); }
                _CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbPhotoLayout); }
@@ -644,8 +629,11 @@ void CFbBaseView::Destroy(void)
        ASSERT(m);
 
        CBaseView::Destroy();
-       CMediaContentDbUpdateListener::Destroy();
-       CUsbConnectionListener::Destroy();
+
+       if(CMediaContentListener::FlagCreate())
+               CMediaContentListener::Destroy();
+       if(CUsbListener::FlagCreate())
+               CUsbListener::Destroy();
 
        m->pLayoutMgr->RemoveLayout(m->pFbMusicLayout);
        m->pFbMusicLayout->Destroy();
@@ -681,28 +669,31 @@ Evas_Object* CFbBaseView::Base(void)
 }
 
 
-void CFbBaseView::OnConnect(void)
+void CFbBaseView::OnStatusChanged(SUsbHostDeviceInfo *changedDevice, SUsbHostDeviceStatus status)
 {
-       m->pPopup = new CPopup;
-       if (!m->pPopup)
-               return;
-       if (!m->pPopup->Create(m->eoBase)) {
-               delete m->pPopup;
-               m->pPopup = NULL;
-               return;
-       }
+       if(status == USB_HOST_DEV_CONNECTED) {
+               m->pPopup = new CPopup;
+               if (!m->pPopup)
+                       return;
+               if (!m->pPopup->Create(m->eoBase)) {
+                       delete m->pPopup;
+                       m->pPopup = NULL;
+                       return;
+               }
 
-       if (CInfo::SourceType() == E_USB) {
-               if (!FlagConnected()) {
-                       CInfo::SetSourceType(E_ALL);
-                       elm_object_text_set(m->eoBtnSource,
-                               _(CSourceCtxPopup::SourceText(CInfo::SourceType())));
+               if (CInfo::SourceType() == E_USB) {
+                       if (!FlagConnected()) {
+                               CInfo::SetSourceType(E_ALL);
+                               elm_object_text_set(m->eoBtnSource,
+                                               _(CSourceCtxPopup::SourceText(CInfo::SourceType())));
+                       }
                }
        }
+       /* FIXME: should add disconnected flow */
 }
 
 
-void CFbBaseView::OnUpdated(const SEntity *entity)
+void CFbBaseView::OnDbUpdated(const SEntity *entity)
 {
        _DBG();
        m->pPopup->Destroy();