blob: 7fe6deb79fe04cb5a0b82067e0683f87bfa85180 (
plain)
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
|
/*
* Copyright (C) 2008,2009,2010 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 KGPGIMPORT_H
#define KGPGIMPORT_H
#include <QObject>
#include <QList>
#include <QString>
#include <QStringList>
#include <QUrl>
#include "kgpgtextorfiletransaction.h"
class KGpgItemModel;
/**
* @brief import one or more keys into the keyring
*/
class KGpgImport: public KGpgTextOrFileTransaction {
Q_OBJECT
Q_DISABLE_COPY(KGpgImport)
public:
/**
* @brief import given text
* @param parent parent object
* @param text key text to import
*/
explicit KGpgImport(QObject *parent, const QString &text = QString());
/**
* @brief import key(s) from file(s)
* @param parent parent object
* @param files list of file locations to import from
*/
KGpgImport(QObject *parent, const QList<QUrl> &files);
/**
* @brief destructor
*/
virtual ~KGpgImport();
/**
* @brief get the names and short fingerprints of the imported keys
* @return list of keys that were imported
*/
QStringList getImportedKeys() const;
/**
* @brief get the full fingerprints of the imported keys
* @param log transaction log to scan
* @param reason key import reason
* @return list of ids that were imported
*
* You can filter the list of keys returned by the status of that key
* as reported by GnuPG. See doc/DETAILS of GnuPG for the meaning of
* the different flags.
*
* If reason is -1 (the default) all processed key ids are returned.
* If reason is 0 only keys of status 0 (unchanged) are returned. For
* any other value a key is returned if one of his status bits matched
* one of the bits in reason (i.e. (reason & status) != 0).
*/
static QStringList getImportedIds(const QStringList &log, const int reason = -1);
/**
* @brief get the full fingerprints of the imported keys
*
* This is an overloaded member. It calls the static function with the
* result log from this transaction object.
*/
QStringList getImportedIds(const int reason = -1) const;
/**
* @brief get textual summary of the import events
* @return messages describing what was imported
*
* This is an overloaded member. It calls the static function with the
* result log from this transaction object.
*/
QString getImportMessage() const;
/**
* @brief get textual summary of the import events
* @param log import log
* @return messages describing what was imported
*
* The log must contain a "IMPORT_RES" line. If this is not present
* the result string will contain an error message.
*/
static QString getImportMessage(const QStringList &log);
/**
* @brief get detailed summary of import
* @param log import log
* @return message describing which keys changed and how
*
* The log must contain a "IMPORT_RES" line. If this is not present
* the result string will contain an error message.
*/
static QString getDetailedImportMessage(const QStringList &log, const KGpgItemModel *model = NULL);
/**
* @brief check if the given text contains a private or public key
* @param text text to check
* @param incomplete assume text is only the beginning of the data
* @return if text contains a key or not
* @retval 0 no key found
* @retval 1 public key found
* @retval 2 private key found
*/
static int isKey(const QString &text, const bool incomplete = false);
protected:
virtual QStringList command() const;
};
#endif // KGPGIMPORT_H
|