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