1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include "dbsqlitewx.h"
#include "dbsqlitewxinstance.h"
#include <QMap>
DbSqliteWx::DbSqliteWx()
{
}
QString DbSqliteWx::getLabel() const
{
return "WxSQLite3";
}
QList<DbPluginOption> DbSqliteWx::getOptionsList() const
{
static const QMap<QString, QVariant> ciphers = {
{"wxSQLite3: AES 128 Bit", "aes128cbc"},
{"wxSQLite3: AES 256 Bit", "aes256cbc"},
{"sqleet: ChaCha20-Poly1305", "chacha20"},
{"SQLCipher: AES 256 Bit", "sqlcipher"},
{"System.Data.SQLite: RC4", "rc4"}
};
static_qstring(defaultCipher, "aes256cbc");
QList<DbPluginOption> opts;
DbPluginOption optPass;
optPass.type = DbPluginOption::PASSWORD;
optPass.key = PASSWORD_OPT;
optPass.label = tr("Password (key)");
optPass.toolTip = tr("Leave empty to create or connect to decrypted database.");
optPass.placeholderText = tr("Encryption password");
opts << optPass;
DbPluginOption optCipher;
optCipher.type = DbPluginOption::CHOICE;
optCipher.key = CIPHER_OPT;
optCipher.label = tr("Cipher");
optCipher.toolTip = tr("Cipher determines encryption algorithm used to encrypt the database.");
optCipher.choiceDataValues = ciphers;
optCipher.defaultValue = defaultCipher;
opts << optCipher;
DbPluginOption optPragmas;
optPragmas.type = DbPluginOption::SQL;
optPragmas.key = PRAGMAS_OPT;
optPragmas.label = tr("Cipher configuration (optional)");
optPragmas.toolTip = tr("PRAGMA statements to customize SQLite3 Multiple Ciphers configuration, such as KDF iterations, legacy mode, etc.\n"
"They will be executed upon each opening of the database.\n"
"See documentation for SQLite3 Multiple Ciphers for details.");
opts << optPragmas;
return opts;
}
bool DbSqliteWx::checkIfDbServedByPlugin(Db *db) const
{
return (db && dynamic_cast<DbSqliteWxInstance*>(db));
}
Db *DbSqliteWx::newInstance(const QString &name, const QString &path, const QHash<QString, QVariant> &options)
{
return new DbSqliteWxInstance(name, path, options);
}
|