From 06323ee7b8ef49ec481279eb9d9a55936daafd93 Mon Sep 17 00:00:00 2001 From: nowrep Date: Wed, 15 May 2013 15:04:48 +0200 Subject: [PATCH] [PasswordManager] Make backends aware of being active. --- .../passwordbackends/passwordbackend.cpp | 33 +++++++++++++++++++ .../passwordbackends/passwordbackend.h | 8 ++++- src/lib/autofill/passwordmanager.cpp | 1 + src/lib/lib.pro | 3 +- 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/lib/autofill/passwordbackends/passwordbackend.cpp diff --git a/src/lib/autofill/passwordbackends/passwordbackend.cpp b/src/lib/autofill/passwordbackends/passwordbackend.cpp new file mode 100644 index 000000000..44632c7cb --- /dev/null +++ b/src/lib/autofill/passwordbackends/passwordbackend.cpp @@ -0,0 +1,33 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2013 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "passwordbackend.h" + +PasswordBackend::PasswordBackend() + : m_active(false) +{ +} + +void PasswordBackend::setActive(bool active) +{ + m_active = active; +} + +bool PasswordBackend::isActive() const +{ + return m_active; +} diff --git a/src/lib/autofill/passwordbackends/passwordbackend.h b/src/lib/autofill/passwordbackends/passwordbackend.h index f4b990b9b..6bb5626e8 100644 --- a/src/lib/autofill/passwordbackends/passwordbackend.h +++ b/src/lib/autofill/passwordbackends/passwordbackend.h @@ -23,7 +23,7 @@ class PasswordBackend { public: - explicit PasswordBackend() { } + explicit PasswordBackend(); virtual ~PasswordBackend() { } virtual QVector getEntries(const QUrl &url) = 0; @@ -35,6 +35,12 @@ public: virtual void removeEntry(const PasswordEntry &entry) = 0; virtual void removeAll() = 0; + + void setActive(bool active); + bool isActive() const; + +private: + bool m_active; }; #endif // PASSWORDBACKEND_H diff --git a/src/lib/autofill/passwordmanager.cpp b/src/lib/autofill/passwordmanager.cpp index 6382aa4b1..4b93e6921 100644 --- a/src/lib/autofill/passwordmanager.cpp +++ b/src/lib/autofill/passwordmanager.cpp @@ -39,6 +39,7 @@ void PasswordManager::loadSettings() settings.endGroup(); m_backend = m_backends[m_backends.contains(backendId) ? backendId : "database"]; + m_backend->setActive(true); } QVector PasswordManager::getEntries(const QUrl &url) diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 9d2a61880..26af73c2a 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -217,7 +217,8 @@ SOURCES += \ network/pac/pacmanager.cpp \ tools/delayedfilewatcher.cpp \ autofill/passwordmanager.cpp \ - autofill/passwordbackends/databasepasswordbackend.cpp + autofill/passwordbackends/databasepasswordbackend.cpp \ + autofill/passwordbackends/passwordbackend.cpp HEADERS += \ webview/tabpreview.h \