From aaf082a3325a74308a56a803168243b953a96fa5 Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Sat, 8 Jun 2013 15:44:00 +0430 Subject: [PATCH] [PasswordManager] change return type of updateEntry() to bool. --- src/lib/autofill/autofill.cpp | 4 ++-- src/lib/autofill/autofill.h | 2 +- .../passwordbackends/databasepasswordbackend.cpp | 4 ++-- .../passwordbackends/databasepasswordbackend.h | 2 +- src/lib/autofill/passwordbackends/passwordbackend.h | 2 +- src/lib/autofill/passwordmanager.cpp | 4 ++-- src/lib/autofill/passwordmanager.h | 2 +- .../gnomekeyringpasswordbackend.cpp | 10 ++++++---- .../gnomekeyringpasswordbackend.h | 2 +- .../KWalletPasswords/kwalletpasswordbackend.cpp | 4 +++- src/plugins/KWalletPasswords/kwalletpasswordbackend.h | 2 +- 11 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/lib/autofill/autofill.cpp b/src/lib/autofill/autofill.cpp index bf1dc826b..6f4065342 100644 --- a/src/lib/autofill/autofill.cpp +++ b/src/lib/autofill/autofill.cpp @@ -149,9 +149,9 @@ void AutoFill::updateEntry(const QUrl &url, const QString &name, const QString & } // WEB Form -void AutoFill::updateEntry(const PasswordEntry &entry) +bool AutoFill::updateEntry(const PasswordEntry &entry) { - m_manager->updateEntry(entry); + return m_manager->updateEntry(entry); } void AutoFill::removeEntry(const PasswordEntry &entry) diff --git a/src/lib/autofill/autofill.h b/src/lib/autofill/autofill.h index 94e428d06..25b6f5964 100644 --- a/src/lib/autofill/autofill.h +++ b/src/lib/autofill/autofill.h @@ -55,7 +55,7 @@ public: void addEntry(const QUrl &url, const PageFormData &formData); void updateEntry(const QUrl &url, const QString &name, const QString &pass); - void updateEntry(const PasswordEntry &entry); + bool updateEntry(const PasswordEntry &entry); void removeEntry(const PasswordEntry &entry); void removeAllEntries(); diff --git a/src/lib/autofill/passwordbackends/databasepasswordbackend.cpp b/src/lib/autofill/passwordbackends/databasepasswordbackend.cpp index f27ca4227..2915ec8a7 100644 --- a/src/lib/autofill/passwordbackends/databasepasswordbackend.cpp +++ b/src/lib/autofill/passwordbackends/databasepasswordbackend.cpp @@ -105,7 +105,7 @@ void DatabasePasswordBackend::addEntry(const PasswordEntry &entry) query.exec(); } -void DatabasePasswordBackend::updateEntry(const PasswordEntry &entry) +bool DatabasePasswordBackend::updateEntry(const PasswordEntry &entry) { QSqlQuery query; @@ -124,7 +124,7 @@ void DatabasePasswordBackend::updateEntry(const PasswordEntry &entry) query.addBindValue(entry.id); } - query.exec(); + return query.exec(); } void DatabasePasswordBackend::updateLastUsed(PasswordEntry &entry) diff --git a/src/lib/autofill/passwordbackends/databasepasswordbackend.h b/src/lib/autofill/passwordbackends/databasepasswordbackend.h index cba9aad4b..d79ffaf5a 100644 --- a/src/lib/autofill/passwordbackends/databasepasswordbackend.h +++ b/src/lib/autofill/passwordbackends/databasepasswordbackend.h @@ -31,7 +31,7 @@ public: QVector getAllEntries(); void addEntry(const PasswordEntry &entry); - void updateEntry(const PasswordEntry &entry); + bool updateEntry(const PasswordEntry &entry); void updateLastUsed(PasswordEntry &entry); void removeEntry(const PasswordEntry &entry); diff --git a/src/lib/autofill/passwordbackends/passwordbackend.h b/src/lib/autofill/passwordbackends/passwordbackend.h index db0435420..81a12a9d0 100644 --- a/src/lib/autofill/passwordbackends/passwordbackend.h +++ b/src/lib/autofill/passwordbackends/passwordbackend.h @@ -34,7 +34,7 @@ public: virtual QVector getAllEntries() = 0; virtual void addEntry(const PasswordEntry &entry) = 0; - virtual void updateEntry(const PasswordEntry &entry) = 0; + virtual bool updateEntry(const PasswordEntry &entry) = 0; virtual void updateLastUsed(PasswordEntry &entry) = 0; virtual void removeEntry(const PasswordEntry &entry) = 0; diff --git a/src/lib/autofill/passwordmanager.cpp b/src/lib/autofill/passwordmanager.cpp index f7f3d9c1e..1dc59b81f 100644 --- a/src/lib/autofill/passwordmanager.cpp +++ b/src/lib/autofill/passwordmanager.cpp @@ -95,10 +95,10 @@ void PasswordManager::addEntry(const PasswordEntry &entry) m_backend->addEntry(entry); } -void PasswordManager::updateEntry(const PasswordEntry &entry) +bool PasswordManager::updateEntry(const PasswordEntry &entry) { ensureLoaded(); - m_backend->updateEntry(entry); + return m_backend->updateEntry(entry); } void PasswordManager::updateLastUsed(PasswordEntry &entry) diff --git a/src/lib/autofill/passwordmanager.h b/src/lib/autofill/passwordmanager.h index 6aa0bd8dc..939583bb7 100644 --- a/src/lib/autofill/passwordmanager.h +++ b/src/lib/autofill/passwordmanager.h @@ -66,7 +66,7 @@ public: QVector getAllEntries(); void addEntry(const PasswordEntry &entry); - void updateEntry(const PasswordEntry &entry); + bool updateEntry(const PasswordEntry &entry); void updateLastUsed(PasswordEntry &entry); void removeEntry(const PasswordEntry &entry); diff --git a/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.cpp b/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.cpp index 62fbc5c81..756c3e60e 100644 --- a/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.cpp +++ b/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.cpp @@ -144,7 +144,7 @@ void GnomeKeyringPasswordBackend::addEntry(const PasswordEntry &entry) m_allEntries.append(stored); } -void GnomeKeyringPasswordBackend::updateEntry(const PasswordEntry &entry) +bool GnomeKeyringPasswordBackend::updateEntry(const PasswordEntry &entry) { initialize(); @@ -159,7 +159,7 @@ void GnomeKeyringPasswordBackend::updateEntry(const PasswordEntry &entry) if (result != GNOME_KEYRING_RESULT_OK) { qWarning() << "GnomeKeyringPasswordBackend::updateEntry Cannot updated entry attributes in keyring!"; - return; + return false; } // Update secret @@ -169,7 +169,7 @@ void GnomeKeyringPasswordBackend::updateEntry(const PasswordEntry &entry) if (result != GNOME_KEYRING_RESULT_OK) { qWarning() << "GnomeKeyringPasswordBackend::updateEntry Cannot get entry info from keyring!"; - return; + return false; } QByteArray pass = entry.password.toUtf8(); @@ -181,7 +181,7 @@ void GnomeKeyringPasswordBackend::updateEntry(const PasswordEntry &entry) if (result != GNOME_KEYRING_RESULT_OK) { qWarning() << "GnomeKeyringPasswordBackend::updateEntry Cannot set entry info in keyring!"; - return; + return false; } int index = m_allEntries.indexOf(entry); @@ -189,6 +189,8 @@ void GnomeKeyringPasswordBackend::updateEntry(const PasswordEntry &entry) if (index > -1) { m_allEntries[index] = entry; } + + return true; } void GnomeKeyringPasswordBackend::updateLastUsed(PasswordEntry &entry) diff --git a/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.h b/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.h index 1782e78ae..121be2b9d 100644 --- a/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.h +++ b/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.h @@ -34,7 +34,7 @@ public: QVector getAllEntries(); void addEntry(const PasswordEntry &entry); - void updateEntry(const PasswordEntry &entry); + bool updateEntry(const PasswordEntry &entry); void updateLastUsed(PasswordEntry &entry); void removeEntry(const PasswordEntry &entry); diff --git a/src/plugins/KWalletPasswords/kwalletpasswordbackend.cpp b/src/plugins/KWalletPasswords/kwalletpasswordbackend.cpp index fa411f1ca..ba3d52d32 100644 --- a/src/plugins/KWalletPasswords/kwalletpasswordbackend.cpp +++ b/src/plugins/KWalletPasswords/kwalletpasswordbackend.cpp @@ -87,7 +87,7 @@ void KWalletPasswordBackend::addEntry(const PasswordEntry &entry) m_allEntries.append(stored); } -void KWalletPasswordBackend::updateEntry(const PasswordEntry &entry) +bool KWalletPasswordBackend::updateEntry(const PasswordEntry &entry) { initialize(); @@ -99,6 +99,8 @@ void KWalletPasswordBackend::updateEntry(const PasswordEntry &entry) if (index > -1) { m_allEntries[index] = entry; } + + return true; } void KWalletPasswordBackend::updateLastUsed(PasswordEntry &entry) diff --git a/src/plugins/KWalletPasswords/kwalletpasswordbackend.h b/src/plugins/KWalletPasswords/kwalletpasswordbackend.h index 815010ecf..2eef9c734 100644 --- a/src/plugins/KWalletPasswords/kwalletpasswordbackend.h +++ b/src/plugins/KWalletPasswords/kwalletpasswordbackend.h @@ -36,7 +36,7 @@ public: QVector getAllEntries(); void addEntry(const PasswordEntry &entry); - void updateEntry(const PasswordEntry &entry); + bool updateEntry(const PasswordEntry &entry); void updateLastUsed(PasswordEntry &entry); void removeEntry(const PasswordEntry &entry);