add option to avoid Face images being saved to addrbook
[claws.git] / src / passwordstore.h
1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 2016 Claws Mail team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (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
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19
20 #ifndef __PASSWORDSTORE_H
21 #define __PASSWORDSTORE_H
22
23 #include <glib.h>
24
25 typedef enum {
26         PWS_CORE,
27         PWS_ACCOUNT,
28         PWS_PLUGIN,
29         NUM_PWS_TYPES
30 } PasswordBlockType;
31
32 typedef struct _PasswordBlock {
33         PasswordBlockType block_type;
34         gchar *block_name;
35         GHashTable *entries;
36 } PasswordBlock;
37
38 /* Saves a password into a chosen password block.
39  * The block is created if it doesn't exist.
40  * block_type - from PasswordBlockType
41  * block_name - name of the block
42  * password_id - ID of the saved password
43  * password - the actual password string
44  * encrypted - TRUE if the password string is in an already encrypted form
45  *             (useful mostly for migration from accountrc)
46  *
47  * Function will make a copy of the strings where necessary and doesn't
48  * take ownership of any of the passed arguments. */
49 gboolean passwd_store_set(PasswordBlockType block_type,
50                 const gchar *block_name,
51                 const gchar *password_id,
52                 const gchar *password,
53                 gboolean encrypted);
54
55 /* Retrieves a password. Returned string should be freed by the caller. */
56 gchar *passwd_store_get(PasswordBlockType block_type,
57                 const gchar *block_name,
58                 const gchar *password_id);
59
60 /* Returns TRUE if such password exists in the password store,
61  * false otherwise. No decryption happens. */
62 gboolean passwd_store_has_password(PasswordBlockType block_type,
63                 const gchar *block_name,
64                 const gchar *password_id);
65
66 gboolean passwd_store_delete_block(PasswordBlockType block_type,
67                 const gchar *block_name);
68
69 /* Reencrypts all stored passwords using new_mpwd as an encryption
70  * password. */
71 void passwd_store_reencrypt_all(const gchar *old_mpwd,
72                 const gchar *new_mpwd);
73
74 /* Writes/reads password store to/from file. */
75 void passwd_store_write_config(void);
76 int passwd_store_read_config(void);
77
78 /* Convenience wrappers for handling account passwords.
79  * (This is to save some boilerplate code converting account_id to
80  * a string and freeing the string afterwards.) */
81 gboolean passwd_store_set_account(gint account_id,
82                 const gchar *password_id,
83                 const gchar *password,
84                 gboolean encrypted);
85 gchar *passwd_store_get_account(gint account_id,
86                 const gchar *password_id);
87 gboolean passwd_store_has_password_account(gint account_id,
88                 const gchar *password_id);
89
90 /* Macros for standard, predefined password IDs. */
91 #define PWS_ACCOUNT_RECV      "recv"
92 #define PWS_ACCOUNT_SEND      "send"
93 #define PWS_ACCOUNT_RECV_CERT "recv_cert"
94 #define PWS_ACCOUNT_SEND_CERT "send_cert"
95 #define PWS_ACCOUNT_PROXY_PASS "proxy_pass"
96
97 #define PWS_CORE_PROXY "proxy"
98 #define PWS_CORE_PROXY_PASS "proxy_pass"
99
100 #endif /* __PASSWORDSTORE_H */