integrate tv-service for recent channel 15/45215/1 accepted/tizen/tv/20150804.011650 submit/tizen/20150804.005548
authorSoohye Shin <soohye.shin@samsung.com>
Mon, 3 Aug 2015 14:16:50 +0000 (23:16 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Mon, 3 Aug 2015 14:17:29 +0000 (23:17 +0900)
Change-Id: Ic32649fdbdc54f3ec6dd86816864eba3d0899435
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
CMakeLists.txt
include/defs.h
packaging/org.tizen.home.spec
src/data/data_recent.c

index 18cd8d8..c19a6b5 100644 (file)
@@ -70,6 +70,7 @@ pkg_check_modules(PKGS REQUIRED
                app-utils
                pkgmgr-info
                notification
+               tv-service
                capi-appfw-application)
 
 FOREACH(flag ${PKGS_CFLAGS})
index 23a7573..816d66d 100644 (file)
 #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 MAX_ITEM_COUNT 8
 #define MAX_USER_COUNT 9
index c2b9785..4a5f5b0 100644 (file)
@@ -17,6 +17,7 @@ BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(libgum)
 BuildRequires: pkgconfig(app-utils)
 BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(tv-service)
 BuildRequires: pkgconfig(notification)
 BuildRequires: edje-bin
 BuildRequires: gettext-devel
index 7259ba1..b923ec9 100644 (file)
@@ -20,6 +20,7 @@
 #include <app_contents.h>
 #include <glib.h>
 #include <pkgmgr-info.h>
+#include <tv_service_proxy_channel_info.h>
 
 #include "data_recent.h"
 #include "datamgr.h"
@@ -29,6 +30,8 @@
 /* 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)
 {
@@ -84,7 +87,7 @@ static void _app_list_foreach(gpointer data, gpointer user_data)
        if (r != PMINFO_R_OK)
                _ERR("failed to get app icon");
 
-       if (!strcmp(thumb_land, ""))
+       if (!thumb_land || !strcmp(thumb_land, ""))
                thumb_land = THUMB_DEFAULT;
 
        di = _new_datamgr_item(label, thumb_land, rdata->id, IMAGE_RECENT_APP,
@@ -113,11 +116,71 @@ static bool _load_recent_app(struct datamgr *dm)
        return true;
 }
 
+static void _channel_list_foreach(gpointer data, gpointer user_data)
+{
+       struct recent_data *rdata;
+       struct datamgr_item *di;
+       struct datamgr *dm;
+       TvServiceChannel channel;
+       int r;
+       char buf[BUF_TITLE_MAX];
+
+       if (!data || !user_data) {
+               _ERR("Invalid argument");
+               return;
+       }
+
+       rdata = data;
+       dm = user_data;
+
+       r = tv_service_get_channel(atoi(rdata->id), &channel);
+       if (r != TVS_ERROR_OK) {
+               _ERR("failed to get channel");
+               return;
+       }
+
+       if (channel.minor > 0)
+               snprintf(buf, sizeof(buf), "%ld-%ld %s",
+                               channel.major, channel.minor,
+                               channel.program_name ?
+                                               channel.program_name : "");
+       else
+               snprintf(buf, sizeof(buf), "%ld %s", channel.major,
+                               channel.program_name ?
+                                               channel.program_name : "");
+
+       di = _new_datamgr_item(buf, THUMB_DEFAULT, rdata->id,
+                       IMAGE_RECENT_CHANNEL, 1);
+       if (di)
+               dm->list = eina_list_append(dm->list, di);
+}
+
+static bool _load_recent_channel(struct datamgr *dm)
+{
+       GList *channel_list = NULL;
+       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;
+       }
+
+       g_list_foreach(channel_list, _channel_list_foreach, dm);
+
+       app_contents_free_recent_list(channel_list);
+
+       return true;
+}
+
 static bool _load_recent(struct datamgr *dm)
 {
        if (!_load_recent_app(dm))
                _ERR("failed to load recent app");
 
+       if (!_load_recent_channel(dm))
+               _ERR("failed to load recent channel");
+
        /* It should be implemented later about media contents */
 
        return true;
@@ -129,8 +192,8 @@ 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);
@@ -160,10 +223,25 @@ static void _fini(struct datamgr *dm)
        }
 
        _unload_recent(dm);
+
+       tv_service_channel_info_destroy();
 }
 
 static bool _init(struct datamgr *dm)
 {
+       int r;
+
+       if (!dm) {
+               _ERR("Invalid argument");
+               return false;
+       }
+
+       r = tv_service_channel_info_create();
+       if (r != TVS_ERROR_OK) {
+               _ERR("failed to create tv service");
+               return false;
+       }
+
        return _load_recent(dm);
 }