commit b59d6806a0db4e60201fdd38f122d258fae2429a
parent fb5d8f910e1ae1a38eb5b94aa318e1913f3572ba
Author: Kyle Milz <kmilz@ucalgary.ca>
Date: Mon, 24 Sep 2012 15:11:39 -0600
implement per buffer inspector and proxy settings
each buffer now remembers if its inspector was showing and if a proxy
was set.
this is useful accross multi buffer browsing as you can have
inspectors/proxies only on the buffers you need them for.
Diffstat:
M | commands.c | | | 95 | +++++++++++++++++++++++++++++++++---------------------------------------------- |
M | config.h | | | 2 | +- |
M | main.c | | | 159 | ++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------- |
M | main.h | | | 9 | ++++++--- |
M | utilities.c | | | 1 | + |
5 files changed, 152 insertions(+), 114 deletions(-)
diff --git a/commands.c b/commands.c
@@ -280,7 +280,7 @@ descend(const Arg *arg, void *data)
{
App_Data *ad = data;
// char *source = (char*)webkit_web_view_get_uri(webview), *p = &source[0], *new;
- const char *source = elm_web_uri_get(ad->current_web);
+ const char *source = elm_web_uri_get(ad->cur_buf->web);
const char *p = &source[0];
char *new;
@@ -312,7 +312,7 @@ descend(const Arg *arg, void *data)
memcpy(new, source, len);
new[len] = '\0';
// webkit_web_view_load_uri(webview, new);
- elm_web_uri_set(ad->current_web, new);
+ elm_web_uri_set(ad->cur_buf->web, new);
free(new);
return TRUE;
}
@@ -355,7 +355,7 @@ input(const Arg *arg, void *data)
*/
elm_entry_entry_set(ad->url, arg->s);
- if (arg->i & InsertCurrentURL && (url = elm_web_uri_get(ad->current_web)))
+ if (arg->i & InsertCurrentURL && (url = elm_web_uri_get(ad->cur_buf->web)))
elm_entry_entry_append(ad->url, url);
elm_object_focus_set(ad->url, EINA_TRUE);
@@ -424,16 +424,16 @@ navigate(const Arg *arg, void *data)
App_Data *ad = data;
if (arg->i & NavigationForwardBack) {
// webkit_web_view_go_back_or_forward(webview, (arg->i == NavigationBack ? -1 : 1) * (count ? count : 1));
- elm_web_navigate(ad->current_web, (arg->i == NavigationBack ? -1 : 1) * (ad->count ? ad->count : 1));
+ elm_web_navigate(ad->cur_buf->web, (arg->i == NavigationBack ? -1 : 1) * (ad->count ? ad->count : 1));
/* hack needed for tiled backing store */
- elm_web_reload(ad->current_web);
+ elm_web_reload(ad->cur_buf->web);
}
else if (arg->i & NavigationReloadActions)
// (arg->i == NavigationReload ? webkit_web_view_reload : webkit_web_view_reload_bypass_cache)(webview);
- (arg->i == NavigationReload ? elm_web_reload : elm_web_reload_full)(ad->current_web);
+ (arg->i == NavigationReload ? elm_web_reload : elm_web_reload_full)(ad->cur_buf->web);
else
// webkit_web_view_stop_loading(webview);
- elm_web_stop(ad->current_web);
+ elm_web_stop(ad->cur_buf->web);
return TRUE;
}
@@ -442,7 +442,7 @@ number(const Arg *arg, void *data)
{
App_Data *ad = data;
// const char *source = webkit_web_view_get_uri(webview);
- const char *source = elm_web_uri_get(ad->current_web);
+ const char *source = elm_web_uri_get(ad->cur_buf->web);
char *uri, *p, *new;
int number, diff = (ad->count ? ad->count : 1) * (arg->i == Increment ? 1 : -1);
@@ -463,7 +463,7 @@ number(const Arg *arg, void *data)
*p = '\0';
new = strdup_printf("%s%d", uri, number); /* create new uri */
// webkit_web_view_load_uri(webview, new);
- elm_web_uri_set(ad->current_web, new);
+ elm_web_uri_set(ad->cur_buf->web, new);
free(new);
free(uri);
return TRUE;
@@ -546,7 +546,7 @@ open_arg(const Arg *arg, void *data)
}
}
// webkit_web_view_load_uri(webview, new);
- elm_web_uri_set(ad->current_web, new);
+ elm_web_uri_set(ad->cur_buf->web, new);
free(new);
} else {
Buffer_Data *td = buffer_add(ad);
@@ -638,11 +638,11 @@ tab_quit(const Arg *arg, void *data)
FILE *f;
char *filename;
App_Data *ad = data;
- if (!ad->current_web)
+ if (!ad->cur_buf->web)
return EINA_TRUE;
// const char *uri = webkit_web_view_get_uri(webview);
- const char *uri = elm_web_uri_get(ad->current_web);
+ const char *uri = elm_web_uri_get(ad->cur_buf->web);
if (uri != NULL) {
/* write last URL into status file for recreation with "u" */
filename = strdup_printf(CLOSED_URL_FILENAME);
@@ -654,7 +654,7 @@ tab_quit(const Arg *arg, void *data)
}
}
- evas_object_del(ad->current_web);
+ evas_object_del(ad->cur_buf->web);
// elm_naviframe_item_pop(ad->naviframe);
// Elm_Object_Item *obj_item = elm_naviframe_top_item_get(ad->naviframe);
// if (obj_item) ad->current_web = elm_object_item_widget_get(obj_item);
@@ -730,11 +730,11 @@ search(const Arg *arg, void *data)
direction ^= ad->search_direction;
do {
// success = webkit_web_view_search_text(webview, search_handle, arg->i & CaseSensitive, direction, FALSE);
- success = elm_web_text_search(ad->current_web, ad->search_handle, arg->i & CaseSensitive, direction, FALSE);
+ success = elm_web_text_search(ad->cur_buf->web, ad->search_handle, arg->i & CaseSensitive, direction, FALSE);
if (!success) {
if (arg->i & Wrapping) {
// success = webkit_web_view_search_text(webview, search_handle, arg->i & CaseSensitive, direction, TRUE);
- success = elm_web_text_search(ad->current_web, ad->search_handle, arg->i & CaseSensitive, direction, EINA_TRUE);
+ success = elm_web_text_search(ad->cur_buf->web, ad->search_handle, arg->i & CaseSensitive, direction, EINA_TRUE);
if (success) {
a.i = Warning;
a.s = strdup_printf("search hit %s, continuing at %s",
@@ -768,12 +768,12 @@ set(const Arg *arg, void *data)
if (ad->search_handle) {
ad->search_handle = NULL;
// webkit_web_view_unmark_text_matches(webview);
- elm_web_text_matches_unmark_all(ad->current_web);
+ elm_web_text_matches_unmark_all(ad->cur_buf->web);
}
// gtk_entry_set_text(GTK_ENTRY(inputbox), "");
// gtk_widget_grab_focus(GTK_WIDGET(webview));
elm_entry_entry_set(ad->url, "");
- elm_object_focus_set(ad->current_web, EINA_TRUE);
+ elm_object_focus_set(ad->cur_buf->web, EINA_TRUE);
break;
case ModePassThrough:
a.s = strdup("-- PASS THROUGH --");
@@ -874,8 +874,7 @@ script(const Arg *arg, void *data)
// WebKitNetworkRequest *request;
// WebKitDownload *download;
App_Data *ad = data;
- Evas_Object *view = elm_web_webkit_view_get(ad->current_web);
- Evas_Object *frame = ewk_view_frame_main_get(view);
+ Evas_Object *frame = ewk_view_frame_main_get(ad->cur_buf->view);
if (!arg->s) {
set_error("Missing argument.", data);
@@ -963,8 +962,7 @@ scroll(const Arg *arg, void *data)
float val;
Eina_Bool horizontal = EINA_FALSE;
App_Data *ad = data;
- Evas_Object *view = elm_web_webkit_view_get(ad->current_web);
- Evas_Object *frame = ewk_view_frame_main_get(view);
+ Evas_Object *frame = ewk_view_frame_main_get(ad->cur_buf->view);
ewk_frame_visible_content_geometry_get(frame, EINA_FALSE, &x, &y, &page_w, &page_h);
ewk_frame_scroll_pos_get(frame, &x, &y);
@@ -1015,9 +1013,9 @@ zoom(const Arg *arg, void *data)
// webkit_web_view_set_full_content_zoom(webview, (arg->i & ZoomFullContent) > 0);
// webkit_web_view_set_zoom_level(ad->current_tab->web, (arg->i & ZoomOut) ?
- elm_web_zoom_set(ad->current_web, (arg->i & ZoomOut) ?
+ elm_web_zoom_set(ad->cur_buf->web, (arg->i & ZoomOut) ?
// webkit_web_view_get_zoom_level(webview) +
- elm_web_zoom_get(ad->current_web) +
+ elm_web_zoom_get(ad->cur_buf->web) +
(((float)(ad->count ? ad->count : 1)) * (arg->i & (1 << 1) ? 1.0 : -1.0) * ad->zoomstep) :
(ad->count ? (float)ad->count / 100.0 : 1.0));
return TRUE;
@@ -1089,8 +1087,8 @@ bookmark(const Arg *arg, void *data)
FILE *f;
char *filename;
App_Data *ad = data;
- const char *uri = elm_web_uri_get(ad->current_web);
- const char *title = elm_web_title_get(ad->current_web);
+ const char *uri = elm_web_uri_get(ad->cur_buf->web);
+ const char *title = elm_web_title_get(ad->cur_buf->web);
filename = strdup_printf(BOOKMARKS_STORAGE_FILENAME);
f = fopen(filename, "a");
free(filename);
@@ -1166,33 +1164,18 @@ Eina_Bool
proxy(const Arg *arg, void *data)
{
App_Data *ad = data;
- char *proxy_uri, *new;
+ Buffer_Data *bd = ad->cur_buf;
- if (ewk_network_proxy_uri_get()) {
+ if (bd->proxy_enabled) {
printf("proxy off\n");
- ewk_network_proxy_uri_set(NULL);
- } else {
- printf("proxy on .. ");
- proxy_uri = getenv("http_proxy");
- if (proxy_uri == NULL)
- proxy_uri = getenv("HTTP_PROXY");
-
- if (proxy_uri != NULL && 0 < strlen(proxy_uri)) {
- new = strstr(proxy_uri, "http://") ?
- strdup(proxy_uri) : strdup_printf("http://%s", proxy_uri);
-
- printf("success! (%s)\n", new);
- ewk_network_proxy_uri_set(new);
-
- free(new);
- }
- else {
- printf("HTTP_PROXY not set.\n");
- }
+ // ewk_network_proxy_uri_set(NULL);
+ g_object_set(ad->soup_session, "proxy-uri", NULL, NULL);
+ bd->proxy_enabled = EINA_FALSE;
+ } else if (enable_proxy(ad->cur_buf)) {
+ bd->proxy_enabled = EINA_TRUE;
+ elm_web_reload(bd->web);
}
- elm_web_reload(ad->current_web);
-
return EINA_TRUE;
}
@@ -1473,15 +1456,17 @@ Eina_Bool
inspector(const Arg *arg, void *data)
{
App_Data *ad = data;
- Evas_Object *view = elm_web_webkit_view_get(ad->current_web);
+ Buffer_Data *bd = ad->cur_buf;
- if (!ewk_view_web_inspector_view_get(view)) {
- ewk_view_setting_enable_developer_extras_set(view, EINA_TRUE);
- ewk_view_web_inspector_show(view);
+ if (!bd->inspector_enabled) {
+ ewk_view_setting_enable_developer_extras_set(bd->view, EINA_TRUE);
+ ewk_view_web_inspector_show(bd->view);
+ bd->inspector_enabled = EINA_TRUE;
}
- else if (ewk_view_web_inspector_view_get(view)) {
- ewk_view_web_inspector_close(view);
- ewk_view_setting_enable_developer_extras_set(view, EINA_FALSE);
+ else {
+ ewk_view_web_inspector_close(bd->view);
+ bd->inspector_enabled = EINA_FALSE;
+ ewk_view_setting_enable_developer_extras_set(bd->view, EINA_FALSE);
}
return EINA_TRUE;
diff --git a/config.h b/config.h
@@ -79,7 +79,7 @@ static URIHandler uri_handlers[] = {
#define USER_STYLESHEET "%s/evi/style.css", config_base
/* ssl */
-// static Eina_Bool strict_ssl = TRUE; /* FALSE will accept any SSL certificate at face value */
+static Eina_Bool strict_ssl = TRUE; /* FALSE will accept any SSL certificate at face value */
static char ca_bundle[MAX_SETTING_SIZE] = "/etc/ssl/certs/ca-certificates.crt";
/* proxy */
diff --git a/main.c b/main.c
@@ -12,6 +12,7 @@
#include <Elementary.h>
#include <EWebKit.h>
+#include <libsoup/soup.h>
#include "javascript.h"
#include "viking.h"
@@ -77,6 +78,38 @@ void download_complete_cb(void*, const char*, int);
int download_progress_cb(void*, const char*, long int, long int, long int, long int);
+Eina_Bool
+enable_proxy(Buffer_Data *bd)
+{
+ SoupURI *soup_uri;
+ char *proxy_uri, *new;
+
+ printf("trying to enable proxy .. ");
+
+ proxy_uri = getenv("http_proxy");
+ if (proxy_uri == NULL)
+ proxy_uri = getenv("HTTP_PROXY");
+
+ if (proxy_uri != NULL && 0 < strlen(proxy_uri)) {
+ new = strstr(proxy_uri, "http://") ?
+ strdup(proxy_uri) : strdup_printf("http://%s", proxy_uri);
+
+ soup_uri = soup_uri_new(new);
+ g_object_set(bd->app->soup_session, "proxy-uri", soup_uri, NULL);
+
+ printf("success! (%s)\n", new);
+ bd->proxy_enabled = EINA_TRUE;
+
+ soup_uri_free(soup_uri);
+ free(new);
+ return EINA_TRUE;
+ }
+ else {
+ printf("HTTP_PROXY not set.\n");
+ return EINA_FALSE;
+ }
+}
+
static void
ascii_bar(int total, int state, char *string)
{
@@ -95,7 +128,7 @@ update_state(void *data)
{
// char *markup;
App_Data *ad = data;
- Evas_Object *view = elm_web_webkit_view_get(ad->current_web);
+ Evas_Object *view = ad->cur_buf->view;
Evas_Object *frame = ewk_view_frame_main_get(view);
int download_count = eina_hash_population(ad->downloads);
// GString *status = g_string_new("");
@@ -156,7 +189,7 @@ update_state(void *data)
}
/* put a notification if we are zoomed */
- double zoom = elm_web_zoom_get(ad->current_web);
+ double zoom = elm_web_zoom_get(ad->cur_buf->web);
if (zoom != 1) {
char *zoom_str = strdup_printf(" %0.2lfx", zoom);
strcat(status, zoom_str);
@@ -205,13 +238,11 @@ update_url(const char *uri, void *data)
if (uri == NULL)
return;
- // Evas_Object *view, *frame;
App_Data *ad = data;
- Eina_Bool back = elm_web_back_possible_get(ad->current_web);
- Eina_Bool fwd = elm_web_forward_possible_get(ad->current_web);
+ Eina_Bool back = elm_web_back_possible_get(ad->cur_buf->web);
+ Eina_Bool fwd = elm_web_forward_possible_get(ad->cur_buf->web);
- Evas_Object *view = elm_web_webkit_view_get(ad->current_web);
- Evas_Object *frame = ewk_view_frame_main_get(view);
+ Evas_Object *frame = ewk_view_frame_main_get(ad->cur_buf->view);
char *url_color = "#FFF";
if (!strncmp(uri, "https://", 8)) {
@@ -296,7 +327,6 @@ webview_inspector_cb(void *data, Evas_Object *obj, void *event_info)
{
Buffer_Data *td = data;
App_Data *ad = td->app;
- Evas_Object *view = elm_web_webkit_view_get(td->web);
td->web_inspector = ewk_view_single_add(evas_object_evas_get(ad->win));
ewk_view_theme_set(td->web_inspector, "/usr/share/ewebkit-0/themes/default.edj");
@@ -304,15 +334,28 @@ webview_inspector_cb(void *data, Evas_Object *obj, void *event_info)
evas_object_size_hint_weight_set(td->web_inspector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(td->web_inspector, EVAS_HINT_FILL, EVAS_HINT_FILL);
- ewk_view_web_inspector_view_set(view, td->web_inspector);
+ ewk_view_web_inspector_view_set(td->view, td->web_inspector);
evas_object_show(td->web_inspector);
elm_box_pack_end(ad->web_inspector, td->web_inspector);
- evas_object_size_hint_weight_set(ad->web_inspector, EVAS_HINT_EXPAND, 1.0);
+ evas_object_size_hint_weight_set(ad->web_inspector, EVAS_HINT_EXPAND, 0.66);
evas_object_show(ad->web_inspector);
- td->inspector_enabled = EINA_TRUE;
+ /*
+ td->web_inspector = elm_web_add(ad->win);
+
+ evas_object_size_hint_weight_set(td->web_inspector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(td->web_inspector, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ ewk_view_web_inspector_view_set(view, elm_web_webkit_view_get(td->web_inspector));
+
+ evas_object_show(td->web_inspector);
+ elm_box_pack_end(ad->web_inspector, td->web_inspector);
+
+ evas_object_size_hint_weight_set(ad->web_inspector, EVAS_HINT_EXPAND, 1.0);
+ evas_object_show(ad->web_inspector);
+ */
}
static void
@@ -320,15 +363,12 @@ webview_inspector_close_cb(void *data, Evas_Object *obj, void *event_info)
{
Buffer_Data *td = data;
App_Data *ad = td->app;
- Evas_Object *view = elm_web_webkit_view_get(td->web);
- ewk_view_setting_enable_developer_extras_set(view, EINA_FALSE);
elm_box_clear(ad->web_inspector);
evas_object_size_hint_weight_set(ad->web_inspector, EVAS_HINT_EXPAND, 0.0);
- ewk_view_web_inspector_view_set(view, NULL);
+ ewk_view_web_inspector_view_set(td->view, NULL);
td->web_inspector = NULL;
- td->inspector_enabled = EINA_FALSE;
}
void
@@ -338,7 +378,7 @@ webview_uri_changed_cb(void *data, Evas_Object *obj, void *event_info)
Buffer_Data *td = data;
const char *uri = event_info;
- if (td->web != td->app->current_web)
+ if (td->web != td->app->cur_buf->web)
return;
// userscript_hooks_start(elm_web_uri_get(td->web));
@@ -379,8 +419,8 @@ history(void *data)
// const char *uri = webkit_web_view_get_uri(webview);
// const char *title = webkit_web_view_get_title(webview);
App_Data *ad = data;
- const char *uri = elm_web_uri_get(ad->current_web);
- const char *title = elm_web_title_get(ad->current_web);
+ const char *uri = elm_web_uri_get(ad->cur_buf->web);
+ const char *title = elm_web_title_get(ad->cur_buf->web);
char *entry, buffer[512], *new;
int n, i = 0;
Eina_Bool finished = EINA_FALSE;
@@ -869,11 +909,11 @@ inputbox_activate_cb(void *data, Evas_Object *obj, void *event_info)
process_line((text + 1), data);
} else if (length > 1 && ((forward = text[0] == '/') || text[0] == '?')) {
// webkit_web_view_unmark_text_matches(webview);
- elm_web_text_matches_unmark_all(ad->current_web);
+ elm_web_text_matches_unmark_all(ad->cur_buf->web);
// webkit_web_view_mark_text_matches(webview, &text[1], FALSE, 0);
// webkit_web_view_set_highlight_text_matches(webview, TRUE);
- elm_web_text_matches_mark(ad->current_web, &text[1], EINA_FALSE, EINA_TRUE, 0);
+ elm_web_text_matches_mark(ad->cur_buf->web, &text[1], EINA_FALSE, EINA_TRUE, 0);
ad->count = 0;
ad->search_direction = forward;
@@ -890,9 +930,10 @@ inputbox_activate_cb(void *data, Evas_Object *obj, void *event_info)
// gtk_entry_set_text(entry, "");
elm_entry_entry_set(ad->url, "");
// gtk_widget_grab_focus(GTK_WIDGET(webview));
+
/* process_line above may have deleted the tab, check if its still around */
- if (ad->current_web)
- elm_object_focus_set(ad->current_web, EINA_TRUE);
+ if (ad->cur_buf->web)
+ elm_object_focus_set(ad->cur_buf->web, EINA_TRUE);
}
static Eina_Bool
@@ -1055,8 +1096,7 @@ inputmethod_changed_cb(void *data, Evas_Object *obj, void *event_info)
Eina_Bool *enabled = event_info;
Buffer_Data *td = data;
App_Data *ad = td->app;
- Evas_Object *view = elm_web_webkit_view_get(td->web);
- Evas_Object *frame = ewk_view_frame_main_get(view);
+ Evas_Object *frame = ewk_view_frame_main_get(td->view);
if (ad->mode == ModeNormal && enabled) {
Arg a = { .i = ModeInsert };
@@ -1196,10 +1236,10 @@ inputbox_changed_cb(void *data, Evas_Object *obj, void *event_info)
// if (gtk_widget_is_focus(GTK_WIDGET(entry)) && length > 1 && ((forward = text[0] == '/') || text[0] == '?')) {
if (elm_object_focus_get(ad->url) && length > 1 && ((forward = text[0] == '/') || text[0] == '?')) {
// webkit_web_view_unmark_text_matches(webview);
- elm_web_text_matches_unmark_all(ad->current_web);
+ elm_web_text_matches_unmark_all(ad->cur_buf->web);
// webkit_web_view_search_text(webview, &text[1], searchoptions & CaseSensitive, forward, searchoptions & Wrapping);
- elm_web_text_search(ad->current_web, &text[1], EINA_TRUE, forward, EINA_FALSE);
+ elm_web_text_search(ad->cur_buf->web, &text[1], EINA_TRUE, forward, EINA_FALSE);
return;
// } else if (gtk_widget_is_focus(GTK_WIDGET(entry)) && length >= 1 &&
} else if (elm_object_focus_get(ad->url) && length >= 1 &&
@@ -1285,33 +1325,37 @@ _win_del_request_cb(void *data, Evas_Object *obj, void *event_info)
}
void
-buffer_current_set(Buffer_Data *td)
+buffer_current_set(Buffer_Data *new_buf)
{
- App_Data *ad = td->app;
- // const char *uri;
- Evas_Object *view;
+ App_Data *ad = new_buf->app;
+ Buffer_Data *old_buf = ad->cur_buf;
- if (td->web == td->app->current_web)
+ if (new_buf == old_buf)
return;
- if (ad->current_web) {
- view = elm_web_webkit_view_get(ad->current_web);
- ewk_view_visibility_state_set(view, EWK_PAGE_VISIBILITY_STATE_HIDDEN, 0);
+ if (ad->cur_buf) {
+ ewk_view_visibility_state_set(ad->cur_buf->view, EWK_PAGE_VISIBILITY_STATE_HIDDEN, 0);
+ if (ad->cur_buf->inspector_enabled)
+ ewk_view_web_inspector_close(ad->cur_buf->view);
+ if (ad->cur_buf->proxy_enabled)
+ g_object_set(ad->soup_session, "proxy-uri", NULL, NULL);
}
- ad->current_web = td->web;
+ ad->cur_buf = new_buf;
- if (ad->current_web) {
- view = elm_web_webkit_view_get(ad->current_web);
- ewk_view_visibility_state_set(view, EWK_PAGE_VISIBILITY_STATE_VISIBLE, 0);
- }
-
- // uri = elm_web_uri_get(td->web);
- update_url(elm_web_uri_get(td->web), td->app);
- // elm_object_text_set(td->app->url, uri);
- // if (uri) update_url(uri, td->app);
+ if (ad->cur_buf) {
+ ewk_view_visibility_state_set(ad->cur_buf->view, EWK_PAGE_VISIBILITY_STATE_VISIBLE, 0);
+ if (ad->cur_buf->inspector_enabled) {
+ printf("re-enabling inspector ..\n");
+ ewk_view_setting_enable_developer_extras_set(ad->cur_buf->view, EINA_TRUE);
+ ewk_view_web_inspector_show(ad->cur_buf->view);
+ }
- elm_naviframe_item_simple_promote(td->app->naviframe, td->web);
+ update_url(elm_web_uri_get(ad->cur_buf->web), ad);
+ elm_naviframe_item_simple_promote(ad->naviframe, ad->cur_buf->web);
+ if (ad->cur_buf->proxy_enabled)
+ enable_proxy(ad->cur_buf);
+ }
}
static void
@@ -1322,7 +1366,7 @@ _web_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
elm_naviframe_item_pop(ad->naviframe);
if (!ad->exiting)
- ad->current_web = NULL;
+ ad->cur_buf->web = NULL;
ad->buffer_list = eina_list_remove(ad->buffer_list, td);
@@ -1347,6 +1391,8 @@ buffer_add(App_Data *ad)
td->web = elm_web_add(ad->win);
td->buf_number = ad->buf_total;
td->inspector_enabled = EINA_FALSE;
+ td->proxy_enabled = EINA_FALSE;
+ td->view = elm_web_webkit_view_get(td->web);
ad->buffer_list = eina_list_append(ad->buffer_list, td);
@@ -1358,7 +1404,6 @@ buffer_add(App_Data *ad)
elm_web_inwin_mode_set(td->web, EINA_TRUE);
evas_object_size_hint_weight_set(td->web, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(td->web, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
elm_naviframe_item_simple_push(ad->naviframe, td->web);
evas_object_data_set(td->web, "buffer_data", td);
@@ -1375,13 +1420,12 @@ buffer_add(App_Data *ad)
evas_object_smart_callback_add(td->web, "link,hover,out", webview_hoverlink_out_cb, td);
evas_object_smart_callback_add(td->web, "inputmethod,changed", inputmethod_changed_cb, td);
- Evas_Object *view = elm_web_webkit_view_get(td->web);
-
- evas_object_smart_callback_add(view, "inspector,view,create", webview_inspector_cb, td);
- evas_object_smart_callback_add(view, "inspector,view,close", webview_inspector_close_cb, td);
- evas_object_smart_callback_add(view, "protocolhandler,isregistered", protocol_register_cb, td);
- evas_object_smart_callback_add(view, "icon,received", icon_received_cb, td);
- evas_object_smart_callback_add(view, "xss,detected", xss_detected_cb, td);
+ /* these signals are not offered by elm_web */
+ evas_object_smart_callback_add(td->view, "inspector,view,create", webview_inspector_cb, td);
+ evas_object_smart_callback_add(td->view, "inspector,view,close", webview_inspector_close_cb, td);
+ evas_object_smart_callback_add(td->view, "protocolhandler,isregistered", protocol_register_cb, td);
+ evas_object_smart_callback_add(td->view, "icon,received", icon_received_cb, td);
+ evas_object_smart_callback_add(td->view, "xss,detected", xss_detected_cb, td);
evas_object_event_callback_add(td->web, EVAS_CALLBACK_FREE, _web_free_cb, td);
evas_object_event_callback_add(td->web, EVAS_CALLBACK_KEY_DOWN, webview_keypress_cb, td);
@@ -1435,7 +1479,7 @@ elm_main(int argc, char *argv[])
evas_object_smart_callback_add(win, "delete,request", _win_del_request_cb, ad);
- ewk_network_tls_ca_certificates_path_set(ca_bundle);
+ // ewk_network_tls_ca_certificates_path_set(ca_bundle);
ewk_settings_icon_database_path_set("./");
ewk_settings_application_cache_path_set("./");
ewk_settings_shadow_dom_enable_set(EINA_TRUE);
@@ -1520,6 +1564,11 @@ elm_main(int argc, char *argv[])
ad->status_state = status_state;
ad->event_box = event_box;
ad->web_inspector = web_inspector;
+ ad->soup_session = ewk_network_default_soup_session_get();
+
+ g_object_set(G_OBJECT(ad->soup_session), "ssl-ca-file", ca_bundle, NULL);
+ g_object_set(G_OBJECT(ad->soup_session), "ssl-strict", strict_ssl, NULL);
+
ad->buf_total = 0;
diff --git a/main.h b/main.h
@@ -49,9 +49,8 @@ typedef struct
Eina_List *commandhistory;
int commandpointer;
- // SoupSession *session;
-
- Evas_Object *current_web;
+ SoupSession *soup_session;
+ Buffer_Data *cur_buf;
Eina_Bool exiting : 1;
} App_Data;
@@ -59,11 +58,14 @@ typedef struct
struct _Buffer_Data
{
Evas_Object *web;
+ Evas_Object *view;
App_Data *app;
unsigned int buf_number;
Eina_Bool inspector_enabled;
Evas_Object *web_inspector;
+
+ Eina_Bool proxy_enabled;
};
struct dl {
@@ -75,6 +77,7 @@ void update_state(void *);
Eina_Bool echo(const Arg *arg, void *);
void buffer_current_set(Buffer_Data *td);
Buffer_Data *buffer_add(App_Data *ad);
+Eina_Bool enable_proxy(Buffer_Data *bd);
#endif
diff --git a/utilities.c b/utilities.c
@@ -9,6 +9,7 @@
#include <Elementary.h>
+#include <libsoup/soup.h>
#include <stdlib.h> /* malloc */
#include <stdarg.h> /* vsnprintf */