diff options
author | Marco Barisione <marco.barisione@collabora.co.uk> | 2013-05-06 21:02:09 +0800 |
---|---|---|
committer | Marco Barisione <marco.barisione@collabora.co.uk> | 2013-08-20 18:03:05 +0800 |
commit | 88819ece017f0693803f33bb560e4d01140174c1 (patch) | |
tree | eff64c70d25e3a59d13d74ecbb1099e6b6860890 /tp-account-widgets | |
parent | dc5ad68355fa55261f24098d9be184a2c6f6f459 (diff) | |
download | gsoc2013-empathy-88819ece017f0693803f33bb560e4d01140174c1.tar gsoc2013-empathy-88819ece017f0693803f33bb560e4d01140174c1.tar.gz gsoc2013-empathy-88819ece017f0693803f33bb560e4d01140174c1.tar.bz2 gsoc2013-empathy-88819ece017f0693803f33bb560e4d01140174c1.tar.lz gsoc2013-empathy-88819ece017f0693803f33bb560e4d01140174c1.tar.xz gsoc2013-empathy-88819ece017f0693803f33bb560e4d01140174c1.tar.zst gsoc2013-empathy-88819ece017f0693803f33bb560e4d01140174c1.zip |
tpaw-utils: move empathy_connect_new_account to tp-aw and rename it
This commit also changes the licence of the moved code (all copyrighted
by Collabora Ltd.) from GPL to LGPL.
https://bugzilla.gnome.org/show_bug.cgi?id=699492
Diffstat (limited to 'tp-account-widgets')
-rw-r--r-- | tp-account-widgets/tpaw-account-widget.c | 3 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-utils.c | 46 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-utils.h | 7 |
3 files changed, 53 insertions, 3 deletions
diff --git a/tp-account-widgets/tpaw-account-widget.c b/tp-account-widgets/tpaw-account-widget.c index fcde66f36..e2c8016a6 100644 --- a/tp-account-widgets/tpaw-account-widget.c +++ b/tp-account-widgets/tpaw-account-widget.c @@ -29,6 +29,7 @@ #include <glib/gi18n-lib.h> #include <dbus/dbus-protocol.h> +#include <tp-account-widgets/tpaw-utils.h> #include "tpaw-account-widget-irc.h" #include "tpaw-account-widget-private.h" @@ -895,7 +896,7 @@ account_widget_account_enabled_cb (GObject *source_object, } else { - empathy_connect_new_account (account, self->priv->account_manager); + tpaw_connect_new_account (account, self->priv->account_manager); } g_signal_emit (self, signals[CLOSE], 0, GTK_RESPONSE_APPLY); diff --git a/tp-account-widgets/tpaw-utils.c b/tp-account-widgets/tpaw-utils.c index d8bebdac0..8570658c3 100644 --- a/tp-account-widgets/tpaw-utils.c +++ b/tp-account-widgets/tpaw-utils.c @@ -1,7 +1,8 @@ /* - * Copyright (C) 2013 Collabora Ltd. + * Copyright (C) 2009-2013 Collabora Ltd. * * Authors: Marco Barisione <marco.barisione@collabora.co.uk> + * Guillaume Desmottes <guillaume.desmottes@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 @@ -23,3 +24,46 @@ #define DEBUG_FLAG EMPATHY_DEBUG_OTHER #include "empathy-debug.h" + +/* Change the RequestedPresence of a newly created account to ensure that it + * is actually connected. */ +void +tpaw_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; + + case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE: + case TP_CONNECTION_PRESENCE_TYPE_AWAY: + case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY: + case TP_CONNECTION_PRESENCE_TYPE_HIDDEN: + case TP_CONNECTION_PRESENCE_TYPE_BUSY: + case TP_CONNECTION_PRESENCE_TYPE_ERROR: + default: + /* do nothing if the presence is not offline */ + break; + } +} diff --git a/tp-account-widgets/tpaw-utils.h b/tp-account-widgets/tpaw-utils.h index 8c5dc8cb1..55d83d506 100644 --- a/tp-account-widgets/tpaw-utils.h +++ b/tp-account-widgets/tpaw-utils.h @@ -1,7 +1,8 @@ /* - * Copyright (C) 2013 Collabora Ltd. + * Copyright (C) 2009-2013 Collabora Ltd. * * Authors: Marco Barisione <marco.barisione@collabora.co.uk> + * Guillaume Desmottes <guillaume.desmottes@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 @@ -22,9 +23,13 @@ #define __TPAW_UTILS_H__ #include <glib.h> +#include <telepathy-glib/telepathy-glib.h> G_BEGIN_DECLS +void tpaw_connect_new_account (TpAccount *account, + TpAccountManager *account_manager); + G_END_DECLS #endif /* __TPAW_UTILS_H__ */ |