1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/*
* Copyright (C) 2009 Rolf Eike Beer <[email protected]>
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef KGPGEXPORT_H
#define KGPGEXPORT_H
#include <QObject>
#include <QStringList>
#include <QUrl>
#include "kgpgtransaction.h"
class QProcess;
/**
* @brief export one or more keys from keyring
*
* The exported keys can be written to a file or sent to standard input of another
* QProcess.
*/
class KGpgExport: public KGpgTransaction {
Q_OBJECT
KGpgExport(); // = delete C++0x
Q_DISABLE_COPY(KGpgExport)
public:
/**
* @brief export keys to QProcess
* @param parent parent object
* @param ids ids to export
* @param outp process to write into
* @param options additional options to pass to GnuPG (e.g. export ascii armored)
* @param secret if secret key exporting is allowed
*/
KGpgExport(QObject *parent, const QStringList &ids, QProcess *outp, const QStringList &options = QStringList(), const bool secret = false);
/**
* @brief export keys to KGpgTransaction
* @param parent parent object
* @param ids ids to export
* @param outt transaction to write into
* @param options additional options to pass to GnuPG (e.g. export ascii armored)
* @param secret if secret key exporting is allowed
*/
KGpgExport(QObject *parent, const QStringList &ids, KGpgTransaction *outt, const QStringList &options = QStringList(), const bool secret = false);
/**
* @brief export keys to file
* @param parent parent object
* @param ids ids to export
* @param file filename to write into
* @param options additional options to pass to GnuPG (e.g. export ascii armored)
* @param secret if secret key exporting is allowed
*/
KGpgExport(QObject *parent, const QStringList &ids, const QString &file, const QStringList &options = QStringList(), const bool secret = false);
/**
* @brief export keys to standard output
* @param parent parent object
* @param ids ids to export
* @param options additional options to pass to GnuPG (e.g. export ascii armored)
* @param secret if secret key exporting is allowed
*
* Only ascii-armored export is supported in standard output mode. If it is not
* already set in the given option it will be added automatically.
*/
KGpgExport(QObject *parent, const QStringList &ids, const QStringList &options = QStringList(), const bool secret = false);
/**
* @brief destructor
*/
virtual ~KGpgExport();
/**
* @brief set key id to export
* @param id key fingerprint
*/
void setKeyId(const QString &id);
/**
* @brief set key ids to export
* @param ids key fingerprints
*/
void setKeyIds(const QStringList &ids);
/**
* @brief return the key ids to export
* @return list of key fingerprints
*/
const QStringList &getKeyIds() const;
/**
* @brief set the process the output is sent to
* @param outp process to send output to
*/
void setOutputProcess(QProcess *outp);
/**
* @brief set the transaction the output is sent to
* @param outd transaction to send output to
*/
void setOutputTransaction(KGpgTransaction *outt);
/**
* @brief set filename to send output to
* @param filename file to send output to
*/
void setOutputFile(const QString &filename);
/**
* @brief return the output filename currently set
* @return filename key will get written to
*/
const QString &getOutputFile() const;
/**
* @brief return the data read from standard output
* @return standard output data
*/
const QByteArray &getOutputData() const;
protected:
virtual bool preStart();
virtual bool nextLine(const QString &line);
private:
QStringList m_keyids;
QProcess *m_outp;
QString m_outf;
QByteArray m_data;
enum OutputMode {
ModeFile = 0,
ModeProcess = 1,
ModeStdout = 2,
ModeTransaction = 3
};
enum OutputMode m_outputmode;
void procSetup(const QStringList &options, const bool secret);
};
#endif // KGPGEXPORT_H
|