From f028931f118ee0a8d3c4da156d7645f8a10fd085 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Fri, 6 Mar 2015 18:12:48 +0900 Subject: [PATCH 01/16] Apply CPopupWindow class Change-Id: I10549bcd391b8b8d1c8bdf3ffdfcca80dfd563fd Signed-off-by: Kim Tae Soo --- CMakeLists.txt | 1 + include/context-view.h | 16 ++---- src/views/RemovePopupWindow.cpp | 51 +++++++++++++++++ src/views/RemovePopupWindow.h | 35 ++++++++++++ src/views/context-view.cpp | 120 +++++++++++----------------------------- 5 files changed, 124 insertions(+), 99 deletions(-) create mode 100644 src/views/RemovePopupWindow.cpp create mode 100644 src/views/RemovePopupWindow.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ab5516..4ebda26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,7 @@ SET(SRCS src/main.cpp src/views/SortCtxPopup.cpp src/views/PlaySettingCtxPopup.cpp src/views/PlayListCtxPopup.cpp + src/views/RemovePopupWindow.cpp src/playback/playlist-mgr.cpp src/playback/music-controller.cpp src/playback/playback-mgr.cpp diff --git a/include/context-view.h b/include/context-view.h index 7679dd1..caf007c 100644 --- a/include/context-view.h +++ b/include/context-view.h @@ -19,6 +19,7 @@ #include +#include "PopupWindow.h" struct SContentInfo; struct SRltvCtnt; @@ -33,14 +34,11 @@ private: private: static void sm_CbRltdCtntSelected(void *data, Evas_Object *obj, const char *emission, const char *source); - static void sm_CbPopupKeyPressed(void *data, Evas *e, Evas_Object *obj, void *ei); - void m_OnPopUpKeyPressed(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); + static void sm_CbRemove(void* cookie, CPopupWindow *instance); + void m_OnRemove(CPopupWindow *instance); - static void sm_CbRemove(void *data, Evas_Object *obj, void *ei); - void m_OnRemove(Evas_Object *obj); - - static void sm_CbCancel(void *data, Evas_Object *obj, void *ei); - void m_OnCancel(Evas_Object *obj); + static void sm_CbCancel(void* cookie, CPopupWindow *instance); + void m_OnCancel(CPopupWindow *instance); static int sm_CbSortPlaylist(const void *d1, const void *d2); static void sm_CbPopupDeleted(void *data, Evas *e, Evas_Object *obj, void *ei); @@ -84,9 +82,7 @@ private: bool m_CreateInfoPart(void); bool m_CreateFullView(void); CCtxPopup *m_CreatePlaylistPopup(void); - Evas_Object *m_CreateRemovePopup(Evas_Object *base, const char *msg, - Evas_Object_Event_Cb _close_cb, Evas_Smart_Cb _remove_cb, - Evas_Smart_Cb _cancel_cb, void *dt); + CPopupWindow *m_CreateRemovePopup(Evas_Object *base, const char *msg); void m_DestroyPopup(void); void m_HandleBtnSelected(int btnType); void m_HandleMoreinfoSelected(Evas_Object *obj); diff --git a/src/views/RemovePopupWindow.cpp b/src/views/RemovePopupWindow.cpp new file mode 100644 index 0000000..2c0aa51 --- /dev/null +++ b/src/views/RemovePopupWindow.cpp @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the License); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an AS IS BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include +#include +#include +#include +#include +#include "i18n.h" +#include "define.h" +#include "dbg.h" +#include "common.h" +#include "RemovePopupWindow.h" + + +#define NUM_BTNS 2 + +const char *btnText[NUM_BTNS] = { + _(MUSIC_TEXT_REMOVE), + _(MUSIC_TEXT_CANCEL) +}; + +void CRemovePopupWindow::t_OnConfiguration(void) +{ + t_SetParams(_(MUSIC_TEXT_REMOVE), NULL, _(m_msg), NUM_BTNS, (const char **)btnText); +} + +bool CRemovePopupWindow::Create(Evas_Object* base, const SCallback* callback, const char *msg) +{ + m_msg = msg; + + if (!CPopupWindow::Create(base, callback)) { + _ERR("Creation of remove popup failed"); + return false; + } + + return true; +} \ No newline at end of file diff --git a/src/views/RemovePopupWindow.h b/src/views/RemovePopupWindow.h new file mode 100644 index 0000000..5fdbec7 --- /dev/null +++ b/src/views/RemovePopupWindow.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __REMOVE_POPUP_WINDOW_H__ +#define __REMOVE_POPUP_WINDOW_H__ + +#include + +class CRemovePopupWindow : public CPopupWindow { +private: + const char *m_msg; + +protected: + virtual void t_OnConfiguration(void); + +public: + bool Create(Evas_Object* base, const SCallback* callback, const char *msg); +}; + + +#endif // __REMOVE_POPUP_WINDOW_H__ \ No newline at end of file diff --git a/src/views/context-view.cpp b/src/views/context-view.cpp index 3c9c0a9..f07350d 100644 --- a/src/views/context-view.cpp +++ b/src/views/context-view.cpp @@ -34,6 +34,8 @@ #include "ViewMgr.h" #include "context-view.h" #include "PlayListCtxPopup.h" +#include "PopupWindow.h" +#include "RemovePopupWindow.h" #include "Info.h" #define _GET_PRIV(o) evas_object_data_get(o, "CTMDATA"); @@ -102,7 +104,8 @@ struct SContextView { Evas_Object *playbtn; Evas_Object *first_line[TABLE_MAX_COL]; Evas_Object *last_line[TABLE_MAX_COL]; - Evas_Object *popup; + //Evas_Object *popup; + CRemovePopupWindow *popup; CPlayListCtxPopup *ctxpopup; Ecore_Idler *idler; CMusicController *mhandle; @@ -172,38 +175,19 @@ void CContextView::sm_CbRltdCtntSelected(void *data, Evas_Object *obj, const cha } -void CContextView::sm_CbPopupKeyPressed(void *data, Evas *e, Evas_Object *obj, void *ei) +void CContextView::sm_CbRemove(void* cookie, CPopupWindow *instance) { - CContextView *root = (CContextView *)data; + CContextView *root = (CContextView *)cookie; if (root) - root->m_OnPopUpKeyPressed(e, obj, (Evas_Event_Key_Down *)ei); + root->m_OnRemove(instance); } -void CContextView::m_OnPopUpKeyPressed(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) -{ - if (!ev->keyname) - return; - - if (!strcmp(ev->keyname, KEY_BACK) || - !strcmp(ev->keyname, KEY_BACK_REMOTE)) - m_DestroyPopup(); -} - - -void CContextView::sm_CbRemove(void *data, Evas_Object *obj, void *ei) -{ - CContextView *root = (CContextView *)data; - if (root) - root->m_OnRemove(obj); -} - - -void CContextView::m_OnRemove(Evas_Object *obj) +void CContextView::m_OnRemove(CPopupWindow *instance) { SContentInfo *cinfo = NULL; - if (!obj) { + if (!instance) { _ERR("Invalid argument."); return; } @@ -218,17 +202,17 @@ void CContextView::m_OnRemove(Evas_Object *obj) } -void CContextView::sm_CbCancel(void *data, Evas_Object *obj, void *ei) +void CContextView::sm_CbCancel(void* cookie, CPopupWindow *instance) { - CContextView *root = (CContextView *)data; + CContextView *root = (CContextView *)cookie; if (root) - root->m_OnCancel(obj); + root->m_OnCancel(instance); } -void CContextView::m_OnCancel(Evas_Object *obj) +void CContextView::m_OnCancel(CPopupWindow *instance) { - if (!obj) { + if (!instance) { _ERR("Invalid argument."); return; } @@ -1146,79 +1130,41 @@ CCtxPopup *CContextView::m_CreatePlaylistPopup(void) } -Evas_Object *CContextView::m_CreateRemovePopup(Evas_Object *base, const char *msg, - Evas_Object_Event_Cb _close_cb, Evas_Smart_Cb _remove_cb, - Evas_Smart_Cb _cancel_cb, void *dt) +CPopupWindow *CContextView::m_CreateRemovePopup(Evas_Object *base, const char *msg) { - Evas_Object *popup, *yesbtn, *nobtn, *lbl; + CRemovePopupWindow *popup; - if (!base || !_remove_cb || !_cancel_cb || !dt) { - _ERR("Invalid argument."); - return NULL; - } - - popup = elm_popup_add(base); + popup = new CRemovePopupWindow; if (!popup) { - _ERR("elm_popup_add failed."); - return NULL; - } - - elm_object_style_set(popup, MUSIC_STYLE_REMOVE_POPUP); - elm_object_part_text_set(popup, MUSIC_PART_RPOPUP_TITLE, - _(MUSIC_TEXT_REMOVE)); - elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER); - evas_object_event_callback_add(popup, EVAS_CALLBACK_KEY_DOWN, - _close_cb, dt); - evas_object_show(popup); - - lbl = elm_label_add(popup); - if (!lbl) { - _ERR("Add Evas_Object failed."); - evas_object_del(popup); - return NULL; - } - - elm_object_style_set(lbl, MUSIC_STYLE_REMOVE_LABEL); - elm_object_text_set(lbl, _(msg)); - elm_object_content_set(popup, lbl); - - yesbtn = elm_button_add(popup); - if (!yesbtn) { - _ERR("Add Evas_Object failed."); - evas_object_del(popup); + _ERR("Memory alloc failed"); return NULL; } - elm_object_text_set(yesbtn, _(MUSIC_TEXT_REMOVE)); - elm_object_part_content_set(popup, MUSIC_PART_RPOPUP_BTN1, yesbtn); - evas_object_smart_callback_add(yesbtn, MUSIC_SIGNAL_CLICKED, - _remove_cb, dt); + CPopupWindow::SCallback cb; + cb.cookie = this; + cb.onBtn1Pressed = sm_CbRemove; + cb.onBtn2Pressed = sm_CbCancel; + cb.onBtn3Pressed = NULL; - nobtn = elm_button_add(popup); - if (!nobtn) { - _ERR("Add Evas_Object failed."); - evas_object_del(popup); + if (!popup->Create(base, &cb, msg)) { + _ERR("Pop creation failed"); + delete popup; return NULL; } - elm_object_text_set(nobtn, _(MUSIC_TEXT_CANCEL)); - elm_object_part_content_set(popup, MUSIC_PART_RPOPUP_BTN2, nobtn); - evas_object_smart_callback_add(nobtn, MUSIC_SIGNAL_CLICKED, - _cancel_cb, dt); - elm_object_focus_set(nobtn, EINA_TRUE); - return popup; } void CContextView::m_DestroyPopup(void) { - if (m->popup) - evas_object_del(m->popup); + if (m->popup && m->popup->FlagCreate()) + m->popup->Destroy(); if (m->ctxpopup && m->ctxpopup->FlagCreate()) m->ctxpopup->Destroy(); + delete m->popup; m->popup = NULL; delete m->ctxpopup; m->ctxpopup = NULL; @@ -1257,9 +1203,7 @@ void CContextView::m_HandleBtnSelected(int btnType) break; case CONTEXT_VIEW_BUTTON_DEL: - m->popup = m_CreateRemovePopup(m->base, - MUSIC_TEXT_REMOVE_SMSG, sm_CbPopupKeyPressed, - sm_CbRemove, sm_CbCancel, this); + m->popup = (CRemovePopupWindow *)m_CreateRemovePopup(m->base, MUSIC_TEXT_REMOVE_SMSG); break; case CONTEXT_VIEW_BUTTON_RENAME: @@ -1275,9 +1219,7 @@ void CContextView::m_HandleBtnSelected(int btnType) break; case CONTEXT_VIEW_BUTTON_DELETE: - m->popup = m_CreateRemovePopup(m->base, - MUSIC_TEXT_REMOVE_PLMSG, sm_CbPopupKeyPressed, - sm_CbRemove, sm_CbCancel, this); + m->popup = (CRemovePopupWindow *)m_CreateRemovePopup(m->base, MUSIC_TEXT_REMOVE_PLMSG); break; default: -- 2.7.4 From 7b09c5ce303cae0d169a93df2114aa36cee955aa Mon Sep 17 00:00:00 2001 From: Kim Youngjin Date: Sat, 7 Mar 2015 14:24:06 +0900 Subject: [PATCH 02/16] refactoring Change-Id: I86d68ebb81fb6fcb3db575fdf45e83198958a4f0 Signed-off-by: Kim Youngjin --- include/common.h | 3 +- include/mediadata.h | 38 +- include/music-controller.h | 27 +- src/data/mediadata.cpp | 1033 +++++++++++++++++------------------ src/main.cpp | 5 +- src/playback/music-controller.cpp | 140 +++-- src/views/album-layout.cpp | 4 +- src/views/album-songs-layout.cpp | 6 +- src/views/artist-layout.cpp | 4 +- src/views/base-view.cpp | 5 +- src/views/category-layout.cpp | 9 +- src/views/category-songs-layout.cpp | 6 +- src/views/folder-layout.cpp | 6 +- src/views/genre-layout.cpp | 4 +- src/views/playback-view.cpp | 8 +- src/views/playlist-layout.cpp | 7 +- src/views/song-layout.cpp | 8 +- 17 files changed, 666 insertions(+), 647 deletions(-) diff --git a/include/common.h b/include/common.h index b913ab8..b6c5a14 100644 --- a/include/common.h +++ b/include/common.h @@ -135,7 +135,8 @@ enum ECategoryType { CAT_TYPE_ARTIST, CAT_TYPE_GENRE, CAT_TYPE_PLAYLISTS, - CAT_TYPE_PLAYLIST_NEW + CAT_TYPE_PLAYLIST_NEW, + CAT_TYPE_MAX, }; struct SParcel { diff --git a/include/mediadata.h b/include/mediadata.h index 9cd1289..fb0423b 100644 --- a/include/mediadata.h +++ b/include/mediadata.h @@ -17,15 +17,29 @@ #ifndef __MEDIA_DATA_H__ #define __MEDIA_DATA_H__ + struct mediadata; struct album_info; struct category_info; + #include #include "common.h" #include -class CMediadata : public CMediaContentDbUpdateListener { + +class CPlaylistMgr { +public: + virtual bool Alloc(const char *name, Eina_List *elIdList); + virtual bool Delete(int id); + virtual bool Rename(int id, const char *name); + + virtual bool Insert(int id, Eina_List *elIdList); + virtual bool Remove(int id, Eina_List *elIdList); +}; + + +class CMediadata : public CMediaContentDbUpdateListener, public CPlaylistMgr { private: struct SMediadata* m; @@ -34,15 +48,12 @@ private: static bool sm_CbEachMediaData(media_info_h md_h, void *dt); static bool sm_CbEachFolderData(media_folder_h folder_h, void *dt); static bool sm_CbEachAlbumData(media_album_h album_h, void *dt); - static bool sm_CbEachPlaylist(media_playlist_h ph, void *dt); - static bool sm_CbPlaylistMember(int memb_id, media_info_h mdh, void *dt); static bool sm_CbPlaylist(media_playlist_h ph, void *dt); private: bool m_HandleEachMediaData(media_info_h md_h); bool m_HandleEachFolderData(media_folder_h folder_h); bool m_HandleEachAlbumData(media_album_h album_h); - bool m_HandleEachPlaylist(media_playlist_h ph); void m_DeleteSongList(void); void m_DeleteFolderSongList(void); void m_DeleteAlbumSongList(void); @@ -50,9 +61,10 @@ private: void m_DeleteFolderList(void); void m_DeleteAlbumList(void); void m_DeleteCategoryList(ECategoryType type); + bool m_CreateFilter(void); - bool m_DestroyFilter(void); - int m_GetPlaylistList(void); + void m_DestroyFilter(void); + void m_GetCategoryList(ECategoryType type); int m_GetPlaylistSongList(CCategoryInfo *catinfo); int m_GetFolderSongList(CFolderInfo *finfo); @@ -70,22 +82,22 @@ public: bool Create(void); virtual void Destroy(void); + SCbInfo *AddCallback(int type, void(*cb)(void *dt), void *data); + bool RemoveCallback(SCbInfo *cbinfo); + CSongInfo *SongByUri(char *uri); Eina_List *Medialist(int source_type, int EListType, void *info); - struct SCbInfo *AddCallback(int type, void(*cb)(void *dt), void *data); - bool RemoveCallback(struct SCbInfo *cbinfo); + bool SetPlayedTime(char *media_id); - bool InsertPlaylist(const char *name, Eina_List *idlist); + bool ExistPlaylist(const char *name); - bool DeletePlaylist(int id); - bool RenamePlaylist(int id, const char *name); - bool AddmediaPlaylist(int lid, Eina_List *idlist); - bool RemovemediaPlaylist(int lid, Eina_List *idlist); static Eina_List *PlaylistsForCtxt(void); public: virtual void OnUpdated(const SEntity *entity); + }; + #endif /*__MEDIA_DATA_H__*/ diff --git a/include/music-controller.h b/include/music-controller.h index d60f6ea..0b29bd9 100644 --- a/include/music-controller.h +++ b/include/music-controller.h @@ -41,10 +41,10 @@ class CMusicController : public CUsbConnectionListener { private: static CMusicController *instance; static int refCnt; + struct SMusicController *m; private: - enum EDirectionType { DIR_PREVIOUS, DIR_NEXT @@ -54,6 +54,7 @@ private: E_ON_COMPLETE, E_BUTTON_CLICK }; + private: CMusicController() {} virtual ~CMusicController() {} @@ -85,16 +86,7 @@ public: bool SetCurrentSongIndex(int ind); bool GetTotalSongs(int *ts); bool GetSonginfoFromIndex(int index, CSongInfo **const csinfo); - - int PlayState(void); - bool SetPlayState(int state); - - int ShuffleState(void); - bool SetShuffleState(int state); - - int RepeatState(void); - bool SetRepeatState(int state); - + bool SetPosition(int milsec); bool GetPosition(int *const milseconds); @@ -122,8 +114,21 @@ public: bool MediaAddmediaPlaylist(int id, Eina_List *idlist); bool MediaRemovemediaPlaylist(int id, Eina_List *idlist); bool MediaAddsongsPlaylist(int lid, Eina_List *list); + CSongInfo *MediaSongByUri(char *uri); + bool SetPlayState(EPlayStatus state); + EPlayStatus + PlayState(void); + + bool SetShuffleState(EShuffleStatus state); + EShuffleStatus + ShuffleState(void); + + bool SetRepeatState(ERepeatStatus state); + ERepeatStatus + RepeatState(void); + public: virtual void OnConnect(void); }; diff --git a/src/data/mediadata.cpp b/src/data/mediadata.cpp index e1b1072..b943517 100644 --- a/src/data/mediadata.cpp +++ b/src/data/mediadata.cpp @@ -22,6 +22,8 @@ #include "dbg.h" #include "i18n.h" #include "define.h" + +#include #include "song_info.h" #include "album_info.h" #include "category_info.h" @@ -43,28 +45,343 @@ enum songlist_type { E_SINGLE_SONG }; + +class CStorage { +protected: + Eina_List *elList; + +public: + CStorage() { + elList = NULL; + } + virtual ~CStorage() { + + } + + void SetList(Eina_List *el) { + elList = el; + } + Eina_List *List(void) { + return elList; + } + + void Delete(void) { + if (!elList) + return; + + CCategoryInfo *catinfo = NULL; + void *obj = NULL; + + EINA_LIST_FREE(elList, obj) { + catinfo = (CCategoryInfo *)obj; + catinfo->Destroy(); + delete catinfo; + } + + elList = NULL; + } + virtual bool Update(void) = 0; +}; + + +class CArtistStorage : public CStorage { +public: + virtual bool Update(void) { + return true; + } +}; + +class CGenreStorage : public CStorage { +public: + virtual bool Update(void) { + return true; + } +}; + +class CPlaylistStorage : public CStorage { +private: + static bool sm_CbPlaylistMember(int memb_id, media_info_h mdh, void *dt) + { + CCategoryInfo *catinfo = (CCategoryInfo *)dt; + CCategoryInfo::CListMember *member = NULL; + char *id = NULL; + + if (!mdh || !catinfo) + return false; + + if (media_info_get_media_id(mdh, &id) != MEDIA_CONTENT_ERROR_NONE) { + _ERR(" Failed to get media id "); + return false; + } + + char *thumb; + if (!catinfo->ThumbnailPath()) { + if (media_info_get_thumbnail_path(mdh, &thumb) != MEDIA_CONTENT_ERROR_NONE) + _ERR("Media thumbnail path Fetch error"); + catinfo->SetThumbnailPath(thumb); + } + + member = new CCategoryInfo::CListMember; + if (!member) { + free(id); + return false; + } + + member->memberId = memb_id; + member->mediaId = id; + + catinfo->SetMember(member); + + return true; + } + + static bool sm_CbEachPlaylist(media_playlist_h ph, void *dt) + { + CPlaylistStorage *root = (CPlaylistStorage *)dt; + + if (!root) + return false; + + root->m_OnEachPlaylist(ph); + + return true; + } + bool m_OnEachPlaylist(media_playlist_h ph) + { + if (!ph) + return false; + + _CREATE_BEGIN{ + CCategoryInfo *catinfo = NULL; + char *tmpStr = NULL; + int categoryId = 0; + int songCount = 0; + _CHECK(catinfo = new CCategoryInfo) + _CHECK(catinfo->Create()) + _CHECK(media_playlist_get_name(ph, &tmpStr) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_playlist_get_playlist_id(ph, &categoryId) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_playlist_get_media_count_from_db(catinfo->CategoryId(), NULL, &songCount) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_playlist_foreach_media_from_db(catinfo->CategoryId(), NULL, + sm_CbPlaylistMember, (void *)catinfo) == MEDIA_CONTENT_ERROR_NONE) + + _WHEN_SUCCESS{ + catinfo->SetName(tmpStr); + catinfo->SetCategoryId(categoryId); + catinfo->SetSongCount(songCount); + elList = eina_list_append(elList, catinfo); + } + + _CHECK_FAIL{ /* */ } + _CHECK_FAIL{ /* */ } + _CHECK_FAIL{ /* */ } + _CHECK_FAIL{ /* */ } + _CHECK_FAIL{ catinfo->Destroy(); } + _CHECK_FAIL{ delete catinfo; catinfo = NULL; } + }_CREATE_END_AND_CATCH{ return false; } + + return true; + } + + int m_GetPlaylistList(void) + { + if (media_playlist_foreach_playlist_from_db(NULL, sm_CbEachPlaylist, this)) { + _ERR(" Get each playlist failed "); + return false; + } + + return true; + } + +public: + virtual bool Update(void) { + Delete(); + m_GetPlaylistList(); + return true; + } +}; + + struct SMediadata { Eina_List *songlist; Eina_List *folderlist; Eina_List *folder_songlist; Eina_List *albumlist; Eina_List *album_songlist; - Eina_List *playlistslist; + + //Eina_List *categoryList[CAT_TYPE_MAX]; + + CPlaylistStorage *storagePlaylist; + CArtistStorage *storageArtist; + CGenreStorage *storageGenre; + Eina_List *playlist_songlist; - Eina_List *artistlist; - Eina_List *genrelist; Eina_List *cblist; - CSongInfo *sinfo; + CSongInfo *songInfo; filter_h filter; int source_type; int slist_type; int member_id; SMediadata() { memset(this, 0, sizeof(SMediadata)); + + storagePlaylist = new CPlaylistStorage; + storageArtist = new CArtistStorage; + storageGenre = new CGenreStorage; + } + ~SMediadata() { + delete storageGenre; + delete storageArtist; + delete storagePlaylist; } }; + + +bool CPlaylistMgr::Alloc(const char *name, Eina_List *elIdList) +{ + ASSERT(name); + ASSERT(elIdList); + + bool ret = false; + media_playlist_h ph; + if (media_playlist_insert_to_db(name, &ph) == MEDIA_CONTENT_ERROR_NONE) { + Eina_List *l; + void *obj; + EINA_LIST_FOREACH(elIdList, l, obj) { + char *id = (char *)obj; + media_playlist_add_media(ph, id); + } + + if (media_playlist_update_to_db(ph) == MEDIA_CONTENT_ERROR_NONE) { + ret = true; + } + else { + _ERR("CPlaylist::Insert failed./media_plyalist_update_to_db"); + } + } + else { + _ERR("CPlaylist::Insert failed./media_playlist_insert_to_db"); + } + + return ret; +} + + +bool CPlaylistMgr::Delete(int id) +{ + bool ret = true; + + if (media_playlist_delete_from_db(id) != MEDIA_CONTENT_ERROR_NONE) { + _ERR(" Failed to delete playlist"); + ret = false; + } + + return ret; +} + + +bool CPlaylistMgr::Rename(int id, const char *name) +{ + ASSERT(name); + + bool ret = false; + int r; + + media_playlist_h ph; + + r = media_playlist_get_playlist_from_db(id, &ph); + if (r == MEDIA_CONTENT_ERROR_NONE) { + r = media_playlist_set_name(ph, name); + if (r == MEDIA_CONTENT_ERROR_NONE) { + r = media_playlist_update_to_db(ph); + if (r == MEDIA_CONTENT_ERROR_NONE) { + ret = true; + } + else { + _ERR("[CPlaylist::Rename] Failed to update to db"); + } + } + else { + _ERR("[CPlaylist::Rename] Failed to set playlist name"); + } + } else { + _ERR("[CPlaylist::Rename] Failed to get playlist"); + } + + return ret; +} + + +bool CPlaylistMgr::Insert(int plid, Eina_List *elIdList) +{ + ASSERT(elIdList); + + bool ret = false; + int r; + + media_playlist_h ph; + r = media_playlist_get_playlist_from_db(plid, &ph); + if (r == MEDIA_CONTENT_ERROR_NONE) { + Eina_List *l; + void *obj; + EINA_LIST_FOREACH(elIdList, l, obj) { + char *id = (char *)obj; + media_playlist_add_media(ph, id); + } + + r = media_playlist_update_to_db(ph); + if (r == MEDIA_CONTENT_ERROR_NONE) { + ret = true; + } + else { + _ERR("[CPlaylistMgr::Remove] Failed to update to db"); + } + } + else { + _ERR(" Failed to get playlist"); + } + + return ret; +} + + +bool CPlaylistMgr::Remove(int plid, Eina_List *elIdList) +{ + ASSERT(elIdList && "Invalid argument"); + + bool ret = false; + int r; + + media_playlist_h ph; + r = media_playlist_get_playlist_from_db(plid, &ph); + if (r == MEDIA_CONTENT_ERROR_NONE) { + Eina_List *l; + CSongInfo *songInfo; + void *obj; + EINA_LIST_FOREACH(elIdList, l, obj) { + songInfo = (CSongInfo *)obj; + int id = songInfo->MemberId(); + if (id) + media_playlist_remove_media(ph, id); + } + + r = media_playlist_update_to_db(ph); + if (r == MEDIA_CONTENT_ERROR_NONE) { + ret = true; + } + else { + _ERR("[CPlaylistMgr::Remove] Failed to update playlist to db"); + } + } + else { + _ERR(" Failed to get playlist"); + } + + return ret; +} + + bool CMediadata::sm_CbTotalDuration(media_info_h md_h, void *dt) { audio_meta_h audio_h; @@ -130,54 +447,6 @@ bool CMediadata::sm_CbEachAlbumData(media_album_h album_h, void *dt) } -bool CMediadata::sm_CbEachPlaylist(media_playlist_h ph, void *dt) -{ - CMediadata *root = (CMediadata *)dt; - - if (!root) - return false; - - root->m_HandleEachPlaylist(ph); - - return true; -} - - -bool CMediadata::sm_CbPlaylistMember(int memb_id, media_info_h mdh, void *dt) -{ - CCategoryInfo *catinfo = (CCategoryInfo *)dt; - CCategoryInfo::CListMember *member = NULL; - char *id = NULL; - - if (!mdh || !catinfo) - return false; - - if (media_info_get_media_id(mdh, &id) != MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to get media id "); - return false; - } - - char *thumb; - if (!catinfo->ThumbnailPath()) { - if (media_info_get_thumbnail_path(mdh, &thumb) != MEDIA_CONTENT_ERROR_NONE) - _ERR("Media thumbnail path Fetch error"); - catinfo->SetThumbnailPath(thumb); - } - - member = new CCategoryInfo::CListMember; - if (!member) { - free(id); - return false; - } - - member->memberId = memb_id; - member->mediaId = id; - - catinfo->SetMember(member); - - return true; -} - bool CMediadata::sm_CbPlaylist(media_playlist_h ph, void* dt) { @@ -214,50 +483,50 @@ bool CMediadata::sm_CbPlaylist(media_playlist_h ph, void* dt) bool CMediadata::m_HandleEachMediaData(media_info_h md_h) { - CSongInfo *sinfo = NULL; + CSongInfo *songInfo = NULL; audio_meta_h audio_h = NULL; char* tmpStr = NULL; int tmpValue; bool ret; - sinfo = new CSongInfo; - if (!sinfo) { + songInfo = new CSongInfo; + if (!songInfo) { _ERR("Memory alloc failed"); return false; } - ret = sinfo->Create(); + ret = songInfo->Create(); if (!ret) { _ERR("CSongInfo creation failed"); - delete sinfo; + delete songInfo; return false; } if (media_info_get_file_path(md_h, &tmpStr) != MEDIA_CONTENT_ERROR_NONE) { _ERR("Media file path Fetch error"); - sinfo->Destroy(); - delete sinfo; + songInfo->Destroy(); + delete songInfo; return false; } - sinfo->SetPath(tmpStr); + songInfo->SetPath(tmpStr); if (media_info_get_thumbnail_path(md_h, &tmpStr) != MEDIA_CONTENT_ERROR_NONE) _ERR("Media thumbnail path Fetch error"); - sinfo->SetThumbnailPath(tmpStr); + songInfo->SetThumbnailPath(tmpStr); if (media_info_get_media_type(md_h, (media_content_type_e *)&tmpValue) != MEDIA_CONTENT_ERROR_NONE) _ERR("Media type Fetch error"); - sinfo->SetType(tmpValue); + songInfo->SetType(tmpValue); if (media_info_get_audio(md_h, &audio_h) != MEDIA_CONTENT_ERROR_NONE) { _ERR("Media info get audio error"); - sinfo->Destroy(); - delete sinfo; + songInfo->Destroy(); + delete songInfo; return false; } @@ -265,68 +534,68 @@ bool CMediadata::m_HandleEachMediaData(media_info_h md_h) MEDIA_CONTENT_ERROR_NONE) { _ERR("Media ID Fetch error"); audio_meta_destroy(audio_h); - sinfo->Destroy(); - delete sinfo; + songInfo->Destroy(); + delete songInfo; return false; } - sinfo->SetId(tmpStr); + songInfo->SetId(tmpStr); if (media_info_get_title(md_h, &tmpStr) != MEDIA_CONTENT_ERROR_NONE) _ERR("audio title get error"); - sinfo->SetName(tmpStr); + songInfo->SetName(tmpStr); if (audio_meta_get_artist(audio_h, &tmpStr) != MEDIA_CONTENT_ERROR_NONE) _ERR("audio artist get error"); - sinfo->SetArtist(tmpStr); + songInfo->SetArtist(tmpStr); if (audio_meta_get_album(audio_h, &tmpStr) != MEDIA_CONTENT_ERROR_NONE) _ERR("audio album get error"); - sinfo->SetAlbum(tmpStr); + songInfo->SetAlbum(tmpStr); if (audio_meta_get_genre(audio_h, &tmpStr) != MEDIA_CONTENT_ERROR_NONE) _ERR("audio genre get error"); - sinfo->SetGenre(tmpStr); + songInfo->SetGenre(tmpStr); if (audio_meta_get_composer(audio_h, &tmpStr) != MEDIA_CONTENT_ERROR_NONE) _ERR("audio composer get error"); - sinfo->SetComposer(tmpStr); + songInfo->SetComposer(tmpStr); if (audio_meta_get_duration(audio_h, &tmpValue) != MEDIA_CONTENT_ERROR_NONE) _ERR("audio duration get error"); - sinfo->SetDuration(tmpValue); + songInfo->SetDuration(tmpValue); audio_meta_destroy(audio_h); switch (m->slist_type) { case E_FOLDER_SONGS: m->folder_songlist = eina_list_append( - m->folder_songlist, sinfo); + m->folder_songlist, songInfo); break; case E_ALBUM_SONGS: m->album_songlist = eina_list_append( - m->album_songlist, sinfo); + m->album_songlist, songInfo); break; case E_PLAYLIST_SONGS: - sinfo->SetMemberId(m->member_id); + songInfo->SetMemberId(m->member_id); m->playlist_songlist = eina_list_append( - m->playlist_songlist, sinfo); + m->playlist_songlist, songInfo); break; case E_SINGLE_SONG: - m->sinfo = sinfo; + m->songInfo = songInfo; break; case E_ALL_SONGS: default: - m->songlist = eina_list_append(m->songlist, sinfo); + m->songlist = eina_list_append(m->songlist, songInfo); break; } return true; @@ -399,7 +668,7 @@ bool CMediadata::m_HandleEachFolderData(media_folder_h folder_h) bool CMediadata::m_HandleEachAlbumData(media_album_h album_h) { CAlbumInfo *alinfo = NULL; - CSongInfo *sinfo = NULL; + CSongInfo *songInfo = NULL; void *obj = NULL; char *tmpStr = NULL; int tmpValue; @@ -460,8 +729,8 @@ bool CMediadata::m_HandleEachAlbumData(media_album_h album_h) m_GetAlbumSongList(alinfo); EINA_LIST_FOREACH(m->album_songlist, l, obj) { - sinfo = (CSongInfo *)obj; - tmpStr = sinfo->Genre(); + songInfo = (CSongInfo *)obj; + tmpStr = songInfo->Genre(); if (tmpStr) { alinfo->SetGenre(tmpStr); break; @@ -469,8 +738,8 @@ bool CMediadata::m_HandleEachAlbumData(media_album_h album_h) } EINA_LIST_FOREACH(m->album_songlist, l, obj) { - sinfo = (CSongInfo *)obj; - tmpStr = sinfo->ThumbnailPath(); + songInfo = (CSongInfo *)obj; + tmpStr = songInfo->ThumbnailPath(); if (tmpStr) { alinfo->SetThumbnailPath(tmpStr); break; @@ -481,81 +750,18 @@ bool CMediadata::m_HandleEachAlbumData(media_album_h album_h) return true; } - -bool CMediadata::m_HandleEachPlaylist(media_playlist_h ph) -{ - CCategoryInfo *catinfo = NULL; - char *tmpStr; - int tmpValue; - bool ret; - - if (!ph) - return false; - - catinfo = new CCategoryInfo; - if (!catinfo) { - _ERR("Memory alloc failed"); - return false; - } - - ret = catinfo->Create(); - if (!ret) { - _ERR("CCategoryInfo Create failed"); - delete catinfo; - return false; - } - - if (media_playlist_get_name(ph, &tmpStr) != - MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to read playlist name "); - catinfo->Destroy(); - delete catinfo; - return false; - } - catinfo->SetName(tmpStr); - - if (media_playlist_get_playlist_id(ph, &tmpValue) != - MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to read playlist name "); - catinfo->Destroy(); - delete catinfo; - return false; - } - catinfo->SetCategoryId(tmpValue); - - if (media_playlist_get_media_count_from_db(catinfo->CategoryId(), NULL, - &tmpValue) != MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to read playlist name "); - catinfo->Destroy(); - delete catinfo; - return false; - } - catinfo->SetSongCount(tmpValue); - - if (media_playlist_foreach_media_from_db(catinfo->CategoryId(), NULL, - sm_CbPlaylistMember, (void *)catinfo) != - MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to read playlist members "); - catinfo->Destroy(); - delete catinfo; - return false; - } - - m->playlistslist = eina_list_append(m->playlistslist, catinfo); - - return true; -} - - void CMediadata::m_DeleteSongList(void) { - CSongInfo *sinfo = NULL; + if (!m->songlist) + return; + + CSongInfo *songInfo = NULL; void *obj = NULL; EINA_LIST_FREE(m->songlist, obj) { - sinfo = (CSongInfo *)obj; - sinfo->Destroy(); - delete sinfo; + songInfo = (CSongInfo *)obj; + songInfo->Destroy(); + delete songInfo; } m->songlist = NULL; @@ -564,13 +770,16 @@ void CMediadata::m_DeleteSongList(void) void CMediadata::m_DeleteFolderSongList(void) { - CSongInfo *sinfo = NULL; + CSongInfo *songInfo = NULL; void *obj = NULL; + if (!m->folder_songlist) + return; + EINA_LIST_FREE(m->folder_songlist, obj) { - sinfo = (CSongInfo *)obj; - sinfo->Destroy(); - delete sinfo; + songInfo = (CSongInfo *)obj; + songInfo->Destroy(); + delete songInfo; } m->folder_songlist = NULL; @@ -579,13 +788,15 @@ void CMediadata::m_DeleteFolderSongList(void) void CMediadata::m_DeleteAlbumSongList(void) { - CSongInfo *sinfo = NULL; + CSongInfo *songInfo = NULL; void *obj = NULL; + if (!m->album_songlist) + return; EINA_LIST_FREE(m->album_songlist, obj) { - sinfo = (CSongInfo *)obj; - sinfo->Destroy(); - delete sinfo; + songInfo = (CSongInfo *)obj; + songInfo->Destroy(); + delete songInfo; } m->album_songlist = NULL; @@ -594,13 +805,16 @@ void CMediadata::m_DeleteAlbumSongList(void) void CMediadata::m_DeletePlaylistSongList(void) { - CSongInfo *sinfo = NULL; + CSongInfo *songInfo = NULL; void *obj = NULL; + if (!m->playlist_songlist) + return; + EINA_LIST_FREE(m->playlist_songlist, obj) { - sinfo = (CSongInfo *)obj; - sinfo->Destroy(); - delete sinfo; + songInfo = (CSongInfo *)obj; + songInfo->Destroy(); + delete songInfo; } m->playlist_songlist = NULL; @@ -611,6 +825,8 @@ void CMediadata::m_DeleteFolderList(void) { CFolderInfo *finfo = NULL; void *obj = NULL; + if (!m->folderlist) + return; EINA_LIST_FREE(m->folderlist, obj) { finfo = (CFolderInfo *)obj; @@ -624,6 +840,8 @@ void CMediadata::m_DeleteFolderList(void) void CMediadata::m_DeleteAlbumList(void) { + if (!m->albumlist) + return; CAlbumInfo *alinfo = NULL; void *obj = NULL; @@ -643,31 +861,13 @@ void CMediadata::m_DeleteCategoryList(ECategoryType type) void *obj = NULL; if (type == CAT_TYPE_ARTIST) { - EINA_LIST_FREE(m->artistlist, obj) { - catinfo = (CCategoryInfo *)obj; - catinfo->Destroy(); - delete catinfo; - } - - m->artistlist = NULL; + m->storageArtist->Delete(); } else if (type == CAT_TYPE_GENRE) { - EINA_LIST_FREE(m->genrelist, obj) { - catinfo = (CCategoryInfo *)obj; - catinfo->Destroy(); - delete catinfo; - } - - m->genrelist = NULL; + m->storageGenre->Delete(); } else if (type == CAT_TYPE_PLAYLISTS) { - EINA_LIST_FREE(m->playlistslist, obj) { - catinfo = (CCategoryInfo *)obj; - catinfo->Destroy(); - delete catinfo; - } - - m->playlistslist = NULL; + m->storagePlaylist->Delete(); } } @@ -677,7 +877,7 @@ bool CMediadata::m_CreateFilter(void) char buf[MAX_LENGTH]; int ret; - ret = media_filter_create(&(m->filter)); + ret = media_filter_create(&m->filter); if (ret != MEDIA_CONTENT_ERROR_NONE) { _ERR("Media Filter Creation Failed"); return false; @@ -707,29 +907,15 @@ bool CMediadata::m_CreateFilter(void) } -bool CMediadata::m_DestroyFilter(void) +void CMediadata::m_DestroyFilter(void) { if (media_filter_destroy(m->filter) != MEDIA_CONTENT_ERROR_NONE) { _ERR("Filter destroy failed"); - m->filter = NULL; - return false; } m->filter = NULL; - - return true; } -int CMediadata::m_GetPlaylistList(void) -{ - if (media_playlist_foreach_playlist_from_db(NULL, sm_CbEachPlaylist, this)) { - _ERR(" Get each playlist failed "); - return false; - } - - return true; -} - void CMediadata::m_GetCategoryList(ECategoryType type) { @@ -743,16 +929,28 @@ void CMediadata::m_GetCategoryList(ECategoryType type) if (!m->albumlist) return; + CStorage *stg = NULL; + if (type == CAT_TYPE_ARTIST) + stg = m->storageArtist; + else + stg = m->storageGenre; + char *str; + count = 0; EINA_LIST_FOREACH(m->albumlist, l, obj) { alinfo = (CAlbumInfo *)obj; - if (type == CAT_TYPE_ARTIST) - catinfo = CCategoryInfo::FindCategory(m->artistlist, alinfo->Artist()); - else - catinfo = CCategoryInfo::FindCategory(m->genrelist, alinfo->Genre()); + if (type == CAT_TYPE_ARTIST) { + str = alinfo->Artist(); + } + else { + str = alinfo->Genre(); + } + catinfo = CCategoryInfo::FindCategory(stg->List(), str); if (!catinfo) { catinfo = new CCategoryInfo(); + if (!catinfo) + continue; ret = catinfo->Create(); if (!ret) { @@ -763,24 +961,11 @@ void CMediadata::m_GetCategoryList(ECategoryType type) catinfo->SetCategoryId(++count); catinfo->SetAlbumCount(1); catinfo->SetSongCount(alinfo->SongCount()); - if (type == CAT_TYPE_ARTIST) { - if (alinfo->Artist()) - catinfo->SetName(alinfo->Artist()); - else - catinfo->SetName(_(MUSIC_STR_UNKNOWN)); - - m->artistlist = eina_list_append( - m->artistlist, catinfo); - } - else { - if (alinfo->Genre()) - catinfo->SetName(alinfo->Genre()); - else - catinfo->SetName(_(MUSIC_STR_UNKNOWN)); - - m->genrelist = eina_list_append( - m->genrelist, catinfo); - } + if (str) + catinfo->SetName(str); + else + catinfo->SetName(_(MUSIC_STR_UNKNOWN)); + stg->SetList(eina_list_append(stg->List(), catinfo)); } else { catinfo->SetAlbumCount(catinfo->AlbumCount() + 1); @@ -921,55 +1106,41 @@ void CMediadata::m_UpdateLists(void) return; } - if (m->songlist) - m_DeleteSongList(); + m_DeleteSongList(); m_GetSongList(); - if (m->albumlist) - m_DeleteAlbumList(); + m_DeleteAlbumList(); m_GetAlbumList(); - if (m->artistlist) - m_DeleteCategoryList(CAT_TYPE_ARTIST); + m_DeleteCategoryList(CAT_TYPE_ARTIST); m_GetCategoryList(CAT_TYPE_ARTIST); - if (m->genrelist) - m_DeleteCategoryList(CAT_TYPE_GENRE); + m_DeleteCategoryList(CAT_TYPE_GENRE); m_GetCategoryList(CAT_TYPE_GENRE); - if (m->folderlist) - m_DeleteFolderList(); + m_DeleteFolderList(); m_GetFolderList(); - r = m_DestroyFilter(); - if (r == false) - _ERR("Media Filter Creation Failed"); + m_DestroyFilter(); } bool CMediadata::Create(void) { - if (m) - return false; - - m = new SMediadata; - if (!m) { - _ERR("m calloc failed"); - return false; - } - - int r; - r = media_content_connect(); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Media Content Connect Failed"); - delete m; - m = NULL; - return false; - } - - CMediaContentDbUpdateListener::Create(); + ASSERT(!FlagCreate()); + + _CREATE_BEGIN{ + _CHECK(m = new SMediadata) + _CHECK(media_content_connect()) + _CHECK(CMediaContentDbUpdateListener::Create()) + _WHEN_SUCCESS{ + m->source_type = SOURCE_TYPE_NONE; + } - m->source_type = SOURCE_TYPE_NONE; + _CHECK_FAIL{ CMediaContentDbUpdateListener::Destroy(); } + _CHECK_FAIL{ media_content_disconnect(); } + _CHECK_FAIL{ delete m; m = NULL; } + }_CREATE_END_AND_CATCH{ return false; } return true; } @@ -977,8 +1148,7 @@ bool CMediadata::Create(void) void CMediadata::Destroy(void) { - if (!m) - return; + ASSERT(FlagCreate()); int r; struct SCbInfo *cbinfo; @@ -993,9 +1163,9 @@ void CMediadata::Destroy(void) m_DeleteCategoryList(CAT_TYPE_GENRE); m_DeleteCategoryList(CAT_TYPE_PLAYLISTS); m_DeletePlaylistSongList(); - if (m->sinfo && m->sinfo->FlagCreate()) - m->sinfo->Destroy(); - delete m->sinfo; + if (m->songInfo && m->songInfo->FlagCreate()) + m->songInfo->Destroy(); + delete m->songInfo; EINA_LIST_FREE(m->cblist, obj) { cbinfo = (SCbInfo *)obj; @@ -1009,18 +1179,17 @@ void CMediadata::Destroy(void) _ERR("Media Content Connect Failed"); delete m; + m = NULL; } -struct SCbInfo *CMediadata::AddCallback(int type, +SCbInfo *CMediadata::AddCallback(int type, void (*cb)(void *), void *data) { - struct SCbInfo *cbinfo; - - if (!m || !cb) - return NULL; + ASSERT(FlagCreate()); + ASSERT(cb); - cbinfo = (SCbInfo *)calloc(1, sizeof(*cbinfo)); + SCbInfo *cbinfo = new SCbInfo; if (!cbinfo) return NULL; @@ -1036,32 +1205,72 @@ struct SCbInfo *CMediadata::AddCallback(int type, bool CMediadata::RemoveCallback(struct SCbInfo *cbinfo) { - if (!m) - return false; + ASSERT(FlagCreate()); if (!cbinfo) return false; - m->cblist = eina_list_remove(m->cblist, - cbinfo); - free(cbinfo); + m->cblist = eina_list_remove(m->cblist, cbinfo); + delete cbinfo; return true; } - -Eina_List *CMediadata::Medialist(int source_type, int EListType, void *info) +CSongInfo *CMediadata::SongByUri(char *uri) { - if (!m) + ASSERT(FlagCreate()); + + filter_h filter; + char buf[MAX_LENGTH]; + int r; + + if (!uri) return NULL; + if (m->songInfo && m->songInfo->FlagCreate()) { + m->songInfo->Destroy(); + } + + delete m->songInfo; + m->songInfo = NULL; + + r = media_filter_create(&filter); + if (r != MEDIA_CONTENT_ERROR_NONE) { + _ERR("Media Filter Creation Failed"); + return NULL; + } + + snprintf(buf, sizeof(buf), "%s AND (MEDIA_PATH LIKE '%s%%')", + MEDIA_CONDITION_MUSIC, + uri); + + media_filter_set_condition(filter, buf, + MEDIA_CONTENT_COLLATE_DEFAULT); + + m->slist_type = E_SINGLE_SONG; + r = media_info_foreach_media_from_db(filter, sm_CbEachMediaData, + (void *)this); + if (r != MEDIA_CONTENT_ERROR_NONE) + _ERR("Failed to fetch media info"); + + if (media_filter_destroy(filter) != MEDIA_CONTENT_ERROR_NONE) + _ERR("Filter destroy failed"); + + return m->songInfo; +} + + +Eina_List *CMediadata::Medialist(int source_type, int listType, void *info) +{ + ASSERT(FlagCreate()); + if (source_type != m->source_type) { m->source_type = source_type; m_UpdateLists(); } - switch (EListType) { + switch (listType) { case LIST_TYPE_SONG: return m->songlist; @@ -1069,8 +1278,7 @@ Eina_List *CMediadata::Medialist(int source_type, int EListType, void *info) return m->albumlist; case LIST_TYPE_ALBUM_SONG: - if (m->album_songlist) - m_DeleteAlbumSongList(); + m_DeleteAlbumSongList(); m_GetAlbumSongList((CAlbumInfo *)info); return m->album_songlist; @@ -1078,26 +1286,22 @@ Eina_List *CMediadata::Medialist(int source_type, int EListType, void *info) return m->folderlist; case LIST_TYPE_FOLDER_SONG: - if (m->folder_songlist) - m_DeleteFolderSongList(); + m_DeleteFolderSongList(); m_GetFolderSongList((CFolderInfo *)info); return m->folder_songlist; case LIST_TYPE_ARTIST: - return m->artistlist; + return m->storageArtist->List(); case LIST_TYPE_GENRE: - return m->genrelist; + return m->storageGenre->List(); case LIST_TYPE_PLAYLISTS: - if (m->playlistslist) - m_DeleteCategoryList(CAT_TYPE_PLAYLISTS); - m_GetPlaylistList(); - return m->playlistslist; + m->storagePlaylist->Update(); + return m->storagePlaylist->List(); case LIST_TYPE_PLAYLISTS_SONG: - if (m->playlist_songlist) - m_DeletePlaylistSongList(); + m_DeletePlaylistSongList(); m_GetPlaylistSongList((CCategoryInfo *)info); return m->playlist_songlist; @@ -1109,96 +1313,28 @@ Eina_List *CMediadata::Medialist(int source_type, int EListType, void *info) return NULL; } -CSongInfo *CMediadata::SongByUri(char *uri) -{ - if (!m) - return NULL; - - filter_h filter; - char buf[MAX_LENGTH]; - int r; - - if (!uri) - return NULL; - - if (m->sinfo && m->sinfo->FlagCreate()) { - m->sinfo->Destroy(); - } - - delete m->sinfo; - m->sinfo = NULL; - - r = media_filter_create(&filter); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Media Filter Creation Failed"); - return NULL; - } - - snprintf(buf, sizeof(buf), "%s AND (MEDIA_PATH LIKE '%s%%')", - MEDIA_CONDITION_MUSIC, - uri); - - media_filter_set_condition(filter, buf, - MEDIA_CONTENT_COLLATE_DEFAULT); - - m->slist_type = E_SINGLE_SONG; - r = media_info_foreach_media_from_db(filter, sm_CbEachMediaData, - (void *)this); - if (r != MEDIA_CONTENT_ERROR_NONE) - _ERR("Failed to fetch media info"); - - if (media_filter_destroy(filter) != MEDIA_CONTENT_ERROR_NONE) - _ERR("Filter destroy failed"); - - return m->sinfo; -} - bool CMediadata::SetPlayedTime(char *media_id) { - if (!m) - return false; + ASSERT(FlagCreate()); + ASSERT(media_id && "Invalid Parameter"); - media_info_h mdh; - audio_meta_h adh; + media_info_h mdh = 0; + audio_meta_h adh = 0; time_t ptime; - int r; - if (!media_id) { - _ERR("Invalid parameter"); - return false; - } + _CREATE_BEGIN{ + _CHECK(media_info_get_media_from_db(media_id, &mdh) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_info_get_audio(mdh, &adh) == MEDIA_CONTENT_ERROR_NONE) + _COMMAND{ ptime = time(NULL); } + _CHECK(audio_meta_set_played_time(adh, ptime) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(audio_meta_update_to_db(adh) == MEDIA_CONTENT_ERROR_NONE) - r = media_info_get_media_from_db(media_id, &mdh); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Failed to get media from id"); - return false; - } - - r = media_info_get_audio(mdh, &adh); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Failed to get audio from media"); - media_info_destroy(mdh); - return false; - } - - ptime = time(NULL); - - r = audio_meta_set_played_time(adh, ptime); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Failed to set played time"); - audio_meta_destroy(adh); - media_info_destroy(mdh); - return false; - } - - r = audio_meta_update_to_db(adh); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Failed to update to db"); - audio_meta_destroy(adh); - media_info_destroy(mdh); - return false; - } + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{ audio_meta_destroy(adh); } + _CHECK_FAIL{ media_info_destroy(mdh); } + }_CREATE_END_AND_CATCH{ return false; } audio_meta_destroy(adh); media_info_destroy(mdh); @@ -1207,53 +1343,18 @@ bool CMediadata::SetPlayedTime(char *media_id) } -bool CMediadata::InsertPlaylist(const char *name, Eina_List *idlist) -{ - if (!m) - return false; - - media_playlist_h ph; - int r; - Eina_List *l; - char *id = NULL; - void *obj; - - if (!name) - return false; - - r = media_playlist_insert_to_db(name, &ph); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to insert "); - return false; - } - - EINA_LIST_FOREACH(idlist, l, obj) { - id = (char *)obj; - media_playlist_add_media(ph, id); - } - - media_playlist_update_to_db(ph); - - return true; -} - - bool CMediadata::ExistPlaylist(const char *name) { - if (!m) - return false; + ASSERT(FlagCreate()); Eina_List *l; CCategoryInfo *catinfo; void *obj; - if (!name) + if (!name || !m->storagePlaylist->List()) return false; - if (!m->playlistslist) - return false; - - EINA_LIST_FOREACH(m->playlistslist, l, obj) { + EINA_LIST_FOREACH(m->storagePlaylist->List(), l, obj) { catinfo = (CCategoryInfo *)obj; if (catinfo->Name() && !strcmp(catinfo->Name(), name)) return true; @@ -1263,116 +1364,6 @@ bool CMediadata::ExistPlaylist(const char *name) } -bool CMediadata::DeletePlaylist(int id) -{ - if (!m) - return false; - - int r; - - r = media_playlist_delete_from_db(id); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to delete playlist"); - return false; - } - - return true; -} - - -bool CMediadata::RenamePlaylist(int id, const char *name) -{ - if (!m) - return false; - - int r; - media_playlist_h ph; - - r = media_playlist_get_playlist_from_db(id, &ph); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to get playlist"); - return false; - } - - r = media_playlist_set_name(ph, name); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to set playlist name"); - return false; - } - - media_playlist_update_to_db(ph); - - return true; -} - - -bool CMediadata::AddmediaPlaylist(int lid, Eina_List *idlist) -{ - if (!m) - return false; - - media_playlist_h ph; - int r; - Eina_List *l; - char *id; - void *obj; - - if (!idlist) - return false; - - r = media_playlist_get_playlist_from_db(lid, &ph); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to get playlist"); - return false; - } - - EINA_LIST_FOREACH(idlist, l, obj) { - id = (char *)obj; - media_playlist_add_media(ph, id); - } - - media_playlist_update_to_db(ph); - - return true; -} - - -bool CMediadata::RemovemediaPlaylist(int lid, Eina_List *idlist) -{ - if (!m) - return false; - - media_playlist_h ph; - int r; - Eina_List *l; - CSongInfo *sinfo; - void *obj; - int id; - - if (!idlist) { - _ERR(" Invalid argument "); - return false; - } - - r = media_playlist_get_playlist_from_db(lid, &ph); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to get playlist"); - return false; - } - - EINA_LIST_FOREACH(idlist, l, obj) { - sinfo = (CSongInfo *)obj; - id = sinfo->MemberId(); - if (id) - media_playlist_remove_media(ph, id); - } - - media_playlist_update_to_db(ph); - - return true; -} - - Eina_List *CMediadata::PlaylistsForCtxt(void) { Eina_List *list; diff --git a/src/main.cpp b/src/main.cpp index 918efb4..ce0f967 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,12 +17,15 @@ #include #include #include "dbg.h" + + #include #include #include "song_info.h" #include "album_info.h" -#include "music-controller.h" #include "define.h" +#include "common.h" +#include "music-controller.h" #include "BaseApp.h" #include "BaseView.h" #include "BaseLayout.h" diff --git a/src/playback/music-controller.cpp b/src/playback/music-controller.cpp index 781da57..e831a34 100644 --- a/src/playback/music-controller.cpp +++ b/src/playback/music-controller.cpp @@ -15,19 +15,21 @@ */ #include #include -#include #include #include "dbg.h" #include "i18n.h" + +#include + #include "song_info.h" #include "album_info.h" #include "folder_info.h" +#include "common.h" #include "category_info.h" #include "music-controller.h" #include "playlist-mgr.h" #include "playback-mgr.h" #include "mediadata.h" -#include "common.h" #include "bus.h" #include "Info.h" @@ -39,9 +41,11 @@ struct SMusicController { CAlbumInfo *alinfo; Eina_List *elListener; int initial_index; - int playstate; - int shufflestate; - int repeatstate; + + EPlayStatus statePlay; + EShuffleStatus stateShuffle; + + ERepeatStatus repeatstate; struct SCbInfo *cbinfo; SMusicController() { @@ -58,6 +62,10 @@ struct SMusicController { }; +CMusicController *CMusicController::instance = NULL; +int CMusicController::refCnt = 0; + + void IMusicControllerListener::sm_CbComplete(void *cookie) { IMusicControllerListener *root = (IMusicControllerListener *)cookie; @@ -90,20 +98,16 @@ void IMusicControllerListener::sm_CbUpdateContent(void *cookie) } -CMusicController *CMusicController::instance = NULL; -int CMusicController::refCnt = 0; - - -static void _run_callback(SMusicController *mhandle, int type) +static void _run_callback(SMusicController *m, int type) { Eina_List *l; struct SCbInfo *cbinfo; void *obj; - if (!mhandle) + if (!m) return; - EINA_LIST_FOREACH(mhandle->elListener, l, obj) { + EINA_LIST_FOREACH(m->elListener, l, obj) { cbinfo = (SCbInfo *)obj; if (cbinfo->type == type && cbinfo->cb) cbinfo->cb(cbinfo->data); @@ -126,9 +130,9 @@ bool CMusicController::t_PlayNext(int direction, int playnext_type) goto finish; if (direction == DIR_NEXT) { - r = m->pPlaylist->LoadNextSong(m->shufflestate); + r = m->pPlaylist->LoadNextSong(m->stateShuffle); } else { - r = m->pPlaylist->LoadPreviousSong(m->shufflestate); + r = m->pPlaylist->LoadPreviousSong(m->stateShuffle); } if (r == false) { @@ -210,8 +214,8 @@ SMusicController *CMusicController::t_Create(void) return NULL; } - mhandle->playstate = PLAY_STATUS_INITIAL; - mhandle->shufflestate = SHUFFLE_STATUS_OFF; + mhandle->statePlay = PLAY_STATUS_INITIAL; + mhandle->stateShuffle = SHUFFLE_STATUS_OFF; mhandle->repeatstate = REPEAT_STATUS_ALL; mhandle->initial_index = 0; CInfo::SetSortType(E_SORT_TITLE_A_Z); @@ -256,6 +260,9 @@ bool CMusicController::Initialize(void) { if (refCnt == 0) { instance = new CMusicController; + if (instance == NULL) { + return false; + } instance->m = instance->t_Create(); if (!instance->m) { _ERR("music_init failed"); @@ -412,7 +419,7 @@ bool CMusicController::Start(void) goto playback_error; } - m->playstate = PLAY_STATUS_PLAY; + m->statePlay = PLAY_STATUS_PLAY; if (m->pPlaylist->GetSonginfoFromIndex(index, &sinfo)) { media_id = sinfo->Id(); @@ -446,7 +453,7 @@ bool CMusicController::Stop(void) if (!m->pPlayback->Stop()) _ERR(" playback stop failed "); - m->playstate = PLAY_STATUS_STOP; + m->statePlay = PLAY_STATUS_STOP; if (!m->pPlayback->Unprepare()) _ERR(" playback unprepare failed"); @@ -583,7 +590,7 @@ bool CMusicController::Resume(void) if (!m->pPlayback->Resume()) return false; - m->playstate = PLAY_STATUS_PLAY; + m->statePlay = PLAY_STATUS_PLAY; return true; } @@ -600,7 +607,7 @@ bool CMusicController::Pause(void) if (!m->pPlayback->Pause()) return false; - m->playstate = PLAY_STATUS_PAUSE; + m->statePlay = PLAY_STATUS_PAUSE; return true; } @@ -651,7 +658,7 @@ bool CMusicController::RemoveSong(CSongInfo *sinfo, int index) return false; } - if (!m->pPlaylist->RemoveSong(sinfo, index, m->shufflestate)) { + if (!m->pPlaylist->RemoveSong(sinfo, index, m->stateShuffle)) { _ERR("Song can not be deleted"); return false; } @@ -718,8 +725,7 @@ CSongInfo *CMusicController::MediaSongByUri(char *uri) bool CMusicController::MediaGetList(int EListType, void *info, Eina_List **list) { - if (!m) - return false; + ASSERT(FlagCreate()); Eina_List *mlist; @@ -735,17 +741,15 @@ bool CMusicController::MediaGetList(int EListType, void *info, Eina_List **list) bool CMusicController::MediaInsertPlaylist(const char *name, Eina_List *idlist) { - if (!m) - return false; + ASSERT(FlagCreate()); - return m->pMediadata->InsertPlaylist(name, idlist); + return m->pMediadata->Alloc(name, idlist); } bool CMusicController::MediaExistPlaylist(const char *name) { - if (!m) - return false; + ASSERT(FlagCreate()); if (!name) return false; @@ -756,53 +760,48 @@ bool CMusicController::MediaExistPlaylist(const char *name) bool CMusicController::MediaDeletePlaylist(int id) { - if (!m) - return false; + ASSERT(FlagCreate()); - return m->pMediadata->DeletePlaylist(id); + return m->pMediadata->Delete(id); } bool CMusicController::MediaRenamePlaylist(int id, const char *name) { - if (!m) - return false; + ASSERT(FlagCreate()); if (!name) return false; - return m->pMediadata->RenamePlaylist(id, name); + return m->pMediadata->Rename(id, name); } bool CMusicController::MediaAddmediaPlaylist(int id, Eina_List *idlist) { - if (!m) - return false; + ASSERT(FlagCreate()); if (!idlist) return false; - return m->pMediadata->AddmediaPlaylist(id, idlist); + return m->pMediadata->Insert(id, idlist); } bool CMusicController::MediaRemovemediaPlaylist(int id, Eina_List *idlist) { - if (!m) - return false; + ASSERT(FlagCreate()); if (!idlist) return false; - return m->pMediadata->RemovemediaPlaylist(id, idlist); + return m->pMediadata->Remove(id, idlist); } bool CMusicController::MediaAddsongsPlaylist(int lid, Eina_List *list) { - if (!m) - return false; + ASSERT(FlagCreate()); Eina_List *idlist, *l; CSongInfo *sinfo; @@ -831,8 +830,7 @@ bool CMusicController::MediaAddsongsPlaylist(int lid, Eina_List *list) bool CMusicController::SetCurrentSong(char *mediaid) { - if (!m) - return false; + ASSERT(FlagCreate()); if (!m->pPlaylist->FlagCreate() || !mediaid) return false; @@ -871,65 +869,59 @@ bool CMusicController::SetCurrentAlbum(CAlbumInfo *alinfo) } -int CMusicController::PlayState(void) +bool CMusicController::SetPlayState(EPlayStatus state) { - if (!m) - return -1; + ASSERT(FlagCreate()); - return m->playstate; + m->statePlay = state; + + return true; } -int CMusicController::ShuffleState(void) +EPlayStatus CMusicController::PlayState(void) { - if (!m) - return -1; + ASSERT(FlagCreate()); - return m->shufflestate; + return m->statePlay; } -int CMusicController::RepeatState(void) +bool CMusicController::SetShuffleState(EShuffleStatus state) { - if (!m) - return -1; + ASSERT(FlagCreate()); - return m->repeatstate; + m->stateShuffle = state; + if (state && m->pPlaylist->FlagCreate()) + m->pPlaylist->UpdateShuffle(); + + return true; } -bool CMusicController::SetPlayState(int state) +EShuffleStatus CMusicController::ShuffleState(void) { - if (!m) - return false; - - m->playstate = state; + ASSERT(FlagCreate()); - return true; + return m->stateShuffle; } -bool CMusicController::SetShuffleState(int state) +bool CMusicController::SetRepeatState(ERepeatStatus state) { - if (!m) - return false; + ASSERT(FlagCreate()); - m->shufflestate = state; - if (state && m->pPlaylist->FlagCreate()) - m->pPlaylist->UpdateShuffle(); + m->repeatstate = state; return true; } -bool CMusicController::SetRepeatState(int state) +ERepeatStatus CMusicController::RepeatState(void) { - if (!m) - return false; + ASSERT(FlagCreate()); - m->repeatstate = state; - - return true; + return m->repeatstate; } diff --git a/src/views/album-layout.cpp b/src/views/album-layout.cpp index 234ae1f..21cb797 100644 --- a/src/views/album-layout.cpp +++ b/src/views/album-layout.cpp @@ -17,18 +17,20 @@ #include #include #include + #include #include #include #include + #include "dbg.h" #include "i18n.h" #include "define.h" +#include "common.h" #include "album_info.h" #include "song_info.h" #include "music-controller.h" #include "LayoutMgr.h" -#include "common.h" #include "common-ui.h" #include "BaseView.h" #include "BaseLayout.h" diff --git a/src/views/album-songs-layout.cpp b/src/views/album-songs-layout.cpp index 80537ee..86ad546 100644 --- a/src/views/album-songs-layout.cpp +++ b/src/views/album-songs-layout.cpp @@ -17,20 +17,22 @@ #include #include #include + #include "AppCommon.h" +#include "InputHandler.h" + #include "dbg.h" #include "i18n.h" #include "define.h" +#include "common.h" #include "song_info.h" #include "album_info.h" #include "music-controller.h" #include "LayoutMgr.h" -#include "common.h" #include "common-ui.h" #include "BaseView.h" #include "ExtBaseLayout.h" #include "ViewMgr.h" -#include "InputHandler.h" #include "album-songs-layout.h" #include "base-view.h" diff --git a/src/views/artist-layout.cpp b/src/views/artist-layout.cpp index 745bd46..46e88e5 100644 --- a/src/views/artist-layout.cpp +++ b/src/views/artist-layout.cpp @@ -18,18 +18,18 @@ #include #include #include "AppCommon.h" +#include #include "dbg.h" #include "i18n.h" #include "define.h" -#include +#include "common.h" #include "category_info.h" #include "album_info.h" #include "song_info.h" #include "music-controller.h" #include "LayoutMgr.h" #include "entry-popup.h" -#include "common.h" #include "common-ui.h" #include "BaseView.h" #include "ExtBaseLayout.h" diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index ededc04..c3cd591 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -23,14 +23,15 @@ #include "dbg.h" #include "AppCommon.h" +#include "InputHandler.h" + +#include "common.h" #include "song_info.h" #include "album_info.h" #include "folder_info.h" #include "category_info.h" #include "music-controller.h" #include "LayoutMgr.h" -#include "common.h" -#include "InputHandler.h" #include "BaseView.h" #include "BaseLayout.h" #include "ExtBaseLayout.h" diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index a53a798..8201fe2 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -17,21 +17,22 @@ #include #include #include + #include "AppCommon.h" +#include +#include +#include #include "dbg.h" #include "i18n.h" #include "define.h" -#include -#include -#include +#include "common.h" #include "category_info.h" #include "album_info.h" #include "song_info.h" #include "music-controller.h" #include "LayoutMgr.h" #include "entry-popup.h" -#include "common.h" #include "common-ui.h" #include "BaseView.h" #include "ExtBaseLayout.h" diff --git a/src/views/category-songs-layout.cpp b/src/views/category-songs-layout.cpp index 00576bc..a32e72c 100644 --- a/src/views/category-songs-layout.cpp +++ b/src/views/category-songs-layout.cpp @@ -17,21 +17,23 @@ #include #include #include + #include "AppCommon.h" +#include "InputHandler.h" + #include "dbg.h" #include "i18n.h" #include "define.h" +#include "common.h" #include "song_info.h" #include "album_info.h" #include "category_info.h" #include "music-controller.h" #include "LayoutMgr.h" -#include "common.h" #include "common-ui.h" #include "BaseView.h" #include "ExtBaseLayout.h" #include "ViewMgr.h" -#include "InputHandler.h" #include "category-songs-layout.h" #include "base-view.h" #include "category-layout.h" diff --git a/src/views/folder-layout.cpp b/src/views/folder-layout.cpp index 3966db6..3c3aaf9 100644 --- a/src/views/folder-layout.cpp +++ b/src/views/folder-layout.cpp @@ -17,20 +17,22 @@ #include #include #include + #include "AppCommon.h" +#include #include "dbg.h" #include "i18n.h" #include "define.h" #include #include + +#include "common.h" #include "folder_info.h" #include "song_info.h" #include "album_info.h" -#include #include "music-controller.h" #include "LayoutMgr.h" -#include "common.h" #include "common-ui.h" #include "BaseView.h" #include "ExtBaseLayout.h" diff --git a/src/views/genre-layout.cpp b/src/views/genre-layout.cpp index 28d50b8..1a1d3c9 100644 --- a/src/views/genre-layout.cpp +++ b/src/views/genre-layout.cpp @@ -18,18 +18,18 @@ #include #include #include "AppCommon.h" +#include #include "dbg.h" #include "i18n.h" #include "define.h" -#include +#include "common.h" #include "category_info.h" #include "album_info.h" #include "song_info.h" #include "music-controller.h" #include "LayoutMgr.h" #include "entry-popup.h" -#include "common.h" #include "common-ui.h" #include "BaseView.h" #include "ExtBaseLayout.h" diff --git a/src/views/playback-view.cpp b/src/views/playback-view.cpp index e062b9b..4142ecd 100644 --- a/src/views/playback-view.cpp +++ b/src/views/playback-view.cpp @@ -17,16 +17,18 @@ #include #include #include + #include "AppCommon.h" -#include "dbg.h" -#include "define.h" #include + +#include "define.h" +#include "common.h" +#include "dbg.h" #include "song_info.h" #include "album_info.h" #include "music-controller.h" #include "volume-control.h" #include "i18n.h" -#include "common.h" #include "common-ui.h" #include "BaseView.h" #include "ViewMgr.h" diff --git a/src/views/playlist-layout.cpp b/src/views/playlist-layout.cpp index ca56347..8fda9e4 100644 --- a/src/views/playlist-layout.cpp +++ b/src/views/playlist-layout.cpp @@ -17,19 +17,20 @@ #include #include #include -#include "AppCommon.h" #include "dbg.h" #include "i18n.h" -#include "define.h" +#include "AppCommon.h" #include + +#include "define.h" +#include "common.h" #include "category_info.h" #include "album_info.h" #include "song_info.h" #include "music-controller.h" #include "LayoutMgr.h" #include "entry-popup.h" -#include "common.h" #include "common-ui.h" #include "BaseView.h" #include "ExtBaseLayout.h" diff --git a/src/views/song-layout.cpp b/src/views/song-layout.cpp index 9c97e52..b31c6ee 100644 --- a/src/views/song-layout.cpp +++ b/src/views/song-layout.cpp @@ -17,18 +17,20 @@ #include #include #include +#include "dbg.h" +#include "i18n.h" + #include "AppCommon.h" #include "InputHandler.h" #include #include -#include "dbg.h" -#include "i18n.h" + #include "define.h" +#include "common.h" #include "song_info.h" #include "album_info.h" #include "music-controller.h" #include "LayoutMgr.h" -#include "common.h" #include "common-ui.h" #include "BaseView.h" #include "ExtBaseLayout.h" -- 2.7.4 From 4870ba56b2e789570ab6286e1752de02814b91c0 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Mon, 9 Mar 2015 13:40:50 +0900 Subject: [PATCH 03/16] Fix bug (condition check error) Change-Id: If1aedeffdbe85c9c35d4bb943ce405660831a906 Signed-off-by: Kim Tae Soo --- src/data/mediadata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/mediadata.cpp b/src/data/mediadata.cpp index b943517..88b41a2 100644 --- a/src/data/mediadata.cpp +++ b/src/data/mediadata.cpp @@ -1131,7 +1131,7 @@ bool CMediadata::Create(void) _CREATE_BEGIN{ _CHECK(m = new SMediadata) - _CHECK(media_content_connect()) + _CHECK(media_content_connect() == MEDIA_CONTENT_ERROR_NONE) _CHECK(CMediaContentDbUpdateListener::Create()) _WHEN_SUCCESS{ m->source_type = SOURCE_TYPE_NONE; -- 2.7.4 From 8c8c1d2ec24a88121f1395e12fd9dbd5ef55823a Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Mon, 9 Mar 2015 15:33:07 +0900 Subject: [PATCH 04/16] Remove X dependency Change-Id: I488d3d2ac987185910f4261cf846773ee85fdd2b Signed-off-by: Kim Tae Soo --- CMakeLists.txt | 3 --- include/define.h | 2 ++ packaging/org.tizen.music-player-tv-ref.spec | 3 --- src/views/Info.cpp | 1 - src/views/album-layout.cpp | 1 - src/views/album-songs-layout.cpp | 1 - src/views/artist-layout.cpp | 1 - src/views/base-view.cpp | 1 - src/views/category-layout.cpp | 1 - src/views/category-songs-layout.cpp | 1 - src/views/common-ui.cpp | 1 - src/views/context-view.cpp | 1 - src/views/entry-popup.cpp | 1 - src/views/folder-layout.cpp | 1 - src/views/genre-layout.cpp | 1 - src/views/playback-view.cpp | 1 - src/views/playlist-layout.cpp | 1 - src/views/song-layout.cpp | 1 - 18 files changed, 2 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ebda26..bedf5db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,11 +108,8 @@ pkg_check_modules(PKGS REQUIRED capi-media-player capi-media-sound-manager capi-content-media-content - #capi-system-usbdevice mm-player edje - utilX - x11 gio-2.0 ) diff --git a/include/define.h b/include/define.h index 08ade04..b2eb576 100644 --- a/include/define.h +++ b/include/define.h @@ -436,6 +436,8 @@ #define KEY_NEXT "Next" #define KEY_PREVIOUS "Previous" #define KEY_EXIT "Exit" +#define KEY_MUTE "Mute" +#define KEY_PAUSE "Pause" /* SORTING ID */ #define SORT_BY_ARTIST_AZ "SORT_BY_ARTIST_AZ" diff --git a/packaging/org.tizen.music-player-tv-ref.spec b/packaging/org.tizen.music-player-tv-ref.spec index 1fcee0f..35cce08 100644 --- a/packaging/org.tizen.music-player-tv-ref.spec +++ b/packaging/org.tizen.music-player-tv-ref.spec @@ -15,13 +15,10 @@ BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(capi-media-player) BuildRequires: pkgconfig(capi-media-sound-manager) BuildRequires: pkgconfig(capi-content-media-content) -#BuildRequires: pkgconfig(capi-system-usbdevice) BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(mm-player) BuildRequires: pkgconfig(edje) -BuildRequires: pkgconfig(utilX) -BuildRequires: pkgconfig(x11) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(application-common) BuildRequires: edje-bin diff --git a/src/views/Info.cpp b/src/views/Info.cpp index 19db11a..00584d8 100644 --- a/src/views/Info.cpp +++ b/src/views/Info.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include "i18n.h" #include "define.h" #include "common.h" diff --git a/src/views/album-layout.cpp b/src/views/album-layout.cpp index 21cb797..9d5baf5 100644 --- a/src/views/album-layout.cpp +++ b/src/views/album-layout.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include diff --git a/src/views/album-songs-layout.cpp b/src/views/album-songs-layout.cpp index 86ad546..0daa036 100644 --- a/src/views/album-songs-layout.cpp +++ b/src/views/album-songs-layout.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "AppCommon.h" #include "InputHandler.h" diff --git a/src/views/artist-layout.cpp b/src/views/artist-layout.cpp index 46e88e5..dc2563f 100644 --- a/src/views/artist-layout.cpp +++ b/src/views/artist-layout.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "AppCommon.h" #include #include "dbg.h" diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index c3cd591..3957a3f 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "AppCommon.h" #include "i18n.h" #include "define.h" diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index 8201fe2..e078dd7 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "AppCommon.h" #include diff --git a/src/views/category-songs-layout.cpp b/src/views/category-songs-layout.cpp index a32e72c..611cbe0 100644 --- a/src/views/category-songs-layout.cpp +++ b/src/views/category-songs-layout.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "AppCommon.h" #include "InputHandler.h" diff --git a/src/views/common-ui.cpp b/src/views/common-ui.cpp index a0dc8bf..1937f7b 100644 --- a/src/views/common-ui.cpp +++ b/src/views/common-ui.cpp @@ -15,7 +15,6 @@ */ #include -#include #include "i18n.h" #include "define.h" #include "dbg.h" diff --git a/src/views/context-view.cpp b/src/views/context-view.cpp index f07350d..638999e 100644 --- a/src/views/context-view.cpp +++ b/src/views/context-view.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "AppCommon.h" #include #include "dbg.h" diff --git a/src/views/entry-popup.cpp b/src/views/entry-popup.cpp index 17966c7..e77236a 100644 --- a/src/views/entry-popup.cpp +++ b/src/views/entry-popup.cpp @@ -15,7 +15,6 @@ */ #include -#include #include "i18n.h" #include "define.h" #include "common.h" diff --git a/src/views/folder-layout.cpp b/src/views/folder-layout.cpp index 3c3aaf9..24da067 100644 --- a/src/views/folder-layout.cpp +++ b/src/views/folder-layout.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "AppCommon.h" #include diff --git a/src/views/genre-layout.cpp b/src/views/genre-layout.cpp index 1a1d3c9..fc6594c 100644 --- a/src/views/genre-layout.cpp +++ b/src/views/genre-layout.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "AppCommon.h" #include #include "dbg.h" diff --git a/src/views/playback-view.cpp b/src/views/playback-view.cpp index 4142ecd..27e6893 100644 --- a/src/views/playback-view.cpp +++ b/src/views/playback-view.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "AppCommon.h" #include diff --git a/src/views/playlist-layout.cpp b/src/views/playlist-layout.cpp index 8fda9e4..5ba4c7e 100644 --- a/src/views/playlist-layout.cpp +++ b/src/views/playlist-layout.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "dbg.h" #include "i18n.h" diff --git a/src/views/song-layout.cpp b/src/views/song-layout.cpp index b31c6ee..e2c42b0 100644 --- a/src/views/song-layout.cpp +++ b/src/views/song-layout.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "dbg.h" #include "i18n.h" -- 2.7.4 From 21054a45665efc4748f714b13e541bbd5e0a999f Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 10 Mar 2015 09:25:48 +0900 Subject: [PATCH 05/16] Fix double macro definition warning Change-Id: I30f0be8673f6d988f728349d6f8d923894e4412d Signed-off-by: Kim Tae Soo --- include/define.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/define.h b/include/define.h index b2eb576..ad9eac7 100644 --- a/include/define.h +++ b/include/define.h @@ -423,20 +423,35 @@ #define POSITION_PLAY_LIST_POPUP_Y 1020 /* TEMP KEY DEFINITION */ +#undef KEY_VOLUMEUP #define KEY_VOLUMEUP "F9" +#undef KEY_VOLUMEDOWN #define KEY_VOLUMEDOWN "F10" +#undef KEY_ENTER #define KEY_ENTER "Return" +#undef KEY_BACK #define KEY_BACK "Escape" +#undef KEY_MENU #define KEY_MENU "Super_L" +#undef KEY_ENTER_REMOTE #define KEY_ENTER_REMOTE "KP_Enter" +#undef KEY_BACK_REMOTE #define KEY_BACK_REMOTE "XF86Close" +#undef KEY_MENU_REMOTE #define KEY_MENU_REMOTE "XF86MenuKB" + /* SHOULD BE DEFINED */ +#undef KEY_PLAY #define KEY_PLAY "Play" +#undef KEY_NEXT #define KEY_NEXT "Next" +#undef KEY_PREVIOUS #define KEY_PREVIOUS "Previous" +#undef KEY_EXIT #define KEY_EXIT "Exit" +#undef KEY_MUTE #define KEY_MUTE "Mute" +#undef KEY_PAUSE #define KEY_PAUSE "Pause" /* SORTING ID */ -- 2.7.4 From cd287701e8f022a05714be9c4e249c910a660d33 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 10 Mar 2015 14:33:04 +0900 Subject: [PATCH 06/16] Refactoring of class Create function (use macro) Change-Id: I1e3eaa033aa59b02976f2d3fccf26a7fea93a0ed Signed-off-by: Kim Tae Soo --- src/playback/music-controller.cpp | 72 +++++++++------------ src/views/album-layout.cpp | 127 ++++++++++++++------------------------ 2 files changed, 74 insertions(+), 125 deletions(-) diff --git a/src/playback/music-controller.cpp b/src/playback/music-controller.cpp index e831a34..7ae4712 100644 --- a/src/playback/music-controller.cpp +++ b/src/playback/music-controller.cpp @@ -206,51 +206,35 @@ static void _content_update_cb(void *dt) SMusicController *CMusicController::t_Create(void) { - SMusicController *mhandle; - - mhandle = new SMusicController; - if (!mhandle) { - _ERR(" music init failed "); - return NULL; - } - - mhandle->statePlay = PLAY_STATUS_INITIAL; - mhandle->stateShuffle = SHUFFLE_STATUS_OFF; - mhandle->repeatstate = REPEAT_STATUS_ALL; - mhandle->initial_index = 0; - CInfo::SetSortType(E_SORT_TITLE_A_Z); - CInfo::SetSourceType(SOURCE_TYPE_ALL); - mhandle->alinfo = new CAlbumInfo; - - if (!mhandle->alinfo->Create()) { - _ERR(" mediadata create failed "); - delete mhandle; - return NULL; - } - - if (!mhandle->pMediadata->Create()) { - _ERR(" mediadata create failed "); - mhandle->alinfo->Destroy(); - delete mhandle->alinfo; - delete mhandle; - return NULL; - } - - if (!mhandle->pPlayback->Create()) - _ERR(" playback create failed "); - - if (!mhandle->pPlayback->SetCallback(sm_CbPlaybackCompletion, this)) - _ERR(" playback add completion callback failed "); - - mhandle->cbinfo = mhandle->pMediadata->AddCallback(E_CONTENT_UPDATE, _content_update_cb, mhandle); + SMusicController *mhandle = NULL; + + _CREATE_BEGIN { + _CHECK(mhandle = new SMusicController) + _CHECK(mhandle->alinfo = new CAlbumInfo) + _CHECK(mhandle->alinfo->Create() == true) + _CHECK(mhandle->pMediadata->Create() == true) + _CHECK(mhandle->pPlayback->Create() == true) + _CHECK(mhandle->pPlayback->SetCallback(sm_CbPlaybackCompletion, this) == true) + _CHECK(CUsbConnectionListener::Create() == true) + + _WHEN_SUCCESS{ + mhandle->statePlay = PLAY_STATUS_INITIAL; + mhandle->stateShuffle = SHUFFLE_STATUS_OFF; + mhandle->repeatstate = REPEAT_STATUS_ALL; + mhandle->initial_index = 0; + CInfo::SetSortType(E_SORT_TITLE_A_Z); + CInfo::SetSourceType(SOURCE_TYPE_ALL); + mhandle->cbinfo = mhandle->pMediadata->AddCallback(E_CONTENT_UPDATE, _content_update_cb, mhandle); + } - if (!CUsbConnectionListener::Create()) { - _ERR("CUsbConnectionListener::Create failed"); - mhandle->pPlayback->Destroy(); - mhandle->pMediadata->Destroy(); - delete mhandle; - return NULL; - } + _CHECK_FAIL{ CUsbConnectionListener::Destroy(); } + _CHECK_FAIL{} + _CHECK_FAIL{ mhandle->pPlayback->Destroy(); } + _CHECK_FAIL{ mhandle->pMediadata->Destroy(); } + _CHECK_FAIL{ mhandle->alinfo->Destroy(); } + _CHECK_FAIL{ delete mhandle->alinfo; } + _CHECK_FAIL{ delete mhandle; mhandle = NULL; } + } _CREATE_END_AND_CATCH{ return NULL; } return mhandle; } diff --git a/src/views/album-layout.cpp b/src/views/album-layout.cpp index 9d5baf5..946b10c 100644 --- a/src/views/album-layout.cpp +++ b/src/views/album-layout.cpp @@ -419,92 +419,57 @@ bool CAlbumLayout::Create(CLayoutMgr *mgr, const char *albumId) Evas_Object *layout = NULL; CMusicController *mhandle = NULL; CViewMgr *vmgr = NULL; + SParcel parcel; - m = new SAlbumLayout; - if (!m) { - _ERR(" albumlayout data allocation failed "); - return false; - } - - vmgr = CViewMgr::GetInstance(); - if (!vmgr) { - _ERR(" get viewmgr failed "); - delete m; - m = NULL; - return false; - } - - base = mgr->Base(); - if (!base) { - _ERR(" get base failed "); - delete m; - m = NULL; - return false; - } - - win = vmgr->Window(); - if (!win) { - _ERR(" vimewmgr get win failed "); - delete m; - m = NULL; - return false; - } - - mhandle = CMusicController::GetInstance(); - if (!mhandle) { - _ERR(" music controller get music instance failed "); - delete m; - m = NULL; - return false; - } - - layout = CCommonUI::AddBase(base, MUSIC_ALBUM_LAYOUT); - if (!layout) { - _ERR(" get layout failed "); - delete m; - m = NULL; - return false; - } - - bool r = CExtBaseLayout::Create(layout); - if (!r) { - _ERR(" CBaseLayout creation failed "); - evas_object_del(layout); - delete m; - m = NULL; - return false; - } - - if (albumId) { - m->album_id = new char[strlen(albumId) + 1]; - strcpy(m->album_id, albumId); - } - else { - m->album_id = NULL; - } - - m->win = win; - m->base = base; - m->vmgr = vmgr; - m->mhandle = mhandle; - m->lmgr = mgr; - m->callback.cbHandleEmptyStatus = NULL; - m->callback.cookie = NULL; + _CREATE_BEGIN { + _CHECK(m = new SAlbumLayout) + _CHECK(vmgr = CViewMgr::GetInstance()) + _CHECK(base = mgr->Base()) + _CHECK(win = vmgr->Window()) + _CHECK(mhandle = CMusicController::GetInstance()) + _CHECK(layout = CCommonUI::AddBase(base, MUSIC_ALBUM_LAYOUT)) + _CHECK(CExtBaseLayout::Create(layout)) + _CHECK(m->layoutAlbumSongs = new CAlbumSongsLayout(MUSIC_ALBUM_SONGS_LAYOUT)) + _CHECK(m->layoutAlbumSongs->Create(mgr)) + _CHECK(mgr->AddLayout(m->layoutAlbumSongs)) + + _WHEN_SUCCESS { + if (albumId) { + m->album_id = new char[strlen(albumId) + 1]; + strcpy(m->album_id, albumId); + } + else + m->album_id = NULL; - m->layoutAlbumSongs = new CAlbumSongsLayout(MUSIC_ALBUM_SONGS_LAYOUT); - m->layoutAlbumSongs->Create(m->lmgr); - m->lmgr->AddLayout(m->layoutAlbumSongs); + m->win = win; + m->base = base; + m->vmgr = vmgr; + m->mhandle = mhandle; + m->lmgr = mgr; + m->callback.cbHandleEmptyStatus = NULL; + m->callback.cookie = NULL; - m_CreateAlbumGrid(); + m_CreateAlbumGrid(); + Connect(layout, ALBUM_LAYOUT, TYPE_KEY_DOWN); - Connect(layout, ALBUM_LAYOUT, TYPE_KEY_DOWN); + parcel.ctxtInfo = NULL; + parcel.updateType = E_LAYOUT_UPDATE; + parcel.layoutId = MUSIC_ALBUM_LAYOUT; + parcel.keyEvent = NULL; + m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel); + } - SParcel parcel; - parcel.ctxtInfo = NULL; - parcel.updateType = E_LAYOUT_UPDATE; - parcel.layoutId = MUSIC_ALBUM_LAYOUT; - parcel.keyEvent = NULL; - m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel); + _CHECK_FAIL{} + _CHECK_FAIL{ m->layoutAlbumSongs->Destroy(); } + _CHECK_FAIL{ delete m->layoutAlbumSongs; } + _CHECK_FAIL{ CExtBaseLayout::Destroy(); } + _CHECK_FAIL{ evas_object_del(layout); } + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } return true; } -- 2.7.4 From 09635d5fb3b8511fa2aa0b2b0cd9e6d59f718070 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 10 Mar 2015 15:13:43 +0900 Subject: [PATCH 07/16] Change focus chain to improve usability Change-Id: Ia9c1aa1f26dfff27a732ebbcdbe6af3dbf91bcbd Signed-off-by: Kim Tae Soo --- src/views/base-view.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index 3957a3f..6d3b140 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -231,8 +231,12 @@ void CMusicBaseView::m_UpdateFocusSequence(void) elm_object_focus_next_object_set(m->group_btn[i], m->content, ELM_FOCUS_RIGHT); - elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_SONG], m->plbackbtn, ELM_FOCUS_UP); - elm_object_focus_next_object_set(m->plbackbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_SONG], m->group_btn[GROUP_BTN_PLAYLIST], ELM_FOCUS_UP); + elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_PLAYLIST], m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN); + if (m->c_grpbtn != NULL) + elm_object_focus_next_object_set(m->plbackbtn, m->c_grpbtn, ELM_FOCUS_LEFT); + else + elm_object_focus_next_object_set(m->plbackbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_LEFT); elm_object_focus_next_object_set(m->plbackbtn, m->content, ELM_FOCUS_DOWN); elm_object_focus_next_object_set(m->srcbtn, m->content, ELM_FOCUS_DOWN); elm_object_focus_next_object_set(m->sortbtn, m->content, ELM_FOCUS_DOWN); @@ -250,7 +254,8 @@ void CMusicBaseView::m_UpdateEmptyFocusSequence(void) elm_object_focus_next_object_set(m->group_btn[i], m->plbackbtn, ELM_FOCUS_RIGHT); - elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_SONG], m->plbackbtn, ELM_FOCUS_UP); + elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_SONG], m->group_btn[GROUP_BTN_PLAYLIST], ELM_FOCUS_UP); + elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_PLAYLIST], m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN); elm_object_focus_next_object_set(m->plbackbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_LEFT); elm_object_focus_next_object_set(m->plbackbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN); elm_object_focus_next_object_set(m->srcbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN); -- 2.7.4 From f90c5d042289d606b6b2458f1a30babb3eadbfc2 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 10 Mar 2015 15:48:15 +0900 Subject: [PATCH 08/16] Change the definition of menu key of remote controller Change-Id: Ic112695df52fe56dc747ae4116245e12632d2899 Signed-off-by: Kim Tae Soo --- include/define.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/define.h b/include/define.h index ad9eac7..305c877 100644 --- a/include/define.h +++ b/include/define.h @@ -438,7 +438,7 @@ #undef KEY_BACK_REMOTE #define KEY_BACK_REMOTE "XF86Close" #undef KEY_MENU_REMOTE -#define KEY_MENU_REMOTE "XF86MenuKB" +#define KEY_MENU_REMOTE "XF86Send" /* SHOULD BE DEFINED */ #undef KEY_PLAY -- 2.7.4 From 8fbf23031836eb68c5ce2210c2a97be991d86437 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 10 Mar 2015 16:49:41 +0900 Subject: [PATCH 09/16] [JIRA:TT-21] Musicplayer disappears when home button was pressed Change-Id: Ie035036cd18b73f9c0892e6d0bf3faf4b38b16e6 Signed-off-by: Kim Tae Soo --- src/main.cpp | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ce0f967..e6df0a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,6 +52,8 @@ private: CPlaybackView *m_cPlaybackView; CContextView *m_cContextView; + CViewMgr *m_pViewMgr; + private: static void sm_CbPushView(void* cookie, CBaseView *pHideView, CBaseView *pShowView) @@ -114,9 +116,9 @@ public: virtual void OnTerminate(void) { - CViewMgr::GetInstance()->RemoveView(m_cBaseView); - CViewMgr::GetInstance()->RemoveView(m_cPlaybackView); - CViewMgr::GetInstance()->RemoveView(m_cContextView); + m_pViewMgr->RemoveView(m_cBaseView); + m_pViewMgr->RemoveView(m_cPlaybackView); + m_pViewMgr->RemoveView(m_cContextView); CSortMgr::Finalize(); CViewMgr::Finalize(); @@ -134,17 +136,25 @@ public: virtual void OnPause(void) { - elm_exit(); + _DBG("Musicplayer app is paused"); + m_pViewMgr->Pause(); + } + virtual void OnResume(void) + { + _DBG("Musicplayer app is Resumed"); + m_pViewMgr->Resume(); + } + + virtual void OnAppControl(app_control_h app_control) { _DBG(""); - CViewMgr* viewmgr = NULL; - int r; char *album_id; char *uri; char *source; + int r; _DBG(""); r = app_control_get_extra_data(app_control, PARAM_ALBUM, &album_id); @@ -181,8 +191,8 @@ public: _DBG(""); CViewMgr::Initialize(ad.win, (void*)"path"); - viewmgr = CViewMgr::GetInstance(); - if (!viewmgr) { + m_pViewMgr = CViewMgr::GetInstance(); + if (!m_pViewMgr) { _ERR(" viewmgr init failed "); CMusicController::Finalize(); goto error; @@ -196,9 +206,9 @@ public: m_cContextView = new CContextView(MUSIC_CONTEXT_VIEW); _DBG(""); - viewmgr->AddView(m_cBaseView); - viewmgr->AddView(m_cPlaybackView); - viewmgr->AddView(m_cContextView); + m_pViewMgr->AddView(m_cBaseView); + m_pViewMgr->AddView(m_cPlaybackView); + m_pViewMgr->AddView(m_cContextView); _DBG(""); @@ -207,10 +217,10 @@ public: cb.cookie = this; cb.cbPushView = sm_CbPushView; cb.cbPopView = sm_CbPopView; - viewmgr->AddCallback(&cb); + m_pViewMgr->AddCallback(&cb); _DBG(""); - if (!viewmgr->PushView(MUSIC_BASE_VIEW, ad.arglist)) { + if (!m_pViewMgr->PushView(MUSIC_BASE_VIEW, ad.arglist)) { _ERR(" view push failed "); CViewMgr::Finalize(); CMusicController::Finalize(); -- 2.7.4 From 5a9fcbf10c73f7e7ba6762466cca6ed2b19931ad Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 10 Mar 2015 22:51:49 +0900 Subject: [PATCH 10/16] Fix bug: When song or album item is selected, music player should show song lay out or album layout for each case. Change-Id: Iad36fb648bf5f261da2f5e65aa5e277abc2525c3 Signed-off-by: Kim Tae Soo --- src/views/base-view.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index 6d3b140..0e2ee52 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -742,15 +742,15 @@ bool CMusicBaseView::Create(void *data) m->layoutSong = new CSongLayout(MUSIC_SONG_LAYOUT); arg = NULL; - if (m->arglist && m->arglist->album_id) - arg = m->arglist->album_id; + if (m->arglist && m->arglist->uri) + arg = m->arglist->uri; m->layoutSong->Create(m->lmgr, arg); lmgr->AddLayout(m->layoutSong); m->layoutAlbum = new CAlbumLayout(MUSIC_ALBUM_LAYOUT); arg = NULL; - if (m->arglist && m->arglist->uri) - arg = m->arglist->uri; + if (m->arglist && m->arglist->album_id) + arg = m->arglist->album_id; m->layoutAlbum->Create(m->lmgr, arg); m->layoutAlbum->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this); lmgr->AddLayout(m->layoutAlbum); -- 2.7.4 From a7808317902154457fe2ecf2b7bc43025c235ab6 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Tue, 10 Mar 2015 23:13:57 +0900 Subject: [PATCH 11/16] Fix focus bug of CPlaybackView Change-Id: I9f965b7c97f472bcfcbe3183c6c50922e0e4d761 Signed-off-by: Kim Tae Soo --- src/views/playback-view.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/views/playback-view.cpp b/src/views/playback-view.cpp index 27e6893..09fe230 100644 --- a/src/views/playback-view.cpp +++ b/src/views/playback-view.cpp @@ -1784,6 +1784,8 @@ void CPlaybackView::t_OnShow(void) int state; + m_UpdateCurrentSongInfo(); + if (m->cs_itinfo) { elm_genlist_item_show(m->cs_itinfo->item, ELM_GENLIST_ITEM_SCROLLTO_IN); -- 2.7.4 From 05201aa99a98ff22a766e246401cc0cd85a9525e Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 11 Mar 2015 08:23:55 +0900 Subject: [PATCH 12/16] Apply the modification of CSortMgr Change-Id: I1f63097cf37f20b20fe6a7d2de5d57b771a824fb Signed-off-by: Kim Tae Soo --- src/views/album-layout.cpp | 3 +-- src/views/category-layout.cpp | 3 +-- src/views/folder-layout.cpp | 3 +-- src/views/song-layout.cpp | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/views/album-layout.cpp b/src/views/album-layout.cpp index 946b10c..2770396 100644 --- a/src/views/album-layout.cpp +++ b/src/views/album-layout.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include "dbg.h" #include "i18n.h" @@ -368,7 +367,7 @@ void CAlbumLayout::m_SortAlbumGrid(void) sortType = CInfo::SortType(); - m->alblist = CSort::Sort(m->alblist, sortFuncId[sortType]); + m->alblist = CSortMgr::Sort(m->alblist, sortFuncId[sortType]); } diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index e078dd7..b86e802 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -20,7 +20,6 @@ #include "AppCommon.h" #include #include -#include #include "dbg.h" #include "i18n.h" #include "define.h" @@ -922,7 +921,7 @@ void CCategoryLayout::m_SortCatgrid(void) sortType = CInfo::SortType(); - m->catlist = CSort::Sort(m->catlist, sortFuncType[sortType]); + m->catlist = CSortMgr::Sort(m->catlist, sortFuncType[sortType]); } diff --git a/src/views/folder-layout.cpp b/src/views/folder-layout.cpp index 24da067..f362152 100644 --- a/src/views/folder-layout.cpp +++ b/src/views/folder-layout.cpp @@ -23,7 +23,6 @@ #include "i18n.h" #include "define.h" #include -#include #include "common.h" #include "folder_info.h" @@ -497,7 +496,7 @@ void CFolderLayout::m_SortFolderGrid(void) sortType = CInfo::SortType(); - m->flist = CSort::Sort(m->flist, sortFuncId[sortType]); + m->flist = CSortMgr::Sort(m->flist, sortFuncId[sortType]); } diff --git a/src/views/song-layout.cpp b/src/views/song-layout.cpp index e2c42b0..daa7d23 100644 --- a/src/views/song-layout.cpp +++ b/src/views/song-layout.cpp @@ -22,7 +22,6 @@ #include "AppCommon.h" #include "InputHandler.h" #include -#include #include "define.h" #include "common.h" @@ -395,7 +394,7 @@ void CSongLayout::m_SortSongList(void) sortType = CInfo::SortType(); - m->slist = CSort::Sort(m->slist, sortFuncId[sortType]); + m->slist = CSortMgr::Sort(m->slist, sortFuncId[sortType]); } void CSongLayout::m_EmptySongList(bool sort_flag) -- 2.7.4 From 8e9e296fd54d92f71f53d1c029520d0e54662612 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 11 Mar 2015 13:10:11 +0900 Subject: [PATCH 13/16] CCategoryStorage class is separated from mediadata.cpp Change-Id: I039b7fc52dd4fbee3527a623f7c5c215369f4f88 Signed-off-by: Kim Tae Soo --- CMakeLists.txt | 1 + include/CategoryStorage.h | 58 ++++++++++++++ src/data/CategoryStorage.cpp | 180 +++++++++++++++++++++++++++++++++++++++++++ src/data/mediadata.cpp | 162 +------------------------------------- 4 files changed, 242 insertions(+), 159 deletions(-) create mode 100644 include/CategoryStorage.h create mode 100644 src/data/CategoryStorage.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index bedf5db..c68dd9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,7 @@ SET(SRCS src/main.cpp src/data/category_info.cpp src/data/folder_info.cpp src/data/bus.cpp + src/data/CategoryStorage.cpp ) SET(TARGET_EDJ "${PROJECT_NAME}.edj") diff --git a/include/CategoryStorage.h b/include/CategoryStorage.h new file mode 100644 index 0000000..662a41c --- /dev/null +++ b/include/CategoryStorage.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CATEGORY_STORAGE_H__ +#define __CATEGORY_STORAGE_H__ + + +class CCategoryStorage { +protected: + Eina_List *elList; + +public: + CCategoryStorage() { elList = NULL; } + virtual ~CCategoryStorage() {} + + void SetList(Eina_List *el); + Eina_List *List(void); + void Delete(void); + + virtual bool Update(void) = 0; +}; + +class CArtistStorage : public CCategoryStorage { +public: + virtual bool Update(void); +}; + +class CGenreStorage : public CCategoryStorage { +public: + virtual bool Update(void); +}; + +class CPlaylistStorage : public CCategoryStorage { +private: + static bool sm_CbPlaylistMember(int memb_id, media_info_h mdh, void *dt); + static bool sm_CbEachPlaylist(media_playlist_h ph, void *dt); + bool m_OnEachPlaylist(media_playlist_h ph); + int m_GetPlaylistList(void); + +public: + virtual bool Update(void); +}; + + +#endif // __CATEGORY_STORAGE_H__ \ No newline at end of file diff --git a/src/data/CategoryStorage.cpp b/src/data/CategoryStorage.cpp new file mode 100644 index 0000000..7e7b946 --- /dev/null +++ b/src/data/CategoryStorage.cpp @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include +#include "dbg.h" +#include "i18n.h" +#include "define.h" + +#include +#include "song_info.h" +#include "album_info.h" +#include "category_info.h" +#include "folder_info.h" +#include "CategoryStorage.h" +#include "common.h" + + +void CCategoryStorage::SetList(Eina_List *el) +{ + elList = el; +} + + +Eina_List *CCategoryStorage::List(void) +{ + return elList; +} + + +void CCategoryStorage::Delete(void) +{ + if (!elList) + return; + + CCategoryInfo *catinfo = NULL; + void *obj = NULL; + + EINA_LIST_FREE(elList, obj) { + catinfo = (CCategoryInfo *)obj; + catinfo->Destroy(); + delete catinfo; + } + + elList = NULL; +} + + +bool CArtistStorage::Update(void) +{ + return true; +} + + +bool CGenreStorage::Update(void) +{ + return true; +} + + +bool CPlaylistStorage::sm_CbPlaylistMember(int memb_id, media_info_h mdh, void *dt) +{ + CCategoryInfo *catinfo = (CCategoryInfo *)dt; + CCategoryInfo::CListMember *member = NULL; + char *id = NULL; + + if (!mdh || !catinfo) + return false; + + if (media_info_get_media_id(mdh, &id) != MEDIA_CONTENT_ERROR_NONE) { + _ERR(" Failed to get media id "); + return false; + } + + char *thumb; + if (!catinfo->ThumbnailPath()) { + if (media_info_get_thumbnail_path(mdh, &thumb) != MEDIA_CONTENT_ERROR_NONE) + _ERR("Media thumbnail path Fetch error"); + catinfo->SetThumbnailPath(thumb); + } + + member = new CCategoryInfo::CListMember; + if (!member) { + free(id); + return false; + } + + member->memberId = memb_id; + member->mediaId = id; + + catinfo->SetMember(member); + + return true; +} + + +bool CPlaylistStorage::sm_CbEachPlaylist(media_playlist_h ph, void *dt) +{ + CPlaylistStorage *root = (CPlaylistStorage *)dt; + + if (!root) + return false; + + root->m_OnEachPlaylist(ph); + + return true; +} + + +bool CPlaylistStorage::m_OnEachPlaylist(media_playlist_h ph) +{ + if (!ph) + return false; + + _CREATE_BEGIN{ + CCategoryInfo *catinfo = NULL; + char *tmpStr = NULL; + int categoryId = 0; + int songCount = 0; + _CHECK(catinfo = new CCategoryInfo) + _CHECK(catinfo->Create()) + _CHECK(media_playlist_get_name(ph, &tmpStr) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_playlist_get_playlist_id(ph, &categoryId) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_playlist_get_media_count_from_db(catinfo->CategoryId(), NULL, &songCount) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_playlist_foreach_media_from_db(catinfo->CategoryId(), NULL, + sm_CbPlaylistMember, (void *)catinfo) == MEDIA_CONTENT_ERROR_NONE) + + _WHEN_SUCCESS{ + catinfo->SetName(tmpStr); + catinfo->SetCategoryId(categoryId); + catinfo->SetSongCount(songCount); + elList = eina_list_append(elList, catinfo); + } + + _CHECK_FAIL{ /* */ } + _CHECK_FAIL{ /* */ } + _CHECK_FAIL{ /* */ } + _CHECK_FAIL{ /* */ } + _CHECK_FAIL{ catinfo->Destroy(); } + _CHECK_FAIL{ delete catinfo; catinfo = NULL; } + }_CREATE_END_AND_CATCH{ return false; } + + return true; +} + + +int CPlaylistStorage::m_GetPlaylistList(void) +{ + if (media_playlist_foreach_playlist_from_db(NULL, sm_CbEachPlaylist, this)) { + _ERR(" Get each playlist failed "); + return false; + } + + return true; +} + + +bool CPlaylistStorage::Update(void) +{ + Delete(); + m_GetPlaylistList(); + return true; +} diff --git a/src/data/mediadata.cpp b/src/data/mediadata.cpp index 88b41a2..6893576 100644 --- a/src/data/mediadata.cpp +++ b/src/data/mediadata.cpp @@ -28,15 +28,16 @@ #include "album_info.h" #include "category_info.h" #include "folder_info.h" +#include "CategoryStorage.h" #include "mediadata.h" #include "common.h" #define MEDIA_CONDITION_MUSIC "(MEDIA_TYPE=3)" #define MEDIA_CONDITION_INTERNAL "(MEDIA_STORAGE_TYPE=0)" #define MEDIA_CONDITION_EXTERNAL "(MEDIA_STORAGE_TYPE=1)" - #define MUSIC_STR_UNKNOWN N_("Unknown") + enum songlist_type { E_ALL_SONGS, E_ALBUM_SONGS, @@ -46,161 +47,6 @@ enum songlist_type { }; -class CStorage { -protected: - Eina_List *elList; - -public: - CStorage() { - elList = NULL; - } - virtual ~CStorage() { - - } - - void SetList(Eina_List *el) { - elList = el; - } - Eina_List *List(void) { - return elList; - } - - void Delete(void) { - if (!elList) - return; - - CCategoryInfo *catinfo = NULL; - void *obj = NULL; - - EINA_LIST_FREE(elList, obj) { - catinfo = (CCategoryInfo *)obj; - catinfo->Destroy(); - delete catinfo; - } - - elList = NULL; - } - virtual bool Update(void) = 0; -}; - - -class CArtistStorage : public CStorage { -public: - virtual bool Update(void) { - return true; - } -}; - -class CGenreStorage : public CStorage { -public: - virtual bool Update(void) { - return true; - } -}; - -class CPlaylistStorage : public CStorage { -private: - static bool sm_CbPlaylistMember(int memb_id, media_info_h mdh, void *dt) - { - CCategoryInfo *catinfo = (CCategoryInfo *)dt; - CCategoryInfo::CListMember *member = NULL; - char *id = NULL; - - if (!mdh || !catinfo) - return false; - - if (media_info_get_media_id(mdh, &id) != MEDIA_CONTENT_ERROR_NONE) { - _ERR(" Failed to get media id "); - return false; - } - - char *thumb; - if (!catinfo->ThumbnailPath()) { - if (media_info_get_thumbnail_path(mdh, &thumb) != MEDIA_CONTENT_ERROR_NONE) - _ERR("Media thumbnail path Fetch error"); - catinfo->SetThumbnailPath(thumb); - } - - member = new CCategoryInfo::CListMember; - if (!member) { - free(id); - return false; - } - - member->memberId = memb_id; - member->mediaId = id; - - catinfo->SetMember(member); - - return true; - } - - static bool sm_CbEachPlaylist(media_playlist_h ph, void *dt) - { - CPlaylistStorage *root = (CPlaylistStorage *)dt; - - if (!root) - return false; - - root->m_OnEachPlaylist(ph); - - return true; - } - bool m_OnEachPlaylist(media_playlist_h ph) - { - if (!ph) - return false; - - _CREATE_BEGIN{ - CCategoryInfo *catinfo = NULL; - char *tmpStr = NULL; - int categoryId = 0; - int songCount = 0; - _CHECK(catinfo = new CCategoryInfo) - _CHECK(catinfo->Create()) - _CHECK(media_playlist_get_name(ph, &tmpStr) == MEDIA_CONTENT_ERROR_NONE) - _CHECK(media_playlist_get_playlist_id(ph, &categoryId) == MEDIA_CONTENT_ERROR_NONE) - _CHECK(media_playlist_get_media_count_from_db(catinfo->CategoryId(), NULL, &songCount) == MEDIA_CONTENT_ERROR_NONE) - _CHECK(media_playlist_foreach_media_from_db(catinfo->CategoryId(), NULL, - sm_CbPlaylistMember, (void *)catinfo) == MEDIA_CONTENT_ERROR_NONE) - - _WHEN_SUCCESS{ - catinfo->SetName(tmpStr); - catinfo->SetCategoryId(categoryId); - catinfo->SetSongCount(songCount); - elList = eina_list_append(elList, catinfo); - } - - _CHECK_FAIL{ /* */ } - _CHECK_FAIL{ /* */ } - _CHECK_FAIL{ /* */ } - _CHECK_FAIL{ /* */ } - _CHECK_FAIL{ catinfo->Destroy(); } - _CHECK_FAIL{ delete catinfo; catinfo = NULL; } - }_CREATE_END_AND_CATCH{ return false; } - - return true; - } - - int m_GetPlaylistList(void) - { - if (media_playlist_foreach_playlist_from_db(NULL, sm_CbEachPlaylist, this)) { - _ERR(" Get each playlist failed "); - return false; - } - - return true; - } - -public: - virtual bool Update(void) { - Delete(); - m_GetPlaylistList(); - return true; - } -}; - - struct SMediadata { Eina_List *songlist; Eina_List *folderlist; @@ -236,8 +82,6 @@ struct SMediadata { }; - - bool CPlaylistMgr::Alloc(const char *name, Eina_List *elIdList) { ASSERT(name); @@ -929,7 +773,7 @@ void CMediadata::m_GetCategoryList(ECategoryType type) if (!m->albumlist) return; - CStorage *stg = NULL; + CCategoryStorage *stg = NULL; if (type == CAT_TYPE_ARTIST) stg = m->storageArtist; else -- 2.7.4 From 8f15b68b14f8201db76a091dec1f8673b12afb6e Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Wed, 11 Mar 2015 16:51:13 +0900 Subject: [PATCH 14/16] Refactoring of CMediaData class: Make it manage song list using CSongStorage class Change-Id: I19fdd29a964148f9abee039d9a6bde35cd8c7c93 Signed-off-by: Kim Tae Soo --- CMakeLists.txt | 1 + include/SongStorage.h | 89 +++++++++++ include/mediadata.h | 10 -- src/data/CategoryStorage.cpp | 15 +- src/data/SongStorage.cpp | 285 ++++++++++++++++++++++++++++++++++ src/data/mediadata.cpp | 362 ++++--------------------------------------- 6 files changed, 415 insertions(+), 347 deletions(-) create mode 100644 include/SongStorage.h create mode 100644 src/data/SongStorage.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c68dd9d..173cc4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,7 @@ SET(SRCS src/main.cpp src/data/folder_info.cpp src/data/bus.cpp src/data/CategoryStorage.cpp + src/data/SongStorage.cpp ) SET(TARGET_EDJ "${PROJECT_NAME}.edj") diff --git a/include/SongStorage.h b/include/SongStorage.h new file mode 100644 index 0000000..c843034 --- /dev/null +++ b/include/SongStorage.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __SONG_STORAGE_H__ +#define __SONG_STORAGE_H__ + + +class CSongStorage { +public: + enum EType { + SONGS_SONG_STORAGE, + ALBUM_SONG_STORAGE, + FOLDER_SONG_STORAGE, + PLAYLIST_SONG_STORAGE, + SINGLE_SONG_STORAGE, + }; + +protected: + EType t_type; + int t_memberId; + CSongInfo *t_songInfo; + Eina_List *elList; + +private: + static bool sm_CbOnEachSong(media_info_h mh, void *dt); + bool m_OnEachSong(media_info_h mh); + +protected: + virtual bool t_GetSongList(CNameInfo *info, filter_h filter); + +public: + CSongStorage() { elList = NULL; } + virtual ~CSongStorage() {} + + Eina_List *List(void); + void Delete(void); +}; + +class CSongsSongStorage : public CSongStorage { +public: + CSongsSongStorage() { t_type = SONGS_SONG_STORAGE; } + + bool Update(filter_h filter); +}; + +class CAlbumSongStorage : public CSongStorage { +public: + CAlbumSongStorage() { t_type = ALBUM_SONG_STORAGE; } + + bool Update(CAlbumInfo *alinfo, filter_h filter); +}; + +class CFolderSongStorage : public CSongStorage { +public: + CFolderSongStorage() { t_type = FOLDER_SONG_STORAGE; } + + bool Update(CFolderInfo *finfo, filter_h filter); +}; + +class CPlaylistSongStorage : public CSongStorage { +public: + CPlaylistSongStorage() { t_type = PLAYLIST_SONG_STORAGE; } + + bool Update(CCategoryInfo *catinfo, filter_h filter); +}; + +class CSingleSongStorage : public CSongStorage { +public: + CSingleSongStorage() { t_type = SINGLE_SONG_STORAGE; } + + CSongInfo *SongInfo(filter_h filter); +}; + + + +#endif // __SONG_STORAGE_H__ \ No newline at end of file diff --git a/include/mediadata.h b/include/mediadata.h index fb0423b..3e9f4a6 100644 --- a/include/mediadata.h +++ b/include/mediadata.h @@ -45,19 +45,13 @@ private: private: 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); static bool sm_CbEachAlbumData(media_album_h album_h, void *dt); static bool sm_CbPlaylist(media_playlist_h ph, void *dt); private: - bool m_HandleEachMediaData(media_info_h md_h); bool m_HandleEachFolderData(media_folder_h folder_h); bool m_HandleEachAlbumData(media_album_h album_h); - void m_DeleteSongList(void); - void m_DeleteFolderSongList(void); - void m_DeleteAlbumSongList(void); - void m_DeletePlaylistSongList(void); void m_DeleteFolderList(void); void m_DeleteAlbumList(void); void m_DeleteCategoryList(ECategoryType type); @@ -66,12 +60,8 @@ private: void m_DestroyFilter(void); void m_GetCategoryList(ECategoryType type); - int m_GetPlaylistSongList(CCategoryInfo *catinfo); - int m_GetFolderSongList(CFolderInfo *finfo); int m_GetFolderList(void); - int m_GetAlbumSongList(CAlbumInfo *alinfo); int m_GetAlbumList(void); - int m_GetSongList(void); void m_UpdateLists(void); public: diff --git a/src/data/CategoryStorage.cpp b/src/data/CategoryStorage.cpp index 7e7b946..4ea93bd 100644 --- a/src/data/CategoryStorage.cpp +++ b/src/data/CategoryStorage.cpp @@ -135,14 +135,13 @@ bool CPlaylistStorage::m_OnEachPlaylist(media_playlist_h ph) int categoryId = 0; int songCount = 0; _CHECK(catinfo = new CCategoryInfo) - _CHECK(catinfo->Create()) - _CHECK(media_playlist_get_name(ph, &tmpStr) == MEDIA_CONTENT_ERROR_NONE) - _CHECK(media_playlist_get_playlist_id(ph, &categoryId) == MEDIA_CONTENT_ERROR_NONE) - _CHECK(media_playlist_get_media_count_from_db(catinfo->CategoryId(), NULL, &songCount) == MEDIA_CONTENT_ERROR_NONE) - _CHECK(media_playlist_foreach_media_from_db(catinfo->CategoryId(), NULL, - sm_CbPlaylistMember, (void *)catinfo) == MEDIA_CONTENT_ERROR_NONE) - - _WHEN_SUCCESS{ + _CHECK(catinfo->Create()) + _CHECK(media_playlist_get_name(ph, &tmpStr) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_playlist_get_playlist_id(ph, &categoryId) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_playlist_get_media_count_from_db(catinfo->CategoryId(), NULL, &songCount) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_playlist_foreach_media_from_db(catinfo->CategoryId(), NULL, sm_CbPlaylistMember, (void *)catinfo) == MEDIA_CONTENT_ERROR_NONE) + + _WHEN_SUCCESS { catinfo->SetName(tmpStr); catinfo->SetCategoryId(categoryId); catinfo->SetSongCount(songCount); diff --git a/src/data/SongStorage.cpp b/src/data/SongStorage.cpp new file mode 100644 index 0000000..7f33e23 --- /dev/null +++ b/src/data/SongStorage.cpp @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include +#include "dbg.h" +#include "i18n.h" +#include "define.h" + +#include +#include "song_info.h" +#include "album_info.h" +#include "category_info.h" +#include "folder_info.h" +#include "SongStorage.h" +#include "common.h" + + +bool CSongStorage::sm_CbOnEachSong(media_info_h mh, void *dt) +{ + CSongStorage *root = (CSongStorage *)dt; + bool r = false; + if (root) + r = root->m_OnEachSong(mh); + + return r; +} + + +bool CSongStorage::m_OnEachSong(media_info_h mh) +{ + _CREATE_BEGIN { + CSongInfo *songInfo = NULL; + audio_meta_h audio_h = NULL; + char *filePath; + char *thumbnailPath; + int mediaType; + char *mediaId; + char *title; + char *artist; + char *album; + char *genre; + char *composer; + int duration; + + _CHECK(songInfo = new CSongInfo) + _CHECK(songInfo->Create()) + _CHECK(media_info_get_file_path(mh, &filePath) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_info_get_thumbnail_path(mh, &thumbnailPath) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_info_get_media_type(mh, (media_content_type_e *)&mediaType) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_info_get_audio(mh, &audio_h) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(audio_meta_get_media_id(audio_h, &mediaId) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_info_get_title(mh, &title) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(audio_meta_get_artist(audio_h, &artist) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(audio_meta_get_album(audio_h, &album) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(audio_meta_get_genre(audio_h, &genre) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(audio_meta_get_composer(audio_h, &composer) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(audio_meta_get_duration(audio_h, &duration) == MEDIA_CONTENT_ERROR_NONE) + + + _WHEN_SUCCESS { + songInfo->SetPath(filePath); + songInfo->SetThumbnailPath(thumbnailPath); + songInfo->SetType(mediaType); + songInfo->SetId(mediaId); + songInfo->SetName(title); + songInfo->SetArtist(artist); + songInfo->SetAlbum(album); + songInfo->SetGenre(genre); + songInfo->SetComposer(composer); + songInfo->SetDuration(duration); + + audio_meta_destroy(audio_h); + + switch (t_type) { + case SONGS_SONG_STORAGE: + case ALBUM_SONG_STORAGE: + case FOLDER_SONG_STORAGE: + elList = eina_list_append(elList, songInfo); + break; + + case PLAYLIST_SONG_STORAGE: + songInfo->SetMemberId(t_memberId); + elList = eina_list_append(elList, songInfo); + break; + + case SINGLE_SONG_STORAGE: + t_songInfo = songInfo; + break; + + default: + _ERR("Invalid Song Storage Type!!"); + ASSERT(0); + break; + } + } + + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{ audio_meta_destroy(audio_h); } + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{} + _CHECK_FAIL{ songInfo->Destroy(); } + _CHECK_FAIL{ delete songInfo; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; +} + + +bool CSongStorage::t_GetSongList(CNameInfo *info, filter_h filter) +{ + int r; + + switch (t_type) { + case SONGS_SONG_STORAGE: + case SINGLE_SONG_STORAGE: + { + r = media_info_foreach_media_from_db(filter, + sm_CbOnEachSong, (void *)this); + if (r != MEDIA_CONTENT_ERROR_NONE) { + _ERR("media_info_foreach_media_from_db failed"); + return false; + } + } + break; + + case ALBUM_SONG_STORAGE: + { + ASSERT(info); + CAlbumInfo *alinfo = (CAlbumInfo *)info; + + r = media_album_foreach_media_from_db(alinfo->AlbumId(), filter, + sm_CbOnEachSong, (void *)this); + if (r != MEDIA_CONTENT_ERROR_NONE) { + _ERR("media_album_foreach_media_from_db failed"); + return false; + } + } + break; + + case FOLDER_SONG_STORAGE: + { + ASSERT(info); + CFolderInfo *finfo = (CFolderInfo *)info; + + r = media_folder_foreach_media_from_db(finfo->Id(), filter, + sm_CbOnEachSong, (void *)this); + if (r != MEDIA_CONTENT_ERROR_NONE) { + _ERR("media_folder_foreach_media_from_db failed"); + return false; + } + } + break; + + case PLAYLIST_SONG_STORAGE: + { + ASSERT(info); + CCategoryInfo *catinfo = (CCategoryInfo *)info; + CCategoryInfo::CListMember *member = NULL; + media_info_h mdh; + Eina_List *l = NULL; + void *obj = NULL; + int r; + + if (!catinfo->MemberList()) { + _DBG("Playlist is empty"); + return false; + } + + EINA_LIST_FOREACH(catinfo->MemberList(), l, obj) { + member = (CCategoryInfo::CListMember *)obj; + if (!member->mediaId) + continue; + + r = media_info_get_media_from_db(member->mediaId, &mdh); + if (r != MEDIA_CONTENT_ERROR_NONE) { + _ERR("unable to get handle from id"); + continue; + } + + t_memberId = member->memberId; + if (!m_OnEachSong(mdh)) { + _ERR("unable to get media data"); + return false; + } + } + } + break; + + default: + _ERR("Invalid Song Storage Type!!"); + ASSERT(0); + break; + } + + return true; +} + + +Eina_List *CSongStorage::List(void) +{ + return elList; +} + + +void CSongStorage::Delete(void) +{ + if (!elList) + return; + + CSongInfo *songInfo = NULL; + void *obj = NULL; + + EINA_LIST_FREE(elList, obj) { + songInfo = (CSongInfo *)obj; + songInfo->Destroy(); + delete songInfo; + } + + elList = NULL; +} + + +bool CSongsSongStorage::Update(filter_h filter) +{ + Delete(); + t_GetSongList(NULL, filter); + return true; +} + + +bool CAlbumSongStorage::Update(CAlbumInfo *alinfo, filter_h filter) +{ + Delete(); + t_GetSongList(alinfo, filter); + return true; +} + + +bool CFolderSongStorage::Update(CFolderInfo *finfo, filter_h filter) +{ + Delete(); + t_GetSongList(finfo, filter); + return true; +} + + +bool CPlaylistSongStorage::Update(CCategoryInfo *catinfo, filter_h filter) +{ + Delete(); + t_GetSongList(catinfo, filter); + return true; +} + + +CSongInfo *CSingleSongStorage::SongInfo(filter_h filter) +{ + Delete(); + t_GetSongList(NULL, filter); + return t_songInfo; +} \ No newline at end of file diff --git a/src/data/mediadata.cpp b/src/data/mediadata.cpp index 6893576..9cf3bb9 100644 --- a/src/data/mediadata.cpp +++ b/src/data/mediadata.cpp @@ -29,6 +29,7 @@ #include "category_info.h" #include "folder_info.h" #include "CategoryStorage.h" +#include "SongStorage.h" #include "mediadata.h" #include "common.h" @@ -48,19 +49,19 @@ enum songlist_type { struct SMediadata { - Eina_List *songlist; Eina_List *folderlist; - Eina_List *folder_songlist; Eina_List *albumlist; - Eina_List *album_songlist; - //Eina_List *categoryList[CAT_TYPE_MAX]; + CSongsSongStorage *storageSong; + CAlbumSongStorage *storageAlbumSong; + CFolderSongStorage *storageFolderSong; + CPlaylistSongStorage *storagePlaylistSong; + CSingleSongStorage *storageSingleSong; CPlaylistStorage *storagePlaylist; CArtistStorage *storageArtist; CGenreStorage *storageGenre; - Eina_List *playlist_songlist; Eina_List *cblist; CSongInfo *songInfo; filter_h filter; @@ -70,6 +71,11 @@ struct SMediadata { SMediadata() { memset(this, 0, sizeof(SMediadata)); + storageSong = new CSongsSongStorage; + storageFolderSong = new CFolderSongStorage; + storageAlbumSong = new CAlbumSongStorage; + storagePlaylistSong = new CPlaylistSongStorage; + storageSingleSong = new CSingleSongStorage; storagePlaylist = new CPlaylistStorage; storageArtist = new CArtistStorage; storageGenre = new CGenreStorage; @@ -78,6 +84,11 @@ struct SMediadata { delete storageGenre; delete storageArtist; delete storagePlaylist; + delete storageSingleSong; + delete storagePlaylistSong; + delete storageAlbumSong; + delete storageFolderSong; + delete storageSong; } }; @@ -252,19 +263,6 @@ bool CMediadata::sm_CbTotalDuration(media_info_h md_h, void *dt) } -bool CMediadata::sm_CbEachMediaData(media_info_h md_h, void *dt) -{ - CMediadata *root = (CMediadata *)dt; - - if (!root) - return false; - - root->m_HandleEachMediaData(md_h); - - return true; -} - - bool CMediadata::sm_CbEachFolderData(media_folder_h folder_h, void *dt) { CMediadata *root = (CMediadata *)dt; @@ -325,127 +323,6 @@ bool CMediadata::sm_CbPlaylist(media_playlist_h ph, void* dt) } -bool CMediadata::m_HandleEachMediaData(media_info_h md_h) -{ - CSongInfo *songInfo = NULL; - audio_meta_h audio_h = NULL; - char* tmpStr = NULL; - int tmpValue; - bool ret; - - songInfo = new CSongInfo; - if (!songInfo) { - _ERR("Memory alloc failed"); - return false; - } - - ret = songInfo->Create(); - if (!ret) { - _ERR("CSongInfo creation failed"); - delete songInfo; - return false; - } - - if (media_info_get_file_path(md_h, &tmpStr) - != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Media file path Fetch error"); - songInfo->Destroy(); - delete songInfo; - return false; - } - songInfo->SetPath(tmpStr); - - if (media_info_get_thumbnail_path(md_h, &tmpStr) != - MEDIA_CONTENT_ERROR_NONE) - _ERR("Media thumbnail path Fetch error"); - songInfo->SetThumbnailPath(tmpStr); - - if (media_info_get_media_type(md_h, - (media_content_type_e *)&tmpValue) != - MEDIA_CONTENT_ERROR_NONE) - _ERR("Media type Fetch error"); - songInfo->SetType(tmpValue); - - if (media_info_get_audio(md_h, &audio_h) != - MEDIA_CONTENT_ERROR_NONE) { - _ERR("Media info get audio error"); - songInfo->Destroy(); - delete songInfo; - return false; - } - - if (audio_meta_get_media_id(audio_h, &tmpStr) != - MEDIA_CONTENT_ERROR_NONE) { - _ERR("Media ID Fetch error"); - audio_meta_destroy(audio_h); - songInfo->Destroy(); - delete songInfo; - return false; - } - songInfo->SetId(tmpStr); - - if (media_info_get_title(md_h, &tmpStr) != - MEDIA_CONTENT_ERROR_NONE) - _ERR("audio title get error"); - songInfo->SetName(tmpStr); - - if (audio_meta_get_artist(audio_h, &tmpStr) != - MEDIA_CONTENT_ERROR_NONE) - _ERR("audio artist get error"); - songInfo->SetArtist(tmpStr); - - if (audio_meta_get_album(audio_h, &tmpStr) != - MEDIA_CONTENT_ERROR_NONE) - _ERR("audio album get error"); - songInfo->SetAlbum(tmpStr); - - if (audio_meta_get_genre(audio_h, &tmpStr) != - MEDIA_CONTENT_ERROR_NONE) - _ERR("audio genre get error"); - songInfo->SetGenre(tmpStr); - - if (audio_meta_get_composer(audio_h, &tmpStr) != - MEDIA_CONTENT_ERROR_NONE) - _ERR("audio composer get error"); - songInfo->SetComposer(tmpStr); - - if (audio_meta_get_duration(audio_h, &tmpValue) != - MEDIA_CONTENT_ERROR_NONE) - _ERR("audio duration get error"); - songInfo->SetDuration(tmpValue); - - audio_meta_destroy(audio_h); - - switch (m->slist_type) { - case E_FOLDER_SONGS: - m->folder_songlist = eina_list_append( - m->folder_songlist, songInfo); - break; - - case E_ALBUM_SONGS: - m->album_songlist = eina_list_append( - m->album_songlist, songInfo); - break; - - case E_PLAYLIST_SONGS: - songInfo->SetMemberId(m->member_id); - m->playlist_songlist = eina_list_append( - m->playlist_songlist, songInfo); - break; - - case E_SINGLE_SONG: - m->songInfo = songInfo; - break; - - case E_ALL_SONGS: - default: - m->songlist = eina_list_append(m->songlist, songInfo); - break; - } - return true; -} - - bool CMediadata::m_HandleEachFolderData(media_folder_h folder_h) { CFolderInfo *finfo = NULL; @@ -567,12 +444,9 @@ bool CMediadata::m_HandleEachAlbumData(media_album_h album_h) } alinfo->SetSongCount(tmpValue); - if (m->album_songlist) - m_DeleteAlbumSongList(); + m->storageAlbumSong->Update(alinfo, m->filter); - m_GetAlbumSongList(alinfo); - - EINA_LIST_FOREACH(m->album_songlist, l, obj) { + EINA_LIST_FOREACH(m->storageAlbumSong->List(), l, obj) { songInfo = (CSongInfo *)obj; tmpStr = songInfo->Genre(); if (tmpStr) { @@ -581,7 +455,7 @@ bool CMediadata::m_HandleEachAlbumData(media_album_h album_h) } } - EINA_LIST_FOREACH(m->album_songlist, l, obj) { + EINA_LIST_FOREACH(m->storageAlbumSong->List(), l, obj) { songInfo = (CSongInfo *)obj; tmpStr = songInfo->ThumbnailPath(); if (tmpStr) { @@ -594,76 +468,6 @@ bool CMediadata::m_HandleEachAlbumData(media_album_h album_h) return true; } -void CMediadata::m_DeleteSongList(void) -{ - if (!m->songlist) - return; - - CSongInfo *songInfo = NULL; - void *obj = NULL; - - EINA_LIST_FREE(m->songlist, obj) { - songInfo = (CSongInfo *)obj; - songInfo->Destroy(); - delete songInfo; - } - - m->songlist = NULL; -} - - -void CMediadata::m_DeleteFolderSongList(void) -{ - CSongInfo *songInfo = NULL; - void *obj = NULL; - - if (!m->folder_songlist) - return; - - EINA_LIST_FREE(m->folder_songlist, obj) { - songInfo = (CSongInfo *)obj; - songInfo->Destroy(); - delete songInfo; - } - - m->folder_songlist = NULL; -} - - -void CMediadata::m_DeleteAlbumSongList(void) -{ - CSongInfo *songInfo = NULL; - void *obj = NULL; - if (!m->album_songlist) - return; - - EINA_LIST_FREE(m->album_songlist, obj) { - songInfo = (CSongInfo *)obj; - songInfo->Destroy(); - delete songInfo; - } - - m->album_songlist = NULL; -} - - -void CMediadata::m_DeletePlaylistSongList(void) -{ - CSongInfo *songInfo = NULL; - void *obj = NULL; - - if (!m->playlist_songlist) - return; - - EINA_LIST_FREE(m->playlist_songlist, obj) { - songInfo = (CSongInfo *)obj; - songInfo->Destroy(); - delete songInfo; - } - - m->playlist_songlist = NULL; -} - void CMediadata::m_DeleteFolderList(void) { @@ -760,7 +564,6 @@ void CMediadata::m_DestroyFilter(void) } - void CMediadata::m_GetCategoryList(ECategoryType type) { CAlbumInfo *alinfo = NULL; @@ -821,60 +624,6 @@ void CMediadata::m_GetCategoryList(ECategoryType type) } -int CMediadata::m_GetPlaylistSongList(CCategoryInfo *catinfo) -{ - media_info_h mdh; - Eina_List *l = NULL; - CCategoryInfo::CListMember *member = NULL; - void *obj = NULL; - int r; - - if (!catinfo || !catinfo->MemberList()) { - _ERR(" Invalid argument "); - return false; - } - - m->slist_type = E_PLAYLIST_SONGS; - - EINA_LIST_FOREACH(catinfo->MemberList(), l, obj) { - member = (CCategoryInfo::CListMember *)obj; - if (!member->mediaId) - continue; - - r = media_info_get_media_from_db(member->mediaId, &mdh); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR("unable to get handle from id"); - continue; - } - - m->member_id = member->memberId; - if (!m_HandleEachMediaData(mdh)) - _ERR("unable to get media data"); - } - - return true; -} - - -int CMediadata::m_GetFolderSongList(CFolderInfo *finfo) -{ - char *id = NULL; - int r; - - id = finfo->Id(); - - m->slist_type = E_FOLDER_SONGS; - r = media_folder_foreach_media_from_db(id, m->filter, - sm_CbEachMediaData, (void *)this); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Media folder foreach folder from db failed"); - return false; - } - - return true; -} - - int CMediadata::m_GetFolderList(void) { int r; @@ -890,25 +639,6 @@ int CMediadata::m_GetFolderList(void) } -int CMediadata::m_GetAlbumSongList(CAlbumInfo *alinfo) -{ - int id; - int r; - - id = alinfo->AlbumId(); - - m->slist_type = E_ALBUM_SONGS; - r = media_album_foreach_media_from_db(id, m->filter, - sm_CbEachMediaData, (void *)this); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Media folder foreach folder from db failed"); - return false; - } - - return true; -} - - int CMediadata::m_GetAlbumList(void) { int r; @@ -924,22 +654,6 @@ int CMediadata::m_GetAlbumList(void) } -int CMediadata::m_GetSongList(void) -{ - int r; - - m->slist_type = E_ALL_SONGS; - r = media_info_foreach_media_from_db(m->filter, - sm_CbEachMediaData, (void *)this); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Media folder foreach folder from db failed"); - return false; - } - - return true; -} - - void CMediadata::m_UpdateLists(void) { bool r; @@ -950,8 +664,7 @@ void CMediadata::m_UpdateLists(void) return; } - m_DeleteSongList(); - m_GetSongList(); + m->storageSong->Update(m->filter); m_DeleteAlbumList(); m_GetAlbumList(); @@ -998,15 +711,16 @@ void CMediadata::Destroy(void) struct SCbInfo *cbinfo; void *obj; - m_DeleteSongList(); + m->storageSong->Delete(); m_DeleteAlbumList(); - m_DeleteAlbumSongList(); + m->storageAlbumSong->Delete(); m_DeleteFolderList(); - m_DeleteFolderSongList(); + m->storageFolderSong->Delete(); m_DeleteCategoryList(CAT_TYPE_ARTIST); m_DeleteCategoryList(CAT_TYPE_GENRE); m_DeleteCategoryList(CAT_TYPE_PLAYLISTS); - m_DeletePlaylistSongList(); + m->storagePlaylistSong->Delete(); + if (m->songInfo && m->songInfo->FlagCreate()) m->songInfo->Destroy(); delete m->songInfo; @@ -1092,14 +806,7 @@ CSongInfo *CMediadata::SongByUri(char *uri) media_filter_set_condition(filter, buf, MEDIA_CONTENT_COLLATE_DEFAULT); - m->slist_type = E_SINGLE_SONG; - r = media_info_foreach_media_from_db(filter, sm_CbEachMediaData, - (void *)this); - if (r != MEDIA_CONTENT_ERROR_NONE) - _ERR("Failed to fetch media info"); - - if (media_filter_destroy(filter) != MEDIA_CONTENT_ERROR_NONE) - _ERR("Filter destroy failed"); + m->songInfo = m->storageSingleSong->SongInfo(filter); return m->songInfo; } @@ -1116,23 +823,21 @@ Eina_List *CMediadata::Medialist(int source_type, int listType, void *info) switch (listType) { case LIST_TYPE_SONG: - return m->songlist; + return m->storageSong->List(); case LIST_TYPE_ALBUM: return m->albumlist; case LIST_TYPE_ALBUM_SONG: - m_DeleteAlbumSongList(); - m_GetAlbumSongList((CAlbumInfo *)info); - return m->album_songlist; + m->storageAlbumSong->Update((CAlbumInfo *)info, m->filter); + return m->storageAlbumSong->List(); case LIST_TYPE_FOLDER: return m->folderlist; case LIST_TYPE_FOLDER_SONG: - m_DeleteFolderSongList(); - m_GetFolderSongList((CFolderInfo *)info); - return m->folder_songlist; + m->storageFolderSong->Update((CFolderInfo *)info, m->filter); + return m->storageFolderSong->List(); case LIST_TYPE_ARTIST: return m->storageArtist->List(); @@ -1145,9 +850,8 @@ Eina_List *CMediadata::Medialist(int source_type, int listType, void *info) return m->storagePlaylist->List(); case LIST_TYPE_PLAYLISTS_SONG: - m_DeletePlaylistSongList(); - m_GetPlaylistSongList((CCategoryInfo *)info); - return m->playlist_songlist; + m->storagePlaylistSong->Update((CCategoryInfo *)info, m->filter); + return m->storagePlaylistSong->List(); default: _ERR(" Wrong list type "); -- 2.7.4 From 6d5b8ca8627090b17fcd102b477305b6dad55d96 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Thu, 12 Mar 2015 08:31:45 +0900 Subject: [PATCH 15/16] Fix bug. Playlist should be updated in playback view when playback view is pushed. Change-Id: I7023688d375f4bd6af0d9784f4328fb634506a6a Signed-off-by: Kim Tae Soo --- src/views/base-view.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/views/base-view.cpp b/src/views/base-view.cpp index 0e2ee52..e92bf0e 100644 --- a/src/views/base-view.cpp +++ b/src/views/base-view.cpp @@ -312,7 +312,13 @@ void CMusicBaseView::m_ShowCurrentLayout(void) void CMusicBaseView::m_GotoPlayback(void) { - if (!CViewMgr::GetInstance()->PushView(MUSIC_PLAYBACK_VIEW, NULL)) + SParcel parcel; + parcel.ctxtInfo = NULL; + parcel.updateType = E_PLAYLIST_UPDATE; + parcel.layoutId = NULL; + parcel.keyEvent = NULL; + + if (!CViewMgr::GetInstance()->PushView(MUSIC_PLAYBACK_VIEW, &parcel)) _ERR(" viewmgr push view MUSIC_PLAYBACK_VIEW failed "); } -- 2.7.4 From c75a119b7d2c159ae386f2b936d56f8583e1f9c8 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Thu, 12 Mar 2015 09:33:18 +0900 Subject: [PATCH 16/16] Apply modification of CBaseView Change-Id: I1fee3cb6b99adcab026ae1eb41d95c41ac851594 Signed-off-by: Kim Tae Soo --- include/base-view.h | 5 +---- include/context-view.h | 5 +---- include/playback-view.h | 13 +++++++------ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/include/base-view.h b/include/base-view.h index 04873d8..5a86149 100644 --- a/include/base-view.h +++ b/include/base-view.h @@ -28,8 +28,7 @@ struct SArgList { }; -class CMusicBaseView : public CBaseView, public CListenerMgr, - public IKeyDownListener, public IKeyUpListener, +class CMusicBaseView : public CBaseView, public IMouseMoveListener, public IMouseClickedListener, public IMusicControllerListener { @@ -73,8 +72,6 @@ protected: public: CMusicBaseView(const char *pViewId) : CBaseView(pViewId), - IKeyDownListener(this), - IKeyUpListener(this), IMouseMoveListener(this), IMouseClickedListener(this), m(0) {} diff --git a/include/context-view.h b/include/context-view.h index caf007c..41331f1 100644 --- a/include/context-view.h +++ b/include/context-view.h @@ -24,8 +24,7 @@ struct SContentInfo; struct SRltvCtnt; -class CContextView : public CBaseView, public CListenerMgr, - public IKeyDownListener, public IKeyUpListener, +class CContextView : public CBaseView, public IMouseMoveListener, public IMouseUpListener, public IFocusedListener, public IUnfocusedListener { private: @@ -95,8 +94,6 @@ protected: public: CContextView(const char *pViewId) : CBaseView(pViewId), - IKeyDownListener(this), - IKeyUpListener(this), IMouseMoveListener(this), IMouseUpListener(this), IFocusedListener(this), diff --git a/include/playback-view.h b/include/playback-view.h index 7f07ffa..a1e36a3 100644 --- a/include/playback-view.h +++ b/include/playback-view.h @@ -25,11 +25,12 @@ struct SItemInfo; -class CPlaybackView : public CBaseView, CListenerMgr, - IKeyDownListener, IKeyUpListener, IMouseClickedListener, IMouseMoveListener, - IPressedListener, IUnpressedListener, IChangedListener, IRealizedListener, IUnrealizedListener, - IActivatedListener, - IMusicControllerListener { +class CPlaybackView : public CBaseView, + public IMouseClickedListener, public IMouseMoveListener, + public IPressedListener, public IUnpressedListener, + public IChangedListener, public IRealizedListener, + public IUnrealizedListener, public IActivatedListener, + public IMusicControllerListener { private: struct SPlaybackView* m; @@ -126,7 +127,7 @@ protected: public: CPlaybackView(const char *pViewId) : CBaseView(pViewId), - IKeyDownListener(this), IKeyUpListener(this), IMouseClickedListener(this), IMouseMoveListener(this), + IMouseClickedListener(this), IMouseMoveListener(this), IPressedListener(this), IUnpressedListener(this), IChangedListener(this), IRealizedListener(this), IUnrealizedListener(this), IActivatedListener(this), m(0) {} -- 2.7.4