1. Apply CUsbConnectionListener and CMediaContentDbUpdateListener 17/35017/4 submit/tizen_tv/20150209.024119
authorKim Tae Soo <taesoo46.kim@samsung.com>
Fri, 6 Feb 2015 03:00:43 +0000 (12:00 +0900)
committerKim Tae Soo <taesoo46.kim@samsung.com>
Fri, 6 Feb 2015 09:10:54 +0000 (18:10 +0900)
2. Fix bug (Event couldn't be handled in genlist of CCategoryLayout)
3. Add temp definition of back key and menu key

Change-Id: Ie2d21904e7119e68435d817b066e75ec90dd91b5
Signed-off-by: Kim Tae Soo <taesoo46.kim@samsung.com>
include/common.h
include/mediadata.h
include/music-controller.h
src/data/mediadata.cpp
src/playback/music-controller.cpp
src/views/base-view.cpp
src/views/category-layout.cpp

index bef2530..1d22aef 100644 (file)
@@ -151,6 +151,8 @@ struct SParcel {
 #define KEY_NEXT "Next"
 #define KEY_PREVIOUS "Previous"
 #define KEY_EXIT "Exit"
+#define KEY_BACK "Escape"
+#define KEY_MENU "Super_L"
 
 
 #endif /* __COMMON_H__ */
index fa00297..df6fbb1 100644 (file)
@@ -24,18 +24,13 @@ struct folder_info;
 
 #include <media_content.h>
 #include "common.h"
+#include <MediaContentDbListener.h>
 
-class CMediadata {
+class CMediadata : public CMediaContentDbUpdateListener {
 private:
        struct SMediadata* m;
 
 private:
-       static void sm_CbContentUpdate(media_content_error_e err, int pid,
-               media_content_db_update_item_type_e update_item,
-               media_content_db_update_type_e update_type,
-               media_content_type_e media_type,
-               char *uuid, char *path, char *mime_type,
-               void *dt);
        static bool sm_CbTotalDuration(media_info_h md_h, void *dt);
        static bool sm_CbEachMediaData(media_info_h md_h, void *dt);
        static bool sm_CbEachFolderData(media_folder_h folder_h, void *dt);
@@ -45,11 +40,6 @@ private:
        static bool sm_CbPlaylist(media_playlist_h ph, void *dt);
 
 private:
-       void m_HandleContentUpdate(media_content_error_e err, int pid,
-               media_content_db_update_item_type_e update_item,
-               media_content_db_update_type_e update_type,
-               media_content_type_e media_type,
-               char *uuid, char *path, char *mime_type);
        bool m_HandleEachMediaData(media_info_h md_h);
        bool m_HandleEachFolderData(media_folder_h folder_h);
        bool m_HandleEachAlbumData(media_album_h album_h);
@@ -94,6 +84,9 @@ public:
        bool RemovemediaPlaylist(int lid, Eina_List *idlist);
 
        static Eina_List *PlaylistsForCtxt(void);
+
+public:
+       virtual void OnUpdated(const SEntity *entity);
 };
 
 #endif /*__MEDIA_DATA_H__*/
index be0c9ff..a666afb 100644 (file)
@@ -19,7 +19,7 @@
 
 
 #include <Eina.h>
-//#include <usb-device.h>
+#include <UsbConnectionListener.h>
 
 struct SSongInfo;
 struct album_info;
@@ -40,7 +40,7 @@ protected:
 };
 
 
-class CMusicController {
+class CMusicController : public CUsbConnectionListener {
 private:
        static CMusicController *instance;
        static int refCnt;
@@ -65,9 +65,6 @@ private:
        static void sm_CbPlaybackCompletion(void *data);
        void m_OnPlaybackCompletion(void);
 
-       //static void sm_CbConnected(usb_device_h usb_device, char *action, void *dt);
-       //void m_OnConnected(usb_device_h usb_device, char *action);
-
 protected:
        bool t_PlayNext(int direction, int playnext_type);
        SMusicController* t_Create(void);
@@ -134,6 +131,9 @@ public:
        bool MediaRemovemediaPlaylist(int id, Eina_List *idlist);
        bool MediaAddsongsPlaylist(int lid, Eina_List *list);
        struct SSongInfo *MediaSongByUri(char *uri);
+
+public:
+       virtual void OnConnect(void);
 };
 
 
index 33b5608..6be37f7 100644 (file)
@@ -64,21 +64,6 @@ struct SMediadata {
        }
 };
 
-void CMediadata::sm_CbContentUpdate(media_content_error_e err, int pid,
-       media_content_db_update_item_type_e update_item,
-       media_content_db_update_type_e update_type,
-       media_content_type_e media_type,
-       char *uuid, char *path, char *mime_type,
-       void *dt)
-{
-       CMediadata *root = (CMediadata *)dt;
-
-       if (!root)
-               return;
-
-       root->m_HandleContentUpdate(err, pid, update_item, update_type, media_type, uuid, path, mime_type);
-}
-
 
 bool CMediadata::sm_CbTotalDuration(media_info_h md_h, void *dt)
 {
@@ -225,28 +210,6 @@ bool CMediadata::sm_CbPlaylist(media_playlist_h ph, void* dt)
 }
 
 
-void CMediadata::m_HandleContentUpdate(media_content_error_e err, int pid,
-       media_content_db_update_item_type_e update_item,
-       media_content_db_update_type_e update_type,
-       media_content_type_e media_type,
-       char *uuid, char *path, char *mime_type)
-{
-       Eina_List *l = NULL;
-       SCbInfo *cbinfo = NULL;
-       void *obj = NULL;
-
-       if (err != MEDIA_CONTENT_ERROR_NONE || !m)
-               return;
-
-       m->source_type = SOURCE_TYPE_NONE;
-       EINA_LIST_FOREACH(m->cblist, l, obj) {
-               cbinfo = (SCbInfo *)obj;
-               if (cbinfo->type == E_CONTENT_UPDATE && cbinfo->cb)
-                       cbinfo->cb(cbinfo->data);
-       }
-}
-
-
 bool CMediadata::m_HandleEachMediaData(media_info_h md_h)
 {
        SSongInfo *sinfo = NULL;
@@ -909,7 +872,7 @@ bool CMediadata::Create(void)
                return false;
        }
 
-       media_content_set_db_updated_cb(sm_CbContentUpdate, (void *)this);
+       CMediaContentDbUpdateListener::Create();
 
        m->source_type = SOURCE_TYPE_NONE;
 
@@ -942,14 +905,13 @@ void CMediadata::Destroy(void)
                free(cbinfo);
        }
 
-       free(m);
-
-       media_content_unset_db_updated_cb();
+       CMediaContentDbUpdateListener::Destroy();
 
        r = media_content_disconnect();
        if (r != MEDIA_CONTENT_ERROR_NONE)
                _ERR("Media Content Connect Failed");
 
+       delete m;
 }
 
 
@@ -1320,3 +1282,21 @@ Eina_List *CMediadata::PlaylistsForCtxt(void)
 
        return list;
 }
+
+
+void CMediadata::OnUpdated(const SEntity *entity)
+{
+       Eina_List *l = NULL;
+       SCbInfo *cbinfo = NULL;
+       void *obj = NULL;
+
+       if (entity->err != MEDIA_CONTENT_ERROR_NONE || !m)
+               return;
+
+       m->source_type = SOURCE_TYPE_NONE;
+       EINA_LIST_FOREACH(m->cblist, l, obj) {
+               cbinfo = (SCbInfo *)obj;
+               if (cbinfo->type == E_CONTENT_UPDATE && cbinfo->cb)
+                       cbinfo->cb(cbinfo->data);
+       }
+}
\ No newline at end of file
index 57a339f..2e0ddd1 100644 (file)
@@ -15,7 +15,6 @@
  */
 #include <app.h>
 #include <string.h>
-//#include <usb-device.h>
 #include <AppCommon.h>
 #include <stdlib.h>
 #include "dbg.h"
@@ -180,43 +179,6 @@ void CMusicController::m_OnPlaybackCompletion(void)
        }
 }
 
-bool CMusicController::CheckUsb(void)
-{
-       /*if (!m)
-               return false;
-
-       if (usb_get_connected_device_number(USB_MASS_STORAGE) <= 0)
-               return false;
-
-       return true;*/
-       return false;
-}
-
-/*void CMusicController::sm_CbConnected(usb_device_h usb_device, char *action, void *dt)
-{
-       CMusicController *root = (CMusicController*)dt;
-       if (root)
-               root->m_OnConnected(usb_device, action);
-}
-
-
-void CMusicController::m_OnConnected(usb_device_h usb_device, char *action)
-{
-       Eina_List *l;
-       struct SCbInfo *cbinfo;
-       void *obj;
-
-       if (SourceType() == SOURCE_TYPE_USB) {
-               if (!CheckUsb())
-                       SetSourceType(SOURCE_TYPE_ALL);
-       }
-
-       EINA_LIST_FOREACH(m->elListener, l, obj) {
-               cbinfo = (SCbInfo *)obj;
-               if (cbinfo->type == E_USB_CONNECT && cbinfo->cb)
-                       cbinfo->cb(cbinfo->data);
-       }
-}*/
 
 static void _content_update_cb(void *dt)
 {
@@ -265,12 +227,17 @@ SMusicController *CMusicController::t_Create(void)
                _ERR(" playback create failed ");
 
        if (!mhandle->pPlayback->SetCallback(sm_CbPlaybackCompletion, this))
-               _ERR(" playback add completion callback failed");
+               _ERR(" playback add completion callback failed ");
 
        mhandle->cbinfo = mhandle->pMediadata->AddCallback(E_CONTENT_UPDATE, _content_update_cb, mhandle);
 
-       //usb_device_init();
-       //usb_set_connected_cb(sm_CbConnected, this);
+       if (!CUsbConnectionListener::Create()) {
+               _ERR("CUsbConnectionListener::Create failed");
+               mhandle->pPlayback->Destroy();
+               mhandle->pMediadata->Destroy();
+               delete mhandle;
+               return NULL;
+       }
 
        return mhandle;
 }
@@ -300,6 +267,8 @@ void CMusicController::t_Destroy(void)
        struct SCbInfo *cbinfo;
        void *obj;
 
+       CUsbConnectionListener::Destroy();
+
        if (m->pPlayback->FlagCreate()) {
                if (!m->pPlayback->UnsetCallback())
                        _ERR(" playback remove completion callback failed");
@@ -324,9 +293,6 @@ void CMusicController::t_Destroy(void)
                free(cbinfo);
        }
 
-       //usb_unset_connected_cb();
-       //usb_device_fini();
-
        delete m;
 }
 
@@ -995,3 +961,25 @@ bool CMusicController::SetSortType(int type)
 
        return true;
 }
+
+
+void CMusicController::OnConnect(void)
+{
+       if (!m)
+               return;
+
+       Eina_List *l;
+       struct SCbInfo *cbinfo;
+       void *obj;
+
+       if (SourceType() == SOURCE_TYPE_USB) {
+               if (!FlagConnected())
+                       SetSourceType(SOURCE_TYPE_ALL);
+       }
+
+       EINA_LIST_FOREACH(m->elListener, l, obj) {
+               cbinfo = (SCbInfo *)obj;
+               if (cbinfo->type == E_USB_CONNECT && cbinfo->cb)
+                       cbinfo->cb(cbinfo->data);
+       }
+}
\ No newline at end of file
index f17c58f..bc717b5 100644 (file)
@@ -392,7 +392,7 @@ void CMusicBaseView::m_CreateCtxPopup(int btnType)
 
        for (i = 0; i < size; i++) {
                if (btnType == BTN_SOURCE && i == SOURCE_TYPE_USB &&
-                       !m->mhandle->CheckUsb())
+                       !m->mhandle->FlagConnected())
                        continue;
 
                btn = s_AddButton(box);
index 9aa6545..8c4ae3e 100644 (file)
@@ -1351,11 +1351,17 @@ void CCategoryLayout::m_SortCatgrid(void)
 
 void CCategoryLayout::m_EmptyLayout(bool sort_flag)
 {
-       if (t.grid)
+       if (t.grid) {
                elm_gengrid_clear(t.grid);
+               evas_object_del(t.grid);
+               t.grid = NULL;
+       }
 
-       if (m->glist)
+       if (m->glist) {
                elm_genlist_clear(m->glist);
+               evas_object_del(m->glist);
+               m->glist = NULL;
+       }
 
        if (!sort_flag) {
                if (m->catlist) {