diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2010-02-17 13:55:26 -0300 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2010-02-17 13:55:26 -0300 |
commit | 9ec7bf0cf9413566ebb50fd5a3d388cbfaaaa013 (patch) | |
tree | 410dc4d5b71aeca4d0a0aac28f79a2dcb21c3af7 /src | |
parent | f8d6d864ed3b9bd82564b73ef264bd834f2e1bf2 (diff) |
Implement the view source functionality as a dpi
Diffstat (limited to 'src')
-rw-r--r-- | src/capi.c | 24 | ||||
-rw-r--r-- | src/capi.h | 6 | ||||
-rw-r--r-- | src/nav.c | 20 | ||||
-rw-r--r-- | src/nav.h | 1 | ||||
-rw-r--r-- | src/uicmd.cc | 6 |
5 files changed, 46 insertions, 11 deletions
@@ -85,7 +85,7 @@ void a_Capi_init(void) * Create a new connection data structure */ static capi_conn_t * - Capi_conn_new(DilloUrl *url, void *bw, char *server, char *datastr) + Capi_conn_new(const DilloUrl *url, void *bw, char *server, char *datastr) { capi_conn_t *conn; @@ -478,8 +478,8 @@ const char *a_Capi_set_content_type(const DilloUrl *url, const char *ctype, * Most of the time we send dpi commands, but it also serves for raw data * as with "view source". */ -int a_Capi_dpi_send_data(DilloUrl *url, void *bw, char *data, int data_sz, - char *server, int flags) +int a_Capi_dpi_send_data(const DilloUrl *url, void *bw, + char *data, int data_sz, char *server, int flags) { capi_conn_t *conn; DataBuf *dbuf; @@ -502,7 +502,7 @@ int a_Capi_dpi_send_data(DilloUrl *url, void *bw, char *data, int data_sz, a_Capi_ccc(OpSend, 1, BCK, conn->InfoSend, dbuf, NULL); dFree(dbuf); } else { - MSG(" ERROR: [a_Capi_dpi_send_cmd] No open connection found\n"); + MSG(" ERROR: [a_Capi_dpi_send_data] No open connection found\n"); } } @@ -520,6 +520,22 @@ int a_Capi_dpi_send_cmd(DilloUrl *url, void *bw, char *cmd, char *server, } /* + * Send this url's source to the "view source" dpi + */ +void a_Capi_dpi_send_source(BrowserWindow *bw, const DilloUrl *url, + char *buf, int buf_size) +{ + char *cmd, size_str[32]; + + /* send the page's source to this dpi connection */ + snprintf(size_str, 32, "%d", buf_size); + cmd = a_Dpip_build_cmd("cmd=%s url=%s data_size=%s", + "start_send_page", URL_STR(url), size_str); + a_Capi_dpi_send_cmd(NULL, bw, cmd, "vsource", 0); + a_Capi_dpi_send_data(url, bw, buf, buf_size, "vsource", 0); +} + +/* * Remove a client from the cache client queue. * force = also abort the CCC if this is the last client. */ @@ -31,10 +31,12 @@ 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_data(const 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_dpi_send_source(BrowserWindow *bw, const DilloUrl *url, + char *buf, int buf_size); void a_Capi_stop_client(int Key, int force); void a_Capi_conn_abort_by_url(const DilloUrl *url); @@ -583,3 +583,23 @@ void a_Nav_unref_buf(const DilloUrl *Url) { a_Capi_unref_buf(Url); } + +/* + * Send source to a dpi + */ +void a_Nav_send_source(BrowserWindow *bw, const DilloUrl *url) +{ + char *buf; + int buf_size; + DilloUrl *vs_url; + + if (a_Nav_get_buf(url, &buf, &buf_size)) { + vs_url = a_Url_new("dpi:/vsource/", NULL); + a_UIcmd_open_url_nt(bw, vs_url, 1); + a_Url_free(vs_url); + + /* send the page's source to this dpi connection */ + a_Capi_dpi_send_source(bw, url, buf, buf_size); + a_Nav_unref_buf(url); + } +} @@ -34,6 +34,7 @@ void a_Nav_save_url(BrowserWindow *bw, const DilloUrl *url, const char *filename); int a_Nav_get_buf(const DilloUrl *Url, char **PBuf, int *BufSize); void a_Nav_unref_buf(const DilloUrl *Url); +void a_Nav_send_source(BrowserWindow *bw, const DilloUrl *url); #ifdef __cplusplus } diff --git a/src/uicmd.cc b/src/uicmd.cc index 3bf7ddd8..b57e456f 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -1002,11 +1002,7 @@ void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr) */ void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url) { - DilloUrl *vs_url; - - vs_url = a_Url_new("dpi:/vsource/", NULL); - a_UIcmd_open_url_nt(bw, vs_url, 1); - a_Url_free(vs_url); + a_Nav_send_source(bw, url); } /* |