media_info_destroy(media);
}
+static void _web_list_foreach(gpointer data, gpointer user_data)
+{
+ struct recent_data *rdata;
+ struct datamgr *dm;
+ int r, w, h, size, time, id;
+ char *title, *url;
+ unsigned char *value;
+ struct thumbnail_data *thumbnail;
+ struct datamgr_item *di;
+
+ if (!data || !user_data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ rdata = data;
+ dm = user_data;
+
+ r = bp_history_adaptor_initialize();
+ if (r < 0) {
+ _ERR("Initialize history adaptor failed.");
+ return;
+ }
+
+ id = atoi(rdata->id);
+
+ r = bp_history_adaptor_get_title(id, &title);
+ if (r < 0) {
+ _ERR("failed to get title of history");
+ goto err;
+ }
+
+ r = bp_history_adaptor_get_url(id, &url);
+ if (r < 0) {
+ _ERR("failed to get url of history");
+ goto err;
+ }
+
+ r = bp_history_adaptor_get_date_visited(id, &time);
+ if (r < 0) {
+ _ERR("failed to get icon of history");
+ goto err;
+ }
+
+ r = bp_history_adaptor_get_snapshot(id, &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);
+
+err:
+ bp_history_adaptor_deinitialize();
+}
+
static bool _load_recent(struct datamgr *dm, enum app_contents_type type,
int count, GFunc func)
{
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 (!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");
+ if (!_load_recent(dm, CONTENTS_WEB, 1, _web_list_foreach))
+ _ERR("failed to load recent web contents");
dm->list = eina_list_sort(dm->list, 0, _sort_list);
static void _clear(struct datamgr *dm)
{
- if (!app_contents_recent_clear_all())
+ int r;
+
+ r = app_contents_recent_clear_all();
+ if (r != APP_CONTENTS_ERROR_NONE)
_ERR("failed to clear all recents");
}