[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kmail/Applications/18.08] src/editor: Allow to restore with mailtransportname and identity name.
From:       Laurent Montel <null () kde ! org>
Date:       2018-09-24 11:22:54
Message-ID: E1g4Ox4-0007m9-6U () code ! kde ! org
[Download RAW message or body]

Git commit 23735c196825fab47f2f667c24f8ef7bb0eb3c28 by Laurent Montel.
Committed on 24/09/2018 at 11:20.
Pushed by mlaurent into branch 'Applications/18.08'.

Allow to restore with mailtransportname and identity name.

bug reported by David.

For example we will able to resend mail when we migrate mail in another
computer.

M  +82   -10   src/editor/kmcomposerwin.cpp

https://commits.kde.org/kmail/23735c196825fab47f2f667c24f8ef7bb0eb3c28

diff --git a/src/editor/kmcomposerwin.cpp b/src/editor/kmcomposerwin.cpp
index 2b598747f..0af83d9f6 100644
--- a/src/editor/kmcomposerwin.cpp
+++ b/src/editor/kmcomposerwin.cpp
@@ -1543,7 +1543,34 @@ void KMComposerWin::setMessage(const KMime::Message::Ptr \
&newMsg, bool lastSignS  if (auto hrd = newMsg->headerByType("X-KMail-Identity")) {
         const QString identityStr = hrd->asUnicodeString();
         if (!identityStr.isEmpty()) {
-            mId = identityStr.toUInt();
+            const KIdentityManagement::Identity &ident = \
KMKernel::self()->identityManager()->identityForUoid(identityStr.toUInt()); +         \
if (ident.isNull()) { +                if (auto hrd = \
newMsg->headerByType("X-KMail-Identity-Name")) { +                    const QString \
identityStrName = hrd->asUnicodeString(); +                    const \
KIdentityManagement::Identity id = \
KMKernel::self()->identityManager()->modifyIdentityForName(identityStrName); +        \
if (!id.isNull()) { +                        mId = id.uoid();
+                    } else {
+                        mId = 0;
+                    }
+                } else {
+                    mId = 0;
+                }
+            } else {
+                mId = identityStr.toUInt();
+            }
+        }
+    } else {
+        if (auto hrd = newMsg->headerByType("X-KMail-Identity-Name")) {
+            const QString identityStrName = hrd->asUnicodeString();
+            const KIdentityManagement::Identity id = \
KMKernel::self()->identityManager()->modifyIdentityForName(identityStrName); +        \
if (!id.isNull()) { +                mId = id.uoid();
+            } else {
+                mId = 0;
+            }
+        } else {
+            mId = 0;
         }
     }
 
@@ -2996,16 +3023,61 @@ void KMComposerWin::slotIdentityChanged(uint uoid, bool \
initialChange)  mMsg->setHeader(header);
         }
     }
-    const int transportId = ident.transport().isEmpty() ? -1 : \
                ident.transport().toInt();
-    const Transport *transport = \
                TransportManager::self()->transportById(transportId, true);
-    if (!transport) {
-        mMsg->removeHeader("X-KMail-Transport");
-        mComposerBase->transportComboBox()->setCurrentTransport(TransportManager::self()->defaultTransportId());
 +
+
+    if (initialChange) {
+        if (auto hrd = mMsg->headerByType("X-KMail-Transport")) {
+            const QString mailtransportStr = hrd->asUnicodeString();
+            if (!mailtransportStr.isEmpty()) {
+                int transportId = mailtransportStr.toInt();
+                const Transport *transport = \
TransportManager::self()->transportById(transportId, false); /*don't return default \
transport */ +                if (transport) {
+                    KMime::Headers::Generic *header = new \
KMime::Headers::Generic("X-KMail-Transport"); +                    \
header->fromUnicodeString(QString::number(transport->id()), "utf-8"); +               \
mMsg->setHeader(header); +                    \
mComposerBase->transportComboBox()->setCurrentTransport(transport->id()); +           \
} else { +                    if (auto hrd = \
mMsg->headerByType("X-KMail-Transport-Name")) { +                        const \
QString identityStrName = hrd->asUnicodeString(); +                        const \
Transport *transport = TransportManager::self()->transportByName(identityStrName, \
true); +                        if (transport) {
+                            KMime::Headers::Generic *header = new \
KMime::Headers::Generic("X-KMail-Transport"); +                            \
header->fromUnicodeString(QString::number(transport->id()), "utf-8"); +               \
mMsg->setHeader(header); +                            \
mComposerBase->transportComboBox()->setCurrentTransport(transport->id()); +           \
} else { +                            \
mComposerBase->transportComboBox()->setCurrentTransport(TransportManager::self()->defaultTransportId());
 +                        }
+                    } else {
+                        \
mComposerBase->transportComboBox()->setCurrentTransport(TransportManager::self()->defaultTransportId());
 +                    }
+                }
+            }
+        } else {
+            const int transportId = ident.transport().isEmpty() ? -1 : \
ident.transport().toInt(); +            const Transport *transport = \
TransportManager::self()->transportById(transportId, true); +            if \
(transport) { +                KMime::Headers::Generic *header = new \
KMime::Headers::Generic("X-KMail-Transport"); +                \
header->fromUnicodeString(QString::number(transport->id()), "utf-8"); +               \
mMsg->setHeader(header); +                \
mComposerBase->transportComboBox()->setCurrentTransport(transport->id()); +           \
} else { +                \
mComposerBase->transportComboBox()->setCurrentTransport(TransportManager::self()->defaultTransportId());
 +            }
+
+        }
     } else {
-        KMime::Headers::Generic *header = new \
                KMime::Headers::Generic("X-KMail-Transport");
-        header->fromUnicodeString(QString::number(transport->id()), "utf-8");
-        mMsg->setHeader(header);
-        mComposerBase->transportComboBox()->setCurrentTransport(transport->id());
+        const int transportId = ident.transport().isEmpty() ? -1 : \
ident.transport().toInt(); +        const Transport *transport = \
TransportManager::self()->transportById(transportId, true); +        if (!transport) \
{ +            mMsg->removeHeader("X-KMail-Transport");
+            mComposerBase->transportComboBox()->setCurrentTransport(TransportManager::self()->defaultTransportId());
 +        } else {
+            KMime::Headers::Generic *header = new \
KMime::Headers::Generic("X-KMail-Transport"); +            \
header->fromUnicodeString(QString::number(transport->id()), "utf-8"); +            \
mMsg->setHeader(header); +            \
mComposerBase->transportComboBox()->setCurrentTransport(transport->id()); +        }
     }
 
     const bool fccIsDisabled = ident.disabledFcc();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic