]> git.0d.be Git - empathy.git/blob - src/empathy-accounts-common.c
f84f28dba3454e983b2a387e2283d6b8618d520d
[empathy.git] / src / empathy-accounts-common.c
1 /*
2  * Copyright (C) 2005-2007 Imendio AB
3  * Copyright (C) 2007-2010 Collabora Ltd.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA  02110-1301  USA
19  *
20  * Authors: Martyn Russell <martyn@imendio.com>
21  *          Xavier Claessens <xclaesse@gmail.com>
22  *          Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
23  *          Jonathan Tellier <jonathan.tellier@gmail.com>
24  *          Travis Reitter <travis.reitter@collabora.co.uk>
25  */
26
27 #include "config.h"
28
29 #include "empathy-ui-utils.h"
30
31 #include "empathy-accounts-common.h"
32 #include "empathy-accounts-dialog.h"
33
34 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
35 #include "empathy-debug.h"
36
37 gboolean
38 empathy_accounts_has_non_salut_accounts (TpAccountManager *manager)
39 {
40   gboolean ret = FALSE;
41   GList *accounts, *l;
42
43   accounts = tp_account_manager_dup_valid_accounts (manager);
44
45   for (l = accounts ; l != NULL; l = g_list_next (l))
46     {
47       if (tp_strdiff (tp_account_get_protocol_name (l->data), "local-xmpp"))
48         {
49           ret = TRUE;
50           break;
51         }
52     }
53
54   g_list_free_full (accounts, g_object_unref);
55
56   return ret;
57 }
58
59 gboolean
60 empathy_accounts_has_accounts (TpAccountManager *manager)
61 {
62   GList *accounts;
63   gboolean has_accounts;
64
65   accounts = tp_account_manager_dup_valid_accounts (manager);
66   has_accounts = (accounts != NULL);
67   g_list_free_full (accounts, g_object_unref);
68
69   return has_accounts;
70 }
71
72 void
73 empathy_accounts_show_accounts_ui (TpAccountManager *manager,
74     TpAccount *account,
75     GApplication *app)
76 {
77   static GtkWidget *accounts_window = NULL;
78
79   g_return_if_fail (TP_IS_ACCOUNT_MANAGER (manager));
80   g_return_if_fail (!account || TP_IS_ACCOUNT (account));
81
82   if (accounts_window == NULL)
83     {
84       accounts_window = empathy_accounts_dialog_show (NULL, account);
85
86       gtk_application_add_window (GTK_APPLICATION (app),
87           GTK_WINDOW (accounts_window));
88     }
89
90   gtk_window_present (GTK_WINDOW (accounts_window));
91 }