Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright 2006 John M Bell <jmb202@ecs.soton.ac.uk>
  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.  * Unified URL information database (interface)
  21.  */
  22.  
  23. #ifndef _NETSURF_CONTENT_URLDB_H_
  24. #define _NETSURF_CONTENT_URLDB_H_
  25.  
  26. #include <stdbool.h>
  27. #include <time.h>
  28. #include "content/content.h"
  29. #include "content/content_type.h"
  30. #include "utils/nsurl.h"
  31.  
  32. typedef enum {
  33.         COOKIE_NETSCAPE = 0,
  34.         COOKIE_RFC2109 = 1,
  35.         COOKIE_RFC2965 = 2
  36. } cookie_version;
  37.  
  38. struct url_data {
  39.         const char *title;              /**< Resource title */
  40.         unsigned int visits;            /**< Visit count */
  41.         time_t last_visit;              /**< Last visit time */
  42.         content_type type;              /**< Type of resource */
  43. };
  44.  
  45. struct cookie_data {
  46.         const char *name;               /**< Cookie name */
  47.         const char *value;              /**< Cookie value */
  48.         const bool value_was_quoted;    /**< Value was quoted in Set-Cookie: */
  49.         const char *comment;            /**< Cookie comment */
  50.         const bool domain_from_set;     /**< Domain came from Set-Cookie: header */
  51.         const char *domain;             /**< Domain */
  52.         const bool path_from_set;       /**< Path came from Set-Cookie: header */
  53.         const char *path;               /**< Path */
  54.         const time_t expires;           /**< Expiry timestamp, or 1 for session */
  55.         const time_t last_used;         /**< Last used time */
  56.         const bool secure;              /**< Only send for HTTPS requests */
  57.         const bool http_only;           /**< Only expose to HTTP(S) requests */
  58.         cookie_version version;         /**< Specification compliance */
  59.         const bool no_destroy;          /**< Never destroy this cookie,
  60.                                         * unless it's expired */
  61.  
  62.         const struct cookie_data *prev; /**< Previous in list */
  63.         const struct cookie_data *next; /**< Next in list */
  64. };
  65.  
  66. struct bitmap;
  67.  
  68. /* Destruction */
  69. void urldb_destroy(void);
  70.  
  71. /* Persistence support */
  72. void urldb_load(const char *filename);
  73. void urldb_save(const char *filename);
  74. void urldb_set_url_persistence(nsurl *url, bool persist);
  75.  
  76. /* URL insertion */
  77. bool urldb_add_url(nsurl *url);
  78. struct host_part *urldb_add_host(const char *host);
  79. struct path_data *urldb_add_path(lwc_string *scheme, unsigned int port,
  80.                 const struct host_part *host, char *path_query,
  81.                 lwc_string *fragment, nsurl *url);
  82.  
  83. /* URL data modification / lookup */
  84. void urldb_set_url_title(nsurl *url, const char *title);
  85. void urldb_set_url_content_type(nsurl *url, content_type type);
  86. void urldb_update_url_visit_data(nsurl *url);
  87. void urldb_reset_url_visit_data(nsurl *url);
  88. const struct url_data *urldb_get_url_data(nsurl *url);
  89. nsurl *urldb_get_url(nsurl *url);
  90.  
  91. /* Authentication modification / lookup */
  92. void urldb_set_auth_details(nsurl *url, const char *realm,
  93.                 const char *auth);
  94. const char *urldb_get_auth_details(nsurl *url, const char *realm);
  95.  
  96. /* SSL certificate permissions */
  97. void urldb_set_cert_permissions(nsurl *url, bool permit);
  98. bool urldb_get_cert_permissions(nsurl *url);
  99.  
  100. /* Thumbnail handling */
  101. void urldb_set_thumbnail(nsurl *url, struct bitmap *bitmap);
  102. struct bitmap *urldb_get_thumbnail(nsurl *url);
  103.  
  104. /* URL completion */
  105. void urldb_iterate_partial(const char *prefix,
  106.                 bool (*callback)(nsurl *url,
  107.                 const struct url_data *data));
  108.  
  109. /* Iteration */
  110. void urldb_iterate_entries(bool (*callback)(nsurl *url,
  111.                 const struct url_data *data));
  112. void urldb_iterate_cookies(bool (*callback)(const struct cookie_data *cookie));
  113.  
  114. /* Debug */
  115. void urldb_dump(void);
  116.  
  117. /* Cookies */
  118. bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer);
  119. char *urldb_get_cookie(nsurl *url, bool include_http_only);
  120. void urldb_delete_cookie(const char *domain, const char *path, const char *name);
  121. void urldb_load_cookies(const char *filename);
  122. void urldb_save_cookies(const char *filename);
  123.  
  124. #endif
  125.