mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-25 07:49:38 +03:00
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
This commit is contained in:
parent
217e59aebe
commit
c1dbdad995
@ -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
|
||||
*
|
||||
|
@ -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);
|
||||
|
@ -435,14 +435,15 @@ void options_load_tree_entry(xmlNode *li, struct node *directory) {
|
||||
if (!data) {
|
||||
/* No entry in database, so add one */
|
||||
urldb_add_url(url);
|
||||
/* and bump visit data */
|
||||
urldb_update_url_visit_data(url);
|
||||
/* now attempt to get url data */
|
||||
data = urldb_get_url_data(url);
|
||||
}
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
/* Make this URL persistent */
|
||||
urldb_set_url_persistence(url, true);
|
||||
|
||||
if (!data->title)
|
||||
urldb_set_url_title(url, title);
|
||||
|
||||
|
@ -1535,7 +1535,7 @@ void ro_msg_dataload(wimp_message *message)
|
||||
data = urldb_get_url_data(url);
|
||||
if (!data) {
|
||||
urldb_add_url(url);
|
||||
urldb_update_url_visit_data(url);
|
||||
urldb_set_url_persistence(url, true);
|
||||
data = urldb_get_url_data(url);
|
||||
}
|
||||
if (data) {
|
||||
@ -2173,7 +2173,7 @@ void ro_gui_view_source(struct content *content)
|
||||
return;
|
||||
}
|
||||
snprintf(full_name, 256, "%s/%s", TEMP_FILENAME_PREFIX, temp_name);
|
||||
full_name[255] = '\0';
|
||||
full_name[255] = '\0';
|
||||
r = __riscosify(full_name, 0, __RISCOSIFY_NO_SUFFIX, message.file_name,
|
||||
212, 0);
|
||||
if (r == 0) {
|
||||
|
@ -105,8 +105,9 @@ void ro_gui_hotlist_initialise(void) {
|
||||
data = urldb_get_url_data(default_entries[i].url);
|
||||
if (!data) {
|
||||
urldb_add_url(default_entries[i].url);
|
||||
urldb_update_url_visit_data(
|
||||
default_entries[i].url);
|
||||
urldb_set_url_persistence(
|
||||
default_entries[i].url,
|
||||
true);
|
||||
data = urldb_get_url_data(
|
||||
default_entries[i].url);
|
||||
}
|
||||
@ -314,7 +315,7 @@ bool ro_gui_hotlist_dialog_apply(wimp_w w) {
|
||||
data = urldb_get_url_data(url);
|
||||
if (!data) {
|
||||
urldb_add_url(url);
|
||||
urldb_update_url_visit_data(url);
|
||||
urldb_set_url_persistence(url, true);
|
||||
data = urldb_get_url_data(url);
|
||||
}
|
||||
if (!data) {
|
||||
|
Loading…
Reference in New Issue
Block a user