Line data Source code
1 : // SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2 : // SPDX-License-Identifier: GPL-3.0-or-later
3 : #ifndef SRC_IMITATEPASS_H_
4 : #define SRC_IMITATEPASS_H_
5 :
6 : #include "pass.h"
7 : #include "simpletransaction.h"
8 :
9 : /*!
10 : \class ImitatePass
11 : \brief Imitates pass features when pass is not enabled or available
12 : */
13 : class ImitatePass : public Pass, private simpleTransaction {
14 0 : Q_OBJECT
15 :
16 : auto verifyGpgIdFile(const QString &file) -> bool;
17 : auto removeDir(const QString &dirName) -> bool;
18 :
19 : void GitCommit(const QString &file, const QString &msg);
20 :
21 : void executeGit(PROCESS id, const QStringList &args,
22 : QString input = QString(), bool readStdout = true,
23 : bool readStderr = true);
24 : void executeGpg(PROCESS id, const QStringList &args,
25 : QString input = QString(), bool readStdout = true,
26 : bool readStderr = true);
27 :
28 : class transactionHelper {
29 : simpleTransaction *m_transaction;
30 : PROCESS m_result;
31 :
32 : public:
33 : transactionHelper(simpleTransaction *trans, PROCESS result)
34 : : m_transaction(trans), m_result(result) {
35 0 : m_transaction->transactionStart();
36 0 : }
37 0 : ~transactionHelper() { m_transaction->transactionEnd(m_result); }
38 : };
39 :
40 : protected:
41 : virtual void finished(int id, int exitCode, const QString &out,
42 : const QString &err) Q_DECL_OVERRIDE;
43 :
44 : virtual void executeWrapper(PROCESS id, const QString &app,
45 : const QStringList &args, QString input,
46 : bool readStdout = true,
47 : bool readStderr = true) Q_DECL_OVERRIDE;
48 :
49 : public:
50 : ImitatePass();
51 46 : virtual ~ImitatePass() {}
52 : virtual void GitInit() Q_DECL_OVERRIDE;
53 : virtual void GitPull() Q_DECL_OVERRIDE;
54 : virtual void GitPull_b() Q_DECL_OVERRIDE;
55 : virtual void GitPush() Q_DECL_OVERRIDE;
56 : virtual void Show(QString file) Q_DECL_OVERRIDE;
57 : virtual void OtpGenerate(QString file) Q_DECL_OVERRIDE;
58 : virtual void Insert(QString file, QString newValue,
59 : bool overwrite = false) Q_DECL_OVERRIDE;
60 : virtual void Remove(QString file, bool isDir = false) Q_DECL_OVERRIDE;
61 : virtual void Init(QString path, const QList<UserInfo> &users) Q_DECL_OVERRIDE;
62 :
63 : void reencryptPath(const QString &dir);
64 : signals:
65 : void startReencryptPath();
66 : void endReencryptPath();
67 :
68 : // Pass interface
69 : public:
70 : void Move(const QString src, const QString dest,
71 : const bool force = false) Q_DECL_OVERRIDE;
72 : void Copy(const QString src, const QString dest,
73 : const bool force = false) Q_DECL_OVERRIDE;
74 : };
75 :
76 : #endif // SRC_IMITATEPASS_H_
|