[empathy: 5/14] Port the main of empathy to EmpathyAccount



commit dd54eb8205f1cd12267af127dab79297c0edc469
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date:   Fri Jun 26 14:49:13 2009 +0100

    Port the main of empathy to EmpathyAccount

 src/empathy-accounts-dialog.c     |  125 ++++++++++++++++++-------------------
 src/empathy-accounts-dialog.h     |    4 +-
 src/empathy-chat-window.c         |   26 ++++----
 src/empathy-chat-window.h         |    4 +-
 src/empathy-chatrooms-window.c    |    4 +-
 src/empathy-event-manager.c       |   11 +---
 src/empathy-import-dialog.c       |   24 ++++---
 src/empathy-import-dialog.h       |    1 +
 src/empathy-import-pidgin.c       |    1 -
 src/empathy-main-window.c         |   25 +++----
 src/empathy-new-chatroom-dialog.c |   16 +++--
 src/empathy-status-icon.c         |   16 +++--
 src/empathy.c                     |   22 ++++---
 13 files changed, 141 insertions(+), 138 deletions(-)
---
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 4cf3911..98e8485 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -31,7 +31,6 @@
 #include <glib/gi18n.h>
 #include <dbus/dbus-glib.h>
 
-#include <libmissioncontrol/mc-account.h>
 #include <libmissioncontrol/mc-profile.h>
 #include <telepathy-glib/util.h>
 
@@ -96,7 +95,7 @@ enum {
 };
 
 static void       accounts_dialog_update_account            (EmpathyAccountsDialog    *dialog,
-							     McAccount                *account);
+							     EmpathyAccount           *account);
 static void       accounts_dialog_model_setup               (EmpathyAccountsDialog    *dialog);
 static void       accounts_dialog_model_add_columns         (EmpathyAccountsDialog    *dialog);
 static void       accounts_dialog_name_editing_started_cb   (GtkCellRenderer          *renderer,
@@ -109,19 +108,19 @@ static void       accounts_dialog_model_pixbuf_data_func    (GtkTreeViewColumn
 							     GtkTreeModel             *model,
 							     GtkTreeIter              *iter,
 							     EmpathyAccountsDialog    *dialog);
-static McAccount *accounts_dialog_model_get_selected        (EmpathyAccountsDialog    *dialog);
+static EmpathyAccount *accounts_dialog_model_get_selected        (EmpathyAccountsDialog    *dialog);
 static void       accounts_dialog_model_set_selected        (EmpathyAccountsDialog    *dialog,
-							     McAccount                *account);
+							     EmpathyAccount           *account);
 static gboolean   accounts_dialog_model_remove_selected     (EmpathyAccountsDialog    *dialog);
 static void       accounts_dialog_model_selection_changed   (GtkTreeSelection         *selection,
 							     EmpathyAccountsDialog    *dialog);
 static void       accounts_dialog_add_or_update_account     (EmpathyAccountsDialog    *dialog,
-							     McAccount                *account);
+							     EmpathyAccount           *account);
 static void       accounts_dialog_account_added_cb          (EmpathyAccountManager    *manager,
-							     McAccount                *account,
+							     EmpathyAccount           *account,
 							     EmpathyAccountsDialog    *dialog);
 static void       accounts_dialog_account_removed_cb        (EmpathyAccountManager    *manager,
-							     McAccount                *account,
+							     EmpathyAccount           *account,
 							     EmpathyAccountsDialog    *dialog);
 static gboolean   accounts_dialog_row_changed_foreach       (GtkTreeModel             *model,
 							     GtkTreePath              *path,
@@ -129,7 +128,7 @@ static gboolean   accounts_dialog_row_changed_foreach       (GtkTreeModel
 							     gpointer                  user_data);
 static gboolean   accounts_dialog_flash_connecting_cb       (EmpathyAccountsDialog    *dialog);
 static void       accounts_dialog_connection_changed_cb     (EmpathyAccountManager    *manager,
-							     McAccount                *account,
+							     EmpathyAccount           *account,
 							     TpConnectionStatusReason  reason,
 							     TpConnectionStatus        current,
 							     TpConnectionStatus        previous,
@@ -154,12 +153,12 @@ static void       accounts_dialog_destroy_cb                (GtkWidget
 
 static void
 accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
-				   McAccount             *account)
+				   EmpathyAccount        *account)
 {
 	gchar *text;
 
 	text = g_markup_printf_escaped ("<big><b>%s</b></big>",
-			mc_account_get_display_name (account));
+			empathy_account_get_display_name (account));
 	gtk_label_set_markup (GTK_LABEL (dialog->label_name), text);
 
 	g_free (text);
@@ -167,7 +166,7 @@ accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
 
 static void
 accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
-				McAccount            *account)
+				EmpathyAccount       *account)
 {
 	McProfile   *profile;
 	const gchar *config_ui;
@@ -216,7 +215,7 @@ accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
 		dialog->settings_widget = NULL;
 	}
 
-	profile = mc_account_get_profile (account);
+	profile = empathy_account_get_profile (account);
 	config_ui = mc_profile_get_configuration_ui (profile);
 	if (!tp_strdiff (config_ui, "jabber")) {
 		dialog->settings_widget =
@@ -282,10 +281,10 @@ accounts_dialog_model_setup (EmpathyAccountsDialog *dialog)
 	GtkTreeSelection *selection;
 
 	store = gtk_list_store_new (COL_COUNT,
-				    G_TYPE_BOOLEAN,    /* enabled */
-				    G_TYPE_STRING,     /* name */
-				    G_TYPE_UINT,       /* status */
-				    MC_TYPE_ACCOUNT);  /* account */
+				    G_TYPE_BOOLEAN,        /* enabled */
+				    G_TYPE_STRING,         /* name */
+				    G_TYPE_UINT,           /* status */
+				    EMPATHY_TYPE_ACCOUNT); /* account */
 
 	gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->treeview),
 				 GTK_TREE_MODEL (store));
@@ -311,7 +310,7 @@ accounts_dialog_name_edited_cb (GtkCellRendererText   *renderer,
 				gchar                 *new_text,
 				EmpathyAccountsDialog *dialog)
 {
-	McAccount    *account;
+	EmpathyAccount    *account;
 	GtkTreeModel *model;
 	GtkTreePath  *treepath;
 	GtkTreeIter   iter;
@@ -333,7 +332,7 @@ accounts_dialog_name_edited_cb (GtkCellRendererText   *renderer,
 			    -1);
 	gtk_tree_path_free (treepath);
 
-	mc_account_set_display_name (account, new_text);
+	empathy_account_set_display_name (account, new_text);
 	g_object_unref (account);
 }
 
@@ -342,7 +341,7 @@ accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer,
 				   gchar                 *path,
 				   EmpathyAccountsDialog *dialog)
 {
-	McAccount    *account;
+	EmpathyAccount    *account;
 	GtkTreeModel *model;
 	GtkTreePath  *treepath;
 	GtkTreeIter   iter;
@@ -356,11 +355,11 @@ accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer,
 			    -1);
 	gtk_tree_path_free (treepath);
 
-	enabled = mc_account_is_enabled (account);
-	mc_account_set_enabled (account, !enabled);
+	enabled = empathy_account_is_enabled (account);
+	empathy_account_set_enabled (account, !enabled);
 
 	DEBUG ("%s account %s", enabled ? "Disabled" : "Enable",
-		mc_account_get_display_name (account));
+		empathy_account_get_display_name (account));
 
 	g_object_unref (account);
 }
@@ -457,7 +456,7 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn    *tree_column,
 					GtkTreeIter          *iter,
 					EmpathyAccountsDialog *dialog)
 {
-	McAccount          *account;
+	EmpathyAccount     *account;
 	const gchar        *icon_name;
 	GdkPixbuf          *pixbuf;
 	TpConnectionStatus  status;
@@ -504,7 +503,7 @@ accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn    *tree_column,
 
 static gboolean
 accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog,
-				 McAccount             *account,
+				 EmpathyAccount        *account,
 				 GtkTreeIter           *iter)
 {
 	GtkTreeView      *view;
@@ -520,7 +519,7 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog,
 	for (ok = gtk_tree_model_get_iter_first (model, iter);
 	     ok;
 	     ok = gtk_tree_model_iter_next (model, iter)) {
-		McAccount *this_account;
+		EmpathyAccount *this_account;
 		gboolean   equal;
 
 		gtk_tree_model_get (model, iter,
@@ -538,14 +537,14 @@ accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog,
 	return FALSE;
 }
 
-static McAccount *
+static EmpathyAccount *
 accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog)
 {
 	GtkTreeView      *view;
 	GtkTreeModel     *model;
 	GtkTreeSelection *selection;
 	GtkTreeIter       iter;
-	McAccount        *account;
+	EmpathyAccount   *account;
 
 	view = GTK_TREE_VIEW (dialog->treeview);
 	selection = gtk_tree_view_get_selection (view);
@@ -561,7 +560,7 @@ accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog)
 
 static void
 accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
-				    McAccount             *account)
+				    EmpathyAccount        *account)
 {
 	GtkTreeSelection *selection;
 	GtkTreeIter       iter;
@@ -594,7 +593,7 @@ static void
 accounts_dialog_model_selection_changed (GtkTreeSelection     *selection,
 					 EmpathyAccountsDialog *dialog)
 {
-	McAccount    *account;
+	EmpathyAccount    *account;
 	GtkTreeModel *model;
 	GtkTreeIter   iter;
 	gboolean      is_selection;
@@ -611,7 +610,7 @@ accounts_dialog_model_selection_changed (GtkTreeSelection     *selection,
 
 static void
 accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog,
-				       McAccount             *account)
+				       EmpathyAccount        *account)
 {
 	GtkTreeModel       *model;
 	GtkTreeIter         iter;
@@ -620,9 +619,9 @@ accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog,
 	gboolean            enabled;
 
 	model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
-	status = mission_control_get_connection_status (dialog->mc, account, NULL);
-	name = mc_account_get_display_name (account);
-	enabled = mc_account_is_enabled (account);
+	g_object_get (account, "status", &status, NULL);
+	name = empathy_account_get_display_name (account);
+	enabled = empathy_account_is_enabled (account);
 
 	if (!accounts_dialog_get_account_iter (dialog, account, &iter)) {
 		DEBUG ("Adding new account");
@@ -646,7 +645,7 @@ accounts_dialog_add_or_update_account (EmpathyAccountsDialog *dialog,
 
 static void
 accounts_dialog_account_added_cb (EmpathyAccountManager *manager,
-				  McAccount *account,
+				  EmpathyAccount *account,
 				  EmpathyAccountsDialog *dialog)
 {
 	const gchar *current_name;
@@ -656,25 +655,25 @@ accounts_dialog_account_added_cb (EmpathyAccountManager *manager,
 
 	/* Change the display name to "%s (%s)" % (protocol, account).
 	 *  - The protocol is the display name of the profile.
-	 *  - The account should be the normalized name of the McAccount but
+	 *  - The account should be the normalized name of the EmpathyAccount but
 	 *    it's not set until first connection, so we get the "account"
 	 *    parameter for CM that have it. */
-	current_name = mc_account_get_display_name (account);
-	mc_account_get_param_string (account, "account", &account_param);
+	current_name = empathy_account_get_display_name (account);
+	account_param = empathy_account_get_param_string (account, "account");
 	if (!EMP_STR_EMPTY (account_param)) {
 		McProfile   *profile;
 		const gchar *profile_name;
 		gchar       *new_name;
 
-		profile = mc_account_get_profile (account);
+		profile = empathy_account_get_profile (account);
 		profile_name = mc_profile_get_display_name (profile);
 		new_name = g_strdup_printf ("%s (%s)", profile_name,
 					    account_param);
 
 		DEBUG ("Setting new display name for account %s: '%s'",
-		       mc_account_get_unique_name (account), new_name);
+		       empathy_account_get_unique_name (account), new_name);
 
-		mc_account_set_display_name (account, new_name);
+		empathy_account_set_display_name (account, new_name);
 		g_free (new_name);
 		g_object_unref (profile);
 	} else {
@@ -685,7 +684,7 @@ accounts_dialog_account_added_cb (EmpathyAccountManager *manager,
 
 static void
 accounts_dialog_account_removed_cb (EmpathyAccountManager *manager,
-				    McAccount            *account,
+				    EmpathyAccount       *account,
 				    EmpathyAccountsDialog *dialog)
 {
 
@@ -722,7 +721,7 @@ accounts_dialog_flash_connecting_cb (EmpathyAccountsDialog *dialog)
 
 static void
 accounts_dialog_connection_changed_cb     (EmpathyAccountManager    *manager,
-					   McAccount                *account,
+					   EmpathyAccount           *account,
 					   TpConnectionStatusReason  reason,
 					   TpConnectionStatus        current,
 					   TpConnectionStatus        previous,
@@ -763,7 +762,7 @@ accounts_dialog_connection_changed_cb     (EmpathyAccountManager    *manager,
 
 static void
 enable_or_disable_account (EmpathyAccountsDialog *dialog,
-			   McAccount *account,
+			   EmpathyAccount *account,
 			   gboolean enabled)
 {
 	GtkTreeModel *model;
@@ -773,7 +772,7 @@ enable_or_disable_account (EmpathyAccountsDialog *dialog,
 	model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
 
 	DEBUG ("Account %s is now %s",
-		mc_account_get_display_name (account),
+		empathy_account_get_display_name (account),
 		enabled ? "enabled" : "disabled");
 
 	if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
@@ -785,7 +784,7 @@ enable_or_disable_account (EmpathyAccountsDialog *dialog,
 
 static void
 accounts_dialog_account_disabled_cb (EmpathyAccountManager *manager,
-				     McAccount             *account,
+				     EmpathyAccount        *account,
 				     EmpathyAccountsDialog *dialog)
 {
 	enable_or_disable_account (dialog, account, FALSE);
@@ -793,7 +792,7 @@ accounts_dialog_account_disabled_cb (EmpathyAccountManager *manager,
 
 static void
 accounts_dialog_account_enabled_cb (EmpathyAccountManager *manager,
-				    McAccount             *account,
+				    EmpathyAccount        *account,
 				    EmpathyAccountsDialog *dialog)
 {
 	enable_or_disable_account (dialog, account, TRUE);
@@ -801,10 +800,10 @@ accounts_dialog_account_enabled_cb (EmpathyAccountManager *manager,
 
 static void
 accounts_dialog_account_changed_cb (EmpathyAccountManager *manager,
-				    McAccount             *account,
+				    EmpathyAccount        *account,
 				    EmpathyAccountsDialog  *dialog)
 {
-	McAccount *selected_account;
+	EmpathyAccount *selected_account;
 
 	accounts_dialog_add_or_update_account (dialog, account);
 	selected_account = accounts_dialog_model_get_selected (dialog);
@@ -818,7 +817,7 @@ accounts_dialog_button_create_clicked_cb (GtkWidget             *button,
 					  EmpathyAccountsDialog  *dialog)
 {
 	McProfile *profile;
-	McAccount *account;
+	EmpathyAccount *account;
 	gchar     *str;
 	McProfileCapabilityFlags cap;
 
@@ -826,7 +825,7 @@ accounts_dialog_button_create_clicked_cb (GtkWidget             *button,
 	    EMPATHY_PROFILE_CHOOSER (dialog->combobox_profile));
 
 	/* Create account */
-	account = mc_account_create (profile);
+	account = empathy_account_manager_create (dialog->account_manager, profile);
 	if (account == NULL) {
 		/* We can't display an error to the user as MC doesn't give us
 		 * any clue about the reason of the failure... */
@@ -837,7 +836,7 @@ accounts_dialog_button_create_clicked_cb (GtkWidget             *button,
 	/* To translator: %s is the protocol name */
 	str = g_strdup_printf (_("New %s account"),
 			       mc_profile_get_display_name (profile));
-	mc_account_set_display_name (account, str);
+	empathy_account_set_display_name (account, str);
 	g_free (str);
 
 	cap = mc_profile_get_capabilities (profile);
@@ -846,7 +845,7 @@ accounts_dialog_button_create_clicked_cb (GtkWidget             *button,
 
 		active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->radiobutton_register));
 		if (active) {
-			mc_account_set_param_boolean (account, "register", TRUE);
+			empathy_account_set_param_boolean (account, "register", TRUE);
 		}
 	}
 
@@ -861,7 +860,7 @@ static void
 accounts_dialog_button_back_clicked_cb (GtkWidget             *button,
 					EmpathyAccountsDialog  *dialog)
 {
-	McAccount *account;
+	EmpathyAccount *account;
 
 	account = accounts_dialog_model_get_selected (dialog);
 	accounts_dialog_update_account (dialog, account);
@@ -932,13 +931,13 @@ static void
 accounts_dialog_button_remove_clicked_cb (GtkWidget            *button,
 					  EmpathyAccountsDialog *dialog)
 {
-	McAccount *account;
+	EmpathyAccount *account;
 	GtkWidget *message_dialog;
 	gint       res;
 
 	account = accounts_dialog_model_get_selected (dialog);
 
-	if (!mc_account_is_complete (account)) {
+	if (!empathy_account_is_valid (account)) {
 		accounts_dialog_model_remove_selected (dialog);
 		accounts_dialog_model_select_first (dialog);
 		return;
@@ -950,7 +949,7 @@ accounts_dialog_button_remove_clicked_cb (GtkWidget            *button,
 		 GTK_BUTTONS_NONE,
 		 _("You are about to remove your %s account!\n"
 		   "Are you sure you want to proceed?"),
-		 mc_account_get_display_name (account));
+		 empathy_account_get_display_name (account));
 
 	gtk_message_dialog_format_secondary_text
 		(GTK_MESSAGE_DIALOG (message_dialog),
@@ -971,7 +970,7 @@ accounts_dialog_button_remove_clicked_cb (GtkWidget            *button,
 	res = gtk_dialog_run (GTK_DIALOG (message_dialog));
 
 	if (res == GTK_RESPONSE_YES) {
-		mc_account_delete (account);
+		empathy_account_manager_remove (dialog->account_manager, account);
 		accounts_dialog_model_select_first (dialog);
 	}
 	gtk_widget_destroy (message_dialog);
@@ -1021,15 +1020,15 @@ accounts_dialog_destroy_cb (GtkWidget            *widget,
 					      dialog);
 
 	/* Delete incomplete accounts */
-	accounts = mc_accounts_list ();
+	accounts = empathy_account_manager_dup_accounts (dialog->account_manager);
 	for (l = accounts; l; l = l->next) {
-		McAccount *account;
+		EmpathyAccount *account;
 
 		account = l->data;
-		if (!mc_account_is_complete (account)) {
+		if (!empathy_account_is_valid (account)) {
 			/* FIXME: Warn the user the account is not complete
 			 *        and is going to be removed. */
-			mc_account_delete (account);
+			empathy_account_manager_remove (dialog->account_manager, account);
 		}
 
 		g_object_unref (account);
@@ -1048,7 +1047,7 @@ accounts_dialog_destroy_cb (GtkWidget            *widget,
 
 GtkWidget *
 empathy_accounts_dialog_show (GtkWindow *parent,
-			      McAccount *selected_account)
+			      EmpathyAccount *selected_account)
 {
 	static EmpathyAccountsDialog *dialog = NULL;
 	GtkBuilder                   *gui;
@@ -1136,7 +1135,7 @@ empathy_accounts_dialog_show (GtkWindow *parent,
 	accounts_dialog_model_setup (dialog);
 
 	/* Add existing accounts */
-	accounts = mc_accounts_list ();
+	accounts = empathy_account_manager_dup_accounts (dialog->account_manager);
 	for (l = accounts; l; l = l->next) {
 		accounts_dialog_add_or_update_account (dialog, l->data);
 		g_object_unref (l->data);
diff --git a/src/empathy-accounts-dialog.h b/src/empathy-accounts-dialog.h
index b8c3d36..11e237c 100644
--- a/src/empathy-accounts-dialog.h
+++ b/src/empathy-accounts-dialog.h
@@ -27,12 +27,12 @@
 
 #include <gtk/gtk.h>
 
-#include <libmissioncontrol/mc-account.h>
+#include <libempathy/empathy-account.h>
 
 G_BEGIN_DECLS
 
 GtkWidget *empathy_accounts_dialog_show (GtkWindow *parent,
-					 McAccount *selected_account);
+					 EmpathyAccount *selected_account);
 
 G_END_DECLS
 
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 8e317f6..f4315f5 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -408,7 +408,7 @@ chat_window_update_chat_tab (EmpathyChat *chat)
 	EmpathyContact        *remote_contact;
 	const gchar           *name;
 	const gchar           *id;
-	McAccount             *account;
+	EmpathyAccount        *account;
 	const gchar           *subject;
 	const gchar           *status = NULL;
 	GtkWidget             *widget;
@@ -429,7 +429,7 @@ chat_window_update_chat_tab (EmpathyChat *chat)
 	remote_contact = empathy_chat_get_remote_contact (chat);
 
 	DEBUG ("Updating chat tab, name=%s, account=%s, subject=%s, remote_contact=%p",
-		name, mc_account_get_unique_name (account), subject, remote_contact);
+		name, empathy_account_get_unique_name (account), subject, remote_contact);
 
 	/* Update tab image */
 	if (g_list_find (priv->chats_new_msg, chat)) {
@@ -461,7 +461,7 @@ chat_window_update_chat_tab (EmpathyChat *chat)
 	append_markup_printf (tooltip,
 			      "<b>%s</b><small> (%s)</small>",
 			      id,
-			      mc_account_get_display_name (account));
+			      empathy_account_get_display_name (account));
 
 	if (!EMP_STR_EMPTY (status)) {
 		append_markup_printf (tooltip, "\n<i>%s</i>", status);
@@ -556,7 +556,7 @@ chat_window_conv_activate_cb (GtkAction         *action,
 	is_room = empathy_chat_is_room (priv->current_chat);
 	if (is_room) {
 		const gchar *room;
-		McAccount   *account;
+		EmpathyAccount   *account;
 		gboolean     found;
 
 		room = empathy_chat_get_id (priv->current_chat);
@@ -602,7 +602,7 @@ chat_window_favorite_toggled_cb (GtkToggleAction   *toggle_action,
 {
 	EmpathyChatWindowPriv *priv = GET_PRIV (window);
 	gboolean               active;
-	McAccount             *account;
+	EmpathyAccount        *account;
 	const gchar           *room;
 	EmpathyChatroom       *chatroom;
 
@@ -1235,41 +1235,40 @@ chat_window_drag_data_received (GtkWidget        *widget,
 	if (info == DND_DRAG_TYPE_CONTACT_ID) {
 		EmpathyChat           *chat;
 		EmpathyChatWindow     *old_window;
-		McAccount             *account;
+		EmpathyAccount        *account;
+		EmpathyAccountManager *account_manager;
 		const gchar           *id;
 		gchar                **strv;
 		const gchar           *account_id;
 		const gchar           *contact_id;
 
 		id = (const gchar*) selection->data;
+		account_manager = empathy_account_manager_dup_singleton ();
 
 		DEBUG ("DND contact from roster with id:'%s'", id);
 
 		strv = g_strsplit (id, "/", 2);
 		account_id = strv[0];
 		contact_id = strv[1];
-		account = mc_account_lookup (account_id);
+		account = empathy_account_manager_lookup (account_manager, account_id);
 		chat = empathy_chat_window_find_chat (account, contact_id);
 
 		if (!chat) {
-			EmpathyAccountManager *account_manager;
 			TpConnection *connection;
 
-			account_manager = empathy_account_manager_dup_singleton ();
-			connection = empathy_account_manager_get_connection (
-				account_manager, account);
+			connection = empathy_account_get_connection (account);
 
 			if (connection) {
 				empathy_dispatcher_chat_with_contact_id (
 					connection, contact_id, NULL, NULL);
 			}
 
-			g_object_unref (account_manager);
 			g_object_unref (account);
 			g_strfreev (strv);
 			return;
 		}
 		g_object_unref (account);
+		g_object_unref (account_manager);
 		g_strfreev (strv);
 
 		old_window = chat_window_find_chat (chat);
@@ -1740,12 +1739,11 @@ empathy_chat_window_has_focus (EmpathyChatWindow *window)
 }
 
 EmpathyChat *
-empathy_chat_window_find_chat (McAccount   *account,
+empathy_chat_window_find_chat (EmpathyAccount   *account,
 			       const gchar *id)
 {
 	GList *l;
 
-	g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
 	g_return_val_if_fail (!EMP_STR_EMPTY (id), NULL);
 
 	for (l = chat_windows; l; l = l->next) {
diff --git a/src/empathy-chat-window.h b/src/empathy-chat-window.h
index c46ef8f..6f3d21f 100644
--- a/src/empathy-chat-window.h
+++ b/src/empathy-chat-window.h
@@ -31,7 +31,7 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 
-#include <libmissioncontrol/mc-account.h>
+#include <libempathy/empathy-account.h>
 #include <libempathy-gtk/empathy-chat.h>
 
 G_BEGIN_DECLS
@@ -69,7 +69,7 @@ void               empathy_chat_window_move_chat      (EmpathyChatWindow *old_wi
 void               empathy_chat_window_switch_to_chat (EmpathyChatWindow *window,
 						       EmpathyChat       *chat);
 gboolean           empathy_chat_window_has_focus      (EmpathyChatWindow *window);
-EmpathyChat *      empathy_chat_window_find_chat      (McAccount        *account,
+EmpathyChat *      empathy_chat_window_find_chat      (EmpathyAccount   *account,
 						       const gchar      *id);
 void               empathy_chat_window_present_chat   (EmpathyChat      *chat);
 
diff --git a/src/empathy-chatrooms-window.c b/src/empathy-chatrooms-window.c
index a0fb8e6..3b5dd1f 100644
--- a/src/empathy-chatrooms-window.c
+++ b/src/empathy-chatrooms-window.c
@@ -308,7 +308,7 @@ chatrooms_window_model_refresh_data (EmpathyChatroomsWindow *window,
 	GtkTreeIter            iter;
 	GtkTreeViewColumn     *column;
 	EmpathyAccountChooser  *account_chooser;
-	McAccount             *account;
+	EmpathyAccount        *account;
 	GList                 *chatrooms, *l;
 
 	view = GTK_TREE_VIEW (window->treeview);
@@ -506,7 +506,7 @@ chatrooms_window_chatroom_added_cb (EmpathyChatroomManager *manager,
 				    EmpathyChatroomsWindow *window)
 {
 	EmpathyAccountChooser *account_chooser;
-	McAccount            *account;
+	EmpathyAccount       *account;
 
 	account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser);
 	account = empathy_account_chooser_dup_account (account_chooser);
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index a80aad2..1a7ec09 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -914,19 +914,12 @@ event_manager_presence_changed_cb (EmpathyContactMonitor *monitor,
     TpConnectionPresenceType previous,
     EmpathyEventManager *manager)
 {
-  McAccount *account;
-  gboolean just_connected;
-  EmpathyAccountManager *account_manager;
+  EmpathyAccount *account;
   gchar *header = NULL;
   gboolean preference = FALSE;
 
   account = empathy_contact_get_account (contact);
-  account_manager = empathy_account_manager_dup_singleton ();
-  just_connected = empathy_account_manager_is_account_just_connected (
-                  account_manager, account);
-
-  g_object_unref (account_manager);
-  if (just_connected)
+  if (empathy_account_is_just_connected (account))
     return;
 
   if (tp_connection_presence_type_cmp_availability (previous,
diff --git a/src/empathy-import-dialog.c b/src/empathy-import-dialog.c
index 8e9a045..1e13589 100644
--- a/src/empathy-import-dialog.c
+++ b/src/empathy-import-dialog.c
@@ -27,7 +27,6 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 
-#include <libmissioncontrol/mc-account.h>
 #include <telepathy-glib/util.h>
 
 #include "empathy-import-dialog.h"
@@ -36,6 +35,7 @@
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
 #include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-account-manager.h>
 
 #include <libempathy-gtk/empathy-ui-utils.h>
 
@@ -91,13 +91,16 @@ empathy_import_account_data_free (EmpathyImportAccountData *data)
 static void
 import_dialog_add_account (EmpathyImportAccountData *data)
 {
-  McAccount *account;
+  EmpathyAccountManager *account_manager;
+  EmpathyAccount *account;
   GHashTableIter iter;
   gpointer key, value;
   gchar *display_name;
   GValue *username;
 
-  account = mc_account_create (data->profile);
+  account_manager = empathy_account_manager_dup_singleton ();
+  account = empathy_account_manager_create (account_manager, data->profile);
+  g_object_unref (account_manager);
   if (account == NULL)
     {
       DEBUG ("Failed to create account");
@@ -115,21 +118,21 @@ import_dialog_add_account (EmpathyImportAccountData *data)
           case G_TYPE_STRING:
             DEBUG ("Set param '%s' to '%s' (string)",
                 param, g_value_get_string (gvalue));
-            mc_account_set_param_string (account,
+            empathy_account_set_param_string (account,
                 param, g_value_get_string (gvalue));
             break;
 
           case G_TYPE_BOOLEAN:
             DEBUG ("Set param '%s' to %s (boolean)",
                 param, g_value_get_boolean (gvalue) ? "TRUE" : "FALSE");
-            mc_account_set_param_boolean (account,
+            empathy_account_set_param_boolean (account,
                 param, g_value_get_boolean (gvalue));
             break;
 
           case G_TYPE_INT:
             DEBUG ("Set param '%s' to '%i' (integer)",
                 param, g_value_get_int (gvalue));
-            mc_account_set_param_int (account,
+            empathy_account_set_param_int (account,
                 param, g_value_get_int (gvalue));
             break;
         }
@@ -140,7 +143,7 @@ import_dialog_add_account (EmpathyImportAccountData *data)
   display_name = g_strdup_printf ("%s (%s)",
       mc_profile_get_display_name (data->profile),
       g_value_get_string (username));
-  mc_account_set_display_name (account, display_name);
+  empathy_account_set_display_name (account, display_name);
 
   g_free (display_name);
   g_object_unref (account);
@@ -155,11 +158,12 @@ import_dialog_account_id_in_list (GList *accounts,
   for (l = accounts; l; l = l->next)
     {
       McAccount *account = l->data;
-      gchar *value;
+      gchar *value = NULL;
       gboolean result;
 
-      if (mc_account_get_param_string (account, "account", &value)
-          == MC_ACCOUNT_SETTING_ABSENT)
+      mc_account_get_param_string (account, "account", &value);
+
+      if (value == NULL)
         continue;
 
       result = tp_strdiff (value, account_id);
diff --git a/src/empathy-import-dialog.h b/src/empathy-import-dialog.h
index a3ef3e1..0e3fd14 100644
--- a/src/empathy-import-dialog.h
+++ b/src/empathy-import-dialog.h
@@ -20,6 +20,7 @@
  */
 
 #include <gtk/gtk.h>
+#include <libmissioncontrol/mc-profile.h>
 
 #ifndef __EMPATHY_IMPORT_DIALOG_H__
 #define __EMPATHY_IMPORT_DIALOG_H__
diff --git a/src/empathy-import-pidgin.c b/src/empathy-import-pidgin.c
index 804936e..935c022 100644
--- a/src/empathy-import-pidgin.c
+++ b/src/empathy-import-pidgin.c
@@ -28,7 +28,6 @@
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 
-#include <libmissioncontrol/mc-account.h>
 #include <telepathy-glib/util.h>
 #include <telepathy-glib/dbus.h>
 
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 0da037b..c7816d7 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -302,7 +302,7 @@ static void
 main_window_error_edit_clicked_cb (GtkButton         *button,
 				   EmpathyMainWindow *window)
 {
-	McAccount *account;
+	EmpathyAccount *account;
 	GtkWidget *error_widget;
 
 	account = g_object_get_data (G_OBJECT (button), "account");
@@ -317,7 +317,7 @@ static void
 main_window_error_clear_clicked_cb (GtkButton         *button,
 				    EmpathyMainWindow *window)
 {
-	McAccount *account;
+	EmpathyAccount *account;
 	GtkWidget *error_widget;
 
 	account = g_object_get_data (G_OBJECT (button), "account");
@@ -328,7 +328,7 @@ main_window_error_clear_clicked_cb (GtkButton         *button,
 
 static void
 main_window_error_display (EmpathyMainWindow *window,
-			   McAccount         *account,
+			   EmpathyAccount    *account,
 			   const gchar       *message)
 {
 	GtkWidget *child;
@@ -349,7 +349,7 @@ main_window_error_display (EmpathyMainWindow *window,
 
 		/* Just set the latest error and return */
 		str = g_markup_printf_escaped ("<b>%s</b>\n%s",
-					       mc_account_get_display_name (account),
+					       empathy_account_get_display_name (account),
 					       message);
 		gtk_label_set_markup (GTK_LABEL (label), str);
 		g_free (str);
@@ -430,7 +430,7 @@ main_window_error_display (EmpathyMainWindow *window,
 	gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
 
 	str = g_markup_printf_escaped ("<b>%s</b>\n%s",
-				       mc_account_get_display_name (account),
+				       empathy_account_get_display_name (account),
 				       message);
 	gtk_label_set_markup (GTK_LABEL (label), str);
 	g_free (str);
@@ -482,7 +482,7 @@ main_window_update_status (EmpathyMainWindow *window, EmpathyAccountManager *man
 
 static void
 main_window_connection_changed_cb (EmpathyAccountManager *manager,
-				   McAccount *account,
+				   EmpathyAccount *account,
 				   TpConnectionStatusReason reason,
 				   TpConnectionStatus current,
 				   TpConnectionStatus previous,
@@ -569,11 +569,11 @@ main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor,
 					 TpConnectionPresenceType previous,
 					 EmpathyMainWindow *window)
 {
-	McAccount *account;
+	EmpathyAccount *account;
 	gboolean should_play;
 
 	account = empathy_contact_get_account (contact);
-	should_play = !empathy_account_manager_is_account_just_connected (window->account_manager, account);
+	should_play = !empathy_account_is_just_connected (account);
 
 	if (!should_play) {
 		return;
@@ -729,16 +729,13 @@ main_window_view_show_map_cb (GtkCheckMenuItem  *item,
 static void
 main_window_favorite_chatroom_join (EmpathyChatroom *chatroom)
 {
-	EmpathyAccountManager *manager;
-	McAccount      *account;
+	EmpathyAccount *account;
 	TpConnection   *connection;
 	const gchar    *room;
 
-	manager = empathy_account_manager_dup_singleton ();
 	account = empathy_chatroom_get_account (chatroom);
-	connection = empathy_account_manager_get_connection (manager, account);
+	connection = empathy_account_get_connection (account);
 	room = empathy_chatroom_get_room (chatroom);
-	g_object_unref (manager);
 
 	if (connection != NULL) {
 		DEBUG ("Requesting channel for '%s'", room);
@@ -1009,7 +1006,7 @@ main_window_configure_event_cb (GtkWidget         *widget,
 
 static void
 main_window_account_created_or_deleted_cb (EmpathyAccountManager  *manager,
-					   McAccount              *account,
+					   EmpathyAccount         *account,
 					   EmpathyMainWindow      *window)
 {
 	gtk_action_set_sensitive (window->view_history,
diff --git a/src/empathy-new-chatroom-dialog.c b/src/empathy-new-chatroom-dialog.c
index da90cbb..e16da91 100644
--- a/src/empathy-new-chatroom-dialog.c
+++ b/src/empathy-new-chatroom-dialog.c
@@ -33,7 +33,6 @@
 #include <glib/gprintf.h>
 
 #include <libmissioncontrol/mission-control.h>
-#include <libmissioncontrol/mc-account.h>
 #include <libmissioncontrol/mc-profile.h>
 
 #include <libempathy/empathy-tp-roomlist.h>
@@ -358,14 +357,14 @@ static void
 new_chatroom_dialog_update_widgets (EmpathyNewChatroomDialog *dialog)
 {
 	EmpathyAccountChooser *account_chooser;
-	McAccount             *account;
+	EmpathyAccount        *account;
 	McProfile             *profile;
 	const gchar           *protocol;
 	const gchar           *room;
 
 	account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
 	account = empathy_account_chooser_dup_account (account_chooser);
-	profile = mc_account_get_profile (account);
+	profile = empathy_account_get_profile (account);
 	protocol = mc_profile_get_protocol_name (profile);
 
 	gtk_entry_set_text (GTK_ENTRY (dialog->entry_server), "");
@@ -399,12 +398,13 @@ new_chatroom_dialog_account_changed_cb (GtkComboBox             *combobox,
 					EmpathyNewChatroomDialog *dialog)
 {
 	EmpathyAccountChooser *account_chooser;
-	McAccount             *account;
+	EmpathyAccount        *account;
 	gboolean               listing = FALSE;
 	gboolean               expanded = FALSE;
 
 	if (dialog->room_list) {
 		g_object_unref (dialog->room_list);
+		dialog->room_list = NULL;
 	}
 
 	ephy_spinner_stop (EPHY_SPINNER (dialog->throbber));
@@ -412,6 +412,9 @@ new_chatroom_dialog_account_changed_cb (GtkComboBox             *combobox,
 
 	account_chooser = EMPATHY_ACCOUNT_CHOOSER (dialog->account_chooser);
 	account = empathy_account_chooser_dup_account (account_chooser);
+	if (account == NULL)
+		goto out;
+
 	dialog->room_list = empathy_tp_roomlist_new (account);
 
 	if (dialog->room_list) {
@@ -444,9 +447,10 @@ new_chatroom_dialog_account_changed_cb (GtkComboBox             *combobox,
 		}
 	}
 
-	new_chatroom_dialog_update_widgets (dialog);
-
 	g_object_unref (account);
+
+out:
+	new_chatroom_dialog_update_widgets (dialog);
 }
 
 static void
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index a4b01b7..f6c63c5 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -306,14 +306,20 @@ status_icon_set_visibility (EmpathyStatusIcon *icon,
 		empathy_window_iconify (priv->window, priv->icon);
 	} else {
 		GList *accounts;
+		GList *l;
+		gboolean one_enabled = FALSE;
 
 		empathy_window_present (GTK_WINDOW (priv->window), TRUE);
 
 		/* Show the accounts dialog if there is no enabled accounts */
-		accounts = mc_accounts_list_by_enabled (TRUE);
-		if (accounts) {
-			mc_accounts_list_free (accounts);
-		} else {
+		accounts = empathy_account_manager_dup_accounts (priv->account_manager);
+		for (l = accounts ; l != NULL ; l = g_list_next (l)) {
+			one_enabled = empathy_account_is_enabled (EMPATHY_ACCOUNT (l->data))
+				|| one_enabled;
+			g_object_unref (l->data);
+		}
+		g_list_free (accounts);
+		if (!one_enabled) {
 			DEBUG ("No enabled account, Showing account dialog");
 			empathy_accounts_dialog_show (GTK_WINDOW (priv->window), NULL);
 		}
@@ -484,7 +490,7 @@ status_icon_create_menu (EmpathyStatusIcon *icon)
 
 static void
 status_icon_connection_changed_cb (EmpathyAccountManager *manager,
-				   McAccount *account,
+				   EmpathyAccount *account,
 				   TpConnectionStatusReason reason,
 				   TpConnectionStatus current,
 				   TpConnectionStatus previous,
diff --git a/src/empathy.c b/src/empathy.c
index 85124d1..40626b5 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -40,7 +40,6 @@
 
 #include <telepathy-glib/dbus.h>
 #include <telepathy-glib/util.h>
-#include <libmissioncontrol/mc-account.h>
 #include <libmissioncontrol/mission-control.h>
 
 #include <libempathy/empathy-idle.h>
@@ -107,7 +106,7 @@ dispatch_cb (EmpathyDispatcher *dispatcher,
 		if (id) {
 			EmpathyAccountManager *manager;
 			TpConnection *connection;
-			McAccount *account;
+			EmpathyAccount *account;
 
 			manager = empathy_account_manager_dup_singleton ();
 			connection = empathy_tp_chat_get_connection (tp_chat);
@@ -227,7 +226,8 @@ create_salut_account (void)
 	McProfile  *profile;
 	McProtocol *protocol;
 	gboolean    salut_created = FALSE;
-	McAccount  *account;
+	EmpathyAccount  *account;
+	EmpathyAccountManager *account_manager;
 	GList      *accounts;
 	EBook      *book;
 	EContact   *contact;
@@ -284,8 +284,10 @@ create_salut_account (void)
 		return;
 	}
 
-	account = mc_account_create (profile);
-	mc_account_set_display_name (account, _("People nearby"));
+	account_manager = empathy_account_manager_dup_singleton ();
+	account = empathy_account_manager_create (account_manager, profile);
+	empathy_account_set_display_name (account, _("People nearby"));
+	g_object_unref (account_manager);
 
 	nickname = e_contact_get (contact, E_CONTACT_NICKNAME);
 	first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME);
@@ -302,11 +304,11 @@ create_salut_account (void)
 		"last-name=%s\nemail=%s\njid=%s\n",
 		nickname, first_name, last_name, email, jid);
 
-	mc_account_set_param_string (account, "nickname", nickname ? nickname : "");
-	mc_account_set_param_string (account, "first-name", first_name ? first_name : "");
-	mc_account_set_param_string (account, "last-name", last_name ? last_name : "");
-	mc_account_set_param_string (account, "email", email ? email : "");
-	mc_account_set_param_string (account, "jid", jid ? jid : "");
+	empathy_account_set_param_string (account, "nickname", nickname ? nickname : "");
+	empathy_account_set_param_string (account, "first-name", first_name ? first_name : "");
+	empathy_account_set_param_string (account, "last-name", last_name ? last_name : "");
+	empathy_account_set_param_string (account, "email", email ? email : "");
+	empathy_account_set_param_string (account, "jid", jid ? jid : "");
 
 	g_free (nickname);
 	g_free (first_name);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]