Changeset View
Changeset View
Standalone View
Standalone View
framework/src/domain/mime/attachmentmodel.cpp
Context not available. | |||||
32 | #include <QUrl> | 32 | #include <QUrl> | ||
---|---|---|---|---|---|
33 | #include <QMimeDatabase> | 33 | #include <QMimeDatabase> | ||
34 | 34 | | |||
35 | #include <QGpgME/ImportJob> | ||||
36 | #include <QGpgME/Protocol> | ||||
37 | | ||||
38 | #include <memory> | ||||
39 | | ||||
35 | QString sizeHuman(float size) | 40 | QString sizeHuman(float size) | ||
36 | { | 41 | { | ||
37 | QStringList list; | 42 | QStringList list; | ||
Context not available. | |||||
210 | return false; | 215 | return false; | ||
211 | } | 216 | } | ||
212 | 217 | | |||
218 | bool AttachmentModel::importPublicKey(const QModelIndex &index) | ||||
219 | { | ||||
220 | Q_ASSERT(index.internalPointer()); | ||||
221 | const auto part = static_cast<MimeTreeParser::MessagePart *>(index.internalPointer()); | ||||
222 | Q_ASSERT(part); | ||||
223 | auto pkey = part->node()->decodedContent(); | ||||
224 | | ||||
225 | const auto *proto = QGpgME::openpgp(); | ||||
226 | std::unique_ptr<QGpgME::ImportJob> job(proto->importJob()); | ||||
227 | auto result = job->exec(pkey); | ||||
228 | | ||||
229 | bool success = true; | ||||
230 | | ||||
231 | QString message; | ||||
232 | if(result.numConsidered() == 0) { | ||||
233 | message = tr("No keys were found in this attachment"); | ||||
234 | success = false; | ||||
235 | } else { | ||||
236 | message = tr("%n Key(s) imported", "", result.numImported()); | ||||
237 | if(result.numUnchanged() != 0) { | ||||
238 | message += "\n" + tr("%n Key(s) were already imported", "", result.numUnchanged()); | ||||
239 | } | ||||
240 | } | ||||
241 | | ||||
242 | Kube::Fabric::Fabric{}.postMessage("notification", | ||||
243 | {{"message", message}}); | ||||
244 | | ||||
245 | return success; | ||||
246 | } | ||||
247 | | ||||
213 | QModelIndex AttachmentModel::parent(const QModelIndex &) const | 248 | QModelIndex AttachmentModel::parent(const QModelIndex &) const | ||
214 | { | 249 | { | ||
215 | return QModelIndex(); | 250 | return QModelIndex(); | ||
Context not available. |