/* * Copyright (C) 2009-2013 Collabora Ltd. * * Authors: Marco Barisione * Guillaume Desmottes * * 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 "config.h" #include "tpaw-utils.h" #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; } }