File: 1003-Implement-explicit-forwarding-as-attachment.patch

package info (click to toggle)
lomiri-dekko-app 0.4.1%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,416 kB
  • sloc: cpp: 26,276; javascript: 4,237; python: 1,082; xml: 379; sh: 126; makefile: 18
file content (85 lines) | stat: -rw-r--r-- 3,704 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
From 39dc9746d2f80b7d71f42ba593ab83ac872fcfe5 Mon Sep 17 00:00:00 2001
From: Guido Berhoerster <guido+debian@berhoerster.name>
Date: Tue, 14 Jan 2025 14:03:36 +0100
Subject: Implement explicit forwarding as attachment


diff --git a/Dekko/backend/mail/MessageBuilder.cpp b/Dekko/backend/mail/MessageBuilder.cpp
index ca2e648..d7726db 100644
--- a/Dekko/backend/mail/MessageBuilder.cpp
+++ b/Dekko/backend/mail/MessageBuilder.cpp
@@ -281,7 +281,6 @@ void MessageBuilder::buildResponse(const MessageBuilder::ReplyType &type, const
 
 void MessageBuilder::buildForward(const MessageBuilder::ForwardType &type, const QMailMessage &src)
 {
-    Q_UNUSED(type);
     const QString subject = Formatting::mangleForwardSubject(src.subject().simplified());
     if (m_subject == Q_NULLPTR) {
         m_internalSubject->setPlainText(subject);
@@ -290,38 +289,40 @@ void MessageBuilder::buildForward(const MessageBuilder::ForwardType &type, const
     }
 
     QString srcBody = "";
-    bool hasInlineBody(false);
+    bool useInlineBody(false);
 
-    // if message has a plaintext part then we forward it inline
-    if (src.hasPlainTextBody()) {
-        hasInlineBody = true;
-        srcBody = src.body().data();
-    }
-
-    if (src.multipartType() == QMailMessage::MultipartAlternative || src.multipartType() == QMailMessage::MultipartMixed) {
-        QMailMessagePartContainer *ptext = src.findPlainTextContainer();
-        if (ptext) {
-            hasInlineBody = true;
-            srcBody = static_cast<QMailMessagePart *>(ptext)->body().data();
+    if (type == MessageBuilder::ForwardType::Inline) {
+        // if message has a plaintext part then we forward it inline
+        if (src.hasPlainTextBody()) {
+            useInlineBody = true;
+            srcBody = src.body().data();
         }
-    } 
-
-    // if srcBody is still empty then try to use html body
-    if (srcBody.isEmpty() && src.hasHtmlBody()) {
-        QMailMessagePartContainer *htext = src.findHtmlContainer();
-        if (htext) {
-            QMailMessagePart *part = static_cast<QMailMessagePart *>(htext);
-            QTextDocument b;
-            b.setHtml(part->body().data());
-            srcBody = b.toPlainText();
-            hasInlineBody = true;
-        } else {
-            qDebug() << "src.hasHtmlBody() but src.findHtmlContainer() == null. That should never happen!?!";
+
+        if (src.multipartType() == QMailMessage::MultipartAlternative || src.multipartType() == QMailMessage::MultipartMixed) {
+            QMailMessagePartContainer *ptext = src.findPlainTextContainer();
+            if (ptext) {
+                useInlineBody = true;
+                srcBody = static_cast<QMailMessagePart *>(ptext)->body().data();
+            }
+        } 
+
+        // if srcBody is still empty then try to use html body
+        if (srcBody.isEmpty() && src.hasHtmlBody()) {
+            QMailMessagePartContainer *htext = src.findHtmlContainer();
+            if (htext) {
+                QMailMessagePart *part = static_cast<QMailMessagePart *>(htext);
+                QTextDocument b;
+                b.setHtml(part->body().data());
+                srcBody = b.toPlainText();
+                useInlineBody = true;
+            } else {
+                qDebug() << "src.hasHtmlBody() but src.findHtmlContainer() == null. That should never happen!?!";
+            }
         }
     }
 
     QString body;
-    if (hasInlineBody) {
+    if (useInlineBody) {
         QString forwardBlock = "\n------------ " + tr("Forwarded Message") + " ------------\n";
         forwardBlock += tr("Date: ") + src.date().toString() + '\n';
         forwardBlock += tr("From: ") + src.from().toString() + '\n';