summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2015-12-07 07:19:43 (GMT)
committerJehun Lim <jehun.lim@samsung.com>2015-12-08 04:33:56 (GMT)
commitf5674be3e2661a02625b97ab55d0ba2ea5b2a56e (patch)
tree2669feae89ab7b06c123ed7294554e81c894cd30
parentccfa3fff423d1097ae8b3299b33005d5eb304f6f (diff)
downloadair_mediahub-f5674be3e2661a02625b97ab55d0ba2ea5b2a56e.zip
air_mediahub-f5674be3e2661a02625b97ab55d0ba2ea5b2a56e.tar.gz
air_mediahub-f5674be3e2661a02625b97ab55d0ba2ea5b2a56e.tar.bz2
base: add source selected callbackrefs/changes/70/53470/5
Change-Id: I0b2500f1d9e1677155099b075ea472cf6d177b2a Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
-rw-r--r--include/data/datamgr.h6
-rw-r--r--include/view.h1
-rw-r--r--src/data/albumdata.c7
-rw-r--r--src/data/datamgr.c3
-rw-r--r--src/data/folderdata.c7
-rw-r--r--src/data/mediadata.c7
-rw-r--r--src/layout/gallery.c28
-rw-r--r--src/layout/movie.c28
-rw-r--r--src/layout/music.c36
-rw-r--r--src/view/base.c27
-rw-r--r--src/view/detail.c3
11 files changed, 124 insertions, 29 deletions
diff --git a/include/data/datamgr.h b/include/data/datamgr.h
index d7e30cf..682eb77 100644
--- a/include/data/datamgr.h
+++ b/include/data/datamgr.h
@@ -33,10 +33,8 @@ enum data_type {
};
enum source_type {
- E_SOURCE_INTERNAL = 0,
- E_SOURCE_EXTERNAL,
- E_SOURCE_ALL,
- E_SOURCE_MAX
+ E_SOURCE_INTERNAL = MEDIA_CONTENT_STORAGE_INTERNAL,
+ E_SOURCE_EXTERNAL = MEDIA_CONTENT_STORAGE_EXTERNAL_USB
};
struct data_ops {
diff --git a/include/view.h b/include/view.h
index 78c2ed5..1c02d79 100644
--- a/include/view.h
+++ b/include/view.h
@@ -55,6 +55,7 @@ enum update_type {
UPDATE_RECENT,
UPDATE_FOCUS_STATE,
UPDATE_VIEW_MODE,
+ UPDATE_SOURCE_TYPE,
UPDATE_TOAST
};
diff --git a/src/data/albumdata.c b/src/data/albumdata.c
index b3cd8ef..8a6acc8 100644
--- a/src/data/albumdata.c
+++ b/src/data/albumdata.c
@@ -416,7 +416,7 @@ static void *_create(const char *media_type, int source_type)
{
struct albumdata *ad;
- if (!media_type || source_type < 0 || source_type >= E_SOURCE_MAX) {
+ if (!media_type) {
_ERR("invalid argument");
return NULL;
}
@@ -599,11 +599,6 @@ static void _set_source(void *handle, int source_type)
return;
}
- if (source_type < 0 || source_type >= E_SOURCE_MAX) {
- _ERR("invalid argument");
- return;
- }
-
ad = handle;
ad->source_type = source_type;
diff --git a/src/data/datamgr.c b/src/data/datamgr.c
index 162aa28..6108562 100644
--- a/src/data/datamgr.c
+++ b/src/data/datamgr.c
@@ -44,8 +44,7 @@ struct datamgr *datamgr_create(int data_type, const char *media_type,
struct data_ops *ops;
void *handle;
- if (!media_type || data_type < 0 || data_type >= E_DATA_MAX ||
- source_type < 0 || source_type >= E_SOURCE_MAX) {
+ if (!media_type || data_type < 0 || data_type >= E_DATA_MAX) {
_ERR("invalid argument");
return NULL;
}
diff --git a/src/data/folderdata.c b/src/data/folderdata.c
index 678fb51..2335653 100644
--- a/src/data/folderdata.c
+++ b/src/data/folderdata.c
@@ -434,7 +434,7 @@ static void *_create(const char *media_type, int source_type)
{
struct folderdata *fd;
- if (!media_type || source_type < 0 || source_type >= E_SOURCE_MAX) {
+ if (!media_type) {
_ERR("invalid argument");
return NULL;
}
@@ -601,11 +601,6 @@ static void _set_source(void *handle, int source_type)
return;
}
- if (source_type < 0 || source_type >= E_SOURCE_MAX) {
- _ERR("invalid argument");
- return;
- }
-
fd = handle;
fd->source_type = source_type;
diff --git a/src/data/mediadata.c b/src/data/mediadata.c
index fa4dba9..b46a16c 100644
--- a/src/data/mediadata.c
+++ b/src/data/mediadata.c
@@ -551,7 +551,7 @@ static void *_create(const char *media_type, int source_type)
{
struct mediadata *md;
- if (!media_type || source_type < 0 || source_type >= E_SOURCE_MAX) {
+ if (!media_type) {
_ERR("invalid argument");
return NULL;
}
@@ -708,11 +708,6 @@ static void _set_source(void *handle, int source_type)
return;
}
- if (source_type < 0 || source_type >= E_SOURCE_MAX) {
- _ERR("invalid argument");
- return;
- }
-
md = handle;
md->source_type = source_type;
diff --git a/src/layout/gallery.c b/src/layout/gallery.c
index de3bf61..7ba53eb 100644
--- a/src/layout/gallery.c
+++ b/src/layout/gallery.c
@@ -59,6 +59,8 @@ struct _priv {
Eina_List *media_list;
int view_mode;
+ int source_type;
+
struct grid_data *gdata;
struct locmgr *locmgr;
@@ -126,6 +128,8 @@ static void _clear_content_list(struct _priv *priv)
priv->media_list = NULL;
}
+ elm_object_part_text_set(priv->layout, PART_NOCONTENT, "");
+
listmgr_clear_content_list(priv->listmgr);
}
@@ -220,7 +224,7 @@ static bool _create_utils(struct _priv *priv)
int i;
for (i = 0; i < E_DATA_MAX; i++) {
- dmgr = datamgr_create(i, GALLERY_MEDIA_COND, E_SOURCE_ALL);
+ dmgr = datamgr_create(i, GALLERY_MEDIA_COND, E_SOURCE_INTERNAL);
if (!dmgr) {
_ERR("failed to create datamgr");
_destroy_datamgr(priv);
@@ -380,6 +384,7 @@ static void _update(void *layout_data, int update_type, void *data)
{
struct view_update_data *vdata;
struct _priv *priv;
+ struct datamgr *dmgr;
int mode;
if (!layout_data) {
@@ -442,6 +447,27 @@ static void _update(void *layout_data, int update_type, void *data)
priv->view_mode = mode;
_update_content_list(priv);
break;
+ case UPDATE_SOURCE_TYPE:
+ if (!data) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ vdata = data;
+ mode = vdata->index;
+
+ if (mode == priv->source_type)
+ return;
+
+ priv->source_type = mode;
+
+ dmgr = priv->dmgr[E_DATA_MEDIA];
+ dmgr->ops->set_source(dmgr->handle, mode);
+
+ _clear_content_list(priv);
+
+ _update_content_list(priv);
+ break;
default:
break;
}
diff --git a/src/layout/movie.c b/src/layout/movie.c
index 3771060..292bef6 100644
--- a/src/layout/movie.c
+++ b/src/layout/movie.c
@@ -64,6 +64,8 @@ struct _priv {
app_media *recent_info;
int view_mode;
+ int source_type;
+
struct grid_data *gdata;
};
@@ -366,6 +368,8 @@ static void _clear_content_list(struct _priv *priv)
priv->media_list = NULL;
}
+ elm_object_part_text_set(priv->layout, PART_NOCONTENT, "");
+
listmgr_clear_content_list(priv->listmgr);
}
@@ -488,7 +492,7 @@ static bool _create_utils(struct _priv *priv)
int i;
for (i = 0; i < E_DATA_MAX; i++) {
- dmgr = datamgr_create(i, MOVIE_MEDIA_COND, E_SOURCE_ALL);
+ dmgr = datamgr_create(i, MOVIE_MEDIA_COND, E_SOURCE_INTERNAL);
if (!dmgr) {
_ERR("failed to create datamgr");
_destroy_datamgr(priv);
@@ -647,6 +651,7 @@ static void _update(void *layout_data, int update_type, void *data)
{
struct view_update_data *vdata;
struct _priv *priv;
+ struct datamgr *dmgr;
int mode;
if (!layout_data) {
@@ -714,6 +719,27 @@ static void _update(void *layout_data, int update_type, void *data)
priv->view_mode = mode;
_update_content_list(priv);
break;
+ case UPDATE_SOURCE_TYPE:
+ if (!data) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ vdata = data;
+ mode = vdata->index;
+
+ if (mode == priv->source_type)
+ return;
+
+ priv->source_type = mode;
+
+ dmgr = priv->dmgr[E_DATA_MEDIA];
+ dmgr->ops->set_source(dmgr->handle, mode);
+
+ _clear_content_list(priv);
+
+ _update_content_list(priv);
+ break;
default:
break;
}
diff --git a/src/layout/music.c b/src/layout/music.c
index 30a8826..6a6b8aa 100644
--- a/src/layout/music.c
+++ b/src/layout/music.c
@@ -60,6 +60,8 @@ struct _priv {
app_media *playing_info;
int view_mode;
+ int source_type;
+
struct grid_data *gdata;
};
@@ -318,6 +320,8 @@ static void _clear_content_list(struct _priv *priv)
priv->media_list = NULL;
}
+ elm_object_part_text_set(priv->layout, PART_NOCONTENT, "");
+
listmgr_clear_content_list(priv->listmgr);
}
@@ -418,6 +422,17 @@ static void _update_playing_item(struct _priv *priv, const char *id)
_ERR("failed to update now playing item");
}
+static void _set_source(struct _priv *priv)
+{
+ struct datamgr *dmgr;
+ int i;
+
+ for (i = 0; i < E_DATA_MAX; i++) {
+ dmgr = priv->dmgr[i];
+ dmgr->ops->set_source(dmgr->handle, priv->source_type);
+ }
+}
+
static void _destroy_datamgr(struct _priv *priv)
{
int i;
@@ -443,7 +458,7 @@ static bool _create_utils(struct _priv *priv)
int i;
for (i = 0; i < E_DATA_MAX; i++) {
- dmgr = datamgr_create(i, MUSIC_MEDIA_COND, E_SOURCE_ALL);
+ dmgr = datamgr_create(i, MUSIC_MEDIA_COND, E_SOURCE_INTERNAL);
if (!dmgr) {
_ERR("failed to create datamgr");
_destroy_datamgr(priv);
@@ -669,6 +684,25 @@ static void _update(void *layout_data, int update_type, void *data)
priv->view_mode = mode;
_update_content_list(priv);
break;
+ case UPDATE_SOURCE_TYPE:
+ if (!data) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ vdata = data;
+ mode = vdata->index;
+
+ if (mode == priv->source_type)
+ return;
+
+ priv->source_type = mode;
+ _set_source(priv);
+
+ _clear_content_list(priv);
+
+ _update_content_list(priv);
+ break;
default:
break;
}
diff --git a/src/view/base.c b/src/view/base.c
index 111b3ef..965bb98 100644
--- a/src/view/base.c
+++ b/src/view/base.c
@@ -28,6 +28,7 @@
#include "define.h"
#include "layout.h"
#include "view.h"
+#include "data/datamgr.h"
#include "util/ctxpopup.h"
#include "util/util.h"
@@ -105,6 +106,11 @@ const char *source[] = {
"USB",
};
+static int source_type[] = {
+ E_SOURCE_INTERNAL,
+ E_SOURCE_EXTERNAL
+};
+
struct _menu_item {
const char *name;
const char *layout_id;
@@ -209,7 +215,26 @@ static void _view_selected_cb(void *data, int mode)
static void _source_selected_cb(void *data, int mode)
{
- /* It will be implemented later */
+ struct view_update_data vdata;
+ struct _priv *priv;
+ int i;
+
+ if (!data)
+ return;
+
+ priv = data;
+
+ elm_object_text_set(priv->source_btn, source[mode]);
+
+ vdata.index = source_type[mode];
+
+ for (i = 0; i < E_LAYOUT_MAX; i++) {
+ layoutmgr_update_layout(priv->lmgr,
+ g_menu_item[i].layout_id,
+ UPDATE_SOURCE_TYPE, &vdata);
+ }
+
+ priv->source_type = mode;
}
static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
diff --git a/src/view/detail.c b/src/view/detail.c
index 851450f..62547db 100644
--- a/src/view/detail.c
+++ b/src/view/detail.c
@@ -985,7 +985,8 @@ static Evas_Object *_create(Evas_Object *win, void *data)
EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, base);
- dmgr = datamgr_create(E_DATA_ALBUM, MUSIC_MEDIA_COND, E_SOURCE_ALL);
+ dmgr = datamgr_create(E_DATA_ALBUM, MUSIC_MEDIA_COND,
+ E_SOURCE_INTERNAL);
if (!dmgr) {
_ERR("failed to create datamgr");
free(priv);