diff options
author | Jonathan White <support@dmapps.us> | 2019-01-20 17:50:20 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2019-01-29 06:38:59 +0300 |
commit | 7e1b16250c8a3b7854030c86af941d0b83d4a0b9 (patch) | |
tree | 83fe30abc4e1e22f6ae5891cb2bf354e0dc90260 /src/core | |
parent | c74664097b010b1c463011ec6ea07fd5c392a178 (diff) |
Performed project-wide code formatting
* Updated format CMake command to properly
ignore new directories and files
* Added output when command is run
* Resolves #2623
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/Bootstrap.cpp | 11 | ||||
-rw-r--r-- | src/core/Database.cpp | 2 | ||||
-rw-r--r-- | src/core/Database.h | 11 | ||||
-rw-r--r-- | src/core/Entry.cpp | 14 | ||||
-rw-r--r-- | src/core/EntrySearcher.cpp | 20 | ||||
-rw-r--r-- | src/core/EntrySearcher.h | 7 | ||||
-rw-r--r-- | src/core/FileWatcher.cpp | 10 | ||||
-rw-r--r-- | src/core/FileWatcher.h | 11 | ||||
-rw-r--r-- | src/core/Group.cpp | 49 | ||||
-rw-r--r-- | src/core/ScreenLockListenerMac.cpp | 8 | ||||
-rw-r--r-- | src/core/ScreenLockListenerMac.h | 10 | ||||
-rw-r--r-- | src/core/TimeInfo.cpp | 2 | ||||
-rw-r--r-- | src/core/Tools.cpp | 11 | ||||
-rw-r--r-- | src/core/Translator.cpp | 3 |
14 files changed, 90 insertions, 79 deletions
diff --git a/src/core/Bootstrap.cpp b/src/core/Bootstrap.cpp index 10dd9b2d8..1950735ae 100644 --- a/src/core/Bootstrap.cpp +++ b/src/core/Bootstrap.cpp @@ -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 diff --git a/src/core/Database.cpp b/src/core/Database.cpp index 261f2757a..13dea7d1c 100644 --- a/src/core/Database.cpp +++ b/src/core/Database.cpp @@ -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; diff --git a/src/core/Database.h b/src/core/Database.h index 8fbeb17ad..84e2f90ef 100644 --- a/src/core/Database.h +++ b/src/core/Database.h @@ -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; diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index d7a3089cb..2fd2e8c44 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -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); diff --git a/src/core/EntrySearcher.cpp b/src/core/EntrySearcher.cpp index 82e6eaa0c..a639afd8b 100644 --- a/src/core/EntrySearcher.cpp +++ b/src/core/EntrySearcher.cpp @@ -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()) { diff --git a/src/core/EntrySearcher.h b/src/core/EntrySearcher.h index ec71a7ce1..d5a9951f9 100644 --- a/src/core/EntrySearcher.h +++ b/src/core/EntrySearcher.h @@ -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; diff --git a/src/core/FileWatcher.cpp b/src/core/FileWatcher.cpp index d57d7de52..d7056f9c7 100644 --- a/src/core/FileWatcher.cpp +++ b/src/core/FileWatcher.cpp @@ -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 diff --git a/src/core/FileWatcher.h b/src/core/FileWatcher.h index 1ef46785c..00d6a6c69 100644 --- a/src/core/FileWatcher.h +++ b/src/core/FileWatcher.h @@ -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; }; diff --git a/src/core/Group.cpp b/src/core/Group.cpp index 6c4adbad7..9cfce863e 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -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) { diff --git a/src/core/ScreenLockListenerMac.cpp b/src/core/ScreenLockListenerMac.cpp index dce05de3f..08e4d1eee 100644 --- a/src/core/ScreenLockListenerMac.cpp +++ b/src/core/ScreenLockListenerMac.cpp @@ -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(); diff --git a/src/core/ScreenLockListenerMac.h b/src/core/ScreenLockListenerMac.h index cd36ce9e6..d2bee79b8 100644 --- a/src/core/ScreenLockListenerMac.h +++ b/src/core/ScreenLockListenerMac.h @@ -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 diff --git a/src/core/TimeInfo.cpp b/src/core/TimeInfo.cpp index b48ad42ea..9f4faf3a4 100644 --- a/src/core/TimeInfo.cpp +++ b/src/core/TimeInfo.cpp @@ -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 } diff --git a/src/core/Tools.cpp b/src/core/Tools.cpp index 7fc2a3462..e72901a61 100644 --- a/src/core/Tools.cpp +++ b/src/core/Tools.cpp @@ -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 diff --git a/src/core/Translator.cpp b/src/core/Translator.cpp index f64a7a44c..595dadfa1 100644 --- a/src/core/Translator.cpp +++ b/src/core/Translator.cpp @@ -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) { |