src/data/bus.cpp
src/data/CategoryStorage.cpp
src/data/SongStorage.cpp
+ src/data/AlbumStorage.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 __ALBUM_STORAGE_H__
+#define __ALBUM_STORAGE_H__
+
+#include "SongStorage.h"
+
+class CAlbumStorage {
+private:
+ Eina_List *elList;
+ filter_h m_filter;
+ CAlbumSongStorage *m_storageAlbumSong;
+
+private:
+ static bool sm_CbOnEachAlbum(media_album_h ah, void *dt);
+ bool m_OnEachAlbum(media_album_h ah);
+ virtual bool m_GetAlbumList(void);
+
+public:
+ CAlbumStorage(CAlbumSongStorage *storageAlbumSong) {
+ elList = NULL;
+ m_storageAlbumSong = storageAlbumSong;
+ }
+ virtual ~CAlbumStorage() {}
+
+ Eina_List *List(void);
+ void Delete(void);
+
+ bool Update(filter_h filter);
+};
+
+#endif //__ALBUM_STORAGE_H__
\ No newline at end of file
private:
static bool sm_CbTotalDuration(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_HandleEachFolderData(media_folder_h folder_h);
- bool m_HandleEachAlbumData(media_album_h album_h);
void m_DeleteFolderList(void);
- void m_DeleteAlbumList(void);
void m_DeleteCategoryList(ECategoryType type);
bool m_CreateFilter(void);
void m_GetCategoryList(ECategoryType type);
int m_GetFolderList(void);
- int m_GetAlbumList(void);
void m_UpdateLists(void);
public:
--- /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 "SongStorage.h"
+#include "AlbumStorage.h"
+#include "common.h"
+
+
+bool CAlbumStorage::sm_CbOnEachAlbum(media_album_h ah, void *dt)
+{
+ CAlbumStorage *root = (CAlbumStorage *)dt;
+ bool r = false;
+ if (root)
+ r = root->m_OnEachAlbum(ah);
+
+ return r;
+}
+
+
+bool CAlbumStorage::m_OnEachAlbum(media_album_h ah)
+{
+ _CREATE_BEGIN {
+ CAlbumInfo *alinfo = NULL;
+ CSongInfo *songInfo = NULL;
+ Eina_List *l = NULL;
+ void *obj = NULL;
+ int albumId;
+ char *name;
+ char *artist;
+ int songCount;
+ char *genre;
+ char *thumbnailPath;
+
+ _CHECK(alinfo = new CAlbumInfo)
+ _CHECK(alinfo->Create())
+ _CHECK(media_album_get_album_id(ah, &albumId) == MEDIA_CONTENT_ERROR_NONE)
+ _CHECK(media_album_get_name(ah, &name) == MEDIA_CONTENT_ERROR_NONE)
+ _CHECK(media_album_get_artist(ah, &artist) == MEDIA_CONTENT_ERROR_NONE)
+ _CHECK(media_album_get_media_count_from_db(alinfo->AlbumId(), m_filter, &songCount))
+
+ _WHEN_SUCCESS{
+ alinfo->SetAlbumId(albumId);
+ alinfo->SetName(name);
+ alinfo->SetArtist(artist);
+ alinfo->SetSongCount(songCount);
+
+ m_storageAlbumSong->Update(alinfo, m_filter);
+
+ EINA_LIST_FOREACH(m_storageAlbumSong->List(), l, obj) {
+ songInfo = (CSongInfo *)obj;
+ genre = songInfo->Genre();
+ if (genre) {
+ alinfo->SetGenre(genre);
+ break;
+ }
+ }
+
+ EINA_LIST_FOREACH(m_storageAlbumSong->List(), l, obj) {
+ songInfo = (CSongInfo *)obj;
+ thumbnailPath = songInfo->ThumbnailPath();
+ if (thumbnailPath) {
+ alinfo->SetThumbnailPath(thumbnailPath);
+ break;
+ }
+ }
+
+ elList = eina_list_append(elList, alinfo);
+ }
+
+ _CHECK_FAIL{}
+ _CHECK_FAIL{}
+ _CHECK_FAIL{}
+ _CHECK_FAIL{}
+ _CHECK_FAIL{ alinfo->Destroy(); }
+ _CHECK_FAIL{ delete alinfo; }
+ } _CREATE_END_AND_CATCH{ return false; }
+
+ return true;
+}
+
+
+bool CAlbumStorage::m_GetAlbumList(void)
+{
+ int r;
+
+ r = media_album_foreach_album_from_db(m_filter,
+ sm_CbOnEachAlbum, (void *)this);
+ if (r != MEDIA_CONTENT_ERROR_NONE) {
+ _ERR("Media album foreach album from db failed");
+ return false;
+ }
+
+ return true;
+}
+
+
+Eina_List *CAlbumStorage::List(void)
+{
+ return elList;
+}
+
+
+void CAlbumStorage::Delete(void)
+{
+ if (!elList)
+ return;
+
+ CAlbumInfo *alinfo = NULL;
+ void *obj = NULL;
+
+ EINA_LIST_FREE(elList, obj) {
+ alinfo = (CAlbumInfo *)obj;
+ alinfo->Destroy();
+ delete alinfo;
+ }
+
+ elList = NULL;
+}
+
+
+bool CAlbumStorage::Update(filter_h filter)
+{
+ m_filter = filter;
+
+ Delete();
+ m_GetAlbumList();
+ return true;
+}
\ No newline at end of file
#include "folder_info.h"
#include "CategoryStorage.h"
#include "SongStorage.h"
+#include "AlbumStorage.h"
#include "mediadata.h"
#include "common.h"
#define MUSIC_STR_UNKNOWN N_("Unknown")
-enum songlist_type {
- E_ALL_SONGS,
- E_ALBUM_SONGS,
- E_FOLDER_SONGS,
- E_PLAYLIST_SONGS,
- E_SINGLE_SONG
-};
-
-
struct SMediadata {
Eina_List *folderlist;
- Eina_List *albumlist;
CSongsSongStorage *storageSong;
CAlbumSongStorage *storageAlbumSong;
CPlaylistSongStorage *storagePlaylistSong;
CSingleSongStorage *storageSingleSong;
+ CAlbumStorage *storageAlbum;
+
CPlaylistStorage *storagePlaylist;
CArtistStorage *storageArtist;
CGenreStorage *storageGenre;
storageAlbumSong = new CAlbumSongStorage;
storagePlaylistSong = new CPlaylistSongStorage;
storageSingleSong = new CSingleSongStorage;
+ storageAlbum = new CAlbumStorage(storageAlbumSong);
storagePlaylist = new CPlaylistStorage;
storageArtist = new CArtistStorage;
storageGenre = new CGenreStorage;
delete storageGenre;
delete storageArtist;
delete storagePlaylist;
+ delete storageAlbum;
delete storageSingleSong;
delete storagePlaylistSong;
delete storageAlbumSong;
}
-bool CMediadata::sm_CbEachAlbumData(media_album_h album_h, void *dt)
-{
- CMediadata *root = (CMediadata *)dt;
-
- if (!root)
- return false;
-
- root->m_HandleEachAlbumData(album_h);
-
- return true;
-}
-
-
-
bool CMediadata::sm_CbPlaylist(media_playlist_h ph, void* dt)
{
Eina_List **list = (Eina_List **)dt;
}
-bool CMediadata::m_HandleEachAlbumData(media_album_h album_h)
-{
- CAlbumInfo *alinfo = NULL;
- CSongInfo *songInfo = NULL;
- void *obj = NULL;
- char *tmpStr = NULL;
- int tmpValue;
- Eina_List *l = NULL;
- bool ret;
-
- alinfo = new CAlbumInfo;
- if (!alinfo) {
- _ERR("Memory alloc failed");
- return false;
- }
-
- ret = alinfo->Create();
- if (!ret) {
- _ERR("CAlbumInfo creation failed");
- delete alinfo;
- return false;
- }
-
- if (media_album_get_album_id(album_h, &tmpValue) !=
- MEDIA_CONTENT_ERROR_NONE) {
- _ERR("Album ID Fetch error");
- alinfo->Destroy();
- delete alinfo;
- return false;
- }
- alinfo->SetAlbumId(tmpValue);
-
- if (media_album_get_name(album_h, &tmpStr) !=
- MEDIA_CONTENT_ERROR_NONE) {
- _ERR("Album name Fetch error");
- alinfo->Destroy();
- delete alinfo;
- return false;
- }
- alinfo->SetName(tmpStr);
-
- if (media_album_get_artist(album_h, &tmpStr) !=
- MEDIA_CONTENT_ERROR_NONE) {
- _ERR("Album artist Fetch error");
- alinfo->Destroy();
- delete alinfo;
- return false;
- }
- alinfo->SetArtist(tmpStr);
-
- if (media_album_get_media_count_from_db(alinfo->AlbumId(), m->filter, &tmpValue)) {
- _ERR("Album artist Fetch error");
- alinfo->Destroy();
- delete alinfo;
- return false;
- }
- alinfo->SetSongCount(tmpValue);
-
- m->storageAlbumSong->Update(alinfo, m->filter);
-
- EINA_LIST_FOREACH(m->storageAlbumSong->List(), l, obj) {
- songInfo = (CSongInfo *)obj;
- tmpStr = songInfo->Genre();
- if (tmpStr) {
- alinfo->SetGenre(tmpStr);
- break;
- }
- }
-
- EINA_LIST_FOREACH(m->storageAlbumSong->List(), l, obj) {
- songInfo = (CSongInfo *)obj;
- tmpStr = songInfo->ThumbnailPath();
- if (tmpStr) {
- alinfo->SetThumbnailPath(tmpStr);
- break;
- }
- }
-
- m->albumlist = eina_list_append(m->albumlist, alinfo);
- return true;
-}
-
-
void CMediadata::m_DeleteFolderList(void)
{
CFolderInfo *finfo = NULL;
}
-void CMediadata::m_DeleteAlbumList(void)
-{
- if (!m->albumlist)
- return;
- CAlbumInfo *alinfo = NULL;
- void *obj = NULL;
-
- EINA_LIST_FREE(m->albumlist, obj) {
- alinfo = (CAlbumInfo *)obj;
- alinfo->Destroy();
- delete alinfo;
- }
-
- m->albumlist = NULL;
-}
-
-
void CMediadata::m_DeleteCategoryList(ECategoryType type)
{
CCategoryInfo *catinfo = NULL;
int count;
bool ret;
- if (!m->albumlist)
+ if (!m->storageAlbum->List())
return;
CCategoryStorage *stg = NULL;
char *str;
count = 0;
- EINA_LIST_FOREACH(m->albumlist, l, obj) {
+ EINA_LIST_FOREACH(m->storageAlbum->List(), l, obj) {
alinfo = (CAlbumInfo *)obj;
if (type == CAT_TYPE_ARTIST) {
str = alinfo->Artist();
}
-int CMediadata::m_GetAlbumList(void)
-{
- int r;
-
- r = media_album_foreach_album_from_db(m->filter,
- sm_CbEachAlbumData, (void *)this);
- if (r != MEDIA_CONTENT_ERROR_NONE) {
- _ERR("Media album foreach album from db failed");
- return false;
- }
-
- return true;
-}
-
-
void CMediadata::m_UpdateLists(void)
{
bool r;
}
m->storageSong->Update(m->filter);
-
- m_DeleteAlbumList();
- m_GetAlbumList();
+ m->storageAlbum->Update(m->filter);
m_DeleteCategoryList(CAT_TYPE_ARTIST);
m_GetCategoryList(CAT_TYPE_ARTIST);
void *obj;
m->storageSong->Delete();
- m_DeleteAlbumList();
+ m->storageAlbum->Delete();
m->storageAlbumSong->Delete();
m_DeleteFolderList();
m->storageFolderSong->Delete();
return m->storageSong->List();
case LIST_TYPE_ALBUM:
- return m->albumlist;
+ return m->storageAlbum->List();
case LIST_TYPE_ALBUM_SONG:
m->storageAlbumSong->Update((CAlbumInfo *)info, m->filter);