mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
[PasswordManager] Small cleanups + offer plugins to add new backends.
This commit is contained in:
parent
ac90002b6f
commit
f8ee9a4b9c
|
@ -44,6 +44,11 @@ AutoFill::AutoFill(QObject* parent)
|
|||
loadSettings();
|
||||
}
|
||||
|
||||
PasswordManager* AutoFill::passwordManager() const
|
||||
{
|
||||
return m_manager;
|
||||
}
|
||||
|
||||
void AutoFill::loadSettings()
|
||||
{
|
||||
Settings settings;
|
||||
|
@ -127,6 +132,7 @@ void AutoFill::addEntry(const QUrl &url, const PageFormData &formData)
|
|||
entry.host = PasswordManager::createHost(url);
|
||||
entry.username = formData.username;
|
||||
entry.password = formData.password;
|
||||
entry.data = formData.postData;
|
||||
|
||||
m_manager->addEntry(entry);
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ class QT_QUPZILLA_EXPORT AutoFill : public QObject
|
|||
public:
|
||||
explicit AutoFill(QObject* parent = 0);
|
||||
|
||||
PasswordManager* passwordManager() const;
|
||||
void loadSettings();
|
||||
|
||||
bool isStored(const QUrl &url);
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
virtual void removeEntry(const PasswordEntry &entry) = 0;
|
||||
virtual void removeAll() = 0;
|
||||
|
||||
void setActive(bool active);
|
||||
virtual void setActive(bool active);
|
||||
bool isActive() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -22,10 +22,42 @@
|
|||
|
||||
#include <QVector>
|
||||
|
||||
static const int passwordEntryVersion = 1;
|
||||
|
||||
QDataStream &operator <<(QDataStream &stream, const PasswordEntry &tab)
|
||||
{
|
||||
stream << passwordEntryVersion;
|
||||
stream << tab.host;
|
||||
stream << tab.id;
|
||||
stream << tab.username;
|
||||
stream << tab.password;
|
||||
stream << tab.data;
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream &operator >>(QDataStream &stream, PasswordEntry &tab)
|
||||
{
|
||||
int version;
|
||||
stream >> version;
|
||||
|
||||
if (version != passwordEntryVersion) {
|
||||
return stream;
|
||||
}
|
||||
|
||||
stream >> tab.host;
|
||||
stream >> tab.id;
|
||||
stream >> tab.username;
|
||||
stream >> tab.password;
|
||||
stream >> tab.data;
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
PasswordManager::PasswordManager(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_backend(0)
|
||||
, m_loaded(false)
|
||||
, m_backend(0)
|
||||
, m_databaseBackend(new DatabasePasswordBackend)
|
||||
{
|
||||
m_backends["database"] = m_databaseBackend;
|
||||
|
@ -123,3 +155,4 @@ PasswordManager::~PasswordManager()
|
|||
{
|
||||
delete m_databaseBackend;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
class PasswordBackend;
|
||||
class DatabasePasswordBackend;
|
||||
|
||||
struct PasswordEntry {
|
||||
struct QT_QUPZILLA_EXPORT PasswordEntry {
|
||||
QVariant id;
|
||||
QString host;
|
||||
QString username;
|
||||
|
@ -37,6 +37,13 @@ struct PasswordEntry {
|
|||
bool isValid() const {
|
||||
return !password.isEmpty();
|
||||
}
|
||||
|
||||
bool operator==(const PasswordEntry &other) const {
|
||||
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);
|
||||
};
|
||||
|
||||
class QT_QUPZILLA_EXPORT PasswordManager : public QObject
|
||||
|
@ -66,9 +73,9 @@ public:
|
|||
private:
|
||||
void ensureLoaded();
|
||||
|
||||
PasswordBackend* m_backend;
|
||||
bool m_loaded;
|
||||
|
||||
PasswordBackend* m_backend;
|
||||
DatabasePasswordBackend* m_databaseBackend;
|
||||
QHash<QString, PasswordBackend*> m_backends;
|
||||
};
|
||||
|
|
|
@ -79,8 +79,22 @@ private:
|
|||
QList<PluginInterface*> m_keyReleaseHandlers;
|
||||
};
|
||||
|
||||
#define QZ_REGISTER_EVENT_HANDLER(Type) mApp->plugins()->registerAppEventHandler(Type, this);
|
||||
#define QZ_REGISTER_SCHEME_HANDLER(Scheme, Object) mApp->networkManager()->registerSchemeHandler(Scheme, Object);
|
||||
#define QZ_UNREGISTER_SCHEME_HANDLER(Scheme, Object) mApp->networkManager()->unregisterSchemeHandler(Scheme, Object);
|
||||
#include "mainapplication.h"
|
||||
#include "networkmanager.h"
|
||||
#include "autofill.h"
|
||||
#include "passwordmanager.h"
|
||||
|
||||
#define QZ_REGISTER_EVENT_HANDLER(Type) \
|
||||
mApp->plugins()->registerAppEventHandler(Type, this);
|
||||
|
||||
#define QZ_REGISTER_SCHEME_HANDLER(Scheme, Object) \
|
||||
mApp->networkManager()->registerSchemeHandler(Scheme, Object);
|
||||
#define QZ_UNREGISTER_SCHEME_HANDLER(Scheme, Object) \
|
||||
mApp->networkManager()->unregisterSchemeHandler(Scheme, Object);
|
||||
|
||||
#define QZ_REGISTER_PASSWORD_BACKEND(Name, Object) \
|
||||
mApp->autoFill()->passwordManager()->registerBackend(Name, Object);
|
||||
#define QZ_UNREGISTER_PASSWORD_BACKEND(Object) \
|
||||
mApp->autoFill()->passwordManager()->unregisterBackend(Object);
|
||||
|
||||
#endif // PLUGINPROXY_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user