Kelson Vibber wrote:
Madis Janson wrote:
This is only my opinion, which may be wrong (I am only contributed few patches to Dillo), but I think the reason for no answer is that strict standards compliance is one of the goals of the Dillo project and the w3c html standard discourages the usage of meta tag for refresh.
http://www.w3.org/TR/html401/struct/global.html#idx-meta_data-2
Actually, that document only discourages using meta refresh for *forwarding*, as there are better, more accessible ways to do it (i.e. 302 Moved and similar responses). It says nothing negative about using a meta http-equiv tag to *refresh* the page.
"Note. Some user agents support the use of META to refresh the current page after a specified number of seconds, with the option of replacing it by a different URI. Authors should not use this technique to forward users to different pages, as this makes the page inaccessible to some users. Instead, automatic page forwarding should be done using server-side redirects."
I hope this could make change your minds about including my patch in dillo project. I remember you that patch doesn't modify standard dillo behaviure but simple add -r flags which allow refresh tag to act. :-) If I have to modify something in the patch to make it accepted feel free to suggest me. Cheers, -- Roberto A. Foglietta Analista Programmatore GNU/Linux SAD Trasporto Locale S.p.a. Corso Italia 13/N 39100 BOLZANO (I) Tel. +39/0471-450.261 Fax +39/0471-450.253 diff -pru dillo-0.8.4/src/browser.h dillo-0.8.4-refresh/src/browser.h --- dillo-0.8.4/src/browser.h 2004-10-20 21:09:51.000000000 +0200 +++ dillo-0.8.4-refresh/src/browser.h 2005-01-17 14:39:34.000000000 +0100 @@ -139,6 +139,12 @@ struct _BrowserWindow /* The id for the idle function that sets button sensitivity. */ guint sens_idle_id; + + /* RAF, 2004-10-26: usefull to refresh tag */ + guint timeout; + guint delay; + guint idle_id; + DilloUrl *refresh_url; }; diff -pru dillo-0.8.4/src/cache.c dillo-0.8.4-refresh/src/cache.c --- dillo-0.8.4/src/cache.c 2004-12-24 16:22:53.000000000 +0100 +++ dillo-0.8.4-refresh/src/cache.c 2005-01-17 14:51:58.000000000 +0100 @@ -906,6 +906,12 @@ static void Cache_process_queue(CacheDat DEBUG_MSG(1, "QueueSize ====> %d\n", g_slist_length(ClientQueue)); } +/* RAF, 2004-10-28 */ +gint a_Cache_queue_size(void) +{ + return g_slist_length(ClientQueue); +} + /* * Callback function for Cache_delayed_process_queue. */ diff -pru dillo-0.8.4/src/cache.h dillo-0.8.4-refresh/src/cache.h --- dillo-0.8.4/src/cache.h 2004-12-23 19:55:07.000000000 +0100 +++ dillo-0.8.4-refresh/src/cache.h 2005-01-17 14:52:16.000000000 +0100 @@ -50,6 +50,7 @@ struct _CacheClient { /* * Function prototypes */ +gint a_Cache_queue_size(void); //RAF, 2004-10-28 void a_Cache_init(void); gint a_Cache_open_url(void *Web, CA_Callback_t Call, void *CbData); gint a_Cache_get_buf(const DilloUrl *Url, gchar **PBuf, gint *BufSize); diff -pru dillo-0.8.4/src/dillo.c dillo-0.8.4-refresh/src/dillo.c --- dillo-0.8.4/src/dillo.c 2005-01-06 13:14:39.000000000 +0100 +++ dillo-0.8.4-refresh/src/dillo.c 2005-01-17 13:55:23.000000000 +0100 @@ -70,6 +70,7 @@ enum { DILLO_CLI_LOCAL = 1 << 5, DILLO_CLI_GEOMETRY = 1 << 6, DILLO_CLI_DBG_RENDERING = 1 << 7, + DILLO_CLI_REFRESH = 1 << 8, //RAF-2004-10-27 DILLO_CLI_ERROR = 1 << 15 }; @@ -82,6 +83,9 @@ enum { */ gboolean dillo_dbg_rendering = FALSE; +/* RAF, 2004-10-27: adding command line option to allow refresh */ +gboolean dillo_refresh = FALSE; + /* * Forward declarations */ @@ -114,6 +118,9 @@ static CLI_options Options[] = { 0, DILLO_CLI_DBG_RENDERING, " -D, --debug-rendering Draw additionaly several lines in a web page,\n" " representing its structure. For debugging. "}, + /* RAF 2004-10-27: command line option add */ + {"-r", "-refresh", 0, DILLO_CLI_REFRESH, + " -r, -refresh Allow meta refresh working as webmaster decided."}, {NULL, NULL, 0, 0, NULL} }; @@ -249,6 +256,10 @@ gint main(int argc, char *argv[]) case DILLO_CLI_DBG_RENDERING: dillo_dbg_rendering = TRUE; break; + /* RAF, 2004-10-27: adding command line option for meta refresh */ + case DILLO_CLI_REFRESH: + dillo_refresh = TRUE; + break; case DILLO_CLI_GEOMETRY: if (a_Misc_parse_geometry(opt_argv[0], &xpos, &ypos, &width, &height)) break; diff -pru dillo-0.8.4/src/dillo.h dillo-0.8.4-refresh/src/dillo.h --- dillo-0.8.4/src/dillo.h 2004-05-22 00:13:07.000000000 +0200 +++ dillo-0.8.4-refresh/src/dillo.h 2005-01-17 13:53:23.000000000 +0100 @@ -6,4 +6,7 @@ extern gboolean dillo_dbg_rendering; +/* RAF, 2004-10-27: adding command line option to allow refresh */ +extern gboolean dillo_refresh; + #endif /* __DILLO_H__ */ diff -pru dillo-0.8.4/src/html.c dillo-0.8.4-refresh/src/html.c --- dillo-0.8.4/src/html.c 2005-01-05 22:01:00.000000000 +0100 +++ dillo-0.8.4-refresh/src/html.c 2005-01-17 14:52:58.000000000 +0100 @@ -3150,6 +3150,56 @@ static void Html_tag_close_form(DilloHtm * is a hackish way to put the message. A much cleaner approach is to * build a custom widget for it. */ + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * WORKING ON SUPPORTING DEPRECATED META REFRESH + * Roberto A. Foglietta <roberto.foglietta@sad.it> + * + * Actually I'm working for a local public transport company in which + * I have to to develop a new way to display time table and information + * to people. Using Dillo into embedded linux system allow my collegues + * to change graphical display just editing php code in the server BUT + * this kind of information have to stay up-to-date. Commit a refresh + * from server is, in this case, the best solution I can immagine. + * So supporting meta refresh tag makes Dillo good for embedded client + * systems. This is the main reason because I developed this web-deprecated + * but very-useful-in-embedded function. In addition to this pratical + * consideration I think people use free software to be free, so it makes + * sense give them the freedoom to choose also deprecated functions. + * Obviously to respect Dillo's team decision to do not allow refresh + * as default policy I make it optional by setting a flag from command + * line + */ + +void refresh_true_callback(gpointer client_data) { + BrowserWindow *bw = client_data; + + if(bw->timeout) { + gtk_timeout_remove(bw->timeout); + bw->timeout = 0; + } + + a_Commands_open_link_callback(NULL, client_data); +} + +void refresh_callback(gpointer client_data) { + BrowserWindow *bw = client_data; + + if(a_Cache_queue_size()) { + return; + } + + MSG("a_Cache_queue_size: %d\n", a_Cache_queue_size()); + + if(bw->idle_id) { + gtk_idle_remove(bw->idle_id); + bw->idle_id = 0; + } + + bw->timeout = gtk_timeout_add((guint32)bw->delay*1000, + (GtkFunction)refresh_true_callback, (gpointer)(bw)); +} + static void Html_tag_open_meta(DilloHtml *html, char *tag, gint tagsize) { const gchar *meta_template = @@ -3161,7 +3211,7 @@ static void Html_tag_open_meta(DilloHtml " <a href='%s'>here</a>%s</td></tr></table><br>\n"; const gchar *equiv, *content; - gchar *html_msg, delay_str[64]; + gchar *ptr, *html_msg, delay_str[64]; gint delay; /* only valid inside HEAD */ @@ -3173,7 +3223,34 @@ static void Html_tag_open_meta(DilloHtml if ((equiv = Html_get_attr(html, tag, tagsize, "http-equiv")) && !g_strcasecmp(equiv, "refresh") && (content = Html_get_attr(html, tag, tagsize, "content"))) { + } else { + return; + } + + /* check for delay */ + delay = strtol(content, &ptr, 0); + if(ptr) ptr = (gchar *)content; + + if(*ptr) { + /* todo: fix this to parse "URL =" & friends (HTML spec) */ + /* RAF, 2004-10-25: DONE, I suppose... */ + if (strstr(ptr, "URL") || strstr(ptr, "url") || strstr(ptr, "Url")) { + ptr = strstr(ptr, "="); + while (*(++ptr) == ' ' && *ptr != '>'); /* skip URL= & friends */ + if(*ptr == '>') *ptr = 0; /* doesn't exist any URL= */ + } else { + *ptr = 0; /* doesn't exist any URL= */ + } + } + + if(!*ptr && !delay) { + return; + } else { + g_print("meta refresh: start with refresh %sallowed\n", (dillo_refresh) ? "" : "not "); + g_print("meta refresh: delay -> %d, url -> %s\n", delay, (*ptr) ? ptr : "none"); + } + if(!dillo_refresh) { /* Get delay, if present, and make a message with it */ if ((delay = strtol(content, NULL, 0))) g_snprintf(delay_str, 64, " after %d second%s.", @@ -3196,6 +3273,33 @@ static void Html_tag_open_meta(DilloHtml html->InFlags = SaveFlags; } g_free(html_msg); + } else { + //if(html->bw->refresh_url) + a_Url_free(html->bw->refresh_url); + + if(*ptr) { + html->bw->refresh_url = a_Url_new(ptr, NULL, 0, 0, 0); + a_Url_set_flags(html->bw->refresh_url, URL_FLAGS(html->bw->refresh_url) | URL_E2EReload); + a_Menu_popup_set_url(html->bw, html->bw->refresh_url); + } else { + html->bw->refresh_url = a_History_get_url(NAV_TOP(html->bw)); + a_Url_set_flags(html->bw->refresh_url, URL_FLAGS(html->bw->refresh_url) | URL_E2EReload); + a_Url_set_flags(html->bw->refresh_url, URL_FLAGS(html->bw->refresh_url) & ~URL_SpamSafe); + a_Menu_popup_set_url(html->bw, html->bw->refresh_url); + html->bw->refresh_url = NULL; + } + + /* RAF, 2004-10-25: Use a timeout to refresh the page automatically */ + if(delay) { + //html->bw->timeout = gtk_timeout_add((guint32)delay*1000, + // (GtkFunction)refresh_callback, (gpointer)(html->bw)); + html->bw->delay = delay; + html->bw->idle_id = gtk_idle_add((GtkFunction)refresh_callback, (gpointer)(html->bw)); + } else { + html->bw->timeout = 0; + html->bw->delay = 0; + refresh_callback(html->bw); + } } } diff -pru dillo-0.8.4/src/interface.c dillo-0.8.4-refresh/src/interface.c --- dillo-0.8.4/src/interface.c 2004-12-29 14:26:48.000000000 +0100 +++ dillo-0.8.4-refresh/src/interface.c 2005-01-17 14:46:41.000000000 +0100 @@ -1127,6 +1127,12 @@ a_Interface_browser_window_new(gint widt bw->viewsource_window = NULL; bw->pagebugs_window = NULL; + /* RAF, 2004-10-26: null value for time out */ + bw->timeout = 0; + bw->delay = 0; + bw->idle_id = 0; + bw->refresh_url = NULL; + /* now that the bw is made, let's customize it.. */ Interface_browser_window_customize(bw); diff -pru dillo-0.8.4/src/nav.c dillo-0.8.4-refresh/src/nav.c --- dillo-0.8.4/src/nav.c 2004-12-16 20:02:21.000000000 +0100 +++ dillo-0.8.4-refresh/src/nav.c 2005-01-17 14:43:20.000000000 +0100 @@ -55,6 +55,9 @@ void a_Nav_free(BrowserWindow *bw) { a_Nav_cancel_expect(bw); g_free(bw->nav_stack); + + /* RAF, 2004-10-27: free the url redirection */ + a_Url_free(bw->refresh_url); } @@ -156,6 +159,11 @@ static void Nav_open_url(BrowserWindow * gboolean ForceReload = (URL_FLAGS(url) & URL_E2EReload); MSG("Nav_open_url: Url=>%s<\n", URL_STR_(url)); + /* RAF, 2004-10-28: switch off reload timeout */ + if(bw->timeout) { + gtk_timeout_remove(bw->timeout); + bw->timeout = 0; + } /* Get the url of the current page */ if ( a_Nav_stack_ptr(bw) != -1 )