QtPass  1.2.1
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 Insert(QString file, QString value, bool force) = 0;
47  virtual void Remove(QString file, bool isDir) = 0;
48  virtual void Move(const QString srcDir, const QString dest,
49  const bool force = false) = 0;
50  virtual void Copy(const QString srcDir, const QString dest,
51  const bool force = false) = 0;
52  virtual void Init(QString path, const QList<UserInfo> &users) = 0;
53  virtual QString Generate_b(unsigned int length, const QString &charset);
54 
55  void GenerateGPGKeys(QString batch);
56  QList<UserInfo> listKeys(QString keystring = "", bool secret = false);
57  void updateEnv();
58  static QStringList getRecipientList(QString for_file);
59  // TODO(bezet): getRecipientString is useless, refactor
60  static QString getRecipientString(QString for_file, QString separator = " ",
61  int *count = NULL);
62 
63 protected:
64  void executeWrapper(PROCESS id, const QString &app, const QStringList &args,
65  bool readStdout = true, bool readStderr = true);
66  QString generateRandomPassword(const QString &charset, unsigned int length);
67  quint32 boundedRandom(quint32 bound);
68 
69  virtual void executeWrapper(PROCESS id, const QString &app,
70  const QStringList &args, QString input,
71  bool readStdout = true, bool readStderr = true);
72 
73 protected slots:
74  virtual void finished(int id, int exitCode, const QString &out,
75  const QString &err);
76 
77 signals:
78  void error(QProcess::ProcessError);
80  void statusMsg(QString, int);
81  void critical(QString, QString);
82 
83  void processErrorExit(int exitCode, const QString &err);
84 
85  void finishedAny(const QString &, const QString &);
86  void finishedGitInit(const QString &, const QString &);
87  void finishedGitPull(const QString &, const QString &);
88  void finishedGitPush(const QString &, const QString &);
89  void finishedShow(const QString &);
90  void finishedInsert(const QString &, const QString &);
91  void finishedRemove(const QString &, const QString &);
92  void finishedInit(const QString &, const QString &);
93  void finishedMove(const QString &, const QString &);
94  void finishedCopy(const QString &, const QString &);
95  void finishedGenerate(const QString &, const QString &);
96  void finishedGenerateGPGKeys(const QString &, const QString &);
97 };
98 
99 #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:106
void finishedGenerateGPGKeys(const QString &, const QString &)
PROCESS
Definition: enums.h:16
void finishedGitPush(const QString &, const QString &)
void error(QProcess::ProcessError)
QList< UserInfo > listKeys(QString keystring="", bool secret=false)
Pass::listKeys list users.
Definition: pass.cpp:120
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:307
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:12
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
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:164
void finishedAny(const QString &, const QString &)
static QString getRecipientString(QString for_file, QString separator=" ", int *count=NULL)
Pass::getRecipientString formated string for use with GPG.
Definition: pass.cpp:267
virtual void GitPull_b()=0
void init()
Definition: pass.cpp:39
static QStringList getRecipientList(QString for_file)
Pass::getRecipientList return list of gpg-id&#39;s to encrypt for.
Definition: pass.cpp:231
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:63
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:25
quint32 boundedRandom(quint32 bound)
Definition: pass.cpp:281
void updateEnv()
Pass::updateEnv update the execution environment (used when switching profiles)
Definition: pass.cpp:210
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)