[sound-juicer] libjuicer: Add support for the "none" proxy mode
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sound-juicer] libjuicer: Add support for the "none" proxy mode
- Date: Wed, 7 May 2014 10:24:19 +0000 (UTC)
commit a7da3e85f7b33722a674f1f225ca3da93f5fbda7
Author: Bastien Nocera <hadess hadess net>
Date: Tue May 6 16:27:16 2014 +0200
libjuicer: Add support for the "none" proxy mode
This stops sound-juicer from using a proxy even when that one is
actually deactivated in the preferences.
https://bugzilla.gnome.org/show_bug.cgi?id=729379
configure.ac | 2 +-
libjuicer/sj-metadata-getter.c | 11 ++++++++++-
libjuicer/sj-metadata-gvfs.c | 9 ++++++++-
libjuicer/sj-metadata-musicbrainz5.c | 22 +++++++++++++++++++---
libjuicer/sj-metadata.c | 22 ++++++++++++++++++++++
5 files changed, 60 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b3ac8bc..f0466fd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,7 +57,7 @@ LIBS="$LIBS $BURN_LIBS"
# LIBS="$oldlibs"
# Find the UI libraries
-PKG_CHECK_MODULES(UI, gtk+-3.0 >= $GTK_REQUIRED gio-2.0 gmodule-export-2.0 libcanberra-gtk3)
+PKG_CHECK_MODULES(UI, gtk+-3.0 >= $GTK_REQUIRED gio-2.0 gmodule-export-2.0 libcanberra-gtk3
gsettings-desktop-schemas)
AC_SUBST(UI_CFLAGS)
AC_SUBST(UI_LIBS)
diff --git a/libjuicer/sj-metadata-getter.c b/libjuicer/sj-metadata-getter.c
index b4a3388..b78c720 100644
--- a/libjuicer/sj-metadata-getter.c
+++ b/libjuicer/sj-metadata-getter.c
@@ -31,6 +31,7 @@
#include "sj-metadata-gvfs.h"
#include "sj-error.h"
+#define SJ_SETTINGS_PROXY_MODE "mode"
#define SJ_SETTINGS_PROXY_HOST "host"
#define SJ_SETTINGS_PROXY_PORT "port"
#define SJ_SETTINGS_PROXY_USE_AUTHENTICATION "use-authentication"
@@ -130,7 +131,9 @@ sj_metadata_getter_set_cdrom (SjMetadataGetter *mdg, const char* device)
static void
bind_http_proxy_settings (SjMetadata *metadata)
{
- GSettings *settings = g_settings_new ("org.gnome.system.proxy.http");
+ GSettings *settings;
+
+ settings = g_settings_new ("org.gnome.system.proxy.http");
/* bind with G_SETTINGS_BIND_GET_NO_CHANGES to avoid occasional
segfaults in g_object_set_property called with an invalid pointer
which I think were caused by the update being scheduled before
@@ -162,6 +165,12 @@ bind_http_proxy_settings (SjMetadata *metadata)
G_SETTINGS_BIND_GET_NO_CHANGES);
g_object_unref (settings);
+
+ settings = g_settings_new ("org.gnome.system.proxy");
+ g_settings_bind (settings, SJ_SETTINGS_PROXY_MODE,
+ metadata, "proxy-mode",
+ G_SETTINGS_BIND_GET_NO_CHANGES);
+ g_object_unref (settings);
}
static gboolean
diff --git a/libjuicer/sj-metadata-gvfs.c b/libjuicer/sj-metadata-gvfs.c
index d2e2aa7..87a0669 100644
--- a/libjuicer/sj-metadata-gvfs.c
+++ b/libjuicer/sj-metadata-gvfs.c
@@ -25,6 +25,7 @@
#include <glib/gi18n.h>
#include <glib.h>
#include <gio/gio.h>
+#include <gdesktop-enums.h>
#include "sj-metadata-gvfs.h"
#include "sj-structures.h"
@@ -45,7 +46,8 @@ enum {
PROP_PROXY_HOST,
PROP_PROXY_PORT,
PROP_PROXY_USERNAME,
- PROP_PROXY_PASSWORD
+ PROP_PROXY_PASSWORD,
+ PROP_PROXY_MODE
};
static void metadata_iface_init (gpointer g_iface, gpointer iface_data);
@@ -193,6 +195,10 @@ sj_metadata_gvfs_get_property (GObject *object, guint property_id,
/* Do nothing */
g_value_set_int (value, 0);
break;
+ case PROP_PROXY_MODE:
+ /* Do nothing */
+ g_value_set_enum (value, G_DESKTOP_PROXY_MODE_NONE);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -217,6 +223,7 @@ sj_metadata_gvfs_set_property (GObject *object, guint property_id,
case PROP_PROXY_PORT:
case PROP_PROXY_USERNAME:
case PROP_PROXY_PASSWORD:
+ case PROP_PROXY_MODE:
/* Do nothing */
break;
default:
diff --git a/libjuicer/sj-metadata-musicbrainz5.c b/libjuicer/sj-metadata-musicbrainz5.c
index cce7503..3991daf 100644
--- a/libjuicer/sj-metadata-musicbrainz5.c
+++ b/libjuicer/sj-metadata-musicbrainz5.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <glib.h>
#include <glib-object.h>
+#include <gdesktop-enums.h>
#include <discid/discid.h>
#include <musicbrainz5/mb5_c.h>
@@ -57,6 +58,7 @@ typedef struct {
char *cdrom;
GHashTable *artist_cache;
/* Proxy */
+ GDesktopProxyMode proxy_mode;
char *proxy_host;
char *proxy_username;
char *proxy_password;
@@ -74,7 +76,8 @@ enum {
PROP_PROXY_HOST,
PROP_PROXY_PORT,
PROP_PROXY_USERNAME,
- PROP_PROXY_PASSWORD
+ PROP_PROXY_PASSWORD,
+ PROP_PROXY_MODE
};
static void metadata_interface_init (gpointer g_iface, gpointer iface_data);
@@ -801,12 +804,16 @@ artist-rels";
static void
setup_http_proxy (SjMetadataMusicbrainz5Private *priv)
{
- if (priv->proxy_host == NULL || priv->proxy_port == 0) {
+ if (priv->proxy_mode == G_DESKTOP_PROXY_MODE_NONE ||
+ priv->proxy_mode == G_DESKTOP_PROXY_MODE_AUTOMATIC ||
+ priv->proxy_host == NULL || priv->proxy_port == 0) {
mb5_query_set_proxyhost (priv->mb, NULL);
mb5_query_set_proxyport (priv->mb, 0);
mb5_query_set_proxyusername (priv->mb, NULL);
mb5_query_set_proxypassword (priv->mb, NULL);
- } else {
+ if (priv->proxy_mode == G_DESKTOP_PROXY_MODE_AUTOMATIC)
+ g_warning ("Automatic proxy mode not supported yet, disabling proxy usage");
+ } else if (priv->proxy_mode == G_DESKTOP_PROXY_MODE_MANUAL) {
mb5_query_set_proxyhost (priv->mb, priv->proxy_host);
mb5_query_set_proxyport (priv->mb, priv->proxy_port);
if (priv->proxy_use_authentication &&
@@ -870,6 +877,9 @@ sj_metadata_musicbrainz5_get_property (GObject *object, guint property_id,
case PROP_PROXY_PASSWORD:
g_value_set_string (value, priv->proxy_password);
break;
+ case PROP_PROXY_MODE:
+ g_value_set_enum (value, priv->proxy_mode);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -911,6 +921,10 @@ sj_metadata_musicbrainz5_set_property (GObject *object, guint property_id,
priv->proxy_password = g_value_dup_string (value);
setup_http_proxy (priv);
break;
+ case PROP_PROXY_MODE:
+ priv->proxy_mode = g_value_get_enum (value);
+ setup_http_proxy (priv);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -964,6 +978,8 @@ sj_metadata_musicbrainz5_class_init (SjMetadataMusicbrainz5Class *class)
PROP_PROXY_USERNAME, "proxy-username");
g_object_class_override_property (object_class,
PROP_PROXY_PASSWORD, "proxy-password");
+ g_object_class_override_property (object_class,
+ PROP_PROXY_MODE, "proxy-mode");
/* Although GLib supports fallback locales we do not use them as
MusicBrainz does not provide locale information for the canonical
diff --git a/libjuicer/sj-metadata.c b/libjuicer/sj-metadata.c
index 7f85d67..e772fa6 100644
--- a/libjuicer/sj-metadata.c
+++ b/libjuicer/sj-metadata.c
@@ -21,6 +21,7 @@
#include <glib/gi18n.h>
#include <stdlib.h>
#include <stdio.h>
+#include <gdesktop-enums.h>
#ifndef USE_TOTEM_PL_PARSER
#include <unistd.h>
@@ -38,6 +39,22 @@ enum {
LAST_SIGNAL
};
+static GType
+g_desktop_proxy_mode_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static const GEnumValue values[] = {
+ { G_DESKTOP_PROXY_MODE_NONE, "G_DESKTOP_PROXY_MODE_NONE", "none" },
+ { G_DESKTOP_PROXY_MODE_MANUAL, "G_DESKTOP_PROXY_MODE_MANUAL", "manual" },
+ { G_DESKTOP_PROXY_MODE_AUTO, "G_DESKTOP_PROXY_MODE_AUTO", "auto" },
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GDesktopProxyMode", values);
+ }
+ return etype;
+}
+
static void
sj_metadata_base_init (gpointer g_iface)
{
@@ -75,6 +92,11 @@ sj_metadata_base_init (gpointer g_iface)
g_param_spec_string ("proxy-password", "proxy-password", NULL, NULL,
G_PARAM_READABLE|G_PARAM_WRITABLE|
G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
+ g_object_interface_install_property (g_iface,
+ g_param_spec_enum ("proxy-mode", "proxy-mode", NULL,
+ g_desktop_proxy_mode_get_type(),
G_DESKTOP_PROXY_MODE_NONE,
+ G_PARAM_READABLE|G_PARAM_WRITABLE|
+
G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
initialized = TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]