Autocrypt database handling. More...
#include "config.h"
#include <sqlite3.h>
#include <stdbool.h>
#include <stddef.h>
#include <sys/stat.h>
#include "private.h"
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "lib.h"
Go to the source code of this file.
Functions | |
static int | autocrypt_db_create (const char *db_path) |
Create an Autocrypt SQLite database. | |
int | mutt_autocrypt_db_init (bool can_create) |
Initialise the Autocrypt SQLite database. | |
void | mutt_autocrypt_db_close (void) |
Close the Autocrypt SQLite database connection. | |
void | mutt_autocrypt_db_normalize_addr (struct Address *a) |
Normalise an Email Address. | |
void | mutt_autocrypt_db_normalize_addrlist (struct AddressList *al) |
Normalise a list of Email Addresses. | |
static struct Address * | copy_normalize_addr (struct Address *addr) |
Copy a normalised Email Address. | |
static char * | strdup_column_text (sqlite3_stmt *stmt, int index) |
Copy a string from the database. | |
struct AutocryptAccount * | mutt_autocrypt_db_account_new (void) |
Create a new AutocryptAccount. | |
void | mutt_autocrypt_db_account_free (struct AutocryptAccount **ptr) |
Free an AutocryptAccount. | |
int | mutt_autocrypt_db_account_get (struct Address *addr, struct AutocryptAccount **account) |
Get Autocrypt Account data from the database. | |
int | mutt_autocrypt_db_account_insert (struct Address *addr, const char *keyid, const char *keydata, bool prefer_encrypt) |
Insert an Account into the Autocrypt database. | |
int | mutt_autocrypt_db_account_update (struct AutocryptAccount *acct) |
Update Account info in the Autocrypt database. | |
int | mutt_autocrypt_db_account_delete (struct AutocryptAccount *acct) |
Delete an Account from the Autocrypt database. | |
int | mutt_autocrypt_db_account_get_all (struct AutocryptAccount ***accounts, int *num_accounts) |
Get all accounts from an Autocrypt database. | |
struct AutocryptPeer * | mutt_autocrypt_db_peer_new (void) |
Create a new AutocryptPeer. | |
void | mutt_autocrypt_db_peer_free (struct AutocryptPeer **ptr) |
Free an AutocryptPeer. | |
int | mutt_autocrypt_db_peer_get (struct Address *addr, struct AutocryptPeer **peer) |
Get peer info from the Autocrypt database. | |
int | mutt_autocrypt_db_peer_insert (struct Address *addr, struct AutocryptPeer *peer) |
Insert a peer into the Autocrypt database. | |
int | mutt_autocrypt_db_peer_update (struct AutocryptPeer *peer) |
Update the peer info in an Autocrypt database. | |
struct AutocryptPeerHistory * | mutt_autocrypt_db_peer_history_new (void) |
Create a new AutocryptPeerHistory. | |
void | mutt_autocrypt_db_peer_history_free (struct AutocryptPeerHistory **ptr) |
Free an AutocryptPeerHistory. | |
int | mutt_autocrypt_db_peer_history_insert (struct Address *addr, struct AutocryptPeerHistory *peerhist) |
Insert peer history into the Autocrypt database. | |
struct AutocryptGossipHistory * | mutt_autocrypt_db_gossip_history_new (void) |
Create a new AutocryptGossipHistory. | |
void | mutt_autocrypt_db_gossip_history_free (struct AutocryptGossipHistory **ptr) |
Free an AutocryptGossipHistory. | |
int | mutt_autocrypt_db_gossip_history_insert (struct Address *addr, struct AutocryptGossipHistory *gossip_hist) |
Insert a gossip history into the Autocrypt database. | |
Variables | |
static sqlite3_stmt * | AccountGetStmt = NULL |
Get the matching autocrypt accounts. | |
static sqlite3_stmt * | AccountInsertStmt = NULL |
Insert a new autocrypt account. | |
static sqlite3_stmt * | AccountUpdateStmt = NULL |
Update an autocrypt account. | |
static sqlite3_stmt * | AccountDeleteStmt = NULL |
Delete an autocrypt account. | |
static sqlite3_stmt * | PeerGetStmt = NULL |
Get the matching peer addresses. | |
static sqlite3_stmt * | PeerInsertStmt = NULL |
Insert a new peer address. | |
static sqlite3_stmt * | PeerUpdateStmt = NULL |
Update a peer address. | |
static sqlite3_stmt * | PeerHistoryInsertStmt = NULL |
Add to the peer history. | |
static sqlite3_stmt * | GossipHistoryInsertStmt = NULL |
Add to the gossip history. | |
sqlite3 * | AutocryptDB = NULL |
Handle to the open Autocrypt database. | |
Autocrypt database handling.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file db.c.
|
static |
Create an Autocrypt SQLite database.
db_path | Path to database file |
0 | Success |
-1 | Error |
Definition at line 64 of file db.c.
int mutt_autocrypt_db_init | ( | bool | can_create | ) |
Initialise the Autocrypt SQLite database.
can_create | If true, the directory may be created |
0 | Success |
-1 | Error |
Definition at line 83 of file db.c.
void mutt_autocrypt_db_close | ( | void | ) |
Close the Autocrypt SQLite database connection.
Definition at line 133 of file db.c.
void mutt_autocrypt_db_normalize_addr | ( | struct Address * | a | ) |
a | Address to normalise |
Definition at line 168 of file db.c.
void mutt_autocrypt_db_normalize_addrlist | ( | struct AddressList * | al | ) |
Normalise a list of Email Addresses.
al | List of Addresses to normalise |
Definition at line 179 of file db.c.
Copy a normalised Email Address.
addr | Address to normalise and copy |
ptr | Copy of the Address |
The autocrypt spec says email addresses should be normalized to lower case and stored in idna form.
In order to avoid visible changes to addresses in the index, we make a copy of the address before lowercasing it.
Definition at line 205 of file db.c.
|
static |
Copy a string from the database.
stmt | SQLite database statement |
index | Database row |
ptr | Copy of string |
Definition at line 228 of file db.c.
struct AutocryptAccount * mutt_autocrypt_db_account_new | ( | void | ) |
Create a new AutocryptAccount.
ptr | New AutocryptAccount |
Definition at line 238 of file db.c.
void mutt_autocrypt_db_account_free | ( | struct AutocryptAccount ** | ptr | ) |
Free an AutocryptAccount.
ptr | Account to free |
Definition at line 247 of file db.c.
int mutt_autocrypt_db_account_get | ( | struct Address * | addr, |
struct AutocryptAccount ** | account | ||
) |
Get Autocrypt Account data from the database.
0 | Success |
-1 | Error |
Definition at line 266 of file db.c.
int mutt_autocrypt_db_account_insert | ( | struct Address * | addr, |
const char * | keyid, | ||
const char * | keydata, | ||
bool | prefer_encrypt | ||
) |
Insert an Account into the Autocrypt database.
addr | Email Address for the account |
keyid | Autocrypt KeyID |
keydata | Autocrypt key data |
prefer_encrypt | Whether the account prefers encryption |
0 | Success |
-1 | Error |
Definition at line 328 of file db.c.
int mutt_autocrypt_db_account_update | ( | struct AutocryptAccount * | acct | ) |
Update Account info in the Autocrypt database.
acct | Autocrypt Account data |
0 | Success |
-1 | Error |
Definition at line 382 of file db.c.
int mutt_autocrypt_db_account_delete | ( | struct AutocryptAccount * | acct | ) |
Delete an Account from the Autocrypt database.
acct | Account to delete |
0 | Success |
-1 | Error |
Definition at line 428 of file db.c.
int mutt_autocrypt_db_account_get_all | ( | struct AutocryptAccount *** | accounts, |
int * | num_accounts | ||
) |
Get all accounts from an Autocrypt database.
[out] | accounts | List of accounts |
[out] | num_accounts | Number of accounts |
0 | Success |
-1 | Error |
Definition at line 463 of file db.c.
struct AutocryptPeer * mutt_autocrypt_db_peer_new | ( | void | ) |
Create a new AutocryptPeer.
ptr | New AutocryptPeer |
Definition at line 528 of file db.c.
void mutt_autocrypt_db_peer_free | ( | struct AutocryptPeer ** | ptr | ) |
Free an AutocryptPeer.
ptr | AutocryptPeer to free |
Definition at line 537 of file db.c.
int mutt_autocrypt_db_peer_get | ( | struct Address * | addr, |
struct AutocryptPeer ** | peer | ||
) |
Get peer info from the Autocrypt database.
0 | Success, no matches |
1 | Success, a match |
-1 | Error |
Definition at line 559 of file db.c.
int mutt_autocrypt_db_peer_insert | ( | struct Address * | addr, |
struct AutocryptPeer * | peer | ||
) |
Insert a peer into the Autocrypt database.
addr | Email Address |
peer | AutocryptPeer to insert |
0 | Success |
-1 | Error |
Definition at line 627 of file db.c.
int mutt_autocrypt_db_peer_update | ( | struct AutocryptPeer * | peer | ) |
Update the peer info in an Autocrypt database.
peer | AutocryptPeer to update |
0 | Success |
-1 | Error |
Definition at line 693 of file db.c.
struct AutocryptPeerHistory * mutt_autocrypt_db_peer_history_new | ( | void | ) |
Create a new AutocryptPeerHistory.
ptr | New AutocryptPeerHistory |
Definition at line 749 of file db.c.
void mutt_autocrypt_db_peer_history_free | ( | struct AutocryptPeerHistory ** | ptr | ) |
Free an AutocryptPeerHistory.
ptr | AutocryptPeerHistory to free |
Definition at line 758 of file db.c.
int mutt_autocrypt_db_peer_history_insert | ( | struct Address * | addr, |
struct AutocryptPeerHistory * | peerhist | ||
) |
Insert peer history into the Autocrypt database.
0 | Success |
-1 | Error |
Definition at line 777 of file db.c.
struct AutocryptGossipHistory * mutt_autocrypt_db_gossip_history_new | ( | void | ) |
Create a new AutocryptGossipHistory.
ptr | New AutocryptGossipHistory |
Definition at line 830 of file db.c.
void mutt_autocrypt_db_gossip_history_free | ( | struct AutocryptGossipHistory ** | ptr | ) |
Free an AutocryptGossipHistory.
ptr | AutocryptGossipHistory to free |
Definition at line 839 of file db.c.
int mutt_autocrypt_db_gossip_history_insert | ( | struct Address * | addr, |
struct AutocryptGossipHistory * | gossip_hist | ||
) |
Insert a gossip history into the Autocrypt database.
0 | Success |
-1 | Error |
Definition at line 859 of file db.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |