summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2017-04-28 12:02:48 +0100
committerMichael Drake <michael.drake@codethink.co.uk>2017-04-28 12:02:48 +0100
commit06baaa9f7c037d2aa9d9c67e0b9b07724372e0f0 (patch)
treef941a1385526f15a2f17890d1b3f0e51841b8baf /desktop
parent6c726473eff8a352d51e3931356347384bd8686a (diff)
downloadnetsurf-06baaa9f7c037d2aa9d9c67e0b9b07724372e0f0.tar.gz
netsurf-06baaa9f7c037d2aa9d9c67e0b9b07724372e0f0.tar.bz2
Core hotlist: A NULL save_path makes the hotlist read-only.
Diffstat (limited to 'desktop')
-rw-r--r--desktop/hotlist.c19
-rw-r--r--desktop/hotlist.h2
2 files changed, 15 insertions, 6 deletions
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 3e2fcedd5..0f5be77c9 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -107,7 +107,7 @@ static nserror hotlist_get_temp_path(const char *path, char **temp_path)
/* Save the hotlist to to a file at the given path
*
- * \param path Path to save hostlist file to.
+ * \param path Path to save hotlist file to. NULL path is a no-op.
* \return NSERROR_OK on success, or appropriate error otherwise
*/
static nserror hotlist_save(const char *path)
@@ -115,6 +115,11 @@ static nserror hotlist_save(const char *path)
nserror res = NSERROR_OK;
char *temp_path;
+ /* NULL path is a no-op. */
+ if (path == NULL) {
+ return NSERROR_OK;
+ }
+
/* Get path to export to */
res = hotlist_get_temp_path(path, &temp_path);
if (res != NSERROR_OK) {
@@ -163,7 +168,7 @@ static void hotlist_schedule_save_cb(void *p)
*/
static nserror hotlist_schedule_save(void)
{
- if (hl_ctx.save_scheduled == false) {
+ if (hl_ctx.save_scheduled == false && hl_ctx.save_path != NULL) {
nserror err = guit->misc->schedule(10 * 1000,
hotlist_schedule_save_cb, NULL);
if (err != NSERROR_OK) {
@@ -1285,9 +1290,13 @@ nserror hotlist_init(
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;
+ if (save_path != NULL) {
+ hl_ctx.save_path = strdup(save_path);
+ if (hl_ctx.save_path == NULL) {
+ return NSERROR_NOMEM;
+ }
+ } else {
+ hl_ctx.save_path = NULL;
}
/* Init. hotlist treeview entry fields */
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index e38eac1c2..a16b3e8ad 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -41,7 +41,7 @@ struct rect;
* hotlist can be queried to ask if URLs are present in the hotlist.
*
* \param load_path The path to load hotlist from.
- * \param save_path The path to save hotlist to.
+ * \param save_path The path to save hotlist to, or NULL for read-only.
* \return NSERROR_OK on success, appropriate error otherwise
*/
nserror hotlist_init(