10#include "job/attachmentjob.h"
11#include "contentjobbase_p.h"
12#include "job/singlepartjob.h"
13#include "part/globalpart.h"
14#include "utils/util.h"
16#include "messagecomposer_debug.h"
19using namespace MessageCore;
21class MessageComposer::AttachmentJobPrivate :
public ContentJobBasePrivate
24 AttachmentJobPrivate(AttachmentJob *qq)
25 : ContentJobBasePrivate(qq)
31 Q_DECLARE_PUBLIC(AttachmentJob)
41AttachmentJob::~AttachmentJob() =
default;
45 Q_D(
const AttachmentJob);
55void AttachmentJob::doStart()
60 if (d->part->mimeType() ==
"multipart/digest" || d->part->mimeType() ==
"message/rfc822") {
65 auto part =
new KMime::Content;
66 part->setContent(d->part->data());
68 d->subjobContents << part;
74 auto sjob =
new SinglepartJob(
this);
75 sjob->setData(d->part->data());
80 if (d->part->mimeType() ==
"message/rfc822") {
81 sjob->contentTransferEncoding()->setEncoding(KMime::Headers::CE7Bit);
83 sjob->contentTransferEncoding()->setEncoding(d->part->encoding());
86 auto ct = sjob->contentType();
87 ct->setMimeType(d->part->mimeType());
88 ct->setName(d->part->name());
96 QByteArray textCharset = d->part->charset();
98 qCWarning(MESSAGECOMPOSER_LOG) <<
"No charset specified. Using UTF-8.";
99 textCharset =
"utf-8";
101 ct->setCharset(textCharset);
104 sjob->contentDescription()->fromUnicodeString(d->part->description());
106 auto contentDisposition = sjob->contentDisposition();
107 contentDisposition->setFilename(d->part->fileName());
108 contentDisposition->setRFC2047Charset(
"utf-8");
109 if (d->part->isInline()) {
110 contentDisposition->setDisposition(KMime::Headers::CDinline);
112 contentDisposition->setDisposition(KMime::Headers::CDattachment);
118void AttachmentJob::process()
122 Q_ASSERT(d->subjobContents.count() == 1);
123 d->resultContent = d->subjobContents.constFirst();
127#include "moc_attachmentjob.cpp"
QSharedPointer< AttachmentPart > Ptr
Defines a pointer to an attachment object.
The ContentJobBase class.
virtual void doStart()
Reimplement to do additional stuff before processing children, such as adding more subjobs.
Simple interface that both EncryptJob and SignEncryptJob implement so the composer can extract some e...
bool isEmpty() const const