mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
[PasswordManager] Added updated member to PasswordEntry struct.
This commit is contained in:
parent
c7c1002fce
commit
54a3509fcb
@ -109,7 +109,7 @@ QVector<PasswordEntry> AutoFill::getAllFormData()
|
||||
return m_manager->getAllEntries();
|
||||
}
|
||||
|
||||
void AutoFill::updateLastUsed(const PasswordEntry &data)
|
||||
void AutoFill::updateLastUsed(PasswordEntry &data)
|
||||
{
|
||||
m_manager->updateLastUsed(data);
|
||||
}
|
||||
@ -225,20 +225,21 @@ void AutoFill::post(const QNetworkRequest &request, const QByteArray &outgoingDa
|
||||
return;
|
||||
}
|
||||
|
||||
PasswordEntry updateData = { -1, QString(), QString(), QString(), QByteArray() };
|
||||
PasswordEntry updateData;
|
||||
|
||||
if (isStored(siteUrl)) {
|
||||
const QVector<PasswordEntry> &list = getFormData(siteUrl);
|
||||
|
||||
foreach (const PasswordEntry &data, list) {
|
||||
if (data.username == formData.username) {
|
||||
updateLastUsed(data);
|
||||
updateData = data;
|
||||
updateLastUsed(updateData);
|
||||
|
||||
if (data.password == formData.password) {
|
||||
updateData.password.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
updateData = data;
|
||||
updateData.username = formData.username;
|
||||
updateData.password = formData.password;
|
||||
updateData.data = formData.postData;
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
QVector<PasswordEntry> getFormData(const QUrl &url);
|
||||
QVector<PasswordEntry> getAllFormData();
|
||||
|
||||
void updateLastUsed(const PasswordEntry &data);
|
||||
void updateLastUsed(PasswordEntry &data);
|
||||
|
||||
void addEntry(const QUrl &url, const QString &name, const QString &pass);
|
||||
void addEntry(const QUrl &url, const PageFormData &formData);
|
||||
|
@ -128,7 +128,7 @@ void DatabasePasswordBackend::updateEntry(const PasswordEntry &entry)
|
||||
mApp->dbWriter()->executeQuery(query);
|
||||
}
|
||||
|
||||
void DatabasePasswordBackend::updateLastUsed(const PasswordEntry &entry)
|
||||
void DatabasePasswordBackend::updateLastUsed(PasswordEntry &entry)
|
||||
{
|
||||
QSqlQuery query;
|
||||
query.prepare("UPDATE autofill SET last_used=strftime('%s', 'now') WHERE id=?");
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
|
||||
void addEntry(const PasswordEntry &entry);
|
||||
void updateEntry(const PasswordEntry &entry);
|
||||
void updateLastUsed(const PasswordEntry &entry);
|
||||
void updateLastUsed(PasswordEntry &entry);
|
||||
|
||||
void removeEntry(const PasswordEntry &entry);
|
||||
void removeAll();
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
virtual void addEntry(const PasswordEntry &entry) = 0;
|
||||
virtual void updateEntry(const PasswordEntry &entry) = 0;
|
||||
virtual void updateLastUsed(const PasswordEntry &entry) = 0;
|
||||
virtual void updateLastUsed(PasswordEntry &entry) = 0;
|
||||
|
||||
virtual void removeEntry(const PasswordEntry &entry) = 0;
|
||||
virtual void removeAll() = 0;
|
||||
|
@ -22,21 +22,22 @@
|
||||
|
||||
#include <QVector>
|
||||
|
||||
static const int passwordEntryVersion = 1;
|
||||
static const int passwordEntryVersion = 2;
|
||||
|
||||
QDataStream &operator <<(QDataStream &stream, const PasswordEntry &tab)
|
||||
QDataStream &operator <<(QDataStream &stream, const PasswordEntry &entry)
|
||||
{
|
||||
stream << passwordEntryVersion;
|
||||
stream << tab.host;
|
||||
stream << tab.id;
|
||||
stream << tab.username;
|
||||
stream << tab.password;
|
||||
stream << tab.data;
|
||||
stream << entry.host;
|
||||
stream << entry.id;
|
||||
stream << entry.username;
|
||||
stream << entry.password;
|
||||
stream << entry.data;
|
||||
stream << entry.updated;
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream &operator >>(QDataStream &stream, PasswordEntry &tab)
|
||||
QDataStream &operator >>(QDataStream &stream, PasswordEntry &entry)
|
||||
{
|
||||
int version;
|
||||
stream >> version;
|
||||
@ -45,11 +46,12 @@ QDataStream &operator >>(QDataStream &stream, PasswordEntry &tab)
|
||||
return stream;
|
||||
}
|
||||
|
||||
stream >> tab.host;
|
||||
stream >> tab.id;
|
||||
stream >> tab.username;
|
||||
stream >> tab.password;
|
||||
stream >> tab.data;
|
||||
stream >> entry.host;
|
||||
stream >> entry.id;
|
||||
stream >> entry.username;
|
||||
stream >> entry.password;
|
||||
stream >> entry.data;
|
||||
stream >> entry.updated;
|
||||
|
||||
return stream;
|
||||
}
|
||||
@ -98,7 +100,7 @@ void PasswordManager::updateEntry(const PasswordEntry &entry)
|
||||
m_backend->updateEntry(entry);
|
||||
}
|
||||
|
||||
void PasswordManager::updateLastUsed(const PasswordEntry &entry)
|
||||
void PasswordManager::updateLastUsed(PasswordEntry &entry)
|
||||
{
|
||||
ensureLoaded();
|
||||
m_backend->updateLastUsed(entry);
|
||||
|
@ -33,6 +33,9 @@ struct QT_QUPZILLA_EXPORT PasswordEntry {
|
||||
QString username;
|
||||
QString password;
|
||||
QByteArray data;
|
||||
int updated;
|
||||
|
||||
PasswordEntry() : updated(-1) { }
|
||||
|
||||
bool isValid() const {
|
||||
return !password.isEmpty();
|
||||
@ -42,8 +45,12 @@ struct QT_QUPZILLA_EXPORT PasswordEntry {
|
||||
return id == other.id;
|
||||
}
|
||||
|
||||
friend QT_QUPZILLA_EXPORT QDataStream &operator<<(QDataStream &stream, const PasswordEntry &tab);
|
||||
friend QT_QUPZILLA_EXPORT QDataStream &operator>>(QDataStream &stream, PasswordEntry &tab);
|
||||
bool operator<(const PasswordEntry &other) const {
|
||||
return updated > other.updated;
|
||||
}
|
||||
|
||||
friend QT_QUPZILLA_EXPORT QDataStream &operator<<(QDataStream &stream, const PasswordEntry &entry);
|
||||
friend QT_QUPZILLA_EXPORT QDataStream &operator>>(QDataStream &stream, PasswordEntry &entry);
|
||||
};
|
||||
|
||||
class QT_QUPZILLA_EXPORT PasswordManager : public QObject
|
||||
@ -60,7 +67,7 @@ public:
|
||||
|
||||
void addEntry(const PasswordEntry &entry);
|
||||
void updateEntry(const PasswordEntry &entry);
|
||||
void updateLastUsed(const PasswordEntry &entry);
|
||||
void updateLastUsed(PasswordEntry &entry);
|
||||
|
||||
void removeEntry(const PasswordEntry &entry);
|
||||
void removeAllEntries();
|
||||
|
@ -1,6 +1,6 @@
|
||||
include(../../defines.pri)
|
||||
|
||||
contains(DEFINES, "KDE_INTEGRATION") {
|
||||
!mac:unix:contains(DEFINES, "KDE_INTEGRATION") {
|
||||
TARGET = $$qtLibraryTarget(KWalletPasswords)
|
||||
|
||||
SOURCES += kwalletplugin.cpp \
|
||||
|
@ -107,22 +107,22 @@ void KWalletPasswordBackend::updateEntry(const PasswordEntry &entry)
|
||||
}
|
||||
}
|
||||
|
||||
void KWalletPasswordBackend::updateLastUsed(const PasswordEntry &entry)
|
||||
void KWalletPasswordBackend::updateLastUsed(PasswordEntry &entry)
|
||||
{
|
||||
initialize();
|
||||
|
||||
QString id = QString("%1/%2").arg(entry.host, QString::number(QDateTime::currentDateTime().toTime_t()));
|
||||
|
||||
PasswordEntry stored = entry;
|
||||
stored.id = id;
|
||||
|
||||
m_wallet->removeEntry(entry.id.toString());
|
||||
m_wallet->writeEntry(stored.id.toString(), encodeEntry(stored));
|
||||
|
||||
int index = m_allEntries.indexOf(entry);
|
||||
entry.id = id;
|
||||
|
||||
m_wallet->writeEntry(entry.id.toString(), encodeEntry(entry));
|
||||
|
||||
|
||||
if (index > -1) {
|
||||
m_allEntries[index] = stored;
|
||||
m_allEntries[index] = entry;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
|
||||
void addEntry(const PasswordEntry &entry);
|
||||
void updateEntry(const PasswordEntry &entry);
|
||||
void updateLastUsed(const PasswordEntry &entry);
|
||||
void updateLastUsed(PasswordEntry &entry);
|
||||
|
||||
void removeEntry(const PasswordEntry &entry);
|
||||
void removeAll();
|
||||
|
Loading…
Reference in New Issue
Block a user