#include <app_media.h>
#include <app_define.h>
#include <app_contents.h>
+#include <web/web_history.h>
#include <time.h>
#include <ctype.h>
#define BUF_TITLE_MAX 128
#define MAX_BUF 64
-static struct datamgr_item *_new_datamgr_item(char *title, char *thumb,
- char *subtitle, char *parameter, char *key, char *value,
- char *icon, int type, time_t time)
+static struct datamgr_item *_new_datamgr_item(char *title, char *subtitle,
+ char *parameter, char *key, char *value, char *icon, int type,
+ time_t time)
{
struct datamgr_item *di;
}
di->title = strdup(title);
- di->focus_icon = strdup(icon);
+ di->icon = strdup(icon);
di->type = type;
di->parameter = strdup(parameter);
di->action = ITEM_SELECT_ACTION_LAUNCH;
di->time = time;
- if (thumb)
- di->icon = strdup(thumb);
+
if (subtitle)
di->subtitle = strdup(subtitle);
if (key && value) {
pkgmgrinfo_appinfo_h handle;
int r;
struct datamgr_item *di;
+ struct thumbnail_data *thumbnail;
struct datamgr *dm;
bool nodisplay;
if (!thumb || !strcmp(thumb, ""))
thumb = IMAGE_RECENT_THUMB_APP;
- di = _new_datamgr_item(label, thumb, NULL, rdata->id, NULL, NULL,
+ di = _new_datamgr_item(label, NULL, rdata->id, NULL, NULL,
IMAGE_RECENT_ICON_APP, 0, rdata->time);
- if (di)
+ if (di) {
+ thumbnail = calloc(1, sizeof(*thumbnail));
+ if (thumbnail) {
+ thumbnail->file = strdup(thumb);
+ thumbnail->type = THUMBNAIL_FILE;
+ di->thumbnail = thumbnail;
+ }
dm->list = eina_list_append(dm->list, di);
+ }
pkgmgrinfo_appinfo_destroy_appinfo(handle);
}
{
struct recent_data *rdata;
struct datamgr_item *di;
+ struct thumbnail_data *thumbnail;
struct datamgr *dm;
TvServiceChannel channel;
int r;
_get_program(atoi(rdata->id), &program);
- di = _new_datamgr_item(buf, thumb ? thumb : IMAGE_RECENT_THUMB_CHANNEL,
- program, APP_ID_LIVETV, PARAM_SERVICE_ID,
+ di = _new_datamgr_item(buf, program, APP_ID_LIVETV, PARAM_SERVICE_ID,
rdata->id, IMAGE_RECENT_ICON_CHANNEL, 1, rdata->time);
- if (di)
+ if (di) {
+ thumbnail = calloc(1, sizeof(*thumbnail));
+ if (thumbnail) {
+ thumbnail->file = strdup(thumb ? thumb :
+ IMAGE_RECENT_THUMB_CHANNEL);
+ thumbnail->type = THUMBNAIL_FILE;
+ di->thumbnail = thumbnail;
+ }
dm->list = eina_list_append(dm->list, di);
+ }
}
static void _set_up_string(char *str)
{
struct recent_data *rdata;
struct datamgr_item *di;
+ struct thumbnail_data *thumbnail;
struct datamgr *dm;
app_media *am;
app_media_info *aminfo;
_set_up_string(day);
snprintf(buf, sizeof(buf), "%s, %s", day, date);
- di = _new_datamgr_item(buf, aminfo->thumbnail_path, NULL,
- APP_ID_MEDIAHUB, PARAM_MEDIA_ID, rdata->id,
- IMAGE_RECENT_ICON_GALLERY, 1, rdata->time);
- if (di)
+ di = _new_datamgr_item(buf, NULL, APP_ID_MEDIAHUB, PARAM_MEDIA_ID,
+ rdata->id, IMAGE_RECENT_ICON_GALLERY, 1, rdata->time);
+ if (di) {
+ thumbnail = calloc(1, sizeof(*thumbnail));
+ if (thumbnail) {
+ thumbnail->file = strdup(aminfo->thumbnail_path);
+ thumbnail->type = THUMBNAIL_FILE;
+ di->thumbnail = thumbnail;
+ }
dm->list = eina_list_append(dm->list, di);
+ }
app_media_destroy(am);
media_info_destroy(media);
{
struct recent_data *rdata;
struct datamgr_item *di;
+ struct thumbnail_data *thumbnail;
struct datamgr *dm;
app_media *am;
app_media_info *aminfo;
if (aminfo->video && aminfo->video->duration)
_get_duration(aminfo->video->duration, dur, sizeof(dur));
- di = _new_datamgr_item(aminfo->title, aminfo->thumbnail_path,
- dur, APP_ID_MEDIAHUB, PARAM_MEDIA_ID,
- rdata->id, IMAGE_RECENT_ICON_MOVIE, 1, rdata->time);
- if (di)
+ di = _new_datamgr_item(aminfo->title, dur, APP_ID_MEDIAHUB,
+ PARAM_MEDIA_ID, rdata->id, IMAGE_RECENT_ICON_MOVIE, 1,
+ rdata->time);
+ if (di) {
+ thumbnail = calloc(1, sizeof(*thumbnail));
+ if (thumbnail) {
+ thumbnail->file = strdup(aminfo->thumbnail_path);
+ thumbnail->type = THUMBNAIL_FILE;
+ di->thumbnail = thumbnail;
+ }
dm->list = eina_list_append(dm->list, di);
+ }
app_media_destroy(am);
media_info_destroy(media);
{
struct recent_data *rdata;
struct datamgr_item *di;
+ struct thumbnail_data *thumbnail;
struct datamgr *dm;
app_media *am;
app_media_info *aminfo;
return;
}
- di = _new_datamgr_item(aminfo->title, aminfo->thumbnail_path,
- aminfo->audio->artist, APP_ID_MEDIAHUB, PARAM_MEDIA_ID,
- rdata->id, IMAGE_RECENT_ICON_MUSIC, 1, rdata->time);
- if (di)
+ di = _new_datamgr_item(aminfo->title, aminfo->audio->artist,
+ APP_ID_MEDIAHUB, PARAM_MEDIA_ID, rdata->id,
+ IMAGE_RECENT_ICON_MUSIC, 1, rdata->time);
+ if (di) {
+ thumbnail = calloc(1, sizeof(*thumbnail));
+ if (thumbnail) {
+ thumbnail->file = strdup(aminfo->thumbnail_path);
+ thumbnail->type = THUMBNAIL_FILE;
+ di->thumbnail = thumbnail;
+ }
dm->list = eina_list_append(dm->list, di);
+ }
app_media_destroy(am);
media_info_destroy(media);
return true;
}
+static void _unload_thumbnail(struct thumbnail_data *thumbnail)
+{
+ if (!thumbnail)
+ return;
+
+ free(thumbnail->file);
+ free(thumbnail->data);
+ free(thumbnail->format);
+
+ free(thumbnail);
+}
+
static void _unload_recent(struct datamgr *dm)
{
struct datamgr_item *di;
free(di->key);
free(di->value);
+ _unload_thumbnail(di->thumbnail);
+
free(di);
}
static bool _load_recent_notification(struct datamgr *dm)
{
struct datamgr_item *di;
+ struct thumbnail_data *thumbnail;
int time, count;
char buf[MAX_BUF];
return false;
}
- di = _new_datamgr_item(MESSAGE_NOTIFICATION, IMAGE_RECENT_THUMB_NOTI,
- buf, APP_ID_INFOSQUARE, NULL, NULL,
- IMAGE_RECENT_ICON_APP, 0, time);
- if (di)
+ di = _new_datamgr_item(MESSAGE_NOTIFICATION, buf, APP_ID_INFOSQUARE,
+ NULL, NULL, IMAGE_RECENT_ICON_APP, 0, time);
+ if (di) {
+ thumbnail = calloc(1, sizeof(*thumbnail));
+ if (thumbnail) {
+ thumbnail->file = strdup(IMAGE_RECENT_THUMB_NOTI);
+ thumbnail->type = THUMBNAIL_FILE;
+ di->thumbnail = thumbnail;
+ }
dm->list = eina_list_append(dm->list, di);
+ }
+
+ return true;
+}
+
+static bool _load_recent_web(struct datamgr *dm)
+{
+ int r, time, count, *ids, w, h, size;
+ char *title, *url;
+ struct datamgr_item *di;
+ struct thumbnail_data *thumbnail;
+ unsigned char *value;
+ bp_history_rows_cond_fmt conds;
+
+ conds.limit = 1;
+ conds.offset = 0;
+ conds.ordering = 1;
+ conds.order_offset = BP_HISTORY_O_FREQUENCY;
+ conds.period_offset = BP_HISTORY_O_DATE_CREATED;
+ conds.period_type = BP_HISTORY_DATE_ALL;
+
+ r = bp_history_adaptor_initialize();
+ if (r < 0) {
+ _ERR("failed to initialize history adaptor");
+ return false;
+ }
+
+ ids = NULL;
+ count = 0;
+ r = bp_history_adaptor_get_cond_ids_p(&ids, &count, &conds,
+ BP_HISTORY_O_TITLE | BP_HISTORY_O_URL, NULL, 1);
+ if (r < 0 || count == 0) {
+ _ERR("failed to get cond ids of history");
+ goto err;
+ }
+
+ title = NULL;
+ r = bp_history_adaptor_get_title(ids[0], &title);
+ if (r < 0) {
+ _ERR("failed to get title of history");
+ goto err;
+ }
+
+ r = bp_history_adaptor_get_url(ids[0], &url);
+ if (r < 0) {
+ _ERR("failed to get url of history");
+ goto err;
+ }
+
+ r = bp_history_adaptor_get_date_visited(ids[0], &time);
+ if (r < 0) {
+ _ERR("failed to get icon of history");
+ goto err;
+ }
+
+ r = bp_history_adaptor_get_snapshot(ids[0], &w, &h, &value, &size);
+ if (r < 0) {
+ _ERR("failed to get snapshot of history");
+ goto err;
+ }
+
+ di = _new_datamgr_item(title, url, APP_ID_BROWSER, NULL, NULL,
+ IMAGE_RECENT_ICON_WEB, 1, time);
+ if (!di)
+ goto err;
+
+ thumbnail = calloc(1, sizeof(*thumbnail));
+ if (thumbnail) {
+ thumbnail->type = THUMBNAIL_DATA;
+ thumbnail->data = calloc(1, size);
+ if (thumbnail->data) {
+ memcpy(thumbnail->data, value, size);
+ thumbnail->format = strdup(FORMAT_PNG);
+ thumbnail->size = size;
+ di->thumbnail = thumbnail;
+ } else
+ free(thumbnail);
+ }
+ dm->list = eina_list_append(dm->list, di);
+
+ free(ids);
+ bp_history_adaptor_deinitialize();
return true;
+err:
+ free(ids);
+ bp_history_adaptor_deinitialize();
+ return false;
}
static Eina_List *_get_items(struct datamgr *dm)
if (!_load_recent_notification(dm))
_ERR("failed to load recent notification contents");
+ if (!_load_recent_web(dm))
+ _ERR("failed to load recent web content");
+
dm->list = eina_list_sort(dm->list, 0, _sort_list);
return dm->list;
bi = data;
bi->priv->cur = bi;
- /* fallthrought */
+ /* fallthrough */
case INPUT_HANDLER_TYPE_DELETE:
elm_object_signal_emit(obj, SIG_FOCUS, SRC_PROG);
break;
elm_object_part_content_set(eo, part, rect);
}
-static Evas_Object *_set_thumb(Evas_Object *eo, const char *file,
- const char *part)
+static Evas_Object *_add_thumb(Evas_Object *eo,
+ struct thumbnail_data *thumbnail)
{
Evas_Object *image;
int w, h;
return NULL;
}
- if (!elm_image_file_set(image, file, NULL)) {
- if (!elm_image_file_set(image, IMAGE_RECENT_THUMB_APP, NULL)) {
- _ERR("failed to set image file");
+ switch (thumbnail->type) {
+ case THUMBNAIL_FILE:
+ if (!elm_image_file_set(image, thumbnail->file, NULL)) {
+ if (!elm_image_file_set(image, IMAGE_RECENT_THUMB_APP,
+ NULL)) {
+ _ERR("failed to set image file");
+ evas_object_del(image);
+ return NULL;
+ }
+ }
+ break;
+ case THUMBNAIL_DATA:
+ if (!elm_image_memfile_set(image, thumbnail->data,
+ thumbnail->size, thumbnail->format, NULL)) {
+ _ERR("failed to set memfile");
evas_object_del(image);
return NULL;
}
+ break;
+ default:
+ _ERR("Invalid type");
+ evas_object_del(image);
+ return NULL;
}
+
elm_image_object_size_get(image, &w, &h);
if (w <= IMAGE_MAX_SIZE && h <= IMAGE_MAX_SIZE)
elm_image_resizable_set(image, EINA_FALSE, EINA_FALSE);
else
elm_image_fill_outside_set(image, EINA_TRUE);
- elm_object_part_content_set(eo, part, image);
+ elm_object_part_content_set(eo, PART_RECENT_THUMBNAIL, image);
return image;
}
}
evas_object_show(eo);
- ic = utils_add_icon(eo, di->focus_icon, PART_RECENT_ICON);
+ ic = utils_add_icon(eo, di->icon, PART_RECENT_ICON);
if (!ic)
_ERR("failed to add icon");
+ thumb = _add_thumb(eo, di->thumbnail);
+ if (!thumb)
+ _ERR("failed to add thumbnail");
+
lbl = utils_add_label(eo, di->title, STYLE_LABEL_RECENT_TITLE,
PART_RECENT_TITLE);
if (!lbl) {
return NULL;
}
- if (di->icon) {
- thumb = _set_thumb(eo, di->icon, PART_RECENT_THUMBNAIL);
- if (!thumb) {
- _ERR("failed to add thumb");
- evas_object_del(eo);
- free(bi);
- return NULL;
- }
- }
-
if (di->subtitle) {
sub_lbl = utils_add_label(eo, di->subtitle,
STYLE_LABEL_RECENT_SUBTITLE,