diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2010-02-17 13:54:58 -0300 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2010-02-17 13:54:58 -0300 |
commit | f8d6d864ed3b9bd82564b73ef264bd834f2e1bf2 (patch) | |
tree | ae2d1e28f3da13a1b239d36f7152f8d86550447b | |
parent | e38ffe05b755b187db244ca65109adaaec52ee48 (diff) |
Add the a_Capi_dpi_send_data() function
-rw-r--r-- | src/capi.c | 23 | ||||
-rw-r--r-- | src/capi.h | 2 | ||||
-rw-r--r-- | src/menu.cc | 2 | ||||
-rw-r--r-- | src/uicmd.cc | 13 | ||||
-rw-r--r-- | src/uicmd.hh | 2 |
5 files changed, 26 insertions, 16 deletions
@@ -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. */ @@ -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); |