]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-account-widget.c
debug-window: fix typo
[empathy.git] / libempathy-gtk / empathy-account-widget.c
index abfda9f8f76ca1486a8afe4f7d3be013be369c6d..794e7d5247a4ccb84dc81abf73183ad93930f5fd 100644 (file)
  *          Danielle Madeley <danielle.madeley@collabora.co.uk>
  */
 
-#include <config.h>
+#include "config.h"
 
-#include <string.h>
-
-#include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
 
-#include <gio/gdesktopappinfo.h>
-
 #include <libempathy/empathy-utils.h>
 
-#include <telepathy-glib/account.h>
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/connection-manager.h>
-#include <telepathy-glib/util.h>
 #include <dbus/dbus-protocol.h>
 
-#include "empathy-account-widget.h"
 #include "empathy-account-widget-private.h"
 #include "empathy-account-widget-sip.h"
 #include "empathy-account-widget-irc.h"
@@ -50,7 +40,7 @@
 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
 #include <libempathy/empathy-debug.h>
 
-G_DEFINE_TYPE (EmpathyAccountWidget, empathy_account_widget, G_TYPE_OBJECT)
+G_DEFINE_TYPE (EmpathyAccountWidget, empathy_account_widget, GTK_TYPE_BOX)
 
 typedef enum
 {
@@ -72,7 +62,7 @@ static ServiceInfo services_infos[N_SERVICES] = {
     { "label_username_f_example", FALSE },
 };
 
-typedef struct {
+struct _EmpathyAccountWidgetPriv {
   EmpathyAccountSettings *settings;
 
   GtkWidget *grid_common_settings;
@@ -81,6 +71,7 @@ typedef struct {
   GtkWidget *entry_password;
   GtkWidget *spinbutton_port;
   GtkWidget *radiobutton_reuse;
+  GtkWidget *hbox_buttons;
 
   gboolean simple;
 
@@ -115,9 +106,7 @@ typedef struct {
   /* Used for 'special' XMPP account having a service associated ensuring that
    * JIDs have a specific suffix; such as Facebook for example */
   gchar *jid_suffix;
-
-  gboolean dispose_run;
-} EmpathyAccountWidgetPriv;
+};
 
 enum {
   PROP_PROTOCOL = 1,
@@ -135,15 +124,12 @@ enum {
   LAST_SIGNAL
 };
 
-static void account_widget_apply_and_log_in (EmpathyAccountWidget *);
-
 enum {
   RESPONSE_LAUNCH
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountWidget)
 #define CHANGED_TIMEOUT 300
 
 #define DIGIT             "0-9"
@@ -176,14 +162,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
 /* Based on http://www.ietf.org/rfc/rfc2812.txt (section 2.3.1) */
 #define IRC_SPECIAL       "_\\[\\]{}\\\\|`^"
 #define IRC_NICK_NAME     "(["ALPHA IRC_SPECIAL"]["ALPHADIGITDASH IRC_SPECIAL"]*)"
-/*   user       =  1*( %x01-09 / %x0B-0C / %x0E-1F / %x21-3F / %x41-FF )
- *                ; any octet except NUL, CR, LF, " " and "@"
- *
- * so technically, like so many other places in IRC, we should be using arrays
- * of bytes here rather than UTF-8 strings. Life: too short. In practice this
- * will always be ASCII.
- */
-#define IRC_USER_NAME     "([^\r\n@ ])+"
 
 /* Based on http://www.ietf.org/rfc/rfc4622.txt (section 2.2)
  * We just exclude invalid characters to avoid ucschars and other redundant
@@ -200,8 +178,7 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 #define ACCOUNT_REGEX_ICQ      "^"ICQ_USER_NAME"$"
 #define ACCOUNT_REGEX_IRC      "^"IRC_NICK_NAME"$"
-#define USERNAME_REGEX_IRC     "^"IRC_USER_NAME"$"
-#define ACCOUNT_REGEX_JABBER   "^"JABBER_USER_NAME"@"HOST"$"
+#define ACCOUNT_REGEX_JABBER   "^"JABBER_USER_NAME"@[^@/]+"
 #define ACCOUNT_REGEX_MSN      "^"MSN_USER_NAME"@"HOST"$"
 #define ACCOUNT_REGEX_YAHOO    "^"YAHOO_USER_NAME"$"
 
@@ -209,30 +186,25 @@ static void
 account_widget_set_control_buttons_sensitivity (EmpathyAccountWidget *self,
     gboolean sensitive)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+  /* we hit this case because of the 'other-accounts-exist' property handler
+   * being called during init (before constructed()) */
+  if (self->priv->apply_button == NULL || self->priv->cancel_button == NULL)
+    return;
 
-  if (!priv->simple)
-    {
-      /* we hit this case because of the 'other-accounts-exist' property handler
-       * being called during init (before constructed()) */
-      if (priv->apply_button == NULL || priv->cancel_button == NULL)
-        return;
+  gtk_widget_set_sensitive (self->priv->apply_button, sensitive);
 
-      gtk_widget_set_sensitive (priv->apply_button, sensitive);
+  if (sensitive)
+    {
+      /* We can't grab default if the widget hasn't be packed in a
+       * window */
+      GtkWidget *window;
 
-      if (sensitive)
+      window = gtk_widget_get_toplevel (self->priv->apply_button);
+      if (window != NULL &&
+          gtk_widget_is_toplevel (window))
         {
-          /* We can't grab default if the widget hasn't be packed in a
-           * window */
-          GtkWidget *window;
-
-          window = gtk_widget_get_toplevel (priv->apply_button);
-          if (window != NULL &&
-              gtk_widget_is_toplevel (window))
-            {
-              gtk_widget_set_can_default (priv->apply_button, TRUE);
-              gtk_widget_grab_default (priv->apply_button);
-            }
+          gtk_widget_set_can_default (self->priv->apply_button, TRUE);
+          gtk_widget_grab_default (self->priv->apply_button);
         }
     }
 }
@@ -270,13 +242,11 @@ account_widget_set_entry_highlighting (GtkEntry *entry,
 static void
 account_widget_handle_control_buttons_sensitivity (EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
   gboolean is_valid;
 
-  is_valid = empathy_account_settings_is_valid (priv->settings);
+  is_valid = empathy_account_settings_is_valid (self->priv->settings);
 
-  if (!priv->simple)
-      account_widget_set_control_buttons_sensitivity (self, is_valid);
+  account_widget_set_control_buttons_sensitivity (self, is_valid);
 
   g_signal_emit (self, signals[HANDLE_APPLY], 0, is_valid);
 }
@@ -287,38 +257,41 @@ account_widget_entry_changed_common (EmpathyAccountWidget *self,
 {
   const gchar *str;
   const gchar *param_name;
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
   gboolean prev_status;
   gboolean curr_status;
 
   str = gtk_entry_get_text (entry);
   param_name = g_object_get_data (G_OBJECT (entry), "param_name");
-  prev_status = empathy_account_settings_parameter_is_valid (priv->settings,
-                                                             param_name);
+  prev_status = empathy_account_settings_parameter_is_valid (
+      self->priv->settings, param_name);
 
   if (EMP_STR_EMPTY (str))
     {
-      const gchar *value = NULL;
-
-      empathy_account_settings_unset (priv->settings, param_name);
+      empathy_account_settings_unset (self->priv->settings, param_name);
 
       if (focus)
         {
-          value = empathy_account_settings_get_string (priv->settings,
+          gchar *value;
+
+          value = empathy_account_settings_dup_string (self->priv->settings,
               param_name);
+
           DEBUG ("Unset %s and restore to %s", param_name, value);
           gtk_entry_set_text (entry, value ? value : "");
+          g_free (value);
         }
     }
   else
     {
       DEBUG ("Setting %s to %s", param_name,
           tp_strdiff (param_name, "password") ? str : "***");
-      empathy_account_settings_set_string (priv->settings, param_name, str);
+      empathy_account_settings_set (self->priv->settings, param_name,
+          g_variant_new_string (str));
     }
 
-  curr_status = empathy_account_settings_parameter_is_valid (priv->settings,
-                                                             param_name);
+  curr_status = empathy_account_settings_parameter_is_valid (
+      self->priv->settings, param_name);
+
   if (curr_status != prev_status)
     account_widget_set_entry_highlighting (entry, !curr_status);
 }
@@ -327,9 +300,7 @@ static void
 account_widget_entry_changed_cb (GtkEditable *entry,
     EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
-  if (priv->automatic_change)
+  if (self->priv->automatic_change)
     return;
 
   account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE);
@@ -340,14 +311,13 @@ static void
 account_widget_entry_map_cb (GtkEntry *entry,
     EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
   const gchar *param_name;
   gboolean is_valid;
 
   /* need to initialize input highlighting */
   param_name = g_object_get_data (G_OBJECT (entry), "param_name");
-  is_valid = empathy_account_settings_parameter_is_valid (priv->settings,
-                                                          param_name);
+  is_valid = empathy_account_settings_parameter_is_valid (self->priv->settings,
+      param_name);
   account_widget_set_entry_highlighting (entry, !is_valid);
 }
 
@@ -358,12 +328,11 @@ account_widget_int_changed_cb (GtkWidget *widget,
   const gchar *param_name;
   gint value;
   const gchar *signature;
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
 
   value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
   param_name = g_object_get_data (G_OBJECT (widget), "param_name");
 
-  signature = empathy_account_settings_get_dbus_signature (priv->settings,
+  signature = empathy_account_settings_get_dbus_signature (self->priv->settings,
     param_name);
   g_return_if_fail (signature != NULL);
 
@@ -373,17 +342,21 @@ account_widget_int_changed_cb (GtkWidget *widget,
     {
     case DBUS_TYPE_INT16:
     case DBUS_TYPE_INT32:
-      empathy_account_settings_set_int32 (priv->settings, param_name, value);
+      empathy_account_settings_set (self->priv->settings, param_name,
+          g_variant_new_int32 (value));
       break;
     case DBUS_TYPE_INT64:
-      empathy_account_settings_set_int64 (priv->settings, param_name, value);
+      empathy_account_settings_set (self->priv->settings, param_name,
+          g_variant_new_int64 (value));
       break;
     case DBUS_TYPE_UINT16:
     case DBUS_TYPE_UINT32:
-      empathy_account_settings_set_uint32 (priv->settings, param_name, value);
+      empathy_account_settings_set (self->priv->settings, param_name,
+          g_variant_new_uint32 (value));
       break;
     case DBUS_TYPE_UINT64:
-      empathy_account_settings_set_uint64 (priv->settings, param_name, value);
+      empathy_account_settings_set (self->priv->settings, param_name,
+          g_variant_new_uint64 (value));
       break;
     default:
       g_return_if_reached ();
@@ -399,7 +372,6 @@ account_widget_checkbutton_toggled_cb (GtkWidget *widget,
   gboolean     value;
   gboolean     default_value;
   const gchar *param_name;
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
 
   value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
   param_name = g_object_get_data (G_OBJECT (widget), "param_name");
@@ -407,8 +379,8 @@ account_widget_checkbutton_toggled_cb (GtkWidget *widget,
   /* FIXME: This is ugly! checkbox don't have a "not-set" value so we
    * always unset the param and set the value if different from the
    * default value. */
-  empathy_account_settings_unset (priv->settings, param_name);
-  default_value = empathy_account_settings_get_boolean (priv->settings,
+  empathy_account_settings_unset (self->priv->settings, param_name);
+  default_value = empathy_account_settings_get_boolean (self->priv->settings,
       param_name);
 
   if (default_value == value)
@@ -418,7 +390,8 @@ account_widget_checkbutton_toggled_cb (GtkWidget *widget,
   else
     {
       DEBUG ("Setting %s to %d", param_name, value);
-      empathy_account_settings_set_boolean (priv->settings, param_name, value);
+      empathy_account_settings_set (self->priv->settings, param_name,
+          g_variant_new_boolean (value));
     }
 
   empathy_account_widget_changed (self);
@@ -428,12 +401,11 @@ static void
 account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl,
     EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
   gboolean   value;
   gint32       port = 0;
 
   value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_ssl));
-  port = empathy_account_settings_get_uint32 (priv->settings, "port");
+  port = empathy_account_settings_get_uint32 (self->priv->settings, "port");
 
   if (value)
     {
@@ -446,9 +418,10 @@ account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl,
         port = 5222;
     }
 
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spinbutton_port), port);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->priv->spinbutton_port),
+      port);
 
-  priv->contains_pending_changes = TRUE;
+  self->priv->contains_pending_changes = TRUE;
 }
 
 static void
@@ -458,10 +431,9 @@ account_widget_combobox_changed_cb (GtkWidget *widget,
   GtkTreeIter iter;
   GtkTreeModel *model;
   const gchar *value;
-  const GValue *v;
+  GVariant *v;
   const gchar *default_value = NULL;
   const gchar *param_name;
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
 
   if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
     return;
@@ -472,22 +444,25 @@ account_widget_combobox_changed_cb (GtkWidget *widget,
 
   param_name = g_object_get_data (G_OBJECT (widget), "param_name");
 
-  v = empathy_account_settings_get_default (priv->settings, param_name);
-  if (v != NULL)
-    default_value = g_value_get_string (v);
+  v = empathy_account_settings_dup_default (self->priv->settings, param_name);
+  if (v != NULL && g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
+    default_value = g_variant_get_string (v, NULL);
 
   if (!tp_strdiff (value, default_value))
     {
       DEBUG ("Unset %s and restore to %s", param_name, default_value);
-      empathy_account_settings_unset (priv->settings, param_name);
+      empathy_account_settings_unset (self->priv->settings, param_name);
     }
   else
     {
       DEBUG ("Setting %s to %s", param_name, value);
-      empathy_account_settings_set_string (priv->settings, param_name, value);
+      empathy_account_settings_set (self->priv->settings, param_name,
+          g_variant_new_string (value));
     }
 
   empathy_account_widget_changed (self);
+
+  tp_clear_pointer (&v, g_variant_unref);
 }
 
 static void
@@ -496,13 +471,12 @@ clear_icon_released_cb (GtkEntry *entry,
     GdkEvent *event,
     EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
   const gchar *param_name;
 
   param_name = g_object_get_data (G_OBJECT (entry), "param_name");
 
   DEBUG ("Unset %s", param_name);
-  empathy_account_settings_unset (priv->settings, param_name);
+  empathy_account_settings_unset (self->priv->settings, param_name);
   gtk_entry_set_text (entry, "");
 
   empathy_account_widget_changed (self);
@@ -524,20 +498,16 @@ static void
 password_entry_activated_cb (GtkEntry *entry,
     EmpathyAccountWidget *self)
 {
-    EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
-    if (gtk_widget_get_sensitive (priv->apply_button))
-        account_widget_apply_and_log_in (self);
+    if (gtk_widget_get_sensitive (self->priv->apply_button))
+        empathy_account_widget_apply_and_log_in (self);
 }
 
 static void
 account_entry_activated_cb (GtkEntry *entry,
     EmpathyAccountWidget *self)
 {
-    EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
-    if (gtk_widget_get_sensitive (priv->apply_button))
-        account_widget_apply_and_log_in (self);
+    if (gtk_widget_get_sensitive (self->priv->apply_button))
+        empathy_account_widget_apply_and_log_in (self);
 }
 
 void
@@ -545,8 +515,6 @@ empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
     GtkWidget *widget,
     const gchar *param_name)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
   g_object_set_data_full (G_OBJECT (widget), "param_name",
       g_strdup (param_name), g_free);
 
@@ -555,28 +523,28 @@ empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
       gint value = 0;
       const gchar *signature;
 
-      signature = empathy_account_settings_get_dbus_signature (priv->settings,
-          param_name);
+      signature = empathy_account_settings_get_dbus_signature (
+          self->priv->settings, param_name);
       g_return_if_fail (signature != NULL);
 
       switch ((int)*signature)
         {
           case DBUS_TYPE_INT16:
           case DBUS_TYPE_INT32:
-            value = empathy_account_settings_get_int32 (priv->settings,
+            value = empathy_account_settings_get_int32 (self->priv->settings,
               param_name);
             break;
           case DBUS_TYPE_INT64:
-            value = empathy_account_settings_get_int64 (priv->settings,
+            value = empathy_account_settings_get_int64 (self->priv->settings,
               param_name);
             break;
           case DBUS_TYPE_UINT16:
           case DBUS_TYPE_UINT32:
-            value = empathy_account_settings_get_uint32 (priv->settings,
+            value = empathy_account_settings_get_uint32 (self->priv->settings,
               param_name);
             break;
           case DBUS_TYPE_UINT64:
-            value = empathy_account_settings_get_uint64 (priv->settings,
+            value = empathy_account_settings_get_uint64 (self->priv->settings,
                 param_name);
             break;
           default:
@@ -591,15 +559,16 @@ empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
     }
   else if (GTK_IS_ENTRY (widget))
     {
-      const gchar *str = NULL;
+      gchar *str;
 
-      str = empathy_account_settings_get_string (priv->settings, param_name);
+      str = empathy_account_settings_dup_string (self->priv->settings,
+          param_name);
       gtk_entry_set_text (GTK_ENTRY (widget), str ? str : "");
 
       if (!tp_strdiff (param_name, "account"))
-        priv->param_account_widget = widget;
+        self->priv->param_account_widget = widget;
       else if (!tp_strdiff (param_name, "password"))
-        priv->param_password_widget = widget;
+        self->priv->param_password_widget = widget;
 
       if (strstr (param_name, "password"))
         {
@@ -623,17 +592,18 @@ empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
         g_signal_connect (widget, "activate",
             G_CALLBACK (account_entry_activated_cb), self);
 
-
       g_signal_connect (widget, "changed",
           G_CALLBACK (account_widget_entry_changed_cb), self);
       g_signal_connect (widget, "map",
           G_CALLBACK (account_widget_entry_map_cb), self);
+
+      g_free (str);
     }
   else if (GTK_IS_TOGGLE_BUTTON (widget))
     {
       gboolean value = FALSE;
 
-      value = empathy_account_settings_get_boolean (priv->settings,
+      value = empathy_account_settings_get_boolean (self->priv->settings,
           param_name);
       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
 
@@ -645,12 +615,13 @@ empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
     {
       /* The combo box's model has to contain the param value in its first
        * column (as a string) */
-      const gchar *str;
+      gchar *str;
       GtkTreeModel *model;
       GtkTreeIter iter;
       gboolean valid;
 
-      str = empathy_account_settings_get_string (priv->settings, param_name);
+      str = empathy_account_settings_dup_string (self->priv->settings,
+          param_name);
       model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
 
       valid = gtk_tree_model_get_iter_first (model, &iter);
@@ -672,6 +643,8 @@ empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
           g_free (name);
         }
 
+      g_free (str);
+
       g_signal_connect (widget, "changed",
           G_CALLBACK (account_widget_combobox_changed_cb),
           self);
@@ -682,7 +655,8 @@ empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
     }
 
   gtk_widget_set_sensitive (widget,
-      empathy_account_settings_param_is_supported (priv->settings, param_name));
+      empathy_account_settings_param_is_supported (self->priv->settings,
+        param_name));
 }
 
 static GHashTable *
@@ -706,6 +680,8 @@ account_widget_generic_format_param_name (const gchar *param_name)
   gchar *p;
   static GHashTable *translated_params = NULL;
 
+  g_return_val_if_fail (param_name != NULL, NULL);
+
   if (G_UNLIKELY (translated_params == NULL))
     translated_params = build_translated_params ();
 
@@ -738,27 +714,28 @@ accounts_widget_generic_setup (EmpathyAccountWidget *self,
     GtkWidget *grid_common_settings,
     GtkWidget *grid_advanced_settings)
 {
-  TpConnectionManagerParam *params, *param;
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+  GList *params, *l;
   guint row_common = 0, row_advanced = 0;
 
-  params = empathy_account_settings_get_tp_params (priv->settings);
+  params = empathy_account_settings_dup_tp_params (self->priv->settings);
 
-  for (param = params; param != NULL && param->name != NULL; param++)
+  for (l = params; l != NULL; l = g_list_next (l))
     {
+      TpConnectionManagerParam *param = l->data;
       GtkWidget       *grid_settings;
       guint           row;
       GtkWidget       *widget = NULL;
       gchar           *param_name_formatted;
+      const gchar *dbus_signature;
 
-      if (param->flags & TP_CONN_MGR_PARAM_FLAG_REQUIRED)
+      if (tp_connection_manager_param_is_required (param))
         {
           grid_settings = grid_common_settings;
           row = row_common++;
         }
-      else if (priv->simple)
+      else if (self->priv->simple)
         {
-          return;
+          continue;
         }
       else
         {
@@ -766,16 +743,20 @@ accounts_widget_generic_setup (EmpathyAccountWidget *self,
           row = row_advanced++;
         }
 
-      param_name_formatted = account_widget_generic_format_param_name
-        (param->name);
+      param_name_formatted = account_widget_generic_format_param_name (
+          tp_connection_manager_param_get_name (param));
+
+      dbus_signature = tp_connection_manager_param_get_dbus_signature (param);
 
-      if (param->dbus_signature[0] == 's')
+      if (dbus_signature[0] == 's')
         {
           gchar *str;
 
-          str = g_strdup_printf (_("%s:"), param_name_formatted);
+          str = g_strdup_printf (_("%s"), param_name_formatted);
           widget = gtk_label_new (str);
-          gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
+          gtk_misc_set_alignment (GTK_MISC (widget), 1., 0.5);
+          gtk_style_context_add_class (gtk_widget_get_style_context (widget),
+              GTK_STYLE_CLASS_DIM_LABEL);
           g_free (str);
 
           gtk_grid_attach (GTK_GRID (grid_settings),
@@ -784,7 +765,8 @@ accounts_widget_generic_setup (EmpathyAccountWidget *self,
           gtk_widget_show (widget);
 
           widget = gtk_entry_new ();
-          if (strcmp (param->name, "account") == 0)
+          if (strcmp (tp_connection_manager_param_get_name (param),
+                "account") == 0)
             {
               g_signal_connect (widget, "realize",
                   G_CALLBACK (gtk_widget_grab_focus),
@@ -797,21 +779,21 @@ accounts_widget_generic_setup (EmpathyAccountWidget *self,
           gtk_widget_show (widget);
         }
       /* int types: ynqiuxt. double type is 'd' */
-      else if (param->dbus_signature[0] == 'y' ||
-          param->dbus_signature[0] == 'n' ||
-          param->dbus_signature[0] == 'q' ||
-          param->dbus_signature[0] == 'i' ||
-          param->dbus_signature[0] == 'u' ||
-          param->dbus_signature[0] == 'x' ||
-          param->dbus_signature[0] == 't' ||
-          param->dbus_signature[0] == 'd')
+      else if (dbus_signature[0] == 'y' ||
+          dbus_signature[0] == 'n' ||
+          dbus_signature[0] == 'q' ||
+          dbus_signature[0] == 'i' ||
+          dbus_signature[0] == 'u' ||
+          dbus_signature[0] == 'x' ||
+          dbus_signature[0] == 't' ||
+          dbus_signature[0] == 'd')
         {
           gchar   *str = NULL;
           gdouble  minint = 0;
           gdouble  maxint = 0;
           gdouble  step = 1;
 
-          switch (param->dbus_signature[0])
+          switch (dbus_signature[0])
             {
             case 'y': minint = G_MININT8;  maxint = G_MAXINT8;   break;
             case 'n': minint = G_MININT16; maxint = G_MAXINT16;  break;
@@ -839,7 +821,7 @@ accounts_widget_generic_setup (EmpathyAccountWidget *self,
               widget, 1, row, 1, 1);
           gtk_widget_show (widget);
         }
-      else if (param->dbus_signature[0] == 'b')
+      else if (dbus_signature[0] == 'b')
         {
           widget = gtk_check_button_new_with_label (param_name_formatted);
           gtk_grid_attach (GTK_GRID (grid_settings),
@@ -849,14 +831,17 @@ accounts_widget_generic_setup (EmpathyAccountWidget *self,
       else
         {
           DEBUG ("Unknown signature for param %s: %s",
-              param_name_formatted, param->dbus_signature);
+              param_name_formatted, dbus_signature);
         }
 
       if (widget)
-        empathy_account_widget_setup_widget (self, widget, param->name);
+        empathy_account_widget_setup_widget (self, widget,
+            tp_connection_manager_param_get_name (param));
 
       g_free (param_name_formatted);
     }
+
+  g_list_free_full (params, (GDestroyNotify) tp_connection_manager_param_free);
 }
 
 static void
@@ -900,8 +885,7 @@ account_widget_account_enabled_cb (GObject *source_object,
 {
   GError *error = NULL;
   TpAccount *account = TP_ACCOUNT (source_object);
-  EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
+  EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (user_data);
 
   tp_account_set_enabled_finish (account, res, &error);
 
@@ -912,11 +896,13 @@ account_widget_account_enabled_cb (GObject *source_object,
     }
   else
     {
-      empathy_connect_new_account (account, priv->account_manager);
+      empathy_connect_new_account (account, self->priv->account_manager);
     }
 
-  /* unref widget - part of the workaround */
-  g_object_unref (widget);
+  g_signal_emit (self, signals[CLOSE], 0, GTK_RESPONSE_APPLY);
+
+  /* unref self - part of the workaround */
+  g_object_unref (self);
 }
 
 static void
@@ -927,9 +913,9 @@ account_widget_applied_cb (GObject *source_object,
   GError *error = NULL;
   TpAccount *account;
   EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source_object);
-  EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
+  EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (user_data);
   gboolean reconnect_required;
+  gboolean fire_close = TRUE;
 
   empathy_account_settings_apply_finish (settings, res, &reconnect_required,
       &error);
@@ -941,20 +927,23 @@ account_widget_applied_cb (GObject *source_object,
       return;
     }
 
-  account = empathy_account_settings_get_account (priv->settings);
+  account = empathy_account_settings_get_account (self->priv->settings);
 
   if (account != NULL)
     {
-      if (priv->creating_account)
+      if (self->priv->creating_account)
         {
           /* By default, when an account is created, we enable it. */
 
-          /* workaround to keep widget alive during async call */
-          g_object_ref (widget);
+          /* workaround to keep self alive during async call */
+          g_object_ref (self);
 
           tp_account_set_enabled_async (account, TRUE,
-              account_widget_account_enabled_cb, widget);
-          g_signal_emit (widget, signals[ACCOUNT_CREATED], 0, account);
+              account_widget_account_enabled_cb, self);
+          g_signal_emit (self, signals[ACCOUNT_CREATED], 0, account);
+
+          /* Will be fired in account_widget_account_enabled_cb */
+          fire_close = FALSE;
         }
       else
         {
@@ -977,37 +966,40 @@ account_widget_applied_cb (GObject *source_object,
         }
     }
 
-  if (!priv->destroyed)
-    account_widget_set_control_buttons_sensitivity (widget, FALSE);
+  if (!self->priv->destroyed)
+    account_widget_set_control_buttons_sensitivity (self, FALSE);
 
-  priv->contains_pending_changes = FALSE;
+  self->priv->contains_pending_changes = FALSE;
 
-  /* announce the widget can be closed */
-  g_signal_emit (widget, signals[CLOSE], 0, GTK_RESPONSE_APPLY);
+  if (fire_close)
+    {
+      /* announce the widget can be closed */
+      g_signal_emit (self, signals[CLOSE], 0, GTK_RESPONSE_APPLY);
+    }
 
   /* unref the widget - part of the workaround */
-  g_object_unref (widget);
+  g_object_unref (self);
 }
 
-static void
-account_widget_apply_and_log_in (EmpathyAccountWidget *self)
+void
+empathy_account_widget_apply_and_log_in (EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
   gboolean display_name_overridden;
 
-  if (priv->radiobutton_reuse != NULL)
+  if (self->priv->radiobutton_reuse != NULL)
     {
       gboolean reuse = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
-            priv->radiobutton_reuse));
+            self->priv->radiobutton_reuse));
 
       DEBUG ("Set register param: %d", !reuse);
-      empathy_account_settings_set_boolean (priv->settings, "register", !reuse);
+      empathy_account_settings_set (self->priv->settings, "register",
+          g_variant_new_boolean (!reuse));
     }
 
-  g_object_get (priv->settings,
+  g_object_get (self->priv->settings,
       "display-name-overridden", &display_name_overridden, NULL);
 
-  if (priv->creating_account || !display_name_overridden)
+  if (self->priv->creating_account || !display_name_overridden)
     {
       gchar *display_name;
 
@@ -1015,7 +1007,7 @@ account_widget_apply_and_log_in (EmpathyAccountWidget *self)
        * manually override it. */
       display_name = empathy_account_widget_get_default_display_name (self);
 
-      empathy_account_settings_set_display_name_async (priv->settings,
+      empathy_account_settings_set_display_name_async (self->priv->settings,
           display_name, NULL, NULL);
 
       g_free (display_name);
@@ -1023,7 +1015,7 @@ account_widget_apply_and_log_in (EmpathyAccountWidget *self)
 
   /* workaround to keep widget alive during async call */
   g_object_ref (self);
-  empathy_account_settings_apply_async (priv->settings,
+  empathy_account_settings_apply_async (self->priv->settings,
       account_widget_applied_cb, self);
 }
 
@@ -1031,7 +1023,7 @@ static void
 account_widget_apply_clicked_cb (GtkWidget *button,
     EmpathyAccountWidget *self)
 {
-    account_widget_apply_and_log_in (self);
+    empathy_account_widget_apply_and_log_in (self);
 }
 
 static void
@@ -1057,216 +1049,46 @@ account_widget_settings_ready_cb (EmpathyAccountSettings *settings,
     gpointer user_data)
 {
   EmpathyAccountWidget *self = user_data;
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
 
-  if (empathy_account_settings_is_ready (priv->settings))
+  if (empathy_account_settings_is_ready (self->priv->settings))
     account_widget_setup_generic (self);
 }
 
-static void
+static GtkWidget *
 account_widget_build_generic (EmpathyAccountWidget *self,
     const char *filename)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-  GtkWidget *expander_advanced;
+  GtkWidget *expander_advanced, *box;
 
   self->ui_details->gui = empathy_builder_get_file (filename,
-      "grid_common_settings", &priv->grid_common_settings,
-      "vbox_generic_settings", &self->ui_details->widget,
+      "grid_common_settings", &self->priv->grid_common_settings,
+      "vbox_generic_settings", &box,
       "expander_advanced_settings", &expander_advanced,
       NULL);
 
-  if (priv->simple)
+  if (self->priv->simple)
     gtk_widget_hide (expander_advanced);
 
   g_object_ref (self->ui_details->gui);
 
-  if (empathy_account_settings_is_ready (priv->settings))
+  if (empathy_account_settings_is_ready (self->priv->settings))
     account_widget_setup_generic (self);
   else
-    g_signal_connect (priv->settings, "notify::ready",
+    g_signal_connect (self->priv->settings, "notify::ready",
         G_CALLBACK (account_widget_settings_ready_cb), self);
-}
-
-static void
-account_widget_launch_external_clicked (GtkWidget *button,
-    TpAccount *account)
-{
-  GdkAppLaunchContext *context = NULL;
-  GdkDisplay *display;
-  GAppInfo *app_info;
-  GError *error = NULL;
 
-  app_info = g_object_get_data (G_OBJECT (button), "app-info");
-
-  g_return_if_fail (G_IS_APP_INFO (app_info));
-
-  display = gdk_display_get_default ();
-  context = gdk_display_get_app_launch_context (display);
-
-  if (!g_app_info_launch (app_info, NULL, (GAppLaunchContext *) context,
-        &error))
-    {
-      g_critical ("Failed to bisho: %s", error->message);
-      g_clear_error (&error);
-    }
-}
-
-static void
-account_widget_launch_external_clicked_meego (GtkWidget *button,
-    TpAccount *account)
-{
-  if (!tp_strdiff (tp_account_get_storage_provider (account),
-        "com.meego.libsocialweb"))
-    {
-      /* we know how to handle this external provider */
-      GDesktopAppInfo *desktop_info;
-      GError *error = NULL;
-      GdkAppLaunchContext *context = NULL;
-      GdkDisplay *display;
-      gchar *cmd;
-      GAppInfo *app_info;
-
-      desktop_info = g_desktop_app_info_new ("gnome-control-center.desktop");
-      if (desktop_info == NULL)
-        {
-          g_critical ("Could not locate 'gnome-control-center.desktop'");
-          return;
-        }
-
-      /* glib doesn't have API to start a desktop file with args... (#637875) */
-      cmd = g_strdup_printf ("%s bisho.desktop", g_app_info_get_commandline (
-            (GAppInfo *) desktop_info));
-
-      app_info = g_app_info_create_from_commandline (cmd, NULL, 0, &error);
-      g_free (cmd);
-
-      if (app_info == NULL)
-        {
-          DEBUG ("Failed to create app info: %s", error->message);
-          g_error_free (error);
-          goto out;
-        }
-
-      display = gdk_display_get_default ();
-      context = gdk_display_get_app_launch_context (display);
-
-      if (!g_app_info_launch (app_info, NULL, (GAppLaunchContext *) context,
-            &error))
-        {
-          g_critical ("Failed to bisho: %s", error->message);
-          g_clear_error (&error);
-        }
-
-out:
-      g_object_unref (desktop_info);
-      tp_clear_object (&app_info);
-      tp_clear_object (&context);
-    }
+  return box;
 }
 
-static void
-account_widget_build_external (EmpathyAccountWidget *self,
-    EmpathyAccountSettings *settings)
-{
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-  TpAccount *account = empathy_account_settings_get_account (settings);
-  GtkWidget *bar, *widget;
-  gchar *str;
-  const gchar *provider, *name = NULL;
-  GDesktopAppInfo *desktop_info = NULL;
-
-  self->ui_details->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
-  priv->grid_common_settings = gtk_grid_new ();
-
-  provider = tp_account_get_storage_provider (account);
-
-  if (!tp_strdiff (provider, "com.meego.libsocialweb"))
-    {
-      name = _("My Web Accounts");
-    }
-  else if (!tp_strdiff (provider, "org.gnome.OnlineAccounts"))
-    {
-      /* FIXME: we should publish the .desktop file in some general way */
-      desktop_info = g_desktop_app_info_new (
-          "gnome-online-accounts-panel.desktop");
-
-      if (desktop_info == NULL)
-        g_critical ("Could not locate 'gnome-online-accounts-panel.desktop'");
-      else
-        name = g_app_info_get_name (G_APP_INFO (desktop_info));
-    }
-
-  if (name != NULL)
-    {
-      str = g_strdup_printf (
-          _("The account %s is edited via %s."),
-          empathy_account_settings_get_display_name (settings), name);
-    }
-  else
-    {
-      str = g_strdup_printf (
-          _("The account %s cannot be edited in Empathy."),
-          empathy_account_settings_get_display_name (settings));
-    }
-
-  widget = gtk_label_new (str);
-  gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
-  g_free (str);
-
-  bar = gtk_info_bar_new ();
-  gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_INFO);
-  gtk_container_add (
-      GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))),
-      widget);
-  gtk_container_set_border_width (GTK_CONTAINER (bar), 6);
-
-  if (!tp_strdiff (provider, "com.meego.libsocialweb"))
-    {
-      /* we know how to handle this external provider */
-      widget = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
-          _("Launch My Web Accounts"), RESPONSE_LAUNCH);
-
-      g_signal_connect (widget, "clicked",
-          G_CALLBACK (account_widget_launch_external_clicked_meego), account);
-    }
-  else if (desktop_info != NULL)
-    {
-      /* general handler */
-      str = g_strdup_printf (_("Edit %s"), name);
-
-      widget = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
-          str, RESPONSE_LAUNCH);
-
-      g_object_set_data_full (G_OBJECT (widget), "app-info",
-          g_object_ref (desktop_info), g_object_unref);
-
-      g_signal_connect (widget, "clicked",
-          G_CALLBACK (account_widget_launch_external_clicked), account);
-
-      g_free (str);
-    }
-
-  gtk_box_pack_start (GTK_BOX (self->ui_details->widget), bar,
-      FALSE, TRUE, 0);
-  gtk_box_pack_start (GTK_BOX (self->ui_details->widget),
-      priv->grid_common_settings, FALSE, TRUE, 0);
-
-  gtk_widget_show_all (self->ui_details->widget);
-
-  tp_clear_object (&desktop_info);
-}
-
-static void
+static GtkWidget *
 account_widget_build_salut (EmpathyAccountWidget *self,
     const char *filename)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-  GtkWidget *expander_advanced;
+  GtkWidget *expander_advanced, *box;
 
   self->ui_details->gui = empathy_builder_get_file (filename,
-      "grid_common_settings", &priv->grid_common_settings,
-      "vbox_salut_settings", &self->ui_details->widget,
+      "grid_common_settings", &self->priv->grid_common_settings,
+      "vbox_salut_settings", &box,
       "expander_advanced_settings", &expander_advanced,
       NULL);
 
@@ -1279,68 +1101,74 @@ account_widget_build_salut (EmpathyAccountWidget *self,
       "entry_jid", "jid",
       NULL);
 
-  if (priv->simple)
+  if (self->priv->simple)
     gtk_widget_hide (expander_advanced);
 
   self->ui_details->default_focus = g_strdup ("entry_first_name");
+
+  return box;
 }
 
-static void
+static GtkWidget *
 account_widget_build_irc (EmpathyAccountWidget *self,
   const char *filename)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+  GtkWidget *box;
 
-  empathy_account_settings_set_regex (priv->settings, "account",
+  empathy_account_settings_set_regex (self->priv->settings, "account",
       ACCOUNT_REGEX_IRC);
-  empathy_account_settings_set_regex (priv->settings, "username",
-      USERNAME_REGEX_IRC);
 
-  if (priv->simple)
+  if (self->priv->simple)
     {
-      priv->irc_network_chooser = empathy_account_widget_irc_build_simple (self,
-          filename);
+      self->priv->irc_network_chooser = empathy_account_widget_irc_build_simple
+        (self, filename, &box);
     }
   else
     {
-      priv->irc_network_chooser = empathy_account_widget_irc_build (self,
-          filename, &priv->grid_common_settings);
+      self->priv->irc_network_chooser = empathy_account_widget_irc_build (self,
+          filename, &self->priv->grid_common_settings, &box);
     }
+
+  return box;
 }
 
-static void
+static GtkWidget *
 account_widget_build_sip (EmpathyAccountWidget *self,
   const char *filename)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-  empathy_account_widget_sip_build (self, filename,
-    &priv->grid_common_settings);
+  GtkWidget *box;
+
+  box = empathy_account_widget_sip_build (self, filename,
+    &self->priv->grid_common_settings);
 
-  if (priv->simple)
+  if (self->priv->simple)
     {
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password_simple"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui,
+            "remember_password_simple"));
     }
   else
     {
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui, "remember_password"));
     }
+
+  return box;
 }
 
-static void
+static GtkWidget *
 account_widget_build_msn (EmpathyAccountWidget *self,
     const char *filename)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+  GtkWidget *box;
 
-  empathy_account_settings_set_regex (priv->settings, "account",
+  empathy_account_settings_set_regex (self->priv->settings, "account",
       ACCOUNT_REGEX_MSN);
 
-  if (priv->simple)
+  if (self->priv->simple)
     {
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "vbox_msn_simple", &self->ui_details->widget,
+          "vbox_msn_simple", &box,
           NULL);
 
       empathy_account_widget_handle_params (self,
@@ -1350,14 +1178,15 @@ account_widget_build_msn (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_id_simple");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password_simple"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui,
+            "remember_password_simple"));
     }
   else
     {
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "grid_common_msn_settings", &priv->grid_common_settings,
-          "vbox_msn_settings", &self->ui_details->widget,
+          "grid_common_msn_settings", &self->priv->grid_common_settings,
+          "vbox_msn_settings", &box,
           NULL);
 
       empathy_account_widget_handle_params (self,
@@ -1369,51 +1198,55 @@ account_widget_build_msn (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_id");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui, "remember_password"));
     }
+
+  return box;
 }
 
 static void
 suffix_id_widget_changed_cb (GtkWidget *entry,
     EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-  const gchar *account;
+  gchar *account;
 
-  g_assert (priv->jid_suffix != NULL);
+  g_assert (self->priv->jid_suffix != NULL);
 
   account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE);
 
-  account = empathy_account_settings_get_string (priv->settings, "account");
+  account = empathy_account_settings_dup_string (self->priv->settings,
+      "account");
+
   if (!EMP_STR_EMPTY (account) &&
-      !g_str_has_suffix (account, priv->jid_suffix))
+      !g_str_has_suffix (account, self->priv->jid_suffix))
     {
       gchar *tmp;
 
-      tmp = g_strdup_printf ("%s%s", account, priv->jid_suffix);
+      tmp = g_strdup_printf ("%s%s", account, self->priv->jid_suffix);
 
       DEBUG ("Change account from '%s' to '%s'", account, tmp);
 
-      empathy_account_settings_set_string (priv->settings, "account", tmp);
+      empathy_account_settings_set (self->priv->settings, "account",
+          g_variant_new_string (tmp));
       g_free (tmp);
     }
 
   empathy_account_widget_changed (self);
+
+  g_free (account);
 }
 
 static gchar *
 remove_jid_suffix (EmpathyAccountWidget *self,
     const gchar *str)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+  g_assert (self->priv->jid_suffix != NULL);
 
-  g_assert (priv->jid_suffix != NULL);
-
-  if (!g_str_has_suffix (str, priv->jid_suffix))
+  if (!g_str_has_suffix (str, self->priv->jid_suffix))
     return g_strdup (str);
 
-  return g_strndup (str, strlen (str) - strlen (priv->jid_suffix));
+  return g_strndup (str, strlen (str) - strlen (self->priv->jid_suffix));
 }
 
 static void
@@ -1421,16 +1254,15 @@ setup_id_widget_with_suffix (EmpathyAccountWidget *self,
     GtkWidget *widget,
     const gchar *suffix)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-  const gchar *str = NULL;
+  gchar *str = NULL;
 
   g_object_set_data_full (G_OBJECT (widget), "param_name",
       g_strdup ("account"), g_free);
 
-  g_assert (priv->jid_suffix == NULL);
-  priv->jid_suffix = g_strdup (suffix);
+  g_assert (self->priv->jid_suffix == NULL);
+  self->priv->jid_suffix = g_strdup (suffix);
 
-  str = empathy_account_settings_get_string (priv->settings, "account");
+  str = empathy_account_settings_dup_string (self->priv->settings, "account");
   if (str != NULL)
     {
       gchar *tmp;
@@ -1438,9 +1270,10 @@ setup_id_widget_with_suffix (EmpathyAccountWidget *self,
       tmp = remove_jid_suffix (self, str);
       gtk_entry_set_text (GTK_ENTRY (widget), tmp);
       g_free (tmp);
+      g_free (str);
     }
 
-  priv->param_account_widget = widget;
+  self->priv->param_account_widget = widget;
 
   g_signal_connect (widget, "changed",
       G_CALLBACK (suffix_id_widget_changed_cb), self);
@@ -1449,11 +1282,10 @@ setup_id_widget_with_suffix (EmpathyAccountWidget *self,
 static Service
 account_widget_get_service (EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
   const gchar *icon_name, *service;
 
-  icon_name = empathy_account_settings_get_icon_name (priv->settings);
-  service = empathy_account_settings_get_service (priv->settings);
+  icon_name = empathy_account_settings_get_icon_name (self->priv->settings);
+  service = empathy_account_settings_get_service (self->priv->settings);
 
   /* Previous versions of Empathy didn't set the Service property on Facebook
    * and gtalk accounts, so we check using the icon name as well. */
@@ -1468,11 +1300,10 @@ account_widget_get_service (EmpathyAccountWidget *self)
   return NO_SERVICE;
 }
 
-static void
+static GtkWidget *
 account_widget_build_jabber (EmpathyAccountWidget *self,
     const char *filename)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
   GtkWidget *spinbutton_port;
   GtkWidget *checkbutton_ssl;
   GtkWidget *label_id, *label_password;
@@ -1481,25 +1312,27 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
   GtkWidget *label_example;
   GtkWidget *expander_advanced;
   GtkWidget *entry_id;
+  GtkWidget *box;
   Service service;
 
   service = account_widget_get_service (self);
 
-  empathy_account_settings_set_regex (priv->settings, "account",
+  empathy_account_settings_set_regex (self->priv->settings, "account",
       ACCOUNT_REGEX_JABBER);
 
-  if (priv->simple && service == NO_SERVICE)
+  if (self->priv->simple && service == NO_SERVICE)
     {
       /* Simple widget for XMPP */
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "vbox_jabber_simple", &self->ui_details->widget,
+          "vbox_jabber_simple", &box,
           "label_id_simple", &label_id,
           "label_id_create", &label_id_create,
           "label_password_simple", &label_password,
           "label_password_create", &label_password_create,
           NULL);
 
-      if (empathy_account_settings_get_boolean (priv->settings, "register"))
+      if (empathy_account_settings_get_boolean (self->priv->settings,
+            "register"))
         {
           gtk_widget_hide (label_id);
           gtk_widget_hide (label_password);
@@ -1514,14 +1347,15 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_id_simple");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password_simple"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui,
+            "remember_password_simple"));
     }
-  else if (priv->simple && service == GTALK_SERVICE)
+  else if (self->priv->simple && service == GTALK_SERVICE)
     {
       /* Simple widget for Google Talk */
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "vbox_gtalk_simple", &self->ui_details->widget,
+          "vbox_gtalk_simple", &box,
           NULL);
 
       empathy_account_widget_handle_params (self,
@@ -1531,14 +1365,15 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_id_g_simple");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password_g_simple"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui,
+            "remember_password_g_simple"));
     }
-  else if (priv->simple && service == FACEBOOK_SERVICE)
+  else if (self->priv->simple && service == FACEBOOK_SERVICE)
     {
       /* Simple widget for Facebook */
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "vbox_fb_simple", &self->ui_details->widget,
+          "vbox_fb_simple", &box,
           "entry_id_fb_simple", &entry_id,
           NULL);
 
@@ -1550,8 +1385,9 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_id_fb_simple");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password_fb_simple"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui,
+            "remember_password_fb_simple"));
     }
   else
     {
@@ -1559,8 +1395,8 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
 
       /* Full widget for XMPP, Google Talk and Facebook*/
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "grid_common_settings", &priv->grid_common_settings,
-          "vbox_jabber_settings", &self->ui_details->widget,
+          "grid_common_settings", &self->priv->grid_common_settings,
+          "vbox_jabber_settings", &box,
           "spinbutton_port", &spinbutton_port,
           "checkbutton_ssl", &checkbutton_ssl,
           "label_username_f_example", &label_example_fb,
@@ -1595,10 +1431,10 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
         }
 
       self->ui_details->default_focus = g_strdup ("entry_id");
-      priv->spinbutton_port = spinbutton_port;
+      self->priv->spinbutton_port = spinbutton_port;
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui, "remember_password"));
 
       g_signal_connect (checkbutton_ssl, "toggled",
           G_CALLBACK (account_widget_jabber_ssl_toggled_cb),
@@ -1622,22 +1458,24 @@ account_widget_build_jabber (EmpathyAccountWidget *self,
       if (!info.show_advanced)
         gtk_widget_hide (expander_advanced);
     }
+
+  return box;
 }
 
-static void
+static GtkWidget *
 account_widget_build_icq (EmpathyAccountWidget *self,
     const char *filename)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
   GtkWidget *spinbutton_port;
+  GtkWidget *box;
 
-  empathy_account_settings_set_regex (priv->settings, "account",
+  empathy_account_settings_set_regex (self->priv->settings, "account",
       ACCOUNT_REGEX_ICQ);
 
-  if (priv->simple)
+  if (self->priv->simple)
     {
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "vbox_icq_simple", &self->ui_details->widget,
+          "vbox_icq_simple", &box,
           NULL);
 
       empathy_account_widget_handle_params (self,
@@ -1647,14 +1485,15 @@ account_widget_build_icq (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_uin_simple");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password_simple"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui,
+            "remember_password_simple"));
     }
   else
     {
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "grid_common_settings", &priv->grid_common_settings,
-          "vbox_icq_settings", &self->ui_details->widget,
+          "grid_common_settings", &self->priv->grid_common_settings,
+          "vbox_icq_settings", &box,
           "spinbutton_port", &spinbutton_port,
           NULL);
 
@@ -1668,22 +1507,23 @@ account_widget_build_icq (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_uin");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui, "remember_password"));
     }
+
+  return box;
 }
 
-static void
+static GtkWidget *
 account_widget_build_aim (EmpathyAccountWidget *self,
     const char *filename)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-  GtkWidget *spinbutton_port;
+  GtkWidget *spinbutton_port, *box;
 
-  if (priv->simple)
+  if (self->priv->simple)
     {
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "vbox_aim_simple", &self->ui_details->widget,
+          "vbox_aim_simple", &box,
           NULL);
 
       empathy_account_widget_handle_params (self,
@@ -1693,14 +1533,15 @@ account_widget_build_aim (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_screenname_simple");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password_simple"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui,
+            "remember_password_simple"));
     }
   else
     {
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "grid_common_settings", &priv->grid_common_settings,
-          "vbox_aim_settings", &self->ui_details->widget,
+          "grid_common_settings", &self->priv->grid_common_settings,
+          "vbox_aim_settings", &box,
           "spinbutton_port", &spinbutton_port,
           NULL);
 
@@ -1713,24 +1554,26 @@ account_widget_build_aim (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_screenname");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui, "remember_password"));
     }
+
+  return box;
 }
 
-static void
+static GtkWidget *
 account_widget_build_yahoo (EmpathyAccountWidget *self,
     const char *filename)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+  GtkWidget *box;
 
-  empathy_account_settings_set_regex (priv->settings, "account",
+  empathy_account_settings_set_regex (self->priv->settings, "account",
       ACCOUNT_REGEX_YAHOO);
 
-  if (priv->simple)
+  if (self->priv->simple)
     {
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "vbox_yahoo_simple", &self->ui_details->widget,
+          "vbox_yahoo_simple", &box,
           NULL);
 
       empathy_account_widget_handle_params (self,
@@ -1740,14 +1583,15 @@ account_widget_build_yahoo (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_id_simple");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password_simple"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui,
+            "remember_password_simple"));
     }
   else
     {
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "grid_common_settings", &priv->grid_common_settings,
-          "vbox_yahoo_settings", &self->ui_details->widget,
+          "grid_common_settings", &self->priv->grid_common_settings,
+          "vbox_yahoo_settings", &box,
           NULL);
 
       empathy_account_widget_handle_params (self,
@@ -1761,21 +1605,23 @@ account_widget_build_yahoo (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_id");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui, "remember_password"));
     }
+
+  return box;
 }
 
-static void
+static GtkWidget *
 account_widget_build_groupwise (EmpathyAccountWidget *self,
     const char *filename)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+  GtkWidget *box;
 
-  if (priv->simple)
+  if (self->priv->simple)
     {
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "vbox_groupwise_simple", &self->ui_details->widget,
+          "vbox_groupwise_simple", &box,
           NULL);
 
       empathy_account_widget_handle_params (self,
@@ -1785,14 +1631,15 @@ account_widget_build_groupwise (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_id_simple");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password_simple"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui,
+            "remember_password_simple"));
     }
   else
     {
       self->ui_details->gui = empathy_builder_get_file (filename,
-          "grid_common_groupwise_settings", &priv->grid_common_settings,
-          "vbox_groupwise_settings", &self->ui_details->widget,
+          "grid_common_groupwise_settings", &self->priv->grid_common_settings,
+          "vbox_groupwise_settings", &box,
           NULL);
 
       empathy_account_widget_handle_params (self,
@@ -1804,31 +1651,20 @@ account_widget_build_groupwise (EmpathyAccountWidget *self,
 
       self->ui_details->default_focus = g_strdup ("entry_id");
 
-      priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
-              self->ui_details->gui, "remember_password"));
+      self->priv->remember_password_widget = GTK_WIDGET (
+          gtk_builder_get_object (self->ui_details->gui, "remember_password"));
     }
-}
-
-static void
-account_widget_destroy_cb (GtkWidget *widget,
-    EmpathyAccountWidget *self)
-{
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-  /* set the destroyed flag - workaround */
-  priv->destroyed = TRUE;
 
-  g_object_unref (self);
+  return box;
 }
 
 void
 empathy_account_widget_set_other_accounts_exist (EmpathyAccountWidget *self,
     gboolean others_exist)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
-  priv->other_accounts_exist = others_exist;
+  self->priv->other_accounts_exist = others_exist;
 
-  if (priv->creating_account)
+  if (self->priv->creating_account)
     account_widget_handle_control_buttons_sensitivity (self);
 }
 
@@ -1838,18 +1674,18 @@ do_set_property (GObject *object,
     const GValue *value,
     GParamSpec *pspec)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
+  EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (object);
 
   switch (prop_id)
     {
     case PROP_SETTINGS:
-      priv->settings = g_value_dup_object (value);
+      self->priv->settings = g_value_dup_object (value);
       break;
     case PROP_SIMPLE:
-      priv->simple = g_value_get_boolean (value);
+      self->priv->simple = g_value_get_boolean (value);
       break;
     case PROP_CREATING_ACCOUNT:
-      priv->creating_account = g_value_get_boolean (value);
+      self->priv->creating_account = g_value_get_boolean (value);
       break;
     case PROP_OTHER_ACCOUNTS_EXIST:
       empathy_account_widget_set_other_accounts_exist (
@@ -1866,25 +1702,25 @@ do_get_property (GObject *object,
     GValue *value,
     GParamSpec *pspec)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
+  EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (object);
 
   switch (prop_id)
     {
     case PROP_PROTOCOL:
       g_value_set_string (value,
-        empathy_account_settings_get_protocol (priv->settings));
+        empathy_account_settings_get_protocol (self->priv->settings));
       break;
     case PROP_SETTINGS:
-      g_value_set_object (value, priv->settings);
+      g_value_set_object (value, self->priv->settings);
       break;
     case PROP_SIMPLE:
-      g_value_set_boolean (value, priv->simple);
+      g_value_set_boolean (value, self->priv->simple);
       break;
     case PROP_CREATING_ACCOUNT:
-      g_value_set_boolean (value, priv->creating_account);
+      g_value_set_boolean (value, self->priv->creating_account);
       break;
     case PROP_OTHER_ACCOUNTS_EXIST:
-      g_value_set_boolean (value, priv->other_accounts_exist);
+      g_value_set_boolean (value, self->priv->other_accounts_exist);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1894,18 +1730,17 @@ do_get_property (GObject *object,
 static void
 set_apply_button (EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
   GtkWidget *image;
 
   /* We can't use the stock button as its accelerator ('A') clashes with the
    * Add button. */
-  gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), FALSE);
+  gtk_button_set_use_stock (GTK_BUTTON (self->priv->apply_button), FALSE);
 
-  gtk_button_set_label (GTK_BUTTON (priv->apply_button), _("A_pply"));
-  gtk_button_set_use_underline (GTK_BUTTON (priv->apply_button), TRUE);
+  gtk_button_set_label (GTK_BUTTON (self->priv->apply_button), _("A_pply"));
+  gtk_button_set_use_underline (GTK_BUTTON (self->priv->apply_button), TRUE);
 
   image = gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_BUTTON);
-  gtk_button_set_image (GTK_BUTTON (priv->apply_button), image);
+  gtk_button_set_image (GTK_BUTTON (self->priv->apply_button), image);
 }
 
 static void
@@ -1915,27 +1750,26 @@ presence_changed_cb (TpAccountManager *manager,
     const gchar *message,
     EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
-  if (priv->destroyed)
+  if (self->priv->destroyed)
     return;
 
-  if (priv->apply_button == NULL)
+  if (self->priv->apply_button == NULL)
     /* This button doesn't exist in 'simple' mode */
     return;
 
   if (state > TP_CONNECTION_PRESENCE_TYPE_OFFLINE &&
-      priv->creating_account)
+      self->priv->creating_account)
     {
       /* We are online and creating a new account, display a Login button */
       GtkWidget *image;
 
-      gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), FALSE);
-      gtk_button_set_label (GTK_BUTTON (priv->apply_button), _("L_og in"));
+      gtk_button_set_use_stock (GTK_BUTTON (self->priv->apply_button), FALSE);
+      gtk_button_set_label (GTK_BUTTON (self->priv->apply_button),
+          _("L_og in"));
 
       image = gtk_image_new_from_stock (GTK_STOCK_CONNECT,
           GTK_ICON_SIZE_BUTTON);
-      gtk_button_set_image (GTK_BUTTON (priv->apply_button), image);
+      gtk_button_set_image (GTK_BUTTON (self->priv->apply_button), image);
     }
   else
     {
@@ -1977,64 +1811,54 @@ out:
   { #cm, #proto, "empathy-account-widget-"#proto".ui", \
     account_widget_build_##proto }
 
-#ifndef HAVE_MEEGO
-/* Meego doesn't support registration */
 static void
 add_register_buttons (EmpathyAccountWidget *self,
     TpAccount *account)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-  const TpConnectionManagerProtocol *protocol;
+  TpProtocol *protocol;
   GtkWidget *radiobutton_register;
-  GtkWidget *vbox = self->ui_details->widget;
 
-  if (!priv->creating_account)
+  if (!self->priv->creating_account)
     return;
 
-  protocol = empathy_account_settings_get_tp_protocol (priv->settings);
+  protocol = empathy_account_settings_get_tp_protocol (self->priv->settings);
   if (protocol == NULL)
     return;
 
-  if (!tp_connection_manager_protocol_can_register (protocol))
+  if (!tp_protocol_can_register (protocol))
     return;
 
   if (account_widget_get_service (self) != NO_SERVICE)
     return;
 
-  if (priv->simple)
+  if (self->priv->simple)
     return;
 
-  priv->radiobutton_reuse = gtk_radio_button_new_with_label (NULL,
+  self->priv->radiobutton_reuse = gtk_radio_button_new_with_label (NULL,
       _("This account already exists on the server"));
   radiobutton_register = gtk_radio_button_new_with_label (
-      gtk_radio_button_get_group (GTK_RADIO_BUTTON (priv->radiobutton_reuse)),
+      gtk_radio_button_get_group (
+        GTK_RADIO_BUTTON (self->priv->radiobutton_reuse)),
       _("Create a new account on the server"));
 
-  gtk_box_pack_start (GTK_BOX (vbox), priv->radiobutton_reuse, FALSE, FALSE, 0);
-  gtk_box_pack_start (GTK_BOX (vbox), radiobutton_register, FALSE, FALSE, 0);
-  gtk_box_reorder_child (GTK_BOX (vbox), priv->radiobutton_reuse, 0);
-  gtk_box_reorder_child (GTK_BOX (vbox), radiobutton_register, 1);
-  gtk_widget_show (priv->radiobutton_reuse);
+  gtk_box_pack_start (GTK_BOX (self), self->priv->radiobutton_reuse, FALSE,
+      FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (self), radiobutton_register, FALSE, FALSE, 0);
+  gtk_box_reorder_child (GTK_BOX (self), self->priv->radiobutton_reuse, 0);
+  gtk_box_reorder_child (GTK_BOX (self), radiobutton_register, 1);
+  gtk_widget_show (self->priv->radiobutton_reuse);
   gtk_widget_show (radiobutton_register);
 }
-#endif /* HAVE_MEEGO */
 
 static void
 remember_password_toggled_cb (GtkToggleButton *button,
     EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+  empathy_account_settings_set_remember_password (self->priv->settings,
+      gtk_toggle_button_get_active (button));
 
-  if (gtk_toggle_button_get_active (button))
-    {
-      gtk_widget_set_sensitive (priv->param_password_widget, TRUE);
-    }
-  else
-    {
-      gtk_widget_set_sensitive (priv->param_password_widget, FALSE);
-      gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), "");
-      empathy_account_settings_unset (priv->settings, "password");
-    }
+  if (!self->priv->automatic_change)
+    empathy_account_widget_changed (self);
 }
 
 static void
@@ -2042,44 +1866,48 @@ account_settings_password_retrieved_cb (GObject *object,
     gpointer user_data)
 {
   EmpathyAccountWidget *self = user_data;
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-  const gchar *password = empathy_account_settings_get_string (
-      priv->settings, "password");
+  gchar *password;
+
+  password = empathy_account_settings_dup_string (
+      self->priv->settings, "password");
+
+  /* We have to do this so that when we call gtk_entry_set_text,
+   * the ::changed callback doesn't think the user made the
+   * change. This is also used in remember_password_toggled_cb. */
+  self->priv->automatic_change = TRUE;
 
   if (password != NULL)
     {
-      /* We have to do this so that when we call gtk_entry_set_text,
-       * the ::changed callback doesn't think the user made the
-       * change. */
-      priv->automatic_change = TRUE;
-      gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), password);
-      priv->automatic_change = FALSE;
+      gtk_entry_set_text (GTK_ENTRY (self->priv->param_password_widget),
+          password);
     }
 
   gtk_toggle_button_set_active (
-      GTK_TOGGLE_BUTTON (priv->remember_password_widget),
+      GTK_TOGGLE_BUTTON (self->priv->remember_password_widget),
       !EMP_STR_EMPTY (password));
+
+  self->priv->automatic_change = FALSE;
+
+  g_free (password);
 }
 
 static void
 do_constructed (GObject *obj)
 {
   EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
   TpAccount *account;
-  TpStorageRestrictionFlags storage_restrictions;
   const gchar *display_name, *default_display_name;
   guint i = 0;
   struct {
     const gchar *cm_name;
     const gchar *protocol;
     const char *file;
-    void (*func)(EmpathyAccountWidget *self, const gchar *filename);
+    GtkWidget * (*func)(EmpathyAccountWidget *self, const gchar *filename);
   } widgets [] = {
     { "salut", "local-xmpp", "empathy-account-widget-local-xmpp.ui",
         account_widget_build_salut },
     WIDGET (gabble, jabber),
-    WIDGET (butterfly, msn),
+    WIDGET (haze, msn),
     WIDGET (haze, icq),
     WIDGET (haze, aim),
     WIDGET (haze, yahoo),
@@ -2087,53 +1915,40 @@ do_constructed (GObject *obj)
     WIDGET (idle, irc),
     WIDGET (sofiasip, sip),
   };
+  const gchar *protocol, *cm_name;
+  GtkWidget *box;
 
-  account = empathy_account_settings_get_account (priv->settings);
+  account = empathy_account_settings_get_account (self->priv->settings);
 
-  if (account != NULL)
-    storage_restrictions = tp_account_get_storage_restrictions (account);
-  else
-    storage_restrictions = 0;
+  cm_name = empathy_account_settings_get_cm (self->priv->settings);
+  protocol = empathy_account_settings_get_protocol (self->priv->settings);
 
-  /* Empathy can only edit accounts without the Cannot_Set_Parameters flag */
-  if (storage_restrictions & TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS)
+  for (i = 0 ; i < G_N_ELEMENTS (widgets); i++)
     {
-      DEBUG ("Account is provided by an external storage provider");
-
-      account_widget_build_external (self, priv->settings);
-    }
-  else
-    {
-      const gchar *protocol, *cm_name;
-
-      cm_name = empathy_account_settings_get_cm (priv->settings);
-      protocol = empathy_account_settings_get_protocol (priv->settings);
-
-      for (i = 0 ; i < G_N_ELEMENTS (widgets); i++)
+      if (!tp_strdiff (widgets[i].cm_name, cm_name) &&
+          !tp_strdiff (widgets[i].protocol, protocol))
         {
-          if (!tp_strdiff (widgets[i].cm_name, cm_name) &&
-              !tp_strdiff (widgets[i].protocol, protocol))
-            {
-              gchar *filename;
+          gchar *filename;
 
-              filename = empathy_file_lookup (widgets[i].file,
-                  "libempathy-gtk");
-              widgets[i].func (self, filename);
-              g_free (filename);
+          filename = empathy_file_lookup (widgets[i].file,
+              "libempathy-gtk");
+          box = widgets[i].func (self, filename);
+          g_free (filename);
 
-              break;
-            }
+          break;
         }
+    }
 
-      if (i == G_N_ELEMENTS (widgets))
-        {
-          gchar *filename = empathy_file_lookup (
-              "empathy-account-widget-generic.ui", "libempathy-gtk");
-          account_widget_build_generic (self, filename);
-          g_free (filename);
-        }
+  if (i == G_N_ELEMENTS (widgets))
+    {
+      gchar *filename = empathy_file_lookup (
+          "empathy-account-widget-generic.ui", "libempathy-gtk");
+      box = account_widget_build_generic (self, filename);
+      g_free (filename);
     }
 
+  gtk_container_add (GTK_CONTAINER (self), box);
+
   /* handle default focus */
   if (self->ui_details->default_focus != NULL)
     {
@@ -2147,118 +1962,118 @@ do_constructed (GObject *obj)
     }
 
   /* remember password */
-  if (priv->param_password_widget != NULL
-      && priv->remember_password_widget != NULL
-      && empathy_account_settings_supports_sasl (priv->settings))
+  if (self->priv->param_password_widget != NULL
+      && self->priv->remember_password_widget != NULL
+      && empathy_account_settings_supports_sasl (self->priv->settings))
     {
-      if (priv->simple)
+      if (self->priv->simple)
         {
           gtk_toggle_button_set_active (
-              GTK_TOGGLE_BUTTON (priv->remember_password_widget), TRUE);
+              GTK_TOGGLE_BUTTON (self->priv->remember_password_widget), TRUE);
         }
       else
         {
+          gchar *password;
+
+          password = empathy_account_settings_dup_string (self->priv->settings,
+              "password");
+
+          /* FIXME: we should enable this checkbox only if the password is
+           * stored for good in the password storage, not only for the session
+           * (bgo #683571) */
           gtk_toggle_button_set_active (
-              GTK_TOGGLE_BUTTON (priv->remember_password_widget),
-              !EMP_STR_EMPTY (empathy_account_settings_get_string (
-                      priv->settings, "password")));
+              GTK_TOGGLE_BUTTON (self->priv->remember_password_widget),
+              !EMP_STR_EMPTY (password));
 
           /* The password might not have been retrieved from the
            * keyring yet. We should update the remember password
            * toggle button and the password entry when/if it is. */
-          tp_g_signal_connect_object (priv->settings, "password-retrieved",
+          tp_g_signal_connect_object (self->priv->settings,
+              "password-retrieved",
               G_CALLBACK (account_settings_password_retrieved_cb), self, 0);
+
+          g_free (password);
         }
 
-      g_signal_connect (priv->remember_password_widget, "toggled",
+      g_signal_connect (self->priv->remember_password_widget, "toggled",
           G_CALLBACK (remember_password_toggled_cb), self);
 
+      self->priv->automatic_change = TRUE;
       remember_password_toggled_cb (
-          GTK_TOGGLE_BUTTON (priv->remember_password_widget), self);
+          GTK_TOGGLE_BUTTON (self->priv->remember_password_widget), self);
+      self->priv->automatic_change = FALSE;
     }
-  else if (priv->remember_password_widget != NULL
-      && !empathy_account_settings_supports_sasl (priv->settings))
+  else if (self->priv->remember_password_widget != NULL
+      && !empathy_account_settings_supports_sasl (self->priv->settings))
     {
-      gtk_widget_set_visible (priv->remember_password_widget, FALSE);
+      gtk_widget_set_visible (self->priv->remember_password_widget, FALSE);
+      empathy_account_settings_set_remember_password (self->priv->settings,
+          TRUE);
     }
 
   /* dup and init the account-manager */
-  priv->account_manager = tp_account_manager_dup ();
+  self->priv->account_manager = tp_account_manager_dup ();
 
   g_object_ref (self);
-  tp_proxy_prepare_async (priv->account_manager, NULL,
+  tp_proxy_prepare_async (self->priv->account_manager, NULL,
       account_manager_ready_cb, self);
 
   /* handle apply and cancel button */
-  if (!priv->simple &&
-      !(storage_restrictions &
-        TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS))
-    {
-      GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
-
-      gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE);
-
-      priv->cancel_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
-
-      priv->apply_button = gtk_button_new ();
-      set_apply_button (self);
-
-      /* We'll change this button to a "Log in" one if we are creating a new
-       * account and are connected. */
-      tp_g_signal_connect_object (priv->account_manager,
-          "most-available-presence-changed",
-          G_CALLBACK (presence_changed_cb), obj, 0);
-
-      gtk_box_pack_end (GTK_BOX (hbox), priv->apply_button, TRUE,
-          TRUE, 3);
-      gtk_box_pack_end (GTK_BOX (hbox), priv->cancel_button, TRUE,
-          TRUE, 3);
-
-      gtk_box_pack_end (GTK_BOX (self->ui_details->widget), hbox, FALSE,
-          FALSE, 3);
-
-      g_signal_connect (priv->cancel_button, "clicked",
-          G_CALLBACK (account_widget_cancel_clicked_cb),
-          self);
-      g_signal_connect (priv->apply_button, "clicked",
-          G_CALLBACK (account_widget_apply_clicked_cb),
-          self);
-      gtk_widget_show_all (hbox);
-
-      if (priv->creating_account)
-        /* When creating an account, the user might have nothing to enter.
-         * That means that no control interaction might occur,
-         * so we update the control button sensitivity manually.
-         */
-        account_widget_handle_control_buttons_sensitivity (self);
-      else
-        account_widget_set_control_buttons_sensitivity (self, FALSE);
-    }
+  self->priv->hbox_buttons = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
+
+  gtk_box_set_homogeneous (GTK_BOX (self->priv->hbox_buttons), TRUE);
+
+  self->priv->cancel_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+
+  self->priv->apply_button = gtk_button_new ();
+  set_apply_button (self);
+
+  /* We'll change this button to a "Log in" one if we are creating a new
+   * account and are connected. */
+  tp_g_signal_connect_object (self->priv->account_manager,
+      "most-available-presence-changed",
+      G_CALLBACK (presence_changed_cb), obj, 0);
+
+  gtk_box_pack_end (GTK_BOX (self->priv->hbox_buttons),
+      self->priv->apply_button, TRUE, TRUE, 3);
+  gtk_box_pack_end (GTK_BOX (self->priv->hbox_buttons),
+      self->priv->cancel_button, TRUE, TRUE, 3);
+
+  gtk_box_pack_end (GTK_BOX (self), self->priv->hbox_buttons, FALSE,
+      FALSE, 3);
+
+  g_signal_connect (self->priv->cancel_button, "clicked",
+      G_CALLBACK (account_widget_cancel_clicked_cb),
+      self);
+  g_signal_connect (self->priv->apply_button, "clicked",
+      G_CALLBACK (account_widget_apply_clicked_cb),
+      self);
+  gtk_widget_show_all (self->priv->hbox_buttons);
+
+  if (self->priv->creating_account)
+    /* When creating an account, the user might have nothing to enter.
+     * That means that no control interaction might occur,
+     * so we update the control button sensitivity manually.
+     */
+    account_widget_handle_control_buttons_sensitivity (self);
+  else
+    account_widget_set_control_buttons_sensitivity (self, FALSE);
 
-#ifndef HAVE_MEEGO
   add_register_buttons (self, account);
-#endif /* HAVE_MEEGO */
 
-  /* hook up to widget destruction to unref ourselves */
-  g_signal_connect (self->ui_details->widget, "destroy",
-      G_CALLBACK (account_widget_destroy_cb), self);
+  g_clear_object (&self->ui_details->gui);
 
-  if (self->ui_details->gui != NULL)
-    {
-      empathy_builder_unref_and_keep_widget (self->ui_details->gui,
-          self->ui_details->widget);
-      self->ui_details->gui = NULL;
-    }
-
-  display_name = empathy_account_settings_get_display_name (priv->settings);
+  display_name = empathy_account_settings_get_display_name (
+      self->priv->settings);
   default_display_name = empathy_account_widget_get_default_display_name (self);
 
   if (tp_strdiff (display_name, default_display_name) &&
-      !priv->creating_account)
+      !self->priv->creating_account)
     {
       /* The display name of the account is not the one that we'd assign by
        * default; assume that the user changed it manually */
-      g_object_set (priv->settings, "display-name-overridden", TRUE, NULL);
+      g_object_set (self->priv->settings, "display-name-overridden", TRUE,
+          NULL);
     }
 }
 
@@ -2266,24 +2081,9 @@ static void
 do_dispose (GObject *obj)
 {
   EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
-  if (priv->dispose_run)
-    return;
-
-  priv->dispose_run = TRUE;
 
-  if (priv->settings != NULL)
-    {
-      g_object_unref (priv->settings);
-      priv->settings = NULL;
-    }
-
-  if (priv->account_manager != NULL)
-    {
-      g_object_unref (priv->account_manager);
-      priv->account_manager = NULL;
-    }
+  g_clear_object (&self->priv->settings);
+  g_clear_object (&self->priv->account_manager);
 
   if (G_OBJECT_CLASS (empathy_account_widget_parent_class)->dispose != NULL)
     G_OBJECT_CLASS (empathy_account_widget_parent_class)->dispose (obj);
@@ -2293,12 +2093,11 @@ static void
 do_finalize (GObject *obj)
 {
   EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
 
   g_free (self->ui_details->default_focus);
   g_slice_free (EmpathyAccountWidgetUIDetails, self->ui_details);
 
-  g_free (priv->jid_suffix);
+  g_free (self->priv->jid_suffix);
 
   if (G_OBJECT_CLASS (empathy_account_widget_parent_class)->finalize != NULL)
     G_OBJECT_CLASS (empathy_account_widget_parent_class)->finalize (obj);
@@ -2384,34 +2183,25 @@ empathy_account_widget_class_init (EmpathyAccountWidgetClass *klass)
 static void
 empathy_account_widget_init (EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv =
-    G_TYPE_INSTANCE_GET_PRIVATE ((self), EMPATHY_TYPE_ACCOUNT_WIDGET,
+  self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), EMPATHY_TYPE_ACCOUNT_WIDGET,
         EmpathyAccountWidgetPriv);
 
-  self->priv = priv;
-  priv->dispose_run = FALSE;
-
   self->ui_details = g_slice_new0 (EmpathyAccountWidgetUIDetails);
 }
 
 /* public methods */
 
 void
-empathy_account_widget_discard_pending_changes
-    (EmpathyAccountWidget *widget)
+empathy_account_widget_discard_pending_changes (EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
-
-  empathy_account_settings_discard_changes (priv->settings);
-  priv->contains_pending_changes = FALSE;
+  empathy_account_settings_discard_changes (self->priv->settings);
+  self->priv->contains_pending_changes = FALSE;
 }
 
 gboolean
-empathy_account_widget_contains_pending_changes (EmpathyAccountWidget *widget)
+empathy_account_widget_contains_pending_changes (EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
-
-  return priv->contains_pending_changes;
+  return self->priv->contains_pending_changes;
 }
 
 void
@@ -2426,41 +2216,32 @@ empathy_account_widget_handle_params (EmpathyAccountWidget *self,
   va_end (args);
 }
 
-GtkWidget *
-empathy_account_widget_get_widget (EmpathyAccountWidget *widget)
-{
-  return widget->ui_details->widget;
-}
-
 EmpathyAccountWidget *
 empathy_account_widget_new_for_protocol (EmpathyAccountSettings *settings,
     gboolean simple)
 {
-  EmpathyAccountWidget *self;
-
   g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings), NULL);
 
-  self = g_object_new
-    (EMPATHY_TYPE_ACCOUNT_WIDGET,
-        "settings", settings, "simple", simple,
+  return g_object_new (EMPATHY_TYPE_ACCOUNT_WIDGET,
+        "orientation", GTK_ORIENTATION_VERTICAL,
+        "settings", settings,
+        "simple", simple,
         "creating-account",
-        empathy_account_settings_get_account (settings) == NULL,
+          empathy_account_settings_get_account (settings) == NULL,
         NULL);
-
-  return self;
 }
 
 gchar *
 empathy_account_widget_get_default_display_name (EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-  const gchar *login_id;
+  gchar *login_id;
   const gchar *protocol, *p;
   gchar *default_display_name;
   Service service;
 
-  login_id = empathy_account_settings_get_string (priv->settings, "account");
-  protocol = empathy_account_settings_get_protocol (priv->settings);
+  login_id = empathy_account_settings_dup_string (self->priv->settings,
+      "account");
+  protocol = empathy_account_settings_get_protocol (self->priv->settings);
   service = account_widget_get_service (self);
 
   if (login_id != NULL)
@@ -2471,7 +2252,7 @@ empathy_account_widget_get_default_display_name (EmpathyAccountWidget *self)
           EmpathyIrcNetwork *network;
 
           network = empathy_irc_network_chooser_get_network (
-              priv->irc_network_chooser);
+              self->priv->irc_network_chooser);
           g_assert (network != NULL);
 
           /* To translators: The first parameter is the login id and the
@@ -2482,7 +2263,7 @@ empathy_account_widget_get_default_display_name (EmpathyAccountWidget *self)
           default_display_name = g_strdup_printf (_("%1$s on %2$s"),
               login_id, empathy_irc_network_get_name (network));
         }
-      else if (service == FACEBOOK_SERVICE && priv->jid_suffix != NULL)
+      else if (service == FACEBOOK_SERVICE && self->priv->jid_suffix != NULL)
         {
           gchar *tmp;
 
@@ -2512,6 +2293,8 @@ empathy_account_widget_get_default_display_name (EmpathyAccountWidget *self)
       default_display_name = g_strdup (_("New account"));
     }
 
+  g_free (login_id);
+
   return default_display_name;
 }
 
@@ -2519,40 +2302,38 @@ empathy_account_widget_get_default_display_name (EmpathyAccountWidget *self)
 void
 empathy_account_widget_changed (EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
   account_widget_handle_control_buttons_sensitivity (self);
-  priv->contains_pending_changes = TRUE;
+  self->priv->contains_pending_changes = TRUE;
 }
 
 void
 empathy_account_widget_set_account_param (EmpathyAccountWidget *self,
     const gchar *account)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
-  if (priv->param_account_widget == NULL)
+  if (self->priv->param_account_widget == NULL)
     return;
 
-  gtk_entry_set_text (GTK_ENTRY (priv->param_account_widget), account);
+  gtk_entry_set_text (GTK_ENTRY (self->priv->param_account_widget), account);
 }
 
 void
 empathy_account_widget_set_password_param (EmpathyAccountWidget *self,
     const gchar *account)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-
-  if (priv->param_password_widget == NULL)
+  if (self->priv->param_password_widget == NULL)
     return;
 
-  gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), account);
+  gtk_entry_set_text (GTK_ENTRY (self->priv->param_password_widget), account);
 }
 
 EmpathyAccountSettings *
 empathy_account_widget_get_settings (EmpathyAccountWidget *self)
 {
-  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+  return self->priv->settings;
+}
 
-  return priv->settings;
+void
+empathy_account_widget_hide_buttons (EmpathyAccountWidget *self)
+{
+  gtk_widget_hide (self->priv->hbox_buttons);
 }