NetSurf
|
#include <stdlib.h>
#include <string.h>
#include <time.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 "desktop/global_history.h"
#include "desktop/treeview.h"
#include "netsurf/browser_window.h"
Go to the source code of this file.
Data Structures | |
struct | global_history_folder |
struct | global_history_ctx |
struct | global_history_entry |
struct | treeview_export_walk_ctx |
Macros | |
#define | N_DAYS 28 |
#define | N_SEC_PER_DAY (60 * 60 * 24) |
Enumerations | |
enum | global_history_folders { GH_TODAY = 0 , GH_YESTERDAY , GH_2_DAYS_AGO , GH_3_DAYS_AGO , GH_4_DAYS_AGO , GH_5_DAYS_AGO , GH_6_DAYS_AGO , GH_LAST_WEEK , GH_2_WEEKS_AGO , GH_3_WEEKS_AGO , GH_N_FOLDERS } |
enum | global_history_fields { GH_TITLE , GH_URL , GH_LAST_VISIT , GH_VISITS , GH_PERIOD , N_FIELDS } |
Functions | |
static struct global_history_entry * | global_history_find (nsurl *url) |
Find an entry in the global history. More... | |
static nserror | global_history_create_dir (enum global_history_folders f) |
Initialise the treeview directories. More... | |
static nserror | global_history_get_parent_treeview_node (treeview_node **parent, int slot) |
Get the treeview folder for history entires in a particular slot. More... | |
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. More... | |
static nserror | global_history_entry_insert (struct global_history_entry *e, int slot) |
Add a global history entry to the treeview. More... | |
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). More... | |
static void | global_history_delete_entry_internal (struct global_history_entry *e) |
Delete a global history entry. More... | |
static bool | global_history_add_entry (nsurl *url, const struct url_data *data) |
Internal routine to actually perform global history addition. More... | |
static nserror | global_history_initialise_entry_fields (void) |
Initialise the treeview entry feilds. More... | |
static nserror | global_history_initialise_time (void) |
Initialise the time. More... | |
static nserror | global_history_init_entries (void) |
Initialise the treeview entries. More... | |
static nserror | global_history_tree_node_folder_cb (struct treeview_node_msg msg, void *data) |
static nserror | global_history_tree_node_entry_cb (struct treeview_node_msg msg, void *data) |
nserror | global_history_init (void *core_window_handle) |
Initialise the global history. More... | |
nserror | global_history_fini (void) |
Finalise the global history. More... | |
nserror | global_history_add (nsurl *url) |
Add an entry to the global history. More... | |
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. More... | |
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. More... | |
nserror | global_history_export (const char *path, const char *title) |
Save global history to file (html) More... | |
void | global_history_redraw (int x, int y, struct rect *clip, const struct redraw_context *ctx) |
Redraw the global history. More... | |
void | global_history_mouse_action (browser_mouse_state mouse, int x, int y) |
Handles all kinds of mouse action. More... | |
bool | global_history_keypress (uint32_t key) |
Key press handling. More... | |
bool | global_history_has_selection (void) |
Determine whether there is a selection. More... | |
bool | global_history_get_selection (nsurl **url, const char **title) |
Get the first selected node. More... | |
nserror | global_history_expand (bool only_folders) |
Expand the treeview's nodes. More... | |
nserror | global_history_contract (bool all) |
Contract the treeview's nodes. More... | |
Variables | |
struct global_history_ctx | gh_ctx |
struct global_history_entry * | gh_list [N_DAYS] |
struct treeview_callback_table | gh_tree_cb_t |
#define N_DAYS 28 |
Definition at line 36 of file global_history.c.
#define N_SEC_PER_DAY (60 * 60 * 24) |
Definition at line 37 of file global_history.c.
Enumerator | |
---|---|
GH_TITLE | |
GH_URL | |
GH_LAST_VISIT | |
GH_VISITS | |
GH_PERIOD | |
N_FIELDS |
Definition at line 53 of file global_history.c.
Enumerator | |
---|---|
GH_TODAY | |
GH_YESTERDAY | |
GH_2_DAYS_AGO | |
GH_3_DAYS_AGO | |
GH_4_DAYS_AGO | |
GH_5_DAYS_AGO | |
GH_6_DAYS_AGO | |
GH_LAST_WEEK | |
GH_2_WEEKS_AGO | |
GH_3_WEEKS_AGO | |
GH_N_FOLDERS |
Definition at line 39 of file global_history.c.
Add an entry to the global history.
If the URL already exists in the global history, the old node is removed.
url | URL for node being added |
Definition at line 829 of file global_history.c.
References gh_ctx, global_history_add_entry(), NSERROR_BAD_PARAMETER, NSERROR_OK, NSLOG, global_history_ctx::tree, and urldb_get_url_data().
Referenced by browser_window_content_ready().
Internal routine to actually perform global history addition.
url | The URL to add |
data | URL data associated with URL |
Definition at line 476 of file global_history.c.
References global_history_entry::data, global_history_entry::entry, gh_ctx, global_history_add_entry_internal(), global_history_find(), N_DAYS, N_SEC_PER_DAY, NSERROR_OK, global_history_entry::slot, global_history_ctx::today, global_history_ctx::tree, TREE_OPTION_SUPPRESS_REDRAW, TREE_OPTION_SUPPRESS_RESIZE, treeview_delete_node(), and global_history_entry::url.
Referenced by global_history_add(), and global_history_init().
|
static |
Add an entry to the global history (creates the entry).
If the treeview has already been created, the entry will be added to the treeview. Otherwise, the entry will have to be added to the treeview later.
When we first create the global history we create it without the treeview, to simplfy sorting the entries.
url | URL for entry to add to history |
slot | Global history slot to contain history entry |
data | URL data for the entry |
got_treeview | Whether the treeview has been created already |
Definition at line 357 of file global_history.c.
References global_history_entry::data, global_history_entry::entry, gh_list, global_history_create_treeview_field_data(), global_history_entry_insert(), global_history_entry::next, NSERROR_NOMEM, NSERROR_OK, nsurl_ref(), global_history_entry::prev, global_history_entry::slot, global_history_entry::t, global_history_entry::url, and global_history_entry::user_delete.
Referenced by global_history_add_entry().
nserror global_history_contract | ( | bool | all | ) |
Contract the treeview's nodes.
all | Iff false, only entries are contracted. |
Definition at line 1009 of file global_history.c.
References gh_ctx, global_history_ctx::tree, and treeview_contract().
Referenced by global_history_menu_select(), global_history_toolbar_click(), HOOKF(), and MENUHANDLER().
|
static |
Initialise the treeview directories.
f | Ident for folder to create |
Definition at line 128 of file global_history.c.
References global_history_ctx::built, global_history_folder::data, treeview_field_desc::field, treeview_field_data::field, global_history_ctx::fields, global_history_folder::folder, global_history_ctx::folders, GH_2_DAYS_AGO, GH_2_WEEKS_AGO, GH_3_DAYS_AGO, GH_3_WEEKS_AGO, GH_4_DAYS_AGO, GH_5_DAYS_AGO, GH_6_DAYS_AGO, gh_ctx, GH_LAST_WEEK, GH_TODAY, GH_YESTERDAY, messages_get(), N_FIELDS, NSERROR_BAD_PARAMETER, global_history_ctx::tree, TREE_OPTION_NONE, TREE_OPTION_SUPPRESS_REDRAW, TREE_OPTION_SUPPRESS_RESIZE, TREE_REL_FIRST_CHILD, TREE_REL_NEXT_SIBLING, treeview_create_node_folder(), treeview_field_data::value, and treeview_field_data::value_len.
Referenced by global_history_get_parent_treeview_node(), and global_history_init().
|
static |
Set a global history entry's data from the url_data.
e | Global history entry to set up |
data | Data associated with entry's URL |
Definition at line 262 of file global_history.c.
References buffer, global_history_folder::data, global_history_entry::data, treeview_field_desc::field, treeview_field_data::field, global_history_ctx::fields, gh_ctx, GH_LAST_VISIT, GH_TITLE, GH_URL, GH_VISITS, url_data::last_visit, messages_get(), NSERROR_OK, nsurl_access(), nsurl_length(), global_history_entry::url, treeview_field_data::value, treeview_field_data::value_len, and url_data::visits.
Referenced by global_history_add_entry_internal().
|
static |
Delete a global history entry.
This does not delete the treeview node, rather it should only be called from the treeview node delete event message.
e | Entry to delete |
Definition at line 430 of file global_history.c.
References global_history_entry::data, global_history_entry::entry, GH_LAST_VISIT, gh_list, GH_TITLE, GH_VISITS, global_history_entry::next, nsurl_unref(), global_history_entry::prev, global_history_entry::slot, global_history_entry::url, urldb_reset_url_visit_data(), global_history_entry::user_delete, and treeview_field_data::value.
Referenced by global_history_tree_node_entry_cb().
|
static |
Add a global history entry to the treeview.
e | entry to add to treeview |
slot | global history slot containing entry |
It is assumed that the entry is unique (for its URL) in the global history table
Definition at line 318 of file global_history.c.
References global_history_ctx::built, global_history_entry::data, global_history_entry::entry, gh_ctx, global_history_get_parent_treeview_node(), NSERROR_OK, parent, global_history_ctx::tree, TREE_OPTION_NONE, TREE_OPTION_SUPPRESS_REDRAW, TREE_OPTION_SUPPRESS_RESIZE, TREE_REL_FIRST_CHILD, and treeview_create_node_entry().
Referenced by global_history_add_entry_internal(), and global_history_init_entries().
nserror global_history_expand | ( | bool | only_folders | ) |
Expand the treeview's nodes.
only_folders | Iff true, only folders are expanded. |
Definition at line 1002 of file global_history.c.
References gh_ctx, global_history_ctx::tree, and treeview_expand().
Referenced by global_history_menu_select(), global_history_toolbar_click(), HOOKF(), and MENUHANDLER().
nserror global_history_export | ( | const char * | path, |
const char * | title | ||
) |
Save global history to file (html)
path | The path to save history to |
title | The title to give the document, or NULL for default |
Definition at line 912 of file global_history.c.
References treeview_export_walk_ctx::fp, gh_ctx, global_history_export_enter_cb(), global_history_export_leave_cb(), NSERROR_OK, NSERROR_SAVE_FAILED, path(), global_history_ctx::tree, TREE_NODE_ENTRY, TREE_NODE_FOLDER, and treeview_walk().
Referenced by HOOKF(), MENUHANDLER(), and ro_gui_save_content().
|
static |
Callback for treeview_walk node entering.
Definition at line 854 of file global_history.c.
References global_history_folder::data, global_history_entry::data, treeview_export_walk_ctx::fp, GH_TITLE, GH_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 global_history_export().
|
static |
Callback for treeview_walk node leaving.
Definition at line 900 of file global_history.c.
References treeview_export_walk_ctx::fp, NSERROR_OK, TREE_NODE_FOLDER, and type.
Referenced by global_history_export().
|
static |
Find an entry in the global history.
url | The URL to find |
Definition at line 98 of file global_history.c.
References gh_list, N_DAYS, global_history_entry::next, nsurl_compare(), NSURL_COMPLETE, and global_history_entry::url.
Referenced by global_history_add_entry().
nserror global_history_fini | ( | void | ) |
Finalise the global history.
This destroys the global history treeview and the global history module's internal data. After calling this if global history is required again, global_history_init must be called.
Definition at line 799 of file global_history.c.
References global_history_ctx::built, treeview_field_desc::field, global_history_ctx::fields, gh_ctx, N_FIELDS, NSERROR_OK, NSLOG, global_history_ctx::tree, treeview_destroy(), and treeview_fini().
Referenced by ami_history_global_destroy(), atari_global_history_finish(), nsgtk_global_history_destroy(), nsw32_global_history_finalise(), and ro_gui_global_history_finalise().
|
inlinestatic |
Get the treeview folder for history entires in a particular slot.
parent | Updated to parent folder. |
slot | Global history slot of entry we want folder node for |
Definition at line 214 of file global_history.c.
References global_history_folder::folder, global_history_ctx::folders, GH_2_WEEKS_AGO, GH_3_WEEKS_AGO, gh_ctx, GH_LAST_WEEK, global_history_create_dir(), N_DAYS, NSERROR_BAD_PARAMETER, NSERROR_OK, and parent.
Referenced by global_history_entry_insert().
bool global_history_get_selection | ( | struct nsurl ** | url, |
const char ** | title | ||
) |
Get the first selected node.
url | Updated to the selected entry's address, or NULL |
title | Updated to the selected entry's title, or NULL |
Definition at line 980 of file global_history.c.
References global_history_entry::data, gh_ctx, GH_TITLE, global_history_ctx::tree, TREE_NODE_ENTRY, treeview_get_selection(), type, global_history_entry::url, and treeview_field_data::value.
Referenced by ami_history_global_drag_end().
bool global_history_has_selection | ( | void | ) |
Determine whether there is a selection.
Definition at line 973 of file global_history.c.
References gh_ctx, global_history_ctx::tree, and treeview_has_selection().
Referenced by ami_history_global_drag_end(), global_history_menu_prepare(), and global_history_toolbar_update().
nserror global_history_init | ( | void * | core_window_handle | ) |
Initialise the global history.
This iterates through the URL database, generating the global history data, and creates a treeview.
This must be called before any other global_history_* function.
core_window_handle | The core_window in which the global history is shown. |
Definition at line 726 of file global_history.c.
References global_history_ctx::built, global_history_ctx::fields, global_history_folder::folder, global_history_ctx::folders, gh_ctx, GH_TODAY, gh_tree_cb_t, global_history_add_entry(), global_history_create_dir(), global_history_init_entries(), global_history_initialise_entry_fields(), global_history_initialise_time(), N_FIELDS, NSERROR_OK, NSLOG, global_history_ctx::tree, treeview_create(), TREEVIEW_DEL_EMPTY_DIRS, treeview_get_height(), treeview_init(), TREEVIEW_NO_MOVES, treeview_node_expand(), TREEVIEW_SEARCHABLE, and urldb_iterate_entries().
Referenced by ami_history_global_present(), atari_global_history_init_phase2(), nsgtk_global_history_init(), nsw32_global_history_init(), and ro_global_history_init().
|
static |
Initialise the treeview entries.
Definition at line 630 of file global_history.c.
References gh_list, global_history_entry_insert(), N_DAYS, global_history_entry::next, NSERROR_OK, and global_history_entry::prev.
Referenced by global_history_init().
|
static |
Initialise the treeview entry feilds.
Definition at line 524 of file global_history.c.
References treeview_field_desc::field, global_history_ctx::fields, treeview_field_desc::flags, gh_ctx, GH_LAST_VISIT, GH_PERIOD, GH_TITLE, GH_URL, GH_VISITS, messages_get(), N_FIELDS, NSERROR_OK, NSERROR_UNKNOWN, TREE_FLAG_COPY_TEXT, TREE_FLAG_DEFAULT, TREE_FLAG_SEARCHABLE, and TREE_FLAG_SHOW_NAME.
Referenced by global_history_init().
|
static |
Initialise the time.
Definition at line 595 of file global_history.c.
References gh_ctx, NSERROR_OK, NSERROR_UNKNOWN, NSLOG, global_history_ctx::today, and global_history_ctx::weekday.
Referenced by global_history_init().
bool global_history_keypress | ( | uint32_t | key | ) |
Key press handling.
key | The ucs4 character codepoint |
Definition at line 966 of file global_history.c.
References gh_ctx, global_history_ctx::tree, and treeview_keypress().
Referenced by ami_history_global_key(), atari_global_history_keypress(), global_history_key(), global_history_menu_select(), global_history_toolbar_click(), HOOKF(), MENUHANDLER(), nsgtk_global_history_key(), and nsw32_global_history_key().
void global_history_mouse_action | ( | enum browser_mouse_state | mouse, |
int | x, | ||
int | y | ||
) |
Handles all kinds of mouse action.
mouse | The current mouse state |
x | X coordinate |
y | Y coordinate |
Definition at line 959 of file global_history.c.
References gh_ctx, global_history_ctx::tree, and treeview_mouse_action().
Referenced by ami_history_global_mouse(), atari_global_history_mouse_action(), global_history_mouse(), nsgtk_global_history_mouse(), and nsw32_global_history_mouse().
void global_history_redraw | ( | int | x, |
int | y, | ||
struct rect * | clip, | ||
const struct redraw_context * | ctx | ||
) |
Redraw the global history.
x | X coordinate to render treeview at |
y | Y coordinate to render treeview at |
clip | Current clip rectangle (wrt tree origin) |
ctx | Current redraw context |
Definition at line 951 of file global_history.c.
References clip(), gh_ctx, global_history_ctx::tree, and treeview_redraw().
Referenced by ami_history_global_draw(), atari_global_history_draw(), global_history_draw(), nsgtk_global_history_draw(), and nsw32_global_history_draw().
|
static |
Definition at line 681 of file global_history.c.
References BROWSER_MOUSE_MOD_1, BROWSER_MOUSE_MOD_2, browser_window_create(), BW_CREATE_HISTORY, global_history_entry::data, treeview_node_msg::data, treeview_node_msg::delete, global_history_entry::entry, global_history_delete_entry_internal(), treeview_node_msg::mouse, treeview_node_msg::msg, treeview_node_msg::node_launch, NSERROR_OK, TREE_MSG_NODE_DELETE, TREE_MSG_NODE_EDIT, TREE_MSG_NODE_LAUNCH, global_history_entry::url, treeview_node_msg::user, and global_history_entry::user_delete.
|
static |
Definition at line 660 of file global_history.c.
References global_history_folder::data, global_history_folder::folder, treeview_node_msg::msg, NSERROR_OK, TREE_MSG_NODE_DELETE, TREE_MSG_NODE_EDIT, and TREE_MSG_NODE_LAUNCH.
struct global_history_ctx gh_ctx |
Definition at line 75 of file global_history.c.
Referenced by global_history_add(), global_history_add_entry(), global_history_contract(), global_history_create_dir(), global_history_create_treeview_field_data(), global_history_entry_insert(), global_history_expand(), global_history_export(), global_history_fini(), global_history_get_parent_treeview_node(), global_history_get_selection(), global_history_has_selection(), global_history_init(), global_history_initialise_entry_fields(), global_history_initialise_time(), global_history_keypress(), global_history_mouse_action(), and global_history_redraw().
struct global_history_entry* gh_list[N_DAYS] |
Definition at line 89 of file global_history.c.
Referenced by global_history_add_entry_internal(), global_history_delete_entry_internal(), global_history_find(), and global_history_init_entries().
struct treeview_callback_table gh_tree_cb_t |
Definition at line 719 of file global_history.c.
Referenced by global_history_init().