diff options
author | pasdam <> | 2018-03-23 13:18:06 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2018-07-07 05:23:52 +0300 |
commit | b4d806ad412b33b9af63f926c06453b63c06a129 (patch) | |
tree | d05933ccf35ba9796fb21460a30e0d21faa911d3 | |
parent | ad4423d226da6105e0732a15918c6429e2ca8ed4 (diff) |
Fixed issues with initial commit
-rw-r--r-- | src/browser/BrowserService.cpp | 30 | ||||
-rw-r--r-- | src/core/TimeInfo.cpp | 2 | ||||
-rw-r--r-- | src/crypto/kdf/Kdf.h | 2 | ||||
-rw-r--r-- | src/format/KdbxReader.cpp | 4 | ||||
-rw-r--r-- | src/format/KdbxXmlReader.cpp | 4 | ||||
-rw-r--r-- | src/format/KeePass2.cpp | 4 | ||||
-rw-r--r-- | src/gui/DatabaseSettingsWidget.cpp | 9 | ||||
-rw-r--r-- | src/gui/EditWidgetIcons.h | 2 | ||||
-rw-r--r-- | src/gui/EditWidgetProperties.cpp | 2 | ||||
-rw-r--r-- | src/gui/IconModels.cpp | 2 | ||||
-rw-r--r-- | src/sshagent/SSHAgent.cpp | 12 | ||||
-rw-r--r-- | src/sshagent/SSHAgent.h | 2 | ||||
-rw-r--r-- | tests/TestEntry.cpp | 4 | ||||
-rw-r--r-- | tests/TestEntryModel.cpp | 4 | ||||
-rw-r--r-- | tests/TestGlobal.h | 1 | ||||
-rw-r--r-- | tests/TestKeePass2Format.cpp | 6 | ||||
-rw-r--r-- | tests/gui/TestGuiPixmaps.cpp | 4 |
17 files changed, 43 insertions, 51 deletions
diff --git a/src/browser/BrowserService.cpp b/src/browser/BrowserService.cpp index b49804ed9..c46f6e709 100644 --- a/src/browser/BrowserService.cpp +++ b/src/browser/BrowserService.cpp @@ -17,6 +17,12 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <QJsonArray> +#include <QInputDialog> +#include <QProgressDialog> +#include <QMessageBox> +#include <QUuid> + #include "BrowserService.h" #include "BrowserAccessControlDialog.h" #include "BrowserEntryConfig.h" @@ -26,19 +32,9 @@ #include "core/Group.h" #include "core/Metadata.h" #include "core/PasswordGenerator.h" -#include "core/Uuid.h" #include "gui/MainWindow.h" -#include <QInputDialog> -#include <QJsonArray> -#include <QMessageBox> -#include <QProgressDialog> -// de887cc3-0363-43b8-974b-5911b8816224 -static const unsigned char KEEPASSXCBROWSER_UUID_DATA[] = - {0xde, 0x88, 0x7c, 0xc3, 0x03, 0x63, 0x43, 0xb8, 0x97, 0x4b, 0x59, 0x11, 0xb8, 0x81, 0x62, 0x24}; -static const Uuid KEEPASSXCBROWSER_UUID = - Uuid(QByteArray::fromRawData(reinterpret_cast<const char*>(KEEPASSXCBROWSER_UUID_DATA), - sizeof(KEEPASSXCBROWSER_UUID_DATA))); +static const QUuid KEEPASSXCBROWSER_UUID = QUuid::fromRfc4122(QByteArray::fromHex("de887cc3036343b8974b5911b8816224")); static const char KEEPASSXCBROWSER_NAME[] = "KeePassXC-Browser Settings"; static const char ASSOCIATE_KEY_PREFIX[] = "Public Key: "; static const char KEEPASSXCBROWSER_GROUP_NAME[] = "KeePassXC-Browser Passwords"; @@ -118,7 +114,7 @@ QString BrowserService::getDatabaseRootUuid() return QString(); } - return rootGroup->uuid().toHex(); + return QString::fromLatin1(rootGroup->uuid().toRfc4122().toHex()); } QString BrowserService::getDatabaseRecycleBinUuid() @@ -132,7 +128,7 @@ QString BrowserService::getDatabaseRecycleBinUuid() if (!recycleBin) { return QString(); } - return recycleBin->uuid().toHex(); + return QString::fromLatin1(recycleBin->uuid().toRfc4122().toHex()); } Entry* BrowserService::getConfigEntry(bool create) @@ -306,7 +302,7 @@ void BrowserService::addEntry(const QString&, } Entry* entry = new Entry(); - entry->setUuid(Uuid::random()); + entry->setUuid(QUuid::createUuid()); entry->setTitle(QUrl(url).host()); entry->setUrl(url); entry->setIcon(KEEPASSXCBROWSER_DEFAULT_ICON); @@ -350,7 +346,7 @@ void BrowserService::updateEntry(const QString& id, return; } - Entry* entry = db->resolveEntry(Uuid::fromHex(uuid)); + Entry* entry = db->resolveEntry(QUuid::fromRfc4122(QByteArray::fromHex(uuid.toLatin1()))); if (!entry) { return; } @@ -631,7 +627,7 @@ QJsonObject BrowserService::prepareEntry(const Entry* entry) res["login"] = entry->resolveMultiplePlaceholders(entry->username()); res["password"] = entry->resolveMultiplePlaceholders(entry->password()); res["name"] = entry->resolveMultiplePlaceholders(entry->title()); - res["uuid"] = entry->resolveMultiplePlaceholders(entry->uuid().toHex()); + res["uuid"] = entry->resolveMultiplePlaceholders(QString::fromLatin1(entry->uuid().toRfc4122().toHex())); if (entry->hasTotp()) { res["totp"] = entry->totp(); @@ -693,7 +689,7 @@ Group* BrowserService::findCreateAddEntryGroup() } Group* group = new Group(); - group->setUuid(Uuid::random()); + group->setUuid(QUuid::createUuid()); group->setName(groupName); group->setIcon(KEEPASSXCBROWSER_DEFAULT_ICON); group->setParent(rootGroup); diff --git a/src/core/TimeInfo.cpp b/src/core/TimeInfo.cpp index ec6ebdeec..85c53a567 100644 --- a/src/core/TimeInfo.cpp +++ b/src/core/TimeInfo.cpp @@ -17,8 +17,6 @@ #include "TimeInfo.h" -#include "core/Tools.h" - TimeInfo::TimeInfo() : m_expires(false) , m_usageCount(0) diff --git a/src/crypto/kdf/Kdf.h b/src/crypto/kdf/Kdf.h index 3d62efe83..1dff11067 100644 --- a/src/crypto/kdf/Kdf.h +++ b/src/crypto/kdf/Kdf.h @@ -19,7 +19,7 @@ #define KEEPASSX_KDF_H #include <QVariant> -#include <QUuid.h> +#include <QUuid> #define KDF_DEFAULT_SEED_SIZE 32 #define KDF_DEFAULT_ROUNDS 1000000ull diff --git a/src/format/KdbxReader.cpp b/src/format/KdbxReader.cpp index e33b6e75c..a8127509b 100644 --- a/src/format/KdbxReader.cpp +++ b/src/format/KdbxReader.cpp @@ -19,7 +19,7 @@ #include "core/Database.h" #include "core/Endian.h" -#define UUID_LENGHT 16 +#define UUID_LENGTH 16 /** * Read KDBX magic header numbers from a device. @@ -135,7 +135,7 @@ KeePass2::ProtectedStreamAlgo KdbxReader::protectedStreamAlgo() const */ void KdbxReader::setCipher(const QByteArray& data) { - if (data.size() != UUID_LENGHT) { + if (data.size() != UUID_LENGTH) { raiseError(tr("Invalid cipher uuid length: %1 (length=%2)").arg(QString(data)).arg(data.size())); return; } diff --git a/src/format/KdbxXmlReader.cpp b/src/format/KdbxXmlReader.cpp index 62b2e6839..d9b6534bc 100644 --- a/src/format/KdbxXmlReader.cpp +++ b/src/format/KdbxXmlReader.cpp @@ -28,7 +28,7 @@ #include <QBuffer> #include <QFile> -#define UUID_LENGHT 16 +#define UUID_LENGTH 16 /** * @param version KDBX version @@ -1099,7 +1099,7 @@ QUuid KdbxXmlReader::readUuid() if (uuidBin.isEmpty()) { return QUuid(); } - if (uuidBin.length() != UUID_LENGHT) { + if (uuidBin.length() != UUID_LENGTH) { if (m_strictMode) { raiseError(tr("Invalid uuid value")); } diff --git a/src/format/KeePass2.cpp b/src/format/KeePass2.cpp index 32e568014..dd9ffc0c6 100644 --- a/src/format/KeePass2.cpp +++ b/src/format/KeePass2.cpp @@ -21,7 +21,7 @@ #include "crypto/kdf/Argon2Kdf.h" #include <QSharedPointer> -#define UUID_LENGHT 16 +#define UUID_LENGTH 16 const QUuid KeePass2::CIPHER_AES = QUuid::fromRfc4122(QByteArray::fromHex("31c1f2e6bf714350be5805216afc5aff")); const QUuid KeePass2::CIPHER_TWOFISH = QUuid::fromRfc4122(QByteArray::fromHex("ad68f29f576f4bb9a36ad47af965346c")); @@ -76,7 +76,7 @@ QByteArray KeePass2::hmacKey(QByteArray masterSeed, QByteArray transformedMaster QSharedPointer<Kdf> KeePass2::kdfFromParameters(const QVariantMap& p) { QByteArray uuidBytes = p.value(KDFPARAM_UUID).toByteArray(); - if (uuidBytes.size() != UUID_LENGHT) { + if (uuidBytes.size() != UUID_LENGTH) { return {}; } diff --git a/src/gui/DatabaseSettingsWidget.cpp b/src/gui/DatabaseSettingsWidget.cpp index 27973685c..8aea47266 100644 --- a/src/gui/DatabaseSettingsWidget.cpp +++ b/src/gui/DatabaseSettingsWidget.cpp @@ -105,9 +105,8 @@ void DatabaseSettingsWidget::load(Database* db) } m_uiEncryption->algorithmComboBox->clear(); - for (auto& cipher : asConst(KeePass2::CIPHERS)) { - m_uiEncryption->algorithmComboBox->addItem(QCoreApplication::translate("KeePass2", cipher.second.toUtf8()), - cipher.first.toByteArray()); + for (auto& cipher: asConst(KeePass2::CIPHERS)) { + m_uiEncryption->algorithmComboBox->addItem(QCoreApplication::translate("KeePass2", cipher.second.toUtf8()), cipher.first); } int cipherIndex = m_uiEncryption->algorithmComboBox->findData(m_db->cipher().toRfc4122()); if (cipherIndex > -1) { @@ -118,12 +117,12 @@ void DatabaseSettingsWidget::load(Database* db) m_uiEncryption->kdfComboBox->blockSignals(true); m_uiEncryption->kdfComboBox->clear(); for (auto& kdf: asConst(KeePass2::KDFS)) { - m_uiEncryption->kdfComboBox->addItem(kdf.second, kdf.first.toRfc4122()); + m_uiEncryption->kdfComboBox->addItem(QCoreApplication::translate("KeePass2", kdf.second.toUtf8()), kdf.first); } m_uiEncryption->kdfComboBox->blockSignals(false); auto kdfUuid = m_db->kdf()->uuid(); - int kdfIndex = m_uiEncryption->kdfComboBox->findData(kdfUuid.toRfc4122()); + int kdfIndex = m_uiEncryption->kdfComboBox->findData(kdfUuid); if (kdfIndex > -1) { m_uiEncryption->kdfComboBox->setCurrentIndex(kdfIndex); kdfChanged(kdfIndex); diff --git a/src/gui/EditWidgetIcons.h b/src/gui/EditWidgetIcons.h index 82c4343e2..7a14123b5 100644 --- a/src/gui/EditWidgetIcons.h +++ b/src/gui/EditWidgetIcons.h @@ -24,7 +24,7 @@ #include <QUrl> #include <QWidget> #include <QNetworkAccessManager> -#include <QUuid.h> +#include <QUuid> #include "config-keepassx.h" #include "core/Global.h" diff --git a/src/gui/EditWidgetProperties.cpp b/src/gui/EditWidgetProperties.cpp index 6ec31c891..93e3b0ae8 100644 --- a/src/gui/EditWidgetProperties.cpp +++ b/src/gui/EditWidgetProperties.cpp @@ -17,7 +17,7 @@ #include "EditWidgetProperties.h" -#include <QUuid.h> +#include <QUuid> #include "MessageBox.h" #include "ui_EditWidgetProperties.h" diff --git a/src/gui/IconModels.cpp b/src/gui/IconModels.cpp index 495ba9b17..39732c502 100644 --- a/src/gui/IconModels.cpp +++ b/src/gui/IconModels.cpp @@ -17,7 +17,7 @@ #include "IconModels.h" -#include <QUuid.h> +#include <QUuid> #include "core/DatabaseIcons.h" diff --git a/src/sshagent/SSHAgent.cpp b/src/sshagent/SSHAgent.cpp index e8639f5d2..758c86851 100644 --- a/src/sshagent/SSHAgent.cpp +++ b/src/sshagent/SSHAgent.cpp @@ -234,11 +234,11 @@ bool SSHAgent::removeIdentity(OpenSSHKey& key) return true; } -void SSHAgent::removeIdentityAtLock(const OpenSSHKey& key, const Uuid& uuid) +void SSHAgent::removeIdentityAtLock(const OpenSSHKey& key, const QUuid& uuid) { OpenSSHKey copy = key; copy.clearPrivate(); - m_keys[uuid.toHex()].insert(copy); + m_keys[uuid].insert(copy); } void SSHAgent::databaseModeChanged(DatabaseWidget::Mode mode) @@ -249,17 +249,17 @@ void SSHAgent::databaseModeChanged(DatabaseWidget::Mode mode) return; } - Uuid uuid = widget->database()->uuid(); + const QUuid& uuid = widget->database()->uuid(); - if (mode == DatabaseWidget::LockedMode && m_keys.contains(uuid.toHex())) { + if (mode == DatabaseWidget::LockedMode && m_keys.contains(uuid)) { - QSet<OpenSSHKey> keys = m_keys.take(uuid.toHex()); + QSet<OpenSSHKey> keys = m_keys.take(uuid); for (OpenSSHKey key : keys) { if (!removeIdentity(key)) { emit error(m_error); } } - } else if (mode == DatabaseWidget::ViewMode && !m_keys.contains(uuid.toHex())) { + } else if (mode == DatabaseWidget::ViewMode && !m_keys.contains(uuid)) { for (Entry* e : widget->database()->rootGroup()->entriesRecursive()) { if (widget->database()->metadata()->recycleBinEnabled() diff --git a/src/sshagent/SSHAgent.h b/src/sshagent/SSHAgent.h index 9bfe52948..ccbfda0cc 100644 --- a/src/sshagent/SSHAgent.h +++ b/src/sshagent/SSHAgent.h @@ -71,7 +71,7 @@ private: const quint32 AGENT_COPYDATA_ID = 0x804e50ba; #endif - QMap<QString, QSet<OpenSSHKey>> m_keys; + QMap<QUuid, QSet<OpenSSHKey>> m_keys; QString m_error; }; diff --git a/tests/TestEntry.cpp b/tests/TestEntry.cpp index aa4426211..5e5d7bc3c 100644 --- a/tests/TestEntry.cpp +++ b/tests/TestEntry.cpp @@ -282,8 +282,8 @@ void TestEntry::testResolveRecursivePlaceholders() auto* entry7 = new Entry(); entry7->setGroup(root); - entry7->setUuid(Uuid::random()); - entry7->setTitle(QString("{REF:T@I:%1} and something else").arg(entry3->uuid().toHex())); + entry7->setUuid(QUuid::createUuid()); + entry7->setTitle(QString("{REF:T@I:%1} and something else").arg(QString(entry3->uuid().toRfc4122().toHex()))); entry7->setUsername(QString("{TITLE}")); entry7->setPassword(QString("PASSWORD")); diff --git a/tests/TestEntryModel.cpp b/tests/TestEntryModel.cpp index dd3a5372a..3378a9f9a 100644 --- a/tests/TestEntryModel.cpp +++ b/tests/TestEntryModel.cpp @@ -220,11 +220,11 @@ void TestEntryModel::testCustomIconModel() QHash<QUuid, QPixmap> icons; QList<QUuid> iconsOrder; - QUuid iconUuid(QByteArray(16, '2')); + QUuid iconUuid = QUuid::fromRfc4122(QByteArray(16, '2')); icons.insert(iconUuid, QPixmap()); iconsOrder << iconUuid; - QUuid iconUuid2(QByteArray(16, '1')); + QUuid iconUuid2 = QUuid::fromRfc4122(QByteArray(16, '1')); icons.insert(iconUuid2, QPixmap()); iconsOrder << iconUuid2; diff --git a/tests/TestGlobal.h b/tests/TestGlobal.h index ef7472c01..9889a4434 100644 --- a/tests/TestGlobal.h +++ b/tests/TestGlobal.h @@ -19,7 +19,6 @@ #define KEEPASSXC_TESTGLOBAL_H #include "core/Group.h" -#include "core/Uuid.h" #include <QDateTime> #include <QTest> diff --git a/tests/TestKeePass2Format.cpp b/tests/TestKeePass2Format.cpp index ce639bdef..c5f22ef6d 100644 --- a/tests/TestKeePass2Format.cpp +++ b/tests/TestKeePass2Format.cpp @@ -577,12 +577,12 @@ void TestKeePass2Format::testDuplicateAttachments() auto entry1 = new Entry(); entry1->setGroup(db->rootGroup()); - entry1->setUuid(QUuid::fromRfc4122(QByteArray::fromHex("aaaaaaaaaaaaaaaa"))); + entry1->setUuid(QUuid::fromRfc4122("aaaaaaaaaaaaaaaa")); entry1->attachments()->set("a", attachment1); auto entry2 = new Entry(); entry2->setGroup(db->rootGroup()); - entry2->setUuid(QUuid::fromRfc4122(QByteArray::fromHex("bbbbbbbbbbbbbbbb"))); + entry2->setUuid(QUuid::fromRfc4122("bbbbbbbbbbbbbbbb")); entry2->attachments()->set("b1", attachment1); entry2->beginUpdate(); entry2->attachments()->set("b2", attachment1); @@ -596,7 +596,7 @@ void TestKeePass2Format::testDuplicateAttachments() auto entry3 = new Entry(); entry3->setGroup(db->rootGroup()); - entry3->setUuid(QUuid::fromRfc4122(QByteArray::fromHex("cccccccccccccccc"))); + entry3->setUuid(QUuid::fromRfc4122("cccccccccccccccc")); entry3->attachments()->set("c1", attachment2); entry3->attachments()->set("c2", attachment2); entry3->attachments()->set("c3", attachment3); diff --git a/tests/gui/TestGuiPixmaps.cpp b/tests/gui/TestGuiPixmaps.cpp index c71fe51b9..c5754ba84 100644 --- a/tests/gui/TestGuiPixmaps.cpp +++ b/tests/gui/TestGuiPixmaps.cpp @@ -73,7 +73,7 @@ void TestGuiPixmaps::testEntryIcons() QCOMPARE(pixmapCached1.cacheKey(), pixmap.cacheKey()); QCOMPARE(pixmapCached2.cacheKey(), pixmap.cacheKey()); - Uuid iconUuid = Uuid::random(); + QUuid iconUuid = QUuid::createUuid(); icon = QImage(2, 1, QImage::Format_RGB32); icon.setPixel(0, 0, qRgb(0, 0, 0)); icon.setPixel(1, 0, qRgb(0, 0, 50)); @@ -116,7 +116,7 @@ void TestGuiPixmaps::testGroupIcons() QCOMPARE(pixmapCached1.cacheKey(), pixmap.cacheKey()); QCOMPARE(pixmapCached2.cacheKey(), pixmap.cacheKey()); - Uuid iconUuid = Uuid::random(); + QUuid iconUuid = QUuid::createUuid(); icon = QImage(2, 1, QImage::Format_RGB32); icon.setPixel(0, 0, qRgb(0, 0, 0)); icon.setPixel(1, 0, qRgb(0, 0, 50)); |