summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2015-12-07 07:02:08 (GMT)
committerJehun Lim <jehun.lim@samsung.com>2015-12-08 01:56:17 (GMT)
commitccfa3fff423d1097ae8b3299b33005d5eb304f6f (patch)
treeb65f67f587c9a0bab37fde731be4d6ab8529a15e
parent1369e843cb53187d125ff530e5f6540028c96cbc (diff)
downloadair_mediahub-ccfa3fff423d1097ae8b3299b33005d5eb304f6f.zip
air_mediahub-ccfa3fff423d1097ae8b3299b33005d5eb304f6f.tar.gz
air_mediahub-ccfa3fff423d1097ae8b3299b33005d5eb304f6f.tar.bz2
datamgr: add function to set source typerefs/changes/68/53468/2
Change-Id: I2ba6f265df4c21b80d909b914a198a0b7b28e073 Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
-rw-r--r--include/data/datamgr.h3
-rw-r--r--src/data/albumdata.c35
-rw-r--r--src/data/folderdata.c35
-rw-r--r--src/data/mediadata.c69
4 files changed, 96 insertions, 46 deletions
diff --git a/include/data/datamgr.h b/include/data/datamgr.h
index 158ace4..d7e30cf 100644
--- a/include/data/datamgr.h
+++ b/include/data/datamgr.h
@@ -22,7 +22,7 @@
#include "data/folderdata.h"
#define MOVIE_MEDIA_COND "media_type=1 AND copyright!=\"Unknown\""
-#define GALLERY_MEDIA_COND "media_type=0 OR (media_type=1 AND copyright=\"Unknown\")"
+#define GALLERY_MEDIA_COND "(media_type=0 OR (media_type=1 AND copyright=\"Unknown\"))"
#define MUSIC_MEDIA_COND "media_type=3"
enum data_type {
@@ -46,6 +46,7 @@ struct data_ops {
Eina_List *(*get_group)(void *handle, int type, void *data);
void (*free_group)(Eina_List *list);
int (*get_count)(void *handle, int type);
+ void (*set_source)(void *handle, int source_type);
};
struct datamgr {
diff --git a/src/data/albumdata.c b/src/data/albumdata.c
index a81f3a0..b3cd8ef 100644
--- a/src/data/albumdata.c
+++ b/src/data/albumdata.c
@@ -91,23 +91,16 @@ static bool _create_filter(struct albumdata *ad, filter_h *filter,
return false;
}
- snprintf(buf, sizeof(buf), "%s", ad->media_type);
+ snprintf(buf, sizeof(buf), "%s AND MEDIA_STORAGE_TYPE=%d",
+ ad->media_type, ad->source_type);
- if (ad->source_type != E_SOURCE_ALL) {
+ if (cond) {
char s1[64];
- snprintf(s1, sizeof(s1), " AND MEDIA_STORAGE_TYPE=%d",
- ad->source_type);
+ snprintf(s1, sizeof(s1), " AND %s", cond);
strncat(buf, s1, strlen(s1));
}
- if (cond) {
- char s2[64];
-
- snprintf(s2, sizeof(s2), " AND %s", cond);
- strncat(buf, s2, strlen(s2));
- }
-
media_filter_set_condition(tmp_filter, buf,
MEDIA_CONTENT_COLLATE_DEFAULT);
@@ -597,6 +590,25 @@ static Eina_List *_get_group(void *handle, int type, void *data)
return list;
}
+static void _set_source(void *handle, int source_type)
+{
+ struct albumdata *ad;
+
+ if (!handle) {
+ _ERR("failed to get albumdata handle");
+ return;
+ }
+
+ if (source_type < 0 || source_type >= E_SOURCE_MAX) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ ad = handle;
+
+ ad->source_type = source_type;
+}
+
static struct data_ops _ops = {
.create = _create,
.destroy = _destroy,
@@ -604,6 +616,7 @@ static struct data_ops _ops = {
.get_count = _get_count,
.get_group = _get_group,
.free_group = _free_group,
+ .set_source = _set_source,
};
struct data_ops *albumdata_get_ops(void)
diff --git a/src/data/folderdata.c b/src/data/folderdata.c
index bd9ad40..678fb51 100644
--- a/src/data/folderdata.c
+++ b/src/data/folderdata.c
@@ -88,23 +88,16 @@ static bool _create_filter(struct folderdata *fd, filter_h *filter,
media_filter_set_order(tmp_filter, MEDIA_CONTENT_ORDER_ASC,
FOLDER_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
} else {
- snprintf(buf, sizeof(buf), "%s", fd->media_type);
+ snprintf(buf, sizeof(buf), "%s AND MEDIA_STORAGE_TYPE=%d",
+ fd->media_type, fd->source_type);
- if (fd->source_type != E_SOURCE_ALL) {
+ if (cond) {
char s1[256];
- snprintf(s1, sizeof(s1), " AND MEDIA_STORAGE_TYPE=%d",
- fd->source_type);
+ snprintf(s1, sizeof(s1), " AND %s", cond);
strncat(buf, s1, strlen(s1));
}
- if (cond) {
- char s2[256];
-
- snprintf(s2, sizeof(s2), " AND %s", cond);
- strncat(buf, s2, strlen(s2));
- }
-
media_filter_set_order(tmp_filter, MEDIA_CONTENT_ORDER_ASC,
MEDIA_TITLE,
MEDIA_CONTENT_COLLATE_DEFAULT);
@@ -599,6 +592,25 @@ static Eina_List *_get_group(void *handle, int type, void *data)
return list;
}
+static void _set_source(void *handle, int source_type)
+{
+ struct folderdata *fd;
+
+ if (!handle) {
+ _ERR("failed to get folderdata handle");
+ return;
+ }
+
+ if (source_type < 0 || source_type >= E_SOURCE_MAX) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ fd = handle;
+
+ fd->source_type = source_type;
+}
+
static struct data_ops _ops = {
.create = _create,
.destroy = _destroy,
@@ -606,6 +618,7 @@ static struct data_ops _ops = {
.get_count = _get_count,
.get_group = _get_group,
.free_group = _free_group,
+ .set_source = _set_source,
};
struct data_ops *folderdata_get_ops(void)
diff --git a/src/data/mediadata.c b/src/data/mediadata.c
index 524da10..fa4dba9 100644
--- a/src/data/mediadata.c
+++ b/src/data/mediadata.c
@@ -113,15 +113,8 @@ static bool _create_filter(struct mediadata *md, filter_h *filter)
return false;
}
- snprintf(buf, sizeof(buf), "%s", md->media_type);
-
- if (md->source_type != E_SOURCE_ALL) {
- char s[64];
-
- snprintf(s, sizeof(s), " AND MEDIA_STORAGE_TYPE=%d",
- md->source_type);
- strncat(buf, s, strlen(s));
- }
+ snprintf(buf, sizeof(buf), "%s AND MEDIA_STORAGE_TYPE=%d",
+ md->media_type, md->source_type);
media_filter_set_condition(tmp_filter, buf,
MEDIA_CONTENT_COLLATE_DEFAULT);
@@ -485,6 +478,14 @@ static Eina_List *_sort_list(Eina_List *list, int sort)
return sorted_list;
}
+static void _destroy_media_list(Eina_List *list)
+{
+ app_media *am;
+
+ EINA_LIST_FREE(list, am)
+ app_media_destroy(am);
+}
+
static bool _get_each_media_info(media_info_h media_h, void *data)
{
Eina_List **list;
@@ -512,6 +513,17 @@ static bool _get_medialist(struct mediadata *md)
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 (md->media_list) {
+ _destroy_media_list(md->media_list);
+ md->media_list = NULL;
+ }
+
if (!_create_filter(md, &filter)) {
_ERR("failed to create filter");
return false;
@@ -530,13 +542,14 @@ static bool _get_medialist(struct mediadata *md)
media_filter_destroy(filter);
+ media_content_disconnect();
+
return true;
}
static void *_create(const char *media_type, int source_type)
{
struct mediadata *md;
- int ret;
if (!media_type || source_type < 0 || source_type >= E_SOURCE_MAX) {
_ERR("invalid argument");
@@ -552,28 +565,17 @@ static void *_create(const char *media_type, int source_type)
md->media_type = media_type;
md->source_type = source_type;
- ret = media_content_connect();
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- _ERR("failed to connect to media content");
- free(md);
- return NULL;
- }
-
if (!_get_medialist(md)) {
_ERR("failed to get medialist");
free(md);
- media_content_disconnect();
return NULL;
}
- media_content_disconnect();
-
return (void *)md;
}
static void _destroy(void *handle)
{
- app_media *am;
struct mediadata *md;
if (!handle) {
@@ -583,8 +585,7 @@ static void _destroy(void *handle)
md = handle;
- EINA_LIST_FREE(md->media_list, am)
- app_media_destroy(am);
+ _destroy_media_list(md->media_list);
free(md);
}
@@ -698,6 +699,27 @@ static Eina_List *_get_group(void *handle, int type, void *data)
return list;
}
+static void _set_source(void *handle, int source_type)
+{
+ struct mediadata *md;
+
+ if (!handle) {
+ _ERR("failed to get mediadata handle");
+ return;
+ }
+
+ if (source_type < 0 || source_type >= E_SOURCE_MAX) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ md = handle;
+
+ md->source_type = source_type;
+
+ _get_medialist(md);
+}
+
static struct data_ops _ops = {
.create = _create,
.destroy = _destroy,
@@ -705,6 +727,7 @@ static struct data_ops _ops = {
.get_count = _get_count,
.get_group = _get_group,
.free_group = _free_group,
+ .set_source = _set_source,
};
struct data_ops *mediadata_get_ops(void)