commit 033b63a01f222e13c91cc297917fae8b10c240f9
parent baff75744be41e8e3453180f81b589753e558faf
Author: Kyle Milz <kmilz@ucalgary.ca>
Date: Mon, 15 Oct 2012 21:52:19 -0600
get the schema registration working
now we can spawn external programs when a certain schema has been
requested.
Diffstat:
1 file changed, 9 insertions(+), 32 deletions(-)
diff --git a/src/callbacks.c b/src/callbacks.c
@@ -1056,36 +1056,15 @@ setup_window_callbacks(Window_Data *wd)
}
static void
-about_url_scheme_request_cb(Ewk_Url_Scheme_Request *request, void *user_data)
-{
- const char *path;
- char *contents_data = NULL;
- unsigned int contents_length = 0;
-
- path = ewk_url_scheme_request_path_get(request);
- if (!strcmp(path, "plugins")) {
- // Initialize contents_data with the contents of plugins about page, and set its length to contents_length
- } else if (!strcmp(path, "memory")) {
- // Initialize contents_data with the contents of memory about page, and set its length to contents_length
- } else if (!strcmp(path, "applications")) {
- // Initialize contents_data with the contents of application about page, and set its length to contents_length
- } else {
- Eina_Strbuf *buf = eina_strbuf_new();
- eina_strbuf_append_printf(buf, "<html><body><p>Invalid about:%s page</p></body></html>", path);
- contents_data = eina_strbuf_string_steal(buf);
- contents_length = strlen(contents_data);
- eina_strbuf_free(buf);
- }
- ewk_url_scheme_request_finish(request, contents_data, contents_length, "text/html");
- free(contents_data);
-}
-
-static void
generic_url_scheme_request_cb(Ewk_Url_Scheme_Request *request, void *user_data)
{
+ Eina_Strbuf *buf = eina_strbuf_new();
char *handler = user_data;
- printf("generic_url_scheme_request() cmd = %s\n", handler);
- ecore_exe_run(handler, NULL);
+ const char *url = ewk_url_scheme_request_url_get(request);
+ eina_strbuf_append_printf(buf, "%s \"%s\"\n", handler, url);
+ printf("%s\n", eina_strbuf_string_get(buf));
+ ecore_exe_run(eina_strbuf_string_steal(buf), NULL);
+ // ewk_url_scheme_request_finish(request, NULL, 0, "text/html");
}
void
@@ -1115,15 +1094,13 @@ setup_main_callbacks(App_Data *ad, const char *cookie_path)
/* url scheme registration */
URIHandler uri_handlers[] = {
- { "mailto:", "terminology -e mutt %s" },
- { "ftp://", "terminology -e wget ftp://%s" },
- { "magnet:", "terminology -e rtorrent %s" },
+ { "mailto", "terminology -e mutt" },
+ { "ftp", "terminology -e wget ftp://" },
+ { "magnet", "xterm -e rtorrent" },
};
for (i = 0; i < LENGTH(uri_handlers); i++)
ewk_context_url_scheme_register(context, uri_handlers[i].handle,
generic_url_scheme_request_cb, uri_handlers[i].handler);
-
- ewk_context_url_scheme_register(context, "about:", about_url_scheme_request_cb, NULL);
}