mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Performed project-wide code formatting
* Updated format CMake command to properly ignore new directories and files * Added output when command is run * Resolves #2623
This commit is contained in:
parent
c74664097b
commit
7e1b16250c
@ -15,10 +15,11 @@
|
||||
|
||||
set(EXCLUDED_DIRS
|
||||
# third-party directories
|
||||
zxcvbn/
|
||||
streams/QtIOCompressor
|
||||
src/zxcvbn/
|
||||
# objective-c directories
|
||||
autotype/mac)
|
||||
src/touchid/
|
||||
src/autotype/mac/
|
||||
src/gui/macutils/)
|
||||
|
||||
set(EXCLUDED_FILES
|
||||
# third-party files
|
||||
@ -37,7 +38,7 @@ set(EXCLUDED_FILES
|
||||
core/ScreenLockListenerMac.h
|
||||
core/ScreenLockListenerMac.cpp)
|
||||
|
||||
file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h)
|
||||
file(GLOB_RECURSE ALL_SOURCE_FILES RELATIVE ${CMAKE_SOURCE_DIR} src/*.cpp src/*.h tests/*.cpp tests/*.h)
|
||||
foreach(SOURCE_FILE ${ALL_SOURCE_FILES})
|
||||
foreach(EXCLUDED_DIR ${EXCLUDED_DIRS})
|
||||
string(FIND ${SOURCE_FILE} ${EXCLUDED_DIR} SOURCE_FILE_EXCLUDED)
|
||||
@ -52,7 +53,12 @@ foreach(SOURCE_FILE ${ALL_SOURCE_FILES})
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
add_custom_target(
|
||||
format
|
||||
COMMAND echo ${ALL_SOURCE_FILES} | xargs clang-format -style=file -i
|
||||
)
|
||||
add_custom_target(format)
|
||||
foreach(SOURCE_FILE ${ALL_SOURCE_FILES})
|
||||
add_custom_command(
|
||||
TARGET format
|
||||
PRE_BUILD
|
||||
COMMAND echo Formatting ${SOURCE_FILE}
|
||||
COMMAND clang-format -style=file -i \"${SOURCE_FILE}\"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
endforeach()
|
||||
|
@ -77,7 +77,8 @@ bool BrowserService::isDatabaseOpened() const
|
||||
return false;
|
||||
}
|
||||
|
||||
return dbWidget->currentMode() == DatabaseWidget::Mode::ViewMode || dbWidget->currentMode() == DatabaseWidget::Mode::EditMode;
|
||||
return dbWidget->currentMode() == DatabaseWidget::Mode::ViewMode
|
||||
|| dbWidget->currentMode() == DatabaseWidget::Mode::EditMode;
|
||||
}
|
||||
|
||||
bool BrowserService::openDatabase(bool triggerUnlock)
|
||||
@ -91,7 +92,8 @@ bool BrowserService::openDatabase(bool triggerUnlock)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dbWidget->currentMode() == DatabaseWidget::Mode::ViewMode || dbWidget->currentMode() == DatabaseWidget::Mode::EditMode) {
|
||||
if (dbWidget->currentMode() == DatabaseWidget::Mode::ViewMode
|
||||
|| dbWidget->currentMode() == DatabaseWidget::Mode::EditMode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -114,7 +116,8 @@ void BrowserService::lockDatabase()
|
||||
return;
|
||||
}
|
||||
|
||||
if (dbWidget->currentMode() == DatabaseWidget::Mode::ViewMode || dbWidget->currentMode() == DatabaseWidget::Mode::EditMode) {
|
||||
if (dbWidget->currentMode() == DatabaseWidget::Mode::ViewMode
|
||||
|| dbWidget->currentMode() == DatabaseWidget::Mode::EditMode) {
|
||||
dbWidget->lock();
|
||||
}
|
||||
}
|
||||
@ -289,9 +292,12 @@ QJsonArray BrowserService::findMatchingEntries(const QString& id,
|
||||
return result;
|
||||
}
|
||||
|
||||
void BrowserService::addEntry(const QString& id, const QString& login,
|
||||
const QString& password, const QString& url,
|
||||
const QString& submitUrl, const QString& realm,
|
||||
void BrowserService::addEntry(const QString& id,
|
||||
const QString& login,
|
||||
const QString& password,
|
||||
const QString& url,
|
||||
const QString& submitUrl,
|
||||
const QString& realm,
|
||||
QSharedPointer<Database> selectedDb)
|
||||
{
|
||||
if (thread() != QThread::currentThread()) {
|
||||
@ -392,12 +398,13 @@ void BrowserService::updateEntry(const QString& id,
|
||||
MessageBox::Button dialogResult = MessageBox::No;
|
||||
if (!browserSettings()->alwaysAllowUpdate()) {
|
||||
raiseWindow();
|
||||
dialogResult = MessageBox::question(nullptr,
|
||||
tr("KeePassXC: Update Entry"),
|
||||
tr("Do you want to update the information in %1 - %2?")
|
||||
.arg(QUrl(url).host(), username),
|
||||
MessageBox::Save | MessageBox::Cancel,
|
||||
MessageBox::Cancel, MessageBox::Raise);
|
||||
dialogResult = MessageBox::question(
|
||||
nullptr,
|
||||
tr("KeePassXC: Update Entry"),
|
||||
tr("Do you want to update the information in %1 - %2?").arg(QUrl(url).host(), username),
|
||||
MessageBox::Save | MessageBox::Cancel,
|
||||
MessageBox::Cancel,
|
||||
MessageBox::Raise);
|
||||
}
|
||||
|
||||
if (browserSettings()->alwaysAllowUpdate() || dialogResult == MessageBox::Save) {
|
||||
@ -453,7 +460,7 @@ QList<Entry*> BrowserService::searchEntries(const QString& url, const StringPair
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (auto* dbWidget = qobject_cast<DatabaseWidget*>(m_dbTabWidget->widget(i))) {
|
||||
if (const auto& db = dbWidget->database()) {
|
||||
// Check if database is connected with KeePassXC-Browser
|
||||
// Check if database is connected with KeePassXC-Browser
|
||||
for (const StringPair& keyPair : keyList) {
|
||||
QString key =
|
||||
db->metadata()->customData()->value(QLatin1String(ASSOCIATE_KEY_PREFIX) + keyPair.first);
|
||||
@ -680,10 +687,7 @@ QJsonObject BrowserService::prepareEntry(const Entry* entry)
|
||||
}
|
||||
|
||||
BrowserService::Access
|
||||
BrowserService::checkAccess(const Entry* entry,
|
||||
const QString& host,
|
||||
const QString& submitHost,
|
||||
const QString& realm)
|
||||
BrowserService::checkAccess(const Entry* entry, const QString& host, const QString& submitHost, const QString& realm)
|
||||
{
|
||||
BrowserEntryConfig config;
|
||||
if (!config.load(entry)) {
|
||||
@ -841,12 +845,12 @@ QSharedPointer<Database> BrowserService::getDatabase()
|
||||
QSharedPointer<Database> BrowserService::selectedDatabase()
|
||||
{
|
||||
QList<DatabaseWidget*> databaseWidgets;
|
||||
for (int i = 0; ; ++i) {
|
||||
for (int i = 0;; ++i) {
|
||||
auto* dbWidget = m_dbTabWidget->databaseWidgetFromIndex(i);
|
||||
// Add only open databases
|
||||
if (dbWidget && dbWidget->database()->hasKey() &&
|
||||
(dbWidget->currentMode() == DatabaseWidget::Mode::ViewMode ||
|
||||
dbWidget->currentMode() == DatabaseWidget::Mode::EditMode)) {
|
||||
if (dbWidget && dbWidget->database()->hasKey()
|
||||
&& (dbWidget->currentMode() == DatabaseWidget::Mode::ViewMode
|
||||
|| dbWidget->currentMode() == DatabaseWidget::Mode::EditMode)) {
|
||||
databaseWidgets.push_back(dbWidget);
|
||||
continue;
|
||||
}
|
||||
@ -919,8 +923,8 @@ bool BrowserService::checkLegacySettings()
|
||||
bool legacySettingsFound = false;
|
||||
QList<Entry*> entries = db->rootGroup()->entriesRecursive();
|
||||
for (const auto& e : entries) {
|
||||
if ((e->attributes()->contains(KEEPASSHTTP_NAME) || e->attributes()->contains(KEEPASSXCBROWSER_NAME)) ||
|
||||
(e->title() == KEEPASSHTTP_NAME || e->title().contains(KEEPASSXCBROWSER_NAME, Qt::CaseInsensitive))) {
|
||||
if ((e->attributes()->contains(KEEPASSHTTP_NAME) || e->attributes()->contains(KEEPASSXCBROWSER_NAME))
|
||||
|| (e->title() == KEEPASSHTTP_NAME || e->title().contains(KEEPASSXCBROWSER_NAME, Qt::CaseInsensitive))) {
|
||||
legacySettingsFound = true;
|
||||
break;
|
||||
}
|
||||
|
@ -102,10 +102,7 @@ private:
|
||||
const QString& submitHost,
|
||||
const QString& realm);
|
||||
QJsonObject prepareEntry(const Entry* entry);
|
||||
Access checkAccess(const Entry* entry,
|
||||
const QString& host,
|
||||
const QString& submitHost,
|
||||
const QString& realm);
|
||||
Access checkAccess(const Entry* entry, const QString& host, const QString& submitHost, const QString& realm);
|
||||
Group* findCreateAddEntryGroup(QSharedPointer<Database> selectedDb = {});
|
||||
int
|
||||
sortPriority(const Entry* entry, const QString& host, const QString& submitUrl, const QString& baseSubmitUrl) const;
|
||||
|
@ -41,11 +41,10 @@ const QCommandLineOption Command::QuietOption =
|
||||
<< "quiet",
|
||||
QObject::tr("Silence password prompt and other secondary outputs."));
|
||||
|
||||
const QCommandLineOption Command::KeyFileOption =
|
||||
QCommandLineOption(QStringList() << "k"
|
||||
<< "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
const QCommandLineOption Command::KeyFileOption = QCommandLineOption(QStringList() << "k"
|
||||
<< "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
|
||||
QMap<QString, Command*> commands;
|
||||
|
||||
|
@ -88,7 +88,7 @@ int Create::execute(const QStringList& arguments)
|
||||
}
|
||||
|
||||
QSharedPointer<FileKey> fileKey;
|
||||
if(parser.isSet(Command::KeyFileOption)) {
|
||||
if (parser.isSet(Command::KeyFileOption)) {
|
||||
if (!loadFileKey(parser.value(Command::KeyFileOption), fileKey)) {
|
||||
err << QObject::tr("Loading the key file failed") << endl;
|
||||
return EXIT_FAILURE;
|
||||
|
@ -83,9 +83,9 @@ int Extract::execute(const QStringList& arguments)
|
||||
|
||||
if (fileKey->type() != FileKey::Hashed) {
|
||||
errorTextStream << QObject::tr("WARNING: You are using a legacy key file format which may become\n"
|
||||
"unsupported in the future.\n\n"
|
||||
"Please consider generating a new key file.")
|
||||
<< endl;
|
||||
"unsupported in the future.\n\n"
|
||||
"Please consider generating a new key file.")
|
||||
<< endl;
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
|
@ -47,14 +47,13 @@ namespace Utils
|
||||
* DEVNULL file handle for the CLI.
|
||||
*/
|
||||
#ifdef Q_OS_WIN
|
||||
FILE* DEVNULL = fopen("nul", "w");
|
||||
FILE* DEVNULL = fopen("nul", "w");
|
||||
#else
|
||||
FILE* DEVNULL = fopen("/dev/null", "w");
|
||||
FILE* DEVNULL = fopen("/dev/null", "w");
|
||||
#endif
|
||||
|
||||
|
||||
void setStdinEcho(bool enable = true)
|
||||
{
|
||||
void setStdinEcho(bool enable = true)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||
DWORD mode;
|
||||
@ -98,61 +97,61 @@ void setStdinEcho(bool enable = true)
|
||||
}
|
||||
} // namespace Test
|
||||
|
||||
QSharedPointer<Database> unlockDatabase(const QString& databaseFilename,
|
||||
const QString& keyFilename,
|
||||
FILE* outputDescriptor,
|
||||
FILE* errorDescriptor)
|
||||
{
|
||||
auto compositeKey = QSharedPointer<CompositeKey>::create();
|
||||
TextStream out(outputDescriptor);
|
||||
TextStream err(errorDescriptor);
|
||||
QSharedPointer<Database> unlockDatabase(const QString& databaseFilename,
|
||||
const QString& keyFilename,
|
||||
FILE* outputDescriptor,
|
||||
FILE* errorDescriptor)
|
||||
{
|
||||
auto compositeKey = QSharedPointer<CompositeKey>::create();
|
||||
TextStream out(outputDescriptor);
|
||||
TextStream err(errorDescriptor);
|
||||
|
||||
out << QObject::tr("Insert password to unlock %1: ").arg(databaseFilename) << flush;
|
||||
out << QObject::tr("Insert password to unlock %1: ").arg(databaseFilename) << flush;
|
||||
|
||||
QString line = Utils::getPassword(outputDescriptor);
|
||||
auto passwordKey = QSharedPointer<PasswordKey>::create();
|
||||
passwordKey->setPassword(line);
|
||||
compositeKey->addKey(passwordKey);
|
||||
QString line = Utils::getPassword(outputDescriptor);
|
||||
auto passwordKey = QSharedPointer<PasswordKey>::create();
|
||||
passwordKey->setPassword(line);
|
||||
compositeKey->addKey(passwordKey);
|
||||
|
||||
if (!keyFilename.isEmpty()) {
|
||||
auto fileKey = QSharedPointer<FileKey>::create();
|
||||
QString errorMessage;
|
||||
// LCOV_EXCL_START
|
||||
if (!fileKey->load(keyFilename, &errorMessage)) {
|
||||
err << QObject::tr("Failed to load key file %1: %2").arg(keyFilename, errorMessage) << endl;
|
||||
return {};
|
||||
if (!keyFilename.isEmpty()) {
|
||||
auto fileKey = QSharedPointer<FileKey>::create();
|
||||
QString errorMessage;
|
||||
// LCOV_EXCL_START
|
||||
if (!fileKey->load(keyFilename, &errorMessage)) {
|
||||
err << QObject::tr("Failed to load key file %1: %2").arg(keyFilename, errorMessage) << endl;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (fileKey->type() != FileKey::Hashed) {
|
||||
err << QObject::tr("WARNING: You are using a legacy key file format which may become\n"
|
||||
"unsupported in the future.\n\n"
|
||||
"Please consider generating a new key file.")
|
||||
<< endl;
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
compositeKey->addKey(fileKey);
|
||||
}
|
||||
|
||||
if (fileKey->type() != FileKey::Hashed) {
|
||||
err << QObject::tr("WARNING: You are using a legacy key file format which may become\n"
|
||||
"unsupported in the future.\n\n"
|
||||
"Please consider generating a new key file.")
|
||||
<< endl;
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
compositeKey->addKey(fileKey);
|
||||
}
|
||||
|
||||
auto db = QSharedPointer<Database>::create();
|
||||
QString error;
|
||||
auto db = QSharedPointer<Database>::create();
|
||||
QString error;
|
||||
if (db->open(databaseFilename, compositeKey, &error, false)) {
|
||||
return db;
|
||||
} else {
|
||||
}else {
|
||||
err << error << endl;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a user password from STDIN or return a password previously
|
||||
* set by \link setNextPassword().
|
||||
*
|
||||
* @return the password
|
||||
*/
|
||||
QString getPassword(FILE* outputDescriptor)
|
||||
{
|
||||
TextStream out(outputDescriptor, QIODevice::WriteOnly);
|
||||
/**
|
||||
* Read a user password from STDIN or return a password previously
|
||||
* set by \link setNextPassword().
|
||||
*
|
||||
* @return the password
|
||||
*/
|
||||
QString getPassword(FILE* outputDescriptor)
|
||||
{
|
||||
TextStream out(outputDescriptor, QIODevice::WriteOnly);
|
||||
|
||||
// return preset password if one is set
|
||||
if (!Test::nextPasswords.isEmpty()) {
|
||||
|
@ -36,9 +36,9 @@ namespace Utils
|
||||
QString getPassword(FILE* outputDescriptor = STDOUT);
|
||||
int clipText(const QString& text);
|
||||
QSharedPointer<Database> unlockDatabase(const QString& databaseFilename,
|
||||
const QString& keyFilename = {},
|
||||
FILE* outputDescriptor = STDOUT,
|
||||
FILE* errorDescriptor = STDERR);
|
||||
const QString& keyFilename = {},
|
||||
FILE* outputDescriptor = STDOUT,
|
||||
FILE* errorDescriptor = STDERR);
|
||||
|
||||
namespace Test
|
||||
{
|
||||
|
@ -229,12 +229,11 @@ namespace Bootstrap
|
||||
|
||||
#ifdef WITH_XC_SSHAGENT
|
||||
// OpenSSH for Windows ssh-agent service is running as LocalSystem
|
||||
if (!AddAccessAllowedAce(
|
||||
pACL,
|
||||
ACL_REVISION,
|
||||
PROCESS_QUERY_INFORMATION | PROCESS_DUP_HANDLE, // just enough for ssh-agent
|
||||
pLocalSystemSid // known LocalSystem sid
|
||||
)) {
|
||||
if (!AddAccessAllowedAce(pACL,
|
||||
ACL_REVISION,
|
||||
PROCESS_QUERY_INFORMATION | PROCESS_DUP_HANDLE, // just enough for ssh-agent
|
||||
pLocalSystemSid // known LocalSystem sid
|
||||
)) {
|
||||
goto Cleanup;
|
||||
}
|
||||
#endif
|
||||
|
@ -28,11 +28,11 @@
|
||||
#include "keys/PasswordKey.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QSaveFile>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTimer>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QFileInfo>
|
||||
|
||||
QHash<QUuid, QPointer<Database>> Database::s_uuidMap;
|
||||
QHash<QString, QPointer<Database>> Database::s_filePathMap;
|
||||
|
@ -25,10 +25,10 @@
|
||||
#include <QPointer>
|
||||
|
||||
#include "config-keepassx.h"
|
||||
#include "crypto/kdf/AesKdf.h"
|
||||
#include "crypto/kdf/Kdf.h"
|
||||
#include "format/KeePass2.h"
|
||||
#include "keys/CompositeKey.h"
|
||||
#include "crypto/kdf/AesKdf.h"
|
||||
|
||||
class Entry;
|
||||
enum class EntryReferenceType;
|
||||
@ -66,7 +66,10 @@ public:
|
||||
~Database() override;
|
||||
|
||||
bool open(QSharedPointer<const CompositeKey> key, QString* error = nullptr, bool readOnly = false);
|
||||
bool open(const QString& filePath, QSharedPointer<const CompositeKey> key, QString* error = nullptr, bool readOnly = false);
|
||||
bool open(const QString& filePath,
|
||||
QSharedPointer<const CompositeKey> key,
|
||||
QString* error = nullptr,
|
||||
bool readOnly = false);
|
||||
bool save(QString* error = nullptr, bool atomic = true, bool backup = false);
|
||||
bool save(const QString& filePath, QString* error = nullptr, bool atomic = true, bool backup = false);
|
||||
|
||||
@ -103,7 +106,9 @@ public:
|
||||
|
||||
bool hasKey() const;
|
||||
QSharedPointer<const CompositeKey> key() const;
|
||||
bool setKey(const QSharedPointer<const CompositeKey>& key, bool updateChangedTime = true, bool updateTransformSalt = false);
|
||||
bool setKey(const QSharedPointer<const CompositeKey>& key,
|
||||
bool updateChangedTime = true,
|
||||
bool updateTransformSalt = false);
|
||||
QByteArray challengeResponseKey() const;
|
||||
bool challengeMasterSeed(const QByteArray& masterSeed);
|
||||
bool verifyKey(const QSharedPointer<CompositeKey>& key) const;
|
||||
|
@ -726,17 +726,15 @@ Entry* Entry::clone(CloneFlags flags) const
|
||||
entry->m_attachments->copyDataFrom(m_attachments);
|
||||
|
||||
if (flags & CloneUserAsRef) {
|
||||
entry->m_attributes->set(
|
||||
EntryAttributes::UserNameKey,
|
||||
buildReference(uuid(), EntryAttributes::UserNameKey),
|
||||
m_attributes->isProtected(EntryAttributes::UserNameKey));
|
||||
entry->m_attributes->set(EntryAttributes::UserNameKey,
|
||||
buildReference(uuid(), EntryAttributes::UserNameKey),
|
||||
m_attributes->isProtected(EntryAttributes::UserNameKey));
|
||||
}
|
||||
|
||||
if (flags & ClonePassAsRef) {
|
||||
entry->m_attributes->set(
|
||||
EntryAttributes::PasswordKey,
|
||||
buildReference(uuid(), EntryAttributes::PasswordKey),
|
||||
m_attributes->isProtected(EntryAttributes::PasswordKey));
|
||||
entry->m_attributes->set(EntryAttributes::PasswordKey,
|
||||
buildReference(uuid(), EntryAttributes::PasswordKey),
|
||||
m_attributes->isProtected(EntryAttributes::PasswordKey));
|
||||
}
|
||||
|
||||
entry->m_autoTypeAssociations->copyDataFrom(m_autoTypeAssociations);
|
||||
|
@ -24,7 +24,7 @@
|
||||
EntrySearcher::EntrySearcher(bool caseSensitive)
|
||||
: m_caseSensitive(caseSensitive)
|
||||
, m_termParser(R"re(([-!*+]+)?(?:(\w*):)?(?:(?=")"((?:[^"\\]|\\.)*)"|([^ ]*))( |$))re")
|
||||
// Group 1 = modifiers, Group 2 = field, Group 3 = quoted string, Group 4 = unquoted string
|
||||
// Group 1 = modifiers, Group 2 = field, Group 3 = quoted string, Group 4 = unquoted string
|
||||
{
|
||||
}
|
||||
|
||||
@ -46,9 +46,9 @@ QList<Entry*> EntrySearcher::searchEntries(const QString& searchString, const QL
|
||||
{
|
||||
QList<Entry*> results;
|
||||
for (Entry* entry : entries) {
|
||||
if (searchEntryImpl(searchString, entry)) {
|
||||
results.append(entry);
|
||||
}
|
||||
if (searchEntryImpl(searchString, entry)) {
|
||||
results.append(entry);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
@ -97,10 +97,10 @@ bool EntrySearcher::searchEntryImpl(const QString& searchString, Entry* entry)
|
||||
break;
|
||||
default:
|
||||
// Terms without a specific field try to match title, username, url, and notes
|
||||
found = term->regex.match(entry->resolvePlaceholder(entry->title())).hasMatch() ||
|
||||
term->regex.match(entry->resolvePlaceholder(entry->username())).hasMatch() ||
|
||||
term->regex.match(entry->resolvePlaceholder(entry->url())).hasMatch() ||
|
||||
term->regex.match(entry->notes()).hasMatch();
|
||||
found = term->regex.match(entry->resolvePlaceholder(entry->title())).hasMatch()
|
||||
|| term->regex.match(entry->resolvePlaceholder(entry->username())).hasMatch()
|
||||
|| term->regex.match(entry->resolvePlaceholder(entry->url())).hasMatch()
|
||||
|| term->regex.match(entry->notes()).hasMatch();
|
||||
}
|
||||
|
||||
// Short circuit if we failed to match or we matched and are excluding this term
|
||||
@ -112,9 +112,9 @@ bool EntrySearcher::searchEntryImpl(const QString& searchString, Entry* entry)
|
||||
return true;
|
||||
}
|
||||
|
||||
QList<QSharedPointer<EntrySearcher::SearchTerm> > EntrySearcher::parseSearchTerms(const QString& searchString)
|
||||
QList<QSharedPointer<EntrySearcher::SearchTerm>> EntrySearcher::parseSearchTerms(const QString& searchString)
|
||||
{
|
||||
auto terms = QList<QSharedPointer<SearchTerm> >();
|
||||
auto terms = QList<QSharedPointer<SearchTerm>>();
|
||||
|
||||
auto results = m_termParser.globalMatch(searchString);
|
||||
while (results.hasNext()) {
|
||||
|
@ -19,8 +19,8 @@
|
||||
#ifndef KEEPASSX_ENTRYSEARCHER_H
|
||||
#define KEEPASSX_ENTRYSEARCHER_H
|
||||
|
||||
#include <QString>
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
|
||||
class Group;
|
||||
class Entry;
|
||||
@ -39,7 +39,8 @@ public:
|
||||
private:
|
||||
bool searchEntryImpl(const QString& searchString, Entry* entry);
|
||||
|
||||
enum class Field {
|
||||
enum class Field
|
||||
{
|
||||
Undefined,
|
||||
Title,
|
||||
Username,
|
||||
@ -58,7 +59,7 @@ private:
|
||||
bool exclude;
|
||||
};
|
||||
|
||||
QList<QSharedPointer<SearchTerm> > parseSearchTerms(const QString& searchString);
|
||||
QList<QSharedPointer<SearchTerm>> parseSearchTerms(const QString& searchString);
|
||||
|
||||
bool m_caseSensitive;
|
||||
QRegularExpression m_termParser;
|
||||
|
@ -29,7 +29,7 @@ namespace
|
||||
{
|
||||
const int FileChangeDelay = 500;
|
||||
const int TimerResolution = 100;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DelayingFileWatcher::DelayingFileWatcher(QObject* parent)
|
||||
: QObject(parent)
|
||||
@ -238,13 +238,13 @@ void BulkFileWatcher::emitSignals()
|
||||
{
|
||||
QMap<QString, QList<Signal>> queued;
|
||||
m_pendingSignals.swap(queued);
|
||||
for (const auto& path : queued.keys()){
|
||||
const auto &signal = queued[path];
|
||||
for (const auto& path : queued.keys()) {
|
||||
const auto& signal = queued[path];
|
||||
if (signal.last() == Removed) {
|
||||
emit fileRemoved(path);
|
||||
continue;
|
||||
}
|
||||
if (signal.first() == Created){
|
||||
if (signal.first() == Created) {
|
||||
emit fileCreated(path);
|
||||
continue;
|
||||
}
|
||||
@ -252,7 +252,7 @@ void BulkFileWatcher::emitSignals()
|
||||
}
|
||||
}
|
||||
|
||||
void BulkFileWatcher::scheduleSignal(Signal signal, const QString &path)
|
||||
void BulkFileWatcher::scheduleSignal(Signal signal, const QString& path)
|
||||
{
|
||||
// we need to collect signals since the file watcher API may send multiple signals for a "single" change
|
||||
// therefore we wait until the event loop finished before starting to import any changes
|
||||
|
@ -58,11 +58,13 @@ class BulkFileWatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum Signal {
|
||||
enum Signal
|
||||
{
|
||||
Created,
|
||||
Updated,
|
||||
Removed
|
||||
};
|
||||
|
||||
public:
|
||||
explicit BulkFileWatcher(QObject* parent = nullptr);
|
||||
|
||||
@ -71,7 +73,6 @@ public:
|
||||
void removePath(const QString& path);
|
||||
void addPath(const QString& path);
|
||||
|
||||
|
||||
void ignoreFileChanges(const QString& path);
|
||||
|
||||
signals:
|
||||
@ -88,7 +89,7 @@ private slots:
|
||||
void emitSignals();
|
||||
|
||||
private:
|
||||
void scheduleSignal(Signal event, const QString &path);
|
||||
void scheduleSignal(Signal event, const QString& path);
|
||||
|
||||
private:
|
||||
QMap<QString, bool> m_watchedPaths;
|
||||
@ -96,9 +97,9 @@ private:
|
||||
QFileSystemWatcher m_fileWatcher;
|
||||
QMap<QString, QMap<QString, bool>> m_watchedFilesInDirectory;
|
||||
// needed for Import/Export-References to prevent update after self-write
|
||||
QTimer m_fileWatchUnblockTimer;
|
||||
QTimer m_fileWatchUnblockTimer;
|
||||
// needed to tolerate multiple signals for same event
|
||||
QTimer m_pendingSignalsTimer;
|
||||
QTimer m_pendingSignalsTimer;
|
||||
QMap<QString, QList<Signal>> m_pendingSignals;
|
||||
};
|
||||
|
||||
|
@ -554,7 +554,8 @@ QList<Entry*> Group::entriesRecursive(bool includeHistoryItems) const
|
||||
QList<Entry*> Group::referencesRecursive(const Entry* entry) const
|
||||
{
|
||||
auto entries = entriesRecursive();
|
||||
return QtConcurrent::blockingFiltered(entries, [entry](const Entry* e) { return e->hasReferencesTo(entry->uuid()); });
|
||||
return QtConcurrent::blockingFiltered(entries,
|
||||
[entry](const Entry* e) { return e->hasReferencesTo(entry->uuid()); });
|
||||
}
|
||||
|
||||
Entry* Group::findEntryByUuid(const QUuid& uuid) const
|
||||
@ -600,29 +601,29 @@ Entry* Group::findEntryBySearchTerm(const QString& term, EntryReferenceType refe
|
||||
const QList<Entry*>& entryList = group->entries();
|
||||
for (Entry* entry : entryList) {
|
||||
switch (referenceType) {
|
||||
case EntryReferenceType::Unknown:
|
||||
return nullptr;
|
||||
case EntryReferenceType::Title:
|
||||
found = entry->title() == term;
|
||||
break;
|
||||
case EntryReferenceType::UserName:
|
||||
found = entry->username() == term;
|
||||
break;
|
||||
case EntryReferenceType::Password:
|
||||
found = entry->password() == term;
|
||||
break;
|
||||
case EntryReferenceType::Url:
|
||||
found = entry->url() == term;
|
||||
break;
|
||||
case EntryReferenceType::Notes:
|
||||
found = entry->notes() == term;
|
||||
break;
|
||||
case EntryReferenceType::QUuid:
|
||||
found = entry->uuid() == QUuid::fromRfc4122(QByteArray::fromHex(term.toLatin1()));
|
||||
break;
|
||||
case EntryReferenceType::CustomAttributes:
|
||||
found = entry->attributes()->containsValue(term);
|
||||
break;
|
||||
case EntryReferenceType::Unknown:
|
||||
return nullptr;
|
||||
case EntryReferenceType::Title:
|
||||
found = entry->title() == term;
|
||||
break;
|
||||
case EntryReferenceType::UserName:
|
||||
found = entry->username() == term;
|
||||
break;
|
||||
case EntryReferenceType::Password:
|
||||
found = entry->password() == term;
|
||||
break;
|
||||
case EntryReferenceType::Url:
|
||||
found = entry->url() == term;
|
||||
break;
|
||||
case EntryReferenceType::Notes:
|
||||
found = entry->notes() == term;
|
||||
break;
|
||||
case EntryReferenceType::QUuid:
|
||||
found = entry->uuid() == QUuid::fromRfc4122(QByteArray::fromHex(term.toLatin1()));
|
||||
break;
|
||||
case EntryReferenceType::CustomAttributes:
|
||||
found = entry->attributes()->containsValue(term);
|
||||
break;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
#include "ScreenLockListenerMac.h"
|
||||
|
||||
#include <QMutexLocker>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <QMutexLocker>
|
||||
|
||||
ScreenLockListenerMac* ScreenLockListenerMac::instance()
|
||||
{
|
||||
@ -32,8 +32,10 @@ ScreenLockListenerMac* ScreenLockListenerMac::instance()
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
void ScreenLockListenerMac::notificationCenterCallBack(CFNotificationCenterRef, void*,
|
||||
CFStringRef, const void*,
|
||||
void ScreenLockListenerMac::notificationCenterCallBack(CFNotificationCenterRef,
|
||||
void*,
|
||||
CFStringRef,
|
||||
const void*,
|
||||
CFDictionaryRef)
|
||||
{
|
||||
instance()->onSignalReception();
|
||||
|
@ -24,19 +24,21 @@
|
||||
|
||||
#include "ScreenLockListenerPrivate.h"
|
||||
|
||||
class ScreenLockListenerMac: public ScreenLockListenerPrivate {
|
||||
class ScreenLockListenerMac : public ScreenLockListenerPrivate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static ScreenLockListenerMac* instance();
|
||||
static void notificationCenterCallBack(CFNotificationCenterRef center, void* observer,
|
||||
CFStringRef name, const void* object,
|
||||
static void notificationCenterCallBack(CFNotificationCenterRef center,
|
||||
void* observer,
|
||||
CFStringRef name,
|
||||
const void* object,
|
||||
CFDictionaryRef userInfo);
|
||||
|
||||
private:
|
||||
ScreenLockListenerMac(QWidget* parent = nullptr);
|
||||
void onSignalReception();
|
||||
|
||||
};
|
||||
|
||||
#endif // SCREENLOCKLISTENERMAC_H
|
||||
|
@ -118,6 +118,7 @@ bool TimeInfo::operator!=(const TimeInfo& other) const
|
||||
|
||||
bool TimeInfo::equals(const TimeInfo& other, CompareItemOptions options) const
|
||||
{
|
||||
// clang-format off
|
||||
if (::compare(m_lastModificationTime, other.m_lastModificationTime, options) != 0) {
|
||||
return false;
|
||||
}
|
||||
@ -137,4 +138,5 @@ bool TimeInfo::equals(const TimeInfo& other, CompareItemOptions options) const
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
// clang-format on
|
||||
}
|
||||
|
@ -208,7 +208,8 @@ namespace Tools
|
||||
return regex;
|
||||
}
|
||||
|
||||
QString uuidToHex(const QUuid& uuid) {
|
||||
QString uuidToHex(const QUuid& uuid)
|
||||
{
|
||||
return QString::fromLatin1(uuid.toRfc4122().toHex());
|
||||
}
|
||||
|
||||
@ -216,7 +217,6 @@ namespace Tools
|
||||
: raw(nullptr)
|
||||
, size(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Buffer::~Buffer()
|
||||
@ -226,15 +226,16 @@ namespace Tools
|
||||
|
||||
void Buffer::clear()
|
||||
{
|
||||
if(size > 0){
|
||||
if (size > 0) {
|
||||
free(raw);
|
||||
}
|
||||
raw = nullptr; size = 0;
|
||||
raw = nullptr;
|
||||
size = 0;
|
||||
}
|
||||
|
||||
QByteArray Buffer::content() const
|
||||
{
|
||||
return QByteArray(reinterpret_cast<char*>(raw), size );
|
||||
return QByteArray(reinterpret_cast<char*>(raw), size);
|
||||
}
|
||||
|
||||
} // namespace Tools
|
||||
|
@ -47,8 +47,7 @@ void Translator::installTranslators()
|
||||
#ifdef QT_DEBUG
|
||||
QString("%1/share/translations").arg(KEEPASSX_BINARY_DIR),
|
||||
#endif
|
||||
filePath()->dataPath("translations")
|
||||
};
|
||||
filePath()->dataPath("translations")};
|
||||
|
||||
bool translationsLoaded = false;
|
||||
for (const QString& path : paths) {
|
||||
|
@ -27,6 +27,6 @@ namespace ASN1Key
|
||||
bool parseDSA(QByteArray& ba, OpenSSHKey& key);
|
||||
bool parsePrivateRSA(QByteArray& ba, OpenSSHKey& key);
|
||||
bool parsePublicRSA(QByteArray& ba, OpenSSHKey& key);
|
||||
}
|
||||
} // namespace ASN1Key
|
||||
|
||||
#endif // KEEPASSXC_ASN1KEY_H
|
||||
|
@ -36,39 +36,39 @@ const QString OpenSSHKey::TYPE_OPENSSH_PRIVATE = "OPENSSH PRIVATE KEY";
|
||||
|
||||
namespace
|
||||
{
|
||||
QPair<QString, QList<QByteArray>> binaryDeserialize(const QByteArray& serialized)
|
||||
{
|
||||
if (serialized.isEmpty()) {
|
||||
return {};
|
||||
QPair<QString, QList<QByteArray>> binaryDeserialize(const QByteArray& serialized)
|
||||
{
|
||||
if (serialized.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
QBuffer buffer;
|
||||
buffer.setData(serialized);
|
||||
buffer.open(QBuffer::ReadOnly);
|
||||
BinaryStream stream(&buffer);
|
||||
QString type;
|
||||
stream.readString(type);
|
||||
QByteArray temp;
|
||||
QList<QByteArray> data;
|
||||
while (stream.readString(temp)) {
|
||||
data << temp;
|
||||
}
|
||||
return ::qMakePair(type, data);
|
||||
}
|
||||
QBuffer buffer;
|
||||
buffer.setData(serialized);
|
||||
buffer.open(QBuffer::ReadOnly);
|
||||
BinaryStream stream(&buffer);
|
||||
QString type;
|
||||
stream.readString(type);
|
||||
QByteArray temp;
|
||||
QList<QByteArray> data;
|
||||
while (stream.readString(temp)) {
|
||||
data << temp;
|
||||
}
|
||||
return ::qMakePair(type, data);
|
||||
}
|
||||
|
||||
QByteArray binarySerialize(const QString& type, const QList<QByteArray>& data)
|
||||
{
|
||||
if (type.isEmpty() && data.isEmpty()) {
|
||||
return {};
|
||||
QByteArray binarySerialize(const QString& type, const QList<QByteArray>& data)
|
||||
{
|
||||
if (type.isEmpty() && data.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
QByteArray buffer;
|
||||
BinaryStream stream(&buffer);
|
||||
stream.writeString(type);
|
||||
for (const QByteArray& part : data) {
|
||||
stream.writeString(part);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
QByteArray buffer;
|
||||
BinaryStream stream(&buffer);
|
||||
stream.writeString(type);
|
||||
for (const QByteArray& part : data) {
|
||||
stream.writeString(part);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// bcrypt_pbkdf.cpp
|
||||
int bcrypt_pbkdf(const QByteArray& pass, const QByteArray& salt, QByteArray& key, quint32 rounds);
|
||||
@ -95,7 +95,9 @@ OpenSSHKey OpenSSHKey::generate(bool secure)
|
||||
Tools::Map<Index, gcry_mpi_t, &gcry_mpi_release> mpi;
|
||||
Tools::Map<Index, gcry_sexp_t, &gcry_sexp_release> sexp;
|
||||
gcry_error_t rc = GPG_ERR_NO_ERROR;
|
||||
rc = gcry_sexp_build(&sexp[Params], NULL, secure ? "(genkey (rsa (nbits 4:2048)))" : "(genkey (rsa (transient-key) (nbits 4:2048)))");
|
||||
rc = gcry_sexp_build(&sexp[Params],
|
||||
NULL,
|
||||
secure ? "(genkey (rsa (nbits 4:2048)))" : "(genkey (rsa (transient-key) (nbits 4:2048)))");
|
||||
if (rc != GPG_ERR_NO_ERROR) {
|
||||
qWarning() << "Could not create ssh key" << gcry_err_code(rc);
|
||||
return OpenSSHKey();
|
||||
@ -204,32 +206,32 @@ OpenSSHKey OpenSSHKey::generate(bool secure)
|
||||
}
|
||||
|
||||
OpenSSHKey::OpenSSHKey(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_type(QString())
|
||||
, m_cipherName(QString("none"))
|
||||
, m_kdfName(QString("none"))
|
||||
, m_kdfOptions(QByteArray())
|
||||
, m_rawType(QString())
|
||||
, m_rawData(QByteArray())
|
||||
, m_rawPublicData(QList<QByteArray>())
|
||||
, m_rawPrivateData(QList<QByteArray>())
|
||||
, m_comment(QString())
|
||||
, m_error(QString())
|
||||
: QObject(parent)
|
||||
, m_type(QString())
|
||||
, m_cipherName(QString("none"))
|
||||
, m_kdfName(QString("none"))
|
||||
, m_kdfOptions(QByteArray())
|
||||
, m_rawType(QString())
|
||||
, m_rawData(QByteArray())
|
||||
, m_rawPublicData(QList<QByteArray>())
|
||||
, m_rawPrivateData(QList<QByteArray>())
|
||||
, m_comment(QString())
|
||||
, m_error(QString())
|
||||
{
|
||||
}
|
||||
|
||||
OpenSSHKey::OpenSSHKey(const OpenSSHKey& other)
|
||||
: QObject(nullptr)
|
||||
, m_type(other.m_type)
|
||||
, m_cipherName(other.m_cipherName)
|
||||
, m_kdfName(other.m_kdfName)
|
||||
, m_kdfOptions(other.m_kdfOptions)
|
||||
, m_rawType(other.m_rawType)
|
||||
, m_rawData(other.m_rawData)
|
||||
, m_rawPublicData(other.m_rawPublicData)
|
||||
, m_rawPrivateData(other.m_rawPrivateData)
|
||||
, m_comment(other.m_comment)
|
||||
, m_error(other.m_error)
|
||||
: QObject(nullptr)
|
||||
, m_type(other.m_type)
|
||||
, m_cipherName(other.m_cipherName)
|
||||
, m_kdfName(other.m_kdfName)
|
||||
, m_kdfOptions(other.m_kdfOptions)
|
||||
, m_rawType(other.m_rawType)
|
||||
, m_rawData(other.m_rawData)
|
||||
, m_rawPublicData(other.m_rawPublicData)
|
||||
, m_rawPrivateData(other.m_rawPrivateData)
|
||||
, m_comment(other.m_comment)
|
||||
, m_error(other.m_error)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,7 @@ bool Kdbx4Reader::readDatabaseImpl(QIODevice* device,
|
||||
return false;
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
QByteArray hmacKey = KeePass2::hmacKey(m_masterSeed, db->transformedMasterKey());
|
||||
if (headerHmac != CryptoHash::hmac(headerData, HmacBlockStream::getHmacKey(UINT64_MAX, hmacKey), CryptoHash::Sha256)) {
|
||||
raiseError(tr("Wrong key or database file is corrupt. (HMAC mismatch)"));
|
||||
@ -93,6 +94,7 @@ bool Kdbx4Reader::readDatabaseImpl(QIODevice* device,
|
||||
raiseError(cipherStream.errorString());
|
||||
return false;
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
QIODevice* xmlDevice = nullptr;
|
||||
QScopedPointer<QtIOCompressor> ioCompressor;
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
explicit KdbxXmlWriter(quint32 version);
|
||||
|
||||
void writeDatabase(QIODevice* device,
|
||||
const Database *db,
|
||||
const Database* db,
|
||||
KeePass2RandomStream* randomStream = nullptr,
|
||||
const QByteArray& headerHash = QByteArray());
|
||||
void writeDatabase(const QString& filename, Database* db);
|
||||
|
@ -56,7 +56,8 @@ KeePass1Reader::KeePass1Reader()
|
||||
{
|
||||
}
|
||||
|
||||
QSharedPointer<Database> KeePass1Reader::readDatabase(QIODevice* device, const QString& password, QIODevice* keyfileDevice)
|
||||
QSharedPointer<Database>
|
||||
KeePass1Reader::readDatabase(QIODevice* device, const QString& password, QIODevice* keyfileDevice)
|
||||
{
|
||||
m_error = false;
|
||||
m_errorStr.clear();
|
||||
@ -248,7 +249,8 @@ QSharedPointer<Database> KeePass1Reader::readDatabase(QIODevice* device, const Q
|
||||
return db;
|
||||
}
|
||||
|
||||
QSharedPointer<Database> KeePass1Reader::readDatabase(QIODevice* device, const QString& password, const QString& keyfileName)
|
||||
QSharedPointer<Database>
|
||||
KeePass1Reader::readDatabase(QIODevice* device, const QString& password, const QString& keyfileName)
|
||||
{
|
||||
QScopedPointer<QFile> keyFile;
|
||||
if (!keyfileName.isEmpty()) {
|
||||
@ -262,7 +264,8 @@ QSharedPointer<Database> KeePass1Reader::readDatabase(QIODevice* device, const Q
|
||||
return QSharedPointer<Database>(readDatabase(device, password, keyFile.data()));
|
||||
}
|
||||
|
||||
QSharedPointer<Database> KeePass1Reader::readDatabase(const QString& filename, const QString& password, const QString& keyfileName)
|
||||
QSharedPointer<Database>
|
||||
KeePass1Reader::readDatabase(const QString& filename, const QString& password, const QString& keyfileName)
|
||||
{
|
||||
QFile dbFile(filename);
|
||||
if (!dbFile.open(QFile::ReadOnly)) {
|
||||
@ -290,7 +293,8 @@ QString KeePass1Reader::errorString()
|
||||
return m_errorStr;
|
||||
}
|
||||
|
||||
SymmetricCipherStream* KeePass1Reader::testKeys(const QString& password, const QByteArray& keyfileData, qint64 contentPos)
|
||||
SymmetricCipherStream*
|
||||
KeePass1Reader::testKeys(const QString& password, const QByteArray& keyfileData, qint64 contentPos)
|
||||
{
|
||||
const QList<PasswordEncoding> encodings = {Windows1252, Latin1, UTF8};
|
||||
|
||||
|
@ -48,10 +48,10 @@ bool KeePass2Writer::writeDatabase(const QString& filename, Database* db)
|
||||
*/
|
||||
bool KeePass2Writer::implicitUpgradeNeeded(Database const* db) const
|
||||
{
|
||||
if (db->kdf()->uuid() != KeePass2::KDF_AES_KDBX3 ) {
|
||||
if (db->kdf()->uuid() != KeePass2::KDF_AES_KDBX3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!db->publicCustomData().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -65,15 +65,15 @@ AboutDialog::AboutDialog(QWidget* parent)
|
||||
#endif
|
||||
|
||||
debugInfo.append("\n").append(
|
||||
QString("%1\n- Qt %2\n- %3\n\n")
|
||||
.arg(tr("Libraries:"), QString::fromLocal8Bit(qVersion()), Crypto::backendVersion()));
|
||||
QString("%1\n- Qt %2\n- %3\n\n")
|
||||
.arg(tr("Libraries:"), QString::fromLocal8Bit(qVersion()), Crypto::backendVersion()));
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
debugInfo.append(tr("Operating system: %1\nCPU architecture: %2\nKernel: %3 %4")
|
||||
.arg(QSysInfo::prettyProductName(),
|
||||
QSysInfo::currentCpuArchitecture(),
|
||||
QSysInfo::kernelType(),
|
||||
QSysInfo::kernelVersion()));
|
||||
.arg(QSysInfo::prettyProductName(),
|
||||
QSysInfo::currentCpuArchitecture(),
|
||||
QSysInfo::kernelType(),
|
||||
QSysInfo::kernelVersion()));
|
||||
|
||||
debugInfo.append("\n\n");
|
||||
#endif
|
||||
|
@ -248,7 +248,8 @@ void ApplicationSettingsWidget::saveSettings()
|
||||
config()->set("GUI/MovableToolbar", m_generalUi->toolbarMovableCheckBox->isChecked());
|
||||
|
||||
int currentToolButtonStyleIndex = m_generalUi->toolButtonStyleComboBox->currentIndex();
|
||||
config()->set("GUI/ToolButtonStyle", m_generalUi->toolButtonStyleComboBox->itemData(currentToolButtonStyleIndex).toString());
|
||||
config()->set("GUI/ToolButtonStyle",
|
||||
m_generalUi->toolButtonStyleComboBox->itemData(currentToolButtonStyleIndex).toString());
|
||||
|
||||
config()->set("GUI/ShowTrayIcon", m_generalUi->systrayShowCheckBox->isChecked());
|
||||
config()->set("GUI/DarkTrayIcon", m_generalUi->systrayDarkIconCheckBox->isChecked());
|
||||
@ -329,4 +330,3 @@ void ApplicationSettingsWidget::enableToolbarSettings(bool checked)
|
||||
m_generalUi->toolButtonStyleComboBox->setEnabled(!checked);
|
||||
m_generalUi->toolButtonStyleLabel->setEnabled(!checked);
|
||||
}
|
||||
|
||||
|
@ -202,9 +202,8 @@ void DatabaseOpenWidget::openDatabase()
|
||||
bool ok = m_db->open(m_filename, masterKey, &error, false);
|
||||
QApplication::restoreOverrideCursor();
|
||||
if (!ok) {
|
||||
m_ui->messageWidget->showMessage(
|
||||
tr("Unable to open the database:\n%1").arg(error),
|
||||
MessageWidget::MessageType::Error);
|
||||
m_ui->messageWidget->showMessage(tr("Unable to open the database:\n%1").arg(error),
|
||||
MessageWidget::MessageType::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -232,8 +231,7 @@ void DatabaseOpenWidget::openDatabase()
|
||||
}
|
||||
emit dialogFinished(true);
|
||||
} else {
|
||||
m_ui->messageWidget->showMessage(tr("Unable to open the database:\n%1").arg(error),
|
||||
MessageWidget::Error);
|
||||
m_ui->messageWidget->showMessage(tr("Unable to open the database:\n%1").arg(error), MessageWidget::Error);
|
||||
m_ui->editPassword->setText("");
|
||||
|
||||
#ifdef WITH_XC_TOUCHID
|
||||
|
@ -31,12 +31,12 @@
|
||||
#include "core/Tools.h"
|
||||
#include "format/CsvExporter.h"
|
||||
#include "gui/Clipboard.h"
|
||||
#include "gui/DatabaseOpenDialog.h"
|
||||
#include "gui/DatabaseWidget.h"
|
||||
#include "gui/DatabaseWidgetStateSync.h"
|
||||
#include "gui/DragTabBar.h"
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/MessageBox.h"
|
||||
#include "gui/DatabaseOpenDialog.h"
|
||||
#include "gui/entry/EntryView.h"
|
||||
#include "gui/group/GroupView.h"
|
||||
#ifdef Q_OS_MACOS
|
||||
@ -54,12 +54,15 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
|
||||
setTabBar(tabBar);
|
||||
setDocumentMode(true);
|
||||
|
||||
// clang-format off
|
||||
connect(this, SIGNAL(tabCloseRequested(int)), SLOT(closeDatabaseTab(int)));
|
||||
connect(this, SIGNAL(currentChanged(int)), SLOT(emitActivateDatabaseChanged()));
|
||||
connect(this, SIGNAL(activateDatabaseChanged(DatabaseWidget*)), m_dbWidgetStateSync, SLOT(setActive(DatabaseWidget*)));
|
||||
connect(this, SIGNAL(activateDatabaseChanged(DatabaseWidget*)),
|
||||
m_dbWidgetStateSync, SLOT(setActive(DatabaseWidget*)));
|
||||
connect(autoType(), SIGNAL(globalShortcutTriggered()), SLOT(performGlobalAutoType()));
|
||||
connect(autoType(), SIGNAL(autotypePerformed()), SLOT(relockPendingDatabase()));
|
||||
connect(autoType(), SIGNAL(autotypeRejected()), SLOT(relockPendingDatabase()));
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
DatabaseTabWidget::~DatabaseTabWidget()
|
||||
@ -186,8 +189,9 @@ void DatabaseTabWidget::addDatabaseTab(DatabaseWidget* dbWidget, bool inBackgrou
|
||||
setCurrentIndex(index);
|
||||
}
|
||||
|
||||
connect(dbWidget, SIGNAL(databaseFilePathChanged(QString,QString)), SLOT(updateTabName()));
|
||||
connect(dbWidget, SIGNAL(requestOpenDatabase(QString,bool,QString)), SLOT(addDatabaseTab(QString,bool,QString)));
|
||||
connect(dbWidget, SIGNAL(databaseFilePathChanged(QString, QString)), SLOT(updateTabName()));
|
||||
connect(
|
||||
dbWidget, SIGNAL(requestOpenDatabase(QString, bool, QString)), SLOT(addDatabaseTab(QString, bool, QString)));
|
||||
connect(dbWidget, SIGNAL(closeRequest()), SLOT(closeDatabaseTabFromSender()));
|
||||
connect(dbWidget, SIGNAL(databaseModified()), SLOT(updateTabName()));
|
||||
connect(dbWidget, SIGNAL(databaseSaved()), SLOT(updateTabName()));
|
||||
@ -520,7 +524,6 @@ void DatabaseTabWidget::lockDatabases()
|
||||
// If we locked a database without a file close the tab
|
||||
closeDatabaseTab(dbWidget);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -542,7 +545,8 @@ void DatabaseTabWidget::unlockDatabaseInDialog(DatabaseWidget* dbWidget, Databas
|
||||
* @param intent intent for unlocking
|
||||
* @param file path of the database to be unlocked
|
||||
*/
|
||||
void DatabaseTabWidget::unlockDatabaseInDialog(DatabaseWidget* dbWidget, DatabaseOpenDialog::Intent intent,
|
||||
void DatabaseTabWidget::unlockDatabaseInDialog(DatabaseWidget* dbWidget,
|
||||
DatabaseOpenDialog::Intent intent,
|
||||
const QString& filePath)
|
||||
{
|
||||
m_databaseOpenDialog->setTargetDatabaseWidget(dbWidget);
|
||||
|
@ -18,11 +18,11 @@
|
||||
#ifndef KEEPASSX_DATABASETABWIDGET_H
|
||||
#define KEEPASSX_DATABASETABWIDGET_H
|
||||
|
||||
#include "gui/MessageWidget.h"
|
||||
#include "DatabaseOpenDialog.h"
|
||||
#include "gui/MessageWidget.h"
|
||||
|
||||
#include <QTabWidget>
|
||||
#include <QPointer>
|
||||
#include <QTabWidget>
|
||||
|
||||
class Database;
|
||||
class DatabaseWidget;
|
||||
|
@ -32,8 +32,8 @@
|
||||
#include <QSplitter>
|
||||
|
||||
#include "autotype/AutoType.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/EntrySearcher.h"
|
||||
#include "core/FilePath.h"
|
||||
#include "core/FileWatcher.h"
|
||||
@ -42,18 +42,18 @@
|
||||
#include "core/Metadata.h"
|
||||
#include "core/Tools.h"
|
||||
#include "format/KeePass2Reader.h"
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/Clipboard.h"
|
||||
#include "gui/CloneDialog.h"
|
||||
#include "gui/DatabaseOpenWidget.h"
|
||||
#include "gui/DatabaseOpenDialog.h"
|
||||
#include "gui/dbsettings/DatabaseSettingsDialog.h"
|
||||
#include "gui/DatabaseOpenWidget.h"
|
||||
#include "gui/EntryPreviewWidget.h"
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/KeePass1OpenWidget.h"
|
||||
#include "gui/MessageBox.h"
|
||||
#include "gui/TotpDialog.h"
|
||||
#include "gui/TotpSetupDialog.h"
|
||||
#include "gui/TotpExportSettingsDialog.h"
|
||||
#include "gui/TotpSetupDialog.h"
|
||||
#include "gui/dbsettings/DatabaseSettingsDialog.h"
|
||||
#include "gui/entry/EditEntryWidget.h"
|
||||
#include "gui/entry/EntryView.h"
|
||||
#include "gui/group/EditGroupWidget.h"
|
||||
@ -443,7 +443,7 @@ void DatabaseWidget::deleteSelectedEntries()
|
||||
// Confirm entry removal before moving forward
|
||||
auto* recycleBin = m_db->metadata()->recycleBin();
|
||||
bool permanent = (recycleBin && recycleBin->findEntryByUuid(selectedEntries.first()->uuid()))
|
||||
|| !m_db->metadata()->recycleBinEnabled();
|
||||
|| !m_db->metadata()->recycleBinEnabled();
|
||||
|
||||
if (!confirmDeleteEntries(selectedEntries, permanent)) {
|
||||
return;
|
||||
@ -462,15 +462,16 @@ void DatabaseWidget::deleteSelectedEntries()
|
||||
if (!references.isEmpty()) {
|
||||
// Prompt for reference handling
|
||||
auto result = MessageBox::question(
|
||||
this,
|
||||
tr("Replace references to entry?"),
|
||||
tr("Entry \"%1\" has %2 reference(s). "
|
||||
"Do you want to overwrite references with values, skip this entry, or delete anyway?", "",
|
||||
references.size())
|
||||
.arg((*it)->title().toHtmlEscaped())
|
||||
.arg(references.size()),
|
||||
MessageBox::Overwrite | MessageBox::Skip | MessageBox::Delete,
|
||||
MessageBox::Overwrite);
|
||||
this,
|
||||
tr("Replace references to entry?"),
|
||||
tr("Entry \"%1\" has %2 reference(s). "
|
||||
"Do you want to overwrite references with values, skip this entry, or delete anyway?",
|
||||
"",
|
||||
references.size())
|
||||
.arg((*it)->title().toHtmlEscaped())
|
||||
.arg(references.size()),
|
||||
MessageBox::Overwrite | MessageBox::Skip | MessageBox::Delete,
|
||||
MessageBox::Overwrite);
|
||||
|
||||
if (result == MessageBox::Overwrite) {
|
||||
for (auto* entry : references) {
|
||||
@ -590,8 +591,7 @@ void DatabaseWidget::copyAttribute(QAction* action)
|
||||
Entry* currentEntry = m_entryView->currentEntry();
|
||||
if (currentEntry) {
|
||||
setClipboardTextAndMinimize(
|
||||
currentEntry->resolveMultiplePlaceholders(
|
||||
currentEntry->attributes()->value(action->data().toString())));
|
||||
currentEntry->resolveMultiplePlaceholders(currentEntry->attributes()->value(action->data().toString())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -707,12 +707,12 @@ void DatabaseWidget::deleteGroup()
|
||||
bool isRecycleBin = recycleBin && (currentGroup == recycleBin);
|
||||
bool isRecycleBinSubgroup = recycleBin && currentGroup->findGroupByUuid(recycleBin->uuid());
|
||||
if (inRecycleBin || isRecycleBin || isRecycleBinSubgroup || !m_db->metadata()->recycleBinEnabled()) {
|
||||
auto result = MessageBox::question(this,
|
||||
tr("Delete group"),
|
||||
tr("Do you really want to delete the group \"%1\" for good?")
|
||||
.arg(currentGroup->name().toHtmlEscaped()),
|
||||
MessageBox::Delete | MessageBox::Cancel,
|
||||
MessageBox::Cancel);
|
||||
auto result = MessageBox::question(
|
||||
this,
|
||||
tr("Delete group"),
|
||||
tr("Do you really want to delete the group \"%1\" for good?").arg(currentGroup->name().toHtmlEscaped()),
|
||||
MessageBox::Delete | MessageBox::Cancel,
|
||||
MessageBox::Cancel);
|
||||
|
||||
if (result == MessageBox::Delete) {
|
||||
delete currentGroup;
|
||||
@ -722,7 +722,7 @@ void DatabaseWidget::deleteGroup()
|
||||
tr("Move group to recycle bin?"),
|
||||
tr("Do you really want to move the group "
|
||||
"\"%1\" to the recycle bin?")
|
||||
.arg(currentGroup->name().toHtmlEscaped()),
|
||||
.arg(currentGroup->name().toHtmlEscaped()),
|
||||
MessageBox::Move | MessageBox::Cancel,
|
||||
MessageBox::Cancel);
|
||||
if (result == MessageBox::Move) {
|
||||
@ -815,7 +815,10 @@ void DatabaseWidget::switchToGroupEdit(Group* group, bool create)
|
||||
void DatabaseWidget::connectDatabaseSignals()
|
||||
{
|
||||
// relayed Database events
|
||||
connect(m_db.data(), SIGNAL(filePathChanged(QString,QString)), SIGNAL(databaseFilePathChanged(QString,QString)));
|
||||
connect(m_db.data(),
|
||||
SIGNAL(filePathChanged(QString, QString)),
|
||||
|
||||
SIGNAL(databaseFilePathChanged(QString, QString)));
|
||||
connect(m_db.data(), SIGNAL(databaseModified()), SIGNAL(databaseModified()));
|
||||
connect(m_db.data(), SIGNAL(databaseModified()), SLOT(onDatabaseModified()));
|
||||
connect(m_db.data(), SIGNAL(databaseSaved()), SIGNAL(databaseSaved()));
|
||||
@ -1208,9 +1211,11 @@ bool DatabaseWidget::lock()
|
||||
clipboard()->clearCopiedText();
|
||||
|
||||
if (currentMode() == DatabaseWidget::Mode::EditMode) {
|
||||
auto result = MessageBox::question(this, tr("Lock Database?"),
|
||||
tr("You are editing an entry. Discard changes and lock anyway?"),
|
||||
MessageBox::Discard | MessageBox::Cancel, MessageBox::Cancel);
|
||||
auto result = MessageBox::question(this,
|
||||
tr("Lock Database?"),
|
||||
tr("You are editing an entry. Discard changes and lock anyway?"),
|
||||
MessageBox::Discard | MessageBox::Cancel,
|
||||
MessageBox::Cancel);
|
||||
if (result == MessageBox::Cancel) {
|
||||
return false;
|
||||
}
|
||||
@ -1228,8 +1233,11 @@ bool DatabaseWidget::lock()
|
||||
} else {
|
||||
msg = tr("Database was modified.\nSave changes?");
|
||||
}
|
||||
auto result = MessageBox::question(this, tr("Save changes?"), msg,
|
||||
MessageBox::Save | MessageBox::Discard | MessageBox::Cancel, MessageBox::Save);
|
||||
auto result = MessageBox::question(this,
|
||||
tr("Save changes?"),
|
||||
msg,
|
||||
MessageBox::Save | MessageBox::Discard | MessageBox::Cancel,
|
||||
MessageBox::Save);
|
||||
if (result == MessageBox::Save) {
|
||||
if (!save()) {
|
||||
return false;
|
||||
@ -1288,9 +1296,9 @@ void DatabaseWidget::reloadDatabaseFile()
|
||||
if (!config()->get("AutoReloadOnChange").toBool()) {
|
||||
// Ask if we want to reload the db
|
||||
auto result = MessageBox::question(this,
|
||||
tr("File has changed"),
|
||||
tr("The database file has changed. Do you want to load the changes?"),
|
||||
MessageBox::Yes | MessageBox::No);
|
||||
tr("File has changed"),
|
||||
tr("The database file has changed. Do you want to load the changes?"),
|
||||
MessageBox::Yes | MessageBox::No);
|
||||
|
||||
if (result == MessageBox::No) {
|
||||
// Notify everyone the database does not match the file
|
||||
@ -1306,7 +1314,8 @@ void DatabaseWidget::reloadDatabaseFile()
|
||||
if (db->open(database()->key(), &error, true)) {
|
||||
if (m_db->isModified()) {
|
||||
// Ask if we want to merge changes into new database
|
||||
auto result = MessageBox::question(this,
|
||||
auto result = MessageBox::question(
|
||||
this,
|
||||
tr("Merge Request"),
|
||||
tr("The database file has changed and you have unsaved changes.\nDo you want to merge your changes?"),
|
||||
MessageBox::Merge | MessageBox::Cancel,
|
||||
@ -1336,9 +1345,8 @@ void DatabaseWidget::reloadDatabaseFile()
|
||||
m_db->setReadOnly(isReadOnly);
|
||||
restoreGroupEntryFocus(groupBeforeReload, entryBeforeReload);
|
||||
} else {
|
||||
showMessage(
|
||||
tr("Could not open the new database file while attempting to autoreload.\nError: %1").arg(error),
|
||||
MessageWidget::Error);
|
||||
showMessage(tr("Could not open the new database file while attempting to autoreload.\nError: %1").arg(error),
|
||||
MessageWidget::Error);
|
||||
// Mark db as modified since existing data may differ from file or file was deleted
|
||||
m_db->markAsModified();
|
||||
}
|
||||
@ -1525,12 +1533,16 @@ bool DatabaseWidget::saveAs()
|
||||
while (true) {
|
||||
QString oldFilePath = m_db->filePath();
|
||||
if (!QFileInfo(oldFilePath).exists()) {
|
||||
oldFilePath = QDir::toNativeSeparators(config()->get("LastDir", QDir::homePath()).toString()
|
||||
+ "/" + tr("Passwords").append(".kdbx"));
|
||||
oldFilePath = QDir::toNativeSeparators(config()->get("LastDir", QDir::homePath()).toString() + "/"
|
||||
+ tr("Passwords").append(".kdbx"));
|
||||
}
|
||||
QString newFilePath = fileDialog()->getSaveFileName(
|
||||
this, tr("Save database as"), oldFilePath,
|
||||
tr("KeePass 2 Database").append(" (*.kdbx)"), nullptr, nullptr, "kdbx");
|
||||
QString newFilePath = fileDialog()->getSaveFileName(this,
|
||||
tr("Save database as"),
|
||||
oldFilePath,
|
||||
tr("KeePass 2 Database").append(" (*.kdbx)"),
|
||||
nullptr,
|
||||
nullptr,
|
||||
"kdbx");
|
||||
|
||||
if (!newFilePath.isEmpty()) {
|
||||
// Ensure we don't recurse back into this function
|
||||
@ -1550,8 +1562,10 @@ bool DatabaseWidget::saveAs()
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWidget::showMessage(const QString& text, MessageWidget::MessageType type,
|
||||
bool showClosebutton, int autoHideTimeout)
|
||||
void DatabaseWidget::showMessage(const QString& text,
|
||||
MessageWidget::MessageType type,
|
||||
bool showClosebutton,
|
||||
int autoHideTimeout)
|
||||
{
|
||||
m_messageWidget->setCloseButtonVisible(showClosebutton);
|
||||
m_messageWidget->showMessage(text, type, autoHideTimeout);
|
||||
@ -1580,11 +1594,12 @@ void DatabaseWidget::emptyRecycleBin()
|
||||
return;
|
||||
}
|
||||
|
||||
auto result = MessageBox::question(this,
|
||||
tr("Empty recycle bin?"),
|
||||
tr("Are you sure you want to permanently delete everything from your recycle bin?"),
|
||||
MessageBox::Empty | MessageBox::Cancel,
|
||||
MessageBox::Cancel);
|
||||
auto result =
|
||||
MessageBox::question(this,
|
||||
tr("Empty recycle bin?"),
|
||||
tr("Are you sure you want to permanently delete everything from your recycle bin?"),
|
||||
MessageBox::Empty | MessageBox::Cancel,
|
||||
MessageBox::Cancel);
|
||||
|
||||
if (result == MessageBox::Empty) {
|
||||
m_db->emptyRecycleBin();
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "DatabaseOpenDialog.h"
|
||||
#include "gui/entry/EntryModel.h"
|
||||
#include "gui/MessageWidget.h"
|
||||
#include "gui/csvImport/CsvImportWizard.h"
|
||||
#include "gui/entry/EntryModel.h"
|
||||
|
@ -30,8 +30,8 @@
|
||||
#include "gui/MessageBox.h"
|
||||
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
#include <QtNetwork>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QtNetwork>
|
||||
#endif
|
||||
|
||||
IconStruct::IconStruct()
|
||||
@ -417,7 +417,6 @@ void EditWidgetIcons::removeCustomIcon()
|
||||
int iconUseCount = entriesWithSameIcon.size() + groupsWithSameIcon.size();
|
||||
if (iconUseCount > 0) {
|
||||
|
||||
|
||||
auto result = MessageBox::question(this,
|
||||
tr("Confirm Delete"),
|
||||
tr("This icon is used by %n entry(s), and will be replaced "
|
||||
|
@ -18,9 +18,9 @@
|
||||
#include "EditWidgetProperties.h"
|
||||
#include "ui_EditWidgetProperties.h"
|
||||
|
||||
#include "MessageBox.h"
|
||||
#include "core/CustomData.h"
|
||||
#include "core/TimeInfo.h"
|
||||
#include "MessageBox.h"
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
@ -105,8 +105,8 @@ void EditWidgetProperties::update()
|
||||
m_ui->removeCustomDataButton->setEnabled(false);
|
||||
} else {
|
||||
for (const QString& key : m_customData->keys()) {
|
||||
m_customDataModel->appendRow(QList<QStandardItem*>() << new QStandardItem(key)
|
||||
<< new QStandardItem(m_customData->value(key)));
|
||||
m_customDataModel->appendRow(QList<QStandardItem*>()
|
||||
<< new QStandardItem(key) << new QStandardItem(m_customData->value(key)));
|
||||
}
|
||||
m_ui->removeCustomDataButton->setEnabled(!m_customData->isEmpty());
|
||||
}
|
||||
|
@ -30,8 +30,9 @@
|
||||
#include "keeshare/KeeShare.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
constexpr int GeneralTabIndex = 0;
|
||||
namespace
|
||||
{
|
||||
constexpr int GeneralTabIndex = 0;
|
||||
}
|
||||
|
||||
EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
|
||||
@ -208,7 +209,7 @@ void EntryPreviewWidget::updateEntryGeneralTab()
|
||||
|
||||
const TimeInfo entryTime = m_currentEntry->timeInfo();
|
||||
const QString expires =
|
||||
entryTime.expires() ? entryTime.expiryTime().toLocalTime().toString(Qt::DefaultLocaleShortDate) : tr("Never");
|
||||
entryTime.expires() ? entryTime.expiryTime().toLocalTime().toString(Qt::DefaultLocaleShortDate) : tr("Never");
|
||||
m_ui->entryExpirationLabel->setText(expires);
|
||||
}
|
||||
|
||||
@ -258,7 +259,7 @@ void EntryPreviewWidget::updateEntryAutotypeTab()
|
||||
const auto associations = autotypeAssociations->getAll();
|
||||
for (const auto& assoc : associations) {
|
||||
const QString sequence =
|
||||
assoc.sequence.isEmpty() ? m_currentEntry->effectiveAutoTypeSequence() : assoc.sequence;
|
||||
assoc.sequence.isEmpty() ? m_currentEntry->effectiveAutoTypeSequence() : assoc.sequence;
|
||||
items.append(new QTreeWidgetItem(m_ui->entryAutotypeTree, {assoc.window, sequence}));
|
||||
}
|
||||
|
||||
@ -284,7 +285,7 @@ void EntryPreviewWidget::updateGroupGeneralTab()
|
||||
|
||||
const TimeInfo groupTime = m_currentGroup->timeInfo();
|
||||
const QString expiresText =
|
||||
groupTime.expires() ? groupTime.expiryTime().toString(Qt::DefaultLocaleShortDate) : tr("Never");
|
||||
groupTime.expires() ? groupTime.expiryTime().toString(Qt::DefaultLocaleShortDate) : tr("Never");
|
||||
m_ui->groupExpirationLabel->setText(expiresText);
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,8 @@ QString FileDialog::getSaveFileName(QWidget* parent,
|
||||
}
|
||||
}
|
||||
|
||||
QString FileDialog::getExistingDirectory(QWidget* parent, const QString& caption, QString dir, QFileDialog::Options options)
|
||||
QString
|
||||
FileDialog::getExistingDirectory(QWidget* parent, const QString& caption, QString dir, QFileDialog::Options options)
|
||||
{
|
||||
if (!m_nextDirName.isEmpty()) {
|
||||
QString result = m_nextDirName;
|
||||
|
@ -29,12 +29,14 @@ public:
|
||||
const QString& filter = QString(),
|
||||
QString* selectedFilter = nullptr,
|
||||
QFileDialog::Options options = 0);
|
||||
|
||||
QStringList getOpenFileNames(QWidget* parent = nullptr,
|
||||
const QString& caption = QString(),
|
||||
QString dir = QString(),
|
||||
const QString& filter = QString(),
|
||||
QString* selectedFilter = nullptr,
|
||||
QFileDialog::Options options = 0);
|
||||
|
||||
QString getFileName(QWidget* parent = nullptr,
|
||||
const QString& caption = QString(),
|
||||
QString dir = QString(),
|
||||
@ -43,6 +45,7 @@ public:
|
||||
QFileDialog::Options options = 0,
|
||||
const QString& defaultExtension = QString(),
|
||||
const QString& defaultName = QString());
|
||||
|
||||
QString getSaveFileName(QWidget* parent = nullptr,
|
||||
const QString& caption = QString(),
|
||||
QString dir = QString(),
|
||||
@ -51,6 +54,7 @@ public:
|
||||
QFileDialog::Options options = 0,
|
||||
const QString& defaultExtension = QString(),
|
||||
const QString& defaultName = QString());
|
||||
|
||||
QString getExistingDirectory(QWidget* parent = nullptr,
|
||||
const QString& caption = QString(),
|
||||
QString dir = QString(),
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.8
|
||||
* Command line was: qdbusxml2cpp -c MainWindowAdaptor -a MainWindowAdaptor.h:MainWindowAdaptor.cpp org.keepassxc.MainWindow.xml
|
||||
* Command line was: qdbusxml2cpp -c MainWindowAdaptor -a MainWindowAdaptor.h:MainWindowAdaptor.cpp
|
||||
* org.keepassxc.MainWindow.xml
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||
*
|
||||
@ -9,10 +10,10 @@
|
||||
*/
|
||||
|
||||
#include "MainWindowAdaptor.h"
|
||||
#include <QtCore/QMetaObject>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QMetaObject>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
@ -21,7 +22,7 @@
|
||||
* Implementation of adaptor class MainWindowAdaptor
|
||||
*/
|
||||
|
||||
MainWindowAdaptor::MainWindowAdaptor(QObject *parent)
|
||||
MainWindowAdaptor::MainWindowAdaptor(QObject* parent)
|
||||
: QDBusAbstractAdaptor(parent)
|
||||
{
|
||||
setAutoRelaySignals(true);
|
||||
@ -46,18 +47,18 @@ void MainWindowAdaptor::lockAllDatabases()
|
||||
QMetaObject::invokeMethod(parent(), "lockAllDatabases");
|
||||
}
|
||||
|
||||
void MainWindowAdaptor::openDatabase(const QString &fileName)
|
||||
void MainWindowAdaptor::openDatabase(const QString& fileName)
|
||||
{
|
||||
QMetaObject::invokeMethod(parent(), "openDatabase", Q_ARG(QString, fileName));
|
||||
}
|
||||
|
||||
void MainWindowAdaptor::openDatabase(const QString &fileName, const QString &pw)
|
||||
void MainWindowAdaptor::openDatabase(const QString& fileName, const QString& pw)
|
||||
{
|
||||
QMetaObject::invokeMethod(parent(), "openDatabase", Q_ARG(QString, fileName), Q_ARG(QString, pw));
|
||||
}
|
||||
|
||||
void MainWindowAdaptor::openDatabase(const QString &fileName, const QString &pw, const QString &keyFile)
|
||||
void MainWindowAdaptor::openDatabase(const QString& fileName, const QString& pw, const QString& keyFile)
|
||||
{
|
||||
QMetaObject::invokeMethod(parent(), "openDatabase", Q_ARG(QString, fileName), Q_ARG(QString, pw), Q_ARG(QString, keyFile));
|
||||
QMetaObject::invokeMethod(
|
||||
parent(), "openDatabase", Q_ARG(QString, fileName), Q_ARG(QString, pw), Q_ARG(QString, keyFile));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.8
|
||||
* Command line was: qdbusxml2cpp -c MainWindowAdaptor -a MainWindowAdaptor.h:MainWindowAdaptor.cpp org.keepassxc.MainWindow.xml
|
||||
* Command line was: qdbusxml2cpp -c MainWindowAdaptor -a MainWindowAdaptor.h:MainWindowAdaptor.cpp
|
||||
* org.keepassxc.MainWindow.xml
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
|
||||
*
|
||||
@ -16,8 +17,8 @@
|
||||
#include <QtDBus/QtDBus>
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QByteArray;
|
||||
template<class T> class QList;
|
||||
template<class Key, class Value> class QMap;
|
||||
template <class T> class QList;
|
||||
template <class Key, class Value> class QMap;
|
||||
class QString;
|
||||
class QStringList;
|
||||
class QVariant;
|
||||
@ -26,31 +27,32 @@ QT_END_NAMESPACE
|
||||
/*
|
||||
* Adaptor class for interface org.keepassxc.MainWindow
|
||||
*/
|
||||
class MainWindowAdaptor: public QDBusAbstractAdaptor
|
||||
class MainWindowAdaptor : public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.keepassxc.MainWindow")
|
||||
Q_CLASSINFO("D-Bus Introspection", ""
|
||||
" <interface name=\"org.keepassxc.MainWindow\">\n"
|
||||
" <method name=\"openDatabase\">\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"pw\"/>\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"keyFile\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"openDatabase\">\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"pw\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"openDatabase\">\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"appExit\"/>\n"
|
||||
" <method name=\"lockAllDatabases\"/>\n"
|
||||
" <method name=\"closeAllDatabases\"/>\n"
|
||||
" </interface>\n"
|
||||
"")
|
||||
Q_CLASSINFO("D-Bus Introspection",
|
||||
""
|
||||
" <interface name=\"org.keepassxc.MainWindow\">\n"
|
||||
" <method name=\"openDatabase\">\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"pw\"/>\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"keyFile\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"openDatabase\">\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"pw\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"openDatabase\">\n"
|
||||
" <arg direction=\"in\" type=\"s\" name=\"fileName\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"appExit\"/>\n"
|
||||
" <method name=\"lockAllDatabases\"/>\n"
|
||||
" <method name=\"closeAllDatabases\"/>\n"
|
||||
" </interface>\n"
|
||||
"")
|
||||
public:
|
||||
MainWindowAdaptor(QObject *parent);
|
||||
MainWindowAdaptor(QObject* parent);
|
||||
virtual ~MainWindowAdaptor();
|
||||
|
||||
public:
|
||||
@ -58,9 +60,9 @@ public slots:
|
||||
void appExit();
|
||||
void closeAllDatabases();
|
||||
void lockAllDatabases();
|
||||
void openDatabase(const QString &fileName);
|
||||
void openDatabase(const QString &fileName, const QString &pw);
|
||||
void openDatabase(const QString &fileName, const QString &pw, const QString &keyFile);
|
||||
void openDatabase(const QString& fileName);
|
||||
void openDatabase(const QString& fileName, const QString& pw);
|
||||
void openDatabase(const QString& fileName, const QString& pw, const QString& keyFile);
|
||||
signals:
|
||||
};
|
||||
|
||||
|
@ -20,49 +20,45 @@
|
||||
|
||||
MessageBox::Button MessageBox::m_nextAnswer(MessageBox::NoButton);
|
||||
|
||||
QMap<QAbstractButton*, MessageBox::Button>
|
||||
MessageBox::m_addedButtonLookup =
|
||||
QMap<QAbstractButton*, MessageBox::Button> MessageBox::m_addedButtonLookup =
|
||||
QMap<QAbstractButton*, MessageBox::Button>();
|
||||
|
||||
QMap<MessageBox::Button, std::pair<QString, QMessageBox::ButtonRole>>
|
||||
MessageBox::m_buttonDefs =
|
||||
QMap<MessageBox::Button, std::pair<QString, QMessageBox::ButtonRole>> MessageBox::m_buttonDefs =
|
||||
QMap<MessageBox::Button, std::pair<QString, QMessageBox::ButtonRole>>();
|
||||
|
||||
void MessageBox::initializeButtonDefs()
|
||||
{
|
||||
m_buttonDefs =
|
||||
QMap<Button, std::pair<QString, QMessageBox::ButtonRole>>
|
||||
{
|
||||
// Reimplementation of Qt StandardButtons
|
||||
{Ok, {stdButtonText(QMessageBox::Ok), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Open, {stdButtonText(QMessageBox::Open), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Save, {stdButtonText(QMessageBox::Save), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Cancel, {stdButtonText(QMessageBox::Cancel), QMessageBox::ButtonRole::RejectRole}},
|
||||
{Close, {stdButtonText(QMessageBox::Close), QMessageBox::ButtonRole::RejectRole}},
|
||||
{Discard, {stdButtonText(QMessageBox::Discard), QMessageBox::ButtonRole::DestructiveRole}},
|
||||
{Apply, {stdButtonText(QMessageBox::Apply), QMessageBox::ButtonRole::ApplyRole}},
|
||||
{Reset, {stdButtonText(QMessageBox::Reset), QMessageBox::ButtonRole::ResetRole}},
|
||||
{RestoreDefaults, {stdButtonText(QMessageBox::RestoreDefaults), QMessageBox::ButtonRole::ResetRole}},
|
||||
{Help, {stdButtonText(QMessageBox::Help), QMessageBox::ButtonRole::HelpRole}},
|
||||
{SaveAll, {stdButtonText(QMessageBox::SaveAll), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Yes, {stdButtonText(QMessageBox::Yes), QMessageBox::ButtonRole::YesRole}},
|
||||
{YesToAll, {stdButtonText(QMessageBox::YesToAll), QMessageBox::ButtonRole::YesRole}},
|
||||
{No, {stdButtonText(QMessageBox::No), QMessageBox::ButtonRole::NoRole}},
|
||||
{NoToAll, {stdButtonText(QMessageBox::NoToAll), QMessageBox::ButtonRole::NoRole}},
|
||||
{Abort, {stdButtonText(QMessageBox::Abort), QMessageBox::ButtonRole::RejectRole}},
|
||||
{Retry, {stdButtonText(QMessageBox::Retry), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Ignore, {stdButtonText(QMessageBox::Ignore), QMessageBox::ButtonRole::AcceptRole}},
|
||||
m_buttonDefs = QMap<Button, std::pair<QString, QMessageBox::ButtonRole>>{
|
||||
// Reimplementation of Qt StandardButtons
|
||||
{Ok, {stdButtonText(QMessageBox::Ok), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Open, {stdButtonText(QMessageBox::Open), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Save, {stdButtonText(QMessageBox::Save), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Cancel, {stdButtonText(QMessageBox::Cancel), QMessageBox::ButtonRole::RejectRole}},
|
||||
{Close, {stdButtonText(QMessageBox::Close), QMessageBox::ButtonRole::RejectRole}},
|
||||
{Discard, {stdButtonText(QMessageBox::Discard), QMessageBox::ButtonRole::DestructiveRole}},
|
||||
{Apply, {stdButtonText(QMessageBox::Apply), QMessageBox::ButtonRole::ApplyRole}},
|
||||
{Reset, {stdButtonText(QMessageBox::Reset), QMessageBox::ButtonRole::ResetRole}},
|
||||
{RestoreDefaults, {stdButtonText(QMessageBox::RestoreDefaults), QMessageBox::ButtonRole::ResetRole}},
|
||||
{Help, {stdButtonText(QMessageBox::Help), QMessageBox::ButtonRole::HelpRole}},
|
||||
{SaveAll, {stdButtonText(QMessageBox::SaveAll), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Yes, {stdButtonText(QMessageBox::Yes), QMessageBox::ButtonRole::YesRole}},
|
||||
{YesToAll, {stdButtonText(QMessageBox::YesToAll), QMessageBox::ButtonRole::YesRole}},
|
||||
{No, {stdButtonText(QMessageBox::No), QMessageBox::ButtonRole::NoRole}},
|
||||
{NoToAll, {stdButtonText(QMessageBox::NoToAll), QMessageBox::ButtonRole::NoRole}},
|
||||
{Abort, {stdButtonText(QMessageBox::Abort), QMessageBox::ButtonRole::RejectRole}},
|
||||
{Retry, {stdButtonText(QMessageBox::Retry), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Ignore, {stdButtonText(QMessageBox::Ignore), QMessageBox::ButtonRole::AcceptRole}},
|
||||
|
||||
// KeePassXC Buttons
|
||||
{Overwrite, {QMessageBox::tr("Overwrite"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Delete, {QMessageBox::tr("Delete"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Move, {QMessageBox::tr("Move"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Empty, {QMessageBox::tr("Empty"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Remove, {QMessageBox::tr("Remove"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Skip, {QMessageBox::tr("Skip"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Disable, {QMessageBox::tr("Disable"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Merge, {QMessageBox::tr("Merge"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
};
|
||||
// KeePassXC Buttons
|
||||
{Overwrite, {QMessageBox::tr("Overwrite"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Delete, {QMessageBox::tr("Delete"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Move, {QMessageBox::tr("Move"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Empty, {QMessageBox::tr("Empty"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Remove, {QMessageBox::tr("Remove"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Skip, {QMessageBox::tr("Skip"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Disable, {QMessageBox::tr("Disable"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
{Merge, {QMessageBox::tr("Merge"), QMessageBox::ButtonRole::AcceptRole}},
|
||||
};
|
||||
}
|
||||
|
||||
QString MessageBox::stdButtonText(QMessageBox::StandardButton button)
|
||||
|
@ -19,52 +19,54 @@
|
||||
#ifndef KEEPASSX_MESSAGEBOX_H
|
||||
#define KEEPASSX_MESSAGEBOX_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QMap>
|
||||
|
||||
class MessageBox
|
||||
{
|
||||
public:
|
||||
enum Button : uint64_t {
|
||||
enum Button : uint64_t
|
||||
{
|
||||
// Reimplementation of Qt StandardButtons
|
||||
NoButton = 0,
|
||||
Ok = 1 << 1,
|
||||
Open = 1 << 2,
|
||||
Save = 1 << 3,
|
||||
Cancel = 1 << 4,
|
||||
Close = 1 << 5,
|
||||
Discard = 1 << 6,
|
||||
Apply = 1 << 7,
|
||||
Reset = 1 << 8,
|
||||
NoButton = 0,
|
||||
Ok = 1 << 1,
|
||||
Open = 1 << 2,
|
||||
Save = 1 << 3,
|
||||
Cancel = 1 << 4,
|
||||
Close = 1 << 5,
|
||||
Discard = 1 << 6,
|
||||
Apply = 1 << 7,
|
||||
Reset = 1 << 8,
|
||||
RestoreDefaults = 1 << 9,
|
||||
Help = 1 << 10,
|
||||
SaveAll = 1 << 11,
|
||||
Yes = 1 << 12,
|
||||
YesToAll = 1 << 13,
|
||||
No = 1 << 14,
|
||||
NoToAll = 1 << 15,
|
||||
Abort = 1 << 16,
|
||||
Retry = 1 << 17,
|
||||
Ignore = 1 << 18,
|
||||
Help = 1 << 10,
|
||||
SaveAll = 1 << 11,
|
||||
Yes = 1 << 12,
|
||||
YesToAll = 1 << 13,
|
||||
No = 1 << 14,
|
||||
NoToAll = 1 << 15,
|
||||
Abort = 1 << 16,
|
||||
Retry = 1 << 17,
|
||||
Ignore = 1 << 18,
|
||||
|
||||
// KeePassXC Buttons
|
||||
Overwrite = 1 << 19,
|
||||
Delete = 1 << 20,
|
||||
Move = 1 << 21,
|
||||
Empty = 1 << 22,
|
||||
Remove = 1 << 23,
|
||||
Skip = 1 << 24,
|
||||
Disable = 1 << 25,
|
||||
Merge = 1 << 26,
|
||||
Overwrite = 1 << 19,
|
||||
Delete = 1 << 20,
|
||||
Move = 1 << 21,
|
||||
Empty = 1 << 22,
|
||||
Remove = 1 << 23,
|
||||
Skip = 1 << 24,
|
||||
Disable = 1 << 25,
|
||||
Merge = 1 << 26,
|
||||
|
||||
// Internal loop markers. Update Last when new KeePassXC button is added
|
||||
First = Ok,
|
||||
Last = Merge,
|
||||
};
|
||||
|
||||
enum Action {
|
||||
None = 0,
|
||||
enum Action
|
||||
{
|
||||
None = 0,
|
||||
Raise = 1,
|
||||
};
|
||||
|
||||
@ -102,7 +104,7 @@ private:
|
||||
static Button m_nextAnswer;
|
||||
static QMap<QAbstractButton*, Button> m_addedButtonLookup;
|
||||
static QMap<Button, std::pair<QString, QMessageBox::ButtonRole>> m_buttonDefs;
|
||||
|
||||
|
||||
static Button messageBox(QWidget* parent,
|
||||
QMessageBox::Icon icon,
|
||||
const QString& title,
|
||||
@ -112,9 +114,6 @@ private:
|
||||
Action action = MessageBox::None);
|
||||
|
||||
static QString stdButtonText(QMessageBox::StandardButton button);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_MESSAGEBOX_H
|
||||
|
@ -17,8 +17,8 @@
|
||||
*/
|
||||
|
||||
#include "SearchWidget.h"
|
||||
#include "ui_SearchWidget.h"
|
||||
#include "ui_SearchHelpWidget.h"
|
||||
#include "ui_SearchWidget.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
@ -38,7 +38,7 @@ SearchWidget::SearchWidget(QWidget* parent)
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_helpWidget = new PopupHelpWidget(m_ui->searchEdit);
|
||||
m_helpWidget->setOffset(QPoint(0,1));
|
||||
m_helpWidget->setOffset(QPoint(0, 1));
|
||||
Ui::SearchHelpWidget helpUi;
|
||||
helpUi.setupUi(m_helpWidget);
|
||||
|
||||
@ -56,7 +56,7 @@ SearchWidget::SearchWidget(QWidget* parent)
|
||||
new QShortcut(Qt::Key_Escape, m_ui->searchEdit, SLOT(clear()), nullptr, Qt::ApplicationShortcut);
|
||||
|
||||
m_ui->searchEdit->setPlaceholderText(tr("Search (%1)...", "Search placeholder text, %1 is the keyboard shortcut")
|
||||
.arg(QKeySequence(QKeySequence::Find).toString(QKeySequence::NativeText)));
|
||||
.arg(QKeySequence(QKeySequence::Find).toString(QKeySequence::NativeText)));
|
||||
m_ui->searchEdit->installEventFilter(this);
|
||||
|
||||
QMenu* searchMenu = new QMenu();
|
||||
|
@ -16,9 +16,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include "WelcomeWidget.h"
|
||||
#include "ui_WelcomeWidget.h"
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "config-keepassx.h"
|
||||
#include "core/Config.h"
|
||||
@ -78,7 +78,8 @@ void WelcomeWidget::refreshLastDatabases()
|
||||
}
|
||||
}
|
||||
|
||||
void WelcomeWidget::keyPressEvent(QKeyEvent *event) {
|
||||
void WelcomeWidget::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (m_ui->recentListWidget->hasFocus() && (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) {
|
||||
openDatabaseFromFile(m_ui->recentListWidget->currentItem());
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ signals:
|
||||
void importCsv();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void openDatabaseFromFile(QListWidgetItem* item);
|
||||
|
@ -29,18 +29,18 @@
|
||||
#include "keeshare/DatabaseSettingsPageKeeShare.h"
|
||||
#endif
|
||||
|
||||
#include "core/Global.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/FilePath.h"
|
||||
#include "core/Global.h"
|
||||
#include "touchid/TouchID.h"
|
||||
|
||||
class DatabaseSettingsDialog::ExtraPage
|
||||
{
|
||||
public:
|
||||
ExtraPage(IDatabaseSettingsPage* page, QWidget* widget)
|
||||
: settingsPage(page)
|
||||
, widget(widget)
|
||||
: settingsPage(page)
|
||||
, widget(widget)
|
||||
{
|
||||
}
|
||||
void loadSettings(QSharedPointer<Database> db) const
|
||||
@ -51,6 +51,7 @@ public:
|
||||
{
|
||||
settingsPage->saveSettings(widget);
|
||||
}
|
||||
|
||||
private:
|
||||
QSharedPointer<IDatabaseSettingsPage> settingsPage;
|
||||
QWidget* widget;
|
||||
|
@ -175,9 +175,9 @@ void DatabaseSettingsWidgetBrowser::removeSharedEncryptionKeys()
|
||||
|
||||
if (keysToRemove.isEmpty()) {
|
||||
MessageBox::information(this,
|
||||
tr("KeePassXC: No keys found"),
|
||||
tr("No shared encryption keys found in KeePassXC settings."),
|
||||
MessageBox::Ok);
|
||||
tr("KeePassXC: No keys found"),
|
||||
tr("No shared encryption keys found in KeePassXC settings."),
|
||||
MessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -187,9 +187,9 @@ void DatabaseSettingsWidgetBrowser::removeSharedEncryptionKeys()
|
||||
|
||||
const int count = keysToRemove.count();
|
||||
MessageBox::information(this,
|
||||
tr("KeePassXC: Removed keys from database"),
|
||||
tr("Successfully removed %n encryption key(s) from KeePassXC settings.", "", count),
|
||||
MessageBox::Ok);
|
||||
tr("KeePassXC: Removed keys from database"),
|
||||
tr("Successfully removed %n encryption key(s) from KeePassXC settings.", "", count),
|
||||
MessageBox::Ok);
|
||||
}
|
||||
|
||||
void DatabaseSettingsWidgetBrowser::removeStoredPermissions()
|
||||
@ -227,14 +227,14 @@ void DatabaseSettingsWidgetBrowser::removeStoredPermissions()
|
||||
|
||||
if (counter > 0) {
|
||||
MessageBox::information(this,
|
||||
tr("KeePassXC: Removed permissions"),
|
||||
tr("Successfully removed permissions from %n entry(s).", "", counter),
|
||||
MessageBox::Ok);
|
||||
tr("KeePassXC: Removed permissions"),
|
||||
tr("Successfully removed permissions from %n entry(s).", "", counter),
|
||||
MessageBox::Ok);
|
||||
} else {
|
||||
MessageBox::information(this,
|
||||
tr("KeePassXC: No entry with permissions found!"),
|
||||
tr("The active database does not contain an entry with permissions."),
|
||||
MessageBox::Ok);
|
||||
tr("KeePassXC: No entry with permissions found!"),
|
||||
tr("The active database does not contain an entry with permissions."),
|
||||
MessageBox::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,6 @@ void EditEntryWidget::setupMain()
|
||||
m_mainUi->fetchFaviconButton->setVisible(false);
|
||||
#endif
|
||||
|
||||
|
||||
connect(m_mainUi->togglePasswordButton, SIGNAL(toggled(bool)), m_mainUi->passwordEdit, SLOT(setShowPassword(bool)));
|
||||
connect(m_mainUi->togglePasswordGeneratorButton, SIGNAL(toggled(bool)), SLOT(togglePasswordGeneratorButton(bool)));
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
@ -309,8 +308,8 @@ void EditEntryWidget::setupEntryUpdate()
|
||||
connect(m_sshAgentUi->externalFileEdit, SIGNAL(textChanged(QString)), this, SLOT(setUnsavedChanges()));
|
||||
connect(m_sshAgentUi->addKeyToAgentCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setUnsavedChanges()));
|
||||
connect(m_sshAgentUi->removeKeyFromAgentCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setUnsavedChanges()));
|
||||
connect(m_sshAgentUi->requireUserConfirmationCheckBox, SIGNAL(stateChanged(int)),
|
||||
this, SLOT(setUnsavedChanges()));
|
||||
connect(
|
||||
m_sshAgentUi->requireUserConfirmationCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setUnsavedChanges()));
|
||||
connect(m_sshAgentUi->lifetimeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setUnsavedChanges()));
|
||||
connect(m_sshAgentUi->lifetimeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setUnsavedChanges()));
|
||||
}
|
||||
@ -370,7 +369,9 @@ void EditEntryWidget::setupSSHAgent()
|
||||
connect(m_sshAgentUi->decryptButton, SIGNAL(clicked()), SLOT(decryptPrivateKey()));
|
||||
connect(m_sshAgentUi->copyToClipboardButton, SIGNAL(clicked()), SLOT(copyPublicKey()));
|
||||
|
||||
connect(m_advancedUi->attachmentsWidget->entryAttachments(), SIGNAL(entryAttachmentsModified()), SLOT(updateSSHAgentAttachments()));
|
||||
connect(m_advancedUi->attachmentsWidget->entryAttachments(),
|
||||
SIGNAL(entryAttachmentsModified()),
|
||||
SLOT(updateSSHAgentAttachments()));
|
||||
|
||||
addPage(tr("SSH Agent"), FilePath::instance()->icon("apps", "utilities-terminal"), m_sshAgentWidget);
|
||||
}
|
||||
@ -591,8 +592,8 @@ void EditEntryWidget::addKeyToAgent()
|
||||
lifetime = m_sshAgentUi->lifetimeSpinBox->value();
|
||||
}
|
||||
|
||||
if (!SSHAgent::instance()->addIdentity(key, m_sshAgentUi->removeKeyFromAgentCheckBox->isChecked(),
|
||||
static_cast<quint32>(lifetime), confirm)) {
|
||||
if (!SSHAgent::instance()->addIdentity(
|
||||
key, m_sshAgentUi->removeKeyFromAgentCheckBox->isChecked(), static_cast<quint32>(lifetime), confirm)) {
|
||||
showMessage(SSHAgent::instance()->errorString(), MessageWidget::Error);
|
||||
return;
|
||||
}
|
||||
@ -662,7 +663,11 @@ QString EditEntryWidget::entryTitle() const
|
||||
}
|
||||
}
|
||||
|
||||
void EditEntryWidget::loadEntry(Entry* entry, bool create, bool history, const QString& parentName, QSharedPointer<Database> database)
|
||||
void EditEntryWidget::loadEntry(Entry* entry,
|
||||
bool create,
|
||||
bool history,
|
||||
const QString& parentName,
|
||||
QSharedPointer<Database> database)
|
||||
{
|
||||
m_entry = entry;
|
||||
m_db = std::move(database);
|
||||
|
@ -21,9 +21,8 @@
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QModelIndex>
|
||||
#include <QScopedPointer>
|
||||
#include <QButtonGroup>
|
||||
#include <QPointer>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "config-keepassx.h"
|
||||
#include "gui/EditWidget.h"
|
||||
@ -64,8 +63,8 @@ public:
|
||||
explicit EditEntryWidget(QWidget* parent = nullptr);
|
||||
~EditEntryWidget() override;
|
||||
|
||||
void loadEntry(Entry* entry, bool create, bool history, const QString& parentName,
|
||||
QSharedPointer<Database> database);
|
||||
void
|
||||
loadEntry(Entry* entry, bool create, bool history, const QString& parentName, QSharedPointer<Database> database);
|
||||
|
||||
QString entryTitle() const;
|
||||
void clear();
|
||||
|
@ -223,11 +223,8 @@ void EntryAttachmentsWidget::saveSelectedAttachments()
|
||||
const QString questionText(
|
||||
tr("Are you sure you want to overwrite the existing file \"%1\" with the attachment?"));
|
||||
|
||||
auto result = MessageBox::question(this,
|
||||
tr("Confirm overwrite"),
|
||||
questionText.arg(filename),
|
||||
buttons,
|
||||
MessageBox::Cancel);
|
||||
auto result = MessageBox::question(
|
||||
this, tr("Confirm overwrite"), questionText.arg(filename), buttons, MessageBox::Cancel);
|
||||
|
||||
if (result == MessageBox::Skip) {
|
||||
continue;
|
||||
|
@ -469,7 +469,7 @@ bool EntryModel::isUsernamesHidden() const
|
||||
void EntryModel::setUsernamesHidden(bool hide)
|
||||
{
|
||||
m_hideUsernames = hide;
|
||||
emit dataChanged(index(0, 0), index(rowCount()-1, columnCount() - 1));
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||
emit usernamesHiddenChanged();
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ bool EntryModel::isPasswordsHidden() const
|
||||
void EntryModel::setPasswordsHidden(bool hide)
|
||||
{
|
||||
m_hidePasswords = hide;
|
||||
emit dataChanged(index(0, 0), index(rowCount()-1, columnCount() - 1));
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||
emit passwordsHiddenChanged();
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@ class EditGroupWidget::ExtraPage
|
||||
{
|
||||
public:
|
||||
ExtraPage(IEditGroupPage* page, QWidget* widget)
|
||||
: editPage(page)
|
||||
, widget(widget)
|
||||
: editPage(page)
|
||||
, widget(widget)
|
||||
{
|
||||
}
|
||||
|
||||
@ -52,12 +52,12 @@ private:
|
||||
};
|
||||
|
||||
EditGroupWidget::EditGroupWidget(QWidget* parent)
|
||||
: EditWidget(parent)
|
||||
, m_mainUi(new Ui::EditGroupWidgetMain())
|
||||
, m_editGroupWidgetMain(new QWidget())
|
||||
, m_editGroupWidgetIcons(new EditWidgetIcons())
|
||||
, m_editWidgetProperties(new EditWidgetProperties())
|
||||
, m_group(nullptr)
|
||||
: EditWidget(parent)
|
||||
, m_mainUi(new Ui::EditGroupWidgetMain())
|
||||
, m_editGroupWidgetMain(new QWidget())
|
||||
, m_editGroupWidgetIcons(new EditWidgetIcons())
|
||||
, m_editWidgetProperties(new EditWidgetProperties())
|
||||
, m_group(nullptr)
|
||||
{
|
||||
m_mainUi->setupUi(m_editGroupWidgetMain);
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
#ifndef KEEPASSXC_POPUPHELPWIDGET_H
|
||||
#define KEEPASSXC_POPUPHELPWIDGET_H
|
||||
|
||||
#include <QPointer>
|
||||
#include <QFrame>
|
||||
#include <QPointer>
|
||||
|
||||
class PopupHelpWidget : public QFrame
|
||||
{
|
||||
@ -44,5 +44,4 @@ private:
|
||||
Qt::Corner m_corner;
|
||||
};
|
||||
|
||||
|
||||
#endif //KEEPASSXC_POPUPHELPWIDGET_H
|
||||
#endif // KEEPASSXC_POPUPHELPWIDGET_H
|
||||
|
@ -34,7 +34,7 @@ NewDatabaseWizard::NewDatabaseWizard(QWidget* parent)
|
||||
{
|
||||
setWizardStyle(QWizard::MacStyle);
|
||||
setOption(QWizard::WizardOption::HaveHelpButton, false);
|
||||
setOption(QWizard::WizardOption::NoDefaultButton, false); // Needed for macOS
|
||||
setOption(QWizard::WizardOption::NoDefaultButton, false); // Needed for macOS
|
||||
|
||||
// clang-format off
|
||||
m_pages << new NewDatabaseWizardPageMetaData()
|
||||
|
@ -367,8 +367,8 @@ ShareObserver::Result ShareObserver::importSingedContainerInto(const KeeShareSet
|
||||
case UntrustedForever:
|
||||
case TrustedForever: {
|
||||
bool found = false;
|
||||
const auto trusted = trust.first == TrustedForever ? KeeShareSettings::Trust::Trusted
|
||||
: KeeShareSettings::Trust::Untrusted;
|
||||
const auto trusted =
|
||||
trust.first == TrustedForever ? KeeShareSettings::Trust::Trusted : KeeShareSettings::Trust::Untrusted;
|
||||
for (KeeShareSettings::ScopedCertificate& scopedCertificate : foreign.certificates) {
|
||||
if (scopedCertificate.certificate.key == trust.second.key && scopedCertificate.path == reference.path) {
|
||||
scopedCertificate.certificate.signer = trust.second.signer;
|
||||
@ -454,8 +454,8 @@ ShareObserver::Result ShareObserver::importUnsignedContainerInto(const KeeShareS
|
||||
case UntrustedForever:
|
||||
case TrustedForever: {
|
||||
bool found = false;
|
||||
const auto trusted = trust.first == TrustedForever ? KeeShareSettings::Trust::Trusted
|
||||
: KeeShareSettings::Trust::Untrusted;
|
||||
const auto trusted =
|
||||
trust.first == TrustedForever ? KeeShareSettings::Trust::Trusted : KeeShareSettings::Trust::Untrusted;
|
||||
for (KeeShareSettings::ScopedCertificate& scopedCertificate : foreign.certificates) {
|
||||
if (scopedCertificate.certificate.key == trust.second.key && scopedCertificate.path == reference.path) {
|
||||
scopedCertificate.certificate.signer = trust.second.signer;
|
||||
|
@ -67,9 +67,8 @@ bool YkChallengeResponseKey::challenge(const QByteArray& challenge, unsigned int
|
||||
emit userInteractionRequired();
|
||||
}
|
||||
|
||||
auto result = AsyncTask::runAndWaitForFuture([this, challenge]() {
|
||||
return YubiKey::instance()->challenge(m_slot, true, challenge, m_key);
|
||||
});
|
||||
auto result = AsyncTask::runAndWaitForFuture(
|
||||
[this, challenge]() { return YubiKey::instance()->challenge(m_slot, true, challenge, m_key); });
|
||||
|
||||
if (m_blocking) {
|
||||
emit userConfirmed();
|
||||
|
@ -211,7 +211,7 @@ YubiKey::ChallengeResult YubiKey::challenge(int slot, bool mayBlock, const QByte
|
||||
*/
|
||||
|
||||
if (yk_errno == YK_EUSBERR) {
|
||||
qWarning("USB error: %s", yk_usb_strerror());
|
||||
qWarning("USB error: %s", yk_usb_strerror());
|
||||
} else {
|
||||
qWarning("YubiKey core error: %s", yk_strerror(yk_errno));
|
||||
}
|
||||
|
@ -18,10 +18,10 @@
|
||||
|
||||
#include "SSHAgent.h"
|
||||
|
||||
#include "crypto/ssh/OpenSSHKey.h"
|
||||
#include "crypto/ssh/BinaryStream.h"
|
||||
#include "sshagent/KeeAgentSettings.h"
|
||||
#include "core/Config.h"
|
||||
#include "crypto/ssh/BinaryStream.h"
|
||||
#include "crypto/ssh/OpenSSHKey.h"
|
||||
#include "sshagent/KeeAgentSettings.h"
|
||||
|
||||
#include <QtNetwork>
|
||||
|
||||
@ -371,8 +371,8 @@ void SSHAgent::databaseModeChanged()
|
||||
lifetime = static_cast<quint32>(settings.lifetimeConstraintDuration());
|
||||
}
|
||||
|
||||
if (!addIdentity(key, settings.removeAtDatabaseClose(),
|
||||
lifetime, settings.useConfirmConstraintWhenAdding())) {
|
||||
if (!addIdentity(
|
||||
key, settings.removeAtDatabaseClose(), lifetime, settings.useConfirmConstraintWhenAdding())) {
|
||||
emit error(m_error);
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@
|
||||
#ifndef KEEPASSXC_SSHAGENT_H
|
||||
#define KEEPASSXC_SSHAGENT_H
|
||||
|
||||
#include <QList>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QtCore>
|
||||
|
||||
#include "gui/DatabaseWidget.h"
|
||||
#include "crypto/ssh/OpenSSHKey.h"
|
||||
#include "gui/DatabaseWidget.h"
|
||||
|
||||
class SSHAgent : public QObject
|
||||
{
|
||||
|
@ -174,7 +174,7 @@ void TestCli::testAdd()
|
||||
"/newuser-entry"});
|
||||
m_stderrFile->reset();
|
||||
m_stdoutFile->reset();
|
||||
m_stdoutFile->readLine(); // skip password prompt
|
||||
m_stdoutFile->readLine(); // skip password prompt
|
||||
QCOMPARE(m_stdoutFile->readAll(), QByteArray("Successfully added entry newuser-entry.\n"));
|
||||
|
||||
auto db = readTestDatabase();
|
||||
@ -284,7 +284,8 @@ void TestCli::testClip()
|
||||
|
||||
// TOTP with timeout
|
||||
Utils::Test::setNextPassword("a");
|
||||
future = QtConcurrent::run(&clipCmd, &Clip::execute, QStringList{"clip", m_dbFile->fileName(), "/Sample Entry", "1", "-t"});
|
||||
future = QtConcurrent::run(
|
||||
&clipCmd, &Clip::execute, QStringList{"clip", m_dbFile->fileName(), "/Sample Entry", "1", "-t"});
|
||||
|
||||
QTRY_VERIFY_WITH_TIMEOUT(isTOTP(clipboard->text()), 500);
|
||||
QTRY_COMPARE_WITH_TIMEOUT(clipboard->text(), QString(""), 1500);
|
||||
@ -314,7 +315,8 @@ void TestCli::testCreate()
|
||||
m_stderrFile->reset();
|
||||
m_stdoutFile->reset();
|
||||
|
||||
QCOMPARE(m_stdoutFile->readLine(), QByteArray("Insert password to encrypt database (Press enter to leave blank): \n"));
|
||||
QCOMPARE(m_stdoutFile->readLine(),
|
||||
QByteArray("Insert password to encrypt database (Press enter to leave blank): \n"));
|
||||
QCOMPARE(m_stdoutFile->readLine(), QByteArray("Successfully created new database.\n"));
|
||||
|
||||
Utils::Test::setNextPassword("a");
|
||||
@ -332,7 +334,6 @@ void TestCli::testCreate()
|
||||
QString errorMessage = QString("File " + databaseFilename + " already exists.\n");
|
||||
QCOMPARE(m_stderrFile->readAll(), errorMessage.toUtf8());
|
||||
|
||||
|
||||
// Testing with keyfile creation
|
||||
QString databaseFilename2 = testDir->path() + "testCreate2.kdbx";
|
||||
QString keyfilePath = testDir->path() + "keyfile.txt";
|
||||
@ -343,14 +344,14 @@ void TestCli::testCreate()
|
||||
m_stdoutFile->seek(pos);
|
||||
m_stderrFile->seek(errPos);
|
||||
|
||||
QCOMPARE(m_stdoutFile->readLine(), QByteArray("Insert password to encrypt database (Press enter to leave blank): \n"));
|
||||
QCOMPARE(m_stdoutFile->readLine(),
|
||||
QByteArray("Insert password to encrypt database (Press enter to leave blank): \n"));
|
||||
QCOMPARE(m_stdoutFile->readLine(), QByteArray("Successfully created new database.\n"));
|
||||
|
||||
Utils::Test::setNextPassword("a");
|
||||
auto db2 = QSharedPointer<Database>(Utils::unlockDatabase(databaseFilename2, keyfilePath, Utils::DEVNULL));
|
||||
QVERIFY(db2);
|
||||
|
||||
|
||||
// Testing with existing keyfile
|
||||
QString databaseFilename3 = testDir->path() + "testCreate3.kdbx";
|
||||
pos = m_stdoutFile->pos();
|
||||
@ -360,7 +361,8 @@ void TestCli::testCreate()
|
||||
m_stdoutFile->seek(pos);
|
||||
m_stderrFile->seek(errPos);
|
||||
|
||||
QCOMPARE(m_stdoutFile->readLine(), QByteArray("Insert password to encrypt database (Press enter to leave blank): \n"));
|
||||
QCOMPARE(m_stdoutFile->readLine(),
|
||||
QByteArray("Insert password to encrypt database (Press enter to leave blank): \n"));
|
||||
QCOMPARE(m_stdoutFile->readLine(), QByteArray("Successfully created new database.\n"));
|
||||
|
||||
Utils::Test::setNextPassword("a");
|
||||
@ -681,14 +683,14 @@ void TestCli::testList()
|
||||
Utils::Test::setNextPassword("a");
|
||||
listCmd.execute({"ls", "-q", m_dbFile->fileName()});
|
||||
m_stdoutFile->seek(pos);
|
||||
QCOMPARE(m_stdoutFile->readAll(), QByteArray("Sample Entry\n"
|
||||
"General/\n"
|
||||
"Windows/\n"
|
||||
"Network/\n"
|
||||
"Internet/\n"
|
||||
"eMail/\n"
|
||||
"Homebanking/\n"));
|
||||
|
||||
QCOMPARE(m_stdoutFile->readAll(),
|
||||
QByteArray("Sample Entry\n"
|
||||
"General/\n"
|
||||
"Windows/\n"
|
||||
"Network/\n"
|
||||
"Internet/\n"
|
||||
"eMail/\n"
|
||||
"Homebanking/\n"));
|
||||
|
||||
pos = m_stdoutFile->pos();
|
||||
Utils::Test::setNextPassword("a");
|
||||
@ -1018,11 +1020,12 @@ void TestCli::testShow()
|
||||
Utils::Test::setNextPassword("a");
|
||||
showCmd.execute({"show", m_dbFile->fileName(), "-q", "/Sample Entry"});
|
||||
m_stdoutFile->seek(pos);
|
||||
QCOMPARE(m_stdoutFile->readAll(), QByteArray("Title: Sample Entry\n"
|
||||
"UserName: User Name\n"
|
||||
"Password: Password\n"
|
||||
"URL: http://www.somesite.com/\n"
|
||||
"Notes: Notes\n"));
|
||||
QCOMPARE(m_stdoutFile->readAll(),
|
||||
QByteArray("Title: Sample Entry\n"
|
||||
"UserName: User Name\n"
|
||||
"Password: Password\n"
|
||||
"URL: http://www.somesite.com/\n"
|
||||
"Notes: Notes\n"));
|
||||
|
||||
pos = m_stdoutFile->pos();
|
||||
Utils::Test::setNextPassword("a");
|
||||
@ -1053,14 +1056,14 @@ void TestCli::testShow()
|
||||
Utils::Test::setNextPassword("a");
|
||||
showCmd.execute({"show", "-t", m_dbFile->fileName(), "/Sample Entry"});
|
||||
m_stdoutFile->seek(pos);
|
||||
m_stdoutFile->readLine(); // skip password prompt
|
||||
m_stdoutFile->readLine(); // skip password prompt
|
||||
QVERIFY(isTOTP(m_stdoutFile->readAll()));
|
||||
|
||||
pos = m_stdoutFile->pos();
|
||||
Utils::Test::setNextPassword("a");
|
||||
showCmd.execute({"show", "-a", "Title", m_dbFile->fileName(), "--totp", "/Sample Entry"});
|
||||
m_stdoutFile->seek(pos);
|
||||
m_stdoutFile->readLine(); // skip password prompt
|
||||
m_stdoutFile->readLine(); // skip password prompt
|
||||
QCOMPARE(m_stdoutFile->readLine(), QByteArray("Sample Entry\n"));
|
||||
QVERIFY(isTOTP(m_stdoutFile->readAll()));
|
||||
|
||||
@ -1069,7 +1072,7 @@ void TestCli::testShow()
|
||||
Utils::Test::setNextPassword("a");
|
||||
showCmd.execute({"show", m_dbFile2->fileName(), "--totp", "/Sample Entry"});
|
||||
m_stdoutFile->seek(pos);
|
||||
m_stdoutFile->readLine(); // skip password prompt
|
||||
m_stdoutFile->readLine(); // skip password prompt
|
||||
m_stderrFile->seek(posErr);
|
||||
QCOMPARE(m_stdoutFile->readAll(), QByteArray(""));
|
||||
QCOMPARE(m_stderrFile->readAll(), QByteArray("Entry with path /Sample Entry has no TOTP set up.\n"));
|
||||
|
@ -63,9 +63,9 @@ void TestCsvExporter::testExport()
|
||||
m_csvExporter->exportDatabase(&buffer, m_db);
|
||||
|
||||
QString expectedResult = QString()
|
||||
.append(ExpectedHeaderLine)
|
||||
.append("\"Root/Test Group Name\",\"Test Entry Title\",\"Test Username\",\"Test "
|
||||
"Password\",\"http://test.url\",\"Test Notes\"\n");
|
||||
.append(ExpectedHeaderLine)
|
||||
.append("\"Root/Test Group Name\",\"Test Entry Title\",\"Test Username\",\"Test "
|
||||
"Password\",\"http://test.url\",\"Test Notes\"\n");
|
||||
|
||||
QCOMPARE(QString::fromUtf8(buffer.buffer().constData()), expectedResult);
|
||||
}
|
||||
|
@ -177,7 +177,8 @@ void TestEntrySearcher::testAllAttributesAreSearched()
|
||||
void TestEntrySearcher::testSearchTermParser()
|
||||
{
|
||||
// Test standard search terms
|
||||
auto terms = m_entrySearcher.parseSearchTerms("-test \"quoted \\\"string\\\"\" user:user pass:\"test me\" noquote ");
|
||||
auto terms =
|
||||
m_entrySearcher.parseSearchTerms("-test \"quoted \\\"string\\\"\" user:user pass:\"test me\" noquote ");
|
||||
|
||||
QCOMPARE(terms.length(), 5);
|
||||
|
||||
|
@ -35,7 +35,8 @@ protected:
|
||||
void initTestCaseImpl() override;
|
||||
|
||||
QSharedPointer<Database> readXml(QBuffer* buf, bool strictMode, bool& hasError, QString& errorString) override;
|
||||
QSharedPointer<Database> readXml(const QString& path, bool strictMode, bool& hasError, QString& errorString) override;
|
||||
QSharedPointer<Database>
|
||||
readXml(const QString& path, bool strictMode, bool& hasError, QString& errorString) override;
|
||||
void writeXml(QBuffer* buf, Database* db, bool& hasError, QString& errorString) override;
|
||||
|
||||
void readKdbx(QIODevice* device,
|
||||
|
@ -36,7 +36,8 @@ protected:
|
||||
void initTestCaseImpl() override;
|
||||
|
||||
QSharedPointer<Database> readXml(QBuffer* buf, bool strictMode, bool& hasError, QString& errorString) override;
|
||||
QSharedPointer<Database> readXml(const QString& path, bool strictMode, bool& hasError, QString& errorString) override;
|
||||
QSharedPointer<Database>
|
||||
readXml(const QString& path, bool strictMode, bool& hasError, QString& errorString) override;
|
||||
void writeXml(QBuffer* buf, Database* db, bool& hasError, QString& errorString) override;
|
||||
|
||||
void readKdbx(const QString& path,
|
||||
|
@ -68,7 +68,8 @@ protected:
|
||||
virtual void initTestCaseImpl() = 0;
|
||||
|
||||
virtual QSharedPointer<Database> readXml(QBuffer* buf, bool strictMode, bool& hasError, QString& errorString) = 0;
|
||||
virtual QSharedPointer<Database> readXml(const QString& path, bool strictMode, bool& hasError, QString& errorString) = 0;
|
||||
virtual QSharedPointer<Database>
|
||||
readXml(const QString& path, bool strictMode, bool& hasError, QString& errorString) = 0;
|
||||
virtual void writeXml(QBuffer* buf, Database* db, bool& hasError, QString& errorString) = 0;
|
||||
|
||||
virtual void readKdbx(QIODevice* device,
|
||||
|
@ -145,11 +145,8 @@ void TestSharing::testCertificateSerialization()
|
||||
const OpenSSHKey& key = stubkey();
|
||||
KeeShareSettings::ScopedCertificate original;
|
||||
original.path = "/path";
|
||||
original.certificate = KeeShareSettings::Certificate
|
||||
{
|
||||
OpenSSHKey::serializeToBinary(OpenSSHKey::Public, key),
|
||||
"Some <!> &#_\"\" weird string"
|
||||
};
|
||||
original.certificate = KeeShareSettings::Certificate{OpenSSHKey::serializeToBinary(OpenSSHKey::Public, key),
|
||||
"Some <!> &#_\"\" weird string"};
|
||||
original.trust = trusted;
|
||||
|
||||
QString buffer;
|
||||
@ -230,10 +227,12 @@ void TestSharing::testReferenceSerialization_data()
|
||||
QTest::addColumn<QString>("path");
|
||||
QTest::addColumn<QUuid>("uuid");
|
||||
QTest::addColumn<int>("type");
|
||||
QTest::newRow("1") << "Password" << "/some/path" << QUuid::createUuid() << int(KeeShareSettings::Inactive);
|
||||
QTest::newRow("2") << "" << "" << QUuid() << int(KeeShareSettings::SynchronizeWith);
|
||||
QTest::newRow("3") << "" << "/some/path" << QUuid() << int(KeeShareSettings::ExportTo);
|
||||
|
||||
QTest::newRow("1") << "Password"
|
||||
<< "/some/path" << QUuid::createUuid() << int(KeeShareSettings::Inactive);
|
||||
QTest::newRow("2") << ""
|
||||
<< "" << QUuid() << int(KeeShareSettings::SynchronizeWith);
|
||||
QTest::newRow("3") << ""
|
||||
<< "/some/path" << QUuid() << int(KeeShareSettings::ExportTo);
|
||||
}
|
||||
|
||||
void TestSharing::testSettingsSerialization()
|
||||
@ -277,11 +276,8 @@ void TestSharing::testSettingsSerialization_data()
|
||||
const OpenSSHKey& sshKey0 = stubkey(0);
|
||||
KeeShareSettings::ScopedCertificate certificate0;
|
||||
certificate0.path = "/path/0";
|
||||
certificate0.certificate = KeeShareSettings::Certificate
|
||||
{
|
||||
OpenSSHKey::serializeToBinary(OpenSSHKey::Public, sshKey0),
|
||||
"Some <!> &#_\"\" weird string"
|
||||
};
|
||||
certificate0.certificate = KeeShareSettings::Certificate{OpenSSHKey::serializeToBinary(OpenSSHKey::Public, sshKey0),
|
||||
"Some <!> &#_\"\" weird string"};
|
||||
certificate0.trust = KeeShareSettings::Trust::Trusted;
|
||||
|
||||
KeeShareSettings::Key key0;
|
||||
@ -290,11 +286,8 @@ void TestSharing::testSettingsSerialization_data()
|
||||
const OpenSSHKey& sshKey1 = stubkey(1);
|
||||
KeeShareSettings::ScopedCertificate certificate1;
|
||||
certificate1.path = "/path/1";
|
||||
certificate1.certificate = KeeShareSettings::Certificate
|
||||
{
|
||||
OpenSSHKey::serializeToBinary(OpenSSHKey::Public, sshKey1),
|
||||
"Another "
|
||||
};
|
||||
certificate1.certificate =
|
||||
KeeShareSettings::Certificate{OpenSSHKey::serializeToBinary(OpenSSHKey::Public, sshKey1), "Another "};
|
||||
certificate1.trust = KeeShareSettings::Trust::Untrusted;
|
||||
|
||||
QTest::addColumn<bool>("importing");
|
||||
@ -302,11 +295,16 @@ void TestSharing::testSettingsSerialization_data()
|
||||
QTest::addColumn<KeeShareSettings::Certificate>("ownCertificate");
|
||||
QTest::addColumn<KeeShareSettings::Key>("ownKey");
|
||||
QTest::addColumn<QList<KeeShareSettings::ScopedCertificate>>("foreignCertificates");
|
||||
QTest::newRow("1") << false << false << KeeShareSettings::Certificate() << KeeShareSettings::Key() << QList<KeeShareSettings::ScopedCertificate>();
|
||||
QTest::newRow("2") << true << false << KeeShareSettings::Certificate() << KeeShareSettings::Key() << QList<KeeShareSettings::ScopedCertificate>();
|
||||
QTest::newRow("3") << true << true << KeeShareSettings::Certificate() << KeeShareSettings::Key() << QList<KeeShareSettings::ScopedCertificate>({ certificate0, certificate1 });
|
||||
QTest::newRow("4") << false << true << certificate0.certificate << key0 << QList<KeeShareSettings::ScopedCertificate>();
|
||||
QTest::newRow("5") << false << false << certificate0.certificate << key0 << QList<KeeShareSettings::ScopedCertificate>({ certificate1 });
|
||||
QTest::newRow("1") << false << false << KeeShareSettings::Certificate() << KeeShareSettings::Key()
|
||||
<< QList<KeeShareSettings::ScopedCertificate>();
|
||||
QTest::newRow("2") << true << false << KeeShareSettings::Certificate() << KeeShareSettings::Key()
|
||||
<< QList<KeeShareSettings::ScopedCertificate>();
|
||||
QTest::newRow("3") << true << true << KeeShareSettings::Certificate() << KeeShareSettings::Key()
|
||||
<< QList<KeeShareSettings::ScopedCertificate>({certificate0, certificate1});
|
||||
QTest::newRow("4") << false << true << certificate0.certificate << key0
|
||||
<< QList<KeeShareSettings::ScopedCertificate>();
|
||||
QTest::newRow("5") << false << false << certificate0.certificate << key0
|
||||
<< QList<KeeShareSettings::ScopedCertificate>({certificate1});
|
||||
}
|
||||
|
||||
const OpenSSHKey& TestSharing::stubkey(int index)
|
||||
|
Loading…
Reference in New Issue
Block a user