Commit 0cd56800 authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan
Browse files

Fixed bug 2602, Integrate gnome-vfs http proxy setting into Mozilla

2000-09-29  Gene Z. Ragan  <gzr@eazel.com>

	Fixed bug 2602, Integrate gnome-vfs http proxy setting into Mozilla
	component.

	* components/mozilla/Makefile.am:
	* components/mozilla/nautilus-mozilla-content-view.c:
	(nautilus_mozilla_content_view_initialize):
	Check for proxy settings and init mozilla to use them.

	Fixed bug 2692, Need to let user specify a proxy for Mozilla
	component.

	* libnautilus-extensions/nautilus-global-preferences.c:
	(use_proxy_changed), (proxy_changed),
	(global_preferences_register):

	When the Nautilus preferences mechanism supports system wide settings,
	we should revisit this code and remove the gconf system prefs retrieval
	code.
parent 5fb02ce1
2000-09-29 Gene Z. Ragan <gzr@eazel.com>
Fixed bug 2602, Integrate gnome-vfs http proxy setting into Mozilla
component.
* components/mozilla/Makefile.am:
* components/mozilla/nautilus-mozilla-content-view.c:
(nautilus_mozilla_content_view_initialize):
Check for proxy settings and init mozilla to use them.
Fixed bug 2692, Need to let user specify a proxy for Mozilla
component.
* libnautilus-extensions/nautilus-global-preferences.c:
(use_proxy_changed), (proxy_changed),
(global_preferences_register):
When the Nautilus preferences mechanism supports system wide settings,
we should revisit this code and remove the gconf system prefs retrieval
code.
2000-09-29 Andy Hertzfeld <andy@eazel.com>
* libnautilus-extensions/nautilus-thumbnails.c:
......
......@@ -14,6 +14,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir) \
$(BONOBO_CFLAGS) \
$(GCONF_CFLAGS) \
$(GNOMEUI_CFLAGS) \
$(MOZILLA_COMPONENT_CFLAGS) \
-DMOZILLA_MILESTONE=$(MOZILLA_MILESTONE) \
......@@ -42,6 +43,7 @@ noinst_HEADERS =\
nautilus_mozilla_content_view_LDADD = \
$(top_builddir)/libnautilus/libnautilus.la \
$(BONOBO_LIBS) \
$(GCONF_LIBS) \
$(GNOMEUI_LIBS) \
$(VFS_LIBS) \
$(OAF_LIBS) \
......
......@@ -40,10 +40,13 @@
#include "mozilla-events.h"
#include <bonobo/bonobo-control.h>
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomevfs/gnome-vfs.h>
#include <stdlib.h>
struct NautilusMozillaContentViewDetails {
char *uri;
......@@ -53,6 +56,9 @@ struct NautilusMozillaContentViewDetails {
gboolean got_called_by_nautilus;
};
static const char PROXY_KEY[] = "/system/gnome-vfs/http-proxy";
static const char USE_PROXY_KEY[] = "/system/gnome-vfs/use-http-proxy";
static void nautilus_mozilla_content_view_initialize_class (NautilusMozillaContentViewClass *klass);
static void nautilus_mozilla_content_view_initialize (NautilusMozillaContentView *view);
static void nautilus_mozilla_content_view_destroy (GtkObject *object);
......@@ -127,6 +133,11 @@ static gboolean mozilla_one_time_happenings = FALSE;
static void
nautilus_mozilla_content_view_initialize (NautilusMozillaContentView *view)
{
GConfClient *gconf_client;
GConfError *error = NULL;
char *argv[] = { "nautilus-mozilla-component", NULL };
char *proxy_string = NULL;
view->details = g_new0 (NautilusMozillaContentViewDetails, 1);
view->details->uri = NULL;
......@@ -146,11 +157,38 @@ nautilus_mozilla_content_view_initialize (NautilusMozillaContentView *view)
mozilla_preference_set_boolean ("nglayout.widget.gfxscrollbars", FALSE);
mozilla_preference_set_boolean ("security.checkloaduri", FALSE);
mozilla_preference_set ("general.useragent.misc", "Nautilus");
/* mozilla_preference_set ("network.proxy.http", "proxy"); */
/* mozilla_preference_set_int ("network.proxy.http_port", 80); */
/* mozilla_preference_set_int ("network.proxy.type", 1); */
/* Locate and set proxy preferences */
if (gconf_init (1, argv, &error)) {
gconf_client = gconf_client_get_default ();
if (gconf_client != NULL) {
if (gconf_client_get_bool (gconf_client, USE_PROXY_KEY, &error)) {
proxy_string = gconf_client_get_string (gconf_client, PROXY_KEY, &error);
if (proxy_string != NULL) {
char *proxy, *port;
port = strchr (proxy_string, ':');
if (port != NULL) {
proxy = g_strdup (proxy_string);
proxy [port - proxy_string] = '\0';
port++;
mozilla_preference_set ("network.proxy.http", proxy);
mozilla_preference_set_int ("network.proxy.http_port", atoi (port));
/* 1, Configure proxy settings manually */
mozilla_preference_set_int ("network.proxy.type", 1);
g_free (proxy_string);
g_free (proxy);
}
}
} else {
/* Default is 3, which conects to internet hosts directly */
mozilla_preference_set_int ("network.proxy.type", 3);
}
gtk_object_unref (GTK_OBJECT (gconf_client));
}
}
/*
* For M17, we register a necko protocol handler to deal with eazel: uris
*/
......
......@@ -34,6 +34,8 @@
#include "nautilus-string.h"
#include "nautilus-user-level-manager.h"
#include "nautilus-view-identifier.h"
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
#include <gtk/gtkbox.h>
#include <liboaf/liboaf.h>
......@@ -43,6 +45,9 @@
/* default web search uri - this will soon be changed to point to our service */
#define DEFAULT_SEARCH_WEB_URI "http://www.google.com"
static const char PROXY_KEY[] = "/system/gnome-vfs/http-proxy";
static const char USE_PROXY_KEY[] = "/system/gnome-vfs/use-http-proxy";
/* Forward declarations */
static char * global_preferences_get_sidebar_panel_key (const char *panel_iid);
static gboolean global_preferences_is_sidebar_panel_enabled_cover (gpointer data,
......@@ -678,6 +683,40 @@ global_preferences_register_speed_tradeoff_with_defaults (const char *name
}
/* These three callbacks should go away in the future when we can handle system wide prefs */
static void
use_proxy_changed (gpointer user_data)
{
gboolean use_proxy;
use_proxy = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_HTTP_USE_PROXY, FALSE);
}
static void
proxy_changed (gpointer user_data)
{
char *proxy, *port, *new_proxy;
proxy = nautilus_preferences_get (NAUTILUS_PREFERENCES_HTTP_PROXY, "");
port = nautilus_preferences_get (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT, "");
new_proxy = g_strdup_printf ("%s:%s", proxy, port);
nautilus_preferences_set (PROXY_KEY, new_proxy);
if (proxy != NULL) {
g_free (proxy);
}
if (port != NULL) {
g_free (port);
}
if (new_proxy != NULL) {
g_free (new_proxy);
}
}
/**
* global_preferences_register
*
......@@ -898,24 +937,68 @@ global_preferences_register (void)
}
{
gboolean use_proxy;
char *proxy_string, *port, *proxy;
GConfClient *gconf_client;
GConfError *error = NULL;
use_proxy = FALSE;
proxy = NULL;
port = NULL;
proxy_string = NULL;
gconf_client = gconf_client_get_default ();
if (gconf_client != NULL) {
/* Get system level proxy values from gconf */
use_proxy = gconf_client_get_bool (gconf_client, USE_PROXY_KEY, &error);
proxy_string = gconf_client_get_string (gconf_client, PROXY_KEY, &error);
if (proxy_string != NULL) {
port = strchr (proxy_string, ':');
if (port != NULL) {
proxy = g_strdup (proxy_string);
proxy [port - proxy_string] = '\0';
port++;
}
}
gtk_object_unref (GTK_OBJECT (gconf_client));
}
nautilus_preferences_set_boolean (NAUTILUS_PREFERENCES_HTTP_USE_PROXY, use_proxy);
nautilus_preferences_set (NAUTILUS_PREFERENCES_HTTP_PROXY, proxy);
nautilus_preferences_set (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT, port);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_HTTP_USE_PROXY,
_("Use HTTP Proxy"),
FALSE,
FALSE,
FALSE);
use_proxy,
use_proxy,
use_proxy);
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_HTTP_PROXY,
_("HTTP Proxy"),
"",
"",
"");
proxy,
proxy,
proxy);
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT,
_("HTTP Proxy Port"),
"",
"",
"");
port,
port,
port);
if (proxy != NULL) {
g_free (proxy);
}
if (proxy_string != NULL) {
g_free (proxy_string);
}
/* Add a callbacks to update the system setting with the new local setting. This should go away when the
* prefs mechanism can handle system wide prefs.
*/
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HTTP_USE_PROXY, use_proxy_changed, NULL);
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HTTP_PROXY, proxy_changed, NULL);
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT, proxy_changed, NULL);
}
}
......
......@@ -34,6 +34,8 @@
#include "nautilus-string.h"
#include "nautilus-user-level-manager.h"
#include "nautilus-view-identifier.h"
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
#include <gtk/gtkbox.h>
#include <liboaf/liboaf.h>
......@@ -43,6 +45,9 @@
/* default web search uri - this will soon be changed to point to our service */
#define DEFAULT_SEARCH_WEB_URI "http://www.google.com"
static const char PROXY_KEY[] = "/system/gnome-vfs/http-proxy";
static const char USE_PROXY_KEY[] = "/system/gnome-vfs/use-http-proxy";
/* Forward declarations */
static char * global_preferences_get_sidebar_panel_key (const char *panel_iid);
static gboolean global_preferences_is_sidebar_panel_enabled_cover (gpointer data,
......@@ -678,6 +683,40 @@ global_preferences_register_speed_tradeoff_with_defaults (const char *name
}
/* These three callbacks should go away in the future when we can handle system wide prefs */
static void
use_proxy_changed (gpointer user_data)
{
gboolean use_proxy;
use_proxy = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_HTTP_USE_PROXY, FALSE);
}
static void
proxy_changed (gpointer user_data)
{
char *proxy, *port, *new_proxy;
proxy = nautilus_preferences_get (NAUTILUS_PREFERENCES_HTTP_PROXY, "");
port = nautilus_preferences_get (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT, "");
new_proxy = g_strdup_printf ("%s:%s", proxy, port);
nautilus_preferences_set (PROXY_KEY, new_proxy);
if (proxy != NULL) {
g_free (proxy);
}
if (port != NULL) {
g_free (port);
}
if (new_proxy != NULL) {
g_free (new_proxy);
}
}
/**
* global_preferences_register
*
......@@ -898,24 +937,68 @@ global_preferences_register (void)
}
{
gboolean use_proxy;
char *proxy_string, *port, *proxy;
GConfClient *gconf_client;
GConfError *error = NULL;
use_proxy = FALSE;
proxy = NULL;
port = NULL;
proxy_string = NULL;
gconf_client = gconf_client_get_default ();
if (gconf_client != NULL) {
/* Get system level proxy values from gconf */
use_proxy = gconf_client_get_bool (gconf_client, USE_PROXY_KEY, &error);
proxy_string = gconf_client_get_string (gconf_client, PROXY_KEY, &error);
if (proxy_string != NULL) {
port = strchr (proxy_string, ':');
if (port != NULL) {
proxy = g_strdup (proxy_string);
proxy [port - proxy_string] = '\0';
port++;
}
}
gtk_object_unref (GTK_OBJECT (gconf_client));
}
nautilus_preferences_set_boolean (NAUTILUS_PREFERENCES_HTTP_USE_PROXY, use_proxy);
nautilus_preferences_set (NAUTILUS_PREFERENCES_HTTP_PROXY, proxy);
nautilus_preferences_set (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT, port);
global_preferences_register_boolean_with_defaults (NAUTILUS_PREFERENCES_HTTP_USE_PROXY,
_("Use HTTP Proxy"),
FALSE,
FALSE,
FALSE);
use_proxy,
use_proxy,
use_proxy);
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_HTTP_PROXY,
_("HTTP Proxy"),
"",
"",
"");
proxy,
proxy,
proxy);
global_preferences_register_string_with_defaults (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT,
_("HTTP Proxy Port"),
"",
"",
"");
port,
port,
port);
if (proxy != NULL) {
g_free (proxy);
}
if (proxy_string != NULL) {
g_free (proxy_string);
}
/* Add a callbacks to update the system setting with the new local setting. This should go away when the
* prefs mechanism can handle system wide prefs.
*/
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HTTP_USE_PROXY, use_proxy_changed, NULL);
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HTTP_PROXY, proxy_changed, NULL);
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HTTP_PROXY_PORT, proxy_changed, NULL);
}
}
......
......@@ -38,6 +38,10 @@
#include "nautilus-shell.h"
#include "nautilus-main.h"
#include <bonobo.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
#include <libgnomeui/gnome-messagebox.h>
#include <libgnomeui/gnome-stock.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
#include <libnautilus-extensions/nautilus-icon-factory.h>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment