NetSurf
|
Implementation of Cookie Management. More...
#include <stdlib.h>
#include <string.h>
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/log.h"
#include "content/urldb.h"
#include "desktop/cookie_manager.h"
#include "desktop/treeview.h"
Go to the source code of this file.
Data Structures | |
struct | cookie_manager_folder |
struct | cookie_manager_ctx |
struct | cookie_manager_entry |
struct | treeview_walk_ctx |
Treewalk iterator context. More... | |
Enumerations | |
enum | cookie_manager_field { COOKIE_M_NAME , COOKIE_M_CONTENT , COOKIE_M_DOMAIN , COOKIE_M_PATH , COOKIE_M_EXPIRES , COOKIE_M_LAST_USED , COOKIE_M_RESTRICTIONS , COOKIE_M_VERSION , COOKIE_M_DOMAIN_FOLDER , COOKIE_M_N_FIELDS } |
enum | cookie_manager_value { COOKIE_M_HTTPS , COOKIE_M_SECURE , COOKIE_M_HTTP , COOKIE_M_NONE , COOKIE_M_NETSCAPE , COOKIE_M_RFC2109 , COOKIE_M_RFC2965 , COOKIE_M_YES , COOKIE_M_NO , COOKIE_M_N_VALUES } |
Functions | |
static nserror | cookie_manager_walk_cb (void *ctx, void *node_data, enum treeview_node_type type, bool *abort) |
Callback for treeview_walk. More... | |
static nserror | cookie_manager_find_entry (treeview_node *root, const char *title, size_t title_len, struct cookie_manager_entry **found) |
Find a cookie entry in the cookie manager's treeview. More... | |
static nserror | cookie_manager_find_folder (treeview_node *root, const char *title, size_t title_len, struct cookie_manager_folder **found) |
Find a cookie domain folder in the cookie manager's treeview. More... | |
static void | cookie_manager_free_treeview_field_data (struct cookie_manager_entry *e) |
Free a cookie manager entry's treeview field data. More... | |
static nserror | cookie_manager_field_builder (enum cookie_manager_field field, struct treeview_field_data *data, const char *value) |
Build a cookie manager treeview field from given text. More... | |
static nserror | cookie_manager_field_builder_time (enum cookie_manager_field field, struct treeview_field_data *fdata, const time_t *value) |
Build a cookie manager treeview field from given time. More... | |
static nserror | cookie_manager_set_treeview_field_data (struct cookie_manager_entry *e, const struct cookie_data *data) |
Set a cookie manager entry's data from the cookie_data. More... | |
static nserror | cookie_manager_create_cookie_node (struct cookie_manager_folder *parent, const struct cookie_data *data) |
Creates an empty tree entry for a cookie, and links it into the tree. More... | |
static nserror | cookie_manager_update_cookie_node (struct cookie_manager_entry *e, const struct cookie_data *data) |
Updates a cookie manager entry for updated cookie_data. More... | |
static nserror | cookie_manager_create_domain_folder (struct cookie_manager_folder **folder, const struct cookie_data *data) |
Creates an empty tree folder for a cookie domain, and links it into the tree. More... | |
bool | cookie_manager_add (const struct cookie_data *data) |
Add/update a cookie to the viewer. More... | |
void | cookie_manager_remove (const struct cookie_data *data) |
Remove a cookie from viewer. More... | |
nserror | cookie_manager_set_search_string (const char *string) |
Set the cookie manager search string. More... | |
static nserror | cookie_manager_init_entry_fields (void) |
Initialise the treeview entry feilds. More... | |
static nserror | cookie_manager_init_common_values (void) |
Initialise the common entry values. More... | |
static void | cookie_manager_delete_entry (struct cookie_manager_entry *e) |
Delete cookie manager entries (and optionally delete from urldb) More... | |
static nserror | cookie_manager_tree_node_folder_cb (struct treeview_node_msg msg, void *data) |
static nserror | cookie_manager_tree_node_entry_cb (struct treeview_node_msg msg, void *data) |
nserror | cookie_manager_init (void *core_window_handle) |
Initialise the cookie manager. More... | |
nserror | cookie_manager_fini (void) |
Finalise the cookie manager. More... | |
void | cookie_manager_redraw (int x, int y, struct rect *clip, const struct redraw_context *ctx) |
Redraw the cookies manager. More... | |
void | cookie_manager_mouse_action (enum browser_mouse_state mouse, int x, int y) |
Handles all kinds of mouse action. More... | |
bool | cookie_manager_keypress (uint32_t key) |
Key press handling. More... | |
bool | cookie_manager_has_selection (void) |
Determine whether there is a selection. More... | |
nserror | cookie_manager_expand (bool only_folders) |
Expand the treeview's nodes. More... | |
nserror | cookie_manager_contract (bool all) |
Contract the treeview's nodes. More... | |
Variables | |
struct cookie_manager_ctx | cm_ctx |
struct treeview_callback_table | cm_tree_cb_t |
Implementation of Cookie Management.
This allows users to view and remove their web cookies.
Definition in file cookie_manager.c.
enum cookie_manager_field |
Enumerator | |
---|---|
COOKIE_M_NAME | |
COOKIE_M_CONTENT | |
COOKIE_M_DOMAIN | |
COOKIE_M_PATH | |
COOKIE_M_EXPIRES | |
COOKIE_M_LAST_USED | |
COOKIE_M_RESTRICTIONS | |
COOKIE_M_VERSION | |
COOKIE_M_DOMAIN_FOLDER | |
COOKIE_M_N_FIELDS |
Definition at line 46 of file cookie_manager.c.
enum cookie_manager_value |
Enumerator | |
---|---|
COOKIE_M_HTTPS | |
COOKIE_M_SECURE | |
COOKIE_M_HTTP | |
COOKIE_M_NONE | |
COOKIE_M_NETSCAPE | |
COOKIE_M_RFC2109 | |
COOKIE_M_RFC2965 | |
COOKIE_M_YES | |
COOKIE_M_NO | |
COOKIE_M_N_VALUES |
Definition at line 59 of file cookie_manager.c.
bool cookie_manager_add | ( | const struct cookie_data * | data | ) |
Add/update a cookie to the viewer.
(Called by urldb.)
data | Data of cookie being added/updated. |
Definition at line 467 of file cookie_manager.c.
References cm_ctx, cookie_manager_create_cookie_node(), cookie_manager_create_domain_folder(), cookie_manager_find_entry(), cookie_manager_find_folder(), cookie_manager_update_cookie_node(), cookie_manager_entry::data, NSERROR_OK, parent, and cookie_manager_ctx::tree.
Referenced by cookie_manager_init(), urldb_get_cookie(), and urldb_insert_cookie().
nserror cookie_manager_contract | ( | bool | all | ) |
Contract the treeview's nodes.
all | Iff false, only entries are contracted. |
Definition at line 917 of file cookie_manager.c.
References cm_ctx, cookie_manager_ctx::tree, and treeview_contract().
Referenced by cookie_menu_select(), cookie_toolbar_click(), HOOKF(), and MENUHANDLER().
|
static |
Creates an empty tree entry for a cookie, and links it into the tree.
All information is copied from the cookie_data, and as such can be edited and should be freed.
parent | the node to link to |
data | the cookie data to use |
Definition at line 343 of file cookie_manager.c.
References cookie_manager_ctx::built, cm_ctx, cookie_manager_free_treeview_field_data(), cookie_manager_set_treeview_field_data(), cookie_manager_entry::data, cookie_manager_entry::entry, NSERROR_NOMEM, NSERROR_OK, parent, cookie_manager_ctx::tree, TREE_OPTION_NONE, TREE_OPTION_SUPPRESS_REDRAW, TREE_OPTION_SUPPRESS_RESIZE, TREE_REL_FIRST_CHILD, treeview_create_node_entry(), and cookie_manager_entry::user_delete.
Referenced by cookie_manager_add().
|
static |
Creates an empty tree folder for a cookie domain, and links it into the tree.
All information is copied from the cookie_data, and as such can be edited and should be freed.
folder | updated to the new folder |
data | the cookie data to use |
Definition at line 431 of file cookie_manager.c.
References cookie_manager_ctx::built, cm_ctx, COOKIE_M_N_FIELDS, cookie_manager_folder::data, treeview_field_desc::field, treeview_field_data::field, cookie_manager_ctx::fields, cookie_manager_folder::folder, NSERROR_NOMEM, NSERROR_OK, cookie_manager_ctx::tree, TREE_OPTION_NONE, TREE_OPTION_SUPPRESS_REDRAW, TREE_OPTION_SUPPRESS_RESIZE, TREE_REL_FIRST_CHILD, treeview_create_node_folder(), treeview_field_data::value, and treeview_field_data::value_len.
Referenced by cookie_manager_add().
|
static |
Delete cookie manager entries (and optionally delete from urldb)
e | Cookie manager entry to delete. |
Definition at line 714 of file cookie_manager.c.
References COOKIE_M_DOMAIN, COOKIE_M_NAME, COOKIE_M_PATH, cookie_manager_free_treeview_field_data(), cookie_manager_entry::data, NSLOG, path(), urldb_delete_cookie(), cookie_manager_entry::user_delete, and treeview_field_data::value.
Referenced by cookie_manager_tree_node_entry_cb().
nserror cookie_manager_expand | ( | bool | only_folders | ) |
Expand the treeview's nodes.
only_folders | Iff true, only folders are expanded. |
Definition at line 910 of file cookie_manager.c.
References cm_ctx, cookie_manager_ctx::tree, and treeview_expand().
Referenced by cookie_menu_select(), cookie_toolbar_click(), HOOKF(), and MENUHANDLER().
|
inlinestatic |
Build a cookie manager treeview field from given text.
field | Cookie manager treeview field to build |
data | Cookie manager entry field data to set |
value | Text to set in field, ownership yielded |
Definition at line 219 of file cookie_manager.c.
References cm_ctx, treeview_field_desc::field, treeview_field_data::field, cookie_manager_ctx::fields, NSERROR_OK, treeview_field_data::value, and treeview_field_data::value_len.
Referenced by cookie_manager_init_common_values(), and cookie_manager_set_treeview_field_data().
|
inlinestatic |
Build a cookie manager treeview field from given time.
The time should be converted to text in the users locacle
field | Cookie manager treeview field to build |
fdata | Cookie manager entry field data to set |
value | Time to show in field |
Definition at line 241 of file cookie_manager.c.
References cm_ctx, treeview_field_desc::field, treeview_field_data::field, cookie_manager_ctx::fields, NSERROR_OK, treeview_field_data::value, and treeview_field_data::value_len.
Referenced by cookie_manager_set_treeview_field_data().
|
static |
Find a cookie entry in the cookie manager's treeview.
root | Search root node, or NULL to search from tree's root |
title | ID of the node to look for |
title_len | Byte length of title string |
found | Updated to the matching node's cookie maanger entry |
Definition at line 139 of file cookie_manager.c.
References cm_ctx, cookie_manager_walk_cb(), treeview_walk_ctx::entry, NSERROR_OK, root, treeview_walk_ctx::title, treeview_walk_ctx::title_len, cookie_manager_ctx::tree, TREE_NODE_ENTRY, and treeview_walk().
Referenced by cookie_manager_add(), and cookie_manager_remove().
|
static |
Find a cookie domain folder in the cookie manager's treeview.
root | Search root node, or NULL to search from tree's root |
title | ID of the node to look for |
title_len | Byte length of title string |
found | Updated to the matching node's cookie maanger folder |
Definition at line 169 of file cookie_manager.c.
References cm_ctx, cookie_manager_walk_cb(), treeview_walk_ctx::folder, NSERROR_OK, root, treeview_walk_ctx::title, treeview_walk_ctx::title_len, cookie_manager_ctx::tree, TREE_NODE_FOLDER, and treeview_walk().
Referenced by cookie_manager_add(), and cookie_manager_remove().
nserror cookie_manager_fini | ( | void | ) |
Finalise the cookie manager.
This destroys the cookie manager treeview and the cookie manager module's internal data. After calling this if the cookie manager is required again, cookie_manager_init must be called.
Definition at line 846 of file cookie_manager.c.
References cookie_manager_ctx::built, cm_ctx, COOKIE_M_N_FIELDS, COOKIE_M_N_VALUES, treeview_field_desc::field, cookie_manager_ctx::fields, NSERROR_OK, NSLOG, cookie_manager_ctx::tree, treeview_destroy(), treeview_fini(), treeview_field_data::value, and cookie_manager_ctx::values.
Referenced by ami_cookies_destroy(), atari_cookie_manager_finish(), nsgtk_cookies_destroy(), nsw32_cookies_finalise(), and ro_gui_cookies_finalise().
|
static |
Free a cookie manager entry's treeview field data.
e | Cookie manager entry to free data from |
Definition at line 197 of file cookie_manager.c.
References COOKIE_M_CONTENT, COOKIE_M_DOMAIN, COOKIE_M_EXPIRES, COOKIE_M_LAST_USED, COOKIE_M_NAME, COOKIE_M_PATH, cookie_manager_entry::data, and treeview_field_data::value.
Referenced by cookie_manager_create_cookie_node(), cookie_manager_delete_entry(), and cookie_manager_update_cookie_node().
bool cookie_manager_has_selection | ( | void | ) |
Determine whether there is a selection.
Definition at line 903 of file cookie_manager.c.
References cm_ctx, cookie_manager_ctx::tree, and treeview_has_selection().
Referenced by cookie_menu_prepare(), and cookie_toolbar_update().
nserror cookie_manager_init | ( | void * | core_window_handle | ) |
Initialise the cookie manager.
This iterates through the URL database, enumerating the cookies and creates a treeview.
This must be called before any other cookie_manager_* function.
core_window_handle | The core_window in which the cookie view is shown |
Definition at line 791 of file cookie_manager.c.
References cookie_manager_ctx::built, cm_ctx, cm_tree_cb_t, COOKIE_M_N_FIELDS, cookie_manager_add(), cookie_manager_init_common_values(), cookie_manager_init_entry_fields(), cookie_manager_ctx::fields, NSERROR_OK, NSLOG, cookie_manager_ctx::tree, treeview_create(), TREEVIEW_DEL_EMPTY_DIRS, treeview_get_height(), treeview_init(), TREEVIEW_NO_MOVES, TREEVIEW_SEARCHABLE, and urldb_iterate_cookies().
Referenced by ami_cookies_present(), atari_cookie_manager_init_phase2(), nsgtk_cookies_init(), nsw32_cookie_init(), and ro_cookie_init().
|
static |
Initialise the common entry values.
Definition at line 668 of file cookie_manager.c.
References cm_ctx, COOKIE_M_HTTP, COOKIE_M_HTTPS, COOKIE_M_NETSCAPE, COOKIE_M_NONE, COOKIE_M_RESTRICTIONS, COOKIE_M_RFC2109, COOKIE_M_RFC2965, COOKIE_M_SECURE, COOKIE_M_VERSION, cookie_manager_field_builder(), COOKIE_NETSCAPE, COOKIE_RFC2109, COOKIE_RFC2965, messages_get(), NSERROR_OK, and cookie_manager_ctx::values.
Referenced by cookie_manager_init().
|
static |
Initialise the treeview entry feilds.
Definition at line 560 of file cookie_manager.c.
References cm_ctx, COOKIE_M_CONTENT, COOKIE_M_DOMAIN, COOKIE_M_DOMAIN_FOLDER, COOKIE_M_EXPIRES, COOKIE_M_LAST_USED, COOKIE_M_N_FIELDS, COOKIE_M_NAME, COOKIE_M_PATH, COOKIE_M_RESTRICTIONS, COOKIE_M_VERSION, treeview_field_desc::field, cookie_manager_ctx::fields, treeview_field_desc::flags, messages_get(), NSERROR_OK, NSERROR_UNKNOWN, TREE_FLAG_DEFAULT, TREE_FLAG_SEARCHABLE, and TREE_FLAG_SHOW_NAME.
Referenced by cookie_manager_init().
bool cookie_manager_keypress | ( | uint32_t | key | ) |
Key press handling.
key | The ucs4 character codepoint |
Definition at line 896 of file cookie_manager.c.
References cm_ctx, cookie_manager_ctx::tree, and treeview_keypress().
Referenced by ami_cookies_key(), atari_cookie_manager_keypress(), cookie_key(), cookie_menu_select(), cookie_toolbar_click(), HOOKF(), MENUHANDLER(), nsgtk_cookies_key(), nsw32_cookie_key(), and ro_gui_window_menu_select().
void cookie_manager_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 889 of file cookie_manager.c.
References cm_ctx, cookie_manager_ctx::tree, and treeview_mouse_action().
Referenced by ami_cookies_mouse(), atari_cookie_manager_mouse_action(), cookie_mouse(), nsgtk_cookies_mouse(), and nsw32_cookie_mouse().
void cookie_manager_redraw | ( | int | x, |
int | y, | ||
struct rect * | clip, | ||
const struct redraw_context * | ctx | ||
) |
Redraw the cookies manager.
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 881 of file cookie_manager.c.
References clip(), cm_ctx, cookie_manager_ctx::tree, and treeview_redraw().
Referenced by ami_cookies_draw(), atari_cookie_manager_draw(), cookie_draw(), nsgtk_cookies_draw(), and nsw32_cookie_draw().
void cookie_manager_remove | ( | const struct cookie_data * | data | ) |
Remove a cookie from viewer.
(Called by urldb.)
data | Data of cookie being removed. |
Definition at line 511 of file cookie_manager.c.
References cm_ctx, cookie_manager_find_entry(), cookie_manager_find_folder(), cookie_manager_entry::data, cookie_manager_entry::entry, NSERROR_OK, parent, cookie_manager_ctx::tree, TREE_OPTION_NONE, and treeview_delete_node().
Referenced by urldb_insert_cookie().
nserror cookie_manager_set_search_string | ( | const char * | string | ) |
Set the cookie manager search string.
string | Sering to set as search string. |
Definition at line 543 of file cookie_manager.c.
References cm_ctx, NSERROR_NOT_FOUND, cookie_manager_ctx::tree, and treeview_set_search_string().
Referenced by ami_cookies_present(), nsgtk_cookies_present(), nsw32_cookies_present(), and ro_gui_cookies_present().
|
static |
Set a cookie manager entry's data from the cookie_data.
e | Cookie manager entry to set up |
data | Data associated with entry's cookie |
Definition at line 273 of file cookie_manager.c.
References cm_ctx, COOKIE_M_CONTENT, COOKIE_M_DOMAIN, COOKIE_M_EXPIRES, COOKIE_M_HTTP, COOKIE_M_HTTPS, COOKIE_M_LAST_USED, COOKIE_M_NAME, COOKIE_M_NETSCAPE, COOKIE_M_NONE, COOKIE_M_PATH, COOKIE_M_RESTRICTIONS, COOKIE_M_RFC2109, COOKIE_M_RFC2965, COOKIE_M_SECURE, COOKIE_M_VERSION, cookie_manager_field_builder(), cookie_manager_field_builder_time(), COOKIE_NETSCAPE, COOKIE_RFC2109, COOKIE_RFC2965, cookie_manager_entry::data, cookie_data::domain, cookie_data::expires, cookie_data::http_only, cookie_data::last_used, messages_get(), cookie_data::name, NSERROR_OK, cookie_data::path, cookie_data::secure, cookie_data::value, cookie_manager_ctx::values, and cookie_data::version.
Referenced by cookie_manager_create_cookie_node(), and cookie_manager_update_cookie_node().
|
static |
Definition at line 762 of file cookie_manager.c.
References cookie_manager_delete_entry(), cookie_manager_entry::data, treeview_node_msg::data, treeview_node_msg::delete, cookie_manager_entry::entry, treeview_node_msg::msg, NSERROR_OK, TREE_MSG_NODE_DELETE, TREE_MSG_NODE_EDIT, TREE_MSG_NODE_LAUNCH, treeview_node_msg::user, and cookie_manager_entry::user_delete.
|
static |
Definition at line 741 of file cookie_manager.c.
References cookie_manager_folder::data, treeview_node_msg::msg, NSERROR_OK, TREE_MSG_NODE_DELETE, TREE_MSG_NODE_EDIT, and TREE_MSG_NODE_LAUNCH.
|
static |
Updates a cookie manager entry for updated cookie_data.
All information is copied from the cookie_data, and as such can be edited and should be freed.
e | the entry to update |
data | the cookie data to use |
Definition at line 393 of file cookie_manager.c.
References cm_ctx, cookie_manager_free_treeview_field_data(), cookie_manager_set_treeview_field_data(), cookie_manager_entry::data, cookie_manager_entry::entry, NSERROR_OK, cookie_manager_ctx::tree, treeview_update_node_entry(), and cookie_manager_entry::user_delete.
Referenced by cookie_manager_add().
|
static |
Callback for treeview_walk.
Definition at line 101 of file cookie_manager.c.
References COOKIE_M_NAME, treeview_walk_ctx::ctx, cookie_manager_entry::entry, treeview_walk_ctx::entry, cookie_manager_folder::folder, treeview_walk_ctx::folder, NSERROR_OK, treeview_walk_ctx::title, treeview_walk_ctx::title_len, TREE_NODE_ENTRY, TREE_NODE_FOLDER, and type.
Referenced by cookie_manager_find_entry(), and cookie_manager_find_folder().
struct cookie_manager_ctx cm_ctx |
Definition at line 83 of file cookie_manager.c.
Referenced by cookie_manager_add(), cookie_manager_contract(), cookie_manager_create_cookie_node(), cookie_manager_create_domain_folder(), cookie_manager_expand(), cookie_manager_field_builder(), cookie_manager_field_builder_time(), cookie_manager_find_entry(), cookie_manager_find_folder(), cookie_manager_fini(), cookie_manager_has_selection(), cookie_manager_init(), cookie_manager_init_common_values(), cookie_manager_init_entry_fields(), cookie_manager_keypress(), cookie_manager_mouse_action(), cookie_manager_redraw(), cookie_manager_remove(), cookie_manager_set_search_string(), cookie_manager_set_treeview_field_data(), and cookie_manager_update_cookie_node().
struct treeview_callback_table cm_tree_cb_t |
Definition at line 784 of file cookie_manager.c.
Referenced by cookie_manager_init().