svnno****@sourc*****
svnno****@sourc*****
Tue Mar 27 13:23:32 JST 2007
Revision: 3043 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3043 Author: ikezoe Date: 2007-03-27 13:23:31 +0900 (Tue, 27 Mar 2007) Log Message: ----------- * module/embed/gtk-webcore/kz-gtk-webcore.cpp: Set proxy. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-03-27 03:17:20 UTC (rev 3042) +++ kazehakase/trunk/ChangeLog 2007-03-27 04:23:31 UTC (rev 3043) @@ -1,3 +1,7 @@ +2007-03-27 Hiroyuki Ikezoe <poinc****@ikezo*****> + + * module/embed/gtk-webcore/kz-gtk-webcore.cpp: Set proxy. + 2007-03-27 Kouhei Sutou <kou****@cozmi*****> * src/kz-popup-preview.c (kz_popup_preview_get_image): used Modified: kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp =================================================================== --- kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp 2007-03-27 03:17:20 UTC (rev 3042) +++ kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp 2007-03-27 04:23:31 UTC (rev 3043) @@ -30,9 +30,10 @@ #include "kz-embed-prefs.h" #include "kz-embed.h" #include "kz-prompt-dialog.h" +#include "kz-proxy-item.h" #include "gobject-utils.h" -#define GTK_WEBCORE_HAS_MOUSE_DOWN 0 +#define GTK_WEBCORE_HAS_MOUSE_DOWN 1 typedef struct _KzGtkWebcorePrivate KzGtkWebcorePrivate; struct _KzGtkWebcorePrivate @@ -518,6 +519,82 @@ } static void +set_proxy (KzProfile *profile, KzGtkWebcore *gtk_webcore) +{ + gchar tmp_string[1024]; + gchar *http_host, *https_host, *ftp_host; + guint http_port, https_port, ftp_port; + gboolean value = FALSE, use_same_proxy; + KzProxyItem *item = NULL; + + kz_profile_get_value(profile, "Global", "use_proxy", + &value, sizeof(gboolean), + KZ_PROFILE_VALUE_TYPE_BOOL); + if (!value) + return; + + value = kz_profile_get_value(profile, "Global", "proxy_name", + &tmp_string, G_N_ELEMENTS(tmp_string), + KZ_PROFILE_VALUE_TYPE_STRING); + if (!value) + return; + + item = kz_proxy_find(tmp_string); + if (!item) + return; + + g_object_get(G_OBJECT(item), + "use_same_proxy", &use_same_proxy, + NULL); + if (use_same_proxy) + { + g_object_get(G_OBJECT(item), + "http_host", &http_host, + "http_port", &http_port, + NULL); + if (!http_host) + return; + } + else + { + g_object_get(G_OBJECT(item), + "http_host", &http_host, + "http_port", &http_port, + "https_host", &https_host, + "https_port", &https_port, + "ftp_host", &ftp_host, + "ftp_port", &ftp_port, + NULL); + } + + OSB::Root *engine = 0; + OSB::ProtocolDelegate *delegate = 0; + engine = static_cast<OSB::Root*>(webi_get_internal(WEBI(gtk_webcore))); + + /* proxy for HTTP protocol */ + delegate = engine->protocolDelegateForURL("http://"); + if (delegate && http_host) + delegate->setProxy(http_host); + + /* proxy for HTTPS protocol */ + delegate = engine->protocolDelegateForURL("https://"); + if (delegate && https_host) + delegate->setProxy(https_host); + + /* proxy for FTP protocol */ + delegate = engine->protocolDelegateForURL("ftp://"); + if (delegate && ftp_host) + delegate->setProxy(ftp_host); + + if (http_host) + g_free(http_host); + if (https_host) + g_free(https_host); + if (ftp_host) + g_free(ftp_host); +} + +static void set_default_preferences (KzGtkWebcore *gtk_webcore) { KzProfile *profile; @@ -535,6 +612,7 @@ set_user_agent(profile, gtk_webcore); set_font_preferences (profile, preferences); + set_proxy(profile, gtk_webcore); } static void @@ -550,6 +628,7 @@ priv->button_press_time = 0; set_default_preferences(gtk_webcore); + webi_set_emit_internal_status(WEBI(gtk_webcore), TRUE); gtk_widget_show_all(GTK_WIDGET(gtk_webcore)); }