Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/479c3fd0b50c72632f4ba09dd3a7e93c83298de4
...commit
http://git.netsurf-browser.org/netsurf.git/commit/479c3fd0b50c72632f4ba09dd3a7e93c83298de4
...tree
http://git.netsurf-browser.org/netsurf.git/tree/479c3fd0b50c72632f4ba09dd3a7e93c83298de4
The branch, master has been updated
via 479c3fd0b50c72632f4ba09dd3a7e93c83298de4 (commit)
via e227b3d29c0b3bc01084094a03e186b00c9980aa (commit)
via 0d8ed168b2b64bdbdab53263a587cafba405b83c (commit)
via a137de40a9871f849a7a71a2d9af9b417751e532 (commit)
via c359bd977487b3ea8cd28724f9abc0b5f22acab0 (commit)
via 229f6b5f2352a1843e924eef8b19e9d379b39f45 (commit)
via a44a0875a7f0c11b0c7a74e974872c8fa8f8e69a (commit)
via c47b9f465cfdea1b37e7a5ff7e569290e4a0387e (commit)
from ab53f74788ece5121667bf69375fd3394d984fc9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=479c3fd0b50c72632f4ba09dd3a7e93c83298de4
commit 479c3fd0b50c72632f4ba09dd3a7e93c83298de4
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Hotlist: Save hotlist modifications.
When URLs are added, or address entries are edited or deleted,
a hotlist save is scheduled to happen after 10 seconds, if there
isn't already a hotlist save scheduled.
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 033b668..7cae781 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -63,6 +63,7 @@ struct hotlist_ctx {
bool built;
struct hotlist_folder *default_folder;
char *save_path;
+ bool save_scheduled;
};
struct hotlist_ctx hl_ctx;
@@ -74,6 +75,107 @@ struct hotlist_entry {
};
+/*
+ * Get path for writing hotlist to
+ *
+ * \param path The final path of the hotlist
+ * \param loaded Updated to the path to write the holist to
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+static nserror hotlist_get_temp_path(const char *path, char **temp_path)
+{
+ const char *extension = "-bk";
+ char *joined;
+ int len;
+
+ len = strlen(path) + strlen(extension);
+
+ joined = malloc(len + 1);
+ if (joined == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ if (snprintf(joined, len + 1, "%s%s", path, extension) != len) {
+ free(joined);
+ return NSERROR_UNKNOWN;
+ }
+
+ *temp_path = joined;
+ return NSERROR_OK;
+}
+
+
+/* Save the hotlist to to a file at the given path
+ *
+ * \param path Path to save hostlist file to.
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+static nserror hotlist_save(const char *path)
+{
+ nserror res = NSERROR_OK;
+ char *temp_path;
+
+ /* Get path to export to */
+ res = hotlist_get_temp_path(path, &temp_path);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ /* Export to temp path */
+ res = hotlist_export(temp_path, NULL);
+ if (res != NSERROR_OK) {
+ goto cleanup;
+ }
+
+ /* Remove old hotlist to handle non-POSIX rename() implementations. */
+ (void)remove(path);
+
+ /* Replace any old hotlist file with the one we just saved */
+ if (rename(temp_path, path) != 0) {
+ res = NSERROR_SAVE_FAILED;
+ LOG("Error renaming hotlist: %s.", strerror(errno));
+ goto cleanup;
+ }
+
+cleanup:
+ free(temp_path);
+
+ return res;
+}
+
+
+/**
+ * Scheduler callback for saving the hotlist.
+ *
+ * \param p Unused user data.
+ */
+static void hotlist_schedule_save_cb(void *p)
+{
+ hl_ctx.save_scheduled = false;
+ hotlist_save(hl_ctx.save_path);
+}
+
+
+/**
+ * Schedule a hotlist save.
+ *
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+static nserror hotlist_schedule_save(void)
+{
+ if (hl_ctx.save_scheduled == false) {
+ nserror err = guit->misc->schedule(10 * 1000,
+ hotlist_schedule_save_cb, NULL);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+ hl_ctx.save_scheduled = true;
+ }
+
+ return NSERROR_OK;
+}
+
+
/**
* Set a hotlist entry's data from the url_data.
*
@@ -437,6 +539,8 @@ hotlist_tree_node_entry_cb(struct treeview_node_msg msg,
void *data)
case TREE_MSG_NODE_DELETE:
e->entry = NULL;
hotlist_delete_entry_internal(e);
+
+ err = hotlist_schedule_save();
break;
case TREE_MSG_NODE_EDIT:
@@ -460,6 +564,8 @@ hotlist_tree_node_entry_cb(struct treeview_node_msg msg,
void *data)
free((void *)old_text);
}
+ err = hotlist_schedule_save();
+
} else if (lwc_string_isequal(hl_ctx.fields[HL_URL].field,
msg.data.node_edit.field, &match) ==
lwc_error_ok && match == true &&
@@ -477,6 +583,8 @@ hotlist_tree_node_entry_cb(struct treeview_node_msg msg,
void *data)
treeview_update_node_entry(hl_ctx.tree,
e->entry, e->data, e);
nsurl_unref(old_url);
+
+ err = hotlist_schedule_save();
}
}
break;
@@ -597,7 +705,7 @@ static nserror hotlist_load_entry(dom_node *li,
hotlist_load_ctx *ctx)
/*
- * Callback for libdom_iterate_child_elements, which dispite the namespace is
+ * Callback for libdom_iterate_child_elements, which despite the namespace is
* a NetSurf function.
*
* \param node Node that is a child of the directory UL node
@@ -730,36 +838,6 @@ nserror hotlist_load_directory_cb(dom_node *node, void
*ctx)
/*
- * Get path for writing hotlist to
- *
- * \param path The final path of the hotlist
- * \param loaded Updated to the path to write the holist to
- * \return NSERROR_OK on success, or appropriate error otherwise
- */
-static nserror hotlist_get_temp_path(const char *path, char **temp_path)
-{
- const char *extension = "-bk";
- char *joined;
- int len;
-
- len = strlen(path) + strlen(extension);
-
- joined = malloc(len + 1);
- if (joined == NULL) {
- return NSERROR_NOMEM;
- }
-
- if (snprintf(joined, len + 1, "%s%s", path, extension) != len) {
- free(joined);
- return NSERROR_UNKNOWN;
- }
-
- *temp_path = joined;
- return NSERROR_OK;
-}
-
-
-/*
* Load the hotlist data from file
*
* \param path The path to load the hotlist file from, or NULL
@@ -919,45 +997,6 @@ static nserror hotlist_generate(void)
}
-/* Save the hotlist to to a file at the given path
- *
- * \param path Path to save hostlist file to.
- * \return NSERROR_OK on success, or appropriate error otherwise
- */
-static nserror hotlist_save(const char *path)
-{
- nserror res = NSERROR_OK;
- char *temp_path;
-
- /* Get path to export to */
- res = hotlist_get_temp_path(path, &temp_path);
- if (res != NSERROR_OK) {
- return res;
- }
-
- /* Export to temp path */
- res = hotlist_export(temp_path, NULL);
- if (res != NSERROR_OK) {
- goto cleanup;
- }
-
- /* Remove old hotlist to handle non-POSIX rename() implementations. */
- (void)remove(path);
-
- /* Replace any old hotlist file with the one we just saved */
- if (rename(temp_path, path) != 0) {
- res = NSERROR_SAVE_FAILED;
- LOG("Error renaming hotlist: %s.", strerror(errno));
- goto cleanup;
- }
-
-cleanup:
- free(temp_path);
-
- return res;
-}
-
-
struct treeview_export_walk_ctx {
FILE *fp;
};
@@ -1394,7 +1433,7 @@ nserror hotlist_add_url(nsurl *url)
if (err != NSERROR_OK)
return err;
- return NSERROR_OK;
+ return hotlist_schedule_save();
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=e227b3d29c0b3bc01084094a03e186b00c9980aa
commit e227b3d29c0b3bc01084094a03e186b00c9980aa
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Windows: Update for core hotlist API change.
diff --git a/frontends/windows/hotlist.c b/frontends/windows/hotlist.c
index 07804fe..0efe76f 100644
--- a/frontends/windows/hotlist.c
+++ b/frontends/windows/hotlist.c
@@ -184,7 +184,7 @@ nserror nsw32_hotlist_finalise(void)
return NSERROR_OK;
}
- res = hotlist_fini(nsoption_charp(hotlist_path));
+ res = hotlist_fini();
if (res == NSERROR_OK) {
res = nsw32_corewindow_fini(&hotlist_window->core);
DestroyWindow(hotlist_window->core.hWnd);
diff --git a/frontends/windows/main.c b/frontends/windows/main.c
index 442c71b..ec2b20f 100644
--- a/frontends/windows/main.c
+++ b/frontends/windows/main.c
@@ -371,7 +371,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR
lpcli, int ncmd)
urldb_load(nsoption_charp(url_file));
urldb_load_cookies(nsoption_charp(cookie_file));
- hotlist_init(nsoption_charp(hotlist_path));
+ hotlist_init(nsoption_charp(hotlist_path),
+ nsoption_charp(hotlist_path));
ret = nsws_create_main_class(hInstance);
ret = nsws_create_drawable_class(hInstance);
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=0d8ed168b2b64bdbdab53263a587cafba405b83c
commit 0d8ed168b2b64bdbdab53263a587cafba405b83c
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
RISC OS: Update for core hotlist API change.
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 540a8be..f84e084 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -1185,7 +1185,8 @@ static nserror gui_init(int argc, char** argv)
/* Load in visited URLs, Cookies, and hostlist */
urldb_load(nsoption_charp(url_path));
urldb_load_cookies(nsoption_charp(cookie_file));
- hotlist_init(nsoption_charp(hotlist_path));
+ hotlist_init(nsoption_charp(hotlist_path),
+ nsoption_charp(hotlist_save));
/* Initialise with the wimp */
error = xwimp_initialise(wimp_VERSION_RO38, task_name,
diff --git a/frontends/riscos/hotlist.c b/frontends/riscos/hotlist.c
index ea85bc3..d348009 100644
--- a/frontends/riscos/hotlist.c
+++ b/frontends/riscos/hotlist.c
@@ -583,7 +583,7 @@ nserror ro_gui_hotlist_finalise(void)
return NSERROR_OK;
}
- res = hotlist_fini(nsoption_charp(hotlist_save));
+ res = hotlist_fini();
if (res == NSERROR_OK) {
res = ro_corewindow_fini(&hotlist_window->core);
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=a137de40a9871f849a7a71a2d9af9b417751e532
commit a137de40a9871f849a7a71a2d9af9b417751e532
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
GTK: Update for core hotlist API change.
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index 63646b4..a183e52 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -292,7 +292,8 @@ static nserror nsgtk_init(int argc, char** argv, char
**respath)
urldb_load(nsoption_charp(url_file));
urldb_load_cookies(nsoption_charp(cookie_file));
- hotlist_init(nsoption_charp(hotlist_path));
+ hotlist_init(nsoption_charp(hotlist_path),
+ nsoption_charp(hotlist_path));
/* The tree view system needs to know the screen's DPI, so we
* find that out here, rather than when we create a first browser
@@ -456,7 +457,7 @@ static void gui_quit(void)
messages_get_errorcode(res));
}
- res = hotlist_fini(nsoption_charp(hotlist_path));
+ res = hotlist_fini();
if (res != NSERROR_OK) {
LOG("Error finalising hotlist: %s",
messages_get_errorcode(res));
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=c359bd977487b3ea8cd28724f9abc0b5f22acab0
commit c359bd977487b3ea8cd28724f9abc0b5f22acab0
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Cocoa: Update for core hotlist API change.
diff --git a/frontends/cocoa/desktop-tree.m b/frontends/cocoa/desktop-tree.m
index c3c7296..a010c6f 100644
--- a/frontends/cocoa/desktop-tree.m
+++ b/frontends/cocoa/desktop-tree.m
@@ -139,7 +139,7 @@ static bool treeview_test_init(struct tree *tree)
guit->misc->warning("Couldn't init new global
history.", 0);
break;
case TREE_HOTLIST:
- err = hotlist_init(tree_hotlist_path);
+ err = hotlist_init(tree_hotlist_path, tree_hotlist_path);
if (err != NSERROR_OK)
guit->misc->warning("Couldn't init new hotlist.", 0);
err = hotlist_manager_init(&cw_t, (struct core_window *)tree);
@@ -177,7 +177,7 @@ static bool treeview_test_fini(struct tree *tree)
guit->misc->warning("Couldn't finalise cookie
manager.", 0);
break;
case TREE_HOTLIST:
- err = hotlist_fini(tree_hotlist_path);
+ err = hotlist_fini();
if (err != NSERROR_OK)
guit->misc->warning("Couldn't finalise hotlist.", 0);
break;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=229f6b5f2352a1843e924eef8b19e9d379b39f45
commit 229f6b5f2352a1843e924eef8b19e9d379b39f45
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Atari: Update for core hotlist API change.
diff --git a/frontends/atari/hotlist.c b/frontends/atari/hotlist.c
index da59916..659b3a5 100644
--- a/frontends/atari/hotlist.c
+++ b/frontends/atari/hotlist.c
@@ -79,7 +79,7 @@ static nserror atari_hotlist_init_phase2(struct core_window
*cw,
static void atari_hotlist_finish(struct core_window *cw)
{
LOG("cw:%p", cw);
- hotlist_fini(hl.path);
+ hotlist_fini();
}
static void atari_hotlist_draw(struct core_window *cw, int x,
@@ -199,7 +199,7 @@ void atari_hotlist_init(void)
}
LOG("Hotlist: %s", (char *)&hl.path);
- hotlist_init(hl.path);
+ hotlist_init(hl.path, hl.path);
if( hl.window == NULL ){
int flags = ATARI_TREEVIEW_WIDGETS;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=a44a0875a7f0c11b0c7a74e974872c8fa8f8e69a
commit a44a0875a7f0c11b0c7a74e974872c8fa8f8e69a
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Amiga: Update for core hotlist API change.
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 3e66259..a6164db 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1019,7 +1019,8 @@ static void gui_init2(int argc, char** argv)
}
/**/
- hotlist_init(nsoption_charp(hotlist_file));
+ hotlist_init(nsoption_charp(hotlist_file),
+ nsoption_charp(hotlist_file));
search_web_select_provider(nsoption_int(search_provider));
if (notalreadyrunning &&
@@ -3042,7 +3043,7 @@ static void gui_quit(void)
urldb_save(nsoption_charp(url_file));
urldb_save_cookies(nsoption_charp(cookie_file));
- hotlist_fini(nsoption_charp(hotlist_file));
+ hotlist_fini();
#ifdef __amigaos4__
if(IApplication && ami_appid)
UnregisterApplication(ami_appid, NULL);
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=c47b9f465cfdea1b37e7a5ff7e569290e4a0387e
commit c47b9f465cfdea1b37e7a5ff7e569290e4a0387e
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Core hotlist API: Take save path at init, rather than fini.
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 78473c7..033b668 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -62,6 +62,7 @@ struct hotlist_ctx {
struct treeview_field_desc fields[HL_N_FIELDS];
bool built;
struct hotlist_folder *default_folder;
+ char *save_path;
};
struct hotlist_ctx hl_ctx;
@@ -1227,7 +1228,9 @@ static nserror hotlist_populate(const char *path)
/* Exported interface, documented in hotlist.h */
-nserror hotlist_init(const char *path)
+nserror hotlist_init(
+ const char *load_path,
+ const char *save_path)
{
nserror err;
@@ -1242,9 +1245,16 @@ nserror hotlist_init(const char *path)
hl_ctx.built = false;
hl_ctx.default_folder = NULL;
+ /* Store the save path */
+ hl_ctx.save_path = strdup(save_path);
+ if (hl_ctx.save_path == NULL) {
+ return NSERROR_NOMEM;
+ }
+
/* Init. hotlist treeview entry fields */
err = hotlist_initialise_entry_fields();
if (err != NSERROR_OK) {
+ free(hl_ctx.save_path);
hl_ctx.tree = NULL;
return err;
}
@@ -1254,13 +1264,15 @@ nserror hotlist_init(const char *path)
HL_N_FIELDS, hl_ctx.fields, NULL, NULL,
TREEVIEW_NO_FLAGS);
if (err != NSERROR_OK) {
+ free(hl_ctx.save_path);
hl_ctx.tree = NULL;
return err;
}
/* Populate the hotlist */
- err = hotlist_populate(path);
+ err = hotlist_populate(load_path);
if (err != NSERROR_OK) {
+ free(hl_ctx.save_path);
return err;
}
@@ -1310,7 +1322,7 @@ nserror hotlist_manager_fini(void)
/* Exported interface, documented in hotlist.h */
-nserror hotlist_fini(const char *path)
+nserror hotlist_fini(void)
{
int i;
nserror err;
@@ -1318,11 +1330,13 @@ nserror hotlist_fini(const char *path)
LOG("Finalising hotlist");
/* Save the hotlist */
- err = hotlist_save(path);
+ err = hotlist_save(hl_ctx.save_path);
if (err != NSERROR_OK) {
LOG("Problem saving the hotlist.");
}
+ free(hl_ctx.save_path);
+
/* Destroy the hotlist treeview */
err = treeview_destroy(hl_ctx.tree);
hl_ctx.built = false;
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index ef54f6b..e38eac1 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -40,10 +40,13 @@ struct rect;
* be called before URLs can be added to the hotlist, and before the
* hotlist can be queried to ask if URLs are present in the hotlist.
*
- * \param path The path to hotlist file to load
+ * \param load_path The path to load hotlist from.
+ * \param save_path The path to save hotlist to.
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror hotlist_init(const char *path);
+nserror hotlist_init(
+ const char *load_path,
+ const char *save_path);
/**
* Initialise the hotlist manager.
@@ -78,10 +81,9 @@ nserror hotlist_manager_fini(void);
* internal data. After calling this if hotlist is required again,
* hotlist_init must be called.
*
- * \param path The path to save hotlist to
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror hotlist_fini(const char *path);
+nserror hotlist_fini(void);
/**
* Add an entry to the hotlist for given URL.
-----------------------------------------------------------------------
Summary of changes:
desktop/hotlist.c | 203 +++++++++++++++++++++++++---------------
desktop/hotlist.h | 10 +-
frontends/amiga/gui.c | 5 +-
frontends/atari/hotlist.c | 4 +-
frontends/cocoa/desktop-tree.m | 4 +-
frontends/gtk/gui.c | 5 +-
frontends/riscos/gui.c | 3 +-
frontends/riscos/hotlist.c | 2 +-
frontends/windows/hotlist.c | 2 +-
frontends/windows/main.c | 3 +-
10 files changed, 150 insertions(+), 91 deletions(-)
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 78473c7..7cae781 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -62,6 +62,8 @@ struct hotlist_ctx {
struct treeview_field_desc fields[HL_N_FIELDS];
bool built;
struct hotlist_folder *default_folder;
+ char *save_path;
+ bool save_scheduled;
};
struct hotlist_ctx hl_ctx;
@@ -73,6 +75,107 @@ struct hotlist_entry {
};
+/*
+ * Get path for writing hotlist to
+ *
+ * \param path The final path of the hotlist
+ * \param loaded Updated to the path to write the holist to
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+static nserror hotlist_get_temp_path(const char *path, char **temp_path)
+{
+ const char *extension = "-bk";
+ char *joined;
+ int len;
+
+ len = strlen(path) + strlen(extension);
+
+ joined = malloc(len + 1);
+ if (joined == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ if (snprintf(joined, len + 1, "%s%s", path, extension) != len) {
+ free(joined);
+ return NSERROR_UNKNOWN;
+ }
+
+ *temp_path = joined;
+ return NSERROR_OK;
+}
+
+
+/* Save the hotlist to to a file at the given path
+ *
+ * \param path Path to save hostlist file to.
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+static nserror hotlist_save(const char *path)
+{
+ nserror res = NSERROR_OK;
+ char *temp_path;
+
+ /* Get path to export to */
+ res = hotlist_get_temp_path(path, &temp_path);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ /* Export to temp path */
+ res = hotlist_export(temp_path, NULL);
+ if (res != NSERROR_OK) {
+ goto cleanup;
+ }
+
+ /* Remove old hotlist to handle non-POSIX rename() implementations. */
+ (void)remove(path);
+
+ /* Replace any old hotlist file with the one we just saved */
+ if (rename(temp_path, path) != 0) {
+ res = NSERROR_SAVE_FAILED;
+ LOG("Error renaming hotlist: %s.", strerror(errno));
+ goto cleanup;
+ }
+
+cleanup:
+ free(temp_path);
+
+ return res;
+}
+
+
+/**
+ * Scheduler callback for saving the hotlist.
+ *
+ * \param p Unused user data.
+ */
+static void hotlist_schedule_save_cb(void *p)
+{
+ hl_ctx.save_scheduled = false;
+ hotlist_save(hl_ctx.save_path);
+}
+
+
+/**
+ * Schedule a hotlist save.
+ *
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+static nserror hotlist_schedule_save(void)
+{
+ if (hl_ctx.save_scheduled == false) {
+ nserror err = guit->misc->schedule(10 * 1000,
+ hotlist_schedule_save_cb, NULL);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+ hl_ctx.save_scheduled = true;
+ }
+
+ return NSERROR_OK;
+}
+
+
/**
* Set a hotlist entry's data from the url_data.
*
@@ -436,6 +539,8 @@ hotlist_tree_node_entry_cb(struct treeview_node_msg msg,
void *data)
case TREE_MSG_NODE_DELETE:
e->entry = NULL;
hotlist_delete_entry_internal(e);
+
+ err = hotlist_schedule_save();
break;
case TREE_MSG_NODE_EDIT:
@@ -459,6 +564,8 @@ hotlist_tree_node_entry_cb(struct treeview_node_msg msg,
void *data)
free((void *)old_text);
}
+ err = hotlist_schedule_save();
+
} else if (lwc_string_isequal(hl_ctx.fields[HL_URL].field,
msg.data.node_edit.field, &match) ==
lwc_error_ok && match == true &&
@@ -476,6 +583,8 @@ hotlist_tree_node_entry_cb(struct treeview_node_msg msg,
void *data)
treeview_update_node_entry(hl_ctx.tree,
e->entry, e->data, e);
nsurl_unref(old_url);
+
+ err = hotlist_schedule_save();
}
}
break;
@@ -596,7 +705,7 @@ static nserror hotlist_load_entry(dom_node *li,
hotlist_load_ctx *ctx)
/*
- * Callback for libdom_iterate_child_elements, which dispite the namespace is
+ * Callback for libdom_iterate_child_elements, which despite the namespace is
* a NetSurf function.
*
* \param node Node that is a child of the directory UL node
@@ -729,36 +838,6 @@ nserror hotlist_load_directory_cb(dom_node *node, void
*ctx)
/*
- * Get path for writing hotlist to
- *
- * \param path The final path of the hotlist
- * \param loaded Updated to the path to write the holist to
- * \return NSERROR_OK on success, or appropriate error otherwise
- */
-static nserror hotlist_get_temp_path(const char *path, char **temp_path)
-{
- const char *extension = "-bk";
- char *joined;
- int len;
-
- len = strlen(path) + strlen(extension);
-
- joined = malloc(len + 1);
- if (joined == NULL) {
- return NSERROR_NOMEM;
- }
-
- if (snprintf(joined, len + 1, "%s%s", path, extension) != len) {
- free(joined);
- return NSERROR_UNKNOWN;
- }
-
- *temp_path = joined;
- return NSERROR_OK;
-}
-
-
-/*
* Load the hotlist data from file
*
* \param path The path to load the hotlist file from, or NULL
@@ -918,45 +997,6 @@ static nserror hotlist_generate(void)
}
-/* Save the hotlist to to a file at the given path
- *
- * \param path Path to save hostlist file to.
- * \return NSERROR_OK on success, or appropriate error otherwise
- */
-static nserror hotlist_save(const char *path)
-{
- nserror res = NSERROR_OK;
- char *temp_path;
-
- /* Get path to export to */
- res = hotlist_get_temp_path(path, &temp_path);
- if (res != NSERROR_OK) {
- return res;
- }
-
- /* Export to temp path */
- res = hotlist_export(temp_path, NULL);
- if (res != NSERROR_OK) {
- goto cleanup;
- }
-
- /* Remove old hotlist to handle non-POSIX rename() implementations. */
- (void)remove(path);
-
- /* Replace any old hotlist file with the one we just saved */
- if (rename(temp_path, path) != 0) {
- res = NSERROR_SAVE_FAILED;
- LOG("Error renaming hotlist: %s.", strerror(errno));
- goto cleanup;
- }
-
-cleanup:
- free(temp_path);
-
- return res;
-}
-
-
struct treeview_export_walk_ctx {
FILE *fp;
};
@@ -1227,7 +1267,9 @@ static nserror hotlist_populate(const char *path)
/* Exported interface, documented in hotlist.h */
-nserror hotlist_init(const char *path)
+nserror hotlist_init(
+ const char *load_path,
+ const char *save_path)
{
nserror err;
@@ -1242,9 +1284,16 @@ nserror hotlist_init(const char *path)
hl_ctx.built = false;
hl_ctx.default_folder = NULL;
+ /* Store the save path */
+ hl_ctx.save_path = strdup(save_path);
+ if (hl_ctx.save_path == NULL) {
+ return NSERROR_NOMEM;
+ }
+
/* Init. hotlist treeview entry fields */
err = hotlist_initialise_entry_fields();
if (err != NSERROR_OK) {
+ free(hl_ctx.save_path);
hl_ctx.tree = NULL;
return err;
}
@@ -1254,13 +1303,15 @@ nserror hotlist_init(const char *path)
HL_N_FIELDS, hl_ctx.fields, NULL, NULL,
TREEVIEW_NO_FLAGS);
if (err != NSERROR_OK) {
+ free(hl_ctx.save_path);
hl_ctx.tree = NULL;
return err;
}
/* Populate the hotlist */
- err = hotlist_populate(path);
+ err = hotlist_populate(load_path);
if (err != NSERROR_OK) {
+ free(hl_ctx.save_path);
return err;
}
@@ -1310,7 +1361,7 @@ nserror hotlist_manager_fini(void)
/* Exported interface, documented in hotlist.h */
-nserror hotlist_fini(const char *path)
+nserror hotlist_fini(void)
{
int i;
nserror err;
@@ -1318,11 +1369,13 @@ nserror hotlist_fini(const char *path)
LOG("Finalising hotlist");
/* Save the hotlist */
- err = hotlist_save(path);
+ err = hotlist_save(hl_ctx.save_path);
if (err != NSERROR_OK) {
LOG("Problem saving the hotlist.");
}
+ free(hl_ctx.save_path);
+
/* Destroy the hotlist treeview */
err = treeview_destroy(hl_ctx.tree);
hl_ctx.built = false;
@@ -1380,7 +1433,7 @@ nserror hotlist_add_url(nsurl *url)
if (err != NSERROR_OK)
return err;
- return NSERROR_OK;
+ return hotlist_schedule_save();
}
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index ef54f6b..e38eac1 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -40,10 +40,13 @@ struct rect;
* be called before URLs can be added to the hotlist, and before the
* hotlist can be queried to ask if URLs are present in the hotlist.
*
- * \param path The path to hotlist file to load
+ * \param load_path The path to load hotlist from.
+ * \param save_path The path to save hotlist to.
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror hotlist_init(const char *path);
+nserror hotlist_init(
+ const char *load_path,
+ const char *save_path);
/**
* Initialise the hotlist manager.
@@ -78,10 +81,9 @@ nserror hotlist_manager_fini(void);
* internal data. After calling this if hotlist is required again,
* hotlist_init must be called.
*
- * \param path The path to save hotlist to
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror hotlist_fini(const char *path);
+nserror hotlist_fini(void);
/**
* Add an entry to the hotlist for given URL.
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 3e66259..a6164db 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1019,7 +1019,8 @@ static void gui_init2(int argc, char** argv)
}
/**/
- hotlist_init(nsoption_charp(hotlist_file));
+ hotlist_init(nsoption_charp(hotlist_file),
+ nsoption_charp(hotlist_file));
search_web_select_provider(nsoption_int(search_provider));
if (notalreadyrunning &&
@@ -3042,7 +3043,7 @@ static void gui_quit(void)
urldb_save(nsoption_charp(url_file));
urldb_save_cookies(nsoption_charp(cookie_file));
- hotlist_fini(nsoption_charp(hotlist_file));
+ hotlist_fini();
#ifdef __amigaos4__
if(IApplication && ami_appid)
UnregisterApplication(ami_appid, NULL);
diff --git a/frontends/atari/hotlist.c b/frontends/atari/hotlist.c
index da59916..659b3a5 100644
--- a/frontends/atari/hotlist.c
+++ b/frontends/atari/hotlist.c
@@ -79,7 +79,7 @@ static nserror atari_hotlist_init_phase2(struct core_window
*cw,
static void atari_hotlist_finish(struct core_window *cw)
{
LOG("cw:%p", cw);
- hotlist_fini(hl.path);
+ hotlist_fini();
}
static void atari_hotlist_draw(struct core_window *cw, int x,
@@ -199,7 +199,7 @@ void atari_hotlist_init(void)
}
LOG("Hotlist: %s", (char *)&hl.path);
- hotlist_init(hl.path);
+ hotlist_init(hl.path, hl.path);
if( hl.window == NULL ){
int flags = ATARI_TREEVIEW_WIDGETS;
diff --git a/frontends/cocoa/desktop-tree.m b/frontends/cocoa/desktop-tree.m
index c3c7296..a010c6f 100644
--- a/frontends/cocoa/desktop-tree.m
+++ b/frontends/cocoa/desktop-tree.m
@@ -139,7 +139,7 @@ static bool treeview_test_init(struct tree *tree)
guit->misc->warning("Couldn't init new global
history.", 0);
break;
case TREE_HOTLIST:
- err = hotlist_init(tree_hotlist_path);
+ err = hotlist_init(tree_hotlist_path, tree_hotlist_path);
if (err != NSERROR_OK)
guit->misc->warning("Couldn't init new hotlist.", 0);
err = hotlist_manager_init(&cw_t, (struct core_window *)tree);
@@ -177,7 +177,7 @@ static bool treeview_test_fini(struct tree *tree)
guit->misc->warning("Couldn't finalise cookie
manager.", 0);
break;
case TREE_HOTLIST:
- err = hotlist_fini(tree_hotlist_path);
+ err = hotlist_fini();
if (err != NSERROR_OK)
guit->misc->warning("Couldn't finalise hotlist.", 0);
break;
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index 63646b4..a183e52 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -292,7 +292,8 @@ static nserror nsgtk_init(int argc, char** argv, char
**respath)
urldb_load(nsoption_charp(url_file));
urldb_load_cookies(nsoption_charp(cookie_file));
- hotlist_init(nsoption_charp(hotlist_path));
+ hotlist_init(nsoption_charp(hotlist_path),
+ nsoption_charp(hotlist_path));
/* The tree view system needs to know the screen's DPI, so we
* find that out here, rather than when we create a first browser
@@ -456,7 +457,7 @@ static void gui_quit(void)
messages_get_errorcode(res));
}
- res = hotlist_fini(nsoption_charp(hotlist_path));
+ res = hotlist_fini();
if (res != NSERROR_OK) {
LOG("Error finalising hotlist: %s",
messages_get_errorcode(res));
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 540a8be..f84e084 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -1185,7 +1185,8 @@ static nserror gui_init(int argc, char** argv)
/* Load in visited URLs, Cookies, and hostlist */
urldb_load(nsoption_charp(url_path));
urldb_load_cookies(nsoption_charp(cookie_file));
- hotlist_init(nsoption_charp(hotlist_path));
+ hotlist_init(nsoption_charp(hotlist_path),
+ nsoption_charp(hotlist_save));
/* Initialise with the wimp */
error = xwimp_initialise(wimp_VERSION_RO38, task_name,
diff --git a/frontends/riscos/hotlist.c b/frontends/riscos/hotlist.c
index ea85bc3..d348009 100644
--- a/frontends/riscos/hotlist.c
+++ b/frontends/riscos/hotlist.c
@@ -583,7 +583,7 @@ nserror ro_gui_hotlist_finalise(void)
return NSERROR_OK;
}
- res = hotlist_fini(nsoption_charp(hotlist_save));
+ res = hotlist_fini();
if (res == NSERROR_OK) {
res = ro_corewindow_fini(&hotlist_window->core);
diff --git a/frontends/windows/hotlist.c b/frontends/windows/hotlist.c
index 07804fe..0efe76f 100644
--- a/frontends/windows/hotlist.c
+++ b/frontends/windows/hotlist.c
@@ -184,7 +184,7 @@ nserror nsw32_hotlist_finalise(void)
return NSERROR_OK;
}
- res = hotlist_fini(nsoption_charp(hotlist_path));
+ res = hotlist_fini();
if (res == NSERROR_OK) {
res = nsw32_corewindow_fini(&hotlist_window->core);
DestroyWindow(hotlist_window->core.hWnd);
diff --git a/frontends/windows/main.c b/frontends/windows/main.c
index 442c71b..ec2b20f 100644
--- a/frontends/windows/main.c
+++ b/frontends/windows/main.c
@@ -371,7 +371,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR
lpcli, int ncmd)
urldb_load(nsoption_charp(url_file));
urldb_load_cookies(nsoption_charp(cookie_file));
- hotlist_init(nsoption_charp(hotlist_path));
+ hotlist_init(nsoption_charp(hotlist_path),
+ nsoption_charp(hotlist_path));
ret = nsws_create_main_class(hInstance);
ret = nsws_create_drawable_class(hInstance);
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org