X-Git-Url: https://vaikene.ee/gitweb/pswgen11.html?a=blobdiff_plain;f=src%2Fapps%2FPswGen%2FCLI%2Fcli.cpp;h=cd18b852b7f096660a5ac1ecf6130b12242d4f11;hb=602faa7b96d4467f127ccd581228ca7245283c32;hp=fbc8450ebe37f2ec2ddba2170994a536587df353;hpb=cdc02ee6da9c883125d5cff563bdcfcc0bf2b7b8;p=evaf
diff --git a/src/apps/PswGen/CLI/cli.cpp b/src/apps/PswGen/CLI/cli.cpp
index fbc8450..cd18b85 100644
--- a/src/apps/PswGen/CLI/cli.cpp
+++ b/src/apps/PswGen/CLI/cli.cpp
@@ -54,8 +54,8 @@ int const Module::DefaultPasswordLength = 16;
Module::Module()
: Plugins::iPlugin()
, mReady(false)
- , mGenerator(false)
- , mStorage(false)
+ , mGenerator(0)
+ , mStorage(0)
, mEvReady(0)
{
setObjectName(QString("%1-Module").arg(VER_MODULE_NAME_STR));
@@ -159,7 +159,7 @@ void Module::generatePassword()
{
QString masterPassword;
QString appName;
- int passwordLength = DefaultPasswordLength;
+ int passwordLength = 0;
// Process command-line arguments
QStringList args = QCoreApplication::arguments();
@@ -199,10 +199,14 @@ void Module::generatePassword()
QExplicitlySharedDataPointer data;
if (mStorage) {
data = mStorage->query(appName);
- if (data)
+ if (data && passwordLength == 0)
passwordLength = data->length();
}
+ // If the length argument is still not initialized, use the default length value
+ if (!passwordLength)
+ passwordLength = DefaultPasswordLength;
+
// Generate password
QString password = mGenerator->generatePassword(appName, masterPassword, passwordLength);
cout << "Generated password : " << password << endl;
@@ -211,6 +215,8 @@ void Module::generatePassword()
if (mStorage) {
if (!data)
data = new Storage::Data(appName, passwordLength);
+ else
+ data->setLength(passwordLength);
mStorage->save(appName, data);
}
}