summaryrefslogtreecommitdiffstats
path: root/src/pass.cpp
diff options
context:
space:
mode:
authorClaudio Maradonna <penguyman@stronzi.org>2018-07-24 01:26:22 +0200
committerClaudio Maradonna <penguyman@stronzi.org>2018-07-24 01:26:22 +0200
commit094967fb68c0350d6234cd9374bf24748d7f4133 (patch)
treed6df6569754661cce1882e5aa73873383acadbac /src/pass.cpp
parent9ff9147be35f498ec33e42f44a7aa66f9274524e (diff)
Now qDebug enable only if QT_DEBUG is defined. Trying to refactoring MainWindow - QtPass class should handle connecctions and business logic
Diffstat (limited to 'src/pass.cpp')
-rw-r--r--src/pass.cpp75
1 files changed, 41 insertions, 34 deletions
diff --git a/src/pass.cpp b/src/pass.cpp
index 2586b252..e81b4686 100644
--- a/src/pass.cpp
+++ b/src/pass.cpp
@@ -1,8 +1,11 @@
#include "pass.h"
-#include "debughelper.h"
#include "qtpasssettings.h"
#include "util.h"
+#ifdef QT_DEBUG
+#include "debughelper.h"
+#endif
+
using namespace std;
using namespace Enums;
@@ -31,7 +34,9 @@ void Pass::executeWrapper(PROCESS id, const QString &app,
void Pass::executeWrapper(PROCESS id, const QString &app,
const QStringList &args, QString input,
bool readStdout, bool readStderr) {
+#ifdef QT_DEBUG
dbg() << app << args;
+#endif
exec.execute(id, QtPassSettings::getPassStore(), app, args, input, readStdout,
readStderr);
}
@@ -118,41 +123,41 @@ void Pass::GenerateGPGKeys(QString batch) {
* @return QList<UserInfo> users
*/
QList<UserInfo> Pass::listKeys(QStringList keystrings, bool secret) {
- QList<UserInfo> users;
- QStringList args = {"--no-tty", "--with-colons"};
- args.append(secret ? "--list-secret-keys" : "--list-keys");
+ QList<UserInfo> users;
+ QStringList args = {"--no-tty", "--with-colons"};
+ args.append(secret ? "--list-secret-keys" : "--list-keys");
- foreach (QString keystring, keystrings) {
- if(!keystring.isEmpty()) {
- args.append(keystring);
- }
+ foreach (QString keystring, keystrings) {
+ if (!keystring.isEmpty()) {
+ args.append(keystring);
}
- QString p_out;
- if (exec.executeBlocking(QtPassSettings::getGpgExecutable(), args, &p_out) !=
- 0)
- return users;
- QStringList keys = p_out.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
- UserInfo current_user;
- foreach (QString key, keys) {
- QStringList props = key.split(':');
- if (props.size() < 10)
- continue;
- if (props[0] == (secret ? "sec" : "pub")) {
- if (!current_user.key_id.isEmpty())
- users.append(current_user);
- current_user = UserInfo();
- current_user.key_id = props[4];
- current_user.name = props[9].toUtf8();
- current_user.validity = props[1][0].toLatin1();
- current_user.created.setTime_t(props[5].toUInt());
- current_user.expiry.setTime_t(props[6].toUInt());
- } else if (current_user.name.isEmpty() && props[0] == "uid") {
- current_user.name = props[9];
- }
- }
- if (!current_user.key_id.isEmpty())
- users.append(current_user);
+ }
+ QString p_out;
+ if (exec.executeBlocking(QtPassSettings::getGpgExecutable(), args, &p_out) !=
+ 0)
return users;
+ QStringList keys = p_out.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
+ UserInfo current_user;
+ foreach (QString key, keys) {
+ QStringList props = key.split(':');
+ if (props.size() < 10)
+ continue;
+ if (props[0] == (secret ? "sec" : "pub")) {
+ if (!current_user.key_id.isEmpty())
+ users.append(current_user);
+ current_user = UserInfo();
+ current_user.key_id = props[4];
+ current_user.name = props[9].toUtf8();
+ current_user.validity = props[1][0].toLatin1();
+ current_user.created.setTime_t(props[5].toUInt());
+ current_user.expiry.setTime_t(props[6].toUInt());
+ } else if (current_user.name.isEmpty() && props[0] == "uid") {
+ current_user.name = props[9];
+ }
+ }
+ if (!current_user.key_id.isEmpty())
+ users.append(current_user);
+ return users;
}
/**
@@ -214,7 +219,9 @@ void Pass::finished(int id, int exitCode, const QString &out,
emit finishedCopy(out, err);
break;
default:
+#ifdef QT_DEBUG
dbg() << "Unhandled process type" << pid;
+#endif
break;
}
}
@@ -281,7 +288,7 @@ QStringList Pass::getRecipientList(QString for_file) {
* @return recepient string
*/
QStringList Pass::getRecipientString(QString for_file, QString separator,
- int *count) {
+ int *count) {
return Pass::getRecipientList(for_file);
}