Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / calendar / libedata-cal / e-cal-backend-util.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* Evolution calendar - generic backend class
3  *
4  * Copyright (C) 2000 Ximian, Inc.
5  * Copyright (C) 2001 Ximian, Inc.
6  *
7  * Authors: Rodrigo Moya <rodrigo@ximian.com>    
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of version 2 of the GNU Lesser General Public
11  * License as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22
23 #include <string.h>
24 #include "e-cal-backend-util.h"
25 #include "libedataserver/e-account-list.h"
26
27 static EAccountList *accounts;
28
29 /**
30  * e_cal_backend_mail_account_get_default:
31  * @address: Placeholder for default address.
32  * @name: Placeholder for name.
33  *
34  * Retrieve the default mail account as stored in Evolution configuration.
35  *
36  * Return value: TRUE if there is a default account, FALSE otherwise.
37  */
38 gboolean
39 e_cal_backend_mail_account_get_default (char **address, char **name)
40 {
41         const EAccount *account;
42
43         /* FIXME I think this leaks the gconf client */
44         if (accounts == NULL)
45                 accounts = e_account_list_new(gconf_client_get_default());
46
47         account = e_account_list_get_default(accounts);
48         if (account) {
49                 *address = g_strdup(account->id->address);
50                 *name = g_strdup(account->id->name);
51         }
52
53         return account != NULL;
54 }
55
56 /**
57  * e_cal_backend_mail_account_is_valid:
58  * @user: User name for the account to check.
59  * @name: Placeholder for the account name.
60  *
61  * Checks that a mail account is valid, and returns its name.
62  *
63  * Return value: TRUE if the account is valid, FALSE if not.
64  */
65 gboolean
66 e_cal_backend_mail_account_is_valid (char *user, char **name)
67 {
68         const EAccount *account;
69
70         /* FIXME I think this leaks the gconf client */
71         if (accounts == NULL)
72                 accounts = e_account_list_new(gconf_client_get_default());
73
74         account = e_account_list_find(accounts, E_ACCOUNT_FIND_ID_ADDRESS, user);
75         if (account)
76                 *name = g_strdup(account->id->name);
77
78         return account != NULL;
79 }