#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"
/* 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)
{
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,
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;
EINA_LIST_FREE(dm->list, di) {
free(di->title);
- free(di->subtitle);
free(di->icon);
+ free(di->focus_icon);
free(di->parameter);
free(di);
}
_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);
}