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,
|
||||
dialogResult = MessageBox::question(
|
||||
nullptr,
|
||||
tr("KeePassXC: Update Entry"),
|
||||
tr("Do you want to update the information in %1 - %2?")
|
||||
.arg(QUrl(url).host(), username),
|
||||
tr("Do you want to update the information in %1 - %2?").arg(QUrl(url).host(), username),
|
||||
MessageBox::Save | MessageBox::Cancel,
|
||||
MessageBox::Cancel, MessageBox::Raise);
|
||||
MessageBox::Cancel,
|
||||
MessageBox::Raise);
|
||||
}
|
||||
|
||||
if (browserSettings()->alwaysAllowUpdate() || dialogResult == MessageBox::Save) {
|
||||
@ -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,8 +41,7 @@ const QCommandLineOption Command::QuietOption =
|
||||
<< "quiet",
|
||||
QObject::tr("Silence password prompt and other secondary outputs."));
|
||||
|
||||
const QCommandLineOption Command::KeyFileOption =
|
||||
QCommandLineOption(QStringList() << "k"
|
||||
const QCommandLineOption Command::KeyFileOption = QCommandLineOption(QStringList() << "k"
|
||||
<< "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
|
@ -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;
|
||||
|
@ -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,11 +97,11 @@ void setStdinEcho(bool enable = true)
|
||||
}
|
||||
} // namespace Test
|
||||
|
||||
QSharedPointer<Database> unlockDatabase(const QString& databaseFilename,
|
||||
QSharedPointer<Database> unlockDatabase(const QString& databaseFilename,
|
||||
const QString& keyFilename,
|
||||
FILE* outputDescriptor,
|
||||
FILE* errorDescriptor)
|
||||
{
|
||||
{
|
||||
auto compositeKey = QSharedPointer<CompositeKey>::create();
|
||||
TextStream out(outputDescriptor);
|
||||
TextStream err(errorDescriptor);
|
||||
@ -138,20 +137,20 @@ QSharedPointer<Database> unlockDatabase(const QString& databaseFilename,
|
||||
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)
|
||||
{
|
||||
QString getPassword(FILE* outputDescriptor)
|
||||
{
|
||||
TextStream out(outputDescriptor, QIODevice::WriteOnly);
|
||||
|
||||
// return preset password if one is set
|
||||
|
@ -229,8 +229,7 @@ namespace Bootstrap
|
||||
|
||||
#ifdef WITH_XC_SSHAGENT
|
||||
// OpenSSH for Windows ssh-agent service is running as LocalSystem
|
||||
if (!AddAccessAllowedAce(
|
||||
pACL,
|
||||
if (!AddAccessAllowedAce(pACL,
|
||||
ACL_REVISION,
|
||||
PROCESS_QUERY_INFORMATION | PROCESS_DUP_HANDLE, // just enough for ssh-agent
|
||||
pLocalSystemSid // known LocalSystem sid
|
||||
|
@ -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,15 +726,13 @@ Entry* Entry::clone(CloneFlags flags) const
|
||||
entry->m_attachments->copyDataFrom(m_attachments);
|
||||
|
||||
if (flags & CloneUserAsRef) {
|
||||
entry->m_attributes->set(
|
||||
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,
|
||||
entry->m_attributes->set(EntryAttributes::PasswordKey,
|
||||
buildReference(uuid(), EntryAttributes::PasswordKey),
|
||||
m_attributes->isProtected(EntryAttributes::PasswordKey));
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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,8 +36,8 @@ const QString OpenSSHKey::TYPE_OPENSSH_PRIVATE = "OPENSSH PRIVATE KEY";
|
||||
|
||||
namespace
|
||||
{
|
||||
QPair<QString, QList<QByteArray>> binaryDeserialize(const QByteArray& serialized)
|
||||
{
|
||||
QPair<QString, QList<QByteArray>> binaryDeserialize(const QByteArray& serialized)
|
||||
{
|
||||
if (serialized.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
@ -53,10 +53,10 @@ QPair<QString, QList<QByteArray>> binaryDeserialize(const QByteArray& serialized
|
||||
data << temp;
|
||||
}
|
||||
return ::qMakePair(type, data);
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray binarySerialize(const QString& type, const QList<QByteArray>& data)
|
||||
{
|
||||
QByteArray binarySerialize(const QString& type, const QList<QByteArray>& data)
|
||||
{
|
||||
if (type.isEmpty() && data.isEmpty()) {
|
||||
return {};
|
||||
}
|
||||
@ -67,8 +67,8 @@ QByteArray binarySerialize(const QString& type, const QList<QByteArray>& 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();
|
||||
|
@ -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,7 +48,7 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -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,8 +202,7 @@ 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),
|
||||
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"
|
||||
@ -465,7 +465,8 @@ void DatabaseWidget::deleteSelectedEntries()
|
||||
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?", "",
|
||||
"Do you want to overwrite references with values, skip this entry, or delete anyway?",
|
||||
"",
|
||||
references.size())
|
||||
.arg((*it)->title().toHtmlEscaped())
|
||||
.arg(references.size()),
|
||||
@ -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,10 +707,10 @@ 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,
|
||||
auto result = MessageBox::question(
|
||||
this,
|
||||
tr("Delete group"),
|
||||
tr("Do you really want to delete the group \"%1\" for good?")
|
||||
.arg(currentGroup->name().toHtmlEscaped()),
|
||||
tr("Do you really want to delete the group \"%1\" for good?").arg(currentGroup->name().toHtmlEscaped()),
|
||||
MessageBox::Delete | MessageBox::Cancel,
|
||||
MessageBox::Cancel);
|
||||
|
||||
@ -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?"),
|
||||
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);
|
||||
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;
|
||||
@ -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,8 +1345,7 @@ 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),
|
||||
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,7 +1594,8 @@ void DatabaseWidget::emptyRecycleBin()
|
||||
return;
|
||||
}
|
||||
|
||||
auto result = MessageBox::question(this,
|
||||
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,
|
||||
|
@ -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)
|
||||
|
@ -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,19 +20,15 @@
|
||||
|
||||
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>>
|
||||
{
|
||||
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}},
|
||||
|
@ -19,14 +19,15 @@
|
||||
#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,
|
||||
@ -63,7 +64,8 @@ public:
|
||||
Last = Merge,
|
||||
};
|
||||
|
||||
enum Action {
|
||||
enum Action
|
||||
{
|
||||
None = 0,
|
||||
Raise = 1,
|
||||
};
|
||||
@ -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);
|
||||
|
||||
|
@ -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,10 +29,10 @@
|
||||
#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
|
||||
@ -51,6 +51,7 @@ public:
|
||||
{
|
||||
settingsPage->saveSettings(widget);
|
||||
}
|
||||
|
||||
private:
|
||||
QSharedPointer<IDatabaseSettingsPage> settingsPage;
|
||||
QWidget* widget;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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,7 +683,8 @@ 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"
|
||||
QCOMPARE(m_stdoutFile->readAll(),
|
||||
QByteArray("Sample Entry\n"
|
||||
"General/\n"
|
||||
"Windows/\n"
|
||||
"Network/\n"
|
||||
@ -689,7 +692,6 @@ void TestCli::testList()
|
||||
"eMail/\n"
|
||||
"Homebanking/\n"));
|
||||
|
||||
|
||||
pos = m_stdoutFile->pos();
|
||||
Utils::Test::setNextPassword("a");
|
||||
listCmd.execute({"ls", "-R", m_dbFile->fileName()});
|
||||
@ -1018,7 +1020,8 @@ 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"
|
||||
QCOMPARE(m_stdoutFile->readAll(),
|
||||
QByteArray("Title: Sample Entry\n"
|
||||
"UserName: User Name\n"
|
||||
"Password: Password\n"
|
||||
"URL: http://www.somesite.com/\n"
|
||||
|
@ -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