Commit 0e0da778 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Remove duplicate code

parent 2e142c53
Pipeline #83050 passed with stage
in 25 minutes and 25 seconds
......@@ -1651,6 +1651,24 @@ uint KMComposerWin::currentIdentity() const
return mComposerBase->identityCombo()->currentIdentity();
}
void KMComposerWin::addXFace(const KIdentityManagement::Identity &ident, const KMime::Message::Ptr &msg)
{
if (!ident.isXFaceEnabled() || ident.xface().isEmpty()) {
msg->removeHeader("X-Face");
} else {
QString xface = ident.xface();
if (!xface.isEmpty()) {
int numNL = (xface.length() - 1) / 70;
for (int i = numNL; i > 0; --i) {
xface.insert(i * 70, QStringLiteral("\n\t"));
}
auto header = new KMime::Headers::Generic("X-Face");
header->fromUnicodeString(xface, "utf-8");
msg->setHeader(header);
}
}
}
void KMComposerWin::setMessage(const KMime::Message::Ptr &newMsg,
bool lastSignState,
bool lastEncryptState,
......@@ -1766,20 +1784,7 @@ void KMComposerWin::setMessage(const KMime::Message::Ptr &newMsg,
const auto &ident = identity();
if (!ident.isXFaceEnabled() || ident.xface().isEmpty()) {
mMsg->removeHeader("X-Face");
} else {
QString xface = ident.xface();
if (!xface.isEmpty()) {
int numNL = (xface.length() - 1) / 70;
for (int i = numNL; i > 0; --i) {
xface.insert(i * 70, QStringLiteral("\n\t"));
}
auto header = new KMime::Headers::Generic("X-Face");
header->fromUnicodeString(xface, "utf-8");
mMsg->setHeader(header);
}
}
addXFace(ident, mMsg);
// if these headers are present, the state of the message should be overruled
if (auto hdr = mMsg->headerByType("X-KMail-SignatureActionEnabled")) {
......@@ -3234,20 +3239,7 @@ void KMComposerWin::slotIdentityChanged(uint uoid, bool initialChange)
organization->fromUnicodeString(ident.organization(), "utf-8");
mMsg->setHeader(organization);
}
if (!ident.isXFaceEnabled() || ident.xface().isEmpty()) {
mMsg->removeHeader("X-Face");
} else {
QString xface = ident.xface();
if (!xface.isEmpty()) {
int numNL = (xface.length() - 1) / 70;
for (int i = numNL; i > 0; --i) {
xface.insert(i * 70, QStringLiteral("\n\t"));
}
auto header = new KMime::Headers::Generic("X-Face");
header->fromUnicodeString(xface, "utf-8");
mMsg->setHeader(header);
}
}
addXFace(ident, mMsg);
if (initialChange) {
if (auto hrd = mMsg->headerByType("X-KMail-Transport")) {
......
......@@ -582,6 +582,7 @@ private:
Q_REQUIRED_RESULT bool sendLaterRegistered() const;
void slotRecipientEditorLineFocused();
void updateHamburgerMenu();
void addXFace(const KIdentityManagement::Identity &ident, const KMime::Message::Ptr &msg);
Akonadi::Collection mCollectionForNewMessage;
QMap<QByteArray, QString> mExtraHeaders;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment