Index: sj-metadata.h
===================================================================
--- sj-metadata.h	(revision 5874)
+++ sj-metadata.h	(working copy)
@@ -52,16 +52,11 @@
   void         (*metadata) (SjMetadata *md, GList *albums, GError *error);
 
   /* Virtual Table */
-  GError* (*get_new_error) (SjMetadata *metadata);
-  void (*set_cdrom) (SjMetadata *metadata, const char* device);
-  void (*set_proxy) (SjMetadata *metadata, const char* proxy);
-  void (*set_proxy_port) (SjMetadata *metadata, int proxy_port);
   void (*list_albums) (SjMetadata *metadata, GError **error);
   char *(*get_submit_url) (SjMetadata *metadata);
 };
 
 GType sj_metadata_get_type (void);
-GError *sj_metadata_get_new_error (SjMetadata *metadata);
 void sj_metadata_set_cdrom (SjMetadata *metadata, const char* device);
 void sj_metadata_set_proxy (SjMetadata *metadata, const char* proxy);
 void sj_metadata_set_proxy_port (SjMetadata *metadata, const int proxy_port);
Index: sj-structures.h
===================================================================
--- sj-structures.h	(revision 5874)
+++ sj-structures.h	(working copy)
@@ -34,9 +34,16 @@
 #include <glib/glist.h>
 #include <gtk/gtktreemodel.h>
 
+typedef enum _MetadataSource MetadataSource;
+
 typedef struct _AlbumDetails AlbumDetails;
 typedef struct _TrackDetails TrackDetails;
 
+enum _MetadataSource {
+  SOURCE_CDTEXT,
+  SOURCE_FREEDB,
+  SOURCE_MUSICBRAINZ
+};
 
 struct _TrackDetails {
   AlbumDetails *album;
@@ -47,7 +54,6 @@
   int duration; /* seconds */
   char* track_id;
   char* artist_id;
-  GtkTreeIter iter; /* Temporary iterator for internal use */
 };
 
 struct _AlbumDetails {
@@ -56,10 +62,12 @@
   char* artist_sortname;
   char *genre;
   int   number; /* number of tracks in the album */
+  int   disc_number;
   GList* tracks;
   GDate *release_date; /* MusicBrainz support multiple releases per album */
   char* album_id;
   char* artist_id;
+  MetadataSource metadata_source;
 };
 
 void album_details_free(AlbumDetails *album);
Index: sj-metadata-musicbrainz.c
===================================================================
--- sj-metadata-musicbrainz.c	(revision 5874)
+++ sj-metadata-musicbrainz.c	(working copy)
@@ -41,33 +41,14 @@
 #include <gconf/gconf-client.h>
 #include <musicbrainz/queries.h>
 #include <musicbrainz/mb_c.h>
+#include <nautilus-burn.h>
 #include <stdlib.h>
 #include <unistd.h>
 
-#include <totem-disc.h>
-
 #include "sj-metadata-musicbrainz.h"
 #include "sj-structures.h"
 #include "sj-error.h"
 
-struct SjMetadataMusicbrainzPrivate {
-  GError *construct_error;
-  musicbrainz_t mb;
-  char *http_proxy;
-  int http_proxy_port;
-  char *cdrom;
-  /* TODO: remove and use an async queue or something l33t */
-  GList *albums;
-  GError *error;
-};
-
-static GError* mb_get_new_error (SjMetadata *metadata);
-static void mb_set_cdrom (SjMetadata *metadata, const char* device);
-static void mb_set_proxy (SjMetadata *metadata, const char* proxy);
-static void mb_set_proxy_port (SjMetadata *metadata, const int port);
-static void mb_list_albums (SjMetadata *metadata, GError **error);
-static char *mb_get_submit_url (SjMetadata *metadata);
-
 #define GCONF_MUSICBRAINZ_SERVER "/apps/sound-juicer/musicbrainz_server"
 #define GCONF_PROXY_USE_PROXY "/system/http_proxy/use_http_proxy"
 #define GCONF_PROXY_HOST "/system/http_proxy/host"
@@ -76,145 +57,48 @@
 #define GCONF_PROXY_USERNAME "/system/http_proxy/authentication_user"
 #define GCONF_PROXY_PASSWORD "/system/http_proxy/authentication_password"
 
-/**
- * GObject methods
- */
 
-static GObjectClass *parent_class = NULL;
+struct SjMetadataMusicbrainzPrivate {
+  musicbrainz_t mb;
+  char *http_proxy;
+  int http_proxy_port;
+  char *cdrom;
+  /* TODO: remove and use an async queue? */
+  GList *albums;
+  GError *error;
+  GRegex *disc_regex;
+};
 
-static void
-sj_metadata_musicbrainz_finalize (GObject *object)
-{
-  SjMetadataMusicbrainzPrivate *priv;
-  g_return_if_fail (object != NULL);
-  priv = SJ_METADATA_MUSICBRAINZ (object)->priv;
+#define GET_PRIVATE(o)  \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), SJ_TYPE_METADATA_MUSICBRAINZ, SjMetadataMusicbrainzPrivate))
 
-  g_free (priv->http_proxy);
-  g_free (priv->cdrom);
-  mb_Delete (priv->mb);
-  g_free (priv);
+enum {
+  PROP_0,
+  PROP_DEVICE,
+  PROP_USE_PROXY,
+  PROP_PROXY_HOST,
+  PROP_PROXY_PORT,
+};
 
-  parent_class->finalize (object);
-}
+static void metadata_interface_init (gpointer g_iface, gpointer iface_data);
 
-static void
-sj_metadata_musicbrainz_instance_init (GTypeInstance *instance, gpointer g_class)
-{
-  GConfClient *gconf_client;
-  char *server_name = NULL;
-  SjMetadataMusicbrainz *self = (SjMetadataMusicbrainz*)instance;
-  self->priv = g_new0 (SjMetadataMusicbrainzPrivate, 1);
-  self->priv->construct_error = NULL;
-  self->priv->mb = mb_New ();
-  /* TODO: something. :/ */
-  if (!self->priv->mb) {
-    g_set_error (&self->priv->construct_error,
-                 SJ_ERROR, SJ_ERROR_CD_LOOKUP_ERROR,
-                 _("Cannot create MusicBrainz client"));
-    return;
-  }
-  mb_UseUTF8 (self->priv->mb, TRUE);
+G_DEFINE_TYPE_WITH_CODE (SjMetadataMusicbrainz,
+                         sj_metadata_musicbrainz,
+                         G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (SJ_TYPE_METADATA,
+                                                metadata_interface_init));
 
-  gconf_client = gconf_client_get_default ();
-  server_name = gconf_client_get_string (gconf_client, GCONF_MUSICBRAINZ_SERVER, NULL);
-  if (server_name) {
-    g_strstrip (server_name);
-  }
-  if (server_name && strcmp (server_name, "") != 0) {
-    mb_SetServer (self->priv->mb, server_name, 80);
-    g_free (server_name);
-  }
-  
-  /* Set the HTTP proxy */
-  if (gconf_client_get_bool (gconf_client, GCONF_PROXY_USE_PROXY, NULL)) {
-    char *proxy_host = gconf_client_get_string (gconf_client, GCONF_PROXY_HOST, NULL);
-    mb_SetProxy (self->priv->mb, proxy_host,
-                 gconf_client_get_int (gconf_client, GCONF_PROXY_PORT, NULL));
-    g_free (proxy_host);
-    if (gconf_client_get_bool (gconf_client, GCONF_PROXY_USE_AUTHENTICATION, NULL)) {
-#if HAVE_MB_SETPROXYCREDS
-      char *username = gconf_client_get_string (gconf_client, GCONF_PROXY_USERNAME, NULL);
-      char *password = gconf_client_get_string (gconf_client, GCONF_PROXY_PASSWORD, NULL);
-      mb_SetProxyCreds (self->priv->mb, username, password);
-      g_free (username);
-      g_free (password);
-#else
-      g_warning ("mb_SetProxyCreds() not found, no proxy authorisation possible.");
-#endif
-    }
-  }
 
-  g_object_unref (gconf_client);
-
-  if (g_getenv("MUSICBRAINZ_DEBUG")) {
-    mb_SetDebug (self->priv->mb, TRUE);
-  }
-}
-
-static void
-metadata_interface_init (gpointer g_iface, gpointer iface_data)
-{
-  SjMetadataClass *klass = (SjMetadataClass*)g_iface;
-  klass->get_new_error = mb_get_new_error;
-  klass->set_cdrom = mb_set_cdrom;
-  klass->set_proxy = mb_set_proxy;
-  klass->set_proxy_port = mb_set_proxy_port;
-  klass->list_albums = mb_list_albums;
-  klass->get_submit_url = mb_get_submit_url;
-}
-
-static void
-sj_metadata_musicbrainz_class_init (SjMetadataMusicbrainzClass *class)
-{
-  GObjectClass *object_class;
-  parent_class = g_type_class_peek_parent (class);
-  object_class = (GObjectClass*) class;
-  object_class->finalize = sj_metadata_musicbrainz_finalize;
-}
-
-GType
-sj_metadata_musicbrainz_get_type (void)
-{
-  static GType type = 0;
-  if (type == 0) {
-    static const GTypeInfo info = {
-      sizeof (SjMetadataMusicbrainzClass),
-      NULL,
-      NULL,
-      (GClassInitFunc)sj_metadata_musicbrainz_class_init,
-      NULL,
-      NULL,
-      sizeof (SjMetadataMusicbrainz),
-      0,
-      sj_metadata_musicbrainz_instance_init,
-      NULL
-    };
-    static const GInterfaceInfo metadata_i_info = {
-      (GInterfaceInitFunc) metadata_interface_init,
-      NULL, NULL
-    };
-    type = g_type_register_static (G_TYPE_OBJECT, "SjMetadataMusicBrainzClass", &info, 0);
-    g_type_add_interface_static (type, SJ_TYPE_METADATA, &metadata_i_info);
-  }
-  return type;
-}
-
-GObject *
-sj_metadata_musicbrainz_new (void)
-{
-  return g_object_new (sj_metadata_musicbrainz_get_type (), NULL);
-}
-
-/**
+/*
  * Private methods
  */
 
-#define BYTES_PER_SECTOR 2352
-#define BYTES_PER_SECOND (44100 / 8) / 16 / 2
-
 static int
 get_duration_from_sectors (int sectors)
 {
+#define BYTES_PER_SECTOR 2352
+#define BYTES_PER_SECOND (44100 / 8) / 16 / 2
+  
   return (sectors * BYTES_PER_SECTOR / BYTES_PER_SECOND);
 }
 
@@ -270,62 +154,6 @@
  * Virtual methods
  */
 
-static GError*
-mb_get_new_error (SjMetadata *metadata)
-{
-  GError *error = NULL;
-  if (metadata == NULL || SJ_METADATA_MUSICBRAINZ (metadata)->priv == NULL) {
-    g_set_error (&error,
-                 SJ_ERROR, SJ_ERROR_INTERNAL_ERROR,
-                 _("MusicBrainz metadata object is not valid. This is bad, check your console for errors."));
-    return error;
-  }
-  return SJ_METADATA_MUSICBRAINZ (metadata)->priv->construct_error;
-}
-
-static void
-mb_set_cdrom (SjMetadata *metadata, const char* device)
-{
-  SjMetadataMusicbrainzPrivate *priv;
-  g_return_if_fail (metadata != NULL);
-  g_return_if_fail (device != NULL);
-  priv = SJ_METADATA_MUSICBRAINZ (metadata)->priv;
-
-  if (priv->cdrom) {
-    g_free (priv->cdrom);
-  }
-  priv->cdrom = g_strdup (device);
-  mb_SetDevice (priv->mb, priv->cdrom);
-}
-
-static void
-mb_set_proxy (SjMetadata *metadata, const char* proxy)
-{
-  SjMetadataMusicbrainzPrivate *priv;
-  g_return_if_fail (metadata != NULL);
-  priv = SJ_METADATA_MUSICBRAINZ (metadata)->priv;
-
-  if (proxy == NULL) {
-    proxy = "";
-  }
-  if (priv->http_proxy) {
-    g_free (priv->http_proxy);
-  }
-  priv->http_proxy = g_strdup (proxy);
-  mb_SetProxy (priv->mb, priv->http_proxy, priv->http_proxy_port);
-}
-
-static void
-mb_set_proxy_port (SjMetadata *metadata, const int port)
-{
-  SjMetadataMusicbrainzPrivate *priv;
-  g_return_if_fail (metadata != NULL);
-  priv = SJ_METADATA_MUSICBRAINZ (metadata)->priv;
-
-  priv->http_proxy_port = port;
-  mb_SetProxy (priv->mb, priv->http_proxy, priv->http_proxy_port);
-}
-
 /* Data imported from FreeDB is horrendeous for compilations,
  * Try to split the 'Various' artist */
 static void
@@ -333,7 +161,7 @@
 {
   char *slash, **split;
 
-  if (g_ascii_strncasecmp (MBI_VARIOUS_ARTIST_ID, track->album->artist_id, 64) != 0 && track->album->artist_id[0] != '\0' && track->artist_id[0] != '\0') {
+  if (g_ascii_strncasecmp (track->album->album_id, "freedb:", 7) != 0 && track->album->artist_id[0] != '\0' && track->artist_id[0] != '\0') {
     track->title = g_strdup (data);
     return;
   }
@@ -382,7 +210,7 @@
   g_free (rdf);
 }
 
-/*
+/**
  * Load into the MusicBrainz object the RDF from the specified cache file if it
  * exists and is valid then return TRUE, otherwise return FALSE.
  */
@@ -425,7 +253,7 @@
 }
 #endif
 
-/*
+/**
  * Fill the MusicBrainz object with RDF.  Basically get the CD Index and check
  * the local cache, if that fails then lookup the data online.
  */
@@ -476,6 +304,34 @@
   g_free (cdindex);
 }
 
+/*
+ * Magic character set encoding to try and repair brain-dead FreeDB encoding,
+ * converting it to the current locale's encoding (which is likely to be the
+ * intended encoding).
+ */
+static void
+convert_encoding(char **str)
+{
+  char *iso8859;
+  char *converted;
+
+  if (str == NULL || *str == NULL)
+    return;
+
+  iso8859 = g_convert (*str, -1, "ISO-8859-1", "UTF-8", NULL, NULL, NULL);
+
+  if (iso8859) {
+    converted = g_locale_to_utf8 (iso8859, -1, NULL, NULL, NULL);
+
+    if (converted) {
+      g_free (*str);
+      *str = converted;
+    }
+  }
+
+  g_free (iso8859);
+}
+
 static gpointer
 lookup_cd (SjMetadata *metadata)
 {
@@ -483,10 +339,12 @@
   SjMetadataMusicbrainzPrivate *priv;
   GList *albums = NULL;
   GList *al, *tl;
+  GMatchInfo *info;
   char data[256];
   int num_albums, i, j;
-  TotemDiscMediaType type;
-  GError *totem_error = NULL;
+  NautilusBurnMediaType type;
+  NautilusBurnDriveMonitor *monitor;
+  NautilusBurnDrive *drive;
 
   /* TODO: fire error signal */
   g_return_val_if_fail (metadata != NULL, NULL);
@@ -495,11 +353,31 @@
   g_return_val_if_fail (priv->cdrom != NULL, NULL);
   priv->error = NULL; /* TODO: hack */
 
-  type = totem_cd_detect_type (priv->cdrom, &totem_error);
+  if (! nautilus_burn_initialized ()) {
+    nautilus_burn_init ();
+  }
+  monitor = nautilus_burn_get_drive_monitor ();
+  drive = nautilus_burn_drive_monitor_get_drive_for_device (monitor, priv->cdrom);
+  if (drive == NULL) {
+    return NULL;
+  }
+  type = nautilus_burn_drive_get_media_type (drive);
+  nautilus_burn_drive_unref (drive);
 
-  if (totem_error != NULL) {
-    priv->error = g_error_new (SJ_ERROR, SJ_ERROR_CD_NO_MEDIA, _("Cannot read CD: %s"), totem_error->message);
-    g_error_free (totem_error);
+  if (type == NAUTILUS_BURN_MEDIA_TYPE_ERROR) {
+    char *msg;
+    SjError err;
+
+    if (access (priv->cdrom, W_OK) == 0) {
+      msg = g_strdup_printf (_("Device '%s' does not contain any media"), priv->cdrom);
+      err = SJ_ERROR_CD_NO_MEDIA;
+    } else {
+      msg = g_strdup_printf (_("Device '%s' could not be opened. Check the access permissions on the device."), priv->cdrom);
+      err = SJ_ERROR_CD_PERMISSION_ERROR;
+    }
+    priv->error = g_error_new (SJ_ERROR, err, _("Cannot read CD: %s"), msg);
+    g_free (msg);
+
     priv->albums = NULL;
     g_idle_add ((GSourceFunc)fire_signal_idle, metadata);
     return NULL;
@@ -517,11 +395,14 @@
   for (i = 1; i <= num_albums; i++) {
     int num_tracks;
     AlbumDetails *album;
+    gboolean from_freedb = FALSE;
 
     mb_Select1(priv->mb, MBS_SelectAlbum, i);
     album = g_new0 (AlbumDetails, 1);
 
     if (mb_GetResultData(priv->mb, MBE_AlbumGetAlbumId, data, sizeof (data))) {
+      from_freedb = strstr(data, "freedb:") == data;
+
       mb_GetIDFromURL (priv->mb, data, data, sizeof (data));
       album->album_id = g_strdup (data);
     }
@@ -529,18 +410,19 @@
     if (mb_GetResultData (priv->mb, MBE_AlbumGetAlbumArtistId, data, sizeof (data))) {
       mb_GetIDFromURL (priv->mb, data, data, sizeof (data));
       album->artist_id = g_strdup (data);
-      if (g_ascii_strncasecmp (MBI_VARIOUS_ARTIST_ID, data, 64) == 0) {
-        album->artist = g_strdup (_("Various"));
+
+      if (mb_GetResultData (priv->mb, MBE_AlbumGetAlbumArtistName, data, sizeof (data))) {
+        album->artist = g_strdup (data);
       } else {
-        if (*data && mb_GetResultData1(priv->mb, MBE_AlbumGetArtistName, data, sizeof (data), 1)) {
-          album->artist = g_strdup (data);
+        if (g_ascii_strcasecmp (MBI_VARIOUS_ARTIST_ID, album->artist_id) == 0) {
+          album->artist = g_strdup (_("Various"));
         } else {
           album->artist = g_strdup (_("Unknown Artist"));
         }
-        if (*data && mb_GetResultData1(priv->mb, MBE_AlbumGetArtistSortName, data, sizeof (data), 1)) {
-          album->artist_sortname = g_strdup (data);
-        }
       }
+      if (mb_GetResultData(priv->mb, MBE_AlbumGetAlbumArtistSortName, data, sizeof (data))) {
+        album->artist_sortname = g_strdup (data);
+      }
     }
 
     if (mb_GetResultData(priv->mb, MBE_AlbumGetAlbumName, data, sizeof (data))) {
@@ -549,6 +431,23 @@
       album->title = g_strdup (_("Unknown Title"));
     }
 
+    if (g_regex_match (priv->disc_regex, album->title, 0, &info)) {
+      int pos = 0;
+      char *s;
+ 
+      g_match_info_fetch_pos (info, 1, &pos, NULL);
+      if (pos) {
+        s = g_strndup (album->title, pos);
+        g_free (album->title);
+        album->title = s;
+      }
+      
+      s = g_match_info_fetch (info, 2);
+      album->disc_number = atoi (s);
+      g_free (s);
+    }
+    g_match_info_free (info);
+
     {
       int num_releases;
       num_releases = mb_GetResultInt (priv->mb, MBE_AlbumGetNumReleaseDates);
@@ -601,6 +500,8 @@
         } else {
           track->title = g_strdup (data);
         }
+      } else {
+        track->title = g_strdup (_("[Untitled]"));
       }
 
       if (track->artist == NULL && mb_GetResultData1(priv->mb, MBE_AlbumGetArtistName, data, sizeof (data), j)) {
@@ -614,11 +515,29 @@
       if (mb_GetResultData1(priv->mb, MBE_AlbumGetTrackDuration, data, sizeof (data), j)) {
         track->duration = atoi (data) / 1000;
       }
+
+      if (from_freedb) {
+        convert_encoding(&track->title);
+        convert_encoding(&track->artist);
+        convert_encoding(&track->artist_sortname);
+      }
       
       album->tracks = g_list_append (album->tracks, track);
       album->number++;
     }
 
+    if (from_freedb) {
+      convert_encoding(&album->title);
+      convert_encoding(&album->artist);
+      convert_encoding(&album->artist_sortname);
+    }
+
+    if (from_freedb) {
+      album->metadata_source = SOURCE_FREEDB;
+    } else {
+      album->metadata_source = SOURCE_MUSICBRAINZ;
+    }
+
     albums = g_list_append (albums, album);
 
     mb_Select (priv->mb, MBS_Rewind);
@@ -683,3 +602,160 @@
     return NULL;
   }
 }
+
+
+/*
+ * GObject methods
+ */
+
+static void
+metadata_interface_init (gpointer g_iface, gpointer iface_data)
+{
+  SjMetadataClass *klass = (SjMetadataClass*)g_iface;
+  klass->list_albums = mb_list_albums;
+  klass->get_submit_url = mb_get_submit_url;
+}
+
+static void
+sj_metadata_musicbrainz_init (SjMetadataMusicbrainz *self)
+{
+  GConfClient *gconf_client;
+  char *server_name = NULL;
+
+  self->priv = GET_PRIVATE (self);
+  self->priv->mb = mb_New ();
+  mb_UseUTF8 (self->priv->mb, TRUE);
+
+  gconf_client = gconf_client_get_default ();
+  server_name = gconf_client_get_string (gconf_client, GCONF_MUSICBRAINZ_SERVER, NULL);
+  if (server_name) {
+    g_strstrip (server_name);
+  }
+  if (server_name && strcmp (server_name, "") != 0) {
+    mb_SetServer (self->priv->mb, server_name, 80);
+    g_free (server_name);
+  }
+  
+  /* Set the HTTP proxy */
+  if (gconf_client_get_bool (gconf_client, GCONF_PROXY_USE_PROXY, NULL)) {
+    char *proxy_host = gconf_client_get_string (gconf_client, GCONF_PROXY_HOST, NULL);
+    mb_SetProxy (self->priv->mb, proxy_host,
+                 gconf_client_get_int (gconf_client, GCONF_PROXY_PORT, NULL));
+    g_free (proxy_host);
+    if (gconf_client_get_bool (gconf_client, GCONF_PROXY_USE_AUTHENTICATION, NULL)) {
+#if HAVE_MB_SETPROXYCREDS
+      char *username = gconf_client_get_string (gconf_client, GCONF_PROXY_USERNAME, NULL);
+      char *password = gconf_client_get_string (gconf_client, GCONF_PROXY_PASSWORD, NULL);
+      mb_SetProxyCreds (self->priv->mb, username, password);
+      g_free (username);
+      g_free (password);
+#else
+      g_warning ("mb_SetProxyCreds() not found, no proxy authorisation possible.");
+#endif
+    }
+  }
+
+  g_object_unref (gconf_client);
+
+  if (g_getenv("MUSICBRAINZ_DEBUG")) {
+    mb_SetDebug (self->priv->mb, TRUE);
+  }
+
+  self->priv->disc_regex = g_regex_new (".+( \\(disc (\\d+).*)", 0, 0, NULL);
+}
+
+static void
+sj_metadata_musicbrainz_get_property (GObject *object, guint property_id,
+                                      GValue *value, GParamSpec *pspec)
+{
+  SjMetadataMusicbrainzPrivate *priv = SJ_METADATA_MUSICBRAINZ (object)->priv;
+  g_assert (priv);
+
+  switch (property_id) {
+  case PROP_DEVICE:
+    g_value_set_string (value, priv->cdrom);
+    break;
+  case PROP_PROXY_HOST:
+    g_value_set_string (value, priv->http_proxy);
+    break;
+  case PROP_PROXY_PORT:
+    g_value_set_int (value, priv->http_proxy_port);
+    break;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+  }
+}
+
+static void
+sj_metadata_musicbrainz_set_property (GObject *object, guint property_id,
+                                      const GValue *value, GParamSpec *pspec)
+{
+  SjMetadataMusicbrainzPrivate *priv = SJ_METADATA_MUSICBRAINZ (object)->priv;
+  g_assert (priv);
+
+  switch (property_id) {
+  case PROP_DEVICE:
+    if (priv->cdrom)
+      g_free (priv->cdrom);
+    priv->cdrom = g_value_dup_string (value);
+    if (priv->cdrom)
+      mb_SetDevice (priv->mb, priv->cdrom);
+    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_SetProxy (priv->mb, priv->http_proxy, priv->http_proxy_port);
+    break;
+  case PROP_PROXY_PORT:
+    priv->http_proxy_port = g_value_get_int (value);
+    mb_SetProxy (priv->mb, priv->http_proxy, priv->http_proxy_port);
+    break;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+  }
+}
+
+static void
+sj_metadata_musicbrainz_finalize (GObject *object)
+{
+  SjMetadataMusicbrainzPrivate *priv;
+  
+  priv = SJ_METADATA_MUSICBRAINZ (object)->priv;
+
+  g_free (priv->http_proxy);
+  g_free (priv->cdrom);
+  g_regex_unref (priv->disc_regex);
+  mb_Delete (priv->mb);
+
+  G_OBJECT_CLASS (sj_metadata_musicbrainz_parent_class)->finalize (object);
+}
+
+static void
+sj_metadata_musicbrainz_class_init (SjMetadataMusicbrainzClass *class)
+{
+  GObjectClass *object_class = (GObjectClass*)class;
+
+  g_type_class_add_private (class, sizeof (SjMetadataMusicbrainzPrivate));
+
+  object_class->get_property = sj_metadata_musicbrainz_get_property;
+  object_class->set_property = sj_metadata_musicbrainz_set_property;
+  object_class->finalize = sj_metadata_musicbrainz_finalize;
+
+  g_object_class_override_property (object_class, PROP_DEVICE, "device");
+  g_object_class_override_property (object_class, PROP_PROXY_HOST, "proxy-host");
+  g_object_class_override_property (object_class, PROP_PROXY_PORT, "proxy-port");
+}
+
+
+/*
+ * Public methods.
+ */
+
+GObject *
+sj_metadata_musicbrainz_new (void)
+{
+  return g_object_new (SJ_TYPE_METADATA_MUSICBRAINZ, NULL);
+}
Index: sj-metadata-musicbrainz.h
===================================================================
--- sj-metadata-musicbrainz.h	(revision 5874)
+++ sj-metadata-musicbrainz.h	(working copy)
@@ -34,7 +34,7 @@
 
 G_BEGIN_DECLS
 
-#define SJ_TYPE_METADATA_MUSICBRAINZ            (sj_metadata_get_type ())
+#define SJ_TYPE_METADATA_MUSICBRAINZ            (sj_metadata_musicbrainz_get_type ())
 #define SJ_METADATA_MUSICBRAINZ(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SJ_TYPE_METADATA_MUSICBRAINZ, SjMetadataMusicbrainz))
 #define SJ_METADATA_MUSICBRAINZ_CLASS(vtable)    (G_TYPE_CHECK_CLASS_CAST ((vtable), SJ_TYPE_METADATA_MUSICBRAINZ, SjMetadataMusicbrainzClass))
 #define SJ_IS_METADATA_MUSICBRAINZ(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SJ_TYPE_METADATA_MUSICBRAINZ))
Index: sj-metadata.c
===================================================================
--- sj-metadata.c	(revision 5874)
+++ sj-metadata.c	(working copy)
@@ -40,17 +40,36 @@
 static int signals[LAST_SIGNAL] = { 0 };
 
 static void
-sj_metadata_base_init (gpointer g_class)
+sj_metadata_base_init (gpointer g_iface)
 {
   static gboolean initialized = FALSE;
   if (!initialized) {
     signals[METADATA] = g_signal_new ("metadata",
-                                      G_TYPE_FROM_CLASS (g_class),
+                                      G_TYPE_FROM_CLASS (g_iface),
                                       G_SIGNAL_RUN_LAST,
                                       G_STRUCT_OFFSET (SjMetadataClass, metadata),
                                       NULL, NULL,
                                       metadata_marshal_VOID__POINTER_POINTER,
                                       G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
+
+    /* TODO: make these constructors */
+    /* TODO: add nice nick and blurb strings */
+    g_object_interface_install_property (g_iface,
+                                         g_param_spec_string ("device", "device", 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_string ("proxy-host", "proxy-host", 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_int ("proxy-port", "proxy-port", NULL,
+                                                           0, G_MAXINT, 0,
+                                                           G_PARAM_READABLE|G_PARAM_WRITABLE|
+                                                           G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
+
     initialized = TRUE;
   }
 }
@@ -79,12 +98,6 @@
   return type;
 }
 
-GError *
-sj_metadata_get_new_error (SjMetadata *metadata)
-{
-  return SJ_METADATA_GET_CLASS (metadata)->get_new_error (metadata);
-}
-
 void
 sj_metadata_set_cdrom (SjMetadata *metadata, const char* device)
 {
@@ -102,13 +115,13 @@
 void
 sj_metadata_set_proxy (SjMetadata *metadata, const char* proxy)
 {
-  SJ_METADATA_GET_CLASS (metadata)->set_proxy (metadata, proxy);
+  g_object_set (metadata, "proxy-host", proxy, NULL);
 }
 
 void
 sj_metadata_set_proxy_port (SjMetadata *metadata, const int proxy_port)
 {
-  SJ_METADATA_GET_CLASS (metadata)->set_proxy_port (metadata, proxy_port);
+  g_object_set (metadata, "proxy-port", proxy_port, NULL);
 }
 
 void
