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 "datahelpers.h"
5 #include "enums.h"
6 #include "executor.h"
7 #include <QDebug>
8 #include <QDir>
9 #include <QList>
10 #include <QProcess>
11 #include <QQueue>
12 #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
13 #include <QRandomGenerator>
14 #else
15 #include <fcntl.h>
16 #include <unistd.h>
17 #endif
18 #include <QString>
19 #include <QTextCodec>
20 #include <cassert>
21 #include <map>
22 
27 class Pass : public QObject {
28  Q_OBJECT
29 
30  bool wrapperRunning;
31  QStringList env;
32 
33 protected:
35 
37 
38 public:
39  Pass();
40  void init();
41 
42  virtual ~Pass() {}
43  virtual void GitInit() = 0;
44  virtual void GitPull() = 0;
45  virtual void GitPull_b() = 0;
46  virtual void GitPush() = 0;
47  virtual void Show(QString file) = 0;
48  virtual void Insert(QString file, QString value, bool force) = 0;
49  virtual void Remove(QString file, bool isDir) = 0;
50  virtual void Move(const QString srcDir, const QString dest,
51  const bool force = false) = 0;
52  virtual void Copy(const QString srcDir, const QString dest,
53  const bool force = false) = 0;
54  virtual void Init(QString path, const QList<UserInfo> &users) = 0;
55  virtual QString Generate_b(unsigned int length, const QString &charset);
56 
57  void GenerateGPGKeys(QString batch);
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 QString getRecipientString(QString for_file, QString separator = " ",
63  int *count = NULL);
64 
65 protected:
66  void executeWrapper(PROCESS id, const QString &app, const QStringList &args,
67  bool readStdout = true, bool readStderr = true);
68  QString generateRandomPassword(const QString &charset, unsigned int length);
69  quint32 boundedRandom(quint32 bound);
70 
71  virtual void executeWrapper(PROCESS id, const QString &app,
72  const QStringList &args, QString input,
73  bool readStdout = true, bool readStderr = true);
74 
75 protected slots:
76  virtual void finished(int id, int exitCode, const QString &out,
77  const QString &err);
78 
79 signals:
80  void error(QProcess::ProcessError);
82  void statusMsg(QString, int);
83  void critical(QString, QString);
84 
85  void processErrorExit(int exitCode, const QString &err);
86 
87  void finishedAny(const QString &, const QString &);
88  void finishedGitInit(const QString &, const QString &);
89  void finishedGitPull(const QString &, const QString &);
90  void finishedGitPush(const QString &, const QString &);
91  void finishedShow(const QString &);
92  void finishedInsert(const QString &, const QString &);
93  void finishedRemove(const QString &, const QString &);
94  void finishedInit(const QString &, const QString &);
95  void finishedMove(const QString &, const QString &);
96  void finishedCopy(const QString &, const QString &);
97  void finishedGenerate(const QString &, const QString &);
98  void finishedGenerateGPGKeys(const QString &, const QString &);
99 };
100 
101 #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:42
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:36
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:27
Executor exec
Definition: pass.h:34
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)