Implement review feedback

This commit is contained in:
Janek Bevendorff 2018-10-19 21:41:42 +02:00
parent bea31f9bcc
commit 0ca7fd369a
14 changed files with 59 additions and 65 deletions

View file

@ -76,7 +76,7 @@ int Remove::removeEntry(Database* database, const QString& databasePath, const Q
QTextStream out(Utils::STDOUT, QIODevice::WriteOnly);
QTextStream err(Utils::STDERR, QIODevice::WriteOnly);
Entry* entry = database->rootGroup()->findEntryByPath(entryPath);
QPointer<Entry> entry = database->rootGroup()->findEntryByPath(entryPath);
if (!entry) {
err << QObject::tr("Entry %1 not found.").arg(entryPath) << endl;
return EXIT_FAILURE;
@ -84,7 +84,8 @@ int Remove::removeEntry(Database* database, const QString& databasePath, const Q
QString entryTitle = entry->title();
bool recycled = true;
if (Tools::hasChild(database->metadata()->recycleBin(), entry) || !database->metadata()->recycleBinEnabled()) {
auto* recycleBin = database->metadata()->recycleBin();
if (!database->metadata()->recycleBinEnabled() || (recycleBin && recycleBin->findEntryByUuid(entry->uuid()))) {
delete entry;
recycled = false;
} else {

View file

@ -72,6 +72,8 @@ void setStdinEcho(bool enable = true)
#endif
}
namespace Test
{
QStringList nextPasswords = {};
/**
@ -85,6 +87,7 @@ void setNextPassword(const QString& password)
{
nextPasswords.append(password);
}
} // namespace Test
/**
* Read a user password from STDIN or return a password previously
@ -97,8 +100,8 @@ QString getPassword()
QTextStream out(STDOUT, QIODevice::WriteOnly);
// return preset password if one is set
if (!nextPasswords.isEmpty()) {
auto password = nextPasswords.takeFirst();
if (!Test::nextPasswords.isEmpty()) {
auto password = Test::nextPasswords.takeFirst();
// simulate user entering newline
out << endl;
return password;

View file

@ -29,8 +29,12 @@ extern FILE* STDIN;
void setStdinEcho(bool enable);
QString getPassword();
void setNextPassword(const QString& password);
int clipText(const QString& text);
namespace Test
{
void setNextPassword(const QString& password);
}
};
#endif // KEEPASSXC_UTILS_H

View file

@ -40,7 +40,7 @@ int main(int argc, char** argv)
}
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationVersion(KEEPASSX_VERSION);
QCoreApplication::setApplicationVersion(KEEPASSXC_VERSION);
#ifdef QT_NO_DEBUG
Bootstrap::bootstrapApplication();
@ -72,7 +72,7 @@ int main(int argc, char** argv)
if (parser.positionalArguments().empty()) {
if (parser.isSet("version")) {
// Switch to parser.showVersion() when available (QT 5.4).
out << KEEPASSX_VERSION << endl;
out << KEEPASSXC_VERSION << endl;
return EXIT_SUCCESS;
}
parser.showHelp();