static void
sj_metadata_musicbrainz3_set_property (GObject *object, guint property_id,
                                       const GValue *value, GParamSpec *pspec)
{
  SjMetadataMusicbrainz3Private *priv = GET_PRIVATE (object);
  g_assert (priv);

  switch (property_id) {
  case PROP_DEVICE:
    if (priv->cdrom)
      g_free (priv->cdrom);
    priv->cdrom = g_value_dup_string (value);
    break;
  case PROP_PROXY_HOST:
    if (priv->http_proxy) {
      g_free (priv->http_proxy);
    }
    priv->http_proxy = g_value_dup_string (value);
    /* TODO: check this unsets the proxy if NULL, or should we pass "" ? */
    mb_webservice_set_proxy_host (priv->mb, priv->http_proxy);
    break;
  case PROP_PROXY_PORT:
    priv->http_proxy_port = g_value_get_int (value);
    mb_webservice_set_proxy_port (priv->mb, priv->http_proxy_port);
    break;
  default:
    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
  }
}
static void
sj_metadata_musicbrainz3_init (SjMetadataMusicbrainz3 *self)
{
  GSettings *settings;

  SjMetadataMusicbrainz3Private *priv;

  priv = GET_PRIVATE (self);

  priv->mb = mb_webservice_new ();

  settings = g_settings_new ("org.gnome.system.proxy.http");

#if 0
  gchar *server_name;

  server_name = g_settings_get_string (settings, SJ_SETTINGS_MUSICBRAINZ_SERVER);

  if (server_name && strcmp (server_name, "") != 0) {
    mb_webservice_set_host (priv->mb, server_name);
  }

  g_free (server_name);
#endif

  /* Set the HTTP proxy */
  if (g_settings_get_boolean (settings, SJ_SETTINGS_PROXY_USE_PROXY)) {
    char *proxy_host;
    int port;

    proxy_host = g_settings_get_string (settings, SJ_SETTINGS_PROXY_HOST);
    mb_webservice_set_proxy_host (priv->mb, proxy_host);
    g_free (proxy_host);

    port = g_settings_get_int (settings, SJ_SETTINGS_PROXY_PORT);
    mb_webservice_set_proxy_port (priv->mb, port);

    if (g_settings_get_boolean (settings, SJ_SETTINGS_PROXY_USE_AUTHENTICATION)) {
      char *username, *password;

      username = g_settings_get_string (settings, SJ_SETTINGS_PROXY_USERNAME);
      mb_webservice_set_proxy_username (priv->mb, username);
      g_free (username);

      password = g_settings_get_string (settings, SJ_SETTINGS_PROXY_PASSWORD);
      mb_webservice_set_proxy_password (priv->mb, password);
      g_free (password);
    }
  }

  g_object_unref (settings);
}
static void
sj_metadata_musicbrainz3_init (SjMetadataMusicbrainz3 *self)
{
  GConfClient *gconf_client;
  gchar *server_name;

  SjMetadataMusicbrainz3Private *priv;

  priv = GET_PRIVATE (self);

  priv->mb = mb_webservice_new ();

  gconf_client = gconf_client_get_default ();

  server_name = gconf_client_get_string (gconf_client, GCONF_MUSICBRAINZ_SERVER, NULL);

  if (server_name && strcmp (server_name, "") != 0) {
    mb_webservice_set_host (priv->mb, server_name);
  }

  g_free (server_name);

  /* Set the HTTP proxy */
  if (gconf_client_get_bool (gconf_client, GCONF_PROXY_USE_PROXY, NULL)) {
    char *proxy_host;
    int port;

    proxy_host = gconf_client_get_string (gconf_client, GCONF_PROXY_HOST, NULL);
    mb_webservice_set_proxy_host (priv->mb, proxy_host);
    g_free (proxy_host);

    port = gconf_client_get_int (gconf_client, GCONF_PROXY_PORT, NULL);
    mb_webservice_set_proxy_port (priv->mb, port);

    if (gconf_client_get_bool (gconf_client, GCONF_PROXY_USE_AUTHENTICATION, NULL)) {
      char *username, *password;

      username = gconf_client_get_string (gconf_client, GCONF_PROXY_USERNAME, NULL);
      mb_webservice_set_proxy_username (priv->mb, username);
      g_free (username);

      password = gconf_client_get_string (gconf_client, GCONF_PROXY_PASSWORD, NULL);
      mb_webservice_set_proxy_password (priv->mb, password);
      g_free (password);
    }
  }

  g_object_unref (gconf_client);
}