NetSurf
Data Structures | Macros | Enumerations | Functions | Variables
hotlist.c File Reference
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <dom/dom.h>
#include <dom/bindings/hubbub/parser.h>
#include "utils/corestrings.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/utf8.h"
#include "utils/libdom.h"
#include "utils/log.h"
#include "utils/nsurl.h"
#include "content/urldb.h"
#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "desktop/hotlist.h"
#include "desktop/treeview.h"
#include "netsurf/browser_window.h"
Include dependency graph for hotlist.c:

Go to the source code of this file.

Data Structures

struct  hotlist_folder
 
struct  hotlist_ctx
 
struct  hotlist_entry
 
struct  hotlist_load_ctx
 
struct  treeview_export_walk_ctx
 
struct  hotlist_iterate_ctx
 
struct  treeview_has_url_walk_ctx
 
struct  treeview_remove_url_walk_ctx
 
struct  treeview_update_url_walk_ctx
 

Macros

#define N_DAYS   28
 
#define N_SEC_PER_DAY   (60 * 60 * 24)
 

Enumerations

enum  hotlist_fields {
  HL_TITLE , HL_URL , HL_LAST_VISIT , HL_VISITS ,
  HL_FOLDER , HL_N_FIELDS
}
 

Functions

static nserror hotlist_get_temp_path (const char *path, char **temp_path)
 
static nserror hotlist_save (const char *path)
 
static void hotlist_schedule_save_cb (void *p)
 Scheduler callback for saving the hotlist. More...
 
static nserror hotlist_schedule_save (void)
 Schedule a hotlist save. More...
 
static nserror hotlist_create_treeview_field_visits_data (struct hotlist_entry *e, const struct url_data *data)
 Set a hotlist entry's data from the url_data. More...
 
static nserror hotlist_create_treeview_field_data (struct hotlist_entry *e, const char *title, const struct url_data *data)
 Set a hotlist entry's data from the url_data. More...
 
static nserror hotlist_entry_insert (struct hotlist_entry *e, treeview_node *relation, enum treeview_relationship rel)
 Add a hotlist entry to the treeview. More...
 
static void hotlist_delete_entry_internal (struct hotlist_entry *e)
 Delete a hotlist entry. More...
 
static nserror hotlist_create_entry (nsurl *url, const char *title, const struct url_data *data, struct hotlist_entry **entry)
 Create hotlist entry data for URL. More...
 
static nserror hotlist_add_entry_internal (nsurl *url, const char *title, const struct url_data *data, treeview_node *relation, enum treeview_relationship rel, treeview_node **entry)
 Add an entry to the hotlist (creates the entry). More...
 
static nserror hotlist_add_folder_internal (const char *title, treeview_node *relation, enum treeview_relationship rel, struct hotlist_folder **folder, bool default_folder)
 Add folder to the hotlist (creates the folder). More...
 
static nserror hotlist_tree_node_folder_cb (struct treeview_node_msg msg, void *data)
 
static nserror hotlist_tree_node_entry_cb (struct treeview_node_msg msg, void *data)
 callback for hotlist treeview entry manipulation. More...
 
static nserror hotlist_load_entry (dom_node *li, hotlist_load_ctx *ctx)
 Parse an entry represented as a li. More...
 
static nserror hotlist_load_directory_cb (dom_node *node, void *ctx)
 
static nserror hotlist_load_directory (dom_node *ul, hotlist_load_ctx *ctx)
 Parse a directory represented as a ul. More...
 
static nserror hotlist_load (const char *path, bool *loaded)
 
static nserror hotlist_generate (void)
 
static nserror hotlist_export_enter_cb (void *ctx, void *node_data, enum treeview_node_type type, bool *abort)
 Callback for treeview_walk node entering. More...
 
static nserror hotlist_export_leave_cb (void *ctx, void *node_data, enum treeview_node_type type, bool *abort)
 Callback for treeview_walk node leaving. More...
 
nserror hotlist_export (const char *path, const char *title)
 Save hotlist to file. More...
 
static nserror hotlist_iterate_enter_cb (void *ctx, void *node_data, enum treeview_node_type type, bool *abort)
 Callback for hotlist_iterate node entering. More...
 
static nserror hotlist_iterate_leave_cb (void *ctx, void *node_data, enum treeview_node_type type, bool *abort)
 Callback for hotlist_iterate node leaving. More...
 
nserror hotlist_iterate (void *ctx, hotlist_folder_enter_cb enter_cb, hotlist_address_cb address_cb, hotlist_folder_leave_cb leave_cb)
 Walk (depth first) the hotlist, calling callbacks on entering folders, address nodes, and on leaving folders. More...
 
static nserror hotlist_initialise_entry_fields (void)
 Initialise the treeview entry feilds. More...
 
static nserror hotlist_populate (const char *path)
 
nserror hotlist_init (const char *load_path, const char *save_path)
 Initialise the hotlist. More...
 
nserror hotlist_manager_init (struct core_window_callback_table *cw_t, void *core_window_handle)
 Initialise the hotlist manager. More...
 
nserror hotlist_manager_fini (void)
 Finalise the hotlist manager. More...
 
nserror hotlist_fini (void)
 Finalise the hotlist. More...
 
nserror hotlist_add_url (nsurl *url)
 Add an entry to the hotlist for given URL. More...
 
static nserror hotlist_has_url_walk_cb (void *ctx, void *node_data, enum treeview_node_type type, bool *abort)
 Callback for treeview_walk. More...
 
bool hotlist_has_url (nsurl *url)
 Check whether given URL is present in hotlist. More...
 
static nserror hotlist_remove_url_walk_cb (void *ctx, void *node_data, enum treeview_node_type type, bool *abort)
 Callback for treeview_walk. More...
 
void hotlist_remove_url (nsurl *url)
 Remove any entries matching the given URL from the hotlist. More...
 
static nserror hotlist_update_url_walk_cb (void *ctx, void *node_data, enum treeview_node_type type, bool *abort)
 Callback for treeview_walk. More...
 
void hotlist_update_url (nsurl *url)
 Update given URL, e.g. More...
 
nserror hotlist_add_entry (nsurl *url, const char *title, bool at_y, int y)
 Add an entry to the hotlist for given Title/URL. More...
 
nserror hotlist_add_folder (const char *title, bool at_y, int y)
 Add a folder to the hotlist. More...
 
void hotlist_redraw (int x, int y, struct rect *clip, const struct redraw_context *ctx)
 Redraw the hotlist. More...
 
void hotlist_mouse_action (browser_mouse_state mouse, int x, int y)
 Handles all kinds of mouse action. More...
 
bool hotlist_keypress (uint32_t key)
 Key press handling. More...
 
bool hotlist_has_selection (void)
 Determine whether there is a selection. More...
 
bool hotlist_get_selection (nsurl **url, const char **title)
 Get the first selected node. More...
 
void hotlist_edit_selection (void)
 Edit the first selected node. More...
 
nserror hotlist_expand (bool only_folders)
 Expand the treeview's nodes. More...
 
nserror hotlist_contract (bool all)
 Contract the treeview's nodes. More...
 

Variables

struct hotlist_ctx hl_ctx
 
struct treeview_callback_table hl_tree_cb_t
 

Macro Definition Documentation

◆ N_DAYS

#define N_DAYS   28

Definition at line 43 of file hotlist.c.

◆ N_SEC_PER_DAY

#define N_SEC_PER_DAY   (60 * 60 * 24)

Definition at line 44 of file hotlist.c.

Enumeration Type Documentation

◆ hotlist_fields

Enumerator
HL_TITLE 
HL_URL 
HL_LAST_VISIT 
HL_VISITS 
HL_FOLDER 
HL_N_FIELDS 

Definition at line 46 of file hotlist.c.

Function Documentation

◆ hotlist_add_entry()

nserror hotlist_add_entry ( struct nsurl url,
const char *  title,
bool  at_y,
int  y 
)

Add an entry to the hotlist for given Title/URL.

Parameters
urlURL for entry to be added, or NULL
titleTitle for entry being added (copied), or NULL
at_yIff true, insert at y-offest
yY-offset in px from top of hotlist. Ignored if (!at_y).
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1624 of file hotlist.c.

References hl_ctx, hotlist_add_entry_internal(), NSERROR_OK, nsurl_create(), nsurl_ref(), nsurl_unref(), hotlist_ctx::tree, treeview_get_relation(), and treeview_update_url_walk_ctx::url.

Referenced by ami_hotlist_icon_drop(), atari_hotlist_add_page(), HOOKF(), hotlist_menu_select(), and MENUHANDLER().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_add_entry_internal()

static nserror hotlist_add_entry_internal ( nsurl url,
const char *  title,
const struct url_data data,
treeview_node relation,
enum treeview_relationship  rel,
treeview_node **  entry 
)
static

Add an entry to the hotlist (creates the entry).

Parameters
urlURL for entry to add to hotlist.
titleTitle for entry, or NULL if using title from data
dataURL data for the entry, or NULL
relationExisting node to insert as relation of, or NULL
relEntry's relationship to relation
entryUpdated to new treeview entry node
Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 406 of file hotlist.c.

References hotlist_entry::data, hotlist_entry::entry, hotlist_create_entry(), hotlist_delete_entry_internal(), hotlist_entry_insert(), NSERROR_OK, hotlist_entry::url, and urldb_set_url_persistence().

Referenced by hotlist_add_entry(), hotlist_add_url(), hotlist_generate(), and hotlist_load_entry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_add_folder()

nserror hotlist_add_folder ( const char *  title,
bool  at_y,
int  y 
)

Add a folder to the hotlist.

Parameters
titleTitle for folder being added, or NULL
at_yIff true, insert at y-offest
yY-offset in px from top of hotlist. Ignored if (!at_y).
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1661 of file hotlist.c.

References hl_ctx, hotlist_add_folder_internal(), NSERROR_OK, hotlist_ctx::tree, and treeview_get_relation().

Referenced by ami_hotlist_scan(), handle_event(), HOOKF(), hotlist_menu_select(), hotlist_toolbar_click(), and MENUHANDLER().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_add_folder_internal()

static nserror hotlist_add_folder_internal ( const char *  title,
treeview_node relation,
enum treeview_relationship  rel,
struct hotlist_folder **  folder,
bool  default_folder 
)
static

Add folder to the hotlist (creates the folder).

Parameters
titleTitle for folder, or NULL if using title from data
relationExisting node to insert as relation of, or NULL
relFolder's relationship to relation
folderUpdated to new hotlist folder data
default_folderAdd to the default folder.
Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 443 of file hotlist.c.

References hotlist_ctx::built, hotlist_folder::data, treeview_field_desc::field, treeview_field_data::field, hotlist_ctx::fields, hotlist_folder::folder, hl_ctx, HL_FOLDER, messages_get(), NSERROR_NOMEM, NSERROR_OK, hotlist_ctx::tree, TREE_OPTION_NONE, TREE_OPTION_SPECIAL_DIR, TREE_OPTION_SUPPRESS_REDRAW, TREE_OPTION_SUPPRESS_RESIZE, treeview_create_node_folder(), treeview_field_data::value, and treeview_field_data::value_len.

Referenced by hotlist_add_folder(), hotlist_add_url(), hotlist_generate(), and hotlist_load_directory_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_add_url()

nserror hotlist_add_url ( struct nsurl url)

Add an entry to the hotlist for given URL.

Parameters
urlURL for node being added
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1431 of file hotlist.c.

References hotlist_ctx::default_folder, hotlist_folder::folder, hl_ctx, hotlist_add_entry_internal(), hotlist_add_folder_internal(), hotlist_schedule_save(), messages_get(), NSERROR_NOMEM, NSERROR_OK, hotlist_ctx::tree, TREE_REL_FIRST_CHILD, and treeview_node_expand().

Referenced by addbookmarks_button_clicked_cb(), ami_gui_event(), HOOKF(), nsgtk_on_link_bookmark_activate_menu(), ro_gui_hotlist_add_page(), ro_gui_hotlist_addurl_bounce(), and toolbar_favorite_click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_contract()

nserror hotlist_contract ( bool  all)

Contract the treeview's nodes.

Parameters
allIff false, only entries are contracted.
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1748 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_contract().

Referenced by HOOKF(), hotlist_menu_select(), hotlist_toolbar_click(), and MENUHANDLER().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_create_entry()

static nserror hotlist_create_entry ( nsurl url,
const char *  title,
const struct url_data data,
struct hotlist_entry **  entry 
)
static

Create hotlist entry data for URL.

Parameters
urlURL for entry to add to hotlist.
titleTitle for entry, or NULL if using title from data
dataURL data for the entry, or NULL
entryUpdated to new hotlist entry data
Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 349 of file hotlist.c.

References hotlist_entry::data, hotlist_entry::entry, hotlist_create_treeview_field_data(), NSERROR_NOMEM, NSERROR_OK, nsurl_ref(), nsurl_unref(), hotlist_entry::url, urldb_add_url(), and urldb_get_url_data().

Referenced by hotlist_add_entry_internal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_create_treeview_field_data()

static nserror hotlist_create_treeview_field_data ( struct hotlist_entry e,
const char *  title,
const struct url_data data 
)
static

Set a hotlist entry's data from the url_data.

Parameters
ehotlist entry to set up
titleTitle for entry, or NULL if using title from data
dataData associated with entry's URL
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 251 of file hotlist.c.

References hotlist_entry::data, treeview_field_desc::field, treeview_field_data::field, hotlist_ctx::fields, hl_ctx, HL_TITLE, HL_URL, hotlist_create_treeview_field_visits_data(), NSERROR_NOMEM, NSERROR_OK, nsurl_access(), nsurl_length(), url_data::title, hotlist_entry::url, treeview_field_data::value, and treeview_field_data::value_len.

Referenced by hotlist_create_entry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_create_treeview_field_visits_data()

static nserror hotlist_create_treeview_field_visits_data ( struct hotlist_entry e,
const struct url_data data 
)
static

Set a hotlist entry's data from the url_data.

Parameters
ehotlist entry to set up.
dataData associated with entry's URL.
Returns
NSERROR_OK on success, appropriate error otherwise.

Definition at line 192 of file hotlist.c.

References buffer, hotlist_entry::data, treeview_field_desc::field, treeview_field_data::field, hotlist_ctx::fields, hl_ctx, HL_LAST_VISIT, HL_VISITS, url_data::last_visit, NSERROR_NOMEM, NSERROR_OK, treeview_field_data::value, treeview_field_data::value_len, and url_data::visits.

Referenced by hotlist_create_treeview_field_data(), and hotlist_update_url_walk_cb().

Here is the caller graph for this function:

◆ hotlist_delete_entry_internal()

static void hotlist_delete_entry_internal ( struct hotlist_entry e)
static

Delete a hotlist entry.

This does not delete the treeview node, rather it should only be called from the treeview node delete event message.

Parameters
eEntry to delete

Definition at line 324 of file hotlist.c.

References hotlist_entry::data, hotlist_entry::entry, HL_LAST_VISIT, HL_TITLE, HL_VISITS, nsurl_unref(), hotlist_entry::url, and treeview_field_data::value.

Referenced by hotlist_add_entry_internal(), and hotlist_tree_node_entry_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_edit_selection()

void hotlist_edit_selection ( void  )

Edit the first selected node.

Definition at line 1734 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_edit_selection().

Referenced by handle_event(), HOOKF(), hotlist_menu_select(), and MENUHANDLER().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_entry_insert()

static nserror hotlist_entry_insert ( struct hotlist_entry e,
treeview_node relation,
enum treeview_relationship  rel 
)
static

Add a hotlist entry to the treeview.

Parameters
eEntry to add to treeview
relationExisting node to insert as relation of, or NULL
relFolder's relationship to relation
Returns
NSERROR_OK on success, or appropriate error otherwise

It is assumed that the entry is unique (for its URL) in the global hotlist table

Definition at line 299 of file hotlist.c.

References hotlist_ctx::built, hotlist_entry::data, hotlist_entry::entry, hl_ctx, NSERROR_OK, hotlist_ctx::tree, TREE_OPTION_NONE, TREE_OPTION_SUPPRESS_REDRAW, TREE_OPTION_SUPPRESS_RESIZE, and treeview_create_node_entry().

Referenced by hotlist_add_entry_internal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_expand()

nserror hotlist_expand ( bool  only_folders)

Expand the treeview's nodes.

Parameters
only_foldersIff true, only folders are expanded.
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1741 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_expand().

Referenced by HOOKF(), hotlist_menu_select(), hotlist_toolbar_click(), and MENUHANDLER().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_export()

nserror hotlist_export ( const char *  path,
const char *  title 
)

Save hotlist to file.

Parameters
pathThe path to save hotlist to
titleThe title to give the hotlist, or NULL for default
Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 1086 of file hotlist.c.

References treeview_export_walk_ctx::fp, hl_ctx, hotlist_export_enter_cb(), hotlist_export_leave_cb(), NSERROR_OK, NSERROR_SAVE_FAILED, path(), hotlist_ctx::tree, TREE_NODE_ENTRY, TREE_NODE_FOLDER, and treeview_walk().

Referenced by HOOKF(), hotlist_save(), MENUHANDLER(), and ro_gui_save_content().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_export_enter_cb()

static nserror hotlist_export_enter_cb ( void *  ctx,
void *  node_data,
enum treeview_node_type  type,
bool *  abort 
)
static

Callback for treeview_walk node entering.

Definition at line 1023 of file hotlist.c.

References hotlist_folder::data, hotlist_entry::data, hotlist_ctx::default_folder, treeview_export_walk_ctx::fp, hl_ctx, HL_TITLE, HL_URL, NSERROR_OK, NSERROR_SAVE_FAILED, TREE_NODE_ENTRY, TREE_NODE_FOLDER, type, utf8_to_html(), treeview_field_data::value, and treeview_field_data::value_len.

Referenced by hotlist_export().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_export_leave_cb()

static nserror hotlist_export_leave_cb ( void *  ctx,
void *  node_data,
enum treeview_node_type  type,
bool *  abort 
)
static

Callback for treeview_walk node leaving.

Definition at line 1074 of file hotlist.c.

References treeview_export_walk_ctx::fp, NSERROR_OK, TREE_NODE_FOLDER, and type.

Referenced by hotlist_export().

Here is the caller graph for this function:

◆ hotlist_fini()

nserror hotlist_fini ( void  )

Finalise the hotlist.

This destroys the hotlist treeview and the hotlist module's internal data. After calling this if hotlist is required again, hotlist_init must be called.

Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1388 of file hotlist.c.

References hotlist_ctx::built, treeview_field_desc::field, hotlist_ctx::fields, guit, hl_ctx, HL_N_FIELDS, hotlist_save(), hotlist_schedule_save_cb(), netsurf_table::misc, NSERROR_OK, NSLOG, hotlist_ctx::save_path, hotlist_ctx::save_scheduled, gui_misc_table::schedule, hotlist_ctx::tree, treeview_destroy(), and treeview_fini().

Referenced by atari_hotlist_finish(), gui_quit(), nsgtk_finalise(), nsw32_hotlist_finalise(), and ro_gui_hotlist_finalise().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_generate()

static nserror hotlist_generate ( void  )
static

Definition at line 962 of file hotlist.c.

References hotlist_folder::folder, hotlist_add_entry_internal(), hotlist_add_folder_internal(), messages_get(), NSERROR_NOMEM, NSERROR_OK, nsurl_create(), nsurl_unref(), and TREE_REL_FIRST_CHILD.

Referenced by hotlist_populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_get_selection()

bool hotlist_get_selection ( struct nsurl **  url,
const char **  title 
)

Get the first selected node.

Parameters
urlUpdated to the selected entry's address, or NULL
titleUpdated to the selected entry's title, or NULL
Returns
true iff hotlist has a selection

Definition at line 1712 of file hotlist.c.

References hotlist_entry::data, hl_ctx, HL_TITLE, hotlist_ctx::tree, TREE_NODE_ENTRY, treeview_get_selection(), type, hotlist_entry::url, and treeview_field_data::value.

Referenced by ami_hotlist_drag_end().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_get_temp_path()

static nserror hotlist_get_temp_path ( const char *  path,
char **  temp_path 
)
static

Definition at line 85 of file hotlist.c.

References NSERROR_NOMEM, NSERROR_OK, NSERROR_UNKNOWN, and path().

Referenced by hotlist_load(), and hotlist_save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_has_selection()

bool hotlist_has_selection ( void  )

Determine whether there is a selection.

Returns
true iff there is a selection

Definition at line 1705 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_has_selection().

Referenced by ami_hotlist_drag_end(), hotlist_menu_prepare(), and hotlist_toolbar_update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_has_url()

bool hotlist_has_url ( struct nsurl url)

Check whether given URL is present in hotlist.

Parameters
urlAddress to look for in hotlist
Returns
true iff url is present in hotlist, false otherwise

Definition at line 1494 of file hotlist.c.

References hotlist_ctx::built, treeview_has_url_walk_ctx::found, hl_ctx, hotlist_has_url_walk_cb(), NSERROR_OK, hotlist_ctx::tree, TREE_NODE_ENTRY, treeview_walk(), and treeview_has_url_walk_ctx::url.

Referenced by ami_gui_event(), ami_gui_update_hotlist_button(), atari_hotlist_add_page(), ro_gui_hotlist_has_page(), ro_gui_hotlist_remove_page(), and toolbar_favorite_click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_has_url_walk_cb()

static nserror hotlist_has_url_walk_cb ( void *  ctx,
void *  node_data,
enum treeview_node_type  type,
bool *  abort 
)
static

Callback for treeview_walk.

Definition at line 1476 of file hotlist.c.

References treeview_has_url_walk_ctx::found, NSERROR_OK, nsurl_compare(), NSURL_COMPLETE, TREE_NODE_ENTRY, type, hotlist_entry::url, and treeview_has_url_walk_ctx::url.

Referenced by hotlist_has_url().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_init()

nserror hotlist_init ( const char *  load_path,
const char *  save_path 
)

Initialise the hotlist.

This opens the hotlist file, construct the hostlist, and creates a treeview. If there's no hotlist file, it generates a default hotlist.

This must be called before any other hotlist_* function. It must 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.

In read-only mode the hotlist can be modified, but changes will not persist over sessions.

Parameters
load_pathThe path to load hotlist from.
save_pathThe path to save hotlist to, or NULL for read-only mode.
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1290 of file hotlist.c.

References hotlist_ctx::built, hotlist_ctx::default_folder, hotlist_ctx::fields, hl_ctx, HL_N_FIELDS, hl_tree_cb_t, hotlist_initialise_entry_fields(), hotlist_populate(), NSERROR_NOMEM, NSERROR_OK, NSLOG, hotlist_ctx::save_path, hotlist_ctx::tree, treeview_create(), treeview_init(), and TREEVIEW_SEARCHABLE.

Referenced by atari_hotlist_init(), gui_init(), gui_init2(), nsgtk_setup(), and WinMain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_initialise_entry_fields()

static nserror hotlist_initialise_entry_fields ( void  )
static

Initialise the treeview entry feilds.

Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 1193 of file hotlist.c.

References treeview_field_desc::field, hotlist_ctx::fields, treeview_field_desc::flags, hl_ctx, HL_FOLDER, HL_LAST_VISIT, HL_N_FIELDS, HL_TITLE, HL_URL, HL_VISITS, messages_get(), NSERROR_OK, NSERROR_UNKNOWN, TREE_FLAG_ALLOW_EDIT, TREE_FLAG_COPY_TEXT, TREE_FLAG_DEFAULT, TREE_FLAG_SEARCHABLE, and TREE_FLAG_SHOW_NAME.

Referenced by hotlist_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_iterate()

nserror hotlist_iterate ( void *  ctx,
hotlist_folder_enter_cb  enter_cb,
hotlist_address_cb  address_cb,
hotlist_folder_leave_cb  leave_cb 
)

Walk (depth first) the hotlist, calling callbacks on entering folders, address nodes, and on leaving folders.

Parameters
ctxClient context, passed back to callback function
enter_cbFunction to call on entering nodes, or NULL
address_cbFunction to call on address nodes, or NULL
leave_cbFunction to call on leaving nodes, or NULL
Returns
NSERROR_OK on success, or appropriate error otherwise

Example usage: Generate a menu containing hotlist entries. For flat list set enter_cb and leave_cb to NULL, or for hierarchical menu provide the folder callbacks.

Definition at line 1164 of file hotlist.c.

References hotlist_iterate_ctx::address_cb, hotlist_iterate_ctx::ctx, hotlist_iterate_ctx::enter_cb, hl_ctx, hotlist_iterate_enter_cb(), hotlist_iterate_leave_cb(), hotlist_iterate_ctx::leave_cb, NSERROR_OK, hotlist_ctx::tree, TREE_NODE_ENTRY, TREE_NODE_FOLDER, and treeview_walk().

Referenced by ami_hotlist_scan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_iterate_enter_cb()

static nserror hotlist_iterate_enter_cb ( void *  ctx,
void *  node_data,
enum treeview_node_type  type,
bool *  abort 
)
static

Callback for hotlist_iterate node entering.

Definition at line 1134 of file hotlist.c.

References hotlist_iterate_ctx::address_cb, hotlist_iterate_ctx::ctx, hotlist_folder::data, hotlist_entry::data, HL_TITLE, NSERROR_OK, TREE_NODE_ENTRY, TREE_NODE_FOLDER, type, hotlist_entry::url, and treeview_field_data::value.

Referenced by hotlist_iterate().

Here is the caller graph for this function:

◆ hotlist_iterate_leave_cb()

static nserror hotlist_iterate_leave_cb ( void *  ctx,
void *  node_data,
enum treeview_node_type  type,
bool *  abort 
)
static

Callback for hotlist_iterate node leaving.

Definition at line 1152 of file hotlist.c.

References hotlist_iterate_ctx::ctx, hotlist_iterate_ctx::leave_cb, NSERROR_OK, TREE_NODE_FOLDER, and type.

Referenced by hotlist_iterate().

Here is the caller graph for this function:

◆ hotlist_keypress()

bool hotlist_keypress ( uint32_t  key)

Key press handling.

Parameters
keyThe ucs4 character codepoint
Returns
true if the keypress is dealt with, false otherwise.

Definition at line 1698 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_keypress().

Referenced by ami_hotlist_key(), atari_hotlist_keypress(), handle_event(), HOOKF(), hotlist_key(), hotlist_menu_select(), hotlist_toolbar_click(), MENUHANDLER(), nsgtk_hotlist_key(), and nsw32_hotlist_key().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_load()

static nserror hotlist_load ( const char *  path,
bool *  loaded 
)
static

Definition at line 858 of file hotlist.c.

References hl_ctx, hotlist_get_temp_path(), hotlist_load_directory(), hotlist_load_ctx::last_was_h4, libdom_find_first_element(), libdom_parse_file(), messages_get(), NSERROR_OK, NSLOG, path(), hotlist_load_ctx::rel, hotlist_load_ctx::relshp, hotlist_load_ctx::title, hotlist_ctx::tree, hotlist_load_ctx::tree, and TREE_REL_FIRST_CHILD.

Referenced by hotlist_populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_load_directory()

static nserror hotlist_load_directory ( dom_node *  ul,
hotlist_load_ctx ctx 
)
static

Parse a directory represented as a ul.

Parameters
ulDOM node for parsed ul.
ctxThe hotlist context.
Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 733 of file hotlist.c.

References hotlist_load_directory_cb(), and libdom_iterate_child_elements().

Referenced by hotlist_load(), and hotlist_load_directory_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_load_directory_cb()

nserror hotlist_load_directory_cb ( dom_node *  node,
void *  ctx 
)
static

Definition at line 744 of file hotlist.c.

References hotlist_ctx::default_folder, hotlist_folder::folder, hl_ctx, hotlist_add_folder_internal(), hotlist_load_directory(), hotlist_load_entry(), hotlist_load_ctx::last_was_h4, NSERROR_DOM, NSERROR_NOMEM, NSERROR_OK, NSLOG, hotlist_load_ctx::rel, hotlist_load_ctx::relshp, hotlist_load_ctx::title, hotlist_load_ctx::tree, TREE_REL_FIRST_CHILD, and TREE_REL_NEXT_SIBLING.

Referenced by hotlist_load_directory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_load_entry()

static nserror hotlist_load_entry ( dom_node *  li,
hotlist_load_ctx ctx 
)
static

Parse an entry represented as a li.

Parameters
liDOM node for parsed li
ctxOur hotlist loading context.
Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 647 of file hotlist.c.

References hotlist_add_entry_internal(), libdom_find_first_element(), messages_get(), NSERROR_INVALID, NSERROR_OK, NSLOG, nsurl_create(), nsurl_unref(), hotlist_load_ctx::rel, hotlist_load_ctx::relshp, and TREE_REL_NEXT_SIBLING.

Referenced by hotlist_load_directory_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_manager_fini()

nserror hotlist_manager_fini ( void  )

Finalise the hotlist manager.

This simply disconnects the underlying treeview from its corewindow, allowing destruction of a GUI hotlist window, without finalising the hotlist module.

Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1373 of file hotlist.c.

References hl_ctx, NSERROR_OK, hotlist_ctx::tree, and treeview_cw_detach().

Referenced by ami_hotlist_destroy(), and nsgtk_hotlist_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_manager_init()

nserror hotlist_manager_init ( struct core_window_callback_table cw_t,
void *  core_window_handle 
)

Initialise the hotlist manager.

This connects the underlying hotlist treeview to a corewindow for display.

The provided core window handle must be valid until hotlist_fini is called.

Parameters
cw_tCallback table for core_window containing the treeview
core_window_handleThe handle in which the treeview is shown
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 1354 of file hotlist.c.

References cw_t, hl_ctx, NSERROR_OK, hotlist_ctx::tree, treeview_cw_attach(), and treeview_get_height().

Referenced by ami_hotlist_present(), atari_hotlist_init_phase2(), nsgtk_hotlist_init(), nsw32_hotlist_init(), and ro_hotlist_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_mouse_action()

void hotlist_mouse_action ( enum browser_mouse_state  mouse,
int  x,
int  y 
)

Handles all kinds of mouse action.

Parameters
mouseThe current mouse state
xX coordinate
yY coordinate

Definition at line 1691 of file hotlist.c.

References hl_ctx, hotlist_ctx::tree, and treeview_mouse_action().

Referenced by ami_hotlist_mouse(), atari_hotlist_mouse_action(), hotlist_mouse(), nsgtk_hotlist_mouse(), and nsw32_hotlist_mouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_populate()

static nserror hotlist_populate ( const char *  path)
static

Definition at line 1268 of file hotlist.c.

References hotlist_generate(), hotlist_load(), NSERROR_OK, and path().

Referenced by hotlist_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_redraw()

void hotlist_redraw ( int  x,
int  y,
struct rect clip,
const struct redraw_context ctx 
)

Redraw the hotlist.

Parameters
xX coordinate to render treeview at
yY coordinate to render treeview at
clipCurrent clip rectangle (wrt tree origin)
ctxCurrent redraw context

Definition at line 1683 of file hotlist.c.

References clip(), hl_ctx, hotlist_ctx::tree, and treeview_redraw().

Referenced by ami_hotlist_draw(), atari_hotlist_draw(), hotlist_draw(), nsgtk_hotlist_draw(), and nsw32_hotlist_draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_remove_url()

void hotlist_remove_url ( struct nsurl url)

Remove any entries matching the given URL from the hotlist.

Parameters
urlAddress to look for in hotlist

Definition at line 1536 of file hotlist.c.

References hotlist_ctx::built, hl_ctx, hotlist_remove_url_walk_cb(), NSERROR_OK, hotlist_ctx::tree, TREE_NODE_ENTRY, treeview_walk(), and treeview_remove_url_walk_ctx::url.

Referenced by ami_gui_event(), ro_gui_hotlist_remove_confirmed(), ro_gui_hotlist_remove_page(), and toolbar_favorite_click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_remove_url_walk_cb()

static nserror hotlist_remove_url_walk_cb ( void *  ctx,
void *  node_data,
enum treeview_node_type  type,
bool *  abort 
)
static

Callback for treeview_walk.

Definition at line 1518 of file hotlist.c.

References hotlist_entry::entry, hl_ctx, NSERROR_OK, nsurl_compare(), NSURL_COMPLETE, hotlist_ctx::tree, TREE_NODE_ENTRY, TREE_OPTION_NONE, treeview_delete_node(), type, hotlist_entry::url, and treeview_remove_url_walk_ctx::url.

Referenced by hotlist_remove_url().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_save()

static nserror hotlist_save ( const char *  path)
static

Definition at line 113 of file hotlist.c.

References hotlist_export(), hotlist_get_temp_path(), NSERROR_OK, NSERROR_SAVE_FAILED, NSLOG, and path().

Referenced by gui_init(), hotlist_fini(), hotlist_schedule_save_cb(), and ro_gui_create_dirs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_schedule_save()

static nserror hotlist_schedule_save ( void  )
static

Schedule a hotlist save.

Returns
NSERROR_OK on success, or appropriate error otherwise

Definition at line 170 of file hotlist.c.

References guit, hl_ctx, hotlist_schedule_save_cb(), netsurf_table::misc, NSERROR_OK, hotlist_ctx::save_path, hotlist_ctx::save_scheduled, and gui_misc_table::schedule.

Referenced by hotlist_add_url(), and hotlist_tree_node_entry_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_schedule_save_cb()

static void hotlist_schedule_save_cb ( void *  p)
static

Scheduler callback for saving the hotlist.

Parameters
pUnused user data.

Definition at line 158 of file hotlist.c.

References hl_ctx, hotlist_save(), hotlist_ctx::save_path, and hotlist_ctx::save_scheduled.

Referenced by hotlist_fini(), and hotlist_schedule_save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_tree_node_entry_cb()

static nserror hotlist_tree_node_entry_cb ( struct treeview_node_msg  msg,
void *  data 
)
static

◆ hotlist_tree_node_folder_cb()

static nserror hotlist_tree_node_folder_cb ( struct treeview_node_msg  msg,
void *  data 
)
static

◆ hotlist_update_url()

void hotlist_update_url ( struct nsurl url)

Update given URL, e.g.

new visited data

Parameters
urlAddress to update entries for

Definition at line 1603 of file hotlist.c.

References hotlist_ctx::built, hl_ctx, hotlist_update_url_walk_cb(), NSERROR_OK, hotlist_ctx::tree, TREE_NODE_ENTRY, treeview_walk(), and treeview_update_url_walk_ctx::url.

Referenced by browser_window_content_done().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hotlist_update_url_walk_cb()

static nserror hotlist_update_url_walk_cb ( void *  ctx,
void *  node_data,
enum treeview_node_type  type,
bool *  abort 
)
static

Callback for treeview_walk.

Definition at line 1560 of file hotlist.c.

References hotlist_entry::data, treeview_update_url_walk_ctx::data, hotlist_entry::entry, hl_ctx, HL_LAST_VISIT, HL_VISITS, hotlist_create_treeview_field_visits_data(), NSERROR_NOMEM, NSERROR_OK, nsurl_compare(), NSURL_COMPLETE, hotlist_ctx::tree, TREE_NODE_ENTRY, treeview_update_node_entry(), type, hotlist_entry::url, treeview_update_url_walk_ctx::url, urldb_add_url(), urldb_get_url_data(), and treeview_field_data::value.

Referenced by hotlist_update_url().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ hl_ctx

struct hotlist_ctx hl_ctx

◆ hl_tree_cb_t

struct treeview_callback_table hl_tree_cb_t
Initial value:
= {
}
static nserror hotlist_tree_node_folder_cb(struct treeview_node_msg msg, void *data)
Definition: hotlist.c:491
static nserror hotlist_tree_node_entry_cb(struct treeview_node_msg msg, void *data)
callback for hotlist treeview entry manipulation.
Definition: hotlist.c:538

Definition at line 624 of file hotlist.c.

Referenced by hotlist_init().