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 /* 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
);
66 gboolean
passwd_store_delete_block(PasswordBlockType block_type
,
67 const gchar
*block_name
);
69 /* Reencrypts all stored passwords using new_mpwd as an encryption
71 void passwd_store_reencrypt_all(const gchar
*old_mpwd
,
72 const gchar
*new_mpwd
);
74 /* Writes/reads password store to/from file. */
75 void passwd_store_write_config(void);
76 int passwd_store_read_config(void);
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
,
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
);
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 #define PWS_ACCOUNT_OAUTH2_AUTH "oauth2_auth"
97 #define PWS_ACCOUNT_OAUTH2_REFRESH "oauth2_refresh"
98 #define PWS_ACCOUNT_OAUTH2_EXPIRY "oauth2_access_expiry"
99 #define PWS_CORE_PROXY "proxy"
100 #define PWS_CORE_PROXY_PASS "proxy_pass"
102 #endif /* __PASSWORDSTORE_H */