drop gnome-vfs dependency (part of bug #524401)
2008-05-16 Jens Granseuer <jensgr@gmx.net> * gnome-network-preferences.c: (get_hostname_from_uri), (extract_proxy_host), (main): drop gnome-vfs dependency (part of bug #524401) svn path=/trunk/; revision=8707
This commit is contained in:
parent
82e738e22d
commit
97cd93b9ef
2 changed files with 51 additions and 16 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2008-05-16 Jens Granseuer <jensgr@gmx.net>
|
||||||
|
|
||||||
|
* gnome-network-preferences.c: (get_hostname_from_uri),
|
||||||
|
(extract_proxy_host), (main): drop gnome-vfs dependency (part of bug
|
||||||
|
#524401)
|
||||||
|
|
||||||
2008-04-06 Denis Washington <denisw@svn.gnome.org>
|
2008-04-06 Denis Washington <denisw@svn.gnome.org>
|
||||||
|
|
||||||
* gnome-network-preferences.glade: rename "Advanced Configuration" tab
|
* gnome-network-preferences.glade: rename "Advanced Configuration" tab
|
||||||
|
|
|
@ -24,10 +24,10 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <libgnome/libgnome.h>
|
#include <libgnome/libgnome.h>
|
||||||
#include <gconf/gconf-client.h>
|
#include <gconf/gconf-client.h>
|
||||||
#include <glade/glade.h>
|
#include <glade/glade.h>
|
||||||
#include <libgnomevfs/gnome-vfs-uri.h>
|
|
||||||
|
|
||||||
#include "capplet-util.h"
|
#include "capplet-util.h"
|
||||||
#include "gconf-property-editor.h"
|
#include "gconf-property-editor.h"
|
||||||
|
@ -336,27 +336,58 @@ cb_use_same_proxy_checkbutton_clicked (GtkWidget *checkbutton,
|
||||||
g_object_unref (client);
|
g_object_unref (client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
get_hostname_from_uri (const gchar *uri)
|
||||||
|
{
|
||||||
|
const gchar *start, *end;
|
||||||
|
gchar *host;
|
||||||
|
|
||||||
|
if (uri == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* skip the scheme part */
|
||||||
|
start = strchr (uri, ':');
|
||||||
|
if (start == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* forward until after the last '/' */
|
||||||
|
do {
|
||||||
|
++start;
|
||||||
|
} while (*start == '/');
|
||||||
|
|
||||||
|
if (*start == '\0')
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* maybe we have a port? */
|
||||||
|
end = strchr (start, ':');
|
||||||
|
if (end == NULL)
|
||||||
|
end = strchr (start, '/');
|
||||||
|
|
||||||
|
if (end != NULL)
|
||||||
|
host = g_strndup (start, end - start);
|
||||||
|
else
|
||||||
|
host = g_strdup (start);
|
||||||
|
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
static GConfValue *
|
static GConfValue *
|
||||||
extract_proxy_host (GConfPropertyEditor *peditor, const GConfValue *orig)
|
extract_proxy_host (GConfPropertyEditor *peditor, const GConfValue *orig)
|
||||||
{
|
{
|
||||||
char const *entered_text = gconf_value_get_string (orig);
|
char const *entered_text = gconf_value_get_string (orig);
|
||||||
GConfValue *res = NULL;
|
GConfValue *res = NULL;
|
||||||
|
|
||||||
if (entered_text != NULL) {
|
if (entered_text != NULL) {
|
||||||
GnomeVFSURI *uri = gnome_vfs_uri_new (entered_text);
|
gchar *host = get_hostname_from_uri (entered_text);
|
||||||
if (uri != NULL) {
|
|
||||||
char const *host = gnome_vfs_uri_get_host_name (uri);
|
if (host != NULL) {
|
||||||
if (host != NULL) {
|
res = gconf_value_new (GCONF_VALUE_STRING);
|
||||||
res = gconf_value_new (GCONF_VALUE_STRING);
|
gconf_value_set_string (res, host);
|
||||||
gconf_value_set_string (res, host);
|
g_free (host);
|
||||||
}
|
|
||||||
gnome_vfs_uri_unref (uri);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != NULL)
|
return (res != NULL) ? res : gconf_value_copy (orig);
|
||||||
return res;
|
|
||||||
return gconf_value_copy (orig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -538,8 +569,6 @@ main (int argc, char **argv)
|
||||||
argc, argv, GNOME_PARAM_NONE);
|
argc, argv, GNOME_PARAM_NONE);
|
||||||
|
|
||||||
client = gconf_client_get_default ();
|
client = gconf_client_get_default ();
|
||||||
gconf_client_add_dir (client, "/system/gnome-vfs",
|
|
||||||
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
|
||||||
gconf_client_add_dir (client, "/system/http_proxy",
|
gconf_client_add_dir (client, "/system/http_proxy",
|
||||||
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
||||||
gconf_client_add_dir (client, "/system/proxy",
|
gconf_client_add_dir (client, "/system/proxy",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue