diff --git a/messagecore/autotests/attachmentupdatejobtest.cpp b/messagecore/autotests/attachmentupdatejobtest.cpp index 0cf3205d..e438c5d1 100644 --- a/messagecore/autotests/attachmentupdatejobtest.cpp +++ b/messagecore/autotests/attachmentupdatejobtest.cpp @@ -1,224 +1,227 @@ /* Copyright (c) 2014-2017 Montel Laurent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "attachmentupdatejobtest.h" #include #include #include #include "qtest_messagecore.h" #define PATH_ATTACHMENTS QLatin1String( KDESRCDIR "/attachments/" ) AttachmentUpdateJobTest::AttachmentUpdateJobTest(QObject *parent) : QObject(parent) { } AttachmentUpdateJobTest::~AttachmentUpdateJobTest() { } void AttachmentUpdateJobTest::shouldHaveDefaultValue() { MessageCore::AttachmentPart::Ptr origPart = MessageCore::AttachmentPart::Ptr(new MessageCore::AttachmentPart); MessageCore::AttachmentUpdateJob *job = new MessageCore::AttachmentUpdateJob(origPart, this); QCOMPARE(origPart, job->originalPart()); QVERIFY(!job->updatedPart()); delete job; } void AttachmentUpdateJobTest::shouldUpdateAttachment() { const QUrl url = QUrl::fromLocalFile(PATH_ATTACHMENTS + QString::fromLatin1("file.txt")); // Some data. QByteArray data("This is short enough that compressing it is not efficient."); const QString name = QString::fromLatin1("name.txt"); const QString description = QString::fromLatin1("description"); // Create the original part. MessageCore::AttachmentPart::Ptr origPart = MessageCore::AttachmentPart::Ptr(new MessageCore::AttachmentPart); origPart->setName(name); origPart->setDescription(description); origPart->setMimeType("text/plain"); origPart->setEncoding(KMime::Headers::CE7Bit); origPart->setData(data); origPart->setUrl(url); MessageCore::AttachmentUpdateJob *job = new MessageCore::AttachmentUpdateJob(origPart, this); VERIFYEXEC(job); QVERIFY(origPart->size() != job->updatedPart()->size()); QVERIFY(origPart->data() != job->updatedPart()->data()); } void AttachmentUpdateJobTest::shouldHaveSameNameDescriptionAfterUpdate() { const QUrl url = QUrl::fromLocalFile(PATH_ATTACHMENTS + QString::fromLatin1("file.txt")); // Some data. QByteArray data("This is short enough that compressing it is not efficient."); const QString name = QString::fromLatin1("name.txt"); const QString description = QString::fromLatin1("description"); + const QString filename = QString::fromLatin1("filename"); // Create the original part. MessageCore::AttachmentPart::Ptr origPart = MessageCore::AttachmentPart::Ptr(new MessageCore::AttachmentPart); origPart->setName(name); + origPart->setFileName(filename); origPart->setDescription(description); origPart->setMimeType("text/plain"); origPart->setEncoding(KMime::Headers::CE7Bit); origPart->setData(data); origPart->setUrl(url); MessageCore::AttachmentUpdateJob *job = new MessageCore::AttachmentUpdateJob(origPart, this); VERIFYEXEC(job); QCOMPARE(origPart->name(), job->updatedPart()->name()); QCOMPARE(origPart->description(), job->updatedPart()->description()); + QCOMPARE(origPart->fileName(), job->updatedPart()->fileName()); } void AttachmentUpdateJobTest::shouldHaveSameCryptoSignStatusAfterUpdate() { const QUrl url = QUrl::fromLocalFile(PATH_ATTACHMENTS + QString::fromLatin1("file.txt")); // Some data. QByteArray data("This is short enough that compressing it is not efficient."); const QString name = QString::fromLatin1("name.txt"); const QString description = QString::fromLatin1("description"); // Create the original part. MessageCore::AttachmentPart::Ptr origPart = MessageCore::AttachmentPart::Ptr(new MessageCore::AttachmentPart); origPart->setName(name); origPart->setDescription(description); origPart->setMimeType("text/plain"); origPart->setEncoding(KMime::Headers::CE7Bit); origPart->setData(data); origPart->setUrl(url); origPart->setSigned(true); origPart->setEncrypted(true); MessageCore::AttachmentUpdateJob *job = new MessageCore::AttachmentUpdateJob(origPart, this); VERIFYEXEC(job); QCOMPARE(origPart->isSigned(), job->updatedPart()->isSigned()); QCOMPARE(origPart->isEncrypted(), job->updatedPart()->isEncrypted()); } void AttachmentUpdateJobTest::shouldHaveSameEncodingAfterUpdate() { const QUrl url = QUrl::fromLocalFile(PATH_ATTACHMENTS + QString::fromLatin1("file.txt")); // Some data. QByteArray data("This is short enough that compressing it is not efficient."); const QString name = QString::fromLatin1("name.txt"); const QString description = QString::fromLatin1("description"); // Create the original part. MessageCore::AttachmentPart::Ptr origPart = MessageCore::AttachmentPart::Ptr(new MessageCore::AttachmentPart); origPart->setName(name); origPart->setDescription(description); origPart->setMimeType("text/pdf"); origPart->setEncoding(KMime::Headers::CE8Bit); origPart->setData(data); origPart->setUrl(url); origPart->setSigned(true); origPart->setEncrypted(true); MessageCore::AttachmentUpdateJob *job = new MessageCore::AttachmentUpdateJob(origPart, this); VERIFYEXEC(job); QCOMPARE(origPart->encoding(), job->updatedPart()->encoding()); } void AttachmentUpdateJobTest::shouldHaveSameMimetypeAfterUpdate() { const QUrl url = QUrl::fromLocalFile(PATH_ATTACHMENTS + QString::fromLatin1("file.txt")); // Some data. QByteArray data("This is short enough that compressing it is not efficient."); const QString name = QString::fromLatin1("name.txt"); const QString description = QString::fromLatin1("description"); // Create the original part. MessageCore::AttachmentPart::Ptr origPart = MessageCore::AttachmentPart::Ptr(new MessageCore::AttachmentPart); origPart->setName(name); origPart->setDescription(description); origPart->setMimeType("text/pdf"); origPart->setEncoding(KMime::Headers::CE8Bit); origPart->setData(data); origPart->setUrl(url); origPart->setSigned(true); origPart->setEncrypted(true); MessageCore::AttachmentUpdateJob *job = new MessageCore::AttachmentUpdateJob(origPart, this); VERIFYEXEC(job); QCOMPARE(origPart->mimeType(), job->updatedPart()->mimeType()); } void AttachmentUpdateJobTest::shouldNotUpdateWhenUrlIsEmpty() { QByteArray data("This is short enough that compressing it is not efficient."); const QString name = QString::fromLatin1("name.txt"); const QString description = QString::fromLatin1("description"); // Create the original part. MessageCore::AttachmentPart::Ptr origPart = MessageCore::AttachmentPart::Ptr(new MessageCore::AttachmentPart); origPart->setName(name); origPart->setDescription(description); origPart->setMimeType("text/plain"); origPart->setEncoding(KMime::Headers::CE7Bit); origPart->setData(data); MessageCore::AttachmentUpdateJob *job = new MessageCore::AttachmentUpdateJob(origPart, this); job->exec(); QVERIFY(!job->updatedPart()); } void AttachmentUpdateJobTest::shouldHaveSameInlineStatus() { const QUrl url = QUrl::fromLocalFile(PATH_ATTACHMENTS + QString::fromLatin1("file.txt")); // Some data. QByteArray data("This is short enough that compressing it is not efficient."); const QString name = QStringLiteral("name.txt"); const QString description = QStringLiteral("description"); // Create the original part. MessageCore::AttachmentPart::Ptr origPart = MessageCore::AttachmentPart::Ptr(new MessageCore::AttachmentPart); origPart->setName(name); origPart->setDescription(description); origPart->setMimeType("text/pdf"); origPart->setEncoding(KMime::Headers::CE8Bit); origPart->setData(data); origPart->setUrl(url); origPart->setSigned(true); origPart->setEncrypted(true); origPart->setInline(true); MessageCore::AttachmentUpdateJob *job = new MessageCore::AttachmentUpdateJob(origPart, this); VERIFYEXEC(job); QCOMPARE(origPart->isInline(), job->updatedPart()->isInline()); } QTEST_MAIN(AttachmentUpdateJobTest) diff --git a/messagecore/src/attachment/attachmentpropertiesdialog.cpp b/messagecore/src/attachment/attachmentpropertiesdialog.cpp index 6a284a28..57844297 100644 --- a/messagecore/src/attachment/attachmentpropertiesdialog.cpp +++ b/messagecore/src/attachment/attachmentpropertiesdialog.cpp @@ -1,401 +1,402 @@ /* Copyright (c) 2009 Constantin Berzan Based on KMail code by various authors (kmmsgpartdlg). This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "attachmentpropertiesdialog.h" #include "attachmentfrommimecontentjob.h" #include "ui_attachmentpropertiesdialog.h" #include "ui_attachmentpropertiesdialog_readonly.h" #include #include "messagecore_debug.h" #include #include #include #include #include #include #include #include #include #include #include #include using namespace MessageCore; class Q_DECL_HIDDEN MessageCore::AttachmentPropertiesDialog::Private { public: Private(AttachmentPropertiesDialog *qq) : q(qq), mReadOnly(false), ui(nullptr), uiReadOnly(nullptr), mainLayout(nullptr) { } ~Private() { delete ui; delete uiReadOnly; } void init(const AttachmentPart::Ptr &part, bool readOnly); void polishUi(); void mimeTypeChanged(const QString &type); // slot void populateEncodings(); void populateMimeTypes(); void populateWhatsThis(); void loadFromPart(); void saveToPart(); AttachmentPropertiesDialog *const q; bool mReadOnly; AttachmentPart::Ptr mPart; Ui::AttachmentPropertiesDialog *ui; Ui::AttachmentPropertiesDialogReadOnly *uiReadOnly; QVBoxLayout *mainLayout; }; void AttachmentPropertiesDialog::Private::init(const AttachmentPart::Ptr &part, bool readOnly) { mReadOnly = readOnly; mPart = part; QWidget *widget = new QWidget(q); mainLayout = new QVBoxLayout; q->setLayout(mainLayout); mainLayout->addWidget(widget); if (mReadOnly) { uiReadOnly = new Ui::AttachmentPropertiesDialogReadOnly; uiReadOnly->setupUi(widget); } else { ui = new Ui::AttachmentPropertiesDialog; ui->setupUi(widget); } polishUi(); q->setModal(true); loadFromPart(); } void AttachmentPropertiesDialog::Private::polishUi() { // Tweak the dialog, depending on whether it is read-only or not. QDialogButtonBox *buttonBox = nullptr; if (mReadOnly) { buttonBox = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close); } else { // Update the icon when the selected mime type changes. connect(ui->mimeType, SIGNAL(currentIndexChanged(QString)), q, SLOT(mimeTypeChanged(QString))); populateMimeTypes(); populateEncodings(); buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); } q->connect(buttonBox->button(QDialogButtonBox::Help), &QAbstractButton::clicked, q, &AttachmentPropertiesDialog::slotHelp); q->connect(buttonBox, SIGNAL(accepted()), q, SLOT(accept())); q->connect(buttonBox, &QDialogButtonBox::rejected, q, &QDialog::reject); mainLayout->addWidget(buttonBox); populateWhatsThis(); } void AttachmentPropertiesDialog::Private::mimeTypeChanged(const QString &type) { QMimeDatabase db; const QMimeType mimeType = db.mimeTypeForName(type); QPixmap pix; if (mimeType.isValid()) { pix = KIconLoader::global()->loadMimeTypeIcon(mimeType.iconName(), KIconLoader::Desktop); } else { pix = QIcon::fromTheme(QStringLiteral("unknown")).pixmap(IconSize(KIconLoader::Desktop), IconSize(KIconLoader::Desktop)); } if (mReadOnly) { uiReadOnly->mimeIcon->setPixmap(pix); } else { ui->mimeIcon->setPixmap(pix); } } void AttachmentPropertiesDialog::Private::populateWhatsThis() { // FIXME These are such a mess... Make them straightforward and pretty. const QString msgMimeType = i18n("

The MIME type of the file:

" "

Normally, you do not need to touch this setting, since the " "type of the file is automatically checked; but, sometimes, %1 " "may not detect the type correctly -- here is where you can fix " "that.

", KAboutData::applicationData().componentName()); const QString msgSize = i18n("

The estimated size of the attachment:

" "

Note that, in an email message, a binary file encoded with " "base64 will take up four thirds the actual size of the file.

"); const QString msgName = i18n("

The file name of the part:

" "

Although this defaults to the name of the attached file, " "it does not specify the file to be attached; rather, it " "suggests a file name to be used by the recipient's mail agent " "when saving the part to disk.

"); const QString msgDescription = i18n("

A description of the part:

" "

This is just an informational description of the part, " "much like the Subject is for the whole message; most " "mail agents will show this information in their message " "previews alongside the attachment's icon.

"); const QString msgEncoding = i18n("

The transport encoding of this part:

" "

Normally, you do not need to change this, since %1 will use " "a decent default encoding, depending on the MIME type; yet, " "sometimes, you can significantly reduce the size of the " "resulting message, e.g. if a PostScript file does not contain " "binary data, but consists of pure text -- in this case, choosing " "\"quoted-printable\" over the default \"base64\" will save up " "to 25% in resulting message size.

", KAboutData::applicationData().componentName()); const QString msgAutoDisplay = i18n("

Check this option if you want to suggest to the " "recipient the automatic (inline) display of this part in the " "message preview, instead of the default icon view;

" "

Technically, this is carried out by setting this part's " "Content-Disposition header field to \"inline\" " "instead of the default \"attachment\".

"); const QString msgSign = i18n("

Check this option if you want this message part to be " "signed.

" "

The signature will be made with the key that you associated " "with the currently-selected identity.

"); const QString msgEncrypt = i18n("

Check this option if you want this message part to be " "encrypted.

" "

The part will be encrypted for the recipients of this " "message.

"); if (mReadOnly) { uiReadOnly->mimeType->setWhatsThis(msgMimeType); uiReadOnly->size->setWhatsThis(msgSize); uiReadOnly->name->setWhatsThis(msgName); uiReadOnly->encoding->setWhatsThis(msgEncoding); uiReadOnly->description->setWhatsThis(msgDescription); } else { ui->mimeType->setWhatsThis(msgMimeType); ui->size->setWhatsThis(msgSize); ui->name->setWhatsThis(msgName); ui->encrypt->setWhatsThis(msgEncrypt); ui->sign->setWhatsThis(msgSign); ui->autoDisplay->setWhatsThis(msgAutoDisplay); ui->encoding->setWhatsThis(msgEncoding); ui->description->setWhatsThis(msgDescription); } } void AttachmentPropertiesDialog::Private::populateEncodings() { using namespace KMime; using namespace KMime::Headers; ui->encoding->clear(); ui->encoding->addItem(nameForEncoding(CE7Bit), int(CE7Bit)); ui->encoding->addItem(nameForEncoding(CE8Bit), int(CE8Bit)); ui->encoding->addItem(nameForEncoding(CEquPr), int(CEquPr)); ui->encoding->addItem(nameForEncoding(CEbase64), int(CEbase64)); // TODO 8bit should be disabled if it is disabled in Settings. // Also, if it's a message/* part, base64 and qp should be disabled. // But since this is a dialog for power users anyway, let them shoot // themselves in the foot. (The AttachmentJob will fail when they // try to compose the message.) } void AttachmentPropertiesDialog::Private::populateMimeTypes() { const QStringList list = QStringList() << QStringLiteral("text/html") << QStringLiteral("text/plain") << QStringLiteral("image/gif") << QStringLiteral("image/jpeg") << QStringLiteral("image/png") << QStringLiteral("application/octet-stream") << QStringLiteral("application/x-gunzip") << QStringLiteral("application/zip"); ui->mimeType->addItems(list); } void AttachmentPropertiesDialog::Private::loadFromPart() { Q_ASSERT(mPart); if (mReadOnly) { uiReadOnly->mimeType->setText(QString::fromLatin1(mPart->mimeType())); mimeTypeChanged(QString::fromLatin1(mPart->mimeType())); uiReadOnly->size->setText(KFormat().formatByteSize(mPart->size())); uiReadOnly->name->setText(mPart->name().isEmpty() ? mPart->fileName() : mPart->name()); if (mPart->description().isEmpty()) { uiReadOnly->description->hide(); uiReadOnly->descriptionLabel->hide(); } else { uiReadOnly->description->setText(mPart->description()); } uiReadOnly->encoding->setText(KMime::nameForEncoding(mPart->encoding())); } else { const QString mimeType = QString::fromLatin1(mPart->mimeType()); const int index = ui->mimeType->findText(mimeType); if (index == -1) { ui->mimeType->insertItem(0, mimeType); ui->mimeType->setCurrentIndex(0); } else { ui->mimeType->setCurrentIndex(index); } ui->size->setText(KFormat().formatByteSize(mPart->size())); ui->name->setText(mPart->name().isEmpty() ? mPart->fileName() : mPart->name()); ui->description->setText(mPart->description()); ui->encoding->setCurrentIndex(int(mPart->encoding())); ui->autoDisplay->setChecked(mPart->isInline()); ui->encrypt->setChecked(mPart->isEncrypted()); ui->sign->setChecked(mPart->isSigned()); } } static QString removeNewlines(const QString &input) { QString ret(input); ret.replace(QLatin1Char('\n'), QLatin1Char(' ')); return ret; } void AttachmentPropertiesDialog::Private::saveToPart() { Q_ASSERT(mPart); Q_ASSERT(!mReadOnly); if (mReadOnly) { return; } mPart->setMimeType(ui->mimeType->currentText().toLatin1()); - mPart->setName(removeNewlines(ui->name->text())); - // TODO what about fileName? Extra field?? + const QString name = removeNewlines(ui->name->text()); + mPart->setName(name); + mPart->setFileName(name); mPart->setDescription(removeNewlines(ui->description->text())); mPart->setInline(ui->autoDisplay->isChecked()); mPart->setSigned(ui->sign->isChecked()); mPart->setEncrypted(ui->encrypt->isChecked()); mPart->setInline(ui->autoDisplay->isChecked()); if (ui->mimeType->currentText().startsWith(QStringLiteral("message")) && ui->encoding->itemData(ui->encoding->currentIndex()) != KMime::Headers::CE7Bit && ui->encoding->itemData(ui->encoding->currentIndex()) != KMime::Headers::CE8Bit) { qCWarning(MESSAGECORE_LOG) << "Encoding on message/rfc822 must be \"7bit\" or \"8bit\"."; } mPart->setEncoding(KMime::Headers::contentEncoding( ui->encoding->itemData(ui->encoding->currentIndex()).toInt())); } AttachmentPropertiesDialog::AttachmentPropertiesDialog(const AttachmentPart::Ptr &part, bool readOnly, QWidget *parent) : QDialog(parent), d(new Private(this)) { d->init(part, readOnly); setWindowTitle(i18n("Attachment Properties")); } AttachmentPropertiesDialog::AttachmentPropertiesDialog(const KMime::Content *content, QWidget *parent) : QDialog(parent), d(new Private(this)) { AttachmentFromMimeContentJob *job = new AttachmentFromMimeContentJob(content, this); job->exec(); if (job->error()) { qCCritical(MESSAGECORE_LOG) << "AttachmentFromMimeContentJob failed." << job->errorString(); } const AttachmentPart::Ptr part = job->attachmentPart(); d->init(part, true); setWindowTitle(i18n("Attachment Properties")); } AttachmentPropertiesDialog::~AttachmentPropertiesDialog() { delete d; } AttachmentPart::Ptr AttachmentPropertiesDialog::attachmentPart() const { return d->mPart; } bool AttachmentPropertiesDialog::isEncryptEnabled() const { if (d->ui) { return d->ui->encrypt->isEnabled(); } return false; } void AttachmentPropertiesDialog::setEncryptEnabled(bool enabled) { if (d->ui) { d->ui->encrypt->setEnabled(enabled); } } bool AttachmentPropertiesDialog::isSignEnabled() const { if (d->ui) { return d->ui->sign->isEnabled(); } return false; } void AttachmentPropertiesDialog::setSignEnabled(bool enabled) { if (d->ui) { d->ui->sign->setEnabled(enabled); } } void AttachmentPropertiesDialog::accept() { if (!d->mReadOnly) { d->saveToPart(); } QDialog::accept(); } void AttachmentPropertiesDialog::slotHelp() { PimCommon::Util::invokeHelp(QStringLiteral("kmail2/the-composer-window.html"), QStringLiteral("attachments")); } #include "moc_attachmentpropertiesdialog.cpp" diff --git a/messagecore/src/attachment/attachmentupdatejob.cpp b/messagecore/src/attachment/attachmentupdatejob.cpp index 322d2d5b..92e035a1 100644 --- a/messagecore/src/attachment/attachmentupdatejob.cpp +++ b/messagecore/src/attachment/attachmentupdatejob.cpp @@ -1,114 +1,115 @@ /* Copyright (C) 2014-2017 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "attachmentfromfolderjob.h" #include "MessageCore/AttachmentFromUrlBaseJob" #include "attachmentfromurljob.h" #include "attachmentupdatejob.h" #include #include "attachmentfromurlutils.h" #include "messagecore_debug.h" #include #include using namespace MessageCore; class Q_DECL_HIDDEN MessageCore::AttachmentUpdateJob::Private { public: Private(AttachmentUpdateJob *qq); void doStart(); // slot void loadJobResult(KJob *); AttachmentUpdateJob *const q; AttachmentPart::Ptr mOriginalPart; AttachmentPart::Ptr mUpdatedPart; }; AttachmentUpdateJob::Private::Private(AttachmentUpdateJob *qq) : q(qq) { } void AttachmentUpdateJob::Private::doStart() { Q_ASSERT(mOriginalPart); if (mOriginalPart->url().isEmpty()) { qCDebug(MESSAGECORE_LOG) << " url is empty. We can't update file"; q->setError(KJob::UserDefinedError); q->setErrorText(i18n("URL is empty.")); q->emitResult(); return; } MessageCore::AttachmentFromUrlBaseJob *job = MessageCore::AttachmentFromUrlUtils::createAttachmentJob(mOriginalPart->url(), q); connect(job, SIGNAL(result(KJob*)), q, SLOT(loadJobResult(KJob*))); job->start(); } void AttachmentUpdateJob::Private::loadJobResult(KJob *job) { if (job->error()) { q->setError(KJob::UserDefinedError); q->setErrorText(job->errorString()); q->emitResult(); return; } Q_ASSERT(dynamic_cast(job)); AttachmentLoadJob *ajob = static_cast(job); mUpdatedPart = ajob->attachmentPart(); mUpdatedPart->setName(q->originalPart()->name()); + mUpdatedPart->setFileName(q->originalPart()->fileName()); mUpdatedPart->setDescription(q->originalPart()->description()); mUpdatedPart->setSigned(q->originalPart()->isSigned()); mUpdatedPart->setEncrypted(q->originalPart()->isEncrypted()); mUpdatedPart->setEncoding(q->originalPart()->encoding()); mUpdatedPart->setMimeType(q->originalPart()->mimeType()); mUpdatedPart->setInline(q->originalPart()->isInline()); q->emitResult(); // Success. } AttachmentUpdateJob::AttachmentUpdateJob(const AttachmentPart::Ptr &part, QObject *parent) : KJob(parent), d(new Private(this)) { d->mOriginalPart = part; } AttachmentUpdateJob::~AttachmentUpdateJob() { delete d; } void AttachmentUpdateJob::start() { QTimer::singleShot(0, this, SLOT(doStart())); } AttachmentPart::Ptr AttachmentUpdateJob::originalPart() const { return d->mOriginalPart; } AttachmentPart::Ptr AttachmentUpdateJob::updatedPart() const { return d->mUpdatedPart; } #include "moc_attachmentupdatejob.cpp"