2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2016 Claws Mail team
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.
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.
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/>.
20 #ifndef __PASSWORDSTORE_H
21 #define __PASSWORDSTORE_H
32 typedef struct _PasswordBlock
{
33 PasswordBlockType block_type
;
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)
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
,
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
);
60 gboolean
passwd_store_delete_block(PasswordBlockType block_type
,
61 const gchar
*block_name
);
63 /* Reencrypts all stored passwords using new_mpwd as an encryption
65 void passwd_store_reencrypt_all(const gchar
*old_mpwd
,
66 const gchar
*new_mpwd
);
68 /* Writes/reads password store to/from file. */
69 void passwd_store_write_config(void);
70 void passwd_store_read_config(void);
72 /* Convenience wrappers for handling account passwords.
73 * (This is to save some boilerplate code converting account_id to
74 * a string and freeing the string afterwards.) */
75 gboolean
passwd_store_set_account(gint account_id
,
76 const gchar
*password_id
,
77 const gchar
*password
,
79 gchar
*passwd_store_get_account(gint account_id
, const gchar
*block_name
);
81 /* Macros for standard, predefined password IDs. */
82 #define PWS_ACCOUNT_RECV "recv"
83 #define PWS_ACCOUNT_SEND "send"
84 #define PWS_ACCOUNT_RECV_CERT "recv_cert"
85 #define PWS_ACCOUNT_SEND_CERT "send_cert"
87 #endif /* __PASSWORDSTORE_H */