src/data/category_info.cpp
src/data/folder_info.cpp
src/data/bus.cpp
+ src/data/CategoryStorage.cpp
)
SET(TARGET_EDJ "${PROJECT_NAME}.edj")
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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 <Eina.h>
+#include <media_content.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include <string.h>
+#include "dbg.h"
+#include "i18n.h"
+#include "define.h"
+
+#include <AppCommon.h>
+#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;
+}
#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,
};
-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;
};
-
-
bool CPlaylistMgr::Alloc(const char *name, Eina_List *elIdList)
{
ASSERT(name);
if (!m->albumlist)
return;
- CStorage *stg = NULL;
+ CCategoryStorage *stg = NULL;
if (type == CAT_TYPE_ARTIST)
stg = m->storageArtist;
else