summaryrefslogtreecommitdiff
path: root/desktop/hotlist.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-08-23 19:49:06 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2013-08-23 19:49:06 +0100
commit2c3d2e5f8e3a862dee1e0101e40abb9430736ef3 (patch)
tree1531098101d3ccf39805e79fb2c47fbab275d40a /desktop/hotlist.c
parent44e33001d7104cc7ec38a654f358392bf6240ad3 (diff)
downloadnetsurf-2c3d2e5f8e3a862dee1e0101e40abb9430736ef3.tar.gz
netsurf-2c3d2e5f8e3a862dee1e0101e40abb9430736ef3.tar.bz2
Add function to update visited data for hotlist entries.
Diffstat (limited to 'desktop/hotlist.c')
-rw-r--r--desktop/hotlist.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 95b358ced..645c7707b 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -1165,6 +1165,75 @@ void hotlist_remove_url(nsurl *url)
}
+struct treeview_update_url_walk_ctx {
+ nsurl *url;
+ const struct url_data *data;
+};
+/** Callback for treeview_walk */
+static nserror hotlist_update_url_walk_cb(void *ctx, void *node_data,
+ enum treeview_node_type type, bool *abort)
+{
+ struct treeview_update_url_walk_ctx *tw = ctx;
+ struct hotlist_entry *e = node_data;
+ nserror err;
+
+ if (type != TREE_NODE_ENTRY) {
+ return NSERROR_OK;
+ }
+
+ if (nsurl_compare(e->url, tw->url, NSURL_COMPLETE) == true) {
+ /* Found match: Update the entry data */
+ free((void *)e->data[HL_LAST_VISIT].value); /* Eww */
+ free((void *)e->data[HL_VISITS].value); /* Eww */
+
+ if (tw->data == NULL) {
+ /* Get the URL data */
+ tw->data = urldb_get_url_data(tw->url);
+ if (tw->data == NULL) {
+ /* No entry in database, so add one */
+ urldb_add_url(tw->url);
+ /* now attempt to get url data */
+ tw->data = urldb_get_url_data(tw->url);
+ }
+ if (tw->data == NULL) {
+ return NSERROR_NOMEM;
+ }
+ }
+
+ err = hotlist_create_treeview_field_data(e,
+ e->data[HL_TITLE].value, tw->data);
+ if (err != NSERROR_OK)
+ return err;
+
+ err = treeview_update_node_entry(hl_ctx.tree,
+ e->entry, e->data, e);
+ if (err != NSERROR_OK)
+ return err;
+ }
+
+ return NSERROR_OK;
+}
+/* Exported interface, documented in hotlist.h */
+void hotlist_update_url(nsurl *url)
+{
+ nserror err;
+ struct treeview_update_url_walk_ctx tw = {
+ .url = url,
+ .data = NULL
+ };
+
+ if (hl_ctx.built == false)
+ return;
+
+ err = treeview_walk(hl_ctx.tree, NULL, hotlist_update_url_walk_cb, NULL,
+ &tw, TREE_NODE_ENTRY);
+ if (err != NSERROR_OK)
+ return;
+
+ return;
+}
+
+
/* Exported interface, documented in hotlist.h */
void hotlist_redraw(int x, int y, struct rect *clip,
const struct redraw_context *ctx)