summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2008-12-25 10:04:24 -0300
committerJorge Arellano Cid <jcid@dillo.org>2008-12-25 10:04:24 -0300
commitc3aeca579c61983bc96d0177806fc48c28c8b825 (patch)
tree2974e8f5a42627d2b6d190fe3c76f8e2e8e0c57e /src
parent022e339b4417b119cc75fcb2cef057bfce41f8e8 (diff)
parent5486bedf18450ae4de413c4174a0175948c95c3e (diff)
merge
Diffstat (limited to 'src')
-rw-r--r--src/IO/about.c75
-rw-r--r--src/IO/http.c3
-rw-r--r--src/auth.c11
-rw-r--r--src/auth.h2
-rw-r--r--src/dicache.c18
-rw-r--r--src/dicache.h3
-rw-r--r--src/dillo.cc233
-rw-r--r--src/form.cc19
-rw-r--r--src/form.hh3
-rw-r--r--src/html.cc39
-rw-r--r--src/html.hh2
-rw-r--r--src/image.cc3
-rw-r--r--src/image.hh1
-rw-r--r--src/menu.cc65
-rw-r--r--src/menu.hh2
-rw-r--r--src/nav.c7
-rw-r--r--src/png.c138
-rw-r--r--src/prefs.c4
-rw-r--r--src/prefs.h5
-rw-r--r--src/ui.cc3
-rw-r--r--src/uicmd.cc8
-rw-r--r--src/uicmd.hh1
22 files changed, 453 insertions, 192 deletions
diff --git a/src/IO/about.c b/src/IO/about.c
index 4cd5e2c1..03d5057c 100644
--- a/src/IO/about.c
+++ b/src/IO/about.c
@@ -14,7 +14,7 @@
/*
* HTML text for startup screen
*/
-const char *AboutSplash=
+const char *const AboutSplash=
"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n"
"<html>\n"
"<head>\n"
@@ -75,7 +75,7 @@ const char *AboutSplash=
" <tr>\n"
" <td>&nbsp;&nbsp;\n"
" <td>\n"
-" <a href='http://cvs.auriga.wearlab.de/cgi-bin/cvsweb.cgi/dillo2/ChangeLog?rev=HEAD;cvsroot=dillo'>\n"
+" <a href='http://freehg.org/u/dillo/main/file/tip/ChangeLog'>\n"
" ChangeLog</a>\n"
" <tr>\n"
" <td>&nbsp;&nbsp;\n"
@@ -240,22 +240,14 @@ const char *AboutSplash=
"<tr>\n"
" <td bgcolor='#CCCCCC'>\n"
" <h4>Release overview</h4>\n"
-" October 14, 2008\n"
+" ??, 2009\n"
"<tr>\n"
" <td bgcolor='#FFFFFF'>\n"
" <table border='0' cellspacing='0' cellpadding='5'>\n"
" <tr>\n"
" <td>\n"
"<p>\n"
-"This is a rewrite of dillo, using FLTK2, that comes\n"
-"with lots of improvements and fixes.\n"
-"<p>\n"
-"Our users will surely enjoy this new release as it will give them\n"
-"the same things they're accustomed plus tabbed browsing,\n"
-"antialiasing, different\n"
-"character sets, accepting compressed pages, control over image\n"
-"loading, smaller footprint, fewer dependencies, better table\n"
-"rendering, bugfixes, improved GUI, ... In brief, a better dillo.\n"
+"[...]\n"
"<p>\n"
"Remember that dillo project uses a release model where every new\n"
"browser shall be better than the former.\n"
@@ -272,69 +264,20 @@ const char *AboutSplash=
" <td bgcolor='#CCCCCC'>\n"
" <h4>ChangeLog highlights</h4>\n"
" (Extracted from the\n"
-" <a href='http://cvs.auriga.wearlab.de/cgi-bin/cvsweb.cgi/dillo2/ChangeLog?rev=HEAD;cvsroot=dillo'>full\n"
+" <a href='http://freehg.org/u/dillo/main/file/tip/ChangeLog'>full\n"
" ChangeLog</a>)\n"
"<tr>\n"
" <td bgcolor='#FFFFFF'>\n"
" <table border='0' cellspacing='0' cellpadding='5'>\n"
" <tr>\n"
" <td>\n"
+"Dillo:<br>\n"
"<ul>\n"
-"<li>Ported Dillo from GTK1 to FLTK2."
-"<li>Ported a susbstantial part of the code from C to C++ (FLTK2 is in C++)."
-"<li>Wrote a new library: Dlib. With 'Dlib' Dillo doesn't need glib anymore."
-"<li>Ported all the code to Dlib."
-"<li>Made Dillo's UI Control Panel resizable on-the-fly."
-"<li>Implemented a new, simpler, dillorc parser."
-"<li>Reimplemented the Concomitant Callback chains into a uniform scheme!"
-"<li>Removed threads from IO. Now it only uses select-based watches."
-"<li>Simplified http.c by reusing the new non-blocking writes in IO."
-"<li>Implemented Stop button to not only stop rendering but also networking."
-"<li>Bound Ctrl+Space to toggle fullscreen mode."
-"<li>Added a http_referer preference. See details in dillorc."
-"<li>CCC: added reentrancy control to the OpEnd and OpAbort operations."
-"<li>CCC: enhanced the debug function and implemented OpAbort for dpi."
-"<li>Hooked a decoder for text/plain with charset."
-"<li>Forbid dpi GET and POST from non dpi-generated urls."
-"<li>Implemented tabbed browsing."
-"<li>Added a image-loading toggle button to the UI."
-"<li>Added line numbers and enabled wrapping in the 'View Source' window."
-"<li>Added HTTP-1.1's chunked transfer support!"
-"<li>Made the stop button sensitive when loading an image."
-"<li>Added support for 'charset' in the HTTP header field for Content-Type."
-"<li>Added support for 'charset' in the META element."
-"<li>Added the multipart/form-data encoding method to form submission."
-"<li>Made zlib a configure requirement, and cleaned up configure.in."
-"<li>Enabled the file dpi to look inside gzipped files."
-"<li>Added code for optional image loading (nice interface)!"
-"<li>Fixed data guesser to detect ASCII, LATIN1, UTF8, KOI8-R, CP-1251 as"
-" text."
-"<li>Fixed void to int conversions for 64bit-arch."
-"<li>Set the url resolver to escape illegal chars instead of stripping."
-"<li>Big html.cc cleanup. New classes, form API, source split."
-"<li>Added int32_t, EAI_NODATA and iconv tests for FreeBSD."
-"<li>Replaced the findtext dialog with an in-window widget!"
+"<li>[...]"
"</ul>\n"
-"Dw2:<br>\n"
+"Dw:<br>\n"
"<ul>\n"
-"<li>Enabled clipped redraws (avoids some flickering)."
-"<li>Added combination of drawing rectangles into a larger one."
-"<li>Made getWidgetAtPoint() a virtual method of widget and implemented a"
-" custom one for TextBlock, reducing CPU usage on pages full of links."
-"<li>Set FltkViewBase::draw to intersect with view area for expose."
-"<li>Added double buffering for partial redraws!"
-"<li>Reduced memory usage in 30% by reusing styles, reducing the size"
-" of struct Content, and not preallocating in SimpleVector. !"
-"<li>Moved highlighting information from struct Word into Textblock"
-" to save memory."
-"<li>Reduced memory usage 10% with a custom memory handler in Textblock."
-"<li>Implemented selection of multibyte glyphs (UTF-8)."
-"<li>Fixed a slithery BUG in lout::misc::Stringbuffer."
-"<li>Added 'enter' and 'leave' signals into class Resource."
-"<li>Enabled mouse wheel scrolling."
-"<li>Added setDeleteCallback(DW_Callback_t func, void *data) to widget."
-" This allows to hook a callback when the widget is destroyed."
-"<li>Changed the table-apportion algorithms + bug fixes. Big work!"
+"<li>[...]"
"</ul>\n"
" </table>\n"
"</table>\n"
diff --git a/src/IO/http.c b/src/IO/http.c
index 9deb961a..328a8601 100644
--- a/src/IO/http.c
+++ b/src/IO/http.c
@@ -197,7 +197,8 @@ Dstr *Http_make_content_type(const DilloUrl *url)
*/
Dstr *a_Http_make_query_str(const DilloUrl *url, bool_t use_proxy)
{
- char *ptr, *cookies, *auth, *referer;
+ const char *auth;
+ char *ptr, *cookies, *referer;
Dstr *query = dStr_new(""),
*full_path = dStr_new(""),
*proxy_auth = dStr_new("");
diff --git a/src/auth.c b/src/auth.c
index 81e97188..ad77b3b4 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -295,21 +295,20 @@ static AuthRealm_t *Auth_realm_by_path(const AuthHost_t *host,
int i, j;
int match_length;
+ match_length = 0;
realm_best = NULL;
for (i = 0; (realm = dList_nth_data(host->realms, i)); i++) {
char *realm_path;
for (j = 0; (realm_path = dList_nth_data(realm->paths, j)); j++) {
- int realm_path_length;
-
- realm_path_length = strlen(realm_path);
+ int realm_path_length = strlen(realm_path);
if (Auth_path_is_inside(path, realm_path, realm_path_length) &&
!(realm_best && match_length >= realm_path_length)) {
realm_best = realm;
match_length = realm_path_length;
}
- } /* for (j = 0; (path = ... */
- } /* for (i = 0; (realm = ... */
+ }
+ }
return realm_best;
}
@@ -353,7 +352,7 @@ static void Auth_realm_add_path(AuthRealm_t *realm, const char *path)
/*
* Return the authorization header for an HTTP query.
*/
-char *a_Auth_get_auth_str(const DilloUrl *url)
+const char *a_Auth_get_auth_str(const DilloUrl *url)
{
AuthHost_t *host;
AuthRealm_t *realm;
diff --git a/src/auth.h b/src/auth.h
index 8813fc37..5f96f642 100644
--- a/src/auth.h
+++ b/src/auth.h
@@ -8,7 +8,7 @@ extern "C" {
#include "url.h"
-char *a_Auth_get_auth_str(const DilloUrl *request_url);
+const char *a_Auth_get_auth_str(const DilloUrl *request_url);
int a_Auth_do_auth(Dlist *auth_string, const DilloUrl *url);
void a_Auth_init(void);
diff --git a/src/dicache.c b/src/dicache.c
index 97ed1915..fb1a0c8c 100644
--- a/src/dicache.c
+++ b/src/dicache.c
@@ -33,9 +33,9 @@ struct _DICacheNode {
*/
static Dlist *CachedIMGs = NULL;
-static int dicache_size_total; /* invariant: dicache_size_total is
- * the sum of the image sizes (3*w*h)
- * of all the images in the dicache. */
+static uint_t dicache_size_total; /* invariant: dicache_size_total is
+ * the sum of the image sizes (3*w*h)
+ * of all the images in the dicache. */
/*
* Compare two dicache nodes
@@ -87,6 +87,7 @@ static DICacheEntry *Dicache_entry_new(void)
entry->BitVec = NULL;
entry->State = DIC_Empty;
entry->version = 0;
+
entry->next = NULL;
return entry;
@@ -223,7 +224,6 @@ void a_Dicache_unref(const DilloUrl *Url, int version)
/*
* Refs the counter of a dicache entry.
*/
-
DICacheEntry* a_Dicache_ref(const DilloUrl *Url, int version)
{
DICacheEntry *entry;
@@ -255,7 +255,6 @@ void a_Dicache_invalidate_entry(const DilloUrl *Url)
*/
void a_Dicache_callback(int Op, CacheClient_t *Client)
{
- /* TODO: Handle Op = CA_Abort (to show what was got) --Jcid */
uint_t i;
DilloWeb *Web = Client->Web;
DilloImage *Image = Web->Image;
@@ -294,7 +293,7 @@ void a_Dicache_callback(int Op, CacheClient_t *Client)
}
}
} else if (Op == CA_Close || Op == CA_Abort) {
- a_Image_close(Web->Image);
+ a_Image_close(Image);
a_Bw_close_client(Web->bw, Client->Key);
}
}
@@ -309,12 +308,13 @@ void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image,
uint_t width, uint_t height, DilloImgType type)
{
DICacheEntry *DicEntry;
- size_t Size = width * height * 3;
dReturn_if_fail ( Image != NULL && width && height );
/* Find the DicEntry for this Image */
DicEntry = Dicache_get_entry_version(url, version);
dReturn_if_fail ( DicEntry != NULL );
+ /* Parameters already set? */
+ dReturn_if_fail ( DicEntry->State < DIC_SetParms );
/* Initialize the DicEntry */
DicEntry->linebuf = dNew(uchar_t, width * 3);
@@ -328,14 +328,14 @@ void a_Dicache_set_parms(DilloUrl *url, int version, DilloImage *Image,
* Extra code is necessary in Imgbuf to be able to free it */
//a_Image_imgbuf_ref(DicEntry->v_imgbuf);
- DicEntry->TotalSize = Size;
+ DicEntry->TotalSize = width * height * 3;
DicEntry->width = width;
DicEntry->height = height;
DicEntry->type = type;
DicEntry->BitVec = a_Bitvec_new((int)height);
DicEntry->State = DIC_SetParms;
- dicache_size_total += Size;
+ dicache_size_total += DicEntry->TotalSize;
/* Allocate and initialize this image */
a_Image_set_parms(Image, DicEntry->v_imgbuf, url, version,
diff --git a/src/dicache.h b/src/dicache.h
index 6cbcf3a5..c78d0953 100644
--- a/src/dicache.h
+++ b/src/dicache.h
@@ -29,7 +29,7 @@ struct _DICacheEntry {
uchar_t *cmap; /* Color map */
uchar_t *linebuf; /* Decompressed RGB buffer for one line */
void *v_imgbuf; /* Void pointer to an Imgbuf object */
- size_t TotalSize; /* Amount of memory the image takes up */
+ uint_t TotalSize; /* Amount of memory the image takes up */
int Y; /* Current decoding row */
uint_t ScanNumber; /* Current decoding scan */
bitvec_t *BitVec; /* Bit vector for decoded rows */
@@ -37,7 +37,6 @@ struct _DICacheEntry {
int RefCount; /* Reference Counter */
int version; /* Version number, used for different
versions of the same URL image */
-
DICacheEntry *next; /* Link to the next "newer" version */
};
diff --git a/src/dillo.cc b/src/dillo.cc
index 10430f29..86b1ffa1 100644
--- a/src/dillo.cc
+++ b/src/dillo.cc
@@ -47,15 +47,135 @@
#include "cookies.h"
#include "auth.h"
+/*
+ * Command line options structure
+ */
+typedef enum {
+ DILLO_CLI_NONE = 0,
+ DILLO_CLI_XID = 1 << 0,
+ DILLO_CLI_FULLWINDOW = 1 << 1,
+ DILLO_CLI_HELP = 1 << 2,
+ DILLO_CLI_VERSION = 1 << 3,
+ DILLO_CLI_LOCAL = 1 << 4,
+ DILLO_CLI_GEOMETRY = 1 << 5,
+ DILLO_CLI_ERROR = 1 << 15,
+} OptID;
+
+typedef struct {
+ const char *shortopt;
+ const char *longopt;
+ int opt_argc; /* positive: mandatory, negative: optional */
+ OptID id;
+ const char *help;
+} CLI_options;
+
+static const CLI_options Options[] = {
+ {"-f", "--fullwindow", 0, DILLO_CLI_FULLWINDOW,
+ " -f, --fullwindow Start in full window mode: hide address bar,\n"
+ " navigation buttons, menu, and status bar."},
+ {"-g", "-geometry", 1, DILLO_CLI_GEOMETRY,
+ " -g, -geometry GEO Set initial window position where GEO is\n"
+ " WxH[{+-}X{+-}Y]"},
+ {"-h", "--help", 0, DILLO_CLI_HELP,
+ " -h, --help Display this help text and exit."},
+ {"-l", "--local", 0, DILLO_CLI_LOCAL,
+ " -l, --local Don't load images for these URL(s)."},
+ {"-v", "--version", 0, DILLO_CLI_VERSION,
+ " -v, --version Display version info and exit."},
+ {"-x", "--xid", 1, DILLO_CLI_XID,
+ " -x, --xid XID (DOES NOT WORK YET)\n"
+ " Open first Dillo window in an existing\n"
+ " GtkSocket which window ID is XID (decimal)."},
+ {NULL, NULL, 0, DILLO_CLI_NONE, NULL}
+};
+
+/*
+ * Print help text generated from the options structure
+ */
+static void Dillo_print_help(const char *cmdname, const CLI_options *options)
+{
+ printf("Usage: %s [OPTION]... [--] [URL|FILE]...\n"
+ "Options:\n", cmdname);
+ while(options && options->help) {
+ printf("%s\n", options->help);
+ options++;
+ }
+ printf(" URL URL to browse.\n"
+ " FILE Local FILE to view.\n"
+ "\n");
+}
+
+/*
+ * Return the maximum number of option arguments
+ */
+static int Dillo_get_max_opt(const CLI_options *options)
+{
+ int i, max;
+
+ for (i = 0, max = 0; options[i].shortopt; i++)
+ if (abs(options[i].opt_argc) > max)
+ max = abs(options[i].opt_argc);
+ return max;
+}
+
+/*
+ * Get next command line option.
+ */
+static OptID Dillo_get_opt(const CLI_options *options, int argc, char **argv,
+ char **opt_argv, int *idx)
+{
+ typedef enum { O_SEARCH, O_FOUND, O_NOTFOUND, O_DONE } State;
+ OptID opt_id = DILLO_CLI_NONE;
+ int i = 0;
+ State state = O_SEARCH;
+
+ if (*idx >= argc) {
+ state = O_DONE;
+ } else {
+ state = O_NOTFOUND;
+ for (i = 0; options[i].shortopt; i++) {
+ if (strcmp(options[i].shortopt, argv[*idx]) == 0 ||
+ strcmp(options[i].longopt, argv[*idx]) == 0) {
+ state = O_FOUND;
+ ++*idx;
+ break;
+ }
+ }
+ }
+ if (state == O_FOUND) {
+ int n_arg = options[i].opt_argc;
+ opt_id = options[i].id;
+ /* Find the required/optional arguments of the option */
+ for (i = 0; *idx < argc && i < abs(n_arg) && argv[*idx][0] != '-'; i++)
+ opt_argv[i] = argv[(*idx)++];
+ opt_argv[i] = NULL;
+
+ /* Optional arguments have opt_argc < 0 */
+ if (i < n_arg) {
+ fprintf(stderr, "Option %s requires %d argument%s\n",
+ argv[*idx-i-1], n_arg, (n_arg == 1) ? "" : "s");
+ opt_id = DILLO_CLI_ERROR;
+ }
+ }
+ if (state == O_NOTFOUND) {
+ if (strcmp(argv[*idx], "--") == 0)
+ (*idx)++;
+ else if (argv[*idx][0] == '-') {
+ fprintf(stderr, "Command line option \"%s\" not recognized.\n",
+ argv[*idx]);
+ opt_id = DILLO_CLI_ERROR;
+ }
+ }
+ return opt_id;
+}
/*
* Given a command line argument, build a DilloUrl for it.
*/
-static DilloUrl *Dillo_make_start_url(char *str)
+static DilloUrl *Dillo_make_start_url(char *str, bool local)
{
char *url_str, *p;
DilloUrl *start_url;
- int is_file = FALSE;
/* Relative path to a local file? */
p = (*str == '/') ? dStrdup(str) : dStrconcat(a_Dir_get_owd(),"/",str,NULL);
@@ -63,20 +183,18 @@ static DilloUrl *Dillo_make_start_url(char *str)
if (access(p, F_OK) == 0) {
/* absolute path may have non-URL characters */
url_str = a_Misc_escape_chars(p, "% ");
- is_file = TRUE;
+ start_url = a_Url_new(url_str + 1, "file:/");
} else {
/* Not a file, filter URL string */
url_str = a_Url_string_strip_delimiters(str);
- }
- dFree(p);
-
- if (is_file) {
- start_url = a_Url_new(url_str + 1, "file:/");
- } else {
start_url = a_Url_new(url_str, NULL);
}
+ dFree(p);
dFree(url_str);
+ if (local)
+ a_Url_set_flags(start_url, URL_FLAGS(start_url) | URL_SpamSafe);
+
return start_url;
}
@@ -85,11 +203,58 @@ static DilloUrl *Dillo_make_start_url(char *str)
*/
int main(int argc, char **argv)
{
+ uint opt_id;
+ uint options_got = 0;
+ uint32_t xid = 0;
+ int idx = 1;
+ int xpos = D_GEOMETRY_DEFAULT_XPOS, ypos = D_GEOMETRY_DEFAULT_YPOS;
+ int width = D_GEOMETRY_DEFAULT_WIDTH, height = D_GEOMETRY_DEFAULT_HEIGHT;
+ char **opt_argv;
+
srand((uint_t)(time(0) ^ getpid()));
// Some OSes exit dillo without this (not GNU/Linux).
signal(SIGPIPE, SIG_IGN);
+ /* Handle command line options */
+ opt_argv = dNew0(char*, Dillo_get_max_opt(Options) + 1);
+ while ((opt_id = Dillo_get_opt(Options, argc, argv, opt_argv, &idx))) {
+ options_got |= opt_id;
+ switch (opt_id) {
+ case DILLO_CLI_FULLWINDOW:
+ case DILLO_CLI_LOCAL:
+ break;
+ case DILLO_CLI_XID:
+ {
+ char *end;
+ xid = strtol(opt_argv[0], &end, 10);
+ if (*end) {
+ fprintf(stderr, "XID argument \"%s\" not valid. Must be an "
+ "unsigned decimal number.\n",opt_argv[0]);
+ return -1;
+ }
+ break;
+ }
+ case DILLO_CLI_GEOMETRY:
+ if (!a_Misc_parse_geometry(opt_argv[0], &xpos, &ypos,&width,&height)){
+ fprintf(stderr, "geometry argument \"%s\" not valid. Must be of "
+ "the form WxH[{+-}X{+-}Y].\n", opt_argv[0]);
+ return -1;
+ }
+ break;
+ case DILLO_CLI_VERSION:
+ puts("Dillo version " VERSION);
+ return 0;
+ case DILLO_CLI_HELP:
+ Dillo_print_help(argv[0], Options);
+ return 0;
+ default:
+ Dillo_print_help(argv[0], Options);
+ return -1;
+ }
+ }
+ dFree(opt_argv);
+
// Initialize internal modules
a_Dir_init();
a_Prefs_init();
@@ -105,12 +270,23 @@ int main(int argc, char **argv)
a_Cookies_init();
a_Auth_init();
+ /* command line options override preferences */
+ if (options_got & DILLO_CLI_FULLWINDOW)
+ prefs.fullwindow_start = TRUE;
+ if (options_got & DILLO_CLI_GEOMETRY) {
+ prefs.width = width;
+ prefs.height = height;
+ prefs.xpos = xpos;
+ prefs.ypos = ypos;
+ }
+
// Sets WM_CLASS hint on X11
fltk::Window::xclass("dillo");
// WORKAROUND: sometimes the default pager triggers redraw storms
fltk::TabGroup::default_pager(fltk::PAGER_SHRINK);
+ /* use preferred font for UI */
fltk::Font *dfont = fltk::font(prefs.vw_fontname, 0);
if (dfont) {
fltk::Widget::default_style->textfont(dfont);
@@ -120,6 +296,7 @@ int main(int argc, char **argv)
// Create a new UI/bw pair
BrowserWindow *bw = a_UIcmd_browser_window_new(0, 0, NULL);
+ /* Proxy authentication */
if (prefs.http_proxyuser && !a_Http_proxy_auth()) {
const char *passwd = a_UIcmd_get_passwd(prefs.http_proxyuser);
if (passwd) {
@@ -129,23 +306,29 @@ int main(int argc, char **argv)
}
}
- if (argc == 2) {
- DilloUrl *url = Dillo_make_start_url(argv[1]);
- a_UIcmd_open_urlstr(bw, URL_STR(url));
- a_Url_free(url);
- } else if (argc == 6) {
- // WORKAROUND: sylpheed execs "dillo -l -f -x XID URL"
- if (strcmp(argv[1], "-l") == 0 && strcmp(argv[2], "-f") == 0 &&
- strcmp(argv[3], "-x") == 0) {
- a_UIcmd_set_images_enabled(bw, FALSE);
- DilloUrl *url = Dillo_make_start_url(argv[5]);
- a_Url_set_flags(url, URL_FLAGS(url) & URL_SpamSafe);
- a_UIcmd_open_urlstr(bw, URL_STR(url));
- a_Url_free(url);
- }
- } else {
- /* Send startup screen */
+ /* Open URLs/files */
+ const bool local = options_got & DILLO_CLI_LOCAL;
+
+ if (idx == argc) {
+ /* No URLs/files on cmdline. Send startup screen */
a_Nav_push(bw, prefs.start_page);
+ } else {
+ for (int i = idx; i < argc; i++) {
+ DilloUrl *start_url = Dillo_make_start_url(argv[i], local);
+
+ if (i > idx) {
+ if (prefs.middle_click_opens_new_tab) {
+ /* user must prefer tabs */
+ const int focus = 0;
+ a_UIcmd_open_url_nt(bw, start_url, focus);
+ } else {
+ a_UIcmd_open_url_nw(bw, start_url);
+ }
+ } else {
+ a_Nav_push(bw, start_url);
+ }
+ a_Url_free(start_url);
+ }
}
return fltk::run();
diff --git a/src/form.cc b/src/form.cc
index 339150bb..c442c017 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -76,7 +76,6 @@ class DilloHtmlForm {
DilloHtml *html;
void eventHandler(Resource *resource, EventButton *event);
- void submit(DilloHtmlInput *active_input, EventButton *event);
DilloUrl *buildQueryUrl(DilloHtmlInput *active_input);
Dstr *buildQueryData(DilloHtmlInput *active_submit);
char *makeMultipartBoundary(iconv_t char_encoder,
@@ -113,6 +112,7 @@ public:
~DilloHtmlForm ();
DilloHtmlInput *getInput (Resource *resource);
DilloHtmlInput *getRadioInput (const char *name);
+ void submit(DilloHtmlInput *active_input, EventButton *event);
void reset ();
void addInput(DilloHtmlInput *input, DilloHtmlInputType type);
};
@@ -206,6 +206,16 @@ void a_Html_input_delete (DilloHtmlInput *input)
delete input;
}
+void a_Html_form_submit2(void *vform)
+{
+ ((DilloHtmlForm *)vform)->submit(NULL, NULL);
+}
+
+void a_Html_form_reset2(void *vform)
+{
+ ((DilloHtmlForm *)vform)->reset();
+}
+
/*
* Form parsing functions
*/
@@ -332,7 +342,7 @@ void Html_tag_open_form(DilloHtml *html, const char *tag, int tagsize)
void Html_tag_close_form(DilloHtml *html, int TagIdx)
{
- static const char *SubmitTag =
+ static const char *const SubmitTag =
"<input type='submit' value='?Submit?' alt='dillo-generated-button'>";
DilloHtmlForm *form;
// int i;
@@ -945,7 +955,7 @@ void DilloHtmlForm::eventHandler(Resource *resource, EventButton *event)
{
MSG("DilloHtmlForm::eventHandler\n");
if (event && (event->button == 3)) {
- MSG("Form menu\n");
+ a_UIcmd_form_popup(html->bw, html->page_url, this);
} else {
DilloHtmlInput *input = getInput(resource);
if (input) {
@@ -996,7 +1006,7 @@ DilloUrl *DilloHtmlForm::buildQueryUrl(DilloHtmlInput *active_input)
_MSG("DilloHtmlForm::buildQueryUrl: action=%s\n",URL_STR_(action));
- if (num_submit_buttons > 0) {
+ if (active_input && num_submit_buttons > 0) {
if ((active_input->type == DILLO_HTML_INPUT_SUBMIT) ||
(active_input->type == DILLO_HTML_INPUT_IMAGE) ||
(active_input->type == DILLO_HTML_INPUT_BUTTON_SUBMIT)) {
@@ -1727,6 +1737,7 @@ void DilloHtmlInput::reset ()
switch (type) {
case DILLO_HTML_INPUT_TEXT:
case DILLO_HTML_INPUT_PASSWORD:
+ case DILLO_HTML_INPUT_INDEX:
{
EntryResource *entryres = (EntryResource*)embed->getResource();
entryres->setText(init_str ? init_str : "");
diff --git a/src/form.hh b/src/form.hh
index 36616466..910efe20 100644
--- a/src/form.hh
+++ b/src/form.hh
@@ -38,6 +38,9 @@ DilloHtmlForm *a_Html_form_new(DilloHtml *html,
void a_Html_form_delete(DilloHtmlForm* form);
void a_Html_input_delete(DilloHtmlInput* input);
+void a_Html_form_submit2(void *v_form);
+void a_Html_form_reset2(void *v_form);
+
/*
* Form parsing functions
diff --git a/src/html.cc b/src/html.cc
index 772c0bb1..a03cc38d 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -215,6 +215,45 @@ void a_Html_load_images(void *v_html, DilloUrl *pattern)
}
/*
+ * Search for form
+ */
+static bool Html_contains_form(DilloHtml *html, void *v_form)
+{
+ for (int i = 0; i < html->forms->size(); i++) {
+ if (html->forms->get(i) == v_form) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/*
+ * Used by the "Submit form" form menuitem.
+ */
+void a_Html_form_submit(void *v_html, void *v_form)
+{
+ DilloHtml *html = (DilloHtml*)v_html;
+
+ if (Html_contains_form(html, v_form)) {
+ /* it's still valid */
+ a_Html_form_submit2(v_form);
+ }
+}
+
+/*
+ * Used by the "Reset form" form menuitem.
+ */
+void a_Html_form_reset(void *v_html, void *v_form)
+{
+ DilloHtml *html = (DilloHtml*)v_html;
+
+ if (Html_contains_form(html, v_form)) {
+ /* it's still valid */
+ a_Html_form_reset2(v_form);
+ }
+}
+
+/*
* Set the URL data for image maps.
*/
static void Html_set_link_coordinates(DilloHtml *html, int link, int x, int y)
diff --git a/src/html.hh b/src/html.hh
index 3e08f37a..b742261c 100644
--- a/src/html.hh
+++ b/src/html.hh
@@ -11,6 +11,8 @@ extern "C" {
* Exported functions
*/
void a_Html_load_images(void *v_html, DilloUrl *pattern);
+void a_Html_form_submit(void *v_html, void *v_form);
+void a_Html_form_reset(void *v_html, void *v_form);
#ifdef __cplusplus
}
diff --git a/src/image.cc b/src/image.cc
index 54eb4710..462ec90c 100644
--- a/src/image.cc
+++ b/src/image.cc
@@ -54,7 +54,6 @@ DilloImage *a_Image_new(int width,
Image->cmap = NULL;
Image->in_type = DILLO_IMG_TYPE_NOTSET;
Image->bg_color = bg_color;
- Image->ProcessedBytes = 0;
Image->ScanNumber = 0;
Image->BitVec = NULL;
Image->State = IMG_Empty;
@@ -172,7 +171,7 @@ void a_Image_new_scan(DilloImage *Image, void *v_imgbuf)
void a_Image_write(DilloImage *Image, void *v_imgbuf,
const uchar_t *buf, uint_t y, int decode)
{
- uchar_t *newbuf;
+ const uchar_t *newbuf;
dReturn_if_fail ( y < Image->height );
diff --git a/src/image.hh b/src/image.hh
index 73b0e5e7..ce906c74 100644
--- a/src/image.hh
+++ b/src/image.hh
@@ -42,7 +42,6 @@ struct _DilloImage {
DilloImgType in_type; /* Image Type */
int32_t bg_color; /* Background color */
- int ProcessedBytes; /* Amount of bytes already decoded */
bitvec_t *BitVec; /* Bit vector for decoded rows */
uint_t ScanNumber; /* Current decoding scan */
ImageState State; /* Processing status */
diff --git a/src/menu.cc b/src/menu.cc
index ac23117d..54babc0b 100644
--- a/src/menu.cc
+++ b/src/menu.cc
@@ -38,7 +38,7 @@ static DilloUrl *popup_url = NULL;
// Weak reference to the popup's bw
static BrowserWindow *popup_bw = NULL;
// Where to place the filemenu popup
-int popup_x, popup_y;
+static int popup_x, popup_y;
// History popup direction (-1 = back, 1 = forward).
static int history_direction = -1;
// History popup, list of URL-indexes.
@@ -212,6 +212,44 @@ static void Menu_load_images_cb(Widget*, void *user_data)
}
}
+/*
+ * Submit form
+ */
+static void Menu_form_submit_cb(Widget*, void *v_form)
+{
+ if (popup_bw && popup_bw->Docs) {
+ if (dList_find_custom(popup_bw->PageUrls, popup_url,
+ (dCompareFunc)a_Url_cmp)){
+ /* HTML page is still there */
+ int n = dList_length(popup_bw->Docs);
+ if (n == 1) {
+ a_Html_form_submit(dList_nth_data(popup_bw->Docs, 0), v_form);
+ } else if (n > 1) {
+ MSG ("Menu_form_submit_cb multiple Docs not implemented\n");
+ }
+ }
+ }
+}
+
+/*
+ * Reset form
+ */
+static void Menu_form_reset_cb(Widget*, void *v_form)
+{
+ if (popup_bw && popup_bw->Docs) {
+ if (dList_find_custom(popup_bw->PageUrls, popup_url,
+ (dCompareFunc)a_Url_cmp)){
+ /* HTML page is still there */
+ int n = dList_length(popup_bw->Docs);
+ if (n == 1) {
+ a_Html_form_reset(dList_nth_data(popup_bw->Docs, 0), v_form);
+ } else if (n > 1) {
+ MSG ("Menu_form_reset_cb multiple Docs not implemented\n");
+ }
+ }
+ }
+}
+
/*
* Validate URL with the W3C
*/
@@ -452,6 +490,31 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
}
/*
+ * Form popup menu (construction & popup)
+ */
+void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
+ void *formptr)
+{
+ static PopupMenu *pm = 0;
+
+ popup_bw = bw;
+ a_Url_free(popup_url);
+ popup_url = a_Url_dup(page_url);
+ if (!pm) {
+ Item *i;
+ pm = new PopupMenu(0,0,0,0,"FORM OPTIONS");
+ pm->add(i = new Item("Submit form"));
+ i->callback(Menu_form_submit_cb);
+ pm->add(i = new Item("Reset form"));
+ i->callback(Menu_form_reset_cb);
+ pm->type(PopupMenu::POPUP123);
+ }
+ pm->user_data(formptr);
+
+ a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
+}
+
+/*
* File popup menu (construction & popup)
*/
void a_Menu_file_popup(BrowserWindow *bw, void *v_wid)
diff --git a/src/menu.hh b/src/menu.hh
index 9e8a73c6..2b30e47d 100644
--- a/src/menu.hh
+++ b/src/menu.hh
@@ -12,6 +12,8 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url);
void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
bool_t loaded_img, DilloUrl *link_url);
+void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
+ void *vform);
void a_Menu_file_popup(BrowserWindow *bw, void *v_wid);
void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url);
void a_Menu_history_popup(BrowserWindow *bw, int direction);
diff --git a/src/nav.c b/src/nav.c
index c441ddfd..d6293143 100644
--- a/src/nav.c
+++ b/src/nav.c
@@ -194,12 +194,13 @@ static void Nav_stack_clean(BrowserWindow *bw)
static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url, int offset)
{
DilloUrl *old_url;
- bool_t MustLoad, ForceReload;
+ bool_t MustLoad, ForceReload, Repush;
int x, y, idx, ClientKey;
DilloWeb *Web;
MSG("Nav_open_url: new url='%s'\n", URL_STR_(url));
+ Repush = (URL_FLAGS(url) & URL_ReloadFromCache) != 0;
ForceReload = (URL_FLAGS(url) & (URL_E2EQuery + URL_ReloadFromCache)) != 0;
/* Get the url of the current page */
@@ -207,8 +208,8 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url, int offset)
old_url = a_History_get_url(NAV_UIDX(bw, idx));
_MSG("Nav_open_url: old_url='%s' idx=%d\n", URL_STR(old_url), idx);
/* Record current scrolling position */
- if (URL_FLAGS(url) & URL_ReloadFromCache) {
- /* Repush operation, don't change scroll position */
+ if (Repush) {
+ /* Don't change scroll position */
} else if (old_url) {
a_UIcmd_get_scroll_xy(bw, &x, &y);
Nav_save_scroll_pos(bw, idx, x, y);
diff --git a/src/png.c b/src/png.c
index fa07e781..e9b0b843 100644
--- a/src/png.c
+++ b/src/png.c
@@ -4,6 +4,7 @@
*
* Geoff Lane nov 1999 zzassgl@twirl.mcc.ac.uk
* Luca Rota, Jorge Arellano Cid, Eric Gaudet 2000
+ * Jorge Arellano Cid 2009
*
* "PNG: The Definitive Guide" by Greg Roelofs, O'Reilly
* ISBN 1-56592-542-4
@@ -67,19 +68,19 @@ typedef
struct _DilloPng {
DilloImage *Image; /* Image meta data */
DilloUrl *url; /* Primary Key for the dicache */
- int version; /* Secondary Key for the dicache */
+ int version; /* Secondary Key for the dicache */
double display_exponent; /* gamma correction */
- ulong_t width; /* png image width */
- ulong_t height; /* png image height */
+ ulong_t width; /* png image width */
+ ulong_t height; /* png image height */
png_structp png_ptr; /* libpng private data */
png_infop info_ptr; /* libpng private info */
- uchar_t *image_data; /* decoded image data */
- uchar_t **row_pointers; /* pntr to row starts */
+ uchar_t *image_data; /* decoded image data */
+ uchar_t **row_pointers; /* pntr to row starts */
jmp_buf jmpbuf; /* png error processing */
- int error; /* error flag */
+ int error; /* error flag */
png_uint_32 previous_row;
- int rowbytes; /* No. bytes in image row */
+ int rowbytes; /* No. bytes in image row */
short passes;
short channels; /* No. image channels */
@@ -92,13 +93,13 @@ struct _DilloPng {
* ipbuf ipbufstart ipbufsize
*/
- uchar_t *ipbuf; /* image data in buffer */
- int ipbufstart; /* first valid image byte */
- int ipbufsize; /* size of valid data in */
+ uchar_t *ipbuf; /* image data in buffer */
+ int ipbufstart; /* first valid image byte */
+ int ipbufsize; /* size of valid data in */
enum prog_state state; /* FSM current state */
- uchar_t *linebuf; /* o/p raster data */
+ uchar_t *linebuf; /* o/p raster data */
} DilloPng;
@@ -297,57 +298,37 @@ static void
png->state = IS_finished;
}
-
/*
- * Op: Operation to perform.
- * If (Op == 0)
- * start or continue processing an image if image data exists.
- * else
- * terminate processing, cleanup any allocated memory,
- * close down the decoding process.
- *
- * Client->CbData : pointer to previously allocated DilloPng work area.
- * This holds the current state of the image processing and is saved
- * across calls to this routine.
- * Client->Buf : Pointer to data start.
- * Client->BufSize : the size of the data buffer.
- *
- * You have to keep track of where you are in the image data and
- * how much has been processed.
- *
- * It's entirely possible that you will not see the end of the data. The
- * user may terminate transfer via a Stop button or there may be a network
- * failure. This means that you can't just wait for all the data to be
- * presented before starting conversion and display.
+ * Finish the decoding process (and free the memory)
*/
-static void Png_callback(int Op, CacheClient_t *Client)
+static void Png_close(DilloPng *png, CacheClient_t *Client)
{
- DilloPng *png = Client->CbData;
-
- if (Op) {
- /* finished - free up the resources for this image */
- a_Dicache_close(png->url, png->version, Client);
- dFree(png->image_data);
- dFree(png->row_pointers);
- dFree(png->linebuf);
-
- if (setjmp(png->jmpbuf))
- MSG_WARN("PNG: can't destroy read structure\n");
- else if (png->png_ptr)
- png_destroy_read_struct(&png->png_ptr, &png->info_ptr, NULL);
- dFree(png);
- return;
- }
+ /* Free up the resources for this image */
+ a_Dicache_close(png->url, png->version, Client);
+ dFree(png->image_data);
+ dFree(png->row_pointers);
+ dFree(png->linebuf);
+
+ if (setjmp(png->jmpbuf))
+ MSG_WARN("PNG: can't destroy read structure\n");
+ else if (png->png_ptr)
+ png_destroy_read_struct(&png->png_ptr, &png->info_ptr, NULL);
+ dFree(png);
+}
- /* Let's make some sound if we have been called with no data */
- dReturn_if_fail ( Client->Buf != NULL && Client->BufSize > 0 );
+/*
+ * Receive and process new chunks of PNG image data
+ */
+static void Png_write(DilloPng *png, void *Buf, uint_t BufSize)
+{
+ dReturn_if_fail ( Buf != NULL && BufSize > 0 );
- _MSG("Png_callback BufSize = %d\n", Client->BufSize);
+ _MSG("Png_callback BufSize = %d\n", BufSize);
/* Keep local copies so we don't have to pass multiple args to
* a number of functions. */
- png->ipbuf = Client->Buf;
- png->ipbufsize = Client->BufSize;
+ png->ipbuf = Buf;
+ png->ipbufsize = BufSize;
/* start/resume the FSM here */
while (png->state != IS_finished && DATASIZE) {
@@ -408,6 +389,37 @@ static void Png_callback(int Op, CacheClient_t *Client)
}
/*
+ * Op: Operation to perform.
+ * If (Op == 0)
+ * start or continue processing an image if image data exists.
+ * else
+ * terminate processing, cleanup any allocated memory,
+ * close down the decoding process.
+ *
+ * Client->CbData : pointer to previously allocated DilloPng work area.
+ * This holds the current state of the image processing and is kept
+ * across calls to this routine.
+ * Client->Buf : Pointer to data start.
+ * Client->BufSize : the size of the data buffer.
+ *
+ * You have to keep track of where you are in the image data and
+ * how much has been processed.
+ *
+ * It's entirely possible that you will not see the end of the data. The
+ * user may terminate transfer via a Stop button or there may be a network
+ * failure. This means that you can't just wait for all the data to be
+ * presented before starting conversion and display.
+ */
+static void Png_callback(int Op, CacheClient_t *Client)
+{
+ if (Op) { /* EOF */
+ Png_close(Client->CbData, Client);
+ } else {
+ Png_write(Client->CbData, Client->Buf, Client->BufSize);
+ }
+}
+
+/*
* Create the image state data that must be kept between calls
*/
static DilloPng *Png_new(DilloImage *Image, DilloUrl *url, int version)
@@ -433,25 +445,19 @@ static DilloPng *Png_new(DilloImage *Image, DilloUrl *url, int version)
/*
* MIME handler for "image/png" type
* (Sets Png_callback or a_Dicache_callback as the cache-client)
+ *
+ * Parameters:
+ * Type: MIME type
+ * Ptr: points to a Web structure
+ * Call: Dillo calls this with more data/eod
+ * Data: Decoding data structure
*/
void *a_Png_image(const char *Type, void *Ptr, CA_Callback_t *Call,
void **Data)
{
-/*
- * Type: MIME type
- * Ptr: points to a Web structure
- * Call: Dillo calls this with more data/eod
- * Data: raw image data
- */
-
DilloWeb *web = Ptr;
DICacheEntry *DicEntry;
- _MSG("a_Png_image: Type = %s\n"
- "a_Png_image: libpng - Compiled %s; using %s.\n"
- "a_Png_image: zlib - Compiled %s; using %s.\n",
- Type, PNG_LIBPNG_VER_STRING, png_libpng_ver,ZLIB_VERSION,zlib_version);
-
if (!web->Image)
web->Image = a_Image_new(0, 0, NULL, prefs.bg_color);
diff --git a/src/prefs.c b/src/prefs.c
index f04cb672..d7042924 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -35,10 +35,6 @@
#define DILLO_START_PAGE "about:splash"
#define DILLO_HOME "http://www.dillo.org/"
-#define D_GEOMETRY_DEFAULT_WIDTH 780
-#define D_GEOMETRY_DEFAULT_HEIGHT 580
-#define D_GEOMETRY_DEFAULT_XPOS -9999
-#define D_GEOMETRY_DEFAULT_YPOS -9999
#define D_VW_FONTNAME "DejaVu Sans"
#define D_FW_FONTNAME "DejaVu Sans Mono"
diff --git a/src/prefs.h b/src/prefs.h
index ec807f46..a12e5a37 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -7,6 +7,11 @@
extern "C" {
#endif /* __cplusplus */
+#define D_GEOMETRY_DEFAULT_WIDTH 780
+#define D_GEOMETRY_DEFAULT_HEIGHT 580
+#define D_GEOMETRY_DEFAULT_XPOS -9999
+#define D_GEOMETRY_DEFAULT_YPOS -9999
+
/* Panel sizes */
enum { P_tiny = 0, P_small, P_medium, P_large };
diff --git a/src/ui.cc b/src/ui.cc
index b47e11cf..9af1b2a4 100644
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -993,7 +993,8 @@ void UI::panel_cb_i()
*/
void UI::color_change_cb_i()
{
- static int ncolor = 0, cols[] = {7,17,26,51,140,156,205,206,215,-1};
+ const int cols[] = {7,17,26,51,140,156,205,206,215,-1};
+ static int ncolor = 0;
ncolor = (cols[ncolor+1] < 0) ? 0 : ncolor + 1;
CuteColor = cols[ncolor];
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 4484f059..f8869129 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -666,6 +666,14 @@ void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img,
}
/*
+ * Pop up the form menu
+ */
+void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform)
+{
+ a_Menu_form_popup((BrowserWindow*)vbw, url, vform);
+}
+
+/*
* Pop up the file menu
*/
void a_UIcmd_file_popup(void *vbw, void *v_wid)
diff --git a/src/uicmd.hh b/src/uicmd.hh
index c4e34736..3b5dc27e 100644
--- a/src/uicmd.hh
+++ b/src/uicmd.hh
@@ -41,6 +41,7 @@ void a_UIcmd_page_popup(void *vbw, const DilloUrl *url,
void a_UIcmd_link_popup(void *vbw, const DilloUrl *url);
void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img,
DilloUrl *link_url);
+void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform);
void a_UIcmd_file_popup(void *vbw, void *v_wid);
void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr);
void a_UIcmd_view_page_source(const DilloUrl *url);