summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2015-12-16 18:35:54 +0900
committerJehun Lim <jehun.lim@samsung.com>2015-12-16 21:39:31 +0900
commitc8190cf76a7d7214a29cbc8672652e4b0f9934dc (patch)
tree77f99c3861ff95428dea9001338504d69b981e4f
parent6133e71c78487ecd1b327d790e927db91236f367 (diff)
downloadair_mediahub-c8190cf76a7d7214a29cbc8672652e4b0f9934dc.tar.gz
air_mediahub-c8190cf76a7d7214a29cbc8672652e4b0f9934dc.tar.bz2
air_mediahub-c8190cf76a7d7214a29cbc8672652e4b0f9934dc.zip
base: add usb changed callback
Change-Id: I0f359fe8e4430f038ec6eb585477e4cc6ff7e544 Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
-rw-r--r--include/util/listmgr.h1
-rw-r--r--include/view.h8
-rw-r--r--src/data/mediadata.c9
-rw-r--r--src/layout/gallery.c32
-rw-r--r--src/layout/movie.c34
-rw-r--r--src/layout/music.c33
-rw-r--r--src/util/listmgr.c20
-rw-r--r--src/view/base.c76
8 files changed, 179 insertions, 34 deletions
diff --git a/include/util/listmgr.h b/include/util/listmgr.h
index d3dfa99..d22015f 100644
--- a/include/util/listmgr.h
+++ b/include/util/listmgr.h
@@ -51,6 +51,7 @@ void listmgr_clear_content_list(struct listmgr *lmgr);
bool listmgr_focus_content_list(struct listmgr *lmgr, const char *id);
bool listmgr_focus_play_info(struct listmgr *lmgr);
+bool listmgr_focus_menu_btn(struct listmgr *lmgr);
void listmgr_set_focus_state(struct listmgr *lmgr, Eina_Bool state);
diff --git a/include/view.h b/include/view.h
index 1c02d79..99e86a1 100644
--- a/include/view.h
+++ b/include/view.h
@@ -55,10 +55,18 @@ enum update_type {
UPDATE_RECENT,
UPDATE_FOCUS_STATE,
UPDATE_VIEW_MODE,
+ UPDATE_SOURCE_CONTENT,
UPDATE_SOURCE_TYPE,
UPDATE_TOAST
};
+enum base_view_layout {
+ E_LAYOUT_MOVIE = 0,
+ E_LAYOUT_GALLERY,
+ E_LAYOUT_MUSIC,
+ E_LAYOUT_MAX
+};
+
enum detail_view_type {
E_DETAIL_MOVIE_GENRE = 0,
E_DETAIL_GALLERY_PLACE,
diff --git a/src/data/mediadata.c b/src/data/mediadata.c
index 39f3638..a31a3da 100644
--- a/src/data/mediadata.c
+++ b/src/data/mediadata.c
@@ -670,11 +670,16 @@ static Eina_List *_get_group(void *handle, int type, void *data)
md = handle;
- for (i = 0; i < E_FILE_MAX; i++)
- md->media_count[i] = 0;
+ if (!_get_medialist(md)) {
+ _ERR("failed to get media list");
+ return NULL;
+ }
md->media_list = _sort_list(md->media_list, type);
+ for (i = 0; i < E_FILE_MAX; i++)
+ md->media_count[i] = 0;
+
gi = NULL;
list = NULL;
EINA_LIST_FOREACH(md->media_list, l, am) {
diff --git a/src/layout/gallery.c b/src/layout/gallery.c
index 7c6aad9..2d80734 100644
--- a/src/layout/gallery.c
+++ b/src/layout/gallery.c
@@ -142,10 +142,8 @@ static void _clear_content_list(struct _priv *priv)
static void _update_content_list(struct _priv *priv)
{
- if (priv->media_list) {
- _update_bottom_area(priv);
+ if (priv->media_list)
return;
- }
priv->gdata = get_gallery_grid_data(priv->view_mode);
if (!priv->gdata) {
@@ -156,13 +154,9 @@ static void _update_content_list(struct _priv *priv)
priv->media_list = priv->gdata->get_item_list(priv->dmgr[E_DATA_MEDIA]);
- _update_bottom_area(priv);
-
- if (!priv->media_list) {
+ if (!priv->media_list)
elm_object_part_text_set(priv->layout,
PART_NOCONTENT, TEXT_NOCONTENT);
- return;
- }
priv->gdata->data = priv->dmgr[E_DATA_MEDIA];
@@ -402,6 +396,7 @@ static void _update(void *layout_data, int update_type, void *data)
switch (update_type) {
case UPDATE_CONTENT:
_update_content_list(priv);
+ _update_bottom_area(priv);
break;
case UPDATE_CONTENT_ITEM:
listmgr_update_content_item(priv->listmgr);
@@ -426,6 +421,8 @@ static void _update(void *layout_data, int update_type, void *data)
}
_update_content_list(priv);
+ _update_bottom_area(priv);
+
_recent_item_selected(priv, data);
break;
case UPDATE_FOCUS_STATE:
@@ -450,7 +447,9 @@ static void _update(void *layout_data, int update_type, void *data)
_clear_content_list(priv);
priv->view_mode = mode;
+
_update_content_list(priv);
+ _update_bottom_area(priv);
break;
case UPDATE_SOURCE_TYPE:
if (!data) {
@@ -472,6 +471,23 @@ static void _update(void *layout_data, int update_type, void *data)
_clear_content_list(priv);
_update_content_list(priv);
+ _update_bottom_area(priv);
+ break;
+ case UPDATE_SOURCE_CONTENT:
+ if (!data) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ vdata = data;
+
+ _clear_content_list(priv);
+ _update_content_list(priv);
+
+ if (vdata->index == E_LAYOUT_GALLERY) {
+ _update_bottom_area(priv);
+ listmgr_focus_menu_btn(priv->listmgr);
+ }
break;
default:
break;
diff --git a/src/layout/movie.c b/src/layout/movie.c
index efefa0c..542236d 100644
--- a/src/layout/movie.c
+++ b/src/layout/movie.c
@@ -397,10 +397,8 @@ static void _clear_content_list(struct _priv *priv)
static void _update_content_list(struct _priv *priv)
{
- if (priv->media_list) {
- _update_bottom_area(priv);
+ if (priv->media_list)
return;
- }
priv->gdata = get_movie_grid_data(priv->view_mode);
if (!priv->gdata) {
@@ -411,13 +409,9 @@ static void _update_content_list(struct _priv *priv)
priv->media_list = priv->gdata->get_item_list(priv->dmgr[E_DATA_MEDIA]);
- _update_bottom_area(priv);
-
- if (!priv->media_list) {
+ if (!priv->media_list)
elm_object_part_text_set(priv->layout,
PART_NOCONTENT, TEXT_NOCONTENT);
- return;
- }
priv->gdata->data = priv->dmgr[E_DATA_MEDIA];
@@ -684,6 +678,8 @@ static void _update(void *layout_data, int update_type, void *data)
switch (update_type) {
case UPDATE_CONTENT:
_update_content_list(priv);
+ _update_bottom_area(priv);
+
_update_recent_item(priv, NULL);
break;
case UPDATE_CONTENT_ITEM:
@@ -713,6 +709,8 @@ static void _update(void *layout_data, int update_type, void *data)
}
_update_content_list(priv);
+ _update_bottom_area(priv);
+
_recent_item_selected(priv, data);
break;
case UPDATE_FOCUS_STATE:
@@ -737,7 +735,9 @@ static void _update(void *layout_data, int update_type, void *data)
_clear_content_list(priv);
priv->view_mode = mode;
+
_update_content_list(priv);
+ _update_bottom_area(priv);
break;
case UPDATE_SOURCE_TYPE:
if (!data) {
@@ -759,6 +759,24 @@ static void _update(void *layout_data, int update_type, void *data)
_clear_content_list(priv);
_update_content_list(priv);
+ _update_bottom_area(priv);
+ break;
+ case UPDATE_SOURCE_CONTENT:
+ if (!data) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ vdata = data;
+
+ _clear_content_list(priv);
+ _update_content_list(priv);
+
+ if (vdata->index == E_LAYOUT_MOVIE) {
+ _update_bottom_area(priv);
+ _update_recent_item(priv, NULL);
+ listmgr_focus_menu_btn(priv->listmgr);
+ }
break;
default:
break;
diff --git a/src/layout/music.c b/src/layout/music.c
index d3ff9a5..d62c05b 100644
--- a/src/layout/music.c
+++ b/src/layout/music.c
@@ -342,10 +342,8 @@ static void _update_content_list(struct _priv *priv)
{
struct datamgr *dmgr;
- if (priv->media_list) {
- _update_bottom_area(priv);
+ if (priv->media_list)
return;
- }
priv->gdata = get_music_grid_data(priv->view_mode);
if (!priv->gdata) {
@@ -360,13 +358,9 @@ static void _update_content_list(struct _priv *priv)
priv->media_list = priv->gdata->get_item_list(dmgr);
- _update_bottom_area(priv);
-
- if (!priv->media_list) {
+ if (!priv->media_list)
elm_object_part_text_set(priv->layout,
PART_NOCONTENT, TEXT_NOCONTENT);
- return;
- }
priv->gdata->data = dmgr;
@@ -642,6 +636,7 @@ static void _update(void *layout_data, int update_type, void *data)
switch (update_type) {
case UPDATE_CONTENT:
_update_content_list(priv);
+ _update_bottom_area(priv);
break;
case UPDATE_CONTENT_ITEM:
listmgr_update_content_item(priv->listmgr);
@@ -670,6 +665,8 @@ static void _update(void *layout_data, int update_type, void *data)
}
_update_content_list(priv);
+ _update_bottom_area(priv);
+
_recent_item_selected(priv, data);
break;
case UPDATE_FOCUS_STATE:
@@ -694,7 +691,9 @@ static void _update(void *layout_data, int update_type, void *data)
_clear_content_list(priv);
priv->view_mode = mode;
+
_update_content_list(priv);
+ _update_bottom_area(priv);
break;
case UPDATE_SOURCE_TYPE:
if (!data) {
@@ -714,6 +713,24 @@ static void _update(void *layout_data, int update_type, void *data)
_clear_content_list(priv);
_update_content_list(priv);
+ _update_bottom_area(priv);
+
+ break;
+ case UPDATE_SOURCE_CONTENT:
+ if (!data) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ vdata = data;
+
+ _clear_content_list(priv);
+ _update_content_list(priv);
+
+ if (vdata->index == E_LAYOUT_MUSIC) {
+ _update_bottom_area(priv);
+ listmgr_focus_menu_btn(priv->listmgr);
+ }
break;
default:
break;
diff --git a/src/util/listmgr.c b/src/util/listmgr.c
index be8eae3..74c411a 100644
--- a/src/util/listmgr.c
+++ b/src/util/listmgr.c
@@ -471,7 +471,7 @@ static Evas_Object *_draw_list_item(struct listmgr *lmgr, struct group_info *gi)
return ly;
}
-bool _focus_to_content(struct listmgr *lmgr, Evas_Object *base)
+static bool _focus_to_content(struct listmgr *lmgr, Evas_Object *base)
{
Evas_Object *content;
@@ -565,6 +565,19 @@ void listmgr_set_focus_state(struct listmgr *lmgr, Eina_Bool state)
lmgr->focus_state = state;
}
+bool listmgr_focus_menu_btn(struct listmgr *lmgr)
+{
+ if (!lmgr) {
+ _ERR("failed to get listmgr");
+ return false;
+ }
+
+ if (!elm_object_focus_get(lmgr->data->menu_btn))
+ elm_object_focus_set(lmgr->data->menu_btn, EINA_TRUE);
+
+ return true;
+}
+
bool listmgr_focus_play_info(struct listmgr *lmgr)
{
if (!lmgr) {
@@ -805,6 +818,11 @@ bool listmgr_update_content_list(struct listmgr *lmgr, Eina_List *list,
return false;
}
+ if (!list) {
+ elm_object_focus_allow_set(lmgr->scr, EINA_FALSE);
+ return true;
+ }
+
lmgr->data->gdata = gdata;
elm_scroller_step_size_set(lmgr->scr, ELM_SCALE_SIZE(SCROLLER_STEP_SIZE(
diff --git a/src/view/base.c b/src/view/base.c
index c1fee10..aba56f2 100644
--- a/src/view/base.c
+++ b/src/view/base.c
@@ -30,6 +30,7 @@
#include "view.h"
#include "data/datamgr.h"
#include "util/ctxpopup.h"
+#include "util/usb.h"
#include "util/util.h"
#define TITLE_TEXT "Media Hub"
@@ -49,13 +50,6 @@ enum _object_type {
BASE_SOURCE_BTN
};
-enum _layout_type {
- E_LAYOUT_MOVIE = 0,
- E_LAYOUT_GALLERY,
- E_LAYOUT_MUSIC,
- E_LAYOUT_MAX
-};
-
struct _priv {
Evas_Object *win;
Evas_Object *base;
@@ -67,6 +61,9 @@ struct _priv {
Evas_Object *notify;
+ struct usb *usb_h;
+ media_content_noti_h noti_h;
+
struct ctxpopup *cpopup;
layoutmgr *lmgr;
@@ -781,8 +778,60 @@ static void _show_toast_favorite(struct _priv *priv, const char *id)
priv->notify = notify;
}
+static void _media_db_updated_cb(media_content_error_e error,
+ int pid,
+ media_content_db_update_item_type_e update_item,
+ media_content_db_update_type_e update_type,
+ media_content_type_e media_type,
+ char *uuid,
+ char *path,
+ char *mime_type,
+ void *user_data)
+{
+ struct view_update_data vdata;
+ struct _priv *priv;
+ int i;
+
+ if (!user_data) {
+ _ERR("invalid argument");
+ return;
+ }
+
+ priv = user_data;
+
+ vdata.index = priv->current_layout;
+
+ for (i = 0; i < E_LAYOUT_MAX; i++) {
+ layoutmgr_update_layout(priv->lmgr,
+ g_menu_item[i].layout_id,
+ UPDATE_SOURCE_CONTENT, &vdata);
+ }
+
+ media_content_remove_db_updated_cb(priv->noti_h);
+}
+
+static void _usb_changed_cb(void *data, int state)
+{
+ media_content_noti_h noti_h;
+ struct _priv *priv;
+ int r;
+
+ if (!data)
+ return;
+
+ priv = data;
+
+ r = media_content_add_db_updated_cb(_media_db_updated_cb,
+ priv, &noti_h);
+ if (r != MEDIA_CONTENT_ERROR_NONE)
+ _ERR("failed to add db updated cb: %d", r);
+
+ priv->noti_h = noti_h;
+}
+
static Evas_Object *_create(Evas_Object *win, void *data)
{
+ struct usb *usb_h;
struct layout_data ldata;
struct _priv *priv;
Evas_Object *base;
@@ -816,6 +865,17 @@ static Evas_Object *_create(Evas_Object *win, void *data)
priv->win = win;
priv->base = base;
+ usb_h = usb_create();
+ if (!usb_h) {
+ _ERR("failed to create usb");
+ free(priv);
+ return NULL;
+ }
+
+ usb_set_callback(usb_h, _usb_changed_cb, priv);
+
+ priv->usb_h = usb_h;
+
if (!_draw_items(priv)) {
_ERR("failed to draw items");
free(priv);
@@ -968,6 +1028,8 @@ static void _destroy(void *view_data)
priv = view_data;
+ usb_destroy(priv->usb_h);
+
for (i = 0; i < E_LAYOUT_MAX; i++)
inputmgr_remove_callback(priv->menu_btn[i], &handler);