2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
2004-02-25 18:12:58 +03:00
|
|
|
* Copyright 2004 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.
|
|
|
|
*
|
|
|
|
* Each content has a type. The type is used to call a specific implementation
|
|
|
|
* of functions such as content_process_data().
|
|
|
|
*
|
|
|
|
* Contents have an associated set of users, which are informed by a callback
|
|
|
|
* when the state of the content changes or something interesting happens.
|
|
|
|
*
|
|
|
|
* Optionally, contents may have instances (depending on type). Instances
|
|
|
|
* represent copies of the same URL, for example if a page is open in two
|
|
|
|
* windows, or a page contains the same image twice.
|
|
|
|
*/
|
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
#ifndef _NETSURF_DESKTOP_CONTENT_H_
|
|
|
|
#define _NETSURF_DESKTOP_CONTENT_H_
|
|
|
|
|
|
|
|
#include "libxml/HTMLparser.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#include "netsurf/utils/config.h"
|
2003-02-09 15:58:15 +03:00
|
|
|
#include "netsurf/content/cache.h"
|
2004-01-24 20:08:16 +03:00
|
|
|
#include "netsurf/content/content_type.h"
|
2003-06-17 23:24:21 +04:00
|
|
|
#include "netsurf/content/fetch.h"
|
2003-04-04 19:19:32 +04:00
|
|
|
#include "netsurf/css/css.h"
|
2003-02-09 15:58:15 +03:00
|
|
|
#include "netsurf/render/box.h"
|
2003-07-18 03:01:02 +04:00
|
|
|
#include "netsurf/render/font.h"
|
2003-09-08 01:08:13 +04:00
|
|
|
#include "netsurf/render/html.h"
|
2004-03-27 03:54:03 +03:00
|
|
|
#ifdef WITH_JPEG
|
|
|
|
#include "netsurf/riscos/jpeg.h"
|
|
|
|
#endif
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_GIF
|
2003-09-08 01:08:13 +04:00
|
|
|
#include "netsurf/riscos/gif.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
|
|
|
#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
|
|
|
|
#ifdef WITH_PNG
|
2003-09-08 01:08:13 +04:00
|
|
|
#include "netsurf/riscos/png.h"
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
|
|
|
#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
|
2003-02-09 15:58:15 +03: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-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_AUTH
|
2003-10-25 23:20:13 +04:00
|
|
|
CONTENT_MSG_AUTH /**< authentication required */
|
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;
|
|
|
|
char *auth_realm; /**< Realm, for CONTENT_MSG_AUTH. */
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
void (*callback)(content_msg msg, struct content *c, void *p1,
|
2004-04-25 03:42:32 +04:00
|
|
|
void *p2, union content_msg_data data);
|
2003-06-17 23:24:21 +04:00
|
|
|
void *p1;
|
|
|
|
void *p2;
|
|
|
|
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. */
|
|
|
|
CONTENT_STATUS_DONE /**< All finished. */
|
|
|
|
} 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;
|
|
|
|
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
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_PNG
|
2003-09-08 01:08:13 +04:00
|
|
|
struct content_png_data png;
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
|
|
|
#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;
|
2003-06-17 23:24:21 +04:00
|
|
|
#endif
|
2003-09-08 01:08:13 +04:00
|
|
|
} data;
|
|
|
|
|
|
|
|
struct cache_entry *cache; /**< Used by cache, 0 if not cached. */
|
|
|
|
unsigned long size; /**< Estimated size of all data
|
|
|
|
associated with this content. */
|
|
|
|
char *title; /**< Title for browser window. */
|
|
|
|
unsigned int active; /**< Number of child fetches or
|
|
|
|
conversions currently in progress. */
|
|
|
|
int error; /**< Non-0 if an error has occurred. */
|
|
|
|
struct content_user *user_list; /**< List of users. */
|
|
|
|
char status_message[80]; /**< Text for status bar. */
|
|
|
|
|
|
|
|
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. */
|
2003-09-08 01:08:13 +04:00
|
|
|
unsigned long total_size; /**< Total data size, 0 if unknown. */
|
2004-01-26 17:16:23 +03:00
|
|
|
|
|
|
|
int lock; /**< Content in use, do not destroy. */
|
|
|
|
bool destroy_pending; /**< Destroy when lock returns to 0. */
|
|
|
|
bool no_error_pages; /**< Used by fetchcache(). */
|
2003-02-09 15:58:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-07-15 02:57:45 +04:00
|
|
|
struct browser_window;
|
|
|
|
|
|
|
|
|
2003-02-09 15:58:15 +03:00
|
|
|
content_type content_lookup(const char *mime_type);
|
2003-06-17 23:24:21 +04:00
|
|
|
struct content * content_create(char *url);
|
2004-05-05 20:33:15 +04:00
|
|
|
void content_set_type(struct content *c, content_type type,
|
|
|
|
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, ...);
|
2003-02-09 15:58:15 +03:00
|
|
|
void content_process_data(struct content *c, char *data, unsigned long size);
|
2003-06-17 23:24:21 +04:00
|
|
|
void content_convert(struct content *c, unsigned long width, unsigned long height);
|
2003-02-09 15:58:15 +03:00
|
|
|
void content_revive(struct content *c, unsigned long width, unsigned long height);
|
|
|
|
void content_reformat(struct content *c, unsigned long width, unsigned long height);
|
|
|
|
void content_destroy(struct content *c);
|
2004-01-23 23:46:29 +03:00
|
|
|
void content_reset(struct content *c);
|
2003-05-10 15:15:49 +04:00
|
|
|
void content_redraw(struct content *c, long x, long y,
|
2003-09-10 21:10:25 +04:00
|
|
|
unsigned long width, unsigned long height,
|
2004-02-25 18:12:58 +03:00
|
|
|
long clip_x0, long clip_y0, long clip_x1, long clip_y1,
|
|
|
|
float scale);
|
2003-06-17 23:24:21 +04:00
|
|
|
void content_add_user(struct content *c,
|
|
|
|
void (*callback)(content_msg msg, struct content *c, void *p1,
|
2004-04-25 03:42:32 +04:00
|
|
|
void *p2, union content_msg_data data),
|
2003-07-15 02:57:45 +04:00
|
|
|
void *p1, void *p2);
|
2003-06-17 23:24:21 +04:00
|
|
|
void content_remove_user(struct content *c,
|
|
|
|
void (*callback)(content_msg msg, struct content *c, void *p1,
|
2004-04-25 03:42:32 +04:00
|
|
|
void *p2, union content_msg_data data),
|
2003-07-15 02:57:45 +04:00
|
|
|
void *p1, void *p2);
|
2004-04-25 03:42:32 +04:00
|
|
|
void content_broadcast(struct content *c, content_msg msg,
|
|
|
|
union content_msg_data data);
|
2003-07-15 02:57:45 +04:00
|
|
|
void content_add_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state);
|
|
|
|
void content_remove_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state);
|
|
|
|
void content_reshape_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state);
|
2003-02-09 15:58:15 +03:00
|
|
|
|
|
|
|
#endif
|