Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.  * Copyright 2005-2007 James Bursa <bursa@users.sourceforge.net>
  3.  * Copyright 2003 Philip Pemberton <philpem@users.sourceforge.net>
  4.  *
  5.  * This file is part of NetSurf, http://www.netsurf-browser.org/
  6.  *
  7.  * NetSurf is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation; version 2 of the License.
  10.  *
  11.  * NetSurf is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  */
  19.  
  20. /** \file
  21.  * Content handling (interface).
  22.  *
  23.  * The content functions manipulate struct contents, which correspond to URLs.
  24.  */
  25.  
  26. #ifndef _NETSURF_CONTENT_CONTENT_PROTECTED_H_
  27. #define _NETSURF_CONTENT_CONTENT_PROTECTED_H_
  28.  
  29. #include <stdint.h>
  30. #include <time.h>
  31. #include "utils/config.h"
  32. #include "content/content.h"
  33. #include "content/content_factory.h"
  34. #include "content/llcache.h"
  35. #include "utils/errors.h"
  36.  
  37. struct bitmap;
  38. struct content;
  39. struct rect;
  40. struct redraw_context;
  41.  
  42. struct content_handler {
  43.         void (*fini)(void);
  44.  
  45.         nserror (*create)(const content_handler *handler,
  46.                         lwc_string *imime_type, const http_parameter *params,
  47.                         llcache_handle *llcache,
  48.                         const char *fallback_charset, bool quirks,
  49.                         struct content **c);
  50.  
  51.         bool (*process_data)(struct content *c,
  52.                         const char *data, unsigned int size);
  53.         bool (*data_complete)(struct content *c);
  54.         void (*reformat)(struct content *c, int width, int height);
  55.         void (*destroy)(struct content *c);
  56.         void (*stop)(struct content *c);
  57.         void (*mouse_track)(struct content *c, struct browser_window *bw,
  58.                         browser_mouse_state mouse, int x, int y);
  59.         void (*mouse_action)(struct content *c, struct browser_window *bw,
  60.                         browser_mouse_state mouse, int x, int y);
  61.         bool (*redraw)(struct content *c, struct content_redraw_data *data,
  62.                         const struct rect *clip,
  63.                         const struct redraw_context *ctx);
  64.         void (*open)(struct content *c, struct browser_window *bw,
  65.                         struct content *page, struct object_params *params);
  66.         void (*close)(struct content *c);
  67.         struct selection * (*get_selection)(struct content *c);
  68.         void (*get_contextual_content)(struct content *c, int x, int y,
  69.                         struct contextual_content *data);
  70.         bool (*scroll_at_point)(struct content *c, int x, int y,
  71.                         int scrx, int scry);
  72.         bool (*drop_file_at_point)(struct content *c, int x, int y,
  73.                         char *file);
  74.         void (*debug_dump)(struct content *c, FILE *f);
  75.         nserror (*clone)(const struct content *old, struct content **newc);
  76.         bool (*matches_quirks)(const struct content *c, bool quirks);
  77.         content_type (*type)(void);
  78.  
  79.         /** handler dependant content sensitive internal data interface. */
  80.         void * (*get_internal)(const struct content *c, void *context);
  81.  
  82.         /** There must be one content per user for this type. */
  83.         bool no_share;
  84. };
  85.  
  86. /** Linked list of users of a content. */
  87. struct content_user
  88. {
  89.         void (*callback)(struct content *c, content_msg msg,
  90.                         union content_msg_data data, void *pw);
  91.         void *pw;
  92.  
  93.         struct content_user *next;
  94. };
  95.  
  96. /** Corresponds to a single URL. */
  97. struct content {
  98.         llcache_handle *llcache;        /**< Low-level cache object */
  99.  
  100.         lwc_string *mime_type;  /**< Original MIME type of data */
  101.  
  102.         const content_handler *handler; /**< Handler for content */
  103.  
  104.         content_status status;  /**< Current status. */
  105.  
  106.         int width, height;      /**< Dimensions, if applicable. */
  107.         int available_width;    /**< Available width (eg window width). */
  108.  
  109.         bool quirks;            /**< Content is in quirks mode */
  110.         char *fallback_charset; /**< Fallback charset, or NULL */
  111.  
  112.         nsurl *refresh;         /**< URL for refresh request */
  113.  
  114.         struct content_rfc5988_link *links; /**< list of metadata links */
  115.  
  116.         unsigned int time;              /**< Creation time,
  117.                                           if LOADING or READY,
  118.                                           otherwise total time. */
  119.  
  120.         unsigned int reformat_time;     /**< Earliest time to attempt a
  121.                                           period reflow while fetching a
  122.                                           page's objects. */
  123.  
  124.         unsigned int size;              /**< Estimated size of all data
  125.                                           associated with this content */
  126.         char *title;                    /**< Title for browser window. */
  127.         unsigned int active;            /**< Number of child fetches or
  128.                                           conversions currently in progress. */
  129.         struct content_user *user_list; /**< List of users. */
  130.         char status_message[120];       /**< Full text for status bar. */
  131.         char sub_status[80];            /**< Status of content. */
  132.         /** Content is being processed: data structures may be inconsistent
  133.          * and content must not be redrawn or modified. */
  134.         bool locked;
  135.  
  136.         unsigned long total_size;       /**< Total data size, 0 if unknown. */
  137.         long http_code;                 /**< HTTP status code, 0 if not HTTP. */
  138.  
  139.         /** Array of first n rendering errors or warnings. */
  140.         struct {
  141.                 const char *token;
  142.                 unsigned int line;      /**< Line no, 0 if not applicable. */
  143.         } error_list[40];
  144.         unsigned int error_count;       /**< Number of valid error entries. */
  145. };
  146.  
  147. extern const char * const content_type_name[];
  148. extern const char * const content_status_name[];
  149.  
  150. nserror content__init(struct content *c, const content_handler *handler,
  151.                 lwc_string *imime_type, const http_parameter *params,
  152.                 struct llcache_handle *llcache, const char *fallback_charset,
  153.                 bool quirks);
  154. nserror content__clone(const struct content *c, struct content *nc);
  155.  
  156. void content_set_ready(struct content *c);
  157. void content_set_done(struct content *c);
  158. void content_set_error(struct content *c);
  159.  
  160. void content_set_status(struct content *c, const char *status_message);
  161. void content_broadcast(struct content *c, content_msg msg,
  162.                 union content_msg_data data);
  163. /**
  164.  * Send an errorcode message to all users.
  165.  */
  166. void content_broadcast_errorcode(struct content *c, nserror errorcode);
  167.  
  168. void content_add_error(struct content *c, const char *token,
  169.                 unsigned int line);
  170.  
  171. bool content__add_rfc5988_link(struct content *c,
  172.                 const struct content_rfc5988_link *link);
  173. struct content_rfc5988_link *content__free_rfc5988_link(
  174.                 struct content_rfc5988_link *link);
  175.  
  176. void content__reformat(struct content *c, bool background,
  177.                 int width, int height);
  178. void content__request_redraw(struct content *c,
  179.                 int x, int y, int width, int height);
  180.  
  181. bool content__set_title(struct content *c, const char *title);
  182.  
  183. lwc_string *content__get_mime_type(struct content *c);
  184. const char *content__get_title(struct content *c);
  185. const char *content__get_status_message(struct content *c);
  186. int content__get_width(struct content *c);
  187. int content__get_height(struct content *c);
  188. int content__get_available_width(struct content *c);
  189. const char *content__get_source_data(struct content *c, unsigned long *size);
  190. void content__invalidate_reuse_data(struct content *c);
  191. nsurl *content__get_refresh_url(struct content *c);
  192. struct bitmap *content__get_bitmap(struct content *c);
  193. bool content__get_opaque(struct content *c);
  194.  
  195. bool content__is_locked(struct content *c);
  196.  
  197. #endif
  198.