2003-06-30 16:44:03 +04:00
|
|
|
/*
|
2006-11-27 18:35:18 +03:00
|
|
|
* This file is part of NetSurf, http://netsurf-browser.org/
|
2003-06-30 16:44:03 +04:00
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
2007-01-13 03:21:15 +03:00
|
|
|
* Copyright 2005-2007 James Bursa <bursa@users.sourceforge.net>
|
2003-06-30 16:44:03 +04:00
|
|
|
* Copyright 2003 Philip Pemberton <philpem@users.sourceforge.net>
|
2003-02-09 15:58:15 +03:00
|
|
|
*/
|
|
|
|
|
2003-09-08 01:08:13 +04:00
|
|
|
/** \file
|
|
|
|
* Content handling (interface).
|
|
|
|
*
|
|
|
|
* The content functions manipulate struct contents, which correspond to URLs.
|
|
|
|
*/
|
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
#ifndef _NETSURF_DESKTOP_CONTENT_H_
|
|
|
|
#define _NETSURF_DESKTOP_CONTENT_H_
|
|
|
|
|
2005-08-21 16:04:18 +04:00
|
|
|
#include <stdint.h>
|
2004-01-05 05:10:59 +03:00
|
|
|
#include "netsurf/utils/config.h"
|
2004-01-24 20:08:16 +03:00
|
|
|
#include "netsurf/content/content_type.h"
|
2003-04-04 19:19:32 +04:00
|
|
|
#include "netsurf/css/css.h"
|
2003-09-08 01:08:13 +04:00
|
|
|
#include "netsurf/render/html.h"
|
2006-02-13 02:07:28 +03:00
|
|
|
#include "netsurf/render/textplain.h"
|
2004-03-27 03:54:03 +03:00
|
|
|
#ifdef WITH_JPEG
|
2004-09-04 02:44:48 +04:00
|
|
|
#include "netsurf/image/jpeg.h"
|
2004-03-27 03:54:03 +03:00
|
|
|
#endif
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_GIF
|
2004-10-05 03:54:42 +04:00
|
|
|
#include "netsurf/image/gif.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2006-02-25 21:51:51 +03:00
|
|
|
#ifdef WITH_BMP
|
|
|
|
#include "netsurf/image/bmp.h"
|
2006-02-26 05:25:19 +03:00
|
|
|
#include "netsurf/image/ico.h"
|
2006-02-25 21:51:51 +03:00
|
|
|
#endif
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_PLUGIN
|
2003-09-08 01:08:13 +04:00
|
|
|
#include "netsurf/riscos/plugin.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2004-07-16 23:47:03 +04:00
|
|
|
#ifdef WITH_MNG
|
2004-09-04 02:44:48 +04:00
|
|
|
#include "netsurf/image/mng.h"
|
2004-07-16 23:47:03 +04:00
|
|
|
#endif
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_SPRITE
|
2003-09-11 02:27:15 +04:00
|
|
|
#include "netsurf/riscos/sprite.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_DRAW
|
2003-09-11 02:27:15 +04:00
|
|
|
#include "netsurf/riscos/draw.h"
|
2003-09-08 01:08:13 +04:00
|
|
|
#endif
|
2005-12-10 17:31:33 +03:00
|
|
|
#ifdef WITH_ARTWORKS
|
|
|
|
#include "netsurf/riscos/artworks.h"
|
|
|
|
#endif
|
2003-02-09 15:58:15 +03:00
|
|
|
|
|
|
|
|
2004-09-04 02:44:48 +04:00
|
|
|
struct bitmap;
|
2004-08-11 23:02:32 +04:00
|
|
|
struct box;
|
|
|
|
struct browser_window;
|
2006-02-06 03:10:09 +03:00
|
|
|
struct cache_data;
|
2004-08-11 23:02:32 +04:00
|
|
|
struct content;
|
2004-06-21 19:09:59 +04:00
|
|
|
struct fetch;
|
2004-08-11 23:02:32 +04:00
|
|
|
struct object_params;
|
2006-02-23 18:06:54 +03:00
|
|
|
struct ssl_cert_info;
|
2004-06-21 19:09:59 +04:00
|
|
|
|
|
|
|
|
2003-09-08 01:08:13 +04:00
|
|
|
/** Used in callbacks to indicate what has occurred. */
|
2003-06-17 23:24:21 +04:00
|
|
|
typedef enum {
|
2003-09-08 01:08:13 +04:00
|
|
|
CONTENT_MSG_LOADING, /**< fetching or converting */
|
|
|
|
CONTENT_MSG_READY, /**< may be displayed */
|
|
|
|
CONTENT_MSG_DONE, /**< finished */
|
|
|
|
CONTENT_MSG_ERROR, /**< error occurred */
|
|
|
|
CONTENT_MSG_STATUS, /**< new status string */
|
2003-09-11 01:44:11 +04:00
|
|
|
CONTENT_MSG_REDIRECT, /**< replacement URL */
|
2003-10-25 23:20:13 +04:00
|
|
|
CONTENT_MSG_REFORMAT, /**< content_reformat done */
|
2004-03-21 15:50:10 +03:00
|
|
|
CONTENT_MSG_REDRAW, /**< needs redraw (eg. new animation frame) */
|
2004-08-11 23:02:32 +04:00
|
|
|
CONTENT_MSG_NEWPTR, /**< address of structure has changed */
|
2006-01-25 09:52:38 +03:00
|
|
|
CONTENT_MSG_REFRESH, /**< wants refresh */
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_AUTH
|
2006-02-23 18:06:54 +03:00
|
|
|
CONTENT_MSG_AUTH, /**< authentication required */
|
|
|
|
#endif
|
|
|
|
#ifdef WITH_SSL
|
|
|
|
CONTENT_MSG_SSL /**< SSL cert verify failed */
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2003-06-17 23:24:21 +04:00
|
|
|
} content_msg;
|
|
|
|
|
2004-04-25 03:42:32 +04:00
|
|
|
/** Extra data for some content_msg messages. */
|
|
|
|
union content_msg_data {
|
|
|
|
const char *error; /**< Error message, for CONTENT_MSG_ERROR. */
|
|
|
|
char *redirect; /**< Redirect URL, for CONTENT_MSG_REDIRECT. */
|
|
|
|
/** Area of content which needs redrawing, for CONTENT_MSG_REDRAW. */
|
|
|
|
struct {
|
2004-06-03 00:58:16 +04:00
|
|
|
float x, y, width, height;
|
2004-04-25 03:42:32 +04:00
|
|
|
/** Redraw the area fully. If false, object must be set,
|
|
|
|
* and only the object will be redrawn. */
|
|
|
|
bool full_redraw;
|
|
|
|
/** Object to redraw if full_redraw is false. */
|
|
|
|
struct content *object;
|
|
|
|
/** Coordinates to plot object at. */
|
2004-06-03 00:58:16 +04:00
|
|
|
float object_x, object_y;
|
2004-04-26 17:47:51 +04:00
|
|
|
/** Dimensions to plot object with. */
|
2004-06-03 00:58:16 +04:00
|
|
|
float object_width, object_height;
|
2004-04-25 03:42:32 +04:00
|
|
|
} redraw;
|
2006-02-23 18:06:54 +03:00
|
|
|
const char *auth_realm; /**< Realm, for CONTENT_MSG_AUTH. */
|
2006-01-25 09:52:38 +03:00
|
|
|
int delay; /**< Minimum delay, for CONTENT_MSG_REFRESH */
|
2006-02-23 18:06:54 +03:00
|
|
|
struct {
|
|
|
|
/** Certificate chain (certs[0] == server) */
|
|
|
|
const struct ssl_cert_info *certs;
|
|
|
|
unsigned long num; /**< Number of certs in chain */
|
|
|
|
} ssl;
|
2004-04-25 03:42:32 +04:00
|
|
|
};
|
|
|
|
|
2003-09-08 01:08:13 +04:00
|
|
|
/** Linked list of users of a content. */
|
2003-06-17 23:24:21 +04:00
|
|
|
struct content_user
|
|
|
|
{
|
2005-08-21 16:04:18 +04:00
|
|
|
void (*callback)(content_msg msg, struct content *c, intptr_t p1,
|
|
|
|
intptr_t p2, union content_msg_data data);
|
|
|
|
intptr_t p1;
|
|
|
|
intptr_t p2;
|
2004-06-21 03:09:52 +04:00
|
|
|
bool stop;
|
2003-06-17 23:24:21 +04:00
|
|
|
struct content_user *next;
|
|
|
|
};
|
|
|
|
|
2003-09-08 01:08:13 +04:00
|
|
|
/** Corresponds to a single URL. */
|
|
|
|
struct content {
|
|
|
|
char *url; /**< URL, in standard form as from url_join. */
|
|
|
|
content_type type; /**< Type of content. */
|
|
|
|
char *mime_type; /**< Original MIME type of data, or 0. */
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CONTENT_STATUS_TYPE_UNKNOWN, /**< Type not yet known. */
|
|
|
|
CONTENT_STATUS_LOADING, /**< Content is being fetched or
|
|
|
|
converted and is not safe to display. */
|
|
|
|
CONTENT_STATUS_READY, /**< Some parts of content still being
|
|
|
|
loaded, but can be displayed. */
|
2004-06-11 00:41:26 +04:00
|
|
|
CONTENT_STATUS_DONE, /**< All finished. */
|
|
|
|
CONTENT_STATUS_ERROR /**< Error occurred, content will be
|
|
|
|
destroyed imminently. */
|
2003-09-08 01:08:13 +04:00
|
|
|
} status; /**< Current status. */
|
|
|
|
|
2004-05-21 18:26:59 +04:00
|
|
|
int width, height; /**< Dimensions, if applicable. */
|
|
|
|
int available_width; /**< Available width (eg window width). */
|
2003-09-08 01:08:13 +04:00
|
|
|
|
|
|
|
/** Data dependent on type. */
|
|
|
|
union {
|
|
|
|
struct content_html_data html;
|
2006-02-13 02:07:28 +03:00
|
|
|
struct content_textplain_data textplain;
|
2003-09-08 01:08:13 +04:00
|
|
|
struct content_css_data css;
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_JPEG
|
2003-09-08 01:08:13 +04:00
|
|
|
struct content_jpeg_data jpeg;
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2004-04-25 03:42:32 +04:00
|
|
|
#ifdef WITH_GIF
|
|
|
|
struct content_gif_data gif;
|
|
|
|
#endif
|
2006-02-25 21:51:51 +03:00
|
|
|
#ifdef WITH_BMP
|
|
|
|
struct content_bmp_data bmp;
|
2006-02-26 05:25:19 +03:00
|
|
|
struct content_ico_data ico;
|
2006-02-25 21:51:51 +03:00
|
|
|
#endif
|
2004-07-16 23:47:03 +04:00
|
|
|
#ifdef WITH_MNG
|
|
|
|
struct content_mng_data mng;
|
|
|
|
#endif
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_SPRITE
|
2003-09-11 02:27:15 +04:00
|
|
|
struct content_sprite_data sprite;
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_DRAW
|
2003-09-11 02:27:15 +04:00
|
|
|
struct content_draw_data draw;
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_PLUGIN
|
2003-09-08 01:08:13 +04:00
|
|
|
struct content_plugin_data plugin;
|
2005-12-10 17:31:33 +03:00
|
|
|
#endif
|
|
|
|
#ifdef WITH_ARTWORKS
|
|
|
|
struct content_artworks_data artworks;
|
2003-06-17 23:24:21 +04:00
|
|
|
#endif
|
2003-09-08 01:08:13 +04:00
|
|
|
} data;
|
|
|
|
|
2006-01-25 09:52:38 +03:00
|
|
|
/**< URL for refresh request, in standard form as from url_join. */
|
|
|
|
char *refresh;
|
|
|
|
|
2004-09-04 02:44:48 +04:00
|
|
|
/** Bitmap, for various image contents. */
|
|
|
|
struct bitmap *bitmap;
|
|
|
|
|
2004-06-21 19:09:59 +04:00
|
|
|
/** This content may be given to new users. Indicates that the content
|
|
|
|
* was fetched using a simple GET, has not expired, and may be
|
|
|
|
* shared between users. */
|
|
|
|
bool fresh;
|
2006-02-06 03:10:09 +03:00
|
|
|
struct cache_data *cache_data; /**< Cache control data */
|
2007-01-30 18:32:31 +03:00
|
|
|
unsigned int time; /**< Creation time, if TYPE_UNKNOWN,
|
2007-01-13 03:21:15 +03:00
|
|
|
LOADING or READY,
|
|
|
|
otherwise total time. */
|
2004-06-21 19:09:59 +04:00
|
|
|
|
|
|
|
unsigned int size; /**< Estimated size of all data
|
2006-12-04 01:34:26 +03:00
|
|
|
associated with this content, except
|
|
|
|
alloced as talloc children of this. */
|
2003-09-08 01:08:13 +04:00
|
|
|
char *title; /**< Title for browser window. */
|
|
|
|
unsigned int active; /**< Number of child fetches or
|
|
|
|
conversions currently in progress. */
|
|
|
|
struct content_user *user_list; /**< List of users. */
|
2007-01-13 03:21:15 +03:00
|
|
|
char status_message[120]; /**< Full text for status bar. */
|
|
|
|
char sub_status[80]; /**< Status of content. */
|
2005-07-06 02:43:38 +04:00
|
|
|
/** Content is being processed: data structures may be inconsistent
|
|
|
|
* and content must not be redrawn or modified. */
|
|
|
|
bool locked;
|
2003-09-08 01:08:13 +04:00
|
|
|
|
|
|
|
struct fetch *fetch; /**< Associated fetch, or 0. */
|
2004-03-11 05:19:14 +03:00
|
|
|
char *source_data; /**< Source data, as received. */
|
|
|
|
unsigned long source_size; /**< Amount of data fetched so far. */
|
2005-04-05 06:36:33 +04:00
|
|
|
unsigned long source_allocated; /**< Amount of space allocated so far. */
|
2003-09-08 01:08:13 +04:00
|
|
|
unsigned long total_size; /**< Total data size, 0 if unknown. */
|
2007-01-13 03:21:15 +03:00
|
|
|
long http_code; /**< HTTP status code, 0 if not HTTP. */
|
2004-01-26 17:16:23 +03:00
|
|
|
|
|
|
|
bool no_error_pages; /**< Used by fetchcache(). */
|
2005-01-03 05:09:20 +03:00
|
|
|
bool download; /**< Used by fetchcache(). */
|
2004-06-11 00:41:26 +04:00
|
|
|
|
|
|
|
/** Array of first n rendering errors or warnings. */
|
|
|
|
struct {
|
|
|
|
const char *token;
|
|
|
|
unsigned int line; /**< Line no, 0 if not applicable. */
|
|
|
|
} error_list[40];
|
|
|
|
unsigned int error_count; /**< Number of valid error entries. */
|
|
|
|
|
|
|
|
struct content *prev; /**< Previous in global content list. */
|
|
|
|
struct content *next; /**< Next in global content list. */
|
2003-02-09 15:58:15 +03:00
|
|
|
};
|
|
|
|
|
2004-06-11 00:41:26 +04:00
|
|
|
extern struct content *content_list;
|
|
|
|
extern const char *content_type_name[];
|
|
|
|
extern const char *content_status_name[];
|
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
|
|
|
|
content_type content_lookup(const char *mime_type);
|
2004-06-11 00:41:26 +04:00
|
|
|
struct content * content_create(const char *url);
|
2004-06-21 19:09:59 +04:00
|
|
|
struct content * content_get(const char *url);
|
2006-02-06 03:10:09 +03:00
|
|
|
struct content * content_get_ready(const char *url);
|
2004-06-11 00:41:26 +04:00
|
|
|
bool content_set_type(struct content *c, content_type type,
|
2004-05-05 20:33:15 +04:00
|
|
|
const char *mime_type, const char *params[]);
|
2004-06-05 19:03:59 +04:00
|
|
|
void content_set_status(struct content *c, const char *status_message, ...);
|
2004-06-22 21:37:51 +04:00
|
|
|
bool content_process_data(struct content *c, const char *data,
|
|
|
|
unsigned int size);
|
2004-06-11 00:41:26 +04:00
|
|
|
void content_convert(struct content *c, int width, int height);
|
2007-01-13 03:21:15 +03:00
|
|
|
void content_set_done(struct content *c);
|
2004-06-11 00:41:26 +04:00
|
|
|
void content_reformat(struct content *c, int width, int height);
|
|
|
|
void content_clean(void);
|
2004-01-23 23:46:29 +03:00
|
|
|
void content_reset(struct content *c);
|
2004-07-30 20:16:07 +04:00
|
|
|
void content_quit(void);
|
2004-08-11 20:26:13 +04:00
|
|
|
bool content_redraw(struct content *c, int x, int y,
|
2004-06-11 00:41:26 +04:00
|
|
|
int width, int height,
|
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
2004-08-15 23:06:24 +04:00
|
|
|
float scale, unsigned long background_colour);
|
2006-02-21 23:49:12 +03:00
|
|
|
bool content_redraw_tiled(struct content *c, int x, int y,
|
|
|
|
int width, int height,
|
|
|
|
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
|
|
|
|
float scale, unsigned long background_colour,
|
|
|
|
bool repeat_x, bool repeat_y);
|
2005-01-02 06:58:21 +03:00
|
|
|
bool content_add_user(struct content *c,
|
2005-08-21 16:04:18 +04:00
|
|
|
void (*callback)(content_msg msg, struct content *c,
|
|
|
|
intptr_t p1, intptr_t p2, union content_msg_data data),
|
|
|
|
intptr_t p1, intptr_t p2);
|
2004-06-23 19:41:50 +04:00
|
|
|
struct content_user * content_find_user(struct content *c,
|
2005-08-21 16:04:18 +04:00
|
|
|
void (*callback)(content_msg msg, struct content *c,
|
|
|
|
intptr_t p1, intptr_t p2, union content_msg_data data),
|
|
|
|
intptr_t p1, intptr_t p2);
|
2003-06-17 23:24:21 +04:00
|
|
|
void content_remove_user(struct content *c,
|
2005-08-21 16:04:18 +04:00
|
|
|
void (*callback)(content_msg msg, struct content *c,
|
|
|
|
intptr_t p1, intptr_t p2, union content_msg_data data),
|
|
|
|
intptr_t p1, intptr_t p2);
|
2004-04-25 03:42:32 +04:00
|
|
|
void content_broadcast(struct content *c, content_msg msg,
|
|
|
|
union content_msg_data data);
|
2004-06-21 03:09:52 +04:00
|
|
|
void content_stop(struct content *c,
|
2005-08-21 16:04:18 +04:00
|
|
|
void (*callback)(content_msg msg, struct content *c,
|
|
|
|
intptr_t p1, intptr_t p2, union content_msg_data data),
|
|
|
|
intptr_t p1, intptr_t p2);
|
2004-08-12 02:08:26 +04:00
|
|
|
void content_open(struct content *c, struct browser_window *bw,
|
2005-10-31 00:22:19 +03:00
|
|
|
struct content *page, unsigned int index, struct box *box,
|
2004-08-12 02:08:26 +04:00
|
|
|
struct object_params *params);
|
|
|
|
void content_close(struct content *c);
|
2004-06-11 00:41:26 +04:00
|
|
|
void content_add_error(struct content *c, const char *token,
|
|
|
|
unsigned int line);
|
2003-02-09 15:58:15 +03:00
|
|
|
|
|
|
|
#endif
|