commit 402bad114e4fd8236c9c091f01c841430e2aafa2
parent 40a5074676f004d2f9c877d992c18c7ee7bf3f0c
Author: Kyle Milz <kmilz@ucalgary.ca>
Date: Mon, 8 Oct 2012 14:56:00 -0600
first attempt at scheme registration
doesn't work yet
Diffstat:
4 files changed, 55 insertions(+), 16 deletions(-)
diff --git a/src/callbacks.c b/src/callbacks.c
@@ -993,3 +993,53 @@ setup_window_callbacks(Window_Data *wd)
evas_object_event_callback_add(wd->url, EVAS_CALLBACK_KEY_UP, inputbox_keyrelease_cb, 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)
+{
+ char *handler = user_data;
+ printf("generic_url_scheme_request() cmd = %s\n", handler);
+ ecore_exe_run(handler, NULL);
+}
+
+void
+setup_url_scheme_callbacks(Ewk_Context *ewk_context)
+{
+ int i;
+ URIHandler uri_handlers[] = {
+ { "mailto:", "terminology -e mutt %s" },
+ { "ftp://", "terminology -e wget ftp://%s" },
+ { "magnet:", "terminology -e rtorrent %s" },
+ };
+
+ for (i = 0; i < LENGTH(uri_handlers); i++)
+ ewk_context_uri_scheme_register(ewk_context, uri_handlers[i].handle,
+ generic_url_scheme_request_cb, uri_handlers[i].handler);
+
+ ewk_context_uri_scheme_register(ewk_context, "about:", about_url_scheme_request_cb, NULL);
+}
+
diff --git a/src/callbacks.h b/src/callbacks.h
@@ -1,6 +1,7 @@
void setup_buffer_callbacks(Buffer_Data*);
void setup_window_callbacks(Window_Data*);
+void setup_url_scheme_callbacks(Ewk_Context*);
/*
static Eina_Bool webview_mimetype_cb(WebKitWebView *webview, WebKitWebFrame *frame, WebKitNetworkRequest *request, char *mime_type, WebKitWebPolicyDecision *decision, gpointer user_data);
diff --git a/src/main.c b/src/main.c
@@ -17,6 +17,7 @@
#include "viking_state.h"
#include "viking.h"
#include "utilities.h"
+#include "callbacks.h"
@@ -170,11 +171,6 @@ session_restore(App_Data *ad)
return !!n_tabs;
}
-static URIHandler uri_handlers[] = {
- { "mailto:", "x-terminal-emulator -e mutt %s" },
- { "ftp://", "x-terminal-emulator -e wget ftp://%s" },
-};
-
/* search engines */
static Searchengine searchengines[] = {
{ "d", "https://duckduckgo.com/?q=%s&t=Vimprobable" },
@@ -347,7 +343,7 @@ elm_main(int argc, char *argv[])
ERR("Could not register session save timer");
make_searchengines_list(searchengines, LENGTH(searchengines));
- make_uri_handlers_list(uri_handlers, LENGTH(uri_handlers));
+ setup_url_scheme_callbacks(ewk_context);
setup_modkeys(ad);
ad->config = config;
diff --git a/src/utilities.c b/src/utilities.c
@@ -31,7 +31,7 @@
// static Eina_Bool complete_case_sensitive = TRUE;
// extern char *config_base;
-static Eina_List *dynamic_searchengines = NULL, *dynamic_uri_handlers = NULL;
+static Eina_List *dynamic_searchengines = NULL;
void parse(const char *buf);
@@ -933,7 +933,7 @@ read_rcfile(const char *config, void *data)
}
newhandler->handle = strdup(buffer);
newhandler->handler = strdup(buffer+index);
- dynamic_uri_handlers = eina_list_prepend(dynamic_uri_handlers, newhandler);
+ // dynamic_uri_handlers = eina_list_prepend(dynamic_uri_handlers, newhandler);
} else {
if (!process_line(s, data))
found_malformed_lines = TRUE;
@@ -943,14 +943,6 @@ read_rcfile(const char *config, void *data)
return found_malformed_lines ? SYNTAX_ERROR : SUCCESS;
}
-void make_uri_handlers_list(URIHandler *uri_handlers, int length)
-{
- int i;
- for (i = 0; i < length; i++, uri_handlers++) {
- dynamic_uri_handlers = eina_list_prepend(dynamic_uri_handlers, uri_handlers);
- }
-}
-
Eina_Bool
open_handler(char *uri) {
/*