diff options
author | portix <none@none> | 2012-06-08 19:38:55 +0200 |
---|---|---|
committer | portix <none@none> | 2012-06-08 19:38:55 +0200 |
commit | 44d64cadd95a2240d2ce4aef6d9a161ca126f71f (patch) | |
tree | e4f76dbe0987832db04a923c2d5186421f8d9a3b /src | |
parent | 53f0d1ea5c91010036fd66ae8b3f42ad7c265312 (diff) | |
download | dwb-44d64cadd95a2240d2ce4aef6d9a161ca126f71f.zip |
New signal downloadStart
Diffstat (limited to 'src')
-rw-r--r-- | src/download.c | 27 | ||||
-rw-r--r-- | src/scripts.c | 1 | ||||
-rw-r--r-- | src/scripts.h | 1 |
3 files changed, 28 insertions, 1 deletions
diff --git a/src/download.c b/src/download.c index 067145a6..81b31c2d 100644 --- a/src/download.c +++ b/src/download.c @@ -371,19 +371,43 @@ void download_start(const char *path) { if (path == NULL) path = GET_TEXT(); + char *json = NULL; + gboolean clean = true; char *fullpath = NULL; const char *filename = webkit_download_get_suggested_filename(dwb.state.download); const char *uri = webkit_download_get_uri(dwb.state.download); /* FIXME seems to be a bug in webkit ? */ WebKitNetworkRequest *request = webkit_download_get_network_request(dwb.state.download); dwb.state.download = webkit_download_new(request); + + if (EMIT_SCRIPT(DOWNLOAD_START)) { + if (dwb.state.dl_action == DL_ACTION_EXECUTE) { + json = util_create_json(4, + CHAR, "referer", soup_get_header_from_request(webkit_download_get_network_request(dwb.state.download), "Referer"), + CHAR, "mimeType", dwb.state.mimetype_request, + CHAR, "application", path, + CHAR, "destinationUri", NULL); + } + else { + char *p = g_build_filename(path, filename, NULL); + json = util_create_json(4, + CHAR, "referer", soup_get_header_from_request(webkit_download_get_network_request(dwb.state.download), "Referer"), + CHAR, "mimeType", dwb.state.mimetype_request, + CHAR, "destinationUri", p, + CHAR, "application", NULL); + g_free(p); + } + ScriptSignal signal = { .jsobj = NULL, .objects = { G_OBJECT(dwb.state.download) }, SCRIPTS_SIG_META(json, DOWNLOAD_START, 1) }; + if (scripts_emit(&signal)) { + goto error_out; + } + } //char *command = NULL; char *tmppath = NULL; const char *last_slash; char path_buffer[PATH_MAX+1]; gboolean external = GET_BOOL("download-use-external-program"); - gboolean clean = true; char buffer[PATH_MAX]; path = util_expand_home(buffer, path, PATH_MAX); @@ -478,6 +502,7 @@ download_start(const char *path) { error_out: dwb_change_mode(NORMAL_MODE, clean); dwb.state.download = NULL; + g_free(json); g_free(fullpath); }/*}}}*/ diff --git a/src/scripts.c b/src/scripts.c index 63ee253d..29915c80 100644 --- a/src/scripts.c +++ b/src/scripts.c @@ -58,6 +58,7 @@ static Sigmap _sigmap[] = { { SCRIPTS_SIG_LOAD_STATUS, "loadStatus" }, { SCRIPTS_SIG_MIME_TYPE, "mimeType" }, { SCRIPTS_SIG_DOWNLOAD, "download" }, + { SCRIPTS_SIG_DOWNLOAD_START, "downloadStart" }, { SCRIPTS_SIG_DOWNLOAD_STATUS, "downloadStatus" }, { SCRIPTS_SIG_RESOURCE, "resource" }, { SCRIPTS_SIG_KEY_PRESS, "keyPress" }, diff --git a/src/scripts.h b/src/scripts.h index 9c0fa3ce..93893ba4 100644 --- a/src/scripts.h +++ b/src/scripts.h @@ -27,6 +27,7 @@ enum SIGNALS { SCRIPTS_SIG_LOAD_STATUS, SCRIPTS_SIG_MIME_TYPE, SCRIPTS_SIG_DOWNLOAD, + SCRIPTS_SIG_DOWNLOAD_START, SCRIPTS_SIG_DOWNLOAD_STATUS, SCRIPTS_SIG_RESOURCE, SCRIPTS_SIG_KEY_PRESS, |