]> git.0d.be Git - empathy.git/blob - src/empathy-accounts-common.c
include telepathy-glib.h
[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 <string.h>
30 #include <stdlib.h>
31
32 #include <gtk/gtk.h>
33 #include <glib/gi18n-lib.h>
34
35 #include <telepathy-glib/telepathy-glib.h>
36
37 #include <libempathy/empathy-utils.h>
38 #include <libempathy/empathy-connection-managers.h>
39 #include <libempathy-gtk/empathy-ui-utils.h>
40
41 #include "empathy-accounts-common.h"
42 #include "empathy-accounts-dialog.h"
43
44 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
45 #include <libempathy/empathy-debug.h>
46
47 gboolean
48 empathy_accounts_has_non_salut_accounts (TpAccountManager *manager)
49 {
50   gboolean ret = FALSE;
51   GList *accounts, *l;
52
53   accounts = tp_account_manager_dup_valid_accounts (manager);
54
55   for (l = accounts ; l != NULL; l = g_list_next (l))
56     {
57       if (tp_strdiff (tp_account_get_protocol_name (l->data), "local-xmpp"))
58         {
59           ret = TRUE;
60           break;
61         }
62     }
63
64   g_list_free_full (accounts, g_object_unref);
65
66   return ret;
67 }
68
69 gboolean
70 empathy_accounts_has_accounts (TpAccountManager *manager)
71 {
72   GList *accounts;
73   gboolean has_accounts;
74
75   accounts = tp_account_manager_dup_valid_accounts (manager);
76   has_accounts = (accounts != NULL);
77   g_list_free_full (accounts, g_object_unref);
78
79   return has_accounts;
80 }
81
82 void
83 empathy_accounts_show_accounts_ui (TpAccountManager *manager,
84     TpAccount *account,
85     GApplication *app)
86 {
87   static GtkWidget *accounts_window = NULL;
88
89   g_return_if_fail (TP_IS_ACCOUNT_MANAGER (manager));
90   g_return_if_fail (!account || TP_IS_ACCOUNT (account));
91
92   if (accounts_window == NULL)
93     {
94       accounts_window = empathy_accounts_dialog_show (NULL, account);
95
96       gtk_application_add_window (GTK_APPLICATION (app),
97           GTK_WINDOW (accounts_window));
98     }
99
100   gtk_window_present (GTK_WINDOW (accounts_window));
101 }