37#define N_SEC_PER_DAY (60 * 60 * 24)
103 for (i = 0; i <
N_DAYS; i++) {
142 label =
"DateYesterday";
183 for (i = f - 1; i >= 0; i--) {
224 }
else if (slot < 14) {
227 }
else if (slot < 21) {
230 }
else if (slot <
N_DAYS) {
266 const char *title = (
data->title != NULL) ?
270 char *last_visited = NULL;
282 if ((lvtime = localtime(&data->
last_visit)) != NULL) {
283 const size_t lvsize = 256;
284 last_visited = malloc(lvsize);
285 if (last_visited != NULL) {
286 len = strftime(last_visited, lvsize,
287 "%a %b %e %H:%M:%S %Y", lvtime);
358 const struct url_data *data,
bool got_treeview)
372 e->
t =
data->last_visit;
394 while (curr != NULL) {
395 if (curr->
t < e->
t) {
434 assert(e->
entry == NULL);
444 }
else if (e->
next == NULL) {
484 assert((
url != NULL) && (
data != NULL));
486 visit_date =
data->last_visit;
491 }
else if (visit_date >= earliest_date) {
498 if (got_treeview ==
true) {
533 label =
"TreeviewLabelTitle";
535 if (lwc_intern_string(label, strlen(label),
544 label =
"TreeviewLabelURL";
546 if (lwc_intern_string(label, strlen(label),
553 label =
"TreeviewLabelLastVisit";
555 if (lwc_intern_string(label, strlen(label),
562 label =
"TreeviewLabelVisits";
564 if (lwc_intern_string(label, strlen(label),
571 label =
"TreeviewLabelPeriod";
573 if (lwc_intern_string(label, strlen(label),
597 struct tm *full_time;
603 NSLOG(netsurf, INFO,
"time info unaviable");
608 full_time = localtime(&t);
609 full_time->tm_sec = 0;
610 full_time->tm_min = 0;
611 full_time->tm_hour = 0;
612 t = mktime(full_time);
614 NSLOG(netsurf, INFO,
"mktime failed");
636 for (i = 0; i <
N_DAYS; i++) {
735 NSLOG(netsurf, INFO,
"Loading global history");
792 NSLOG(netsurf, INFO,
"Loaded global history");
804 NSLOG(netsurf, INFO,
"Finalising global history");
822 NSLOG(netsurf, INFO,
"Finalised global history");
840 "Can't add URL to history that's not present in urldb.");
877 fprintf(tw->
fp,
"<li><a href=\"%s\">%s</a></li>\n",
892 fprintf(tw->
fp,
"<li><h4>%s</h4>\n<ul>\n", f_text);
906 fputs(
"</ul></li>\n", tw->
fp);
923 title =
"NetSurf Browsing History";
925 fputs(
"<!DOCTYPE html "
926 "PUBLIC \"//W3C/DTD HTML 4.01//EN\" "
927 "\"http://www.w3.org/TR/html4/strict.dtd\">\n",
fp);
928 fputs(
"<html>\n<head>\n",
fp);
929 fputs(
"<meta http-equiv=\"Content-Type\" "
930 "content=\"text/html; charset=iso-8859-1\">\n",
fp);
931 fprintf(
fp,
"<title>%s</title>\n", title);
932 fputs(
"</head>\n<body>\n<ul>\n",
fp);
942 fputs(
"</ul>\n</body>\n</html>\n",
fp);
Browser window creation and manipulation interface.
nserror browser_window_create(enum browser_window_create_flags flags, struct nsurl *url, struct nsurl *referrer, struct browser_window *existing, struct browser_window **bw)
Create and open a new root browser window with the given page.
browser_window_create_flags
flags to browser_window_create
@ BW_CREATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
static osspriteop_area * buffer
The buffer characteristics.
nserror global_history_init(void *core_window_handle)
Initialise the global history.
static nserror global_history_create_treeview_field_data(struct global_history_entry *e, const struct url_data *data)
Set a global history entry's data from the url_data.
static nserror global_history_initialise_time(void)
Initialise the time.
static nserror global_history_get_parent_treeview_node(treeview_node **parent, int slot)
Get the treeview folder for history entires in a particular slot.
nserror global_history_expand(bool only_folders)
Expand the treeview's nodes.
static nserror global_history_init_entries(void)
Initialise the treeview entries.
static struct global_history_entry * global_history_find(nsurl *url)
Find an entry in the global history.
nserror global_history_fini(void)
Finalise the global history.
void global_history_redraw(int x, int y, struct rect *clip, const struct redraw_context *ctx)
Redraw the global history.
struct global_history_ctx gh_ctx
nserror global_history_add(nsurl *url)
Add an entry to the global history.
bool global_history_has_selection(void)
Determine whether there is a selection.
static nserror global_history_export_enter_cb(void *ctx, void *node_data, enum treeview_node_type type, bool *abort)
Callback for treeview_walk node entering.
static bool global_history_add_entry(nsurl *url, const struct url_data *data)
Internal routine to actually perform global history addition.
static nserror global_history_tree_node_entry_cb(struct treeview_node_msg msg, void *data)
static void global_history_delete_entry_internal(struct global_history_entry *e)
Delete a global history entry.
static nserror global_history_create_dir(enum global_history_folders f)
Initialise the treeview directories.
bool global_history_get_selection(nsurl **url, const char **title)
Get the first selected node.
static nserror global_history_add_entry_internal(nsurl *url, int slot, const struct url_data *data, bool got_treeview)
Add an entry to the global history (creates the entry).
nserror global_history_export(const char *path, const char *title)
Save global history to file (html)
nserror global_history_contract(bool all)
Contract the treeview's nodes.
static nserror global_history_entry_insert(struct global_history_entry *e, int slot)
Add a global history entry to the treeview.
struct global_history_entry * gh_list[N_DAYS]
static nserror global_history_initialise_entry_fields(void)
Initialise the treeview entry feilds.
static nserror global_history_export_leave_cb(void *ctx, void *node_data, enum treeview_node_type type, bool *abort)
Callback for treeview_walk node leaving.
bool global_history_keypress(uint32_t key)
Key press handling.
void global_history_mouse_action(browser_mouse_state mouse, int x, int y)
Handles all kinds of mouse action.
struct treeview_callback_table gh_tree_cb_t
static nserror global_history_tree_node_folder_cb(struct treeview_node_msg msg, void *data)
nserror treeview_create(treeview **treeout, const struct treeview_callback_table *callbacks, int n_fields, struct treeview_field_desc fields[], struct core_window *cw, treeview_flags flags)
Create a treeview.
void treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y)
Handles all kinds of mouse action.
nserror treeview_contract(treeview *tree, bool all)
Contract a treeview's nodes.
nserror treeview_delete_node(treeview *tree, treeview_node *n, treeview_node_options_flags flags)
Delete a treeview node.
enum treeview_node_type treeview_get_selection(treeview *tree, void **node_data)
Get the first selected node.
nserror treeview_fini(void)
Finalise the treeview module (all treeviews must have been destroyed first)
bool treeview_has_selection(treeview *tree)
Determine whether treeview has a selection.
bool treeview_keypress(treeview *tree, uint32_t key)
Key press handling for treeviews.
nserror treeview_create_node_folder(treeview *tree, treeview_node **folder, treeview_node *relation, enum treeview_relationship rel, const struct treeview_field_data *field, void *data, treeview_node_options_flags flags)
Create a folder node in given treeview.
nserror treeview_destroy(treeview *tree)
Destroy a treeview object.
nserror treeview_walk(treeview *tree, treeview_node *root, treeview_walk_cb enter_cb, treeview_walk_cb leave_cb, void *ctx, enum treeview_node_type type)
Walk (depth first) a treeview subtree, calling a callback at each node of required type.
int treeview_get_height(treeview *tree)
Find current height of a treeview.
void treeview_redraw(treeview *tree, const int x, const int y, struct rect *clip, const struct redraw_context *ctx)
Redraw a treeview object.
nserror treeview_node_expand(treeview *tree, treeview_node *node)
Expand a treeview node.
nserror treeview_init(void)
Prepare treeview module for treeview usage.
nserror treeview_create_node_entry(treeview *tree, treeview_node **entry, treeview_node *relation, enum treeview_relationship rel, const struct treeview_field_data fields[], void *data, treeview_node_options_flags flags)
Create an entry node in given treeview.
nserror treeview_expand(treeview *tree, bool only_folders)
Expand a treeview's nodes.
Treeview handling interface.
@ TREE_MSG_NODE_EDIT
Node to be edited.
@ TREE_MSG_NODE_LAUNCH
Node to be launched.
@ TREE_MSG_NODE_DELETE
Node to be deleted.
treeview_node_type
treeview node type
@ TREE_NODE_ENTRY
Node is an entry.
@ TREE_NODE_FOLDER
Node is folder.
@ TREE_OPTION_SUPPRESS_RESIZE
@ TREE_OPTION_SUPPRESS_REDRAW
@ TREE_FLAG_SEARCHABLE
Whether field is searchable.
@ TREE_FLAG_SHOW_NAME
Whether field name shown.
@ TREE_FLAG_COPY_TEXT
Whether to copy to clipb.
@ TREE_FLAG_DEFAULT
Whether field is default.
treeview_relationship
Relationship between nodes.
@ TREEVIEW_DEL_EMPTY_DIRS
Delete dirs on empty.
@ TREEVIEW_SEARCHABLE
Treeview has search bar.
@ TREEVIEW_NO_MOVES
No node drags.
nserror
Enumeration of error codes.
@ NSERROR_SAVE_FAILED
Failed to save data.
@ NSERROR_BAD_PARAMETER
Bad Parameter.
@ NSERROR_UNKNOWN
Unknown error - DO NOT USE.
@ NSERROR_NOMEM
Memory exhaustion.
browser_mouse_state
Mouse state: 1 is primary mouse button.
@ BROWSER_MOUSE_MOD_2
2nd modifier key pressed (eg.
@ BROWSER_MOUSE_MOD_1
1st modifier key pressed (eg.
libdom utilities (implementation).
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
NetSurf URL handling (interface).
bool nsurl_compare(const nsurl *url1, const nsurl *url2, nsurl_component parts)
Compare two URLs.
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
size_t nsurl_length(const nsurl *url)
Find the length of a NetSurf URL object's URL, as returned by nsurl_access.
nsurl * nsurl_ref(nsurl *url)
Increment the reference count to a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
Interface to utility string handling.
struct global_history_folder folders[GH_N_FOLDERS]
struct treeview_field_desc fields[N_FIELDS]
struct global_history_entry * prev
struct treeview_field_data data[N_FIELDS - 1]
struct global_history_entry * next
struct treeview_field_data data
Client callbacks for events concerning nodes.
nserror(* folder)(struct treeview_node_msg msg, void *data)
const char * value
Field value.
lwc_string * field
Field name.
size_t value_len
Field value length (bytes)
Treeview field description.
lwc_string * field
A treeview field name.
enum treeview_field_flags flags
Flags for field.
bool user
True iff delete by user interaction.
union treeview_node_msg::@94 data
The message data.
struct treeview_node_msg::@94::@95 delete
browser_mouse_state mouse
struct treeview_node_msg::@94::@97 node_launch
enum treeview_msg msg
The message type.
unsigned int visits
Visit count.
time_t last_visit
Last visit time.
Interface to time operations.
void urldb_iterate_entries(bool(*callback)(struct nsurl *url, const struct url_data *data))
Iterate over all entries in database.
const struct url_data * urldb_get_url_data(struct nsurl *url)
Find data for an URL.
void urldb_reset_url_visit_data(nsurl *url)
Reset an URL's visit statistics.
Unified URL information database internal interface.
nserror utf8_to_html(const char *string, const char *encname, size_t len, char **result_out)
Convert a UTF-8 encoded string into a string of the given encoding, applying HTML escape sequences wh...
UTF-8 manipulation functions (interface).
Interface to a number of general purpose functionality.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.