From 586465d88b100637a634b821dc2cd492d9924472 Mon Sep 17 00:00:00 2001 From: Kim Tae Soo Date: Sat, 14 Mar 2015 18:08:58 +0900 Subject: [PATCH] Fix Bug (Playlist creation failed) Change-Id: If010ef836760f313b6bdc140f2e41cdd93243571 Signed-off-by: Kim Tae Soo --- include/category-songs-layout.h | 8 +++++++- src/data/CategoryStorage.cpp | 10 +++++----- src/data/mediadata.cpp | 25 ++++++++++++++----------- src/views/category-layout.cpp | 14 +++++++++++--- src/views/category-songs-layout.cpp | 15 +++++++++------ 5 files changed, 46 insertions(+), 26 deletions(-) diff --git a/include/category-songs-layout.h b/include/category-songs-layout.h index 37586ca..418db0b 100644 --- a/include/category-songs-layout.h +++ b/include/category-songs-layout.h @@ -19,7 +19,6 @@ #include "category-layout.h" -struct SCategorySongsItemsInfo; class CCategorySongsLayout : public CExtBaseLayout, public CListenerMgr, public IKeyDownListener, public IMouseMoveListener, public IMouseClickedListener, @@ -37,6 +36,12 @@ public: SELECT_TYPE_REMOVE }; + struct SCategorySongsItemsInfo { + CSongInfo *sinfo; + Elm_Object_Item *item; + bool check_status; + }; + private: struct SCategorySongsLayout *m; @@ -95,6 +100,7 @@ public: virtual void Destroy(void); void SetParameter(EDepth depth, ESelectType selType, CCategoryInfo *catInfo, CAlbumInfo *albumInfo); + Eina_List *CategorySongItemInfoList(void); public: virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev); diff --git a/src/data/CategoryStorage.cpp b/src/data/CategoryStorage.cpp index e059c59..0e3642e 100644 --- a/src/data/CategoryStorage.cpp +++ b/src/data/CategoryStorage.cpp @@ -91,18 +91,18 @@ bool CCategoryStorage::m_OnEachPlaylist(media_playlist_h ph) _CREATE_BEGIN{ CCategoryInfo *catinfo = NULL; - char *tmpStr = NULL; + char *name = 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_name(ph, &name) == 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) + _CHECK(media_playlist_get_media_count_from_db(categoryId, NULL, &songCount) == MEDIA_CONTENT_ERROR_NONE) + _CHECK(media_playlist_foreach_media_from_db(categoryId, NULL, sm_CbPlaylistMember, (void *)catinfo) == MEDIA_CONTENT_ERROR_NONE) _WHEN_SUCCESS{ - catinfo->SetName(tmpStr); + catinfo->SetName(name); catinfo->SetCategoryId(categoryId); catinfo->SetSongCount(songCount); elList = eina_list_append(elList, catinfo); diff --git a/src/data/mediadata.cpp b/src/data/mediadata.cpp index 9e4199a..d534bdf 100644 --- a/src/data/mediadata.cpp +++ b/src/data/mediadata.cpp @@ -95,26 +95,29 @@ bool CPlaylistMgr::Alloc(const char *name, Eina_List *elIdList) ASSERT(name); ASSERT(elIdList); + media_playlist_h ph = NULL; bool ret = false; - media_playlist_h ph; - if (media_playlist_insert_to_db(name, &ph) == MEDIA_CONTENT_ERROR_NONE) { + int r; + + r = media_playlist_insert_to_db(name, &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_add_media(ph, id); + if (r != MEDIA_CONTENT_ERROR_NONE) + return false; } - if (media_playlist_update_to_db(ph) == MEDIA_CONTENT_ERROR_NONE) { + r = media_playlist_update_to_db(ph); + if (r == 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"); + else + _ERR("CPlaylist::Insert failed. (media_playlist_update_to_db)"); } + else + _ERR("CPlaylist::Insert failed. (media_playlist_insert_to_db)"); return ret; } diff --git a/src/views/category-layout.cpp b/src/views/category-layout.cpp index bf46bb5..ec2a074 100644 --- a/src/views/category-layout.cpp +++ b/src/views/category-layout.cpp @@ -158,7 +158,7 @@ void CCategoryLayout::m_OnEntrynameSet(const char *name) if (!name) return; - idlist = m_GetSelectedList(m->it_infolist, (int)ID_TYPE_MEDIA); + idlist = m_GetSelectedList(m->layoutCatSongs->CategorySongItemInfoList(), (int)ID_TYPE_MEDIA); str = strdup(name); t.epopup->Destroy(); @@ -180,8 +180,16 @@ void CCategoryLayout::m_OnEntrynameSet(const char *name) return; } + free(str); t.depth = E_DEPTH_CATEGORY; t_UpdateLayoutWithFocus(); + + SParcel parcel; + parcel.ctxtInfo = NULL; + parcel.updateType = E_DEPTH_UPDATE; + parcel.layoutId = MUSIC_CATEGORY_PLAYLISTS_SONGS_LAYOUT; + parcel.keyEvent = NULL; + m->vmgr->UpdateView((const char *)MUSIC_BASE_VIEW, &parcel); } @@ -599,7 +607,7 @@ void CCategoryLayout::m_GotoPlayback(int mode, char *id) Eina_List *CCategoryLayout::m_GetSelectedList(Eina_List *infolist, int type) { Eina_List *idlist = NULL, *l = NULL; - SCatItemInfo *itinfo = NULL; + CCategorySongsLayout::SCategorySongsItemsInfo *itinfo = NULL; void *obj = NULL; char *id = NULL; EIdType eType = (EIdType)type; @@ -609,7 +617,7 @@ Eina_List *CCategoryLayout::m_GetSelectedList(Eina_List *infolist, int type) idlist = NULL; EINA_LIST_FOREACH(infolist, l, obj) { - itinfo = (SCatItemInfo *)obj; + itinfo = (CCategorySongsLayout::SCategorySongsItemsInfo *)obj; if (!itinfo->check_status) continue; diff --git a/src/views/category-songs-layout.cpp b/src/views/category-songs-layout.cpp index 58099e9..4da5a47 100644 --- a/src/views/category-songs-layout.cpp +++ b/src/views/category-songs-layout.cpp @@ -69,11 +69,6 @@ enum EIdType { ID_TYPE_MEMBER }; -struct SCategorySongsItemsInfo { - CSongInfo *sinfo; - Elm_Object_Item *item; - bool check_status; -}; struct SCategorySongsLayout { Evas_Object *win; @@ -381,7 +376,7 @@ void CCategorySongsLayout::m_RemoveFocusIdler(void) } -SCategorySongsItemsInfo *CCategorySongsLayout::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item) +CCategorySongsLayout::SCategorySongsItemsInfo *CCategorySongsLayout::m_FindItemInfoFromItem(Eina_List *list, Elm_Object_Item *item) { Eina_List *l = NULL; SCategorySongsItemsInfo *itinfo = NULL; @@ -952,6 +947,14 @@ void CCategorySongsLayout::SetParameter(EDepth depth, ESelectType selType, CCate } +Eina_List *CCategorySongsLayout::CategorySongItemInfoList(void) +{ + ASSERT(m); + + return m->it_infolist; +} + + void CCategorySongsLayout::t_OnShow(void) { ASSERT(m); -- 2.7.4