aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/capi.c23
-rw-r--r--src/capi.h2
-rw-r--r--src/menu.cc2
-rw-r--r--src/uicmd.cc13
-rw-r--r--src/uicmd.hh2
5 files changed, 26 insertions, 16 deletions
diff --git a/src/capi.c b/src/capi.c
index 54e199aa..5458f94e 100644
--- a/src/capi.c
+++ b/src/capi.c
@@ -474,11 +474,12 @@ const char *a_Capi_set_content_type(const DilloUrl *url, const char *ctype,
}
/*
- * Send a dpi cmd.
- * (For instance: add_bookmark, open_url, send_preferences, ...)
+ * Send data to a dpi (e.g. add_bookmark, open_url, send_preferences, ...)
+ * Most of the time we send dpi commands, but it also serves for raw data
+ * as with "view source".
*/
-int a_Capi_dpi_send_cmd(DilloUrl *url, void *bw, char *cmd, char *server,
- int flags)
+int a_Capi_dpi_send_data(DilloUrl *url, void *bw, char *data, int data_sz,
+ char *server, int flags)
{
capi_conn_t *conn;
DataBuf *dbuf;
@@ -487,7 +488,7 @@ int a_Capi_dpi_send_cmd(DilloUrl *url, void *bw, char *cmd, char *server,
/* open a new connection to server */
/* Create a new connection data struct and add it to the list */
- conn = Capi_conn_new(url, bw, server, cmd);
+ conn = Capi_conn_new(url, bw, server, data);
/* start the CCC operations */
a_Capi_ccc(OpStart, 2, BCK, a_Chain_new(), conn, server);
a_Capi_ccc(OpStart, 1, BCK, a_Chain_new(), conn, server);
@@ -497,7 +498,7 @@ int a_Capi_dpi_send_cmd(DilloUrl *url, void *bw, char *cmd, char *server,
conn = Capi_conn_find(server);
if (conn) {
/* found */
- dbuf = a_Chain_dbuf_new(cmd, (int)strlen(cmd), 0);
+ dbuf = a_Chain_dbuf_new(data, data_sz, 0);
a_Capi_ccc(OpSend, 1, BCK, conn->InfoSend, dbuf, NULL);
dFree(dbuf);
} else {
@@ -509,6 +510,16 @@ int a_Capi_dpi_send_cmd(DilloUrl *url, void *bw, char *cmd, char *server,
}
/*
+ * Send a dpi cmd.
+ * (For instance: add_bookmark, open_url, send_preferences, ...)
+ */
+int a_Capi_dpi_send_cmd(DilloUrl *url, void *bw, char *cmd, char *server,
+ int flags)
+{
+ return a_Capi_dpi_send_data(url, bw, cmd, strlen(cmd), server, flags);
+}
+
+/*
* Remove a client from the cache client queue.
* force = also abort the CCC if this is the last client.
*/
diff --git a/src/capi.h b/src/capi.h
index 45df8f64..8b883e52 100644
--- a/src/capi.h
+++ b/src/capi.h
@@ -31,6 +31,8 @@ const char *a_Capi_set_content_type(const DilloUrl *url, const char *ctype,
int a_Capi_get_flags(const DilloUrl *Url);
int a_Capi_get_flags_with_redirection(const DilloUrl *Url);
int a_Capi_dpi_verify_request(BrowserWindow *bw, DilloUrl *url);
+int a_Capi_dpi_send_data(DilloUrl *url, void *bw, char *data, int data_sz,
+ char *server, int flags);
int a_Capi_dpi_send_cmd(DilloUrl *url, void *bw, char *cmd, char *server,
int flags);
void a_Capi_stop_client(int Key, int force);
diff --git a/src/menu.cc b/src/menu.cc
index d382249b..b9c8b6ef 100644
--- a/src/menu.cc
+++ b/src/menu.cc
@@ -180,7 +180,7 @@ static void Menu_save_page_cb(Widget* )
*/
static void Menu_view_page_source_cb(Widget* )
{
- a_UIcmd_view_page_source(popup_url);
+ a_UIcmd_view_page_source(popup_bw, popup_url);
}
/*
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 0d954c68..3bf7ddd8 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -1000,16 +1000,13 @@ void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr)
/*
* Show a text window with the URL's source
*/
-void a_UIcmd_view_page_source(const DilloUrl *url)
+void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
{
- char *buf;
- int buf_size;
+ DilloUrl *vs_url;
- if (a_Nav_get_buf(url, &buf, &buf_size)) {
- void *vWindow = a_Dialog_make_text_window(buf, "View Page source");
- a_Nav_unref_buf(url);
- a_Dialog_show_text_window(vWindow);
- }
+ vs_url = a_Url_new("dpi:/vsource/", NULL);
+ a_UIcmd_open_url_nt(bw, vs_url, 1);
+ a_Url_free(vs_url);
}
/*
diff --git a/src/uicmd.hh b/src/uicmd.hh
index 87d923d3..c8fea9e7 100644
--- a/src/uicmd.hh
+++ b/src/uicmd.hh
@@ -49,7 +49,7 @@ void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform,
bool_t showing_hiddens);
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);
+void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url);
void a_UIcmd_view_page_bugs(void *vbw);
void a_UIcmd_bugmeter_popup(void *vbw);
int *a_UIcmd_get_history(BrowserWindow *bw, int direction);