+
+ priv->account_dialogs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+}
+
+static gboolean
+remove_account (const gchar *account_name, GObject *account, GObject *account_to_remove)
+{
+ return (account == account_to_remove);
+}
+
+static void
+account_dialog_weak_handler (ModestAccountProtocol *self, GObject *where_the_object_was)
+{
+ ModestAccountProtocolPrivate *priv = MODEST_ACCOUNT_PROTOCOL_GET_PRIVATE (self);
+
+ g_hash_table_foreach_remove (priv->account_dialogs, (GHRFunc) remove_account, where_the_object_was);
+}
+
+static gboolean
+dialogs_remove (const gchar *account_name, GObject *account_dialog, ModestAccountProtocol *self)
+{
+ g_object_weak_unref (account_dialog, (GWeakNotify) account_dialog_weak_handler, self);
+
+ return TRUE;