1 /**
2 * @file
3 * Pop-specific Account data
4 *
5 * @authors
6 * Copyright (C) 2021 Richard Russon <rich@flatcap.org>
7 *
8 * @copyright
9 * This program is free software: you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 2 of the License, or (at your option) any later
12 * version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 /**
24 * @page pop_adata Pop-specific Account data
25 *
26 * Pop-specific Account data
27 */
28
29 #include "config.h"
30 #include "core/lib.h"
31 #include "adata.h"
32
33 /**
34 * pop_adata_free - Free the private Account data - Implements Account::adata_free()
35 *
36 * The PopAccountData struct stores global POP data, such as the connection to
37 * the database. This function will close the database, free the resources and
38 * the struct itself.
39 */
pop_adata_free(void ** ptr)40 void pop_adata_free(void **ptr)
41 {
42 if (!ptr || !*ptr)
43 return;
44
45 struct PopAccountData *adata = *ptr;
46 FREE(&adata->auth_list.data);
47 FREE(ptr);
48 }
49
50 /**
51 * pop_adata_new - Create a new PopAccountData object
52 * @retval ptr New PopAccountData struct
53 */
pop_adata_new(void)54 struct PopAccountData *pop_adata_new(void)
55 {
56 return mutt_mem_calloc(1, sizeof(struct PopAccountData));
57 }
58
59 /**
60 * pop_adata_get - Get the Account data for this mailbox
61 * @param m Mailbox
62 * @retval ptr PopAccountData
63 */
pop_adata_get(struct Mailbox * m)64 struct PopAccountData *pop_adata_get(struct Mailbox *m)
65 {
66 if (!m || (m->type != MUTT_POP))
67 return NULL;
68 struct Account *a = m->account;
69 if (!a)
70 return NULL;
71 return a->adata;
72 }
73