Mercurial > dillo_port1.3
changeset 1569:24a5d37b09e1
Add the a_Capi_dpi_send_data() function
author | Jorge Arellano Cid <jcid@dillo.org> |
---|---|
date | Wed, 17 Feb 2010 13:54:58 -0300 |
parents | 96e28c8697ad |
children | f275bd2cdeed |
files | src/capi.c src/capi.h src/menu.cc src/uicmd.cc src/uicmd.hh |
diffstat | 5 files changed, 26 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/capi.c Wed Feb 17 13:53:36 2010 -0300 +++ b/src/capi.c Wed Feb 17 13:54:58 2010 -0300 @@ -474,11 +474,12 @@ } /* - * 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 @@ /* 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 @@ 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 @@ } /* + * 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. */
--- a/src/capi.h Wed Feb 17 13:53:36 2010 -0300 +++ b/src/capi.h Wed Feb 17 13:54:58 2010 -0300 @@ -31,6 +31,8 @@ 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);
--- a/src/menu.cc Wed Feb 17 13:53:36 2010 -0300 +++ b/src/menu.cc Wed Feb 17 13:54:58 2010 -0300 @@ -180,7 +180,7 @@ */ static void Menu_view_page_source_cb(Widget* ) { - a_UIcmd_view_page_source(popup_url); + a_UIcmd_view_page_source(popup_bw, popup_url); } /*
--- a/src/uicmd.cc Wed Feb 17 13:53:36 2010 -0300 +++ b/src/uicmd.cc Wed Feb 17 13:54:58 2010 -0300 @@ -1000,16 +1000,13 @@ /* * 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); } /*
--- a/src/uicmd.hh Wed Feb 17 13:53:36 2010 -0300 +++ b/src/uicmd.hh Wed Feb 17 13:54:58 2010 -0300 @@ -49,7 +49,7 @@ 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);