diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-07-01 21:21:29 +0800 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-07-01 21:21:29 +0800 |
commit | 0a41b6b31705626c71047261b91afdac711dead7 (patch) | |
tree | e51c864f00c5966a5bcb903d2b4c35324bf968b7 | |
parent | a980a2b3eaa634981b0ebfe950f50b515e43cf4a (diff) | |
parent | 1a74f07d19bdbdbf0aa62587343b64f636ec7b20 (diff) | |
download | gsoc2013-empathy-0a41b6b31705626c71047261b91afdac711dead7.tar gsoc2013-empathy-0a41b6b31705626c71047261b91afdac711dead7.tar.gz gsoc2013-empathy-0a41b6b31705626c71047261b91afdac711dead7.tar.bz2 gsoc2013-empathy-0a41b6b31705626c71047261b91afdac711dead7.tar.lz gsoc2013-empathy-0a41b6b31705626c71047261b91afdac711dead7.tar.xz gsoc2013-empathy-0a41b6b31705626c71047261b91afdac711dead7.tar.zst gsoc2013-empathy-0a41b6b31705626c71047261b91afdac711dead7.zip |
Merge branch 'empathy-account'
65 files changed, 1573 insertions, 961 deletions
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c index 488486fdf..7dccb2179 100644 --- a/libempathy-gtk/empathy-account-chooser.c +++ b/libempathy-gtk/empathy-account-chooser.c @@ -65,7 +65,7 @@ typedef struct { typedef struct { EmpathyAccountChooser *chooser; - McAccount *account; + EmpathyAccount *account; gboolean set; } SetAccountData; @@ -88,19 +88,19 @@ static void account_chooser_set_property (GObject GParamSpec *pspec); static void account_chooser_setup (EmpathyAccountChooser *chooser); static void account_chooser_account_created_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, EmpathyAccountChooser *chooser); -static void account_chooser_account_add_foreach (McAccount *account, +static void account_chooser_account_add_foreach (EmpathyAccount *account, EmpathyAccountChooser *chooser); static void account_chooser_account_deleted_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, EmpathyAccountChooser *chooser); -static void account_chooser_account_remove_foreach (McAccount *account, +static void account_chooser_account_remove_foreach (EmpathyAccount *account, EmpathyAccountChooser *chooser); static void account_chooser_update_iter (EmpathyAccountChooser *chooser, GtkTreeIter *iter); static void account_chooser_connection_changed_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, TpConnectionStatusReason reason, TpConnectionStatus new_status, TpConnectionStatus old_status, @@ -253,16 +253,16 @@ empathy_account_chooser_new (void) * @chooser: an #EmpathyAccountChooser * * Returns the account which is currently selected in the chooser or %NULL - * if there is no account selected. The #McAccount returned should be + * if there is no account selected. The #EmpathyAccount returned should be * unrefed with g_object_unref() when finished with. * - * Return value: a new ref to the #McAccount currently selected, or %NULL. + * Return value: a new ref to the #EmpathyAccount currently selected, or %NULL. */ -McAccount * +EmpathyAccount * empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser) { EmpathyAccountChooserPriv *priv; - McAccount *account; + EmpathyAccount *account; GtkTreeModel *model; GtkTreeIter iter; @@ -295,7 +295,7 @@ TpConnection * empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) { EmpathyAccountChooserPriv *priv; - McAccount *account; + EmpathyAccount *account; TpConnection *connection; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), NULL); @@ -303,7 +303,7 @@ empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) priv = GET_PRIV (chooser); account = empathy_account_chooser_dup_account (chooser); - connection = empathy_account_manager_get_connection (priv->manager, account); + connection = empathy_account_get_connection (account); g_object_unref (account); return connection; @@ -312,7 +312,7 @@ empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) /** * empathy_account_chooser_set_account: * @chooser: an #EmpathyAccountChooser - * @account: an #McAccount + * @account: an #EmpathyAccount * * Sets the currently selected account to @account, if it exists in the list. * @@ -320,7 +320,7 @@ empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) */ gboolean empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, - McAccount *account) + EmpathyAccount *account) { GtkComboBox *combobox; GtkTreeModel *model; @@ -457,7 +457,7 @@ account_chooser_setup (EmpathyAccountChooser *chooser) G_TYPE_STRING, /* Image */ G_TYPE_STRING, /* Name */ G_TYPE_BOOLEAN, /* Enabled */ - MC_TYPE_ACCOUNT); + EMPATHY_TYPE_ACCOUNT); gtk_combo_box_set_model (combobox, GTK_TREE_MODEL (store)); @@ -477,25 +477,25 @@ account_chooser_setup (EmpathyAccountChooser *chooser) NULL); /* Populate accounts */ - accounts = mc_accounts_list (); + accounts = empathy_account_manager_dup_accounts (priv->manager); g_list_foreach (accounts, (GFunc) account_chooser_account_add_foreach, chooser); - mc_accounts_list_free (accounts); + g_list_free (accounts); g_object_unref (store); } static void account_chooser_account_created_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, EmpathyAccountChooser *chooser) { account_chooser_account_add_foreach (account, chooser); } static void -account_chooser_account_add_foreach (McAccount *account, +account_chooser_account_add_foreach (EmpathyAccount *account, EmpathyAccountChooser *chooser) { GtkListStore *store; @@ -511,18 +511,20 @@ account_chooser_account_add_foreach (McAccount *account, COL_ACCOUNT_POINTER, account, -1); account_chooser_update_iter (chooser, &iter); + /* We got a reffed account and it was reffed by the liststore as well */ + g_object_unref (account); } static void account_chooser_account_deleted_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, EmpathyAccountChooser *chooser) { account_chooser_account_remove_foreach (account, chooser); } typedef struct { - McAccount *account; + EmpathyAccount *account; GtkTreeIter *iter; gboolean found; } FindAccountData; @@ -534,7 +536,7 @@ account_chooser_find_account_foreach (GtkTreeModel *model, gpointer user_data) { FindAccountData *data = user_data; - McAccount *account; + EmpathyAccount *account; gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1); @@ -553,7 +555,7 @@ account_chooser_find_account_foreach (GtkTreeModel *model, static gboolean account_chooser_find_account (EmpathyAccountChooser *chooser, - McAccount *account, + EmpathyAccount *account, GtkTreeIter *iter) { GtkListStore *store; @@ -573,7 +575,7 @@ account_chooser_find_account (EmpathyAccountChooser *chooser, } static void -account_chooser_account_remove_foreach (McAccount *account, +account_chooser_account_remove_foreach (EmpathyAccount *account, EmpathyAccountChooser *chooser) { GtkListStore *store; @@ -595,7 +597,7 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser, EmpathyAccountChooserPriv *priv; GtkListStore *store; GtkComboBox *combobox; - McAccount *account; + EmpathyAccount *account; const gchar *icon_name; gboolean is_enabled = TRUE; @@ -615,7 +617,7 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser, gtk_list_store_set (store, iter, COL_ACCOUNT_IMAGE, icon_name, - COL_ACCOUNT_TEXT, mc_account_get_display_name (account), + COL_ACCOUNT_TEXT, empathy_account_get_display_name (account), COL_ACCOUNT_ENABLED, is_enabled, -1); @@ -630,7 +632,7 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser, static void account_chooser_connection_changed_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, TpConnectionStatusReason reason, TpConnectionStatus new_status, TpConnectionStatus old_status, @@ -671,7 +673,7 @@ account_chooser_set_account_foreach (GtkTreeModel *model, GtkTreeIter *iter, SetAccountData *data) { - McAccount *account; + EmpathyAccount *account; gboolean equal; gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1); @@ -744,7 +746,7 @@ empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, /** * EmpathyAccountChooserFilterFunc: - * @account: an #McAccount + * @account: an #EmpathyAccount * @user_data: user data, or %NULL * * A function which decides whether the account indicated by @account @@ -755,7 +757,7 @@ empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, /** * empathy_account_chooser_filter_is_connected: - * @account: an #McAccount + * @account: an #EmpathyAccount * @user_data: user data or %NULL * * A useful #EmpathyAccountChooserFilterFunc that one could pass into @@ -764,17 +766,12 @@ empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, * Return value: Whether @account is connected */ gboolean -empathy_account_chooser_filter_is_connected (McAccount *account, +empathy_account_chooser_filter_is_connected (EmpathyAccount *account, gpointer user_data) { - MissionControl *mc; TpConnectionStatus status; - g_return_val_if_fail (MC_IS_ACCOUNT (account), FALSE); - - mc = empathy_mission_control_dup_singleton (); - status = mission_control_get_connection_status (mc, account, NULL); - g_object_unref (mc); + g_object_get (account, "status", &status, NULL); return status == TP_CONNECTION_STATUS_CONNECTED; } diff --git a/libempathy-gtk/empathy-account-chooser.h b/libempathy-gtk/empathy-account-chooser.h index c2105406a..255b6841f 100644 --- a/libempathy-gtk/empathy-account-chooser.h +++ b/libempathy-gtk/empathy-account-chooser.h @@ -27,7 +27,7 @@ #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS @@ -38,7 +38,7 @@ G_BEGIN_DECLS #define EMPATHY_IS_ACCOUNT_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_ACCOUNT_CHOOSER)) #define EMPATHY_ACCOUNT_CHOOSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooserClass)) -typedef gboolean (* EmpathyAccountChooserFilterFunc) (McAccount *account, +typedef gboolean (* EmpathyAccountChooserFilterFunc) (EmpathyAccount *account, gpointer user_data); @@ -58,17 +58,17 @@ struct _EmpathyAccountChooserClass { GType empathy_account_chooser_get_type (void) G_GNUC_CONST; GtkWidget * empathy_account_chooser_new (void); -McAccount * empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser); +EmpathyAccount * empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser); TpConnection * empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser); gboolean empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, - McAccount *account); + EmpathyAccount *account); gboolean empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *chooser); void empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *chooser, gboolean has_all_option); void empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, EmpathyAccountChooserFilterFunc filter, gpointer user_data); -gboolean empathy_account_chooser_filter_is_connected (McAccount *account, +gboolean empathy_account_chooser_filter_is_connected (EmpathyAccount *account, gpointer user_data); G_END_DECLS diff --git a/libempathy-gtk/empathy-account-widget-irc.c b/libempathy-gtk/empathy-account-widget-irc.c index 1306f517f..688a3e0e6 100644 --- a/libempathy-gtk/empathy-account-widget-irc.c +++ b/libempathy-gtk/empathy-account-widget-irc.c @@ -27,7 +27,6 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-protocol.h> #include <libempathy/empathy-utils.h> @@ -44,7 +43,7 @@ #define IRC_NETWORKS_FILENAME "irc-networks.xml" typedef struct { - McAccount *account; + EmpathyAccount *account; EmpathyIrcNetworkManager *network_manager; GtkWidget *vbox_settings; @@ -70,9 +69,9 @@ static void unset_server_params (EmpathyAccountWidgetIrc *settings) { DEBUG ("Unset server, port and use-ssl"); - mc_account_unset_param (settings->account, "server"); - mc_account_unset_param (settings->account, "port"); - mc_account_unset_param (settings->account, "use-ssl"); + empathy_account_unset_param (settings->account, "server"); + empathy_account_unset_param (settings->account, "port"); + empathy_account_unset_param (settings->account, "use-ssl"); } static void @@ -98,7 +97,7 @@ update_server_params (EmpathyAccountWidgetIrc *settings) g_object_get (network, "charset", &charset, NULL); DEBUG ("Setting charset to %s", charset); - mc_account_set_param_string (settings->account, "charset", charset); + empathy_account_set_param_string (settings->account, "charset", charset); g_free (charset); servers = empathy_irc_network_get_servers (network); @@ -117,11 +116,11 @@ update_server_params (EmpathyAccountWidgetIrc *settings) NULL); DEBUG ("Setting server to %s", address); - mc_account_set_param_string (settings->account, "server", address); + empathy_account_set_param_string (settings->account, "server", address); DEBUG ("Setting port to %u", port); - mc_account_set_param_int (settings->account, "port", port); + empathy_account_set_param_int (settings->account, "port", port); DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" ); - mc_account_set_param_boolean (settings->account, "use-ssl", ssl); + empathy_account_set_param_boolean (settings->account, "use-ssl", ssl); g_free (address); } @@ -332,17 +331,17 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings) gboolean ssl = FALSE; EmpathyIrcNetwork *network = NULL; - mc_account_get_param_string (settings->account, "account", &nick); - mc_account_get_param_string (settings->account, "fullname", &fullname); - mc_account_get_param_string (settings->account, "server", &server); - mc_account_get_param_string (settings->account, "charset", &charset); - mc_account_get_param_int (settings->account, "port", &port); - mc_account_get_param_boolean (settings->account, "use-ssl", &ssl); + nick = empathy_account_get_param_string (settings->account, "account"); + fullname = empathy_account_get_param_string (settings->account, "fullname"); + server = empathy_account_get_param_string (settings->account, "server"); + charset = empathy_account_get_param_string (settings->account, "charset"); + port = empathy_account_get_param_int (settings->account, "port"); + ssl = empathy_account_get_param_boolean (settings->account, "use-ssl"); if (!nick) { nick = g_strdup (g_get_user_name ()); - mc_account_set_param_string (settings->account, "account", nick); + empathy_account_set_param_string (settings->account, "account", nick); } if (!fullname) @@ -352,7 +351,7 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings) { fullname = g_strdup (nick); } - mc_account_set_param_string (settings->account, "fullname", fullname); + empathy_account_set_param_string (settings->account, "fullname", fullname); } if (server != NULL) @@ -414,14 +413,14 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings) /** * empathy_account_widget_irc_new: - * @account: the #McAccount to configure + * @account: the #EmpathyAccount to configure * - * Creates a new IRC account widget to configure a given #McAccount + * Creates a new IRC account widget to configure a given #EmpathyAccount * * Returns: The toplevel container of the configuration widget */ GtkWidget * -empathy_account_widget_irc_new (McAccount *account) +empathy_account_widget_irc_new (EmpathyAccount *account) { EmpathyAccountWidgetIrc *settings; gchar *dir, *user_file_with_path, *global_file_with_path; diff --git a/libempathy-gtk/empathy-account-widget-irc.h b/libempathy-gtk/empathy-account-widget-irc.h index a89081fc0..40e58bbc3 100644 --- a/libempathy-gtk/empathy-account-widget-irc.h +++ b/libempathy-gtk/empathy-account-widget-irc.h @@ -22,11 +22,11 @@ #define __EMPATHY_ACCOUNT_WIDGET_IRC_H__ #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS -GtkWidget * empathy_account_widget_irc_new (McAccount *account); +GtkWidget * empathy_account_widget_irc_new (EmpathyAccount *account); G_END_DECLS diff --git a/libempathy-gtk/empathy-account-widget-sip.c b/libempathy-gtk/empathy-account-widget-sip.c index da6082495..05e917e53 100644 --- a/libempathy-gtk/empathy-account-widget-sip.c +++ b/libempathy-gtk/empathy-account-widget-sip.c @@ -28,7 +28,6 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-protocol.h> #include <libempathy/empathy-utils.h> @@ -38,7 +37,7 @@ #include "empathy-ui-utils.h" typedef struct { - McAccount *account; + EmpathyAccount *account; GtkWidget *vbox_settings; @@ -69,14 +68,14 @@ account_widget_sip_discover_stun_toggled_cb ( /** * empathy_account_widget_sip_new: - * @account: the #McAccount to configure + * @account: the #EmpathyAccount to configure * - * Creates a new SIP account widget to configure a given #McAccount + * Creates a new SIP account widget to configure a given #EmpathyAccount * * Returns: The toplevel container of the configuration widget */ GtkWidget * -empathy_account_widget_sip_new (McAccount *account) +empathy_account_widget_sip_new (EmpathyAccount *account) { EmpathyAccountWidgetSip *settings; GtkBuilder *gui; diff --git a/libempathy-gtk/empathy-account-widget-sip.h b/libempathy-gtk/empathy-account-widget-sip.h index 9187c1e0c..69f60aacc 100644 --- a/libempathy-gtk/empathy-account-widget-sip.h +++ b/libempathy-gtk/empathy-account-widget-sip.h @@ -22,11 +22,11 @@ #define __EMPATHY_ACCOUNT_WIDGET_SIP_H__ #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS -GtkWidget * empathy_account_widget_sip_new (McAccount *account); +GtkWidget * empathy_account_widget_sip_new (EmpathyAccount *account); G_END_DECLS diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index b0d7f8de5..f602cd8bd 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -29,10 +29,10 @@ #include <gtk/gtk.h> #include <glib/gi18n-lib.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-protocol.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-account.h> #include "empathy-account-widget.h" #include "empathy-ui-utils.h" @@ -43,7 +43,7 @@ static gboolean account_widget_entry_focus_cb (GtkWidget *widget, GdkEventFocus *event, - McAccount *account) + EmpathyAccount *account) { const gchar *str; const gchar *param_name; @@ -54,8 +54,8 @@ account_widget_entry_focus_cb (GtkWidget *widget, if (EMP_STR_EMPTY (str)) { gchar *value = NULL; - mc_account_unset_param (account, param_name); - mc_account_get_param_string (account, param_name, &value); + empathy_account_unset_param (account, param_name); + value = empathy_account_get_param_string (account, param_name); DEBUG ("Unset %s and restore to %s", param_name, value); gtk_entry_set_text (GTK_ENTRY (widget), value ? value : ""); g_free (value); @@ -64,7 +64,7 @@ account_widget_entry_focus_cb (GtkWidget *widget, const gchar *domain = NULL; gchar *dup_str = NULL; - profile = mc_account_get_profile (account); + profile = empathy_account_get_profile (account); if (mc_profile_get_capabilities (profile) & MC_PROFILE_CAPABILITY_SPLIT_ACCOUNT) { domain = mc_profile_get_default_account_domain (profile); @@ -78,7 +78,7 @@ account_widget_entry_focus_cb (GtkWidget *widget, } DEBUG ("Setting %s to %s", param_name, strstr (param_name, "password") ? "***" : str); - mc_account_set_param_string (account, param_name, str); + empathy_account_set_param_string (account, param_name, str); g_free (dup_str); g_object_unref (profile); } @@ -88,7 +88,7 @@ account_widget_entry_focus_cb (GtkWidget *widget, static void account_widget_int_changed_cb (GtkWidget *widget, - McAccount *account) + EmpathyAccount *account) { const gchar *param_name; gint value; @@ -97,19 +97,19 @@ account_widget_int_changed_cb (GtkWidget *widget, param_name = g_object_get_data (G_OBJECT (widget), "param_name"); if (value == 0) { - mc_account_unset_param (account, param_name); - mc_account_get_param_int (account, param_name, &value); + empathy_account_unset_param (account, param_name); + value = empathy_account_get_param_int (account, param_name); DEBUG ("Unset %s and restore to %d", param_name, value); gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value); } else { DEBUG ("Setting %s to %d", param_name, value); - mc_account_set_param_int (account, param_name, value); + empathy_account_set_param_int (account, param_name, value); } } static void account_widget_checkbutton_toggled_cb (GtkWidget *widget, - McAccount *account) + EmpathyAccount *account) { gboolean value; gboolean default_value; @@ -121,14 +121,14 @@ 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. */ - mc_account_unset_param (account, param_name); - mc_account_get_param_boolean (account, param_name, &default_value); + empathy_account_unset_param (account, param_name); + default_value = empathy_account_get_param_boolean (account, param_name); if (default_value == value) { DEBUG ("Unset %s and restore to %d", param_name, default_value); } else { DEBUG ("Setting %s to %d", param_name, value); - mc_account_set_param_boolean (account, param_name, value); + empathy_account_set_param_boolean (account, param_name, value); } } @@ -136,14 +136,14 @@ static void account_widget_forget_clicked_cb (GtkWidget *button, GtkWidget *entry) { - McAccount *account; + EmpathyAccount *account; const gchar *param_name; param_name = g_object_get_data (G_OBJECT (entry), "param_name"); account = g_object_get_data (G_OBJECT (entry), "account"); DEBUG ("Unset %s", param_name); - mc_account_unset_param (account, param_name); + empathy_account_unset_param (account, param_name); gtk_entry_set_text (GTK_ENTRY (entry), ""); } @@ -161,13 +161,13 @@ static void account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl, GtkWidget *spinbutton_port) { - McAccount *account; + EmpathyAccount *account; gboolean value; gint port = 0; value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_ssl)); account = g_object_get_data (G_OBJECT (spinbutton_port), "account"); - mc_account_get_param_int (account, "port", &port); + port = empathy_account_get_param_int (account, "port"); if (value) { if (port == 5222 || port == 0) { @@ -184,7 +184,7 @@ account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl, static void account_widget_setup_widget (GtkWidget *widget, - McAccount *account, + EmpathyAccount *account, const gchar *param_name) { g_object_set_data_full (G_OBJECT (widget), "param_name", @@ -195,7 +195,7 @@ account_widget_setup_widget (GtkWidget *widget, if (GTK_IS_SPIN_BUTTON (widget)) { gint value = 0; - mc_account_get_param_int (account, param_name, &value); + value = empathy_account_get_param_int (account, param_name); gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value); g_signal_connect (widget, "value-changed", @@ -205,7 +205,7 @@ account_widget_setup_widget (GtkWidget *widget, else if (GTK_IS_ENTRY (widget)) { gchar *str = NULL; - mc_account_get_param_string (account, param_name, &str); + str = empathy_account_get_param_string (account, param_name); gtk_entry_set_text (GTK_ENTRY (widget), str ? str : ""); g_free (str); @@ -220,7 +220,7 @@ account_widget_setup_widget (GtkWidget *widget, else if (GTK_IS_TOGGLE_BUTTON (widget)) { gboolean value = FALSE; - mc_account_get_param_boolean (account, param_name, &value); + value = empathy_account_get_param_boolean (account, param_name); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value); g_signal_connect (widget, "toggled", @@ -256,7 +256,7 @@ account_widget_generic_format_param_name (const gchar *param_name) } static void -accounts_widget_generic_setup (McAccount *account, +accounts_widget_generic_setup (EmpathyAccount *account, GtkWidget *table_common_settings, GtkWidget *table_advanced_settings) { @@ -264,7 +264,7 @@ accounts_widget_generic_setup (McAccount *account, McProfile *profile; GSList *params, *l; - profile = mc_account_get_profile (account); + profile = empathy_account_get_profile (account); protocol = mc_profile_get_protocol (profile); if (!protocol) { @@ -400,7 +400,7 @@ accounts_widget_generic_setup (McAccount *account, } static void -account_widget_handle_params_valist (McAccount *account, +account_widget_handle_params_valist (EmpathyAccount *account, GtkBuilder *gui, const gchar *first_widget, va_list args) @@ -424,14 +424,13 @@ account_widget_handle_params_valist (McAccount *account, } void -empathy_account_widget_handle_params (McAccount *account, +empathy_account_widget_handle_params (EmpathyAccount *account, GtkBuilder *gui, const gchar *first_widget, ...) { va_list args; - g_return_if_fail (MC_IS_ACCOUNT (account)); g_return_if_fail (GTK_IS_BUILDER (gui)); va_start (args, first_widget); @@ -440,7 +439,7 @@ empathy_account_widget_handle_params (McAccount *account, } void -empathy_account_widget_add_forget_button (McAccount *account, +empathy_account_widget_add_forget_button (EmpathyAccount *account, GtkBuilder *gui, const gchar *button, const gchar *entry) @@ -452,7 +451,7 @@ empathy_account_widget_add_forget_button (McAccount *account, button_forget = GTK_WIDGET (gtk_builder_get_object (gui, button)); entry_password = GTK_WIDGET (gtk_builder_get_object (gui, entry)); - mc_account_get_param_string (account, "password", &password); + password = empathy_account_get_param_string (account, "password"); gtk_widget_set_sensitive (button_forget, !EMP_STR_EMPTY (password)); g_free (password); @@ -477,7 +476,7 @@ empathy_account_widget_set_default_focus (GtkBuilder *gui, } GtkWidget * -empathy_account_widget_generic_new (McAccount *account) +empathy_account_widget_generic_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -485,8 +484,6 @@ empathy_account_widget_generic_new (McAccount *account) GtkWidget *table_advanced_settings; gchar *filename; - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); - filename = empathy_file_lookup ("empathy-account-widget-generic.ui", "libempathy-gtk"); gui = empathy_builder_get_file (filename, @@ -502,7 +499,7 @@ empathy_account_widget_generic_new (McAccount *account) } GtkWidget * -empathy_account_widget_salut_new (McAccount *account) +empathy_account_widget_salut_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -530,7 +527,7 @@ empathy_account_widget_salut_new (McAccount *account) } GtkWidget * -empathy_account_widget_msn_new (McAccount *account) +empathy_account_widget_msn_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -560,7 +557,7 @@ empathy_account_widget_msn_new (McAccount *account) } GtkWidget * -empathy_account_widget_jabber_new (McAccount *account) +empathy_account_widget_jabber_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -603,7 +600,7 @@ empathy_account_widget_jabber_new (McAccount *account) } GtkWidget * -empathy_account_widget_icq_new (McAccount *account) +empathy_account_widget_icq_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -636,7 +633,7 @@ empathy_account_widget_icq_new (McAccount *account) } GtkWidget * -empathy_account_widget_aim_new (McAccount *account) +empathy_account_widget_aim_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -668,7 +665,7 @@ empathy_account_widget_aim_new (McAccount *account) } GtkWidget * -empathy_account_widget_yahoo_new (McAccount *account) +empathy_account_widget_yahoo_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -702,7 +699,7 @@ empathy_account_widget_yahoo_new (McAccount *account) } GtkWidget * -empathy_account_widget_groupwise_new (McAccount *account) +empathy_account_widget_groupwise_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; diff --git a/libempathy-gtk/empathy-account-widget.h b/libempathy-gtk/empathy-account-widget.h index 7287f5675..7a76db9e0 100644 --- a/libempathy-gtk/empathy-account-widget.h +++ b/libempathy-gtk/empathy-account-widget.h @@ -27,28 +27,28 @@ #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS -void empathy_account_widget_handle_params (McAccount *account, +void empathy_account_widget_handle_params (EmpathyAccount *account, GtkBuilder *gui, const gchar *first_widget, ...); -void empathy_account_widget_add_forget_button (McAccount *account, +void empathy_account_widget_add_forget_button (EmpathyAccount *account, GtkBuilder *gui, const gchar *button, const gchar *entry); void empathy_account_widget_set_default_focus (GtkBuilder *gui, const gchar *entry); -GtkWidget *empathy_account_widget_generic_new (McAccount *account); -GtkWidget *empathy_account_widget_salut_new (McAccount *account); -GtkWidget *empathy_account_widget_msn_new (McAccount *account); -GtkWidget *empathy_account_widget_jabber_new (McAccount *account); -GtkWidget *empathy_account_widget_icq_new (McAccount *account); -GtkWidget *empathy_account_widget_aim_new (McAccount *account); -GtkWidget *empathy_account_widget_yahoo_new (McAccount *account); -GtkWidget *empathy_account_widget_groupwise_new (McAccount *account); +GtkWidget *empathy_account_widget_generic_new (EmpathyAccount *account); +GtkWidget *empathy_account_widget_salut_new (EmpathyAccount *account); +GtkWidget *empathy_account_widget_msn_new (EmpathyAccount *account); +GtkWidget *empathy_account_widget_jabber_new (EmpathyAccount *account); +GtkWidget *empathy_account_widget_icq_new (EmpathyAccount *account); +GtkWidget *empathy_account_widget_aim_new (EmpathyAccount *account); +GtkWidget *empathy_account_widget_yahoo_new (EmpathyAccount *account); +GtkWidget *empathy_account_widget_groupwise_new (EmpathyAccount *account); G_END_DECLS diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c index c47b5474f..5ed7c69c3 100644 --- a/libempathy-gtk/empathy-chat-text-view.c +++ b/libempathy-gtk/empathy-chat-text-view.c @@ -34,9 +34,9 @@ #include <gtk/gtk.h> #include <telepathy-glib/util.h> -#include <libmissioncontrol/mc-account.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-account.h> #include "empathy-chat-text-view.h" #include "empathy-chat.h" diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 9c5e47b0e..1f5225348 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -64,7 +64,7 @@ #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChat) typedef struct { EmpathyTpChat *tp_chat; - McAccount *account; + EmpathyAccount *account; gchar *id; gchar *name; gchar *subject; @@ -201,7 +201,7 @@ chat_new_connection_cb (EmpathyAccountManager *manager, EmpathyChat *chat) { EmpathyChatPriv *priv = GET_PRIV (chat); - McAccount *account; + EmpathyAccount *account; account = empathy_account_manager_get_account (manager, connection); if (!priv->tp_chat && empathy_account_equal (account, priv->account) && @@ -1562,7 +1562,7 @@ empathy_chat_class_init (EmpathyChatClass *klass) g_param_spec_object ("account", "Account of the chat", "The account of the chat", - MC_TYPE_ACCOUNT, + EMPATHY_TYPE_ACCOUNT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, @@ -1753,7 +1753,7 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, show_pending_messages (chat); } -McAccount * +EmpathyAccount * empathy_chat_get_account (EmpathyChat *chat) { EmpathyChatPriv *priv = GET_PRIV (chat); diff --git a/libempathy-gtk/empathy-chat.h b/libempathy-gtk/empathy-chat.h index c38fd64a6..c7158759a 100644 --- a/libempathy-gtk/empathy-chat.h +++ b/libempathy-gtk/empathy-chat.h @@ -66,7 +66,7 @@ EmpathyChat * empathy_chat_new (EmpathyTpChat *tp_chat); EmpathyTpChat * empathy_chat_get_tp_chat (EmpathyChat *chat); void empathy_chat_set_tp_chat (EmpathyChat *chat, EmpathyTpChat *tp_chat); -McAccount * empathy_chat_get_account (EmpathyChat *chat); +EmpathyAccount * empathy_chat_get_account (EmpathyChat *chat); const gchar * empathy_chat_get_id (EmpathyChat *chat); const gchar * empathy_chat_get_name (EmpathyChat *chat); const gchar * empathy_chat_get_subject (EmpathyChat *chat); diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c index 39edbf579..c1cca3e2b 100644 --- a/libempathy-gtk/empathy-contact-dialogs.c +++ b/libempathy-gtk/empathy-contact-dialogs.c @@ -328,26 +328,18 @@ empathy_contact_personal_dialog_show (GtkWindow *parent) */ static gboolean -can_add_contact_to_account (McAccount *account, +can_add_contact_to_account (EmpathyAccount *account, gpointer user_data) { - EmpathyAccountManager *account_manager; EmpathyContactManager *contact_manager; TpConnection *connection; gboolean result; - account_manager = empathy_account_manager_dup_singleton (); - connection = empathy_account_manager_get_connection (account_manager, - account); - if (!connection) { - g_object_unref (account_manager); - return FALSE; - } + connection = empathy_account_get_connection (account); contact_manager = empathy_contact_manager_dup_singleton (); result = empathy_contact_manager_can_add (contact_manager, connection); g_object_unref (contact_manager); - g_object_unref (account_manager); return result; } diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 61db60cdf..f7b506e7c 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -32,7 +32,6 @@ #include <gtk/gtk.h> #include <telepathy-glib/util.h> -#include <libmissioncontrol/mc-account.h> #include <libempathy/empathy-account-manager.h> #include <libempathy/empathy-call-factory.h> @@ -247,7 +246,7 @@ contact_list_view_drag_data_received (GtkWidget *view, EmpathyContactListViewPriv *priv; EmpathyAccountManager *account_manager; EmpathyTpContactFactory *factory = NULL; - McAccount *account; + EmpathyAccount *account; GtkTreeModel *model; GtkTreeViewDropPosition position; GtkTreePath *path; @@ -302,19 +301,17 @@ contact_list_view_drag_data_received (GtkWidget *view, strv = g_strsplit (id, "/", 2); account_id = strv[0]; contact_id = strv[1]; - account = mc_account_lookup (account_id); + account_manager = empathy_account_manager_dup_singleton (); + account = empathy_account_manager_lookup (account_manager, account_id); if (account) { TpConnection *connection; - /* FIXME: We assume we have already an account manager */ - account_manager = empathy_account_manager_dup_singleton (); - connection = empathy_account_manager_get_connection (account_manager, - account); + connection = empathy_account_get_connection (account); if (connection) { factory = empathy_tp_contact_factory_dup_singleton (connection); } - g_object_unref (account_manager); } + g_object_unref (account_manager); if (!factory) { DEBUG ("Failed to get factory for account '%s'", account_id); @@ -451,7 +448,7 @@ contact_list_view_drag_data_get (GtkWidget *widget, GtkTreeIter iter; GtkTreeModel *model; EmpathyContact *contact; - McAccount *account; + EmpathyAccount *account; const gchar *contact_id; const gchar *account_id; gchar *str; @@ -481,7 +478,7 @@ contact_list_view_drag_data_get (GtkWidget *widget, } account = empathy_contact_get_account (contact); - account_id = mc_account_get_unique_name (account); + account_id = empathy_account_get_unique_name (account); contact_id = empathy_contact_get_id (contact); g_object_unref (contact); str = g_strconcat (account_id, "/", contact_id, NULL); diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 12a139303..7e80d0d65 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -32,7 +32,6 @@ #include <champlain-gtk/champlain-gtk.h> #endif -#include <libmissioncontrol/mc-account.h> #include <telepathy-glib/util.h> #include <libempathy/empathy-tp-contact-factory.h> @@ -41,6 +40,7 @@ #include <libempathy/empathy-location.h> #include <libempathy/empathy-time.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-account.h> #include "empathy-contact-widget.h" #include "empathy-account-chooser.h" @@ -697,7 +697,7 @@ contact_widget_contact_setup (EmpathyContactWidget *information) static void contact_widget_contact_update (EmpathyContactWidget *information) { - McAccount *account = NULL; + EmpathyAccount *account = NULL; const gchar *id = NULL; /* Connect and get info from new contact */ @@ -737,7 +737,7 @@ contact_widget_contact_update (EmpathyContactWidget *information) { const gchar *name; - name = mc_account_get_display_name (account); + name = empathy_account_get_display_name (account); gtk_label_set_label (GTK_LABEL (information->widget_account), name); } } diff --git a/libempathy-gtk/empathy-irc-network-dialog.c b/libempathy-gtk/empathy-irc-network-dialog.c index 63222badc..e6b4a6f7f 100644 --- a/libempathy-gtk/empathy-irc-network-dialog.c +++ b/libempathy-gtk/empathy-irc-network-dialog.c @@ -27,10 +27,10 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-protocol.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-account.h> #include <libempathy/empathy-irc-network-manager.h> #include "empathy-ui-utils.h" diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c index 21d73f8ea..f05017c9c 100644 --- a/libempathy-gtk/empathy-log-window.c +++ b/libempathy-gtk/empathy-log-window.c @@ -31,6 +31,7 @@ #include <gtk/gtk.h> #include <libempathy/empathy-log-manager.h> +#include <libempathy/empathy-account-manager.h> #include <libempathy/empathy-chatroom-manager.h> #include <libempathy/empathy-chatroom.h> #include <libempathy/empathy-message.h> @@ -94,11 +95,11 @@ static void log_window_chats_setup (EmpathyLogWindow *wi static void log_window_chats_accounts_changed_cb (GtkWidget *combobox, EmpathyLogWindow *window); static void log_window_chats_set_selected (EmpathyLogWindow *window, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean is_chatroom); static gboolean log_window_chats_get_selected (EmpathyLogWindow *window, - McAccount **account, + EmpathyAccount **account, gchar **chat_id, gboolean *is_chatroom); static void log_window_chats_get_messages (EmpathyLogWindow *window, @@ -134,14 +135,14 @@ enum { }; GtkWidget * -empathy_log_window_show (McAccount *account, +empathy_log_window_show (EmpathyAccount *account, const gchar *chat_id, gboolean is_chatroom, GtkWindow *parent) { static EmpathyLogWindow *window = NULL; EmpathyAccountChooser *account_chooser; - GList *accounts; + EmpathyAccountManager *account_manager; gint account_num; GtkBuilder *gui; gchar *filename; @@ -228,9 +229,9 @@ empathy_log_window_show (McAccount *account, window); /* Populate */ - accounts = mc_accounts_list (); - account_num = g_list_length (accounts); - mc_accounts_list_free (accounts); + account_manager = empathy_account_manager_dup_singleton (); + account_num = empathy_account_manager_get_count (account_manager); + g_object_unref (account_manager); if (account_num > 1) { gtk_widget_show (window->vbox_chats); @@ -301,7 +302,7 @@ log_window_find_changed_cb (GtkTreeSelection *selection, GtkTreeView *view; GtkTreeModel *model; GtkTreeIter iter; - McAccount *account; + EmpathyAccount *account; gchar *chat_id; gboolean is_chatroom; gchar *date; @@ -417,7 +418,7 @@ log_window_find_populate (EmpathyLogWindow *window, } date_readable = empathy_log_manager_get_date_readable (hit->date); - account_name = mc_account_get_display_name (hit->account); + account_name = empathy_account_get_display_name (hit->account); account_icon = empathy_icon_name_from_account (hit->account); gtk_list_store_append (store, &iter); @@ -464,7 +465,7 @@ log_window_find_setup (EmpathyLogWindow *window) store = gtk_list_store_new (COL_FIND_COUNT, G_TYPE_STRING, /* account icon name */ G_TYPE_STRING, /* account name */ - MC_TYPE_ACCOUNT, /* account */ + EMPATHY_TYPE_ACCOUNT, /* account */ G_TYPE_STRING, /* chat name */ G_TYPE_STRING, /* chat id */ G_TYPE_BOOLEAN, /* is chatroom */ @@ -608,7 +609,7 @@ static void log_window_chats_populate (EmpathyLogWindow *window) { EmpathyAccountChooser *account_chooser; - McAccount *account; + EmpathyAccount *account; GList *chats, *l; GtkTreeView *view; @@ -684,11 +685,11 @@ log_window_chats_setup (EmpathyLogWindow *window) /* new store */ store = gtk_list_store_new (COL_CHAT_COUNT, - G_TYPE_STRING, /* icon */ - G_TYPE_STRING, /* name */ - MC_TYPE_ACCOUNT, /* account */ - G_TYPE_STRING, /* id */ - G_TYPE_BOOLEAN); /* is chatroom */ + G_TYPE_STRING, /* icon */ + G_TYPE_STRING, /* name */ + EMPATHY_TYPE_ACCOUNT, /* account */ + G_TYPE_STRING, /* id */ + G_TYPE_BOOLEAN); /* is chatroom */ model = GTK_TREE_MODEL (store); sortable = GTK_TREE_SORTABLE (store); @@ -739,7 +740,7 @@ log_window_chats_accounts_changed_cb (GtkWidget *combobox, static void log_window_chats_set_selected (EmpathyLogWindow *window, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean is_chatroom) { @@ -763,7 +764,7 @@ log_window_chats_set_selected (EmpathyLogWindow *window, } for (ok = TRUE; ok; ok = gtk_tree_model_iter_next (model, &iter)) { - McAccount *this_account; + EmpathyAccount *this_account; gchar *this_chat_id; gboolean this_is_chatroom; @@ -792,7 +793,7 @@ log_window_chats_set_selected (EmpathyLogWindow *window, static gboolean log_window_chats_get_selected (EmpathyLogWindow *window, - McAccount **account, + EmpathyAccount **account, gchar **chat_id, gboolean *is_chatroom) { @@ -801,7 +802,7 @@ log_window_chats_get_selected (EmpathyLogWindow *window, GtkTreeSelection *selection; GtkTreeIter iter; gchar *id = NULL; - McAccount *acc = NULL; + EmpathyAccount *acc = NULL; gboolean room = FALSE; view = GTK_TREE_VIEW (window->treeview_chats); @@ -839,7 +840,7 @@ static void log_window_chats_get_messages (EmpathyLogWindow *window, const gchar *date_to_show) { - McAccount *account; + EmpathyAccount *account; gchar *chat_id; gboolean is_chatroom; EmpathyMessage *message; @@ -999,7 +1000,7 @@ static void log_window_calendar_chats_month_changed_cb (GtkWidget *calendar, EmpathyLogWindow *window) { - McAccount *account; + EmpathyAccount *account; gchar *chat_id; gboolean is_chatroom; guint year_selected; diff --git a/libempathy-gtk/empathy-log-window.h b/libempathy-gtk/empathy-log-window.h index 6dd8c0303..298d96099 100644 --- a/libempathy-gtk/empathy-log-window.h +++ b/libempathy-gtk/empathy-log-window.h @@ -25,11 +25,11 @@ #ifndef __EMPATHY_LOG_WINDOW_H__ #define __EMPATHY_LOG_WINDOW_H__ -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS -GtkWidget * empathy_log_window_show (McAccount *account, +GtkWidget * empathy_log_window_show (EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, GtkWindow *parent); diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c index 9aee42913..77b368bd9 100644 --- a/libempathy-gtk/empathy-new-message-dialog.c +++ b/libempathy-gtk/empathy-new-message-dialog.c @@ -27,7 +27,6 @@ #include <gtk/gtk.h> #include <glib/gi18n-lib.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mission-control.h> #include <libempathy/empathy-call-factory.h> @@ -35,6 +34,7 @@ #include <libempathy/empathy-contact-manager.h> #include <libempathy/empathy-dispatcher.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-account.h> #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT #include <libempathy/empathy-debug.h> diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c index b16a3e7c9..1f1b3b06d 100644 --- a/libempathy-gtk/empathy-theme-adium.c +++ b/libempathy-gtk/empathy-theme-adium.c @@ -392,7 +392,7 @@ theme_adium_append_message (EmpathyChatView *view, EmpathyThemeAdium *theme = EMPATHY_THEME_ADIUM (view); EmpathyThemeAdiumPriv *priv = GET_PRIV (theme); EmpathyContact *sender; - McAccount *account; + EmpathyAccount *account; McProfile *account_profile; gchar *dup_body = NULL; const gchar *body; @@ -416,7 +416,7 @@ theme_adium_append_message (EmpathyChatView *view, /* Get information */ sender = empathy_message_get_sender (msg); account = empathy_contact_get_account (sender); - account_profile = mc_account_get_profile (account); + account_profile = empathy_account_get_profile (account); service_name = mc_profile_get_display_name (account_profile); timestamp = empathy_message_get_timestamp (msg); body = empathy_message_get_body (msg); diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index ffe81a352..baa6d21de 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -183,11 +183,11 @@ empathy_builder_unref_and_keep_widget (GtkBuilder *gui, } const gchar * -empathy_icon_name_from_account (McAccount *account) +empathy_icon_name_from_account (EmpathyAccount *account) { McProfile *profile; - profile = mc_account_get_profile (account); + profile = empathy_account_get_profile (account); return mc_profile_get_icon_name (profile); } diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h index 4c1384602..10f889b0c 100644 --- a/libempathy-gtk/empathy-ui-utils.h +++ b/libempathy-gtk/empathy-ui-utils.h @@ -34,10 +34,10 @@ #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-profile.h> #include <libempathy/empathy-contact.h> +#include <libempathy/empathy-account.h> #include <libempathy/empathy-ft-handler.h> #include "empathy-chat-view.h" @@ -59,7 +59,7 @@ GtkWidget *empathy_builder_unref_and_keep_widget (GtkBuilder *gui, GtkWidget *root); /* Pixbufs */ -const gchar * empathy_icon_name_from_account (McAccount *account); +const gchar * empathy_icon_name_from_account (EmpathyAccount *account); const gchar * empathy_icon_name_for_presence (TpConnectionPresenceType presence); const gchar * empathy_icon_name_for_contact (EmpathyContact *contact); GdkPixbuf * empathy_pixbuf_from_data (gchar *data, diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am index 2877dc6ae..27671543a 100644 --- a/libempathy/Makefile.am +++ b/libempathy/Makefile.am @@ -24,6 +24,8 @@ BUILT_SOURCES = \ lib_LTLIBRARIES = libempathy.la libempathy_la_SOURCES = \ + empathy-account.c \ + empathy-account-priv.h \ empathy-account-manager.c \ empathy-chatroom.c \ empathy-chatroom-manager.c \ @@ -74,6 +76,7 @@ libempathy_la_LDFLAGS = \ -export-symbols-regex ^empathy_ libempathy_headers = \ + empathy-account.h \ empathy-account-manager.h \ empathy-chatroom.h \ empathy-chatroom-manager.h \ diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c index ff9fd2525..fd8a21b1d 100644 --- a/libempathy/empathy-account-manager.c +++ b/libempathy/empathy-account-manager.c @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk> + * Sjoerd Simons <sjoerd.simons@collabora.co.uk> */ #include "config.h" @@ -23,6 +24,7 @@ #include <libmissioncontrol/mc-account-monitor.h> #include "empathy-account-manager.h" +#include "empathy-account-priv.h" #include "empathy-marshal.h" #include "empathy-utils.h" @@ -35,22 +37,13 @@ typedef struct { McAccountMonitor *monitor; MissionControl *mc; - GHashTable *accounts; /* McAccount -> AccountData */ - GHashTable *connections; /* TpConnection -> McAccount */ + /* (owned) unique name -> (reffed) EmpathyAccount */ + GHashTable *accounts; int connected; int connecting; gboolean dispose_run; } EmpathyAccountManagerPriv; -typedef struct { - TpConnection *connection; - TpConnectionPresenceType presence; - TpConnectionStatus status; - gboolean is_enabled; - - guint source_id; -} AccountData; - enum { ACCOUNT_CREATED, ACCOUNT_DELETED, @@ -68,122 +61,154 @@ static EmpathyAccountManager *manager_singleton = NULL; G_DEFINE_TYPE (EmpathyAccountManager, empathy_account_manager, G_TYPE_OBJECT); -static AccountData * -account_data_new (McPresence presence, - TpConnectionStatus status, - gboolean is_enabled) +static TpConnectionPresenceType +mc_presence_to_tp_presence (McPresence presence) { - AccountData *retval; + switch (presence) + { + case MC_PRESENCE_OFFLINE: + return TP_CONNECTION_PRESENCE_TYPE_OFFLINE; + case MC_PRESENCE_AVAILABLE: + return TP_CONNECTION_PRESENCE_TYPE_AVAILABLE; + case MC_PRESENCE_AWAY: + return TP_CONNECTION_PRESENCE_TYPE_AWAY; + case MC_PRESENCE_EXTENDED_AWAY: + return TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY; + case MC_PRESENCE_HIDDEN: + return TP_CONNECTION_PRESENCE_TYPE_HIDDEN; + case MC_PRESENCE_DO_NOT_DISTURB: + return TP_CONNECTION_PRESENCE_TYPE_BUSY; + default: + return TP_CONNECTION_PRESENCE_TYPE_UNSET; + } +} - retval = g_slice_new0 (AccountData); - retval->presence = presence; - retval->status = status; - retval->is_enabled = is_enabled; - retval->source_id = 0; +static void +emp_account_connection_cb (EmpathyAccount *account, + GParamSpec *spec, + gpointer manager) +{ + TpConnection *connection = empathy_account_get_connection (account); - return retval; + DEBUG ("Signalling connection %p of account %s", + connection, empathy_account_get_unique_name (account)); + + if (connection != NULL) + g_signal_emit (manager, signals[NEW_CONNECTION], 0, connection); } -static AccountData * -account_data_new_default (MissionControl *mc, - McAccount *account) +static void +emp_account_status_changed_cb (EmpathyAccount *account, + TpConnectionStatus old, + TpConnectionStatus new, + TpConnectionStatusReason reason, + gpointer user_data) { - McPresence actual_p; - TpConnectionStatus actual_c; - GError *err = NULL; + EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data); + EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - actual_p = mission_control_get_presence_actual (mc, &err); - if (err != NULL) + switch (old) { - actual_p = MC_PRESENCE_UNSET; - g_clear_error (&err); + case TP_CONNECTION_STATUS_CONNECTING: + priv->connecting--; + break; + case TP_CONNECTION_STATUS_CONNECTED: + priv->connected--; + break; + default: + break; } - actual_c = mission_control_get_connection_status (mc, account, &err); - - if (err != NULL) + switch (new) { - actual_c = TP_CONNECTION_STATUS_DISCONNECTED; - g_error_free (err); + case TP_CONNECTION_STATUS_CONNECTING: + priv->connecting++; + break; + case TP_CONNECTION_STATUS_CONNECTED: + priv->connected++; + break; + default: + break; } - return account_data_new (actual_p, actual_c, mc_account_is_enabled (account)); + g_signal_emit (manager, signals[ACCOUNT_CONNECTION_CHANGED], 0, + account, reason, new, old); } static void -account_data_free (AccountData *data) +emp_account_presence_changed_cb (EmpathyAccount *account, + TpConnectionPresenceType old, + TpConnectionPresenceType new, + gpointer user_data) { - if (data->source_id > 0) - { - g_source_remove (data->source_id); - data->source_id = 0; - } - if (data->connection != NULL) - { - g_object_unref (data->connection); - data->connection = NULL; - } - - g_slice_free (AccountData, data); + EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data); + g_signal_emit (manager, signals[ACCOUNT_PRESENCE_CHANGED], 0, + account, new, old); } -static void -connection_invalidated_cb (TpProxy *connection, - guint domain, - gint code, - gchar *message, - EmpathyAccountManager *manager) +static EmpathyAccount * +create_account (EmpathyAccountManager *manager, + const gchar *account_name, + McAccount *mc_account) { EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - McAccount *account; - AccountData *data; - - DEBUG ("Message: %s", message); + EmpathyAccount *account; + TpConnectionStatus status; + TpConnectionPresenceType presence; + McPresence mc_presence; + TpConnection *connection; + GError *error = NULL; - account = g_hash_table_lookup (priv->connections, connection); - g_assert (account != NULL); + if ((account = g_hash_table_lookup (priv->accounts, account_name)) != NULL) + return account; - data = g_hash_table_lookup (priv->accounts, account); - g_assert (data != NULL); + account = _empathy_account_new (mc_account); + g_hash_table_insert (priv->accounts, g_strdup (account_name), + account); - g_object_unref (data->connection); - data->connection = NULL; + _empathy_account_set_enabled (account, + mc_account_is_enabled (mc_account)); - g_hash_table_remove (priv->connections, connection); -} + g_signal_emit (manager, signals[ACCOUNT_CREATED], 0, account); -static void -connection_ready_cb (TpConnection *connection, - const GError *error, - gpointer manager) -{ - /* Errors will be handled in invalidated callback */ - if (error != NULL) - return; + g_signal_connect (account, "notify::connection", + G_CALLBACK (emp_account_connection_cb), manager); - g_signal_emit (manager, signals[NEW_CONNECTION], 0, connection); -} + connection = mission_control_get_tpconnection (priv->mc, + mc_account, NULL); + _empathy_account_set_connection (account, connection); -static void -account_manager_update_connection (EmpathyAccountManager *manager, - AccountData *data, - McAccount *account) -{ - EmpathyAccountManagerPriv *priv = GET_PRIV (manager); + status = mission_control_get_connection_status (priv->mc, + mc_account, &error); - if (data->connection) - return; + if (error != NULL) + { + status = TP_CONNECTION_STATUS_DISCONNECTED; + g_clear_error (&error); + } - data->connection = mission_control_get_tpconnection (priv->mc, account, NULL); - if (data->connection != NULL) + mc_presence = mission_control_get_presence_actual (priv->mc, &error); + if (error != NULL) + { + presence = TP_CONNECTION_PRESENCE_TYPE_UNSET; + g_clear_error (&error); + } + else { - g_signal_connect (data->connection, "invalidated", - G_CALLBACK (connection_invalidated_cb), manager); - g_hash_table_insert (priv->connections, g_object_ref (data->connection), - g_object_ref (account)); - tp_connection_call_when_ready (data->connection, connection_ready_cb, - manager); + presence = mc_presence_to_tp_presence (mc_presence); } + + g_signal_connect (account, "status-changed", + G_CALLBACK (emp_account_status_changed_cb), manager); + + g_signal_connect (account, "presence-changed", + G_CALLBACK (emp_account_presence_changed_cb), manager); + + _empathy_account_set_status (account, status, + TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED, + presence); + + return account; } static void @@ -191,32 +216,10 @@ account_created_cb (McAccountMonitor *mon, gchar *account_name, EmpathyAccountManager *manager) { - McAccount *account; - EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - TpConnectionStatus initial_status; - - account = mc_account_lookup (account_name); - - if (account) - { - AccountData *data; - - data = account_data_new_default (priv->mc, account); - g_hash_table_insert (priv->accounts, g_object_ref (account), data); - - initial_status = mission_control_get_connection_status (priv->mc, - account, NULL); - - if (initial_status == TP_CONNECTION_STATUS_CONNECTED) - priv->connected++; - else if (initial_status == TP_CONNECTION_STATUS_CONNECTING) - priv->connecting++; - - account_manager_update_connection (manager, data, account); + McAccount *mc_account = mc_account_lookup (account_name); - g_signal_emit (manager, signals[ACCOUNT_CREATED], 0, account); - g_object_unref (account); - } + if (mc_account != NULL) + create_account (manager, account_name, mc_account); } static void @@ -224,16 +227,15 @@ account_deleted_cb (McAccountMonitor *mon, gchar *account_name, EmpathyAccountManager *manager) { - McAccount *account; EmpathyAccountManagerPriv *priv = GET_PRIV (manager); + EmpathyAccount *account; - account = mc_account_lookup (account_name); + account = g_hash_table_lookup (priv->accounts, account_name); if (account) { - g_hash_table_remove (priv->accounts, account); g_signal_emit (manager, signals[ACCOUNT_DELETED], 0, account); - g_object_unref (account); + g_hash_table_remove (priv->accounts, account_name); } } @@ -242,15 +244,13 @@ account_changed_cb (McAccountMonitor *mon, gchar *account_name, EmpathyAccountManager *manager) { - McAccount *account; + EmpathyAccountManagerPriv *priv = GET_PRIV (manager); + EmpathyAccount *account; - account = mc_account_lookup (account_name); + account = g_hash_table_lookup (priv->accounts, account_name); - if (account) - { - g_signal_emit (manager, signals[ACCOUNT_CHANGED], 0, account); - g_object_unref (account); - } + if (account != NULL) + g_signal_emit (manager, signals[ACCOUNT_CHANGED], 0, account); } static void @@ -258,20 +258,15 @@ account_disabled_cb (McAccountMonitor *mon, gchar *account_name, EmpathyAccountManager *manager) { - McAccount *account; EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - AccountData *data; + EmpathyAccount *account; - account = mc_account_lookup (account_name); + account = g_hash_table_lookup (priv->accounts, account_name); if (account) { - data = g_hash_table_lookup (priv->accounts, account); - g_assert (data); - data->is_enabled = FALSE; - + _empathy_account_set_enabled (account, FALSE); g_signal_emit (manager, signals[ACCOUNT_DISABLED], 0, account); - g_object_unref (account); } } @@ -280,135 +275,60 @@ account_enabled_cb (McAccountMonitor *mon, gchar *account_name, EmpathyAccountManager *manager) { - McAccount *account; EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - AccountData *data; + EmpathyAccount *account; - account = mc_account_lookup (account_name); + account = g_hash_table_lookup (priv->accounts, account_name); if (account) { - data = g_hash_table_lookup (priv->accounts, account); - g_assert (data); - data->is_enabled = TRUE; - + _empathy_account_set_enabled (account, TRUE); g_signal_emit (manager, signals[ACCOUNT_ENABLED], 0, account); - g_object_unref (account); } } -static void -update_connection_numbers (EmpathyAccountManager *manager, - TpConnectionStatus status, - TpConnectionStatus old_s) -{ - EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - - if (status == TP_CONNECTION_STATUS_CONNECTED) - { - priv->connected++; - if (old_s == TP_CONNECTION_STATUS_CONNECTING) - priv->connecting--; - } - - if (status == TP_CONNECTION_STATUS_CONNECTING) - { - priv->connecting++; - if (old_s == TP_CONNECTION_STATUS_CONNECTED) - priv->connected--; - } - - if (status == TP_CONNECTION_STATUS_DISCONNECTED) - { - if (old_s == TP_CONNECTION_STATUS_CONNECTED) - priv->connected--; - - if (old_s == TP_CONNECTION_STATUS_CONNECTING) - priv->connecting--; - } -} - -static gboolean -remove_data_timeout (gpointer _data) -{ - AccountData *data = _data; - - data->source_id = 0; - - return FALSE; -} - typedef struct { TpConnectionStatus status; - McPresence presence; + TpConnectionPresenceType presence; TpConnectionStatusReason reason; gchar *unique_name; EmpathyAccountManager *manager; + McAccount *mc_account; } ChangedSignalData; static gboolean account_status_changed_idle_cb (ChangedSignalData *signal_data) { - McAccount *account; - AccountData *data; - McPresence presence, old_p; - TpConnectionStatus status, old_s; - gboolean emit_presence = FALSE, emit_connection = FALSE; + EmpathyAccount *account; EmpathyAccountManager *manager = signal_data->manager; EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - presence = signal_data->presence; - status = signal_data->status; - account = mc_account_lookup (signal_data->unique_name); + account = g_hash_table_lookup (priv->accounts, + signal_data->unique_name); if (account) { - data = g_hash_table_lookup (priv->accounts, account); - g_assert (data); - - old_p = data->presence; - old_s = data->status; - - if (old_p != presence) + if (empathy_account_get_connection (account) == NULL) { - data->presence = presence; - emit_presence = TRUE; - } + TpConnection *connection; - if (old_s != status) - { - data->status = status; - update_connection_numbers (manager, status, old_s); + connection = mission_control_get_tpconnection (priv->mc, + signal_data->mc_account, NULL); - if (status == TP_CONNECTION_STATUS_CONNECTED) + if (connection != NULL) { - if (data->source_id > 0) - { - g_source_remove (data->source_id); - data->source_id = 0; - } - - data->source_id = g_timeout_add_seconds (10, - remove_data_timeout, - data); + _empathy_account_set_connection (account, connection); + g_object_unref (connection); } - emit_connection = TRUE; } - account_manager_update_connection (manager, data, account); - - if (emit_presence) - g_signal_emit (manager, signals[ACCOUNT_PRESENCE_CHANGED], 0, - account, presence, old_p); - - if (emit_connection) - g_signal_emit (manager, signals[ACCOUNT_CONNECTION_CHANGED], 0, - account, signal_data->reason, status, old_s); - - g_object_unref (account); + _empathy_account_set_status (account, signal_data->status, + signal_data->reason, + signal_data->presence); } g_object_unref (signal_data->manager); + g_object_unref (signal_data->mc_account); g_free (signal_data->unique_name); g_slice_free (ChangedSignalData, signal_data); @@ -424,38 +344,18 @@ account_status_changed_cb (MissionControl *mc, EmpathyAccountManager *manager) { ChangedSignalData *data; - TpConnectionPresenceType tp_presence; - switch (presence) - { - case MC_PRESENCE_OFFLINE: - tp_presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE; - break; - case MC_PRESENCE_AVAILABLE: - tp_presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE; - break; - case MC_PRESENCE_AWAY: - tp_presence = TP_CONNECTION_PRESENCE_TYPE_AWAY; - break; - case MC_PRESENCE_EXTENDED_AWAY: - tp_presence = TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY; - break; - case MC_PRESENCE_HIDDEN: - tp_presence = TP_CONNECTION_PRESENCE_TYPE_HIDDEN; - break; - case MC_PRESENCE_DO_NOT_DISTURB: - tp_presence = TP_CONNECTION_PRESENCE_TYPE_BUSY; - break; - default: - tp_presence = TP_CONNECTION_PRESENCE_TYPE_UNSET; - } + DEBUG ("Status of account %s became " + "status: %d presence: %d reason: %d", unique_name, status, + presence, reason); data = g_slice_new0 (ChangedSignalData); data->status = status; - data->presence = tp_presence; + data->presence = mc_presence_to_tp_presence (presence); data->reason = reason; data->unique_name = g_strdup (unique_name); data->manager = g_object_ref (manager); + data->mc_account = mc_account_lookup (unique_name); g_idle_add ((GSourceFunc) account_status_changed_idle_cb, data); } @@ -467,35 +367,33 @@ empathy_account_manager_init (EmpathyAccountManager *manager) GList *mc_accounts, *l; priv = G_TYPE_INSTANCE_GET_PRIVATE (manager, - EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerPriv); + EMPATHY_TYPE_ACCOUNT_MANAGER, EmpathyAccountManagerPriv); + manager->priv = priv; priv->monitor = mc_account_monitor_new (); priv->mc = empathy_mission_control_dup_singleton (); priv->connected = priv->connecting = 0; priv->dispose_run = FALSE; - priv->accounts = g_hash_table_new_full (empathy_account_hash, - empathy_account_equal, - g_object_unref, - (GDestroyNotify) account_data_free); - priv->connections = g_hash_table_new_full (g_direct_hash, g_direct_equal, - g_object_unref, g_object_unref); + priv->accounts = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, (GDestroyNotify) g_object_unref); mc_accounts = mc_accounts_list (); for (l = mc_accounts; l; l = l->next) - account_created_cb (priv->monitor, (char *) mc_account_get_unique_name (l->data), manager); + account_created_cb (priv->monitor, + (char *) mc_account_get_unique_name (l->data), manager); g_signal_connect (priv->monitor, "account-created", - G_CALLBACK (account_created_cb), manager); + G_CALLBACK (account_created_cb), manager); g_signal_connect (priv->monitor, "account-deleted", - G_CALLBACK (account_deleted_cb), manager); + G_CALLBACK (account_deleted_cb), manager); g_signal_connect (priv->monitor, "account-disabled", - G_CALLBACK (account_disabled_cb), manager); + G_CALLBACK (account_disabled_cb), manager); g_signal_connect (priv->monitor, "account-enabled", - G_CALLBACK (account_enabled_cb), manager); + G_CALLBACK (account_enabled_cb), manager); g_signal_connect (priv->monitor, "account-changed", - G_CALLBACK (account_changed_cb), manager); + G_CALLBACK (account_changed_cb), manager); dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->mc), "AccountStatusChanged", G_CALLBACK (account_status_changed_cb), @@ -505,27 +403,12 @@ empathy_account_manager_init (EmpathyAccountManager *manager) } static void -account_manager_disconnect_foreach (gpointer key, - gpointer value, - gpointer user_data) -{ - TpConnection *connection = key; - EmpathyAccountManager *manager = user_data; - - g_signal_handlers_disconnect_by_func (connection, connection_invalidated_cb, - manager); -} - -static void do_finalize (GObject *obj) { EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (obj); EmpathyAccountManagerPriv *priv = GET_PRIV (manager); - g_hash_table_unref (priv->accounts); - g_hash_table_foreach (priv->connections, account_manager_disconnect_foreach, - obj); - g_hash_table_unref (priv->connections); + g_hash_table_destroy (priv->accounts); G_OBJECT_CLASS (empathy_account_manager_parent_class)->finalize (obj); } @@ -610,7 +493,7 @@ empathy_account_manager_class_init (EmpathyAccountManagerClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, - 1, MC_TYPE_ACCOUNT); + 1, EMPATHY_TYPE_ACCOUNT); signals[ACCOUNT_DELETED] = g_signal_new ("account-deleted", @@ -620,7 +503,7 @@ empathy_account_manager_class_init (EmpathyAccountManagerClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, - 1, MC_TYPE_ACCOUNT); + 1, EMPATHY_TYPE_ACCOUNT); signals[ACCOUNT_ENABLED] = g_signal_new ("account-enabled", @@ -630,7 +513,7 @@ empathy_account_manager_class_init (EmpathyAccountManagerClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, - 1, MC_TYPE_ACCOUNT); + 1, EMPATHY_TYPE_ACCOUNT); signals[ACCOUNT_DISABLED] = g_signal_new ("account-disabled", @@ -640,7 +523,7 @@ empathy_account_manager_class_init (EmpathyAccountManagerClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, - 1, MC_TYPE_ACCOUNT); + 1, EMPATHY_TYPE_ACCOUNT); signals[ACCOUNT_CHANGED] = g_signal_new ("account-changed", @@ -650,7 +533,7 @@ empathy_account_manager_class_init (EmpathyAccountManagerClass *klass) NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, - 1, MC_TYPE_ACCOUNT); + 1, EMPATHY_TYPE_ACCOUNT); signals[ACCOUNT_CONNECTION_CHANGED] = g_signal_new ("account-connection-changed", @@ -660,7 +543,7 @@ empathy_account_manager_class_init (EmpathyAccountManagerClass *klass) NULL, NULL, _empathy_marshal_VOID__OBJECT_INT_UINT_UINT, G_TYPE_NONE, - 4, MC_TYPE_ACCOUNT, + 4, EMPATHY_TYPE_ACCOUNT, G_TYPE_INT, /* reason */ G_TYPE_UINT, /* actual connection */ G_TYPE_UINT); /* previous connection */ @@ -673,7 +556,7 @@ empathy_account_manager_class_init (EmpathyAccountManagerClass *klass) NULL, NULL, _empathy_marshal_VOID__OBJECT_INT_INT, G_TYPE_NONE, - 3, MC_TYPE_ACCOUNT, + 3, EMPATHY_TYPE_ACCOUNT, G_TYPE_INT, /* actual presence */ G_TYPE_INT); /* previous presence */ @@ -698,6 +581,16 @@ empathy_account_manager_dup_singleton (void) return g_object_new (EMPATHY_TYPE_ACCOUNT_MANAGER, NULL); } +EmpathyAccount * +empathy_account_manager_create (EmpathyAccountManager *manager, + McProfile *profile) +{ + McAccount *mc_account = mc_account_create (profile); + return g_object_ref (create_account (manager, + mc_account_get_unique_name (mc_account), + mc_account)); +} + int empathy_account_manager_get_connected_accounts (EmpathyAccountManager *manager) { @@ -722,23 +615,6 @@ empathy_account_manager_get_connecting_accounts (EmpathyAccountManager *manager) return priv->connecting; } -gboolean -empathy_account_manager_is_account_just_connected (EmpathyAccountManager *manager, - McAccount *account) -{ - EmpathyAccountManagerPriv *priv; - AccountData *data; - - g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), FALSE); - - priv = GET_PRIV (manager); - data = g_hash_table_lookup (priv->accounts, account); - - g_assert (data); - - return (data->source_id > 0); -} - /** * empathy_account_manager_get_count: * @manager: a #EmpathyAccountManager @@ -759,62 +635,59 @@ empathy_account_manager_get_count (EmpathyAccountManager *manager) return g_hash_table_size (priv->accounts); } -McAccount * +EmpathyAccount * empathy_account_manager_get_account (EmpathyAccountManager *manager, TpConnection *connection) { EmpathyAccountManagerPriv *priv; + GHashTableIter iter; + gpointer value; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), 0); priv = GET_PRIV (manager); - return g_hash_table_lookup (priv->connections, connection); + g_hash_table_iter_init (&iter, priv->accounts); + while (g_hash_table_iter_next (&iter, NULL, &value)) + { + EmpathyAccount *account = EMPATHY_ACCOUNT (value); + + if (connection == empathy_account_get_connection (account)) + return account; + } + + return NULL; } -GList * -empathy_account_manager_dup_accounts (EmpathyAccountManager *manager) +EmpathyAccount * +empathy_account_manager_lookup (EmpathyAccountManager *manager, + const gchar *unique_name) { - EmpathyAccountManagerPriv *priv; - GList *ret; - - g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), NULL); + EmpathyAccountManagerPriv *priv = GET_PRIV (manager); + EmpathyAccount *account; - priv = GET_PRIV (manager); + account = g_hash_table_lookup (priv->accounts, unique_name); - ret = g_hash_table_get_keys (priv->accounts); - g_list_foreach (ret, (GFunc) g_object_ref, NULL); + if (account != NULL) + g_object_ref (account); - return ret; + return account; } -/** - * empathy_account_manager_get_connection: - * @manager: a #EmpathyAccountManager - * @account: a #McAccount - * - * Get the connection of the accounts, or NULL if account is offline or the - * connection is not yet ready. This function does not return a new ref. - * - * Returns: the connection of the accounts. - **/ -TpConnection * -empathy_account_manager_get_connection (EmpathyAccountManager *manager, - McAccount *account) +GList * +empathy_account_manager_dup_accounts (EmpathyAccountManager *manager) { EmpathyAccountManagerPriv *priv; - AccountData *data; + GList *ret; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), NULL); - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); priv = GET_PRIV (manager); - data = g_hash_table_lookup (priv->accounts, account); - if (data && data->connection && tp_connection_is_ready (data->connection)) - return data->connection; + ret = g_hash_table_get_values (priv->accounts); + g_list_foreach (ret, (GFunc) g_object_ref, NULL); - return NULL; + return ret; } /** @@ -831,18 +704,30 @@ empathy_account_manager_dup_connections (EmpathyAccountManager *manager) { EmpathyAccountManagerPriv *priv; GHashTableIter iter; - gpointer connection; + gpointer value; GList *ret = NULL; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_MANAGER (manager), NULL); priv = GET_PRIV (manager); - g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, &connection, NULL)) - if (connection != NULL && tp_connection_is_ready (connection)) - ret = g_list_prepend (ret, g_object_ref (connection)); + g_hash_table_iter_init (&iter, priv->accounts); + while (g_hash_table_iter_next (&iter, NULL, &value)) + { + EmpathyAccount *account = EMPATHY_ACCOUNT (value); + TpConnection *connection; + + connection = empathy_account_get_connection (account); + if (connection != NULL) + ret = g_list_prepend (ret, g_object_ref (connection)); + } return ret; } +void +empathy_account_manager_remove (EmpathyAccountManager *manager, + EmpathyAccount *account) +{ + mc_account_delete (_empathy_account_get_mc_account (account)); +} diff --git a/libempathy/empathy-account-manager.h b/libempathy/empathy-account-manager.h index 11ca6aca2..b04571ff8 100644 --- a/libempathy/empathy-account-manager.h +++ b/libempathy/empathy-account-manager.h @@ -24,7 +24,7 @@ #include <glib-object.h> -#include <libmissioncontrol/mc-account.h> +#include "empathy-account.h" G_BEGIN_DECLS @@ -52,25 +52,28 @@ GType empathy_account_manager_get_type (void); /* public methods */ EmpathyAccountManager * empathy_account_manager_dup_singleton (void); +EmpathyAccount * empathy_account_manager_create + (EmpathyAccountManager *manager, + McProfile *profile); int empathy_account_manager_get_connected_accounts (EmpathyAccountManager *manager); int empathy_account_manager_get_connecting_accounts (EmpathyAccountManager *manager); -gboolean empathy_account_manager_is_account_just_connected - (EmpathyAccountManager *manager, - McAccount *account); int empathy_account_manager_get_count (EmpathyAccountManager *manager); -McAccount * empathy_account_manager_get_account +EmpathyAccount * empathy_account_manager_get_account (EmpathyAccountManager *manager, TpConnection *connection); +EmpathyAccount * empathy_account_manager_lookup + (EmpathyAccountManager *manager, + const gchar *unique_name); GList * empathy_account_manager_dup_accounts (EmpathyAccountManager *manager); -TpConnection * empathy_account_manager_get_connection - (EmpathyAccountManager *manager, - McAccount *account); GList * empathy_account_manager_dup_connections (EmpathyAccountManager *manager); +void empathy_account_manager_remove ( + EmpathyAccountManager *manager, + EmpathyAccount *account); G_END_DECLS diff --git a/libempathy/empathy-account-priv.h b/libempathy/empathy-account-priv.h new file mode 100644 index 000000000..8b656b4d8 --- /dev/null +++ b/libempathy/empathy-account-priv.h @@ -0,0 +1,44 @@ +/* + * empathy-account-priv.h - Private Header for EmpathyAccount + * Copyright (C) 2009 Collabora Ltd. + * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __EMPATHY_ACCOUNT_PRIV_H__ +#define __EMPATHY_ACCOUNT_PRIV_H__ + +#include <glib.h> + +#include <libmissioncontrol/mc-account.h> +#include "empathy-account.h" + +G_BEGIN_DECLS + +EmpathyAccount *_empathy_account_new (McAccount *account); +void _empathy_account_set_status (EmpathyAccount *account, + TpConnectionStatus status, + TpConnectionStatusReason reason, + TpConnectionPresenceType presence); +void _empathy_account_set_connection (EmpathyAccount *account, + TpConnection *connection); +void _empathy_account_set_enabled (EmpathyAccount *account, + gboolean enabled); +McAccount *_empathy_account_get_mc_account (EmpathyAccount *account); + +G_END_DECLS + +#endif /* #ifndef __EMPATHY_ACCOUNT_PRIV_H__*/ diff --git a/libempathy/empathy-account.c b/libempathy/empathy-account.c new file mode 100644 index 000000000..e0a8e756b --- /dev/null +++ b/libempathy/empathy-account.c @@ -0,0 +1,575 @@ +/* + * empathy-account.c - Source for EmpathyAccount + * Copyright (C) 2009 Collabora Ltd. + * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#include <stdio.h> +#include <stdlib.h> + +#include <telepathy-glib/enums.h> + +#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT +#include <libempathy/empathy-debug.h> + +#include "empathy-account.h" +#include "empathy-account-priv.h" +#include "empathy-utils.h" +#include "empathy-marshal.h" + +/* signals */ +enum { + STATUS_CHANGED, + PRESENCE_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL]; + +/* properties */ +enum { + PROP_ENABLED = 1, + PROP_PRESENCE, + PROP_CONNECTION_STATUS, + PROP_CONNECTION_STATUS_REASON, + PROP_CONNECTION, + PROP_UNIQUE_NAME, + PROP_DISPLAY_NAME +}; + +G_DEFINE_TYPE(EmpathyAccount, empathy_account, G_TYPE_OBJECT) + +/* private structure */ +typedef struct _EmpathyAccountPriv EmpathyAccountPriv; + +struct _EmpathyAccountPriv +{ + gboolean dispose_has_run; + + TpConnection *connection; + guint connection_invalidated_id; + + TpConnectionStatus status; + TpConnectionStatusReason reason; + TpConnectionPresenceType presence; + + gboolean enabled; + /* Timestamp when the connection got connected in seconds since the epoch */ + glong connect_time; + + McAccount *mc_account; +}; + +#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccount) + +static void +empathy_account_init (EmpathyAccount *obj) +{ + EmpathyAccountPriv *priv; + + priv = G_TYPE_INSTANCE_GET_PRIVATE (obj, + EMPATHY_TYPE_ACCOUNT, EmpathyAccountPriv); + + obj->priv = priv; + + priv->status = TP_CONNECTION_STATUS_DISCONNECTED; +} + +static void +empathy_account_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + EmpathyAccount *account = EMPATHY_ACCOUNT (object); + EmpathyAccountPriv *priv = GET_PRIV (account); + + switch (prop_id) + { + case PROP_ENABLED: + g_value_set_boolean (value, priv->enabled); + break; + case PROP_PRESENCE: + g_value_set_uint (value, priv->presence); + break; + case PROP_CONNECTION_STATUS: + g_value_set_uint (value, priv->status); + break; + case PROP_CONNECTION_STATUS_REASON: + g_value_set_uint (value, priv->reason); + break; + case PROP_CONNECTION: + g_value_set_object (value, + empathy_account_get_connection (account)); + break; + case PROP_UNIQUE_NAME: + g_value_set_string (value, + empathy_account_get_unique_name (account)); + break; + case PROP_DISPLAY_NAME: + g_value_set_string (value, + empathy_account_get_display_name (account)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void empathy_account_dispose (GObject *object); +static void empathy_account_finalize (GObject *object); + +static void +empathy_account_class_init (EmpathyAccountClass *empathy_account_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (empathy_account_class); + + g_type_class_add_private (empathy_account_class, + sizeof (EmpathyAccountPriv)); + + object_class->get_property = empathy_account_get_property; + object_class->dispose = empathy_account_dispose; + object_class->finalize = empathy_account_finalize; + + g_object_class_install_property (object_class, PROP_ENABLED, + g_param_spec_boolean ("enabled", + "Enabled", + "Whether this account is enabled or not", + FALSE, + G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_PRESENCE, + g_param_spec_uint ("presence", + "Presence", + "The account connections presence type", + 0, + NUM_TP_CONNECTION_PRESENCE_TYPES, + TP_CONNECTION_PRESENCE_TYPE_UNSET, + G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_CONNECTION_STATUS, + g_param_spec_uint ("status", + "ConnectionStatus", + "The accounts connections status type", + 0, + NUM_TP_CONNECTION_STATUSES, + TP_CONNECTION_STATUS_DISCONNECTED, + G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_CONNECTION_STATUS_REASON, + g_param_spec_uint ("status-reason", + "ConnectionStatusReason", + "The account connections status reason", + 0, + NUM_TP_CONNECTION_STATUS_REASONS, + TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED, + G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_CONNECTION, + g_param_spec_object ("connection", + "Connection", + "The accounts connection", + TP_TYPE_CONNECTION, + G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_UNIQUE_NAME, + g_param_spec_string ("unique-name", + "UniqueName", + "The accounts unique name", + NULL, + G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); + + g_object_class_install_property (object_class, PROP_DISPLAY_NAME, + g_param_spec_string ("display-name", + "DisplayName", + "The accounts display name", + NULL, + G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); + + signals[STATUS_CHANGED] = g_signal_new ("status-changed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + _empathy_marshal_VOID__UINT_UINT_UINT, + G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT); + + signals[PRESENCE_CHANGED] = g_signal_new ("presence-changed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + _empathy_marshal_VOID__UINT_UINT, + G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT); +} + +void +empathy_account_dispose (GObject *object) +{ + EmpathyAccount *self = EMPATHY_ACCOUNT (object); + EmpathyAccountPriv *priv = GET_PRIV (self); + + if (priv->dispose_has_run) + return; + + priv->dispose_has_run = TRUE; + + if (priv->connection_invalidated_id != 0) + g_signal_handler_disconnect (priv->connection, + priv->connection_invalidated_id); + priv->connection_invalidated_id = 0; + + if (priv->connection != NULL) + g_object_unref (priv->connection); + priv->connection = NULL; + + /* release any references held by the object here */ + if (G_OBJECT_CLASS (empathy_account_parent_class)->dispose != NULL) + G_OBJECT_CLASS (empathy_account_parent_class)->dispose (object); +} + +void +empathy_account_finalize (GObject *object) +{ + /* free any data held directly by the object here */ + if (G_OBJECT_CLASS (empathy_account_parent_class)->finalize != NULL) + G_OBJECT_CLASS (empathy_account_parent_class)->finalize (object); +} + +gboolean +empathy_account_is_just_connected (EmpathyAccount *account) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + GTimeVal val; + + if (priv->status != TP_CONNECTION_STATUS_CONNECTED) + return FALSE; + + g_get_current_time (&val); + + return (val.tv_sec - priv->connect_time) < 10; +} + +/** + * empathy_account_get_connection: + * @account: a #EmpathyAccount + * + * Get the connection of the account, or NULL if account is offline or the + * connection is not yet ready. This function does not return a new ref. + * + * Returns: the connection of the account. + **/ +TpConnection * +empathy_account_get_connection (EmpathyAccount *account) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + + if (priv->connection != NULL && + tp_connection_is_ready (priv->connection)) + return priv->connection; + + return NULL; +} + +/** + * empathy_account_get_unique_name: + * @account: a #EmpathyAccount + * + * Returns: the unique name of the account. + **/ +const gchar * +empathy_account_get_unique_name (EmpathyAccount *account) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + + return mc_account_get_unique_name (priv->mc_account); +} + +/** + * empathy_account_get_display_name: + * @account: a #EmpathyAccount + * + * Returns: the display name of the account. + **/ +const gchar * +empathy_account_get_display_name (EmpathyAccount *account) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + + return mc_account_get_display_name (priv->mc_account); +} + +gboolean +empathy_account_is_valid (EmpathyAccount *account) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + + return mc_account_is_complete (priv->mc_account); +} + +void +empathy_account_set_enabled (EmpathyAccount *account, gboolean enabled) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + + mc_account_set_enabled (priv->mc_account, enabled); +} + +gboolean +empathy_account_is_enabled (EmpathyAccount *account) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + + return priv->enabled; +} + +void +empathy_account_unset_param (EmpathyAccount *account, const gchar *param) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + + mc_account_unset_param (priv->mc_account, param); +} + +gchar * +empathy_account_get_param_string (EmpathyAccount *account, const gchar *param) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + gchar *value = NULL; + + mc_account_get_param_string (priv->mc_account, param, &value); + return value; +} + +gint +empathy_account_get_param_int (EmpathyAccount *account, const gchar *param) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + int value; + + mc_account_get_param_int (priv->mc_account, param, &value); + return value; +} + +gboolean +empathy_account_get_param_boolean (EmpathyAccount *account, const gchar *param) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + gboolean value; + + mc_account_get_param_boolean (priv->mc_account, param, &value); + return value; +} + +void +empathy_account_set_param_string (EmpathyAccount *account, + const gchar *param, + const gchar *value) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + mc_account_set_param_string (priv->mc_account, param, value); +} + +void +empathy_account_set_param_int (EmpathyAccount *account, + const gchar *param, + gint value) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + mc_account_set_param_int (priv->mc_account, param, value); +} + +void +empathy_account_set_param_boolean (EmpathyAccount *account, + const gchar *param, + gboolean value) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + mc_account_set_param_boolean (priv->mc_account, param, value); +} + +void +empathy_account_set_display_name (EmpathyAccount *account, + const gchar *display_name) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + mc_account_set_display_name (priv->mc_account, display_name); +} + +McProfile * +empathy_account_get_profile (EmpathyAccount *account) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + return mc_account_get_profile (priv->mc_account); +} + +EmpathyAccount * +_empathy_account_new (McAccount *mc_account) +{ + EmpathyAccount *account; + EmpathyAccountPriv *priv; + + account = g_object_new (EMPATHY_TYPE_ACCOUNT, NULL); + priv = GET_PRIV (account); + priv->mc_account = mc_account; + + return account; +} + +void +_empathy_account_set_status (EmpathyAccount *account, + TpConnectionStatus status, + TpConnectionStatusReason reason, + TpConnectionPresenceType presence) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + TpConnectionStatus old_s = priv->status; + TpConnectionPresenceType old_p = priv->presence; + + priv->status = status; + priv->presence = presence; + + if (priv->status != old_s) + { + if (priv->status == TP_CONNECTION_STATUS_CONNECTED) + { + GTimeVal val; + g_get_current_time (&val); + + priv->connect_time = val.tv_sec; + } + + priv->reason = reason; + g_signal_emit (account, signals[STATUS_CHANGED], 0, + old_s, priv->status, reason); + + g_object_notify (G_OBJECT (account), "status"); + } + + if (priv->presence != old_p) + { + g_signal_emit (account, signals[PRESENCE_CHANGED], 0, + old_p, priv->presence); + g_object_notify (G_OBJECT (account), "presence"); + } +} + +static void +empathy_account_connection_ready_cb (TpConnection *connection, + const GError *error, + gpointer user_data) +{ + EmpathyAccount *account = EMPATHY_ACCOUNT (user_data); + EmpathyAccountPriv *priv = GET_PRIV (account); + + if (error != NULL) + { + DEBUG ("(%s) Connection failed to become ready: %s", + empathy_account_get_unique_name (account), error->message); + priv->connection = NULL; + } + else + { + DEBUG ("(%s) Connection ready", + empathy_account_get_unique_name (account)); + g_object_notify (G_OBJECT (account), "connection"); + } +} + +static void +_empathy_account_connection_invalidated_cb (TpProxy *self, + guint domain, + gint code, + gchar *message, + gpointer user_data) +{ + EmpathyAccount *account = EMPATHY_ACCOUNT (user_data); + EmpathyAccountPriv *priv = GET_PRIV (account); + + if (priv->connection == NULL) + return; + + DEBUG ("(%s) Connection invalidated", + empathy_account_get_unique_name (account)); + + g_assert (priv->connection == TP_CONNECTION (self)); + + g_signal_handler_disconnect (priv->connection, + priv->connection_invalidated_id); + priv->connection_invalidated_id = 0; + + g_object_unref (priv->connection); + priv->connection = NULL; + + g_object_notify (G_OBJECT (account), "connection"); +} + +void +_empathy_account_set_connection (EmpathyAccount *account, + TpConnection *connection) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + + if (priv->connection == connection) + return; + + /* Connection already set, don't set the new one */ + if (connection != NULL && priv->connection != NULL) + return; + + if (connection == NULL) + { + g_signal_handler_disconnect (priv->connection, + priv->connection_invalidated_id); + priv->connection_invalidated_id = 0; + + g_object_unref (priv->connection); + priv->connection = NULL; + g_object_notify (G_OBJECT (account), "connection"); + } + else + { + priv->connection = g_object_ref (connection); + priv->connection_invalidated_id = g_signal_connect (priv->connection, + "invalidated", + G_CALLBACK (_empathy_account_connection_invalidated_cb), + account); + + /* notify a change in the connection property when it's ready */ + tp_connection_call_when_ready (priv->connection, + empathy_account_connection_ready_cb, account); + } +} + +void +_empathy_account_set_enabled (EmpathyAccount *account, + gboolean enabled) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + + if (priv->enabled == enabled) + return; + + priv->enabled = enabled; + g_object_notify (G_OBJECT (account), "enabled"); +} + +McAccount * +_empathy_account_get_mc_account (EmpathyAccount *account) +{ + EmpathyAccountPriv *priv = GET_PRIV (account); + return priv->mc_account; +} diff --git a/libempathy/empathy-account.h b/libempathy/empathy-account.h new file mode 100644 index 000000000..75babd826 --- /dev/null +++ b/libempathy/empathy-account.h @@ -0,0 +1,94 @@ +/* + * empathy-account.h - Header for EmpathyAccount + * Copyright (C) 2009 Collabora Ltd. + * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __EMPATHY_ACCOUNT_H__ +#define __EMPATHY_ACCOUNT_H__ + +#include <glib-object.h> + +#include <telepathy-glib/connection.h> +#include <libmissioncontrol/mc-profile.h> + +G_BEGIN_DECLS + +typedef struct _EmpathyAccount EmpathyAccount; +typedef struct _EmpathyAccountClass EmpathyAccountClass; + +struct _EmpathyAccountClass { + GObjectClass parent_class; +}; + +struct _EmpathyAccount { + GObject parent; + gpointer priv; +}; + +GType empathy_account_get_type (void); + +/* TYPE MACROS */ +#define EMPATHY_TYPE_ACCOUNT (empathy_account_get_type ()) +#define EMPATHY_ACCOUNT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), EMPATHY_TYPE_ACCOUNT, EmpathyAccount)) +#define EMPATHY_ACCOUNT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), EMPATHY_TYPE_ACCOUNT, EmpathyAccountClass)) +#define EMPATHY_IS_ACCOUNT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), EMPATHY_TYPE_ACCOUNT)) +#define EMPATHY_IS_ACCOUNT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), EMPATHY_TYPE_ACCOUNT)) +#define EMPATHY_ACCOUNT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNT, \ + EmpathyAccountClass)) + +gboolean empathy_account_is_just_connected (EmpathyAccount *account); +TpConnection *empathy_account_get_connection (EmpathyAccount *account); +const gchar *empathy_account_get_unique_name (EmpathyAccount *account); +const gchar *empathy_account_get_display_name (EmpathyAccount *account); + +void empathy_account_set_enabled (EmpathyAccount *account, + gboolean enabled); +gboolean empathy_account_is_enabled (EmpathyAccount *account); + +void empathy_account_unset_param (EmpathyAccount *account, const gchar *param); +gchar *empathy_account_get_param_string (EmpathyAccount *account, + const gchar *param); +gint empathy_account_get_param_int (EmpathyAccount *account, + const gchar *param); +gboolean empathy_account_get_param_boolean (EmpathyAccount *account, + const gchar *param); + +void empathy_account_set_param_string (EmpathyAccount *account, + const gchar *param, const gchar *value); +void empathy_account_set_param_int (EmpathyAccount *account, + const gchar *param, gint value); +void empathy_account_set_param_boolean (EmpathyAccount *account, + const gchar *param, gboolean value); + +gboolean empathy_account_is_valid (EmpathyAccount *account); + +void empathy_account_set_display_name (EmpathyAccount *account, + const gchar *display_name); + + +/* TODO remove McProfile */ +McProfile *empathy_account_get_profile (EmpathyAccount *account); + +G_END_DECLS + +#endif /* #ifndef __EMPATHY_ACCOUNT_H__*/ diff --git a/libempathy/empathy-chatroom-manager.c b/libempathy/empathy-chatroom-manager.c index 44416670e..08c36d926 100644 --- a/libempathy/empathy-chatroom-manager.c +++ b/libempathy/empathy-chatroom-manager.c @@ -100,7 +100,8 @@ chatroom_manager_file_save (EmpathyChatroomManager *manager) continue; } - account_id = mc_account_get_unique_name (empathy_chatroom_get_account (chatroom)); + account_id = empathy_account_get_unique_name ( + empathy_chatroom_get_account (chatroom)); node = xmlNewChild (root, NULL, "chatroom", NULL); xmlNewTextChild (node, NULL, "name", empathy_chatroom_get_name (chatroom)); @@ -174,7 +175,7 @@ chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager, { EmpathyChatroomManagerPriv *priv; EmpathyChatroom *chatroom; - McAccount *account; + EmpathyAccount *account; xmlNodePtr child; gchar *str; gchar *name; @@ -220,7 +221,7 @@ chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager, xmlFree (str); } - account = mc_account_lookup (account_id); + account = empathy_account_manager_lookup (priv->account_manager, account_id); if (!account) { g_free (name); g_free (room); @@ -556,21 +557,20 @@ empathy_chatroom_manager_remove (EmpathyChatroomManager *manager, EmpathyChatroom * empathy_chatroom_manager_find (EmpathyChatroomManager *manager, - McAccount *account, + EmpathyAccount *account, const gchar *room) { EmpathyChatroomManagerPriv *priv; GList *l; g_return_val_if_fail (EMPATHY_IS_CHATROOM_MANAGER (manager), NULL); - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); g_return_val_if_fail (room != NULL, NULL); priv = GET_PRIV (manager); for (l = priv->chatrooms; l; l = l->next) { EmpathyChatroom *chatroom; - McAccount *this_account; + EmpathyAccount *this_account; const gchar *this_room; chatroom = l->data; @@ -589,7 +589,7 @@ empathy_chatroom_manager_find (EmpathyChatroomManager *manager, GList * empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager, - McAccount *account) + EmpathyAccount *account) { EmpathyChatroomManagerPriv *priv; GList *chatrooms, *l; @@ -619,7 +619,7 @@ empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager, guint empathy_chatroom_manager_get_count (EmpathyChatroomManager *manager, - McAccount *account) + EmpathyAccount *account) { EmpathyChatroomManagerPriv *priv; GList *l; @@ -686,7 +686,7 @@ chatroom_manager_observe_channel_cb (EmpathyDispatcher *dispatcher, const gchar *roomname; GQuark channel_type; TpHandleType handle_type; - McAccount *account; + EmpathyAccount *account; TpConnection *connection; channel_type = empathy_dispatch_operation_get_channel_type_id (operation); diff --git a/libempathy/empathy-chatroom-manager.h b/libempathy/empathy-chatroom-manager.h index 76c71d955..a6038f7fc 100644 --- a/libempathy/empathy-chatroom-manager.h +++ b/libempathy/empathy-chatroom-manager.h @@ -27,8 +27,7 @@ #include <glib-object.h> -#include <libmissioncontrol/mc-account.h> - +#include "empathy-account.h" #include "empathy-chatroom.h" #include "empathy-dispatcher.h" @@ -60,12 +59,12 @@ gboolean empathy_chatroom_manager_add (EmpathyChatroomMa void empathy_chatroom_manager_remove (EmpathyChatroomManager *manager, EmpathyChatroom *chatroom); EmpathyChatroom * empathy_chatroom_manager_find (EmpathyChatroomManager *manager, - McAccount *account, - const gchar *room); + EmpathyAccount *account, + const gchar *room); GList * empathy_chatroom_manager_get_chatrooms (EmpathyChatroomManager *manager, - McAccount *account); + EmpathyAccount *account); guint empathy_chatroom_manager_get_count (EmpathyChatroomManager *manager, - McAccount *account); + EmpathyAccount *account); void empathy_chatroom_manager_observe (EmpathyChatroomManager *manager, EmpathyDispatcher *dispatcher); diff --git a/libempathy/empathy-chatroom.c b/libempathy/empathy-chatroom.c index 147fca0a9..b62d6ad77 100644 --- a/libempathy/empathy-chatroom.c +++ b/libempathy/empathy-chatroom.c @@ -31,7 +31,7 @@ #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChatroom) typedef struct { - McAccount *account; + EmpathyAccount *account; gchar *room; gchar *name; gboolean auto_connect; @@ -84,7 +84,7 @@ empathy_chatroom_class_init (EmpathyChatroomClass *klass) g_param_spec_object ("account", "Chatroom Account", "The account associated with an chatroom", - MC_TYPE_ACCOUNT, + EMPATHY_TYPE_ACCOUNT, G_PARAM_READWRITE)); g_object_class_install_property (object_class, @@ -312,22 +312,19 @@ chatroom_set_property (GObject *object, } EmpathyChatroom * -empathy_chatroom_new (McAccount *account) +empathy_chatroom_new (EmpathyAccount *account) { - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); - return g_object_new (EMPATHY_TYPE_CHATROOM, "account", account, NULL); } EmpathyChatroom * -empathy_chatroom_new_full (McAccount *account, +empathy_chatroom_new_full (EmpathyAccount *account, const gchar *room, const gchar *name, gboolean auto_connect) { - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); g_return_val_if_fail (room != NULL, NULL); return g_object_new (EMPATHY_TYPE_CHATROOM, @@ -338,7 +335,7 @@ empathy_chatroom_new_full (McAccount *account, NULL); } -McAccount * +EmpathyAccount * empathy_chatroom_get_account (EmpathyChatroom *chatroom) { EmpathyChatroomPriv *priv; @@ -351,12 +348,11 @@ empathy_chatroom_get_account (EmpathyChatroom *chatroom) void empathy_chatroom_set_account (EmpathyChatroom *chatroom, - McAccount *account) + EmpathyAccount *account) { EmpathyChatroomPriv *priv; g_return_if_fail (EMPATHY_IS_CHATROOM (chatroom)); - g_return_if_fail (MC_IS_ACCOUNT (account)); priv = GET_PRIV (chatroom); @@ -470,8 +466,8 @@ gboolean empathy_chatroom_equal (gconstpointer v1, gconstpointer v2) { - McAccount *account_a; - McAccount *account_b; + EmpathyAccount *account_a; + EmpathyAccount *account_b; const gchar *room_a; const gchar *room_b; diff --git a/libempathy/empathy-chatroom.h b/libempathy/empathy-chatroom.h index 560517d48..c18c27449 100644 --- a/libempathy/empathy-chatroom.h +++ b/libempathy/empathy-chatroom.h @@ -24,8 +24,7 @@ #include <glib-object.h> -#include <libmissioncontrol/mc-account.h> - +#include <libempathy/empathy-account.h> #include <libempathy/empathy-tp-chat.h> G_BEGIN_DECLS @@ -52,14 +51,14 @@ struct _EmpathyChatroomClass { }; GType empathy_chatroom_get_type (void) G_GNUC_CONST; -EmpathyChatroom *empathy_chatroom_new (McAccount *account); -EmpathyChatroom *empathy_chatroom_new_full (McAccount *account, +EmpathyChatroom *empathy_chatroom_new (EmpathyAccount *account); +EmpathyChatroom *empathy_chatroom_new_full (EmpathyAccount *account, const gchar *room, const gchar *name, gboolean auto_connect); -McAccount * empathy_chatroom_get_account (EmpathyChatroom *chatroom); +EmpathyAccount * empathy_chatroom_get_account (EmpathyChatroom *chatroom); void empathy_chatroom_set_account (EmpathyChatroom *chatroom, - McAccount *account); + EmpathyAccount *account); const gchar * empathy_chatroom_get_room (EmpathyChatroom *chatroom); void empathy_chatroom_set_room (EmpathyChatroom *chatroom, const gchar *room); diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index bad6ef470..d351aecbc 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -39,7 +39,7 @@ #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyContact) typedef struct { TpContact *tp_contact; - McAccount *account; + EmpathyAccount *account; gchar *id; gchar *name; EmpathyAvatar *avatar; @@ -159,7 +159,7 @@ empathy_contact_class_init (EmpathyContactClass *class) g_param_spec_object ("account", "The account", "The account associated with the contact", - MC_TYPE_ACCOUNT, + EMPATHY_TYPE_ACCOUNT, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, @@ -409,12 +409,11 @@ empathy_contact_new (TpContact *tp_contact) } EmpathyContact * -empathy_contact_new_for_log (McAccount *account, +empathy_contact_new_for_log (EmpathyAccount *account, const gchar *id, const gchar *name, gboolean is_user) { - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); g_return_val_if_fail (id != NULL, NULL); return g_object_new (EMPATHY_TYPE_CONTACT, @@ -554,7 +553,7 @@ empathy_contact_set_avatar (EmpathyContact *contact, g_object_notify (G_OBJECT (contact), "avatar"); } -McAccount * +EmpathyAccount * empathy_contact_get_account (EmpathyContact *contact) { EmpathyContactPriv *priv; @@ -830,7 +829,7 @@ static gchar * contact_get_avatar_filename (EmpathyContact *contact, const gchar *token) { - McAccount *account; + EmpathyAccount *account; gchar *avatar_path; gchar *avatar_file; gchar *token_escaped; @@ -847,7 +846,7 @@ contact_get_avatar_filename (EmpathyContact *contact, avatar_path = g_build_filename (g_get_user_cache_dir (), PACKAGE_NAME, "avatars", - mc_account_get_unique_name (account), + empathy_account_get_unique_name (account), contact_escaped, NULL); g_mkdir_with_parents (avatar_path, 0700); diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h index f88831342..d4e385924 100644 --- a/libempathy/empathy-contact.h +++ b/libempathy/empathy-contact.h @@ -25,7 +25,7 @@ #include <glib-object.h> #include <telepathy-glib/contact.h> -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS @@ -70,7 +70,7 @@ typedef enum { GType empathy_contact_get_type (void) G_GNUC_CONST; EmpathyContact * empathy_contact_new (TpContact *tp_contact); -EmpathyContact * empathy_contact_new_for_log (McAccount *account, +EmpathyContact * empathy_contact_new_for_log (EmpathyAccount *account, const gchar *id, const gchar *name, gboolean is_user); TpContact * empathy_contact_get_tp_contact (EmpathyContact *contact); const gchar * empathy_contact_get_id (EmpathyContact *contact); @@ -80,7 +80,7 @@ void empathy_contact_set_name (EmpathyContact *contact, const gchar *name); EmpathyAvatar * empathy_contact_get_avatar (EmpathyContact *contact); void empathy_contact_set_avatar (EmpathyContact *contact, EmpathyAvatar *avatar); -McAccount * empathy_contact_get_account (EmpathyContact *contact); +EmpathyAccount * empathy_contact_get_account (EmpathyContact *contact); TpConnection * empathy_contact_get_connection (EmpathyContact *contact); TpConnectionPresenceType empathy_contact_get_presence (EmpathyContact *contact); void empathy_contact_set_presence (EmpathyContact *contact, diff --git a/libempathy/empathy-dispatch-operation.c b/libempathy/empathy-dispatch-operation.c index 7a116f870..79fe8c62d 100644 --- a/libempathy/empathy-dispatch-operation.c +++ b/libempathy/empathy-dispatch-operation.c @@ -22,6 +22,8 @@ #include <stdio.h> #include <stdlib.h> +#include <telepathy-glib/interfaces.h> + #include "empathy-dispatch-operation.h" #include <libempathy/empathy-enum-types.h> #include <libempathy/empathy-tp-contact-factory.h> @@ -215,7 +217,7 @@ empathy_dispatch_operation_constructed (GObject *object) handle = tp_channel_get_handle (priv->channel, &handle_type); - if (handle_type == TP_CONN_HANDLE_TYPE_CONTACT && priv->contact == NULL) + if (handle_type == TP_HANDLE_TYPE_CONTACT && priv->contact == NULL) { EmpathyTpContactFactory *factory; diff --git a/libempathy/empathy-dispatch-operation.h b/libempathy/empathy-dispatch-operation.h index 84ed36013..148adec90 100644 --- a/libempathy/empathy-dispatch-operation.h +++ b/libempathy/empathy-dispatch-operation.h @@ -24,6 +24,8 @@ #include <glib-object.h> #include <libempathy/empathy-contact.h> +#include <telepathy-glib/connection.h> +#include <telepathy-glib/channel.h> G_BEGIN_DECLS diff --git a/libempathy/empathy-log-manager.c b/libempathy/empathy-log-manager.c index b4c1f1a92..c1e20f487 100644 --- a/libempathy/empathy-log-manager.c +++ b/libempathy/empathy-log-manager.c @@ -157,7 +157,7 @@ empathy_log_manager_add_message (EmpathyLogManager *manager, gboolean empathy_log_manager_exists (EmpathyLogManager *manager, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom) { @@ -165,7 +165,6 @@ empathy_log_manager_exists (EmpathyLogManager *manager, EmpathyLogManagerPriv *priv; g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), FALSE); - g_return_val_if_fail (MC_IS_ACCOUNT (account), FALSE); g_return_val_if_fail (chat_id != NULL, FALSE); priv = GET_PRIV (manager); @@ -182,7 +181,7 @@ empathy_log_manager_exists (EmpathyLogManager *manager, GList * empathy_log_manager_get_dates (EmpathyLogManager *manager, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom) { @@ -190,7 +189,6 @@ empathy_log_manager_get_dates (EmpathyLogManager *manager, EmpathyLogManagerPriv *priv; g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL); - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); g_return_val_if_fail (chat_id != NULL, NULL); priv = GET_PRIV (manager); @@ -219,7 +217,7 @@ empathy_log_manager_get_dates (EmpathyLogManager *manager, GList * empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, const gchar *date) @@ -228,7 +226,6 @@ empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager, EmpathyLogManagerPriv *priv; g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL); - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); g_return_val_if_fail (chat_id != NULL, NULL); priv = GET_PRIV (manager); @@ -261,7 +258,7 @@ log_manager_message_date_cmp (gconstpointer a, GList * empathy_log_manager_get_filtered_messages (EmpathyLogManager *manager, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, guint num_messages, @@ -274,7 +271,6 @@ empathy_log_manager_get_filtered_messages (EmpathyLogManager *manager, guint i = 0; g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL); - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); g_return_val_if_fail (chat_id != NULL, NULL); priv = GET_PRIV (manager); @@ -322,13 +318,12 @@ empathy_log_manager_get_filtered_messages (EmpathyLogManager *manager, GList * empathy_log_manager_get_chats (EmpathyLogManager *manager, - McAccount *account) + EmpathyAccount *account) { GList *l, *out = NULL; EmpathyLogManagerPriv *priv; g_return_val_if_fail (EMPATHY_IS_LOG_MANAGER (manager), NULL); - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); priv = GET_PRIV (manager); diff --git a/libempathy/empathy-log-manager.h b/libempathy/empathy-log-manager.h index da7be4a43..6907e2ede 100644 --- a/libempathy/empathy-log-manager.h +++ b/libempathy/empathy-log-manager.h @@ -65,7 +65,7 @@ struct _EmpathyLogManagerClass struct _EmpathyLogSearchHit { - McAccount *account; + EmpathyAccount *account; gchar *chat_id; gboolean is_chatroom; gchar *filename; @@ -81,17 +81,17 @@ gboolean empathy_log_manager_add_message (EmpathyLogManager *manager, const gchar *chat_id, gboolean chatroom, EmpathyMessage *message, GError **error); gboolean empathy_log_manager_exists (EmpathyLogManager *manager, - McAccount *account, const gchar *chat_id, gboolean chatroom); + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom); GList *empathy_log_manager_get_dates (EmpathyLogManager *manager, - McAccount *account, const gchar *chat_id, gboolean chatroom); + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom); GList *empathy_log_manager_get_messages_for_date (EmpathyLogManager *manager, - McAccount *account, const gchar *chat_id, gboolean chatroom, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, const gchar *date); GList *empathy_log_manager_get_filtered_messages (EmpathyLogManager *manager, - McAccount *account, const gchar *chat_id, gboolean chatroom, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, guint num_messages, EmpathyLogMessageFilter filter, gpointer user_data); GList *empathy_log_manager_get_chats (EmpathyLogManager *manager, - McAccount *account); + EmpathyAccount *account); GList *empathy_log_manager_search_new (EmpathyLogManager *manager, const gchar *text); void empathy_log_manager_search_free (GList *hits); diff --git a/libempathy/empathy-log-store-empathy.c b/libempathy/empathy-log-store-empathy.c index 94f4d1457..7e50cb12f 100644 --- a/libempathy/empathy-log-store-empathy.c +++ b/libempathy/empathy-log-store-empathy.c @@ -32,6 +32,7 @@ #include "empathy-log-store.h" #include "empathy-log-store-empathy.h" #include "empathy-log-manager.h" +#include "empathy-account-manager.h" #include "empathy-contact.h" #include "empathy-time.h" #include "empathy-utils.h" @@ -59,6 +60,7 @@ typedef struct { gchar *basedir; gchar *name; + EmpathyAccountManager *account_manager; } EmpathyLogStoreEmpathyPriv; static void log_store_iface_init (gpointer g_iface,gpointer iface_data); @@ -73,6 +75,7 @@ log_store_empathy_finalize (GObject *object) EmpathyLogStoreEmpathy *self = EMPATHY_LOG_STORE_EMPATHY (object); EmpathyLogStoreEmpathyPriv *priv = GET_PRIV (self); + g_object_unref (priv->account_manager); g_free (priv->basedir); g_free (priv->name); } @@ -99,11 +102,12 @@ empathy_log_store_empathy_init (EmpathyLogStoreEmpathy *self) ".gnome2", PACKAGE_NAME, "logs", NULL); priv->name = g_strdup ("Empathy"); + priv->account_manager = empathy_account_manager_dup_singleton (); } static gchar * log_store_empathy_get_dir (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom) { @@ -113,7 +117,7 @@ log_store_empathy_get_dir (EmpathyLogStore *self, priv = GET_PRIV (self); - account_id = mc_account_get_unique_name (account); + account_id = empathy_account_get_unique_name (account); if (chatroom) basedir = g_build_path (G_DIR_SEPARATOR_S, priv->basedir, account_id, @@ -154,7 +158,7 @@ log_store_empathy_get_timestamp_from_message (EmpathyMessage *message) static gchar * log_store_empathy_get_filename (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom) { @@ -180,7 +184,7 @@ log_store_empathy_add_message (EmpathyLogStore *self, GError **error) { FILE *file; - McAccount *account; + EmpathyAccount *account; EmpathyContact *sender; const gchar *body_str; const gchar *str; @@ -267,7 +271,7 @@ log_store_empathy_add_message (EmpathyLogStore *self, static gboolean log_store_empathy_exists (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom) { @@ -283,7 +287,7 @@ log_store_empathy_exists (EmpathyLogStore *self, static GList * log_store_empathy_get_dates (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom) { @@ -295,7 +299,6 @@ log_store_empathy_get_dates (EmpathyLogStore *self, const gchar *p; g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), NULL); - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); g_return_val_if_fail (chat_id != NULL, NULL); directory = log_store_empathy_get_dir (self, account, chat_id, chatroom); @@ -336,7 +339,7 @@ log_store_empathy_get_dates (EmpathyLogStore *self, static gchar * log_store_empathy_get_filename_for_date (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, const gchar *date) @@ -359,6 +362,7 @@ static EmpathyLogSearchHit * log_store_empathy_search_hit_new (EmpathyLogStore *self, const gchar *filename) { + EmpathyLogStoreEmpathyPriv *priv = GET_PRIV (self); EmpathyLogSearchHit *hit; const gchar *account_name; const gchar *end; @@ -383,7 +387,8 @@ log_store_empathy_search_hit_new (EmpathyLogStore *self, else account_name = strv[len-3]; - hit->account = mc_account_lookup (account_name); + hit->account = empathy_account_manager_lookup (priv->account_manager, + account_name); hit->filename = g_strdup (filename); g_strfreev (strv); @@ -401,7 +406,7 @@ log_store_empathy_get_messages_for_file (EmpathyLogStore *self, xmlNodePtr log_node; xmlNodePtr node; EmpathyLogSearchHit *hit; - McAccount *account; + EmpathyAccount *account; g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), NULL); g_return_val_if_fail (filename != NULL, NULL); @@ -666,7 +671,7 @@ log_store_empathy_get_chats_for_dir (EmpathyLogStore *self, static GList * log_store_empathy_get_messages_for_date (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, const gchar *date) @@ -675,7 +680,6 @@ log_store_empathy_get_messages_for_date (EmpathyLogStore *self, GList *messages; g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), NULL); - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); g_return_val_if_fail (chat_id != NULL, NULL); filename = log_store_empathy_get_filename_for_date (self, account, @@ -688,7 +692,7 @@ log_store_empathy_get_messages_for_date (EmpathyLogStore *self, static GList * log_store_empathy_get_chats (EmpathyLogStore *self, - McAccount *account) + EmpathyAccount *account) { gchar *dir; GList *hits; @@ -697,7 +701,7 @@ log_store_empathy_get_chats (EmpathyLogStore *self, priv = GET_PRIV (self); dir = g_build_filename (priv->basedir, - mc_account_get_unique_name (account), NULL); + empathy_account_get_unique_name (account), NULL); hits = log_store_empathy_get_chats_for_dir (self, dir, FALSE); @@ -716,7 +720,7 @@ log_store_empathy_get_name (EmpathyLogStore *self) static GList * log_store_empathy_get_filtered_messages (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, guint num_messages, diff --git a/libempathy/empathy-log-store.c b/libempathy/empathy-log-store.c index 21a881559..f136f7910 100644 --- a/libempathy/empathy-log-store.c +++ b/libempathy/empathy-log-store.c @@ -55,7 +55,7 @@ empathy_log_store_get_name (EmpathyLogStore *self) gboolean empathy_log_store_exists (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom) { @@ -84,7 +84,7 @@ empathy_log_store_add_message (EmpathyLogStore *self, GList * empathy_log_store_get_dates (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom) { @@ -97,7 +97,7 @@ empathy_log_store_get_dates (EmpathyLogStore *self, GList * empathy_log_store_get_messages_for_date (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, const gchar *date) @@ -111,7 +111,7 @@ empathy_log_store_get_messages_for_date (EmpathyLogStore *self, GList * empathy_log_store_get_last_messages (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom) { @@ -124,7 +124,7 @@ empathy_log_store_get_last_messages (EmpathyLogStore *self, GList * empathy_log_store_get_chats (EmpathyLogStore *self, - McAccount *account) + EmpathyAccount *account) { if (!EMPATHY_LOG_STORE_GET_INTERFACE (self)->get_chats) return NULL; @@ -157,7 +157,7 @@ empathy_log_store_ack_message (EmpathyLogStore *self, GList * empathy_log_store_get_filtered_messages (EmpathyLogStore *self, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, guint num_messages, diff --git a/libempathy/empathy-log-store.h b/libempathy/empathy-log-store.h index db698c4b0..5b6a87875 100644 --- a/libempathy/empathy-log-store.h +++ b/libempathy/empathy-log-store.h @@ -25,7 +25,7 @@ #include <glib-object.h> -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> #include "empathy-message.h" #include "empathy-log-manager.h" @@ -50,23 +50,23 @@ struct _EmpathyLogStoreInterface GTypeInterface parent; const gchar * (*get_name) (EmpathyLogStore *self); - gboolean (*exists) (EmpathyLogStore *self, McAccount *account, + gboolean (*exists) (EmpathyLogStore *self, EmpathyAccount *account, const gchar *chat_id, gboolean chatroom); gboolean (*add_message) (EmpathyLogStore *self, const gchar *chat_id, gboolean chatroom, EmpathyMessage *message, GError **error); - GList * (*get_dates) (EmpathyLogStore *self, McAccount *account, + GList * (*get_dates) (EmpathyLogStore *self, EmpathyAccount *account, const gchar *chat_id, gboolean chatroom); GList * (*get_messages_for_date) (EmpathyLogStore *self, - McAccount *account, const gchar *chat_id, gboolean chatroom, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, const gchar *date); - GList * (*get_last_messages) (EmpathyLogStore *self, McAccount *account, + GList * (*get_last_messages) (EmpathyLogStore *self, EmpathyAccount *account, const gchar *chat_id, gboolean chatroom); GList * (*get_chats) (EmpathyLogStore *self, - McAccount *account); + EmpathyAccount *account); GList * (*search_new) (EmpathyLogStore *self, const gchar *text); void (*ack_message) (EmpathyLogStore *self, const gchar *chat_id, gboolean chatroom, EmpathyMessage *message); - GList * (*get_filtered_messages) (EmpathyLogStore *self, McAccount *account, + GList * (*get_filtered_messages) (EmpathyLogStore *self, EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, guint num_messages, EmpathyLogMessageFilter filter, gpointer user_data); }; @@ -75,25 +75,25 @@ GType empathy_log_store_get_type (void) G_GNUC_CONST; const gchar *empathy_log_store_get_name (EmpathyLogStore *self); gboolean empathy_log_store_exists (EmpathyLogStore *self, - McAccount *account, const gchar *chat_id, gboolean chatroom); + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom); gboolean empathy_log_store_add_message (EmpathyLogStore *self, const gchar *chat_id, gboolean chatroom, EmpathyMessage *message, GError **error); GList *empathy_log_store_get_dates (EmpathyLogStore *self, - McAccount *account, const gchar *chat_id, gboolean chatroom); + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom); GList *empathy_log_store_get_messages_for_date (EmpathyLogStore *self, - McAccount *account, const gchar *chat_id, gboolean chatroom, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, const gchar *date); GList *empathy_log_store_get_last_messages (EmpathyLogStore *self, - McAccount *account, const gchar *chat_id, gboolean chatroom); + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom); GList *empathy_log_store_get_chats (EmpathyLogStore *self, - McAccount *account); + EmpathyAccount *account); GList *empathy_log_store_search_new (EmpathyLogStore *self, const gchar *text); void empathy_log_store_ack_message (EmpathyLogStore *self, const gchar *chat_id, gboolean chatroom, EmpathyMessage *message); GList *empathy_log_store_get_filtered_messages (EmpathyLogStore *self, - McAccount *account, const gchar *chat_id, gboolean chatroom, + EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, guint num_messages, EmpathyLogMessageFilter filter, gpointer user_data); G_END_DECLS diff --git a/libempathy/empathy-tp-roomlist.c b/libempathy/empathy-tp-roomlist.c index 1b2e393d1..b3d955ee4 100644 --- a/libempathy/empathy-tp-roomlist.c +++ b/libempathy/empathy-tp-roomlist.c @@ -27,7 +27,7 @@ #include <telepathy-glib/dbus.h> #include <telepathy-glib/util.h> -#include <libmissioncontrol/mission-control.h> +#include "empathy-account.h" #include "empathy-tp-roomlist.h" #include "empathy-chatroom.h" @@ -40,7 +40,7 @@ typedef struct { TpConnection *connection; TpChannel *channel; - McAccount *account; + EmpathyAccount *account; gboolean is_listing; gboolean start_requested; } EmpathyTpRoomlistPriv; @@ -54,7 +54,7 @@ enum { enum { PROP_0, - PROP_CONNECTION, + PROP_ACCOUNT, PROP_IS_LISTING, }; @@ -352,13 +352,9 @@ static void tp_roomlist_constructed (GObject *list) { EmpathyTpRoomlistPriv *priv = GET_PRIV (list); - MissionControl *mc; - mc = empathy_mission_control_dup_singleton (); - priv->account = mission_control_get_account_for_tpconnection (mc, - priv->connection, - NULL); - g_object_unref (mc); + priv->connection = empathy_account_get_connection (priv->account); + g_object_ref (priv->connection); tp_cli_connection_call_request_channel (priv->connection, -1, TP_IFACE_CHANNEL_TYPE_ROOM_LIST, @@ -379,8 +375,8 @@ tp_roomlist_get_property (GObject *object, EmpathyTpRoomlistPriv *priv = GET_PRIV (object); switch (param_id) { - case PROP_CONNECTION: - g_value_set_object (value, priv->connection); + case PROP_ACCOUNT: + g_value_set_object (value, priv->account); break; case PROP_IS_LISTING: g_value_set_boolean (value, priv->is_listing); @@ -400,8 +396,8 @@ tp_roomlist_set_property (GObject *object, EmpathyTpRoomlistPriv *priv = GET_PRIV (object); switch (param_id) { - case PROP_CONNECTION: - priv->connection = g_object_ref (g_value_get_object (value)); + case PROP_ACCOUNT: + priv->account = g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); @@ -420,11 +416,11 @@ empathy_tp_roomlist_class_init (EmpathyTpRoomlistClass *klass) object_class->set_property = tp_roomlist_set_property; g_object_class_install_property (object_class, - PROP_CONNECTION, - g_param_spec_object ("connection", - "The Connection", - "The connection on which it lists rooms", - TP_TYPE_CONNECTION, + PROP_ACCOUNT, + g_param_spec_object ("account", + "The Account", + "The account on which it lists rooms", + EMPATHY_TYPE_ACCOUNT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, @@ -480,24 +476,14 @@ empathy_tp_roomlist_init (EmpathyTpRoomlist *list) } EmpathyTpRoomlist * -empathy_tp_roomlist_new (McAccount *account) +empathy_tp_roomlist_new (EmpathyAccount *account) { EmpathyTpRoomlist *list; - MissionControl *mc; - TpConnection *connection; - - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); - - mc = empathy_mission_control_dup_singleton (); - connection = mission_control_get_tpconnection (mc, account, NULL); list = g_object_new (EMPATHY_TYPE_TP_ROOMLIST, - "connection", connection, + "account", account, NULL); - g_object_unref (mc); - g_object_unref (connection); - return list; } diff --git a/libempathy/empathy-tp-roomlist.h b/libempathy/empathy-tp-roomlist.h index 9f45b7f5c..801e5c69f 100644 --- a/libempathy/empathy-tp-roomlist.h +++ b/libempathy/empathy-tp-roomlist.h @@ -25,7 +25,7 @@ #include <glib.h> #include <telepathy-glib/connection.h> -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS @@ -49,7 +49,7 @@ struct _EmpathyTpRoomlistClass { }; GType empathy_tp_roomlist_get_type (void) G_GNUC_CONST; -EmpathyTpRoomlist *empathy_tp_roomlist_new (McAccount *account); +EmpathyTpRoomlist *empathy_tp_roomlist_new (EmpathyAccount *account); gboolean empathy_tp_roomlist_is_listing (EmpathyTpRoomlist *list); void empathy_tp_roomlist_start (EmpathyTpRoomlist *list); void empathy_tp_roomlist_stop (EmpathyTpRoomlist *list); diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index fca7fcb5f..fd54c9a98 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -230,25 +230,16 @@ empathy_xml_node_find_child_prop_value (xmlNodePtr node, guint empathy_account_hash (gconstpointer key) { - g_return_val_if_fail (MC_IS_ACCOUNT (key), 0); + g_return_val_if_fail (EMPATHY_IS_ACCOUNT (key), 0); - return g_str_hash (mc_account_get_unique_name (MC_ACCOUNT (key))); + return g_str_hash (empathy_account_get_unique_name (EMPATHY_ACCOUNT (key))); } gboolean empathy_account_equal (gconstpointer a, gconstpointer b) { - const gchar *name_a; - const gchar *name_b; - - g_return_val_if_fail (MC_IS_ACCOUNT (a), FALSE); - g_return_val_if_fail (MC_IS_ACCOUNT (b), FALSE); - - name_a = mc_account_get_unique_name (MC_ACCOUNT (a)); - name_b = mc_account_get_unique_name (MC_ACCOUNT (b)); - - return g_str_equal (name_a, name_b); + return a == b; } MissionControl * diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h index de1437b9d..42acbc8e3 100644 --- a/libempathy/empathy-utils.h +++ b/libempathy/empathy-utils.h @@ -32,7 +32,6 @@ #include <libxml/parser.h> #include <libxml/tree.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mission-control.h> #include "empathy-contact.h" diff --git a/megaphone/src/megaphone-applet.c b/megaphone/src/megaphone-applet.c index 0879e75a5..2e4fb1e72 100644 --- a/megaphone/src/megaphone-applet.c +++ b/megaphone/src/megaphone-applet.c @@ -32,10 +32,10 @@ #include <gconf/gconf-client.h> #include <libmissioncontrol/mission-control.h> -#include <libmissioncontrol/mc-account.h> #include <libempathy/empathy-tp-contact-factory.h> #include <libempathy/empathy-account-manager.h> +#include <libempathy/empathy-dispatcher.h> #include <libempathy/empathy-contact.h> #include <libempathy/empathy-contact-list.h> #include <libempathy/empathy-contact-manager.h> @@ -55,7 +55,7 @@ typedef struct { EmpathyTpContactFactory *factory; EmpathyAccountManager *account_manager; - McAccount *account; + EmpathyAccount *account; gchar *id; GtkWidget *image; gint image_size; @@ -194,7 +194,7 @@ megaphone_applet_got_contact_cb (EmpathyTpContactFactory *factory, static void megaphone_applet_new_connection_cb (EmpathyAccountManager *manager, TpConnection *connection, - McAccount *account, + EmpathyAccount *account, MegaphoneApplet *applet) { MegaphoneAppletPriv *priv = GET_PRIV (applet); @@ -223,13 +223,13 @@ megaphone_applet_preferences_response_cb (GtkWidget *dialog, contact_list = g_object_get_data (G_OBJECT (dialog), "contact-list"); contact = empathy_contact_list_view_dup_selected (contact_list); if (contact) { - McAccount *account; + EmpathyAccount *account; const gchar *account_id; const gchar *contact_id; gchar *str; account = empathy_contact_get_account (contact); - account_id = mc_account_get_unique_name (account); + account_id = empathy_account_get_unique_name (account); contact_id = empathy_contact_get_id (contact); str = g_strconcat (account_id, "/", contact_id, NULL); @@ -300,7 +300,6 @@ megaphone_applet_button_press_event_cb (GtkWidget *widget, MegaphoneApplet *applet) { MegaphoneAppletPriv *priv = GET_PRIV (applet); - MissionControl *mc; /* Only react on left-clicks */ if (event->button != 1 || event->type != GDK_BUTTON_PRESS) { @@ -317,15 +316,8 @@ megaphone_applet_button_press_event_cb (GtkWidget *widget, empathy_contact_get_id (priv->contact), empathy_contact_get_handle (priv->contact)); - mc = empathy_mission_control_dup_singleton (); - mission_control_request_channel (mc, - empathy_contact_get_account (priv->contact), - TP_IFACE_CHANNEL_TYPE_TEXT, - empathy_contact_get_handle (priv->contact), - TP_HANDLE_TYPE_CONTACT, - NULL, NULL); - g_object_unref (mc); - + empathy_dispatcher_chat_with_contact (priv->contact, NULL, NULL); + return TRUE; } @@ -453,15 +445,15 @@ megaphone_applet_set_contact (MegaphoneApplet *applet, /* Lookup the new contact */ if (str) { strv = g_strsplit (str, "/", 2); - priv->account = mc_account_lookup (strv[0]); + priv->account = empathy_account_manager_lookup (priv->account_manager, + strv[0]); priv->id = strv[1]; g_free (strv[0]); g_free (strv); } if (priv->account) { - connection = empathy_account_manager_get_connection ( - priv->account_manager, priv->account); + connection = empathy_account_get_connection (priv->account); if (connection) { megaphone_applet_new_connection_cb (priv->account_manager, connection, priv->account, applet); diff --git a/python/pyempathy/pyempathy.defs b/python/pyempathy/pyempathy.defs index ed19c7a96..6b6f7dfd3 100644 --- a/python/pyempathy/pyempathy.defs +++ b/python/pyempathy/pyempathy.defs @@ -259,6 +259,8 @@ '("tp-error" "EMPATHY_FT_ERROR_TP_ERROR") '("socket" "EMPATHY_FT_ERROR_SOCKET") '("not-supported" "EMPATHY_FT_ERROR_NOT_SUPPORTED") + '("invalid-source-file" "EMPATHY_FT_ERROR_INVALID_SOURCE_FILE") + '("empty-source-file" "EMPATHY_FT_ERROR_EMPTY_SOURCE_FILE") ) ) @@ -275,6 +277,15 @@ (return-type "EmpathyAccountManager*") ) +(define-method create + (of-object "EmpathyAccountManager") + (c-name "empathy_account_manager_create") + (return-type "EmpathyAccount*") + (parameters + '("McProfile*" "profile") + ) +) + (define-method get_connected_accounts (of-object "EmpathyAccountManager") (c-name "empathy_account_manager_get_connected_accounts") @@ -287,15 +298,6 @@ (return-type "int") ) -(define-method is_account_just_connected - (of-object "EmpathyAccountManager") - (c-name "empathy_account_manager_is_account_just_connected") - (return-type "gboolean") - (parameters - '("McAccount*" "account") - ) -) - (define-method get_count (of-object "EmpathyAccountManager") (c-name "empathy_account_manager_get_count") @@ -305,25 +307,25 @@ (define-method get_account (of-object "EmpathyAccountManager") (c-name "empathy_account_manager_get_account") - (return-type "McAccount*") + (return-type "EmpathyAccount*") (parameters '("TpConnection*" "connection") ) ) -(define-method dup_accounts +(define-method lookup (of-object "EmpathyAccountManager") - (c-name "empathy_account_manager_dup_accounts") - (return-type "GList*") + (c-name "empathy_account_manager_lookup") + (return-type "EmpathyAccount*") + (parameters + '("const-gchar*" "unique_name") + ) ) -(define-method get_connection +(define-method dup_accounts (of-object "EmpathyAccountManager") - (c-name "empathy_account_manager_get_connection") - (return-type "TpConnection*") - (parameters - '("McAccount*" "account") - ) + (c-name "empathy_account_manager_dup_accounts") + (return-type "GList*") ) (define-method dup_connections @@ -332,6 +334,15 @@ (return-type "GList*") ) +(define-method remove + (of-object "EmpathyAccountManager") + (c-name "empathy_account_manager_remove") + (return-type "none") + (parameters + '("EmpathyAccount*" "account") + ) +) + ;; From empathy-chatroom.h @@ -346,7 +357,7 @@ (is-constructor-of "EmpathyChatroom") (return-type "EmpathyChatroom*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") ) ) @@ -354,7 +365,7 @@ (c-name "empathy_chatroom_new_full") (return-type "EmpathyChatroom*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "room") '("const-gchar*" "name") '("gboolean" "auto_connect") @@ -364,7 +375,7 @@ (define-method get_account (of-object "EmpathyChatroom") (c-name "empathy_chatroom_get_account") - (return-type "McAccount*") + (return-type "EmpathyAccount*") ) (define-method set_account @@ -372,7 +383,7 @@ (c-name "empathy_chatroom_set_account") (return-type "none") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") ) ) @@ -560,7 +571,7 @@ (c-name "empathy_chatroom_manager_find") (return-type "EmpathyChatroom*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "room") ) ) @@ -570,7 +581,7 @@ (c-name "empathy_chatroom_manager_get_chatrooms") (return-type "GList*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") ) ) @@ -579,7 +590,7 @@ (c-name "empathy_chatroom_manager_get_count") (return-type "guint") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") ) ) @@ -681,6 +692,18 @@ (return-type "none") ) +(define-method stop_call + (of-object "EmpathyCallHandler") + (c-name "empathy_call_handler_stop_call") + (return-type "none") +) + +(define-method has_initial_video + (of-object "EmpathyCallHandler") + (c-name "empathy_call_handler_has_initial_video") + (return-type "gboolean") +) + (define-method bus_message (of-object "EmpathyCallHandler") (c-name "empathy_call_handler_bus_message") @@ -713,7 +736,7 @@ (c-name "empathy_contact_new_for_log") (return-type "EmpathyContact*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "id") '("const-gchar*" "name") '("gboolean" "is_user") @@ -774,7 +797,7 @@ (define-method get_account (of-object "EmpathyContact") (c-name "empathy_contact_get_account") - (return-type "McAccount*") + (return-type "EmpathyAccount*") ) (define-method get_connection @@ -972,6 +995,15 @@ ) ) +(define-function contact_equal + (c-name "empathy_contact_equal") + (return-type "gboolean") + (parameters + '("gconstpointer" "contact1") + '("gconstpointer" "contact2") + ) +) + ;; From empathy-contact-groups.h @@ -1179,6 +1211,11 @@ (varargs #t) ) +(define-function debug_free + (c-name "empathy_debug_free") + (return-type "none") +) + (define-function debug_set_flags (c-name "empathy_debug_set_flags") (return-type "none") @@ -1794,7 +1831,7 @@ (c-name "empathy_log_manager_exists") (return-type "gboolean") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "chat_id") '("gboolean" "chatroom") ) @@ -1805,7 +1842,7 @@ (c-name "empathy_log_manager_get_dates") (return-type "GList*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "chat_id") '("gboolean" "chatroom") ) @@ -1816,7 +1853,7 @@ (c-name "empathy_log_manager_get_messages_for_date") (return-type "GList*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "chat_id") '("gboolean" "chatroom") '("const-gchar*" "date") @@ -1828,7 +1865,7 @@ (c-name "empathy_log_manager_get_filtered_messages") (return-type "GList*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "chat_id") '("gboolean" "chatroom") '("guint" "num_messages") @@ -1842,7 +1879,7 @@ (c-name "empathy_log_manager_get_chats") (return-type "GList*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") ) ) @@ -1908,7 +1945,7 @@ (c-name "empathy_log_store_exists") (return-type "gboolean") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "chat_id") '("gboolean" "chatroom") ) @@ -1931,7 +1968,7 @@ (c-name "empathy_log_store_get_dates") (return-type "GList*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "chat_id") '("gboolean" "chatroom") ) @@ -1942,7 +1979,7 @@ (c-name "empathy_log_store_get_messages_for_date") (return-type "GList*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "chat_id") '("gboolean" "chatroom") '("const-gchar*" "date") @@ -1954,7 +1991,7 @@ (c-name "empathy_log_store_get_last_messages") (return-type "GList*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "chat_id") '("gboolean" "chatroom") ) @@ -1965,7 +2002,7 @@ (c-name "empathy_log_store_get_chats") (return-type "GList*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") ) ) @@ -1994,7 +2031,7 @@ (c-name "empathy_log_store_get_filtered_messages") (return-type "GList*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "chat_id") '("gboolean" "chatroom") '("guint" "num_messages") @@ -2216,6 +2253,14 @@ (return-type "none") ) +(define-function status_presets_is_valid + (c-name "empathy_status_presets_is_valid") + (return-type "gboolean") + (parameters + '("TpConnectionPresenceType" "state") + ) +) + ;; From empathy-time.h @@ -2338,6 +2383,18 @@ (return-type "gboolean") ) +(define-method is_receiving_video + (of-object "EmpathyTpCall") + (c-name "empathy_tp_call_is_receiving_video") + (return-type "gboolean") +) + +(define-method is_sending_video + (of-object "EmpathyTpCall") + (c-name "empathy_tp_call_is_sending_video") + (return-type "gboolean") +) + ;; From empathy-tp-chat.h @@ -2661,7 +2718,7 @@ (is-constructor-of "EmpathyTpRoomlist") (return-type "EmpathyTpRoomlist*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") ) ) diff --git a/python/pyempathygtk/pyempathygtk.defs b/python/pyempathygtk/pyempathygtk.defs index cf85c7853..377eea43a 100644 --- a/python/pyempathygtk/pyempathygtk.defs +++ b/python/pyempathygtk/pyempathygtk.defs @@ -290,7 +290,7 @@ (define-method dup_account (of-object "EmpathyAccountChooser") (c-name "empathy_account_chooser_dup_account") - (return-type "McAccount*") + (return-type "EmpathyAccount*") ) (define-method get_connection @@ -304,7 +304,7 @@ (c-name "empathy_account_chooser_set_account") (return-type "gboolean") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") ) ) @@ -333,11 +333,11 @@ ) ) -(define-function account_chooser_filter_is_connected +(define-method chooser_filter_is_connected + (of-object "EmpathyAccount") (c-name "empathy_account_chooser_filter_is_connected") (return-type "gboolean") (parameters - '("McAccount*" "account") '("gpointer" "user_data") ) ) @@ -346,22 +346,22 @@ ;; From empathy-account-widget.h -(define-function account_widget_handle_params +(define-method widget_handle_params + (of-object "EmpathyAccount") (c-name "empathy_account_widget_handle_params") (return-type "none") (parameters - '("McAccount*" "account") '("GtkBuilder*" "gui") '("const-gchar*" "first_widget") ) (varargs #t) ) -(define-function account_widget_add_forget_button +(define-method widget_add_forget_button + (of-object "EmpathyAccount") (c-name "empathy_account_widget_add_forget_button") (return-type "none") (parameters - '("McAccount*" "account") '("GtkBuilder*" "gui") '("const-gchar*" "button") '("const-gchar*" "entry") @@ -377,102 +377,72 @@ ) ) -(define-function account_widget_generic_new +(define-method widget_generic_new + (of-object "EmpathyAccount") (c-name "empathy_account_widget_generic_new") - (is-constructor-of "EmpathyAccountWidgetGeneric") (return-type "GtkWidget*") - (parameters - '("McAccount*" "account") - ) ) -(define-function account_widget_salut_new +(define-method widget_salut_new + (of-object "EmpathyAccount") (c-name "empathy_account_widget_salut_new") - (is-constructor-of "EmpathyAccountWidgetSalut") (return-type "GtkWidget*") - (parameters - '("McAccount*" "account") - ) ) -(define-function account_widget_msn_new +(define-method widget_msn_new + (of-object "EmpathyAccount") (c-name "empathy_account_widget_msn_new") - (is-constructor-of "EmpathyAccountWidgetMsn") (return-type "GtkWidget*") - (parameters - '("McAccount*" "account") - ) ) -(define-function account_widget_jabber_new +(define-method widget_jabber_new + (of-object "EmpathyAccount") (c-name "empathy_account_widget_jabber_new") - (is-constructor-of "EmpathyAccountWidgetJabber") (return-type "GtkWidget*") - (parameters - '("McAccount*" "account") - ) ) -(define-function account_widget_icq_new +(define-method widget_icq_new + (of-object "EmpathyAccount") (c-name "empathy_account_widget_icq_new") - (is-constructor-of "EmpathyAccountWidgetIcq") (return-type "GtkWidget*") - (parameters - '("McAccount*" "account") - ) ) -(define-function account_widget_aim_new +(define-method widget_aim_new + (of-object "EmpathyAccount") (c-name "empathy_account_widget_aim_new") - (is-constructor-of "EmpathyAccountWidgetAim") (return-type "GtkWidget*") - (parameters - '("McAccount*" "account") - ) ) -(define-function account_widget_yahoo_new +(define-method widget_yahoo_new + (of-object "EmpathyAccount") (c-name "empathy_account_widget_yahoo_new") - (is-constructor-of "EmpathyAccountWidgetYahoo") (return-type "GtkWidget*") - (parameters - '("McAccount*" "account") - ) ) -(define-function account_widget_groupwise_new +(define-method widget_groupwise_new + (of-object "EmpathyAccount") (c-name "empathy_account_widget_groupwise_new") - (is-constructor-of "EmpathyAccountWidgetGroupwise") (return-type "GtkWidget*") - (parameters - '("McAccount*" "account") - ) ) ;; From empathy-account-widget-irc.h -(define-function account_widget_irc_new +(define-method widget_irc_new + (of-object "EmpathyAccount") (c-name "empathy_account_widget_irc_new") - (is-constructor-of "EmpathyAccountWidgetIrc") (return-type "GtkWidget*") - (parameters - '("McAccount*" "account") - ) ) ;; From empathy-account-widget-sip.h -(define-function account_widget_sip_new +(define-method widget_sip_new + (of-object "EmpathyAccount") (c-name "empathy_account_widget_sip_new") - (is-constructor-of "EmpathyAccountWidgetSip") (return-type "GtkWidget*") - (parameters - '("McAccount*" "account") - ) ) @@ -615,7 +585,7 @@ (define-method get_account (of-object "EmpathyChat") (c-name "empathy_chat_get_account") - (return-type "McAccount*") + (return-type "EmpathyAccount*") ) (define-method get_id @@ -695,6 +665,15 @@ (return-type "gboolean") ) +(define-method set_show_contacts + (of-object "EmpathyChat") + (c-name "empathy_chat_set_show_contacts") + (return-type "none") + (parameters + '("gboolean" "show") + ) +) + ;; From empathy-chat-text-view.h @@ -1521,7 +1500,7 @@ (c-name "empathy_log_window_show") (return-type "GtkWidget*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") '("const-gchar*" "chat_id") '("gboolean" "chatroom") '("GtkWindow*" "parent") @@ -1807,7 +1786,7 @@ (c-name "empathy_icon_name_from_account") (return-type "const-gchar*") (parameters - '("McAccount*" "account") + '("EmpathyAccount*" "account") ) ) diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index 4cf391108..98e848566 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 b8c3d3691..11e237c8f 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 8e317f603..f4315f5fa 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 c46ef8fc4..6f3d21fca 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 a0fb8e6ec..3b5dd1f77 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 a80aad236..1a7ec09cb 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 8e9a04595..1e135892d 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 a3ef3e13c..0e3fd148f 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 804936eae..935c022ea 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 0da037beb..c7816d7fd 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 da90cbb49..e16da91a7 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 a4b01b7c0..f6c63c537 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 85124d1e9..40626b532 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); diff --git a/tests/check-empathy-chatroom-manager.c b/tests/check-empathy-chatroom-manager.c index ef5c77618..1c0f924a2 100644 --- a/tests/check-empathy-chatroom-manager.c +++ b/tests/check-empathy-chatroom-manager.c @@ -13,6 +13,7 @@ #include "check-empathy-helpers.h" #include <libempathy/empathy-chatroom-manager.h> +#include <libempathy/empathy-account-manager.h> #define CHATROOM_SAMPLE "chatrooms-sample.xml" #define CHATROOM_FILE "chatrooms.xml" @@ -43,7 +44,7 @@ struct chatroom_t static void check_chatrooms_list (EmpathyChatroomManager *mgr, - McAccount *account, + EmpathyAccount *account, struct chatroom_t *_chatrooms, guint nb_chatrooms) { @@ -83,13 +84,13 @@ check_chatrooms_list (EmpathyChatroomManager *mgr, } static gboolean -change_account_name_in_file (McAccount *account, +change_account_name_in_file (EmpathyAccount *account, const gchar *file) { gchar *cmd; cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s", - mc_account_get_unique_name (account), file); + empathy_account_get_unique_name (account), file); if (system (cmd) == -1) { @@ -106,11 +107,13 @@ START_TEST (test_empathy_chatroom_manager_dup_singleton) { EmpathyChatroomManager *mgr; gchar *file; - McAccount *account; + EmpathyAccount *account; + EmpathyAccountManager *account_manager; struct chatroom_t chatrooms[] = { { "name1", "room1", TRUE, TRUE }, { "name2", "room2", FALSE, TRUE }}; + account_manager = empathy_account_manager_dup_singleton (); account = get_test_account (); copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE); @@ -126,6 +129,7 @@ START_TEST (test_empathy_chatroom_manager_dup_singleton) g_free (file); g_object_unref (mgr); + g_object_unref (account_manager); g_object_unref (account); } END_TEST @@ -134,7 +138,8 @@ START_TEST (test_empathy_chatroom_manager_add) { EmpathyChatroomManager *mgr; gchar *file; - McAccount *account; + EmpathyAccount *account; + EmpathyAccountManager *account_manager; struct chatroom_t chatrooms[] = { { "name1", "room1", TRUE, TRUE }, { "name2", "room2", FALSE, TRUE }, @@ -142,6 +147,8 @@ START_TEST (test_empathy_chatroom_manager_add) { "name4", "room4", FALSE, FALSE }}; EmpathyChatroom *chatroom; + account_manager = empathy_account_manager_dup_singleton (); + account = get_test_account (); copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE); @@ -149,8 +156,7 @@ START_TEST (test_empathy_chatroom_manager_add) file = get_user_xml_file (CHATROOM_FILE); /* change the chatrooms XML file to use the account we just created */ - if (!change_account_name_in_file (account, file)) - return; + fail_unless (change_account_name_in_file (account, file)); mgr = empathy_chatroom_manager_dup_singleton (file); @@ -186,6 +192,7 @@ START_TEST (test_empathy_chatroom_manager_add) g_object_unref (mgr); g_free (file); + g_object_unref (account_manager); g_object_unref (account); } END_TEST @@ -194,11 +201,13 @@ START_TEST (test_empathy_chatroom_manager_remove) { EmpathyChatroomManager *mgr; gchar *file; - McAccount *account; + EmpathyAccount *account; struct chatroom_t chatrooms[] = { { "name2", "room2", FALSE, TRUE }}; EmpathyChatroom *chatroom; + EmpathyAccountManager *account_mgr; + account_mgr = empathy_account_manager_dup_singleton (); account = get_test_account (); copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE); @@ -206,8 +215,7 @@ START_TEST (test_empathy_chatroom_manager_remove) file = get_user_xml_file (CHATROOM_FILE); /* change the chatrooms XML file to use the account we just created */ - if (!change_account_name_in_file (account, file)) - return; + fail_unless (change_account_name_in_file (account, file)); mgr = empathy_chatroom_manager_dup_singleton (file); @@ -241,6 +249,7 @@ START_TEST (test_empathy_chatroom_manager_remove) g_object_unref (mgr); g_free (file); g_object_unref (account); + g_object_unref (account_mgr); } END_TEST @@ -248,12 +257,14 @@ START_TEST (test_empathy_chatroom_manager_change_favorite) { EmpathyChatroomManager *mgr; gchar *file; - McAccount *account; + EmpathyAccount *account; + EmpathyAccountManager *account_manager; struct chatroom_t chatrooms[] = { { "name1", "room1", TRUE, TRUE }, { "name2", "room2", FALSE, FALSE }}; EmpathyChatroom *chatroom; + account_manager = empathy_account_manager_dup_singleton (); account = get_test_account (); copy_xml_file (CHATROOM_SAMPLE, CHATROOM_FILE); @@ -261,8 +272,7 @@ START_TEST (test_empathy_chatroom_manager_change_favorite) file = get_user_xml_file (CHATROOM_FILE); /* change the chatrooms XML file to use the account we just created */ - if (!change_account_name_in_file (account, file)) - return; + fail_unless (change_account_name_in_file (account, file)); mgr = empathy_chatroom_manager_dup_singleton (file); @@ -302,6 +312,7 @@ START_TEST (test_empathy_chatroom_manager_change_favorite) g_object_unref (mgr); g_object_unref (chatroom); g_free (file); + g_object_unref (account_manager); g_object_unref (account); } END_TEST @@ -310,12 +321,14 @@ START_TEST (test_empathy_chatroom_manager_change_chatroom) { EmpathyChatroomManager *mgr; gchar *file; - McAccount *account; + EmpathyAccount *account; + EmpathyAccountManager *account_manager; struct chatroom_t chatrooms[] = { { "name1", "room1", TRUE, TRUE }, { "name2", "room2", FALSE, TRUE }}; EmpathyChatroom *chatroom; + account_manager = empathy_account_manager_dup_singleton (); account = get_test_account (); copy_xml_file (CHATROOM_SAMPLE, "foo.xml"); @@ -323,8 +336,7 @@ START_TEST (test_empathy_chatroom_manager_change_chatroom) file = get_user_xml_file ("foo.xml"); /* change the chatrooms XML file to use the account we just created */ - if (!change_account_name_in_file (account, file)) - return; + fail_unless (change_account_name_in_file (account, file)); mgr = empathy_chatroom_manager_dup_singleton (file); @@ -369,6 +381,7 @@ START_TEST (test_empathy_chatroom_manager_change_chatroom) g_object_unref (mgr); g_free (file); g_object_unref (account); + g_object_unref (account_manager); } END_TEST diff --git a/tests/check-empathy-chatroom.c b/tests/check-empathy-chatroom.c index a4adf6ce1..f2110a8f8 100644 --- a/tests/check-empathy-chatroom.c +++ b/tests/check-empathy-chatroom.c @@ -12,7 +12,7 @@ static EmpathyChatroom * create_chatroom (void) { - McAccount *account; + EmpathyAccount *account; EmpathyChatroom *chatroom; account = get_test_account (); diff --git a/tests/check-empathy-helpers.c b/tests/check-empathy-helpers.c index 65273f8c8..c77cf9b75 100644 --- a/tests/check-empathy-helpers.c +++ b/tests/check-empathy-helpers.c @@ -24,6 +24,8 @@ #include <gconf/gconf.h> #include <gconf/gconf-client.h> +#include <libempathy/empathy-account-manager.h> + #include "check-helpers.h" #include "check-empathy-helpers.h" @@ -63,25 +65,31 @@ copy_xml_file (const gchar *orig, g_free (buffer); } -McAccount * +EmpathyAccount * get_test_account (void) { McProfile *profile; - McAccount *account; + EmpathyAccountManager *account_manager; + EmpathyAccount *account; GList *accounts; + account_manager = empathy_account_manager_dup_singleton (); profile = mc_profile_lookup ("test"); accounts = mc_accounts_list_by_profile (profile); if (g_list_length (accounts) == 0) { /* need to create a test account */ - account = mc_account_create (profile); + account = empathy_account_manager_create (account_manager, profile); } else { /* reuse an existing test account */ - account = accounts->data; + McAccount *mc_account; + mc_account = accounts->data; + account = empathy_account_manager_lookup (account_manager, + mc_account_get_unique_name (mc_account)); } + g_object_unref (account_manager); g_object_unref (profile); @@ -91,16 +99,17 @@ get_test_account (void) /* Not used for now as there is no API to remove completely gconf keys. * So we reuse existing accounts instead of creating new ones */ void -destroy_test_account (McAccount *account) +destroy_test_account (EmpathyAccount *account) { GConfClient *client; gchar *path; GError *error = NULL; GSList *entries = NULL, *l; + EmpathyAccountManager *manager; client = gconf_client_get_default (); path = g_strdup_printf ("/apps/telepathy/mc/accounts/%s", - mc_account_get_unique_name (account)); + empathy_account_get_unique_name (account)); entries = gconf_client_all_entries (client, path, &error); if (error != NULL) @@ -151,6 +160,8 @@ destroy_test_account (McAccount *account) g_object_unref (client); g_free (path); - mc_account_delete (account); + manager = empathy_account_manager_dup_singleton (); + empathy_account_manager_remove (manager, account); g_object_unref (account); + g_object_unref (manager); } diff --git a/tests/check-empathy-helpers.h b/tests/check-empathy-helpers.h index 4d52c04e5..5544b80aa 100644 --- a/tests/check-empathy-helpers.h +++ b/tests/check-empathy-helpers.h @@ -20,12 +20,12 @@ #define __CHECK_EMPATHY_HELPERS_H__ #include <glib.h> -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> gchar * get_xml_file (const gchar *filename); gchar * get_user_xml_file (const gchar *filename); void copy_xml_file (const gchar *orig, const gchar *dest); -McAccount * get_test_account (void); -void destroy_test_account (McAccount *account); +EmpathyAccount * get_test_account (void); +void destroy_test_account (EmpathyAccount *account); #endif /* #ifndef __CHECK_EMPATHY_HELPERS_H__ */ diff --git a/tests/check-helpers.h b/tests/check-helpers.h index 3e0783811..b71b3b65b 100644 --- a/tests/check-helpers.h +++ b/tests/check-helpers.h @@ -21,7 +21,6 @@ #include <glib.h> #include <check.h> -#include <libmissioncontrol/mc-account.h> void check_helpers_init (void); |