Commit b44b3ec0 authored by Volker Krause's avatar Volker Krause

Move away from KMime::Headers::Generic overloaded ctors.

They are unsafe with implicit ascii casts enabled, and thus are going to
be removed from KMime.
parent 8571e708
......@@ -977,7 +977,8 @@ void KMComposeWin::applyTemplate(uint uoid, uint uOldId)
if (ident.isNull()) {
return;
}
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Templates", mMsg.data(), ident.templates(), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Templates", mMsg.data());
header->fromUnicodeString(ident.templates(), "utf-8");
mMsg->setHeader(header);
TemplateParser::TemplateParser::Mode mode;
......@@ -1654,7 +1655,9 @@ void KMComposeWin::setMessage(const KMime::Message::Ptr &newMsg, bool lastSignSt
for (int i = numNL; i > 0; --i) {
xface.insert(i * 70, QStringLiteral("\n\t"));
}
mMsg->setHeader(new KMime::Headers::Generic("X-Face", mMsg.data(), xface, "utf-8"));
auto header = new KMime::Headers::Generic("X-Face", mMsg.data());
header->fromUnicodeString(xface, "utf-8");
mMsg->setHeader(header);
}
}
......@@ -3029,7 +3032,8 @@ void KMComposeWin::slotIdentityChanged(uint uoid, bool initalChange)
for (int i = numNL; i > 0; --i) {
xface.insert(i * 70, QStringLiteral("\n\t"));
}
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-Face", mMsg.data(), xface, "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-Face", mMsg.data());
header->fromUnicodeString(xface, "utf-8");
mMsg->setHeader(header);
}
}
......@@ -3042,7 +3046,8 @@ void KMComposeWin::slotIdentityChanged(uint uoid, bool initalChange)
mMsg->removeHeader("X-KMail-Transport");
mComposerBase->transportComboBox()->setCurrentTransport(TransportManager::self()->defaultTransportId());
} else {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Transport", mMsg.data(), QString::number(transport->id()), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Transport", mMsg.data());
header->fromUnicodeString(QString::number(transport->id()), "utf-8");
mMsg->setHeader(header);
mComposerBase->transportComboBox()->setCurrentTransport(transport->id());
}
......@@ -3050,7 +3055,8 @@ void KMComposeWin::slotIdentityChanged(uint uoid, bool initalChange)
const bool fccIsDisabled = ident.disabledFcc();
if (fccIsDisabled) {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-FccDisabled", mMsg.data(), QStringLiteral("true"), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-FccDisabled", mMsg.data());
header->fromUnicodeString(QStringLiteral("true"), "utf-8");
mMsg->setHeader(header);
} else {
mMsg->removeHeader("X-KMail-FccDisabled");
......
......@@ -746,7 +746,8 @@ bool KMKernel::fillComposer(KMail::Composer *&cWin,
msg->to()->fromUnicodeString(to, "utf-8");
}
if (identity > 0) {
KMime::Headers::Generic *h = new KMime::Headers::Generic("X-KMail-Identity", msg.data(), QByteArray::number(identity));
KMime::Headers::Generic *h = new KMime::Headers::Generic("X-KMail-Identity", msg.data());
h->from7BitString(QByteArray::number(identity));
msg->setHeader(h);
}
if (!body.isEmpty()) {
......
......@@ -294,7 +294,8 @@ void KNotesIconViewItem::saveNoteContent(const QString &subject, const QString &
}
if (position >= 0) {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-Cursor-Position", message.data(), QString::number(position), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-Cursor-Position", message.data());
header->fromUnicodeString(QString::number(position), "utf-8");
message->setHeader(header);
}
......
......@@ -423,7 +423,8 @@ void KNote::saveNoteContent()
message->date(true)->setDateTime(QDateTime::currentDateTime());
message->mainBodyPart()->fromUnicodeString(text().isEmpty() ? QStringLiteral(" ") : text());
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-Cursor-Position", message.data(), QString::number(m_editor->cursorPositionFromStart()), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-Cursor-Position", message.data());
header->fromUnicodeString(QString::number(m_editor->cursorPositionFromStart()), "utf-8");
message->setHeader(header);
message->assemble();
......
......@@ -59,10 +59,9 @@ FilterAction::ReturnCode FilterActionAddHeader::process(ItemContext &context , b
KMime::Headers::Base *header = KMime::Headers::createHeader(mParameter.toLatin1());
if (!header) {
header = new KMime::Headers::Generic(mParameter.toLatin1(), msg.data(), mValue, "utf-8");
} else {
header->fromUnicodeString(mValue, "utf-8");
header = new KMime::Headers::Generic(mParameter.toLatin1(), msg.data());
}
header->fromUnicodeString(mValue, "utf-8");
msg->setHeader(header);
msg->assemble();
......
......@@ -42,10 +42,9 @@ FilterAction::ReturnCode FilterActionReplyTo::process(ItemContext &context , boo
const QByteArray replyTo("Reply-To");
KMime::Headers::Base *header = KMime::Headers::createHeader(replyTo);
if (!header) {
header = new KMime::Headers::Generic(replyTo, msg.data(), mParameter, "utf-8");
} else {
header->fromUnicodeString(mParameter, "utf-8");
header = new KMime::Headers::Generic(replyTo, msg.data());
}
header->fromUnicodeString(mParameter, "utf-8");
msg->setHeader(header);
msg->assemble();
......
......@@ -92,10 +92,9 @@ FilterAction::ReturnCode FilterActionRewriteHeader::process(ItemContext &context
KMime::Headers::Base *newheader = KMime::Headers::createHeader(param);
if (!newheader) {
newheader = new KMime::Headers::Generic(param, msg.data(), newValue, "utf-8");
} else {
newheader->fromUnicodeString(newValue, "utf-8");
newheader = new KMime::Headers::Generic(param, msg.data());
}
newheader->fromUnicodeString(newValue, "utf-8");
msg->setHeader(newheader);
msg->assemble();
......
......@@ -72,7 +72,8 @@ FilterAction::ReturnCode FilterActionSetIdentity::process(ItemContext &context ,
const KMime::Message::Ptr msg = context.item().payload<KMime::Message::Ptr>();
const uint currentId = msg->headerByType("X-KMail-Identity") ? msg->headerByType("X-KMail-Identity")->asUnicodeString().trimmed().toUInt() : 0;
if (currentId != mParameter) {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Identity", msg.data(), QString::number(mParameter), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Identity", msg.data());
header->fromUnicodeString(QString::number(mParameter), "utf-8");
if (applyOnOutbound) {
msg->from()->fromUnicodeString(ident.fullEmailAddr(), "utf-8");
if (!ident.bcc().isEmpty()) {
......
......@@ -82,7 +82,8 @@ FilterAction::ReturnCode FilterActionSetTransport::process(ItemContext &context
}
const KMime::Message::Ptr msg = context.item().payload<KMime::Message::Ptr>();
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Transport", msg.data(), argsAsString(), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Transport", msg.data());
header->fromUnicodeString(argsAsString(), "utf-8");
msg->setHeader(header);
msg->assemble();
......
......@@ -258,7 +258,8 @@ FilterAction::ReturnCode FilterActionWithCommand::genericProcess(ItemContext &co
const QString newUid = aMsg->headerByType("X-UID") ? aMsg->headerByType("X-UID")->asUnicodeString() : QString();
if (uid != newUid) {
aMsg->setFrozen(false);
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-UID", aMsg.data(), uid, "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-UID", aMsg.data());
header->fromUnicodeString(uid, "utf-8");
aMsg->setHeader(header);
aMsg->assemble();
}
......
......@@ -336,9 +336,8 @@ void ComposerPrivate::contentJobFinished(KJob *job)
headers->setHeader(skeletonMessage->date());
headers->setHeader(skeletonMessage->messageID());
KMime::Headers::Generic *realTo =
new KMime::Headers::Generic("X-KMail-EncBccRecipients",
headers, eJob->recipients().join(QLatin1String("%")), "utf-8");
KMime::Headers::Generic *realTo = new KMime::Headers::Generic("X-KMail-EncBccRecipients", headers);
realTo->fromUnicodeString(eJob->recipients().join(QLatin1String("%")), "utf-8");
qCDebug(MESSAGECOMPOSER_LOG) << "got one of multiple messages sending to:" << realTo->asUnicodeString();
qCDebug(MESSAGECOMPOSER_LOG) << "sending to recipients:" << recipients;
......
......@@ -263,23 +263,35 @@ void MessageComposer::ComposerViewBase::updateTemplate(const KMime::Message::Ptr
void MessageComposer::ComposerViewBase::saveMailSettings()
{
const KIdentityManagement::Identity identity = identityManager()->identityForUoid(m_identityCombo->currentIdentity());
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-Transport", m_msg.data(), QString::number(m_transport->currentTransportId()), "utf-8"));
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-Fcc", m_msg.data(), QString::number(m_fccCollection.id()) , "utf-8"));
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-Identity", m_msg.data(), QString::number(identity.uoid()), "utf-8"));
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-Dictionary", m_msg.data(), m_dictionary->currentDictionary(), "utf-8"));
auto header = new KMime::Headers::Generic("X-KMail-Transport", m_msg.data());
header->fromUnicodeString(QString::number(m_transport->currentTransportId()), "utf-8");
m_msg->setHeader(header);
header = new KMime::Headers::Generic("X-KMail-Fcc", m_msg.data());
header->fromUnicodeString(QString::number(m_fccCollection.id()) , "utf-8");
m_msg->setHeader(header);
header = new KMime::Headers::Generic("X-KMail-Identity", m_msg.data());
header->fromUnicodeString(QString::number(identity.uoid()), "utf-8");
m_msg->setHeader(header);
header = new KMime::Headers::Generic("X-KMail-Dictionary", m_msg.data());
header->fromUnicodeString(m_dictionary->currentDictionary(), "utf-8");
m_msg->setHeader(header);
// Save the quote prefix which is used for this message. Each message can have
// a different quote prefix, for example depending on the original sender.
if (m_editor->quotePrefixName().isEmpty()) {
m_msg->removeHeader("X-KMail-QuotePrefix");
} else {
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-QuotePrefix", m_msg.data(), m_editor->quotePrefixName(), "utf-8"));
header = new KMime::Headers::Generic("X-KMail-QuotePrefix", m_msg.data());
header->fromUnicodeString(m_editor->quotePrefixName(), "utf-8");
m_msg->setHeader(header);
}
if (m_editor->composerControler()->isFormattingUsed()) {
qCDebug(MESSAGECOMPOSER_LOG) << "HTML mode";
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-Markup", m_msg.data(), QStringLiteral("true"), "utf-8"));
header = new KMime::Headers::Generic("X-KMail-Markup", m_msg.data());
header->fromUnicodeString(QStringLiteral("true"), "utf-8");
m_msg->setHeader(header);
} else {
m_msg->removeHeader("X-KMail-Markup");
qCDebug(MESSAGECOMPOSER_LOG) << "Plain text";
......@@ -341,11 +353,15 @@ void MessageComposer::ComposerViewBase::send(MessageComposer::MessageSender::Sen
if (m_neverEncrypt && saveIn != MessageComposer::MessageSender::SaveInNone) {
// we can't use the state of the mail itself, to remember the
// signing and encryption state, so let's add a header instead
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-SignatureActionEnabled", m_msg.data(),
m_sign ? QLatin1String("true") : QLatin1String("false"), "utf-8"));
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-EncryptActionEnabled", m_msg.data(),
m_encrypt ? QLatin1String("true") : QLatin1String("false"), "utf-8"));
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-CryptoMessageFormat", m_msg.data(), QString::number(m_cryptoMessageFormat), "utf-8"));
auto header = new KMime::Headers::Generic("X-KMail-SignatureActionEnabled", m_msg.data());
header->fromUnicodeString(m_sign ? QLatin1String("true") : QLatin1String("false"), "utf-8");
m_msg->setHeader(header);
header = new KMime::Headers::Generic("X-KMail-EncryptActionEnabled", m_msg.data());
header->fromUnicodeString(m_encrypt ? QLatin1String("true") : QLatin1String("false"), "utf-8");
m_msg->setHeader(header);
header = new KMime::Headers::Generic("X-KMail-CryptoMessageFormat", m_msg.data());
header->fromUnicodeString(QString::number(m_cryptoMessageFormat), "utf-8");
m_msg->setHeader(header);
} else {
MessageComposer::Util::removeNotNecessaryHeaders(m_msg);
}
......@@ -441,9 +457,15 @@ void MessageComposer::ComposerViewBase::slotEmailAddressResolved(KJob *job)
unExpandedBcc << exp;
}
}
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-UnExpanded-To", m_msg.data(), unExpandedTo.join(QStringLiteral(", ")).toLatin1()));
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-UnExpanded-CC", m_msg.data(), unExpandedCc.join(QStringLiteral(", ")).toLatin1()));
m_msg->setHeader(new KMime::Headers::Generic("X-KMail-UnExpanded-BCC", m_msg.data(), unExpandedBcc.join(QStringLiteral(", ")).toLatin1()));
auto header = new KMime::Headers::Generic("X-KMail-UnExpanded-To", m_msg.data());
header->from7BitString(unExpandedTo.join(QStringLiteral(", ")).toLatin1());
m_msg->setHeader(header);
header = new KMime::Headers::Generic("X-KMail-UnExpanded-CC", m_msg.data());
header->from7BitString(unExpandedCc.join(QStringLiteral(", ")).toLatin1());
m_msg->setHeader(header);
header = new KMime::Headers::Generic("X-KMail-UnExpanded-BCC", m_msg.data());
header->from7BitString(unExpandedBcc.join(QStringLiteral(", ")).toLatin1());
m_msg->setHeader(header);
autoresizeImage = false;
}
......@@ -939,7 +961,9 @@ void MessageComposer::ComposerViewBase::queueMessage(KMime::Message::Ptr message
QMapIterator<QByteArray, QString> customHeader(m_customHeader);
while (customHeader.hasNext()) {
customHeader.next();
message->setHeader(new KMime::Headers::Generic(customHeader.key(), message.data(), customHeader.value(), "utf-8"));
auto header = new KMime::Headers::Generic(customHeader.key(), message.data());
header->fromUnicodeString(customHeader.value(), "utf-8");
message->setHeader(header);
}
message->assemble();
connect(qjob, &MailTransport::MessageQueueJob::result, this, &ComposerViewBase::slotQueueResult);
......
......@@ -323,13 +323,16 @@ MessageFactory::MessageReply MessageFactory::createReply()
MessageCore::Util::addLinkInformation(msg, m_id, Akonadi::MessageStatus::statusReplied());
if (m_parentFolderId > 0) {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Fcc", msg.data(), QString::number(m_parentFolderId), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Fcc", msg.data());
header->fromUnicodeString(QString::number(m_parentFolderId), "utf-8");
msg->setHeader(header);
}
if (m_origMsg->hasHeader("X-KMail-EncryptActionEnabled") &&
m_origMsg->headerByType("X-KMail-EncryptActionEnabled")->as7BitString().contains("true")) {
msg->setHeader(new KMime::Headers::Generic("X-KMail-EncryptActionEnabled", msg.data(), QStringLiteral("true"), "utf-8"));
auto header = new KMime::Headers::Generic("X-KMail-EncryptActionEnabled", msg.data());
header->fromUnicodeString(QStringLiteral("true"), "utf-8");
msg->setHeader(header);
}
msg->assemble();
......@@ -484,7 +487,8 @@ KMime::Message::Ptr MessageFactory::createResend()
uint originalIdentity = identityUoid(m_origMsg);
// Set the identity from above
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Identity", msg.data(), QString::number(originalIdentity), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Identity", msg.data());
header->fromUnicodeString(QString::number(originalIdentity), "utf-8");
msg->setHeader(header);
// Restore the original bcc field as this is overwritten in applyIdentity
......@@ -543,16 +547,16 @@ KMime::Message::Ptr MessageFactory::createRedirect(const QString &toStr, const Q
if (MessageComposer::MessageComposerSettings::useCustomMessageIdSuffix()) {
msgIdSuffix = MessageComposer::MessageComposerSettings::customMsgIDSuffix();
}
KMime::Headers::Generic *header =
new KMime::Headers::Generic("Resent-Message-ID", msg.data(),
MessageCore::StringUtil::generateMessageId(
msg->sender()->asUnicodeString(), msgIdSuffix), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("Resent-Message-ID", msg.data());
header->fromUnicodeString(MessageCore::StringUtil::generateMessageId(msg->sender()->asUnicodeString(), msgIdSuffix), "utf-8");
msg->setHeader(header);
header = new KMime::Headers::Generic("Resent-Date", msg.data(), newDate, "utf-8");
header = new KMime::Headers::Generic("Resent-Date", msg.data());
header->fromUnicodeString(newDate, "utf-8");
msg->setHeader(header);
header = new KMime::Headers::Generic("Resent-From", msg.data(), strFrom, "utf-8");
header = new KMime::Headers::Generic("Resent-From", msg.data());
header->fromUnicodeString(strFrom, "utf-8");
msg->setHeader(header);
if (msg->to(false)) {
......@@ -561,35 +565,42 @@ KMime::Message::Ptr MessageFactory::createRedirect(const QString &toStr, const Q
msg->setHeader(headerT);
}
header = new KMime::Headers::Generic("Resent-To", msg.data(), toStr, "utf-8");
header = new KMime::Headers::Generic("Resent-To", msg.data());
header->fromUnicodeString(toStr, "utf-8");
msg->setHeader(header);
if (!ccStr.isEmpty()) {
header = new KMime::Headers::Generic("Resent-Cc", msg.data(), ccStr, "utf-8");
header = new KMime::Headers::Generic("Resent-Cc", msg.data());
header->fromUnicodeString(ccStr, "utf-8");
msg->setHeader(header);
}
if (!bccStr.isEmpty()) {
header = new KMime::Headers::Generic("Resent-Bcc", msg.data(), bccStr, "utf-8");
header = new KMime::Headers::Generic("Resent-Bcc", msg.data());
header->fromUnicodeString(bccStr, "utf-8");
msg->setHeader(header);
}
header = new KMime::Headers::Generic("X-KMail-Redirect-From", msg.data(), strByWayOf, "utf-8");
header = new KMime::Headers::Generic("X-KMail-Redirect-From", msg.data());
header->fromUnicodeString(strByWayOf, "utf-8");
msg->setHeader(header);
if (transportId != -1) {
header = new KMime::Headers::Generic("X-KMail-Transport", msg.data(), QString::number(transportId), "utf-8");
header = new KMime::Headers::Generic("X-KMail-Transport", msg.data());
header->fromUnicodeString(QString::number(transportId), "utf-8");
msg->setHeader(header);
}
if (!fcc.isEmpty()) {
header = new KMime::Headers::Generic("X-KMail-Fcc", msg.data(), fcc, "utf-8");
header = new KMime::Headers::Generic("X-KMail-Fcc", msg.data());
header->fromUnicodeString(fcc, "utf-8");
msg->setHeader(header);
}
const bool fccIsDisabled = ident.disabledFcc();
if (fccIsDisabled) {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-FccDisabled", msg.data(), QStringLiteral("true"), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-FccDisabled", msg.data());
header->fromUnicodeString(QStringLiteral("true"), "utf-8");
msg->setHeader(header);
} else {
msg->removeHeader("X-KMail-FccDisabled");
......
......@@ -59,15 +59,15 @@ void initFromMessage(const KMime::Message::Ptr &msg, const KMime::Message::Ptr &
if (idHeaders) {
MessageHelper::initHeader(msg, identMan, id);
} else {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Identity", msg.data(),
QString::number(id), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Identity", msg.data());
header->fromUnicodeString(QString::number(id), "utf-8");
msg->setHeader(header);
}
if (origMsg->headerByType("X-KMail-Transport")) {
const QString transport = origMsg->headerByType("X-KMail-Transport")->asUnicodeString();
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Transport", msg.data(),
transport, "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Transport", msg.data());
header->fromUnicodeString(transport, "utf-8");
msg->setHeader(header);
}
}
......@@ -118,40 +118,46 @@ void applyIdentity(const KMime::Message::Ptr &message, const KIdentityManagement
if (ident.isDefault()) {
message->removeHeader("X-KMail-Identity");
} else {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Identity", message.data(), QString::number(ident.uoid()), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Identity", message.data());
header->fromUnicodeString(QString::number(ident.uoid()), "utf-8");
message->setHeader(header);
}
if (ident.transport().isEmpty()) {
message->removeHeader("X-KMail-Transport");
} else {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Transport", message.data(), ident.transport(), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Transport", message.data());
header->fromUnicodeString(ident.transport(), "utf-8");
message->setHeader(header);
}
if (ident.fcc().isEmpty()) {
message->removeHeader("X-KMail-Fcc");
} else {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Fcc", message.data(), ident.fcc(), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Fcc", message.data());
header->fromUnicodeString(ident.fcc(), "utf-8");
message->setHeader(header);
}
if (ident.drafts().isEmpty()) {
message->removeHeader("X-KMail-Drafts");
} else {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Drafts", message.data(), ident.drafts(), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Drafts", message.data());
header->fromUnicodeString(ident.drafts(), "utf-8");
message->setHeader(header);
}
if (ident.templates().isEmpty()) {
message->removeHeader("X-KMail-Templates");
} else {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Templates", message.data(), ident.templates(), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Templates", message.data());
header->fromUnicodeString(ident.templates(), "utf-8");
message->setHeader(header);
}
if (ident.disabledFcc()) {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-FccDisabled", message.data(), QLatin1String("true"), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-FccDisabled", message.data());
header->fromUnicodeString(QLatin1String("true"), "utf-8");
message->setHeader(header);
} else {
message->removeHeader("X-KMail-FccDisabled");
......@@ -237,7 +243,8 @@ QString replacePrefixes(const QString &str, const QStringList &prefixRegExps,
void setAutomaticFields(const KMime::Message::Ptr &msg, bool aIsMulti)
{
msg->setHeader(new KMime::Headers::Generic("MIME-Version", msg.data(), QLatin1String("1.0"), QLatin1String("utf-8").latin1()));
auto header = msg->header<KMime::Headers::MIMEVersion>(true);
header->from7BitString("1.0");
if (aIsMulti || msg->contents().size() > 1) {
// Set the type to 'Multipart' and the subtype to 'Mixed'
......
......@@ -134,13 +134,15 @@ void SkeletonMessageJobPrivate::doStart()
// Fcc:
if (!infoPart->fcc().isEmpty()) {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Fcc", message, infoPart->fcc(), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Fcc", message);
header->fromUnicodeString(infoPart->fcc(), "utf-8");
message->setHeader(header);
}
//Transport:
if (infoPart->transportId() > -1) {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Transport", message, QString::number(infoPart->transportId()), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Transport", message);
header->fromUnicodeString(QString::number(infoPart->transportId()), "utf-8");
message->setHeader(header);
}
......@@ -171,7 +173,8 @@ void SkeletonMessageJobPrivate::doStart()
{
if (globalPart->MDNRequested()) {
const QString addr = infoPart->replyTo().isEmpty() ? infoPart->from() : infoPart->replyTo();
KMime::Headers::Generic *mdn = new KMime::Headers::Generic("Disposition-Notification-To", message, addr, "utf-8");
KMime::Headers::Generic *mdn = new KMime::Headers::Generic("Disposition-Notification-To", message);
mdn->fromUnicodeString(addr, "utf-8");
message->setHeader(mdn);
}
}
......@@ -187,8 +190,10 @@ void SkeletonMessageJobPrivate::doStart()
// Urgent header
if (infoPart->urgent()) {
KMime::Headers::Generic *urg1 = new KMime::Headers::Generic("X-PRIORITY", message, QStringLiteral("2 (High)"), "utf-8");
KMime::Headers::Generic *urg2 = new KMime::Headers::Generic("Priority", message, QStringLiteral("urgent"), "utf-8");
KMime::Headers::Generic *urg1 = new KMime::Headers::Generic("X-PRIORITY", message);
urg1->fromUnicodeString(QStringLiteral("2 (High)"), "utf-8");
KMime::Headers::Generic *urg2 = new KMime::Headers::Generic("Priority", message);
urg2->fromUnicodeString(QStringLiteral("urgent"), "utf-8");
message->setHeader(urg1);
message->setHeader(urg2);
}
......
......@@ -59,10 +59,12 @@ void MessageCore::Util::addLinkInformation(const KMime::Message::Ptr &msg, Akona
type += QLatin1String("forward");
}
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Link-Message", msg.data(), message, "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Link-Message", msg.data());
header->fromUnicodeString(message, "utf-8");
msg->setHeader(header);
header = new KMime::Headers::Generic("X-KMail-Link-Type", msg.data(), type, "utf-8");
header = new KMime::Headers::Generic("X-KMail-Link-Type", msg.data());
header->fromUnicodeString(type, "utf-8");
msg->setHeader(header);
}
......
......@@ -557,9 +557,8 @@ public:
const bool nullIdentity = (identity == KIdentityManagement::Identity::null());
if (!nullIdentity) {
KMime::Headers::Generic *x_header =
new KMime::Headers::Generic(
"X-KMail-Identity", msg.data(), QByteArray::number(identity.uoid()));
KMime::Headers::Generic *x_header = new KMime::Headers::Generic("X-KMail-Identity", msg.data());
x_header->from7BitString(QByteArray::number(identity.uoid()));
msg->setHeader(x_header);
}
......@@ -576,7 +575,9 @@ public:
}
transportId = TransportManager::self()->defaultTransportId();
}
msg->setHeader(new KMime::Headers::Generic("X-KMail-Transport", msg.data(), QString::number(transportId), "utf-8"));
auto header = new KMime::Headers::Generic("X-KMail-Transport", msg.data());
header->fromUnicodeString(QString::number(transportId), "utf-8");
msg->setHeader(header);
// Outlook will only understand the reply if the From: header is the
// same as the To: header of the invitation message.
......
......@@ -334,9 +334,8 @@ void TemplateParser::processWithTemplate(const QString &tmpl)
const int len = parseQuotes(QStringLiteral("DICTIONARYLANGUAGE="), cmd, q);
i += len;
if (!q.isEmpty()) {
KMime::Headers::Generic *header =
new KMime::Headers::Generic("X-KMail-Dictionary", mMsg.data(),
q, "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Dictionary", mMsg.data());
header->fromUnicodeString(q, "utf-8");
mMsg->setHeader(header);
}
} else if (cmd.startsWith(QStringLiteral("INSERT=")) || cmd.startsWith(QStringLiteral("PUT="))) {
......@@ -520,9 +519,8 @@ void TemplateParser::processWithTemplate(const QString &tmpl)
const QString htmlStr = pipe(pipe_cmd, htmlBody);
htmlBody = htmlStr;
KMime::Headers::Generic *header =
new KMime::Headers::Generic("X-KMail-CursorPos", mMsg.data(),
QString::number(0), "utf-8");
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-CursorPos", mMsg.data());
header->fromUnicodeString(QString::number(0), "utf-8");
mMsg->setHeader(header);
} else if (cmd.startsWith(QStringLiteral("TEXT"))) {
......@@ -1104,9 +1102,8 @@ void TemplateParser::processWithTemplate(const QString &tmpl)
i += strlen("CLEAR");
plainBody.clear();
htmlBody.clear();
KMime::Headers::Generic *header =
new KMime::Headers::Generic("X-KMail-CursorPos", mMsg.data(),
QString::