[empathy] factor out empathy_connect_new_account
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] factor out empathy_connect_new_account
- Date: Tue, 2 Mar 2010 15:37:55 +0000 (UTC)
commit b7329ee88d54447ed5b8a0de32a6b26a25ef5024
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Tue Mar 2 10:25:46 2010 +0100
factor out empathy_connect_new_account
libempathy-gtk/empathy-account-widget.c | 28 +----------------------
libempathy/empathy-utils.c | 37 +++++++++++++++++++++++++++++++
libempathy/empathy-utils.h | 4 +++
3 files changed, 42 insertions(+), 27 deletions(-)
---
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index a7b272c..8ce6b5f 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -668,9 +668,6 @@ account_widget_account_enabled_cb (GObject *source_object,
TpAccount *account = TP_ACCOUNT (source_object);
EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
- TpConnectionPresenceType presence;
- gchar *message = NULL;
- gchar *status = NULL;
tp_account_set_enabled_finish (account, res, &error);
@@ -681,34 +678,11 @@ account_widget_account_enabled_cb (GObject *source_object,
}
else
{
- /* only force presence if presence was offline, unknown or unset */
- presence = tp_account_get_requested_presence (account, NULL, NULL);
- switch (presence)
- {
- case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
- case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
- case TP_CONNECTION_PRESENCE_TYPE_UNSET:
- presence = tp_account_manager_get_most_available_presence (
- priv->account_manager, &status, &message);
-
- if (presence == TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
- /* Global presence is offline; we force it so user doesn't have to
- * manually change the presence to connect his new account. */
- presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
-
- tp_account_request_presence_async (account, presence,
- status, NULL, NULL, NULL);
- break;
- default:
- /* do nothing if the presence is not offline */
- break;
- }
+ empathy_connect_new_account (account, priv->account_manager);
}
/* unref widget - part of the workaround */
g_object_unref (widget);
- g_free (message);
- g_free (status);
}
static void
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index fedb14b..7d169ff 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -606,3 +606,40 @@ empathy_account_manager_get_accounts_connected (gboolean *connecting)
return out_connected;
}
+
+/* Change the RequestedPresence of a newly created account to ensure that it
+ * is actually connected. */
+void
+empathy_connect_new_account (TpAccount *account,
+ TpAccountManager *account_manager)
+{
+ TpConnectionPresenceType presence;
+ gchar *status, *message;
+
+ /* only force presence if presence was offline, unknown or unset */
+ presence = tp_account_get_requested_presence (account, NULL, NULL);
+ switch (presence)
+ {
+ case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
+ case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
+ case TP_CONNECTION_PRESENCE_TYPE_UNSET:
+ presence = tp_account_manager_get_most_available_presence (
+ account_manager, &status, &message);
+
+ if (presence == TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
+ /* Global presence is offline; we force it so user doesn't have to
+ * manually change the presence to connect his new account. */
+ presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
+
+ tp_account_request_presence_async (account, presence,
+ status, NULL, NULL, NULL);
+
+ g_free (status);
+ g_free (message);
+ break;
+
+ default:
+ /* do nothing if the presence is not offline */
+ break;
+ }
+}
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index 0fc6fc2..0ab9052 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -31,6 +31,7 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
+#include <telepathy-glib/account-manager.h>
#include "empathy-contact.h"
@@ -90,6 +91,9 @@ TpAccount * empathy_get_account_for_connection (TpConnection *connection);
gboolean empathy_account_manager_get_accounts_connected (gboolean *connecting);
+void empathy_connect_new_account (TpAccount *account,
+ TpAccountManager *account_manager);
+
G_END_DECLS
#endif /* __EMPATHY_UTILS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]