2 * Copyright (C) 2009-2013 Collabora Ltd.
4 * Authors: Marco Barisione <marco.barisione@collabora.co.uk>
5 * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "tpaw-utils.h"
25 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
26 #include "empathy-debug.h"
28 /* Change the RequestedPresence of a newly created account to ensure that it
29 * is actually connected. */
31 tpaw_connect_new_account (TpAccount *account,
32 TpAccountManager *account_manager)
34 TpConnectionPresenceType presence;
35 gchar *status, *message;
37 /* only force presence if presence was offline, unknown or unset */
38 presence = tp_account_get_requested_presence (account, NULL, NULL);
41 case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
42 case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
43 case TP_CONNECTION_PRESENCE_TYPE_UNSET:
44 presence = tp_account_manager_get_most_available_presence (
45 account_manager, &status, &message);
47 if (presence == TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
48 /* Global presence is offline; we force it so user doesn't have to
49 * manually change the presence to connect his new account. */
50 presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
52 tp_account_request_presence_async (account, presence,
53 status, NULL, NULL, NULL);
59 case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE:
60 case TP_CONNECTION_PRESENCE_TYPE_AWAY:
61 case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY:
62 case TP_CONNECTION_PRESENCE_TYPE_HIDDEN:
63 case TP_CONNECTION_PRESENCE_TYPE_BUSY:
64 case TP_CONNECTION_PRESENCE_TYPE_ERROR:
66 /* do nothing if the presence is not offline */