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;
35struct rect;
36
37/**
38 * Initialise the cookie manager.
39 *
40 * This iterates through the URL database, enumerating the cookies and
41 * creates a treeview.
42 *
43 * This must be called before any other cookie_manager_* function.
44 *
45 * \param cw_t Callback table for core_window containing the treeview
46 * \param core_window_handle The core_window in which the treeview is shown
47 * \return NSERROR_OK on success, appropriate error otherwise
48 */
50 void *core_window_handle);
51
52/**
53 * Finalise the cookie manager.
54 *
55 * This destroys the cookie manager treeview and the cookie manager module's
56 * internal data. After calling this if the cookie manager is required again,
57 * cookie_manager_init must be called.
58 *
59 * \return NSERROR_OK on success, appropriate error otherwise
60 */
62
63/**
64 * Add/update a cookie to the viewer. (Called by urldb.)
65 *
66 * \param data Data of cookie being added/updated.
67 * \return true (for urldb_iterate_entries)
68 */
69bool cookie_manager_add(const struct cookie_data *data);
70
71/**
72 * Remove a cookie from viewer. (Called by urldb.)
73 *
74 * \param data Data of cookie being removed.
75 */
76void cookie_manager_remove(const struct cookie_data *data);
77
78/**
79 * Set the cookie manager search string.
80 *
81 * \param string Sering to set as search string.
82 * \return NSERROR_OK on success, appropriate error otherwise
83 */
85 const char *string);
86
87/**
88 * Redraw the cookies manager.
89 *
90 * \param x X coordinate to render treeview at
91 * \param y Y coordinate to render treeview at
92 * \param clip Current clip rectangle (wrt tree origin)
93 * \param ctx Current redraw context
94 */
95void cookie_manager_redraw(int x, int y, struct rect *clip,
96 const struct redraw_context *ctx);
97
98/**
99 * Handles all kinds of mouse action
100 *
101 * \param mouse The current mouse state
102 * \param x X coordinate
103 * \param y Y coordinate
104 */
105void cookie_manager_mouse_action(enum browser_mouse_state mouse, int x, int y);
106
107/**
108 * Key press handling.
109 *
110 * \param key The ucs4 character codepoint
111 * \return true if the keypress is dealt with, false otherwise.
112 */
113bool cookie_manager_keypress(uint32_t key);
114
115/**
116 * Determine whether there is a selection
117 *
118 * \return true iff there is a selection
119 */
121
122/**
123 * Expand the treeview's nodes
124 *
125 * \param only_folders Iff true, only folders are expanded.
126 * \return NSERROR_OK on success, appropriate error otherwise
127 */
128nserror cookie_manager_expand(bool only_folders);
129
130/**
131 * Contract the treeview's nodes
132 *
133 * \param all Iff false, only entries are contracted.
134 * \return NSERROR_OK on success, appropriate error otherwise
135 */
137
138#endif
nserror cookie_manager_contract(bool all)
Contract the treeview's nodes.
nserror cookie_manager_init(struct core_window_callback_table *cw_t, void *core_window_handle)
Initialise the cookie manager.
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_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
static struct core_window_callback_table cw_t
Declare Core Window Callbacks:
Definition: treeview.c:534
Core mouse and pointer states.
browser_mouse_state
Mouse state.
Definition: mouse.h:43
Callbacks to achieve various core window functionality.
Definition: core_window.h:51
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