Non-sensitive data for password generator is stored using the iStorage interface.
The name field uses an auto-completer with data from the Storage module.
# Qt modules
include(${QT_USE_FILE})
# Qt modules
include(${QT_USE_FILE})
-# Needed for exporting/importing symbols
-add_definitions(-DPSWGEN_GUI_LIBRARY)
-
# Include files
include_directories(${eVaf_INCLUDE})
# Required eVaf libraries
# Include files
include_directories(${eVaf_INCLUDE})
# Required eVaf libraries
-set(eVaf_LIBRARIES CommonLib PluginsLib SdiWindow PswGen)
+set(eVaf_LIBRARIES CommonLib PluginsLib SdiWindow)
#include "version.h"
#include "Generator/iGenerator"
#include "version.h"
#include "Generator/iGenerator"
+#include "Storage/iStorage"
#include <Common/Globals>
#include <Common/iLogger>
#include <Common/Globals>
#include <Common/iLogger>
: Plugins::iPlugin()
, mReady(false)
, mGenerator(0)
: Plugins::iPlugin()
, mReady(false)
, mGenerator(0)
{
setObjectName(QString("%1.%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__));
{
setObjectName(QString("%1.%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__));
// Get the iGenerator interface
EVAF_TEST_X((mGenerator = evafQueryInterface<PswGen::iGenerator>("iGenerator")), "No iGenerator interface");
// Get the iGenerator interface
EVAF_TEST_X((mGenerator = evafQueryInterface<PswGen::iGenerator>("iGenerator")), "No iGenerator interface");
+ // Get the iStorage interface (can be null)
+ mStorage = evafQueryInterface<PswGen::iStorage>("iStorage");
+ if (!mStorage)
+ EVAF_WARNING("No iStorage interface");
+
// Get the main window interface and fill it with the widgets
SdiWindow::iSdiWindow * win = evafQueryInterface<SdiWindow::iSdiWindow>("iSdiWindow");
EVAF_TEST_X(win, "No iSdiWindow interface");
// Get the main window interface and fill it with the widgets
SdiWindow::iSdiWindow * win = evafQueryInterface<SdiWindow::iSdiWindow>("iSdiWindow");
EVAF_TEST_X(win, "No iSdiWindow interface");
wName = new QLineEdit;
l->setBuddy(wName);
wName = new QLineEdit;
l->setBuddy(wName);
+ if (mStorage) {
+ QCompleter * completer = new QCompleter(wName);
+ completer->setModel(mStorage->autoCompletionModel());
+ completer->setCompletionMode(QCompleter::InlineCompletion);
+ wName->setCompleter(completer);
+ }
connect(wName, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
g->addWidget(wName, 0, 1, 1, 2);
win->widget()->setFocusProxy(wName);
connect(wName, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
g->addWidget(wName, 0, 1, 1, 2);
win->widget()->setFocusProxy(wName);
void Module::textChanged(QString const &)
{
wGenerate->setDisabled(wMasterPassword->text().isEmpty() || wName->text().isEmpty());
void Module::textChanged(QString const &)
{
wGenerate->setDisabled(wMasterPassword->text().isEmpty() || wName->text().isEmpty());
+ if (!wName->text().isEmpty() && mStorage) {
+ QExplicitlySharedDataPointer<PswGen::Storage::Data> data = mStorage->query(wName->text());
+ if (data)
+ wLength->setValue(data->length());
+ }
}
void Module::generateClicked()
}
void Module::generateClicked()
return;
wPassword->setText(mGenerator->generatePassword(wName->text(), wMasterPassword->text(), wLength->value()));
wCopy->setEnabled(true);
return;
wPassword->setText(mGenerator->generatePassword(wName->text(), wMasterPassword->text(), wLength->value()));
wCopy->setEnabled(true);
+ if (mStorage) {
+ QExplicitlySharedDataPointer<PswGen::Storage::Data> data = mStorage->query(wName->text());
+ if (!data)
+ data = new Storage::Data(wLength->value());
+ else
+ data->setLength(wLength->value());
+ mStorage->save(wName->text(), data);
+ }
}
void Module::copyClicked()
}
void Module::copyClicked()
namespace eVaf {
namespace PswGen {
class iGenerator;
namespace eVaf {
namespace PswGen {
class iGenerator;
/// The iGenerator interface
eVaf::PswGen::iGenerator * mGenerator;
/// The iGenerator interface
eVaf::PswGen::iGenerator * mGenerator;
+ /// The iStorage interface (can be null)
+ eVaf::PswGen::iStorage * mStorage;
+
/// Widgets on the screen
QLineEdit * wName;
QLineEdit * wMasterPassword;
/// Widgets on the screen
QLineEdit * wName;
QLineEdit * wMasterPassword;