NetSurf
cookie_manager.c
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/**
20 * \file
21 * Implementation of Cookie Management
22 *
23 * This allows users to view and remove their web cookies.
24 *
25 * \todo the viewing of cookies is pretty basic and it would be good
26 * to apply more processing of the values and perhaps top level domain
27 * suffix highlighting to give a better user information as to how the
28 * cookies interact with the users sessions.
29 *
30 * \todo In addition to removing cookies it might be useful to allow
31 * users to edit them, especially to alter expiry times.
32 */
33
34
35#include <stdlib.h>
36#include <string.h>
37
38#include "utils/messages.h"
39#include "utils/utils.h"
40#include "utils/log.h"
41#include "content/urldb.h"
42
44#include "desktop/treeview.h"
45
57};
58
70};
71
75};
76
81 bool built;
82};
84
87
89
91};
92
93
95 const char *title;
96 size_t title_len;
99};
100/** Callback for treeview_walk */
101static nserror cookie_manager_walk_cb(void *ctx, void *node_data,
102 enum treeview_node_type type, bool *abort)
103{
104 struct treeview_walk_ctx *tw = ctx;
105
106 if (type == TREE_NODE_ENTRY) {
107 struct cookie_manager_entry *entry = node_data;
108
109 if (entry->data[COOKIE_M_NAME].value_len == tw->title_len &&
110 strcmp(tw->title,
111 entry->data[COOKIE_M_NAME].value) == 0) {
112 /* Found what we're looking for */
113 tw->entry = entry;
114 *abort = true;
115 }
116
117 } else if (type == TREE_NODE_FOLDER) {
118 struct cookie_manager_folder *folder = node_data;
119
120 if (folder->data.value_len == tw->title_len &&
121 strcmp(tw->title, folder->data.value) == 0) {
122 /* Found what we're looking for */
123 tw->folder = folder;
124 *abort = true;
125 }
126 }
127
128 return NSERROR_OK;
129}
130/**
131 * Find a cookie entry in the cookie manager's treeview
132 *
133 * \param root Search root node, or NULL to search from tree's root
134 * \param title ID of the node to look for
135 * \param title_len Byte length of title string
136 * \param found Updated to the matching node's cookie maanger entry
137 * \return NSERROR_OK on success, appropriate error otherwise
138 */
140 const char *title, size_t title_len,
141 struct cookie_manager_entry **found)
142{
143 nserror err;
144 struct treeview_walk_ctx tw = {
145 .title = title,
146 .title_len = title_len,
147 .folder = NULL,
148 .entry = NULL
149 };
150
152 &tw, TREE_NODE_ENTRY);
153 if (err != NSERROR_OK)
154 return err;
155
156 *found = tw.entry;
157
158 return NSERROR_OK;
159}
160/**
161 * Find a cookie domain folder in the cookie manager's treeview
162 *
163 * \param root Search root node, or NULL to search from tree's root
164 * \param title ID of the node to look for
165 * \param title_len Byte length of title string
166 * \param found Updated to the matching node's cookie maanger folder
167 * \return NSERROR_OK on success, appropriate error otherwise
168 */
170 const char *title, size_t title_len,
171 struct cookie_manager_folder **found)
172{
173 nserror err;
174 struct treeview_walk_ctx tw = {
175 .title = title,
176 .title_len = title_len,
177 .folder = NULL,
178 .entry = NULL
179 };
180
182 &tw, TREE_NODE_FOLDER);
183 if (err != NSERROR_OK)
184 return err;
185
186 *found = tw.folder;
187
188 return NSERROR_OK;
189}
190
191
192/**
193 * Free a cookie manager entry's treeview field data.
194 *
195 * \param e Cookie manager entry to free data from
196 */
198 struct cookie_manager_entry *e)
199{
200 /* Eww */
201 free((void *)e->data[COOKIE_M_NAME].value);
202 free((void *)e->data[COOKIE_M_CONTENT].value);
203 free((void *)e->data[COOKIE_M_DOMAIN].value);
204 free((void *)e->data[COOKIE_M_PATH].value);
205 free((void *)e->data[COOKIE_M_EXPIRES].value);
206 free((void *)e->data[COOKIE_M_LAST_USED].value);
207}
208
209
210/**
211 * Build a cookie manager treeview field from given text
212 *
213 * \param field Cookie manager treeview field to build
214 * \param data Cookie manager entry field data to set
215 * \param value Text to set in field, ownership yielded
216 * \return NSERROR_OK on success, appropriate error otherwise
217 */
218static inline nserror
220 struct treeview_field_data *data,
221 const char *value)
222{
223 data->field = cm_ctx.fields[field].field;
224 data->value = value;
225 data->value_len = (value != NULL) ? strlen(value) : 0;
226
227 return NSERROR_OK;
228}
229
230/**
231 * Build a cookie manager treeview field from given time
232 *
233 * The time should be converted to text in the users locacle
234 *
235 * \param field Cookie manager treeview field to build
236 * \param fdata Cookie manager entry field data to set
237 * \param value Time to show in field
238 * \return NSERROR_OK on success, appropriate error otherwise
239 */
240static inline nserror
242 struct treeview_field_data *fdata,
243 const time_t *value)
244{
245 struct tm *ftime;
246
247 fdata->field = cm_ctx.fields[field].field;
248 fdata->value = NULL;
249 fdata->value_len = 0;
250
251 if ((ftime = localtime(value)) != NULL) {
252 const size_t vsize = 256;
253 char *value = malloc(vsize);
254 if (value != NULL) {
255 fdata->value = value;
256 fdata->value_len = strftime(value, vsize,
257 "%a %b %e %H:%M:%S %Y", ftime);
258 }
259 }
260
261 return NSERROR_OK;
262}
263
264
265/**
266 * Set a cookie manager entry's data from the cookie_data.
267 *
268 * \param e Cookie manager entry to set up
269 * \param data Data associated with entry's cookie
270 * \return NSERROR_OK on success, appropriate error otherwise
271 */
272static nserror
274 const struct cookie_data *data)
275{
276 assert(e != NULL);
277 assert(data != NULL);
278
279 /* Set the fields up */
281 &e->data[COOKIE_M_NAME], strdup(data->name));
283 &e->data[COOKIE_M_CONTENT], strdup(data->value));
285 &e->data[COOKIE_M_DOMAIN], strdup(data->domain));
287 &e->data[COOKIE_M_PATH], strdup(data->path));
288
289 /* Set the Expires date field */
290 if (data->expires == -1) {
293 strdup(messages_get("CookieManagerSession")));
294 } else {
296 &e->data[COOKIE_M_EXPIRES], &data->expires);
297 }
298
299 /* Set the Last used date field */
301 &e->data[COOKIE_M_LAST_USED], &data->last_used);
302
303 /* Set the Restrictions text */
304 if (data->secure && data->http_only) {
306 } else if (data->secure) {
308 } else if (data->http_only) {
310 } else {
312 }
313
314 /* Set the Version text */
315 switch (data->version) {
316 case COOKIE_NETSCAPE:
318 break;
319
320 case COOKIE_RFC2109:
322 break;
323
324 case COOKIE_RFC2965:
326 break;
327 }
328
329 return NSERROR_OK;
330}
331
332
333/**
334 * Creates an empty tree entry for a cookie, and links it into the tree.
335 *
336 * All information is copied from the cookie_data, and as such can
337 * be edited and should be freed.
338 *
339 * \param parent the node to link to
340 * \param data the cookie data to use
341 * \return NSERROR_OK on success, appropriate error otherwise
342 */
345 const struct cookie_data *data)
346{
347 nserror err;
348 struct cookie_manager_entry *cookie;
349
350 /* Create new cookie manager entry */
351 cookie = malloc(sizeof(struct cookie_manager_entry));
352 if (cookie == NULL) {
353 return NSERROR_NOMEM;
354 }
355
356 cookie->user_delete = false;
357
359 if (err != NSERROR_OK) {
360 free(cookie);
361 return err;
362 }
363
365 &(cookie->entry),
366 parent->folder,
368 cookie->data,
369 cookie,
373 if (err != NSERROR_OK) {
375 free(cookie);
376 return err;
377 }
378
379 return NSERROR_OK;
380}
381
382
383/**
384 * Updates a cookie manager entry for updated cookie_data.
385 *
386 * All information is copied from the cookie_data, and as such can
387 * be edited and should be freed.
388 *
389 * \param e the entry to update
390 * \param data the cookie data to use
391 * \return NSERROR_OK on success, appropriate error otherwise
392 */
394 struct cookie_manager_entry *e,
395 const struct cookie_data *data)
396{
397 nserror err;
398
399 assert(e != NULL);
400
401 /* Reset to defaults */
402 e->user_delete = false;
404
405 /* Set new field values from the cookie_data */
407 if (err != NSERROR_OK) {
408 return err;
409 }
410
411 /* Update the treeview */
413 if (err != NSERROR_OK) {
414 return err;
415 }
416
417 return NSERROR_OK;
418}
419
420
421/**
422 * Creates an empty tree folder for a cookie domain, and links it into the tree.
423 *
424 * All information is copied from the cookie_data, and as such can
425 * be edited and should be freed.
426 *
427 * \param folder updated to the new folder
428 * \param data the cookie data to use
429 * \return NSERROR_OK on success, appropriate error otherwise
430 */
432 struct cookie_manager_folder **folder,
433 const struct cookie_data *data)
434{
435 nserror err;
436 struct cookie_manager_folder *f;
437
438 /* Create new cookie manager entry */
439 f = malloc(sizeof(struct cookie_manager_folder));
440 if (f == NULL) {
441 return NSERROR_NOMEM;
442 }
443
445 f->data.value = strdup(data->domain);
446 f->data.value_len = (f->data.value != NULL) ?
447 strlen(data->domain) : 0;
448
450 NULL, TREE_REL_FIRST_CHILD, &f->data, f,
454 if (err != NSERROR_OK) {
455 free((void *)f->data.value);
456 free(f);
457 return err;
458 }
459
460 *folder = f;
461
462 return NSERROR_OK;
463}
464
465
466/* exported interface documented in cookie_manager.h */
468{
469 struct cookie_manager_folder *parent = NULL;
470 struct cookie_manager_entry *cookie = NULL;
471 nserror err;
472
473 assert(data != NULL);
474
475 /* If we don't have a cookie manager at the moment, just return true */
476 if (cm_ctx.tree == NULL)
477 return true;
478
479 err = cookie_manager_find_folder(NULL, data->domain,
480 strlen(data->domain), &parent);
481 if (err != NSERROR_OK) {
482 return false;
483 }
484
485 if (parent == NULL) {
486 /* Need to create domain directory */
488 if (err != NSERROR_OK || parent == NULL)
489 return false;
490 }
491
492 /* Create cookie node */
493 err = cookie_manager_find_entry(parent->folder, data->name,
494 strlen(data->name), &cookie);
495 if (err != NSERROR_OK)
496 return false;
497
498 if (cookie == NULL) {
500 } else {
502 }
503 if (err != NSERROR_OK)
504 return false;
505
506 return true;
507}
508
509
510/* exported interface documented in cookie_manager.h */
512{
513 struct cookie_manager_folder *parent = NULL;
514 struct cookie_manager_entry *cookie = NULL;
515 nserror err;
516
517 assert(data != NULL);
518
519 /* If we don't have a cookie manager at the moment, just return */
520 if (cm_ctx.tree == NULL)
521 return;
522
523 err = cookie_manager_find_folder(NULL, data->domain,
524 strlen(data->domain), &parent);
525 if (err != NSERROR_OK || parent == NULL) {
526 /* Nothing to delete */
527 return;
528 }
529
530 err = cookie_manager_find_entry(parent->folder, data->name,
531 strlen(data->name), &cookie);
532 if (err != NSERROR_OK || cookie == NULL) {
533 /* Nothing to delete */
534 return;
535 }
536
537 /* Delete the node */
539}
540
541
542/* exported interface documented in cookie_manager.h */
544 const char *string)
545{
546 /* If we don't have a cookie manager at the moment, just return */
547 if (cm_ctx.tree == NULL) {
548 return NSERROR_NOT_FOUND;
549 }
550
551 return treeview_set_search_string(cm_ctx.tree, string);
552}
553
554
555/**
556 * Initialise the treeview entry feilds
557 *
558 * \return true on success, false on memory exhaustion
559 */
561{
562 int i;
563 const char *label;
564
565 for (i = 0; i < COOKIE_M_N_FIELDS; i++)
566 cm_ctx.fields[i].field = NULL;
567
569 label = "TreeviewLabelName";
570 label = messages_get(label);
571 if (lwc_intern_string(label, strlen(label),
573 lwc_error_ok) {
574 goto error;
575 }
576
578 label = "TreeviewLabelContent";
579 label = messages_get(label);
580 if (lwc_intern_string(label, strlen(label),
582 lwc_error_ok) {
583 goto error;
584 }
585
589 label = "TreeviewLabelDomain";
590 label = messages_get(label);
591 if (lwc_intern_string(label, strlen(label),
593 lwc_error_ok) {
594 goto error;
595 }
596
598 label = "TreeviewLabelPath";
599 label = messages_get(label);
600 if (lwc_intern_string(label, strlen(label),
602 lwc_error_ok) {
603 goto error;
604 }
605
607 label = "TreeviewLabelExpires";
608 label = messages_get(label);
609 if (lwc_intern_string(label, strlen(label),
611 lwc_error_ok) {
612 goto error;
613 }
614
616 label = "TreeviewLabelLastUsed";
617 label = messages_get(label);
618 if (lwc_intern_string(label, strlen(label),
620 lwc_error_ok) {
621 goto error;
622 }
623
625 label = "TreeviewLabelRestrictions";
626 label = messages_get(label);
627 if (lwc_intern_string(label, strlen(label),
629 lwc_error_ok) {
630 goto error;
631 }
632
634 label = "TreeviewLabelVersion";
635 label = messages_get(label);
636 if (lwc_intern_string(label, strlen(label),
638 lwc_error_ok) {
639 goto error;
640 }
641
643 label = "TreeviewLabelDomainFolder";
644 label = messages_get(label);
645 if (lwc_intern_string(label, strlen(label),
647 lwc_error_ok) {
648 return false;
649 }
650
651 return NSERROR_OK;
652
653error:
654 for (i = 0; i < COOKIE_M_N_FIELDS; i++)
655 if (cm_ctx.fields[i].field != NULL)
656 lwc_string_unref(cm_ctx.fields[i].field);
657
658 return NSERROR_UNKNOWN;
659}
660
661
662
663/**
664 * Initialise the common entry values
665 *
666 * \return true on success, false on memory exhaustion
667 */
669{
670 const char *temp;
671
672 /* Set the Restrictions text */
673 temp = messages_get("CookieManagerHTTPS");
675 &cm_ctx.values[COOKIE_M_HTTPS], strdup(temp));
676
677 temp = messages_get("CookieManagerSecure");
679 &cm_ctx.values[COOKIE_M_SECURE], strdup(temp));
680
681 temp = messages_get("CookieManagerHTTP");
683 &cm_ctx.values[COOKIE_M_HTTP], strdup(temp));
684
685 temp = messages_get("None");
687 &cm_ctx.values[COOKIE_M_NONE], strdup(temp));
688
689 /* Set the Cookie version text */
690 assert(COOKIE_NETSCAPE == 0);
691 temp = messages_get("TreeVersion0");
693 &cm_ctx.values[COOKIE_M_NETSCAPE], strdup(temp));
694
695 assert(COOKIE_RFC2109 == 1);
696 temp = messages_get("TreeVersion1");
698 &cm_ctx.values[COOKIE_M_RFC2109], strdup(temp));
699
700 assert(COOKIE_RFC2965 == 2);
701 temp = messages_get("TreeVersion2");
703 &cm_ctx.values[COOKIE_M_RFC2965], strdup(temp));
704
705 return NSERROR_OK;
706}
707
708
709/**
710 * Delete cookie manager entries (and optionally delete from urldb)
711 *
712 * \param e Cookie manager entry to delete.
713 */
715{
716 const char *domain;
717 const char *path;
718 const char *name;
719
720 if (e->user_delete) {
721 /* Delete the cookie from URLdb */
722 domain = e->data[COOKIE_M_DOMAIN].value;
724 name = e->data[COOKIE_M_NAME].value;
725
726 if ((domain != NULL) && (path != NULL) && (name != NULL)) {
727
728 urldb_delete_cookie(domain, path, name);
729 } else {
730 NSLOG(netsurf, INFO,
731 "Delete cookie fail: ""need domain, path, and name.");
732 }
733 }
734
735 /* Delete the cookie manager entry */
737 free(e);
738}
739
740
742 struct treeview_node_msg msg, void *data)
743{
744 struct cookie_manager_folder *f = data;
745
746 switch (msg.msg) {
748 free(f);
749 break;
750
752 break;
753
755 break;
756 }
757
758 return NSERROR_OK;
759}
760
761
763 struct treeview_node_msg msg, void *data)
764{
765 struct cookie_manager_entry *e = data;
766
767 switch (msg.msg) {
769 e->entry = NULL;
770 e->user_delete = msg.data.delete.user;
772 break;
773
775 break;
776
778 break;
779 }
780 return NSERROR_OK;
781}
782
783
787};
788
789
790/* Exported interface, documented in cookie_manager.h */
791nserror cookie_manager_init(void *core_window_handle)
792{
793 nserror err;
794
795 err = treeview_init();
796 if (err != NSERROR_OK) {
797 return err;
798 }
799
800 NSLOG(netsurf, INFO, "Generating cookie manager data");
801
802 /* Init. cookie manager treeview entry fields */
804 if (err != NSERROR_OK) {
805 cm_ctx.tree = NULL;
806 return err;
807 }
808
809 /* Init. common treeview field values */
811 if (err != NSERROR_OK) {
812 cm_ctx.tree = NULL;
813 return err;
814 }
815
816 /* Create the cookie manager treeview */
819 core_window_handle,
823 if (err != NSERROR_OK) {
824 cm_ctx.tree = NULL;
825 return err;
826 }
827
828 /* Load the cookies */
830
831 /* Cookie manager is built
832 * We suppress the treeview height callback on entry insertion before
833 * the treeview is built. */
834 cm_ctx.built = true;
835
836 /* Inform client of window height */
838
839 NSLOG(netsurf, INFO, "Generated cookie manager data");
840
841 return NSERROR_OK;
842}
843
844
845/* Exported interface, documented in cookie_manager.h */
847{
848 int i;
849 nserror err;
850
851 NSLOG(netsurf, INFO, "Finalising cookie manager");
852
853 cm_ctx.built = false;
854
855 /* Destroy the cookie manager treeview */
857 cm_ctx.tree = NULL;
858
859 /* Free cookie manager treeview entry fields */
860 for (i = 0; i < COOKIE_M_N_FIELDS; i++)
861 if (cm_ctx.fields[i].field != NULL)
862 lwc_string_unref(cm_ctx.fields[i].field);
863
864 /* Free cookie manager treeview common entry values */
865 for (i = 0; i < COOKIE_M_N_VALUES; i++)
866 if (cm_ctx.values[i].value != NULL)
867 free((void *) cm_ctx.values[i].value);
868
869 err = treeview_fini();
870 if (err != NSERROR_OK) {
871 return err;
872 }
873
874 NSLOG(netsurf, INFO, "Finalised cookie manager");
875
876 return err;
877}
878
879
880/* Exported interface, documented in cookie_manager.h */
881void cookie_manager_redraw(int x, int y, struct rect *clip,
882 const struct redraw_context *ctx)
883{
884 treeview_redraw(cm_ctx.tree, x, y, clip, ctx);
885}
886
887
888/* Exported interface, documented in cookie_manager.h */
890{
891 treeview_mouse_action(cm_ctx.tree, mouse, x, y);
892}
893
894
895/* Exported interface, documented in cookie_manager.h */
896bool cookie_manager_keypress(uint32_t key)
897{
898 return treeview_keypress(cm_ctx.tree, key);
899}
900
901
902/* Exported interface, documented in cookie_manager.h */
904{
906}
907
908
909/* Exported interface, documented in cookie_manager.h */
911{
912 return treeview_expand(cm_ctx.tree, only_folders);
913}
914
915
916/* Exported interface, documented in cookie_manager.h */
918{
919 return treeview_contract(cm_ctx.tree, all);
920}
921
void urldb_iterate_cookies(bool(*callback)(const struct cookie_data *cookie))
Iterate over all cookies in database.
@ COOKIE_RFC2109
Definition: cookie_db.h:40
@ COOKIE_RFC2965
Definition: cookie_db.h:41
@ COOKIE_NETSCAPE
Definition: cookie_db.h:39
void urldb_delete_cookie(const char *domain, const char *path, const char *name)
Delete a cookie.
Definition: urldb.c:4273
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.
nserror cookie_manager_contract(bool all)
Contract the treeview's nodes.
static nserror cookie_manager_tree_node_folder_cb(struct treeview_node_msg msg, void *data)
nserror cookie_manager_expand(bool only_folders)
Expand the treeview's nodes.
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.
struct cookie_manager_ctx cm_ctx
static nserror cookie_manager_init_entry_fields(void)
Initialise the treeview entry feilds.
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.
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.
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.
static nserror cookie_manager_walk_cb(void *ctx, void *node_data, enum treeview_node_type type, bool *abort)
Callback for treeview_walk.
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.
void cookie_manager_mouse_action(enum browser_mouse_state mouse, int x, int y)
Handles all kinds of mouse action.
cookie_manager_value
@ COOKIE_M_NO
@ COOKIE_M_HTTPS
@ COOKIE_M_N_VALUES
@ COOKIE_M_HTTP
@ COOKIE_M_RFC2965
@ COOKIE_M_SECURE
@ COOKIE_M_NONE
@ COOKIE_M_YES
@ COOKIE_M_RFC2109
@ COOKIE_M_NETSCAPE
static nserror cookie_manager_tree_node_entry_cb(struct treeview_node_msg msg, void *data)
cookie_manager_field
@ COOKIE_M_DOMAIN_FOLDER
@ COOKIE_M_VERSION
@ COOKIE_M_N_FIELDS
@ COOKIE_M_LAST_USED
@ COOKIE_M_RESTRICTIONS
@ COOKIE_M_EXPIRES
@ COOKIE_M_DOMAIN
@ COOKIE_M_CONTENT
@ COOKIE_M_NAME
@ COOKIE_M_PATH
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.
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.
nserror cookie_manager_init(void *core_window_handle)
Initialise the cookie manager.
nserror cookie_manager_fini(void)
Finalise the cookie manager.
static nserror cookie_manager_init_common_values(void)
Initialise the common entry values.
static void cookie_manager_delete_entry(struct cookie_manager_entry *e)
Delete cookie manager entries (and optionally delete from urldb)
struct treeview_callback_table cm_tree_cb_t
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.
static void cookie_manager_free_treeview_field_data(struct cookie_manager_entry *e)
Free a cookie manager entry's treeview field data.
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.
Cookie Manager (interface).
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.
Definition: treeview.c:2022
void treeview_mouse_action(treeview *tree, browser_mouse_state mouse, int x, int y)
Handles all kinds of mouse action.
Definition: treeview.c:4723
nserror treeview_contract(treeview *tree, bool all)
Contract a treeview's nodes.
Definition: treeview.c:2434
nserror treeview_delete_node(treeview *tree, treeview_node *n, treeview_node_options_flags flags)
Delete a treeview node.
Definition: treeview.c:1924
nserror treeview_fini(void)
Finalise the treeview module (all treeviews must have been destroyed first)
Definition: treeview.c:5384
bool treeview_has_selection(treeview *tree)
Determine whether treeview has a selection.
Definition: treeview.c:3326
bool treeview_keypress(treeview *tree, uint32_t key)
Key press handling for treeviews.
Definition: treeview.c:4006
nserror treeview_update_node_entry(treeview *tree, treeview_node *entry, const struct treeview_field_data fields[], void *data)
Update an entry node in given treeview.
Definition: treeview.c:1314
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.
Definition: treeview.c:1198
nserror treeview_destroy(treeview *tree)
Destroy a treeview object.
Definition: treeview.c:2158
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.
Definition: treeview.c:1534
int treeview_get_height(treeview *tree)
Find current height of a treeview.
Definition: treeview.c:4908
void treeview_redraw(treeview *tree, const int x, const int y, struct rect *clip, const struct redraw_context *ctx)
Redraw a treeview object.
Definition: treeview.c:2997
nserror treeview_init(void)
Prepare treeview module for treeview usage.
Definition: treeview.c:5335
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.
Definition: treeview.c:1388
nserror treeview_expand(treeview *tree, bool only_folders)
Expand a treeview's nodes.
Definition: treeview.c:2525
nserror treeview_set_search_string(treeview *tree, const char *string)
Set the search string for a treeview with TREEVIEW_SEARCHABLE.
Definition: treeview.c:4922
Treeview handling interface.
@ TREE_MSG_NODE_EDIT
Node to be edited.
Definition: treeview.h:87
@ TREE_MSG_NODE_LAUNCH
Node to be launched.
Definition: treeview.h:88
@ TREE_MSG_NODE_DELETE
Node to be deleted.
Definition: treeview.h:86
treeview_node_type
treeview node type
Definition: treeview.h:43
@ TREE_NODE_ENTRY
Node is an entry.
Definition: treeview.h:47
@ TREE_NODE_FOLDER
Node is folder.
Definition: treeview.h:46
@ TREE_OPTION_NONE
Definition: treeview.h:64
@ TREE_OPTION_SUPPRESS_RESIZE
Definition: treeview.h:66
@ TREE_OPTION_SUPPRESS_REDRAW
Definition: treeview.h:67
@ TREE_FLAG_SEARCHABLE
Whether field is searchable.
Definition: treeview.h:121
@ TREE_FLAG_SHOW_NAME
Whether field name shown.
Definition: treeview.h:119
@ TREE_FLAG_DEFAULT
Whether field is default.
Definition: treeview.h:118
@ TREE_REL_FIRST_CHILD
Definition: treeview.h:55
@ TREEVIEW_DEL_EMPTY_DIRS
Delete dirs on empty.
Definition: treeview.h:78
@ TREEVIEW_SEARCHABLE
Treeview has search bar.
Definition: treeview.h:79
@ TREEVIEW_NO_MOVES
No node drags.
Definition: treeview.h:75
wimp_w parent
Definition: dialog.c:88
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_NOT_FOUND
Requested item not found.
Definition: errors.h:34
@ NSERROR_UNKNOWN
Unknown error - DO NOT USE.
Definition: errors.h:31
@ NSERROR_NOMEM
Memory exhaustion.
Definition: errors.h:32
@ NSERROR_OK
No error.
Definition: errors.h:30
static struct directory * root
Definition: filename.c:55
const char * type
Definition: filetype.cpp:44
browser_mouse_state
Mouse state.
Definition: mouse.h:43
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Definition: messages.c:241
Localised message support (interface).
Interface to utility string handling.
const char * name
Cookie name.
Definition: cookie_db.h:48
const bool http_only
Only expose to HTTP(S) requests.
Definition: cookie_db.h:59
const time_t last_used
Last used time.
Definition: cookie_db.h:57
const char * domain
Domain.
Definition: cookie_db.h:53
enum cookie_version version
Specification compliance.
Definition: cookie_db.h:60
const bool secure
Only send for HTTPS requests.
Definition: cookie_db.h:58
const char * value
Cookie value.
Definition: cookie_db.h:49
const char * path
Path.
Definition: cookie_db.h:55
const time_t expires
Expiry timestamp, or 1 for session.
Definition: cookie_db.h:56
struct treeview_field_desc fields[COOKIE_M_N_FIELDS]
struct treeview_field_data values[COOKIE_M_N_VALUES]
treeview_node * entry
bool user_delete
struct treeview_field_data data[COOKIE_M_N_FIELDS - 1]
treeview_node * folder
struct treeview_field_data data
Rectangle coordinates.
Definition: types.h:40
Redraw context.
Definition: plotters.h:51
Client callbacks for events concerning nodes.
Definition: treeview.h:147
nserror(* folder)(struct treeview_node_msg msg, void *data)
Definition: treeview.h:148
Treeview field data.
Definition: treeview.h:137
const char * value
Field value.
Definition: treeview.h:139
lwc_string * field
Field name.
Definition: treeview.h:138
size_t value_len
Field value length (bytes)
Definition: treeview.h:140
Treeview field description.
Definition: treeview.h:128
lwc_string * field
A treeview field name.
Definition: treeview.h:129
enum treeview_field_flags flags
Flags for field.
Definition: treeview.h:130
treeview message
Definition: treeview.h:95
bool user
True iff delete by user interaction.
Definition: treeview.h:99
union treeview_node_msg::@94 data
The message data.
struct treeview_node_msg::@94::@95 delete
enum treeview_msg msg
The message type.
Definition: treeview.h:96
Treeview node.
Definition: treeview.c:133
Treewalk iterator context.
struct cookie_manager_folder * folder
struct cookie_manager_entry * entry
const char * title
The treeview context.
Definition: treeview.c:232
Unified URL information database internal 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.
Definition: plot.c:821
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357