NetSurf
cookie_manager.h
Go to the documentation of this file.
1/*
2 * Copyright 2013 Michael Drake <tlsa@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/** \file
20 * Cookie Manager (interface).
21 */
22
23#ifndef _NETSURF_DESKTOP_COOKIE_MANAGER_H_
24#define _NETSURF_DESKTOP_COOKIE_MANAGER_H_
25
26#include <stdbool.h>
27#include <stdint.h>
28
29#include "utils/errors.h"
30#include "netsurf/mouse.h"
31
32struct redraw_context;
33struct cookie_data;
34struct rect;
35
36/**
37 * Initialise the cookie manager.
38 *
39 * This iterates through the URL database, enumerating the cookies and
40 * creates a treeview.
41 *
42 * This must be called before any other cookie_manager_* function.
43 *
44 * \param core_window_handle The core_window in which the cookie view is shown
45 * \return NSERROR_OK on success, appropriate error otherwise
46 */
47nserror cookie_manager_init(void *core_window_handle);
48
49/**
50 * Finalise the cookie manager.
51 *
52 * This destroys the cookie manager treeview and the cookie manager module's
53 * internal data. After calling this if the cookie manager is required again,
54 * cookie_manager_init must be called.
55 *
56 * \return NSERROR_OK on success, appropriate error otherwise
57 */
59
60/**
61 * Add/update a cookie to the viewer. (Called by urldb.)
62 *
63 * \param data Data of cookie being added/updated.
64 * \return true (for urldb_iterate_entries)
65 */
66bool cookie_manager_add(const struct cookie_data *data);
67
68/**
69 * Remove a cookie from viewer. (Called by urldb.)
70 *
71 * \param data Data of cookie being removed.
72 */
73void cookie_manager_remove(const struct cookie_data *data);
74
75/**
76 * Set the cookie manager search string.
77 *
78 * \param string Sering to set as search string.
79 * \return NSERROR_OK on success, appropriate error otherwise
80 */
82 const char *string);
83
84/**
85 * Redraw the cookies manager.
86 *
87 * \param x X coordinate to render treeview at
88 * \param y Y coordinate to render treeview at
89 * \param clip Current clip rectangle (wrt tree origin)
90 * \param ctx Current redraw context
91 */
92void cookie_manager_redraw(int x, int y, struct rect *clip,
93 const struct redraw_context *ctx);
94
95/**
96 * Handles all kinds of mouse action
97 *
98 * \param mouse The current mouse state
99 * \param x X coordinate
100 * \param y Y coordinate
101 */
102void cookie_manager_mouse_action(enum browser_mouse_state mouse, int x, int y);
103
104/**
105 * Key press handling.
106 *
107 * \param key The ucs4 character codepoint
108 * \return true if the keypress is dealt with, false otherwise.
109 */
110bool cookie_manager_keypress(uint32_t key);
111
112/**
113 * Determine whether there is a selection
114 *
115 * \return true iff there is a selection
116 */
118
119/**
120 * Expand the treeview's nodes
121 *
122 * \param only_folders Iff true, only folders are expanded.
123 * \return NSERROR_OK on success, appropriate error otherwise
124 */
125nserror cookie_manager_expand(bool only_folders);
126
127/**
128 * Contract the treeview's nodes
129 *
130 * \param all Iff false, only entries are contracted.
131 * \return NSERROR_OK on success, appropriate error otherwise
132 */
134
135#endif
nserror cookie_manager_contract(bool all)
Contract the treeview's nodes.
nserror cookie_manager_expand(bool only_folders)
Expand the treeview's nodes.
void cookie_manager_redraw(int x, int y, struct rect *clip, const struct redraw_context *ctx)
Redraw the cookies manager.
bool cookie_manager_add(const struct cookie_data *data)
Add/update a cookie to the viewer.
bool cookie_manager_has_selection(void)
Determine whether there is a selection.
void cookie_manager_remove(const struct cookie_data *data)
Remove a cookie from viewer.
void cookie_manager_mouse_action(enum browser_mouse_state mouse, int x, int y)
Handles all kinds of mouse action.
nserror cookie_manager_init(void *core_window_handle)
Initialise the cookie manager.
nserror cookie_manager_fini(void)
Finalise the cookie manager.
nserror cookie_manager_set_search_string(const char *string)
Set the cookie manager search string.
bool cookie_manager_keypress(uint32_t key)
Key press handling.
Error codes.
nserror
Enumeration of error codes.
Definition: errors.h:29
Core mouse and pointer states.
browser_mouse_state
Mouse state.
Definition: mouse.h:43
Rectangle coordinates.
Definition: types.h:40
Redraw context.
Definition: plotters.h:51
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357