diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2007-05-01 20:18:26 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2007-05-01 20:18:26 +0800 |
commit | 8aaf6865026ead0f21a233a2897a89a7de332f5d (patch) | |
tree | 1eb2237d2e0284e26130361ec8ca68922af6e971 /libempathy | |
parent | b21403fed48c9b95d32a9b8968ac8f47135fd34f (diff) | |
download | gsoc2013-empathy-8aaf6865026ead0f21a233a2897a89a7de332f5d.tar gsoc2013-empathy-8aaf6865026ead0f21a233a2897a89a7de332f5d.tar.gz gsoc2013-empathy-8aaf6865026ead0f21a233a2897a89a7de332f5d.tar.bz2 gsoc2013-empathy-8aaf6865026ead0f21a233a2897a89a7de332f5d.tar.lz gsoc2013-empathy-8aaf6865026ead0f21a233a2897a89a7de332f5d.tar.xz gsoc2013-empathy-8aaf6865026ead0f21a233a2897a89a7de332f5d.tar.zst gsoc2013-empathy-8aaf6865026ead0f21a233a2897a89a7de332f5d.zip |
[darcs-to-svn @ Connect accounts in empathy-launcher, not in empathy-contact-list]
svn path=/trunk/; revision=14
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-contact-list.c | 3 | ||||
-rw-r--r-- | libempathy/empathy-contact-manager.c | 15 | ||||
-rw-r--r-- | libempathy/empathy-session.c | 107 | ||||
-rw-r--r-- | libempathy/empathy-session.h | 2 | ||||
-rw-r--r-- | libempathy/empathy-tp-chat.c | 12 |
5 files changed, 19 insertions, 120 deletions
diff --git a/libempathy/empathy-contact-list.c b/libempathy/empathy-contact-list.c index 02d0c174d..1a8640026 100644 --- a/libempathy/empathy-contact-list.c +++ b/libempathy/empathy-contact-list.c @@ -312,7 +312,7 @@ empathy_contact_list_new (McAccount *account) g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); - mc = empathy_session_get_mission_control (); + mc = mission_control_new (tp_get_bus ()); if (mission_control_get_connection_status (mc, account, NULL) != 0) { /* The account is not connected, nothing to do. */ @@ -320,6 +320,7 @@ empathy_contact_list_new (McAccount *account) } tp_conn = mission_control_get_connection (mc, account, NULL); + g_object_unref (mc); g_return_val_if_fail (tp_conn != NULL, NULL); list = g_object_new (EMPATHY_TYPE_CONTACT_LIST, NULL); diff --git a/libempathy/empathy-contact-manager.c b/libempathy/empathy-contact-manager.c index 4246a03c7..cf5a81fe2 100644 --- a/libempathy/empathy-contact-manager.c +++ b/libempathy/empathy-contact-manager.c @@ -24,6 +24,7 @@ #include <string.h> +#include <libtelepathy/tp-helpers.h> #include <libtelepathy/tp-constants.h> #include "empathy-contact-manager.h" @@ -37,8 +38,9 @@ #define DEBUG_DOMAIN "ContactManager" struct _EmpathyContactManagerPriv { - GHashTable *lists; - gboolean setup; + GHashTable *lists; + MissionControl *mc; + gboolean setup; }; typedef struct { @@ -130,7 +132,6 @@ static void empathy_contact_manager_init (EmpathyContactManager *manager) { EmpathyContactManagerPriv *priv; - MissionControl *mc; GSList *accounts, *l; priv = GET_PRIV (manager); @@ -140,14 +141,15 @@ empathy_contact_manager_init (EmpathyContactManager *manager) (GDestroyNotify) g_object_unref, (GDestroyNotify) g_object_unref); - mc = empathy_session_get_mission_control (); + priv->mc = mission_control_new (tp_get_bus ()); - dbus_g_proxy_connect_signal (DBUS_G_PROXY (mc), "AccountStatusChanged", + dbus_g_proxy_connect_signal (DBUS_G_PROXY (priv->mc), + "AccountStatusChanged", G_CALLBACK (contact_manager_status_changed_cb), manager, NULL); /* Get ContactList for existing connections */ - accounts = mission_control_get_online_connections (mc, NULL); + accounts = mission_control_get_online_connections (priv->mc, NULL); for (l = accounts; l; l = l->next) { McAccount *account; @@ -167,6 +169,7 @@ contact_manager_finalize (GObject *object) priv = GET_PRIV (object); g_hash_table_destroy (priv->lists); + g_object_unref (priv->mc); } EmpathyContactManager * diff --git a/libempathy/empathy-session.c b/libempathy/empathy-session.c index 1a46a9cd2..86ac1e180 100644 --- a/libempathy/empathy-session.c +++ b/libempathy/empathy-session.c @@ -33,70 +33,17 @@ #define DEBUG_DOMAIN "Session" -static void session_start_mission_control (void); -static void session_error_cb (MissionControl *mc, - GError *error, - gpointer data); -static void session_account_enabled_cb (McAccountMonitor *monitor, - gchar *unique_name, - gpointer user_data); -static void session_service_ended_cb (MissionControl *mc, - gpointer user_data); - -static MissionControl *mission_control = NULL; static EmpathyContactManager *contact_manager = NULL; void -empathy_session_connect (void) -{ - MissionControl *mc; - McAccountMonitor *monitor; - static gboolean started = FALSE; - - if (started) { - return; - } - - mc = empathy_session_get_mission_control (); - monitor = mc_account_monitor_new (); - - g_signal_connect (monitor, "account-enabled", - G_CALLBACK (session_account_enabled_cb), - NULL); - g_signal_connect (mc, "ServiceEnded", - G_CALLBACK (session_service_ended_cb), - NULL); - - g_object_unref (monitor); - session_start_mission_control (); - - started = TRUE; -} - -void empathy_session_finalize (void) { - if (mission_control) { - g_object_unref (mission_control); - mission_control = NULL; - } - if (contact_manager) { g_object_unref (contact_manager); contact_manager = NULL; } } -MissionControl * -empathy_session_get_mission_control (void) -{ - if (!mission_control) { - mission_control = mission_control_new (tp_get_bus ()); - } - - return mission_control; -} - EmpathyContactManager * empathy_session_get_contact_manager (void) { @@ -107,57 +54,3 @@ empathy_session_get_contact_manager (void) return contact_manager; } -static void -session_start_mission_control (void) -{ - MissionControl *mc; - McPresence presence; - - mc = empathy_session_get_mission_control (); - presence = mission_control_get_presence_actual (mc, NULL); - - if (presence != MC_PRESENCE_UNSET && - presence != MC_PRESENCE_OFFLINE) { - /* MC is already running and online, nothing to do */ - return; - } - - gossip_debug (DEBUG_DOMAIN, "Starting Mission Control..."); - - /* FIXME: Save/Restore status message */ - mission_control_set_presence (mc, MC_PRESENCE_AVAILABLE, - NULL, - (McCallback) session_error_cb, - NULL); - - mission_control_connect_all_with_default_presence (mc, - (McCallback) session_error_cb, - NULL); -} - -static void -session_error_cb (MissionControl *mc, - GError *error, - gpointer data) -{ - if (error) { - gossip_debug (DEBUG_DOMAIN, "Error: %s", error->message); - } -} - -static void -session_account_enabled_cb (McAccountMonitor *monitor, - gchar *unique_name, - gpointer user_data) -{ - gossip_debug (DEBUG_DOMAIN, "Account enabled: %s", unique_name); - session_start_mission_control (); -} - -static void -session_service_ended_cb (MissionControl *mc, - gpointer user_data) -{ - gossip_debug (DEBUG_DOMAIN, "Mission Control stopped"); -} - diff --git a/libempathy/empathy-session.h b/libempathy/empathy-session.h index 0a08cce6d..af843a5e0 100644 --- a/libempathy/empathy-session.h +++ b/libempathy/empathy-session.h @@ -30,9 +30,7 @@ G_BEGIN_DECLS -void empathy_session_connect (void); void empathy_session_finalize (void); -MissionControl * empathy_session_get_mission_control (void); EmpathyContactManager *empathy_session_get_contact_manager (void); G_END_DECLS diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c index 36ac8a7a8..f72655eca 100644 --- a/libempathy/empathy-tp-chat.c +++ b/libempathy/empathy-tp-chat.c @@ -44,6 +44,7 @@ struct _EmpathyTpChatPriv { EmpathyContactList *list; McAccount *account; gchar *id; + MissionControl *mc; TpChan *tp_chan; DBusGProxy *text_iface; @@ -167,6 +168,9 @@ tp_chat_finalize (GObject *object) if (priv->account) { g_object_unref (priv->account); } + if (priv->mc) { + g_object_unref (priv->mc); + } g_free (priv->id); G_OBJECT_CLASS (empathy_tp_chat_parent_class)->finalize (object); @@ -190,6 +194,7 @@ empathy_tp_chat_new (McAccount *account, priv->list = empathy_contact_manager_get_list (manager, account); priv->tp_chan = g_object_ref (tp_chan); priv->account = g_object_ref (account); + priv->mc = mission_control_new (tp_get_bus ()); g_object_ref (priv->list); priv->text_iface = tp_chan_get_interface (tp_chan, @@ -230,7 +235,7 @@ empathy_tp_chat_new_with_contact (GossipContact *contact) g_return_val_if_fail (GOSSIP_IS_CONTACT (contact), NULL); - mc = empathy_session_get_mission_control (); + mc = mission_control_new (tp_get_bus ()); account = gossip_contact_get_account (contact); if (mission_control_get_connection_status (mc, account, NULL) != 0) { @@ -255,6 +260,7 @@ empathy_tp_chat_new_with_contact (GossipContact *contact) g_object_unref (tp_conn); g_object_unref (text_chan); + g_object_unref (mc); return chat; } @@ -373,7 +379,6 @@ const gchar * empathy_tp_chat_get_id (EmpathyTpChat *chat) { EmpathyTpChatPriv *priv; - MissionControl *mc; TpConn *tp_conn; GArray *handles; gchar **names; @@ -387,8 +392,7 @@ empathy_tp_chat_get_id (EmpathyTpChat *chat) return priv->id; } - mc = empathy_session_get_mission_control (); - tp_conn = mission_control_get_connection (mc, priv->account, NULL); + tp_conn = mission_control_get_connection (priv->mc, priv->account, NULL); handles = g_array_new (FALSE, FALSE, sizeof (guint)); g_array_append_val (handles, priv->tp_chan->handle); |