From c1dbdad995bc41ad26fd50721c3f6e872171de20 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 14 Jun 2006 22:46:12 +0000 Subject: Provide persistent flag for urldb entries. Make hotlist use this, rather than abusing the last visited date. This fixes the hotlist being copied to global history issue. svn path=/trunk/netsurf/; revision=2619 --- content/urldb.c | 29 +++++++++++++++++++++++++---- content/urldb.h | 1 + 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'content') diff --git a/content/urldb.c b/content/urldb.c index f150aeb25..43aff459f 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -125,6 +125,7 @@ struct path_data { char *segment; /**< Path segment for this node */ unsigned int frag_cnt; /**< Number of entries in ::fragment */ char **fragment; /**< Array of fragments */ + bool persistent; /**< This entry should persist */ struct bitmap *thumb; /**< Thumbnail image of resource */ struct url_internal_data urld; /**< URL data for resource */ @@ -548,8 +549,8 @@ void urldb_count_urls(const struct path_data *root, time_t expiry, const struct path_data *p; if (!root->children) { - if ((root->urld.last_visit > expiry) && - (root->urld.visits > 0)) + if (root->persistent || ((root->urld.last_visit > expiry) && + (root->urld.visits > 0))) (*count)++; } @@ -578,8 +579,9 @@ void urldb_write_paths(const struct path_data *parent, const char *host, if (!parent->children) { /* leaf node */ - if (!((parent->urld.last_visit > expiry) && - (parent->urld.visits > 0))) + if (!(parent->persistent || + ((parent->urld.last_visit > expiry) && + (parent->urld.visits > 0)))) /* expired */ return; @@ -648,6 +650,25 @@ void urldb_write_paths(const struct path_data *parent, const char *host, } } +/** + * Set the cross-session persistence of the entry for an URL + * + * \param url Absolute URL to persist + * \param persist True to persist, false otherwise + */ +void urldb_set_url_persistence(const char *url, bool persist) +{ + struct path_data *p; + + assert(url); + + p = urldb_find_url(url); + if (!p) + return; + + p->persistent = persist; +} + /** * Insert an URL into the database * diff --git a/content/urldb.h b/content/urldb.h index b7f57ebdd..e919549bf 100644 --- a/content/urldb.h +++ b/content/urldb.h @@ -28,6 +28,7 @@ struct bitmap; /* Persistence support */ void urldb_load(const char *filename); void urldb_save(const char *filename); +void urldb_set_url_persistence(const char *url, bool persist); /* URL insertion */ bool urldb_add_url(const char *url); -- cgit v1.2.3