changeset 1574:da4dac7f14b1

Interim patch for view source
author Jorge Arellano Cid <jcid@dillo.org>
date Sat, 20 Feb 2010 16:11:33 -0300
parents 2307d3f8e41b
children bb02b0e5110b
files ChangeLog src/capi.c src/menu.cc src/nav.c
diffstat 4 files changed, 27 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Feb 17 23:10:05 2010 +0000
+++ b/ChangeLog	Sat Feb 20 16:11:33 2010 -0300
@@ -3,6 +3,9 @@
 =============================================================================
 
 dillo-2.2.1 [not released yet]
+
++- Implemented "View source" as a dpi.
+   Patch: Jorge Arellano Cid
 +- Configurable User-Agent HTTP header.
    Patch: Alexander Voigt, corvid
 +- Include Accept header in HTTP queries.
--- a/src/capi.c	Wed Feb 17 23:10:05 2010 +0000
+++ b/src/capi.c	Sat Feb 20 16:11:33 2010 -0300
@@ -354,9 +354,13 @@
       /* dpi request */
       if ((safe = a_Capi_dpi_verify_request(web->bw, web->url))) {
          if (dStrcasecmp(scheme, "dpi") == 0) {
-            /* make "dpi:/" prefixed urls always reload. */
-            a_Url_set_flags(web->url, URL_FLAGS(web->url) | URL_E2EQuery);
-            reload = 1;
+            if (strcmp(server, "vsource") == 0) {
+               /* don't reload the "view source" page */
+            } else {
+               /* make the other "dpi:/" prefixed urls always reload. */
+               a_Url_set_flags(web->url, URL_FLAGS(web->url) | URL_E2EQuery);
+               reload = 1;
+            }
          }
          if (reload) {
             a_Capi_conn_abort_by_url(web->url);
--- a/src/menu.cc	Wed Feb 17 23:10:05 2010 +0000
+++ b/src/menu.cc	Sat Feb 20 16:11:33 2010 -0300
@@ -339,7 +339,7 @@
    // One menu for every browser window
    static PopupMenu *pm = 0;
    // Active/inactive control.
-   static Item *view_page_bugs_item = 0;
+   static Item *view_page_bugs_item = 0, *view_source_item = 0;
    static ItemGroup *stylesheets = 0;
 
    popup_bw = bw;
@@ -349,7 +349,7 @@
    if (!pm) {
       pm = new PopupMenu(0,0,0,0,"&PAGE OPTIONS");
       pm->begin();
-       i = new Item("View page Source");
+       i = view_source_item = new Item("View page Source");
        i->callback(Menu_view_page_source_cb);
        i = view_page_bugs_item = new Item("View page Bugs");
        i->callback(Menu_view_page_bugs_cb);
@@ -376,6 +376,11 @@
    else
       view_page_bugs_item->deactivate();
 
+   if (strncmp(URL_STR(url), "dpi:/vsource/", 13) == 0)
+      view_source_item->deactivate();
+   else
+      view_source_item->activate();
+
    int n = stylesheets->children();
    for (j = 0; j < n; j++) {
       /* get rid of the old ones */
--- a/src/nav.c	Wed Feb 17 23:10:05 2010 +0000
+++ b/src/nav.c	Sat Feb 20 16:11:33 2010 -0300
@@ -479,7 +479,10 @@
    a_Nav_cancel_expect(bw);
    if (a_Nav_stack_size(bw)) {
       h_url = a_History_get_url(NAV_TOP_UIDX(bw));
-      if (URL_FLAGS(h_url) & URL_Post) {
+      if (strncmp(URL_STR(h_url), "dpi:/vsource/", 13) == 0) {
+         /* disable reload for view source dpi */
+         confirmed = 0;
+      } else if (URL_FLAGS(h_url) & URL_Post) {
          /* Attempt to repost data, let's confirm... */
          choice = a_Dialog_choice3("Repost form data?",
                                    "Yes", "*No", "Cancel");
@@ -592,11 +595,16 @@
    char *buf;
    int buf_size;
    DilloUrl *vs_url;
+   Dstr *dstr_url;
 
    if (a_Nav_get_buf(url, &buf, &buf_size)) {
-      vs_url = a_Url_new("dpi:/vsource/", NULL);
+      dstr_url = dStr_new("dpi:/vsource/:");
+      dStr_append(dstr_url, URL_STR(url));
+
+      vs_url = a_Url_new(dstr_url->str, NULL);
       a_UIcmd_open_url_nt(bw, vs_url, 1);
       a_Url_free(vs_url);
+      dStr_free(dstr_url, 1);
 
       /* send the page's source to this dpi connection */
       a_Capi_dpi_send_source(bw, url, buf, buf_size);