QtPass  1.2.3
Multi-platform GUI for pass, the standard unix password manager.
pass.h
Go to the documentation of this file.
1 #ifndef PASS_H
2 #define PASS_H
3 
4 #include "enums.h"
5 #include "executor.h"
6 #include "userinfo.h"
7 
8 #include <QProcess>
9 #include <QQueue>
10 #include <QString>
11 #include <cassert>
12 #include <map>
13 
14 #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
15 #include <QRandomGenerator>
16 #else
17 #include <fcntl.h>
18 #include <unistd.h>
19 #endif
20 
25 class Pass : public QObject {
26  Q_OBJECT
27 
28  bool wrapperRunning;
29  QStringList env;
30 
31 protected:
33 
35 
36 public:
37  Pass();
38  void init();
39 
40  virtual ~Pass() {}
41  virtual void GitInit() = 0;
42  virtual void GitPull() = 0;
43  virtual void GitPull_b() = 0;
44  virtual void GitPush() = 0;
45  virtual void Show(QString file) = 0;
46  virtual void OtpGenerate(QString file) = 0;
47  virtual void Insert(QString file, QString value, bool force) = 0;
48  virtual void Remove(QString file, bool isDir) = 0;
49  virtual void Move(const QString srcDir, const QString dest,
50  const bool force = false) = 0;
51  virtual void Copy(const QString srcDir, const QString dest,
52  const bool force = false) = 0;
53  virtual void Init(QString path, const QList<UserInfo> &users) = 0;
54  virtual QString Generate_b(unsigned int length, const QString &charset);
55 
56  void GenerateGPGKeys(QString batch);
57  QList<UserInfo> listKeys(QStringList keystring, bool secret = false);
58  QList<UserInfo> listKeys(QString keystring = "", bool secret = false);
59  void updateEnv();
60  static QStringList getRecipientList(QString for_file);
61  // TODO(bezet): getRecipientString is useless, refactor
62  static QStringList getRecipientString(QString for_file,
63  QString separator = " ",
64  int *count = NULL);
65 
66 protected:
67  void executeWrapper(PROCESS id, const QString &app, const QStringList &args,
68  bool readStdout = true, bool readStderr = true);
69  QString generateRandomPassword(const QString &charset, unsigned int length);
70  quint32 boundedRandom(quint32 bound);
71 
72  virtual void executeWrapper(PROCESS id, const QString &app,
73  const QStringList &args, QString input,
74  bool readStdout = true, bool readStderr = true);
75 
76 protected slots:
77  virtual void finished(int id, int exitCode, const QString &out,
78  const QString &err);
79 
80 signals:
81  void error(QProcess::ProcessError);
83  void statusMsg(QString, int);
84  void critical(QString, QString);
85 
86  void processErrorExit(int exitCode, const QString &err);
87 
88  void finishedAny(const QString &, const QString &);
89  void finishedGitInit(const QString &, const QString &);
90  void finishedGitPull(const QString &, const QString &);
91  void finishedGitPush(const QString &, const QString &);
92  void finishedShow(const QString &);
93  void finishedOtpGenerate(const QString &);
94  void finishedInsert(const QString &, const QString &);
95  void finishedRemove(const QString &, const QString &);
96  void finishedInit(const QString &, const QString &);
97  void finishedMove(const QString &, const QString &);
98  void finishedCopy(const QString &, const QString &);
99  void finishedGenerate(const QString &, const QString &);
100  void finishedGenerateGPGKeys(const QString &, const QString &);
101 };
102 
103 #endif // PASS_H
void finishedMove(const QString &, const QString &)
virtual void Copy(const QString srcDir, const QString dest, const bool force=false)=0
void finishedCopy(const QString &, const QString &)
virtual ~Pass()
Definition: pass.h:40
void GenerateGPGKeys(QString batch)
Pass::GenerateGPGKeys internal gpg keypair generator . .
Definition: pass.cpp:114
void finishedGenerateGPGKeys(const QString &, const QString &)
PROCESS
Definition: enums.h:16
QList< UserInfo > listKeys(QStringList keystring, bool secret=false)
Pass::listKeys list users.
Definition: pass.cpp:128
void finishedGitPush(const QString &, const QString &)
void error(QProcess::ProcessError)
virtual void Move(const QString srcDir, const QString dest, const bool force=false)=0
void finishedInsert(const QString &, const QString &)
QString generateRandomPassword(const QString &charset, unsigned int length)
Definition: pass.cpp:329
Executes external commands for handleing password, git and other data.
Definition: executor.h:12
Enums::PROCESS PROCESS
Definition: pass.h:34
Pass()
Pass::Pass wrapper for using either pass or the pass imitation.
Definition: pass.cpp:15
void finishedRemove(const QString &, const QString &)
void finishedGenerate(const QString &, const QString &)
virtual void GitInit()=0
Acts as an abstraction for pass or pass imitation.
Definition: pass.h:25
Executor exec
Definition: pass.h:32
virtual void Remove(QString file, bool isDir)=0
void finishedGitPull(const QString &, const QString &)
virtual void Show(QString file)=0
static QStringList getRecipientString(QString for_file, QString separator=" ", int *count=NULL)
Pass::getRecipientString formated string for use with GPG.
Definition: pass.cpp:293
void critical(QString, QString)
virtual void finished(int id, int exitCode, const QString &out, const QString &err)
Pass::processFinished reemits specific signal based on what process has finished. ...
Definition: pass.cpp:186
void finishedAny(const QString &, const QString &)
virtual void GitPull_b()=0
void init()
Definition: pass.cpp:45
static QStringList getRecipientList(QString for_file)
Pass::getRecipientList return list of gpg-id&#39;s to encrypt for.
Definition: pass.cpp:257
virtual void GitPush()=0
virtual QString Generate_b(unsigned int length, const QString &charset)
Pass::Generate use either pwgen or internal password generator.
Definition: pass.cpp:69
void statusMsg(QString, int)
virtual void GitPull()=0
void finishedInit(const QString &, const QString &)
void executeWrapper(PROCESS id, const QString &app, const QStringList &args, bool readStdout=true, bool readStderr=true)
Definition: pass.cpp:29
quint32 boundedRandom(quint32 bound)
Definition: pass.cpp:303
void updateEnv()
Pass::updateEnv update the execution environment (used when switching profiles)
Definition: pass.cpp:236
void finishedShow(const QString &)
virtual void Insert(QString file, QString value, bool force)=0
void finishedGitInit(const QString &, const QString &)
void startingExecuteWrapper()
virtual void Init(QString path, const QList< UserInfo > &users)=0
void processErrorExit(int exitCode, const QString &err)
void finishedOtpGenerate(const QString &)
virtual void OtpGenerate(QString file)=0