struct data_ops;
enum album_group_type {
- E_ALBUM_NAME = 0,
- E_ALBUM_ARTIST,
- E_ALBUM_MAX
+ E_GROUP_ALBUM_NAME = 0,
+ E_GROUP_ALBUM_ARTIST,
+ E_GROUP_ALBUM_MAX
+};
+
+enum album_list_type {
+ E_LIST_ALBUM_MEDIA = 0,
};
struct album_info {
struct data_ops {
void *(*create)(const char *media_type, int source_type);
void (*destroy)(void *handle);
- Eina_List *(*get_list)(void *handle);
- int (*get_count)(void *handle, int type);
+ Eina_List *(*get_list)(void *handle, int type, void *data);
Eina_List *(*get_group)(void *handle, int type, void *data);
void (*free_group)(Eina_List *list);
+ int (*get_count)(void *handle, int type);
};
struct datamgr {
struct data_ops;
enum folder_group_type {
- E_FOLDER_NAME,
- E_FOLDER_MAX
+ E_GROUP_FOLDER_NAME,
+ E_GROUP_FOLDER_MAX
};
struct folder_info {
struct data_ops;
enum media_group_type {
- E_MEDIA_DATE = 0,
- E_MEDIA_NAME,
- E_MEDIA_GENRE,
- E_MEDIA_TYPE,
- E_MEDIA_MAX
+ E_GROUP_MEDIA_DATE = 0,
+ E_GROUP_MEDIA_NAME,
+ E_GROUP_MEDIA_GENRE,
+ E_GROUP_MEDIA_TYPE,
+ E_GROUP_MEDIA_MAX
+};
+
+enum media_list_type {
+ E_LIST_MEDIA = 0,
};
enum media_file_type {
#include <Elementary.h>
#include <media_content.h>
#include <app_debug.h>
+#include <app_media.h>
#include "data/datamgr.h"
static void *_get_data_artist(struct album_info *);
static char *_get_artist(struct album_info *);
+enum _filter_type {
+ E_FILTER_ALBUM = 0,
+ E_FILTER_MEDIA
+};
struct albumdata {
Eina_List *album_list;
+ Eina_List *media_list;
+
+ int group_type;
const char *media_type;
int source_type;
group_name_get name_get;
};
-static struct _group_info g_group_info[E_ALBUM_MAX] = {
- [E_ALBUM_NAME] = {
+static struct _group_info g_group_info[E_GROUP_ALBUM_MAX] = {
+ [E_GROUP_ALBUM_NAME] = {
.sort_keyword = MEDIA_ALBUM,
.get_list = _get_name_list,
.media_cmp = _compare_name,
.data_get = _get_data_name,
.name_get = _get_name,
},
- [E_ALBUM_ARTIST] = {
+ [E_GROUP_ALBUM_ARTIST] = {
.sort_keyword = MEDIA_ALBUM_ARTIST,
.get_list = _get_artist_list,
.media_cmp = _compare_artist,
};
static bool _create_filter(struct albumdata *ad, filter_h *filter,
- const char *cond, int group_type)
+ const char *cond, int filter_type)
{
filter_h tmp_filter;
int ret;
media_filter_set_condition(tmp_filter, buf,
MEDIA_CONTENT_COLLATE_DEFAULT);
- media_filter_set_order(tmp_filter, MEDIA_CONTENT_ORDER_ASC,
- g_group_info[group_type].sort_keyword,
- MEDIA_CONTENT_COLLATE_DEFAULT);
+ if (filter_type == E_FILTER_ALBUM) {
+ media_filter_set_order(tmp_filter, MEDIA_CONTENT_ORDER_ASC,
+ g_group_info[ad->group_type].sort_keyword,
+ MEDIA_CONTENT_COLLATE_DEFAULT);
+ } else if (filter_type == E_FILTER_MEDIA) {
+ media_filter_set_order(tmp_filter, MEDIA_CONTENT_ORDER_ASC,
+ MEDIA_TITLE, MEDIA_CONTENT_COLLATE_DEFAULT);
+ }
*filter = tmp_filter;
return strndup(ai->artist, 1);
}
+static void _destroy_media_list(Eina_List *list)
+{
+ app_media *am;
+
+ EINA_LIST_FREE(list, am)
+ app_media_destroy(am);
+}
+
static void _destroy_album_list(Eina_List *list)
{
struct album_info *ai;
}
}
+static bool _get_each_media_info(media_info_h media_h, void *data)
+{
+ Eina_List **list;
+ app_media *am;
+
+ if (!data)
+ return false;
+
+ list = data;
+
+ am = app_media_create(media_h);
+ if (!am) {
+ _ERR("failed to create app media");
+ return false;
+ }
+
+ *list = eina_list_append(*list, am);
+
+ return true;
+}
+
static bool _get_each_album_info(media_album_h album, void *data)
{
Eina_List **list;
snprintf(buf, sizeof(buf), "MEDIA_ALBUM_ARTIST=\"%s\"", group_name);
- if (!_create_filter(ad, &filter, buf, E_ALBUM_ARTIST)) {
+ if (!_create_filter(ad, &filter, buf, E_FILTER_ALBUM)) {
_ERR("failed to create filter");
return false;
}
return true;
}
+static bool _get_media_list(struct albumdata *ad, int album_id)
+{
+ filter_h filter;
+ int ret;
+
+ ret = media_content_connect();
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ _ERR("failed to connect to media content");
+ return false;
+ }
+
+ if (!_create_filter(ad, &filter, NULL, E_FILTER_MEDIA)) {
+ _ERR("failed to create filter");
+ media_content_disconnect();
+ return false;
+ }
+
+ ret = media_album_foreach_media_from_db(album_id, filter,
+ _get_each_media_info, &ad->media_list);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ _ERR("failed to get media info");
+ _destroy_media_list(ad->media_list);
+ media_filter_destroy(filter);
+ media_content_disconnect();
+ return false;
+ }
+
+ media_filter_destroy(filter);
+ media_content_disconnect();
+
+ return true;
+}
+
static bool _get_name_list(struct albumdata *ad)
{
filter_h filter;
return false;
}
- if (!_create_filter(ad, &filter, NULL, E_ALBUM_NAME)) {
+ if (!_create_filter(ad, &filter, NULL, E_FILTER_ALBUM)) {
_ERR("failed to create filter");
media_content_disconnect();
return false;
return false;
}
- if (!_create_filter(ad, &filter, NULL, E_ALBUM_ARTIST)) {
+ if (!_create_filter(ad, &filter, NULL, E_FILTER_ALBUM)) {
_ERR("failed to create filter");
media_content_disconnect();
return false;
ad = handle;
_destroy_album_list(ad->album_list);
+ _destroy_media_list(ad->media_list);
free(ad);
}
-static Eina_List *_get_list(void *handle)
+static Eina_List *_get_list(void *handle, int type, void *data)
{
struct albumdata *ad;
+ int *album_id;
if (!handle) {
_ERR("failed to get albumdata handle");
return NULL;
}
+ if (!data) {
+ _ERR("invalid argument");
+ return NULL;
+ }
+
ad = handle;
- return ad->album_list;
+ switch (type) {
+ case E_LIST_ALBUM_MEDIA:
+ if (ad->media_list) {
+ _destroy_media_list(ad->media_list);
+ ad->media_list = NULL;
+ }
+
+ album_id = data;
+ _get_media_list(ad, *album_id);
+ return ad->media_list;
+ default:
+ break;
+ }
+
+ return NULL;
}
static int _get_count(void *handle, int type)
return NULL;
}
- if (type < 0 || type >= E_ALBUM_MAX) {
+ if (type < 0 || type >= E_GROUP_ALBUM_MAX) {
_ERR("invalid argument");
return NULL;
}
ad = handle;
+ ad->group_type = type;
+
if (ad->album_list) {
_destroy_album_list(ad->album_list);
ad->album_list = NULL;
free(fd);
}
-static Eina_List *_get_list(void *handle)
+static Eina_List *_get_list(void *handle, int type, void *data)
{
struct folderdata *fd;
return NULL;
}
- if (type < 0 || type > E_FOLDER_MAX || !data) {
+ if (type < 0 || type > E_GROUP_FOLDER_MAX || !data) {
_ERR("invalid argument");
return NULL;
}
group_name_get name_get;
};
-static struct _list_info g_group_info[E_MEDIA_MAX] = {
- [E_MEDIA_DATE] = {
+static struct _list_info g_group_info[E_GROUP_MEDIA_MAX] = {
+ [E_GROUP_MEDIA_DATE] = {
.sort_cmp_cb = _compare_cb_date,
.media_cmp = _compare_time,
.name_get = _get_time,
.data_get = _get_data_time,
},
- [E_MEDIA_NAME] = {
+ [E_GROUP_MEDIA_NAME] = {
.sort_cmp_cb = _compare_cb_name,
.media_cmp = _compare_title,
.name_get = _get_title,
.data_get = _get_data_title,
},
- [E_MEDIA_GENRE] = {
+ [E_GROUP_MEDIA_GENRE] = {
.sort_cmp_cb = _compare_cb_genre,
.media_cmp = _compare_genre,
.name_get = _get_genre,
.data_get = _get_data_genre,
},
- [E_MEDIA_TYPE] = {
+ [E_GROUP_MEDIA_TYPE] = {
.sort_cmp_cb = _compare_cb_type,
.media_cmp = _compare_type,
.name_get = _get_type,
free(md);
}
-static Eina_List *_get_list(void *handle)
+static Eina_List *_get_list(void *handle, int type, void *data)
{
struct mediadata *md;
return -1;
}
- if (type < 0 || type >= E_MEDIA_MAX) {
+ if (type < 0 || type >= E_FILE_MAX) {
_ERR("invalid argument");
return -1;
}
return NULL;
}
- if (type < 0 || type >= E_MEDIA_MAX) {
+ if (type < 0 || type >= E_GROUP_MEDIA_MAX) {
_ERR("invalid argument");
return NULL;
}
return NULL;
}
- return dmgr->ops->get_group(dmgr->handle, E_MEDIA_DATE, NULL);
+ return dmgr->ops->get_group(dmgr->handle, E_GROUP_MEDIA_DATE, NULL);
}
static Eina_List *_get_type_list(struct datamgr *dmgr)
return NULL;
}
- return dmgr->ops->get_group(dmgr->handle, E_MEDIA_TYPE, NULL);
+ return dmgr->ops->get_group(dmgr->handle, E_GROUP_MEDIA_TYPE, NULL);
}
static void _free_media_list(struct datamgr *dmgr, Eina_List *list)
return NULL;
}
- return dmgr->ops->get_group(dmgr->handle, E_MEDIA_NAME, NULL);
+ return dmgr->ops->get_group(dmgr->handle, E_GROUP_MEDIA_NAME, NULL);
}
static Eina_List *_get_genre_list(struct datamgr *dmgr)
}
gi->name = STR_GENRE_NAME;
- gi->list = dmgr->ops->get_group(dmgr->handle, E_MEDIA_GENRE, NULL);
+ gi->list = dmgr->ops->get_group(dmgr->handle,
+ E_GROUP_MEDIA_GENRE, NULL);
list = NULL;
list = eina_list_append(list, gi);
return NULL;
}
- return dmgr->ops->get_group(dmgr->handle, E_MEDIA_DATE, NULL);
+ return dmgr->ops->get_group(dmgr->handle, E_GROUP_MEDIA_DATE, NULL);
}
static void _free_media_list(struct datamgr *dmgr, Eina_List *list)
return NULL;
}
- return dmgr->ops->get_group(dmgr->handle, E_MEDIA_NAME, NULL);
+ return dmgr->ops->get_group(dmgr->handle, E_GROUP_MEDIA_NAME, NULL);
}
static Eina_List *_get_album_list(struct datamgr *dmgr)
return NULL;
}
- return dmgr->ops->get_group(dmgr->handle, E_ALBUM_NAME, NULL);
+ return dmgr->ops->get_group(dmgr->handle, E_GROUP_ALBUM_NAME, NULL);
}
static Eina_List *_get_artist_list(struct datamgr *dmgr)
return NULL;
}
- return dmgr->ops->get_group(dmgr->handle, E_ALBUM_ARTIST, NULL);
+ return dmgr->ops->get_group(dmgr->handle, E_GROUP_ALBUM_ARTIST, NULL);
}
static Eina_List *_get_genre_list(struct datamgr *dmgr)
}
gi->name = STR_GENRE_NAME;
- gi->list = dmgr->ops->get_group(dmgr->handle, E_MEDIA_GENRE, NULL);
+ gi->list = dmgr->ops->get_group(dmgr->handle,
+ E_GROUP_MEDIA_GENRE, NULL);
list = NULL;
list = eina_list_append(list, gi);
if (!dmgr)
return;
- vdata.list = dmgr->ops->get_list(dmgr->handle);
+ vdata.list = dmgr->ops->get_list(dmgr->handle, E_LIST_MEDIA, NULL);
vdata.index = util_get_media_index_from_id(vdata.list, info->media_id);
viewmgr_update_view(VIEW_VIEWER, UPDATE_CONTENT, &vdata);
return;
}
- priv->gdata->data = dmgr->ops->get_list(dmgr->handle);
+ priv->gdata->data = dmgr->ops->get_list(dmgr->handle,
+ E_LIST_MEDIA, NULL);
if (!listmgr_update_content_list(priv->listmgr, list, priv->gdata))
_ERR("failed to update list area");
if (!dmgr)
return;
- vdata.list = dmgr->ops->get_list(dmgr->handle);
+ vdata.list = dmgr->ops->get_list(dmgr->handle, E_LIST_MEDIA, NULL);
vdata.index = util_get_media_index_from_id(vdata.list, info->media_id);
viewmgr_update_view(VIEW_VIEWER, UPDATE_CONTENT, &vdata);
if (!dmgr)
return;
- vdata.list = dmgr->ops->get_list(dmgr->handle);
+ vdata.list = dmgr->ops->get_list(dmgr->handle, E_LIST_MEDIA, NULL);
vdata.index = util_get_media_index(vdata.list, priv->recent_info);
viewmgr_update_view(VIEW_VIEWER, UPDATE_CONTENT, &vdata);
return;
}
- priv->gdata->data = dmgr->ops->get_list(dmgr->handle);
+ priv->gdata->data = dmgr->ops->get_list(dmgr->handle,
+ E_LIST_MEDIA, NULL);
if (!listmgr_update_content_list(priv->listmgr, list, priv->gdata)) {
_ERR("failed to update list area");
if (!dmgr)
return;
- list = dmgr->ops->get_list(dmgr->handle);
+ list = dmgr->ops->get_list(dmgr->handle, E_LIST_MEDIA, NULL);
if (id)
am = util_find_media_info(list, id);
if (!dmgr)
return;
- vdata.list = dmgr->ops->get_list(dmgr->handle);
+ vdata.list = dmgr->ops->get_list(dmgr->handle, E_LIST_MEDIA, NULL);
vdata.index = util_get_media_index_from_id(vdata.list, info->media_id);
viewmgr_update_view(VIEW_MPLAYER, UPDATE_CONTENT, &vdata);
if (!dmgr)
return;
- vdata.list = dmgr->ops->get_list(dmgr->handle);
+ vdata.list = dmgr->ops->get_list(dmgr->handle, E_LIST_MEDIA, NULL);
vdata.index = util_get_media_index(vdata.list, priv->playing_info);
viewmgr_update_view(VIEW_MPLAYER, UPDATE_CONTENT, &vdata);
return;
}
- priv->gdata->data = dmgr->ops->get_list(dmgr->handle);
+ priv->gdata->data = dmgr->ops->get_list(dmgr->handle,
+ E_LIST_MEDIA, NULL);
if (!listmgr_update_content_list(priv->listmgr, list, priv->gdata))
_ERR("failed to update list area");
if (!dmgr)
return;
- list = dmgr->ops->get_list(dmgr->handle);
+ list = dmgr->ops->get_list(dmgr->handle, E_LIST_MEDIA, NULL);
if (id)
am = util_find_media_info(list, id);