From: Soohye Shin Date: Tue, 4 Aug 2015 12:29:46 +0000 (+0900) Subject: integrate media-content for recent movie/gallery/music X-Git-Tag: accepted/tizen/tv/20150805.065759~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a6fce5ce18910e1ea4e0d3584e94a15722579d3;p=profile%2Ftv%2Fapps%2Fnative%2Fair_home.git integrate media-content for recent movie/gallery/music - modify launch utils func for passing the param to application - add default recent thumbnail files Change-Id: I90fa5bcebdbd8d817423593817c70738a2312ade Signed-off-by: Soohye Shin --- diff --git a/images/ic_default_app.png b/images/ic_default_app.png new file mode 100644 index 0000000..82c7956 Binary files /dev/null and b/images/ic_default_app.png differ diff --git a/images/ic_default_setting.png b/images/ic_default_setting.png new file mode 100644 index 0000000..d69354a Binary files /dev/null and b/images/ic_default_setting.png differ diff --git a/images/ic_default_tv.png b/images/ic_default_tv.png new file mode 100644 index 0000000..71db087 Binary files /dev/null and b/images/ic_default_tv.png differ diff --git a/include/datamgr.h b/include/datamgr.h index f2c5e90..8278688 100644 --- a/include/datamgr.h +++ b/include/datamgr.h @@ -43,6 +43,8 @@ struct datamgr_item { char *focus_icon; char *thumbnail; char *parameter; + char *key; + char *value; bool noti; enum datamgr_item_select_action action; int type; diff --git a/include/defs.h b/include/defs.h index 816d66d..560dae6 100644 --- a/include/defs.h +++ b/include/defs.h @@ -175,12 +175,15 @@ #define IMAGE_RECENT_DELETE_NOR IMAGEDIR"/btn_bar_clearall_nor.png" #define IMAGE_RECENT_DELETE_FOC IMAGEDIR"/btn_bar_clearall_foc.png" #define IMAGE_RECENT_DELETE_DIS IMAGEDIR"/btn_bar_clearall_dis.png" -#define IMAGE_RECENT_APP IMAGEDIR"/ic_thumbnail_app.png" -#define IMAGE_RECENT_CHANNEL IMAGEDIR"/ic_thumbnail_tv.png" -#define IMAGE_RECENT_MOVIE IMAGEDIR"/ic_thumbnail_movie.png" -#define IMAGE_RECENT_GALLERY IMAGEDIR"/ic_thumbnail_gallery.png" -#define IMAGE_RECENT_MUSIC IMAGEDIR"/ic_thumbnail_music.png" -#define IMAGE_RECENT_WEB IMAGEDIR"/ic_thumbnail_web.png" +#define IMAGE_RECENT_ICON_APP IMAGEDIR"/ic_thumbnail_app.png" +#define IMAGE_RECENT_ICON_CHANNEL IMAGEDIR"/ic_thumbnail_tv.png" +#define IMAGE_RECENT_ICON_MOVIE IMAGEDIR"/ic_thumbnail_movie.png" +#define IMAGE_RECENT_ICON_GALLERY IMAGEDIR"/ic_thumbnail_gallery.png" +#define IMAGE_RECENT_ICON_MUSIC IMAGEDIR"/ic_thumbnail_music.png" +#define IMAGE_RECENT_ICON_WEB IMAGEDIR"/ic_thumbnail_web.png" +#define IMAGE_RECENT_THUMB_APP IMAGEDIR"/ic_default_app.png" +#define IMAGE_RECENT_THUMB_CHANNEL IMAGEDIR"/ic_default_tv.png" +#define IMAGE_RECENT_THUMB_SETTING IMAGEDIR"/ic_default_setting" #define MAX_ITEM_COUNT 8 #define MAX_USER_COUNT 9 @@ -196,6 +199,13 @@ #define MESSAGE_DELETE_CONTENTS "If you delete this user, their data will also be deleted." #define MESSAGE_DISCARD_CONTENTS "Discard all entered data?
If you are out of this screen, data won't be saved" +#define KEY_MEDIA "Recent" +#define KEY_CHANNEL "service_id" + +#define PACKAGE_LIVETV "org.tizen.live-tv" +#define PACKAGE_MEDIAHUB "org.tizen.mediahub" +#define PACKAGE_SETTINGS "org.tizen.settings-tv-ref" + #define GUM_ATTR_NAME "username" #define GUM_ATTR_USERTYPE "usertype" #define GUM_ATTR_UID "uid" diff --git a/include/utils.h b/include/utils.h index f8127f2..7c6c3d5 100644 --- a/include/utils.h +++ b/include/utils.h @@ -48,6 +48,6 @@ Evas_Object *utils_add_button(Evas_Object *base, char *text, const char *part); Evas_Object *utils_add_entry(Evas_Object *base, char *text, bool password, const char *part); Evas_Object *utils_add_popup(Evas_Object *base, char *title, char *message); -bool utils_launch_app(const char *pkg); +bool utils_launch_app(const char *pkg, const char *key, const char *value); #endif /* __AIR_HOME_UTILS_H__ */ diff --git a/src/data/data_home.c b/src/data/data_home.c index b6b9789..e55a0a4 100644 --- a/src/data/data_home.c +++ b/src/data/data_home.c @@ -349,7 +349,7 @@ static void _select(struct datamgr_item *di) switch (di->action) { case ITEM_SELECT_ACTION_LAUNCH: - utils_launch_app(di->parameter); + utils_launch_app(di->parameter, NULL, NULL); break; case ITEM_SELECT_ACTION_PUSH: viewmgr_push_view(di->parameter); diff --git a/src/data/data_photo.c b/src/data/data_photo.c index a1ec25f..d1228b6 100644 --- a/src/data/data_photo.c +++ b/src/data/data_photo.c @@ -91,19 +91,6 @@ static Eina_List *_get_items(struct datamgr *dm) static bool _init(struct datamgr *dm) { - int r; - - if (!dm) { - _ERR("Invalid argument"); - return false; - } - - r = media_content_connect(); - if (r != MEDIA_CONTENT_ERROR_NONE) { - _ERR("failed to connect media content"); - return false; - } - return true; } @@ -115,8 +102,6 @@ static void _fini(struct datamgr *dm) } _unload_photo(dm); - - media_content_disconnect(); } static struct data_class dclass = { diff --git a/src/data/data_recent.c b/src/data/data_recent.c index b923ec9..dc38493 100644 --- a/src/data/data_recent.c +++ b/src/data/data_recent.c @@ -21,19 +21,19 @@ #include #include #include +#include +#include #include "data_recent.h" #include "datamgr.h" #include "utils.h" #include "defs.h" -/* FIXME: change default thumbnail */ -#define THUMB_DEFAULT "/usr/share/icons/default/small/apps_img_app_default_4x2.png" - #define BUF_TITLE_MAX 128 static struct datamgr_item *_new_datamgr_item(char *title, char *thumb, - char *parameter, char *icon, int type) + char *subtitle, char *parameter, char *key, char *value, + char *icon, int type) { struct datamgr_item *di; @@ -49,6 +49,12 @@ static struct datamgr_item *_new_datamgr_item(char *title, char *thumb, di->type = type; di->parameter = strdup(parameter); di->action = ITEM_SELECT_ACTION_LAUNCH; + if (subtitle) + di->subtitle = strdup(subtitle); + if (key) + di->key = strdup(key); + if (value) + di->value = strdup(value); return di; } @@ -56,7 +62,7 @@ static struct datamgr_item *_new_datamgr_item(char *title, char *thumb, static void _app_list_foreach(gpointer data, gpointer user_data) { struct recent_data *rdata; - char *label, *thumb, *thumb_land; + char *label, *thumb; pkgmgrinfo_appinfo_h handle; int r; struct datamgr_item *di; @@ -79,43 +85,27 @@ static void _app_list_foreach(gpointer data, gpointer user_data) return; } + label = NULL; + thumb = NULL; r = pkgmgrinfo_appinfo_get_label(handle, &label); if (r != PMINFO_R_OK) _ERR("failed to get app label"); - r = pkgmgrinfo_appinfo_get_effectimage(handle, &thumb, &thumb_land); + r = pkgmgrinfo_appinfo_get_icon(handle, &thumb); if (r != PMINFO_R_OK) _ERR("failed to get app icon"); - if (!thumb_land || !strcmp(thumb_land, "")) - thumb_land = THUMB_DEFAULT; + if (!thumb || !strcmp(thumb, "")) + thumb = IMAGE_RECENT_THUMB_APP; - di = _new_datamgr_item(label, thumb_land, rdata->id, IMAGE_RECENT_APP, - 0); + di = _new_datamgr_item(label, thumb, NULL, rdata->id, NULL, NULL, + IMAGE_RECENT_ICON_APP, 0); if (di) dm->list = eina_list_append(dm->list, di); pkgmgrinfo_appinfo_destroy_appinfo(handle); } -static bool _load_recent_app(struct datamgr *dm) -{ - GList *app_list = NULL; - int r; - - r = app_contents_get_recent_list(CONTENTS_APP, -1, &app_list); - if (r != APP_CONTENTS_ERROR_NONE) { - _ERR("failed to get recent app list"); - return false; - } - - g_list_foreach(app_list, _app_list_foreach, dm); - - app_contents_free_recent_list(app_list); - - return true; -} - static void _channel_list_foreach(gpointer data, gpointer user_data) { struct recent_data *rdata; @@ -149,39 +139,200 @@ static void _channel_list_foreach(gpointer data, gpointer user_data) channel.program_name ? channel.program_name : ""); - di = _new_datamgr_item(buf, THUMB_DEFAULT, rdata->id, - IMAGE_RECENT_CHANNEL, 1); + di = _new_datamgr_item(buf, IMAGE_RECENT_THUMB_CHANNEL, NULL, + PACKAGE_LIVETV, KEY_CHANNEL, rdata->id, + IMAGE_RECENT_ICON_CHANNEL, 1); if (di) dm->list = eina_list_append(dm->list, di); } -static bool _load_recent_channel(struct datamgr *dm) +static void _gallery_list_foreach(gpointer data, gpointer user_data) { - GList *channel_list = NULL; + struct recent_data *rdata; + struct datamgr_item *di; + struct datamgr *dm; + app_media *am; + app_media_info *aminfo; + media_info_h media; int r; - r = app_contents_get_recent_list(CONTENTS_CHANNEL, 1, &channel_list); - if (r != APP_CONTENTS_ERROR_NONE) { - _ERR("failed to get recent channel list"); - return false; + if (!data || !user_data) { + _ERR("Invalid arguement"); + return; } - g_list_foreach(channel_list, _channel_list_foreach, dm); + rdata = data; + dm = user_data; - app_contents_free_recent_list(channel_list); + r = media_info_get_media_from_db(rdata->id, &media); + if (r != MEDIA_CONTENT_ERROR_NONE) { + _ERR("failed to get media"); + return; + } - return true; + am = app_media_create(media); + if (!am) { + _ERR("failed to create media"); + media_info_destroy(media); + return; + } + + aminfo = app_media_get_info(am); + if (!aminfo) { + _ERR("failed to get media info"); + app_media_destroy(am); + media_info_destroy(media); + return; + } + + di = _new_datamgr_item(aminfo->title, aminfo->thumbnail_path, NULL, + PACKAGE_MEDIAHUB, KEY_MEDIA, rdata->id, + IMAGE_RECENT_ICON_GALLERY, 1); + + if (di) + dm->list = eina_list_append(dm->list, di); + + app_media_destroy(am); + media_info_destroy(media); } -static bool _load_recent(struct datamgr *dm) +static void _get_duration(int duration, char **str) { - if (!_load_recent_app(dm)) - _ERR("failed to load recent app"); + char buf[BUF_TITLE_MAX]; + int h, m, s, sec; + + sec = duration / 1000; + h = sec / 3600; + m = (sec % 3600) / 60; + s = sec % 60; + + if (h) + snprintf(buf, sizeof(buf), "%d:%02d:%02d", h, m, s); + else + snprintf(buf, sizeof(buf), "%d:%02d", m, s); + + *str = buf; +} + +static void _movie_list_foreach(gpointer data, gpointer user_data) +{ + struct recent_data *rdata; + struct datamgr_item *di; + struct datamgr *dm; + app_media *am; + app_media_info *aminfo; + media_info_h media; + int r; + char *dur = NULL; + + if (!data || !user_data) { + _ERR("Invalid arguement"); + return; + } - if (!_load_recent_channel(dm)) - _ERR("failed to load recent channel"); + rdata = data; + dm = user_data; - /* It should be implemented later about media contents */ + r = media_info_get_media_from_db(rdata->id, &media); + if (r != MEDIA_CONTENT_ERROR_NONE) { + _ERR("failed to get media"); + return; + } + + am = app_media_create(media); + if (!am) { + _ERR("failed to create media"); + media_info_destroy(media); + return; + } + + aminfo = app_media_get_info(am); + if (!aminfo) { + _ERR("failed to get media info"); + app_media_destroy(am); + media_info_destroy(media); + return; + } + + if (aminfo->video && aminfo->video->duration) + _get_duration(aminfo->video->duration, &dur); + + di = _new_datamgr_item(aminfo->title, aminfo->thumbnail_path, + dur ? dur : NULL, PACKAGE_MEDIAHUB, KEY_MEDIA, + rdata->id, IMAGE_RECENT_ICON_MOVIE, 1); + + if (di) + dm->list = eina_list_append(dm->list, di); + + app_media_destroy(am); + media_info_destroy(media); +} + +static void _music_list_foreach(gpointer data, gpointer user_data) +{ + struct recent_data *rdata; + struct datamgr_item *di; + struct datamgr *dm; + app_media *am; + app_media_info *aminfo; + media_info_h media; + int r; + + if (!data || !user_data) { + _ERR("Invalid arguement"); + return; + } + + rdata = data; + dm = user_data; + + r = media_info_get_media_from_db(rdata->id, &media); + if (r != MEDIA_CONTENT_ERROR_NONE) { + _ERR("failed to get media"); + return; + } + + am = app_media_create(media); + if (!am) { + _ERR("failed to create media"); + media_info_destroy(media); + return; + } + + aminfo = app_media_get_info(am); + if (!aminfo) { + _ERR("failed to get media info"); + app_media_destroy(am); + media_info_destroy(media); + return; + } + + di = _new_datamgr_item(aminfo->title, aminfo->thumbnail_path, + aminfo->audio->artist, PACKAGE_MEDIAHUB, KEY_MEDIA, + rdata->id, IMAGE_RECENT_ICON_MUSIC, 1); + + if (di) + dm->list = eina_list_append(dm->list, di); + + app_media_destroy(am); + media_info_destroy(media); +} + +static bool _load_recent(struct datamgr *dm, enum app_contents_type type, + int count, GFunc func) +{ + GList *rlist = NULL; + int r; + + r = app_contents_get_recent_list(type, count, &rlist); + if (r != APP_CONTENTS_ERROR_NONE) { + _ERR("failed to get recent list"); + return false; + } + + g_list_foreach(rlist, func, dm); + + app_contents_free_recent_list(rlist); return true; } @@ -192,9 +343,12 @@ static void _unload_recent(struct datamgr *dm) EINA_LIST_FREE(dm->list, di) { free(di->title); + free(di->subtitle); free(di->icon); free(di->focus_icon); free(di->parameter); + free(di->key); + free(di->value); free(di); } @@ -210,7 +364,23 @@ static Eina_List *_get_items(struct datamgr *dm) } _unload_recent(dm); - _load_recent(dm); + + if (!_load_recent(dm, CONTENTS_APP, -1, _app_list_foreach)) + _ERR("failed to load recent app contents"); + + if (!_load_recent(dm, CONTENTS_CHANNEL, 1, _channel_list_foreach)) + _ERR("failed to load recent channel contents"); + + if (!_load_recent(dm, CONTENTS_GALLERY, 1, _gallery_list_foreach)) + _ERR("failed to load recent gallery contents"); + + if (!_load_recent(dm, CONTENTS_MOVIE, 1, _movie_list_foreach)) + _ERR("failed to load recent movie contents"); + + if (!_load_recent(dm, CONTENTS_MUSIC, 1, _music_list_foreach)) + _ERR("failed to load recent music contents"); + + /* TODO: Sort for contents list */ return dm->list; } @@ -224,6 +394,7 @@ static void _fini(struct datamgr *dm) _unload_recent(dm); + media_content_disconnect(); tv_service_channel_info_destroy(); } @@ -242,7 +413,14 @@ static bool _init(struct datamgr *dm) return false; } - return _load_recent(dm); + r = media_content_connect(); + if (r != MEDIA_CONTENT_ERROR_NONE) { + tv_service_channel_info_destroy(); + _ERR("failed to connect media content"); + return false; + } + + return true; } static void _select(struct datamgr_item *di) @@ -252,7 +430,7 @@ static void _select(struct datamgr_item *di) switch (di->action) { case ITEM_SELECT_ACTION_LAUNCH: - utils_launch_app(di->parameter); + utils_launch_app(di->parameter, di->key, di->value); break; default: _ERR("Invalid state"); @@ -262,15 +440,7 @@ static void _select(struct datamgr_item *di) static void _clear(struct datamgr *dm) { - int r; - - r = app_contents_recent_clear(CONTENTS_APP); - if (r != APP_CONTENTS_ERROR_NONE) { - _ERR("failed to clear app recent"); - return; - } - - /* It should be implemeted later about media contents */ + /* It should be implemented later */ } static struct data_class dclass = { diff --git a/src/utils.c b/src/utils.c index aadb952..36c6fa6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -371,7 +371,7 @@ Evas_Object *utils_add_popup(Evas_Object *base, char *title, char *message) return popup; } -bool utils_launch_app(const char *pkg) +bool utils_launch_app(const char *pkg, const char *key, const char *value) { app_control_h app_control; int r; @@ -383,6 +383,8 @@ bool utils_launch_app(const char *pkg) app_control_create(&app_control); app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT); + if (key && value) + app_control_add_extra_data(app_control, key, value); app_control_set_app_id(app_control, pkg); r = app_control_send_launch_request(app_control, NULL, NULL);