Diffstat (limited to 'noncore/unsupported/mail2/viewmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/mail2/viewmail.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/unsupported/mail2/viewmail.cpp b/noncore/unsupported/mail2/viewmail.cpp index da6924d..0cfb6e5 100644 --- a/noncore/unsupported/mail2/viewmail.cpp +++ b/noncore/unsupported/mail2/viewmail.cpp | |||
@@ -1,198 +1,198 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qapplication.h> | 4 | #include <qapplication.h> |
5 | 5 | ||
6 | #include "mailfactory.h" | 6 | #include "mailfactory.h" |
7 | #include "composer.h" | 7 | #include "composer.h" |
8 | #include "viewmail.h" | 8 | #include "viewmail.h" |
9 | 9 | ||
10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) | 10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) |
11 | : QListViewItem(parent), _attachItemStore(attachItemStore) | 11 | : QListViewItem(parent), _attachItemStore(attachItemStore) |
12 | { | 12 | { |
13 | setText(0, _attachItemStore.mimeType()); | 13 | setText(0, _attachItemStore.mimeType()); |
14 | setText(1, _attachItemStore.fileName()); | 14 | setText(1, _attachItemStore.fileName()); |
15 | setText(2, _attachItemStore.description()); | 15 | setText(2, _attachItemStore.description()); |
16 | } | 16 | } |
17 | 17 | ||
18 | AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) | 18 | AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) |
19 | : QListViewItem(parent), _attachItemStore(attachItemStore) | 19 | : QListViewItem(parent), _attachItemStore(attachItemStore) |
20 | { | 20 | { |
21 | setText(0, _attachItemStore.mimeType()); | 21 | setText(0, _attachItemStore.mimeType()); |
22 | setText(1, _attachItemStore.fileName()); | 22 | setText(1, _attachItemStore.fileName()); |
23 | setText(2, _attachItemStore.description()); | 23 | setText(2, _attachItemStore.description()); |
24 | } | 24 | } |
25 | 25 | ||
26 | ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) | 26 | ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) |
27 | : ViewMailBase(parent, name, fl), _inLoop(false), _mail(mail), _handler(handler) | 27 | : ViewMailBase(parent, name, fl), _inLoop(false), _mail(mail), _handler(handler) |
28 | { | 28 | { |
29 | setCaption(caption().arg(mail.envelope().from()[0].name())); | 29 | setCaption(caption().arg(mail.envelope().from()[0].name())); |
30 | 30 | ||
31 | _gotBody = false; | 31 | _gotBody = false; |
32 | _mailHtml = tr( | 32 | _mailHtml = tr( |
33 | "<html><body>" | 33 | "<html><body>" |
34 | "<div align=center><b>%1</b></div>" | 34 | "<div align=center><b>%1</b></div>" |
35 | "<b>From:</b> %2<br>" | 35 | "<b>From:</b> %2<br>" |
36 | "<b>To:</b> %3<br>" | 36 | "<b>To:</b> %3<br>" |
37 | "%4" | 37 | "%4" |
38 | "%5" | 38 | "%5" |
39 | "<b>Date:</b> %6<hr>" | 39 | "<b>Date:</b> %6<hr>" |
40 | "<font face=fixed>%7</font>") | 40 | "<font face=fixed>%7</font>") |
41 | .arg(deHtml(mail.envelope().subject().isNull() ? tr("(no subject)") | 41 | .arg(deHtml(mail.envelope().subject().isNull() ? tr("(no subject)") |
42 | : deHtml(mail.envelope().subject()))) | 42 | : deHtml(mail.envelope().subject()))) |
43 | .arg(deHtml(mail.envelope().from().toString().isNull() ? tr("(no from)") | 43 | .arg(deHtml(mail.envelope().from().toString().isNull() ? tr("(no from)") |
44 | : mail.envelope().from().toString())) | 44 | : mail.envelope().from().toString())) |
45 | .arg(deHtml(mail.envelope().to().toString().isNull() ? tr("(no recipient)") | 45 | .arg(deHtml(mail.envelope().to().toString().isNull() ? tr("(no recipient)") |
46 | : mail.envelope().to().toString())) | 46 | : mail.envelope().to().toString())) |
47 | .arg(mail.envelope().cc().toString().isNull() ? QString(0) | 47 | .arg(mail.envelope().cc().toString().isNull() ? QString(0) |
48 | : tr("<b>Cc:</b> %1<br>").arg(deHtml(mail.envelope().cc().toString()))) | 48 | : tr("<b>Cc:</b> %1<br>").arg(deHtml(mail.envelope().cc().toString()))) |
49 | .arg(mail.envelope().bcc().toString().isNull() ? QString(0) | 49 | .arg(mail.envelope().bcc().toString().isNull() ? QString(0) |
50 | : tr("<b>Bcc:</b> %1<br>").arg(deHtml(mail.envelope().bcc().toString()))) | 50 | : tr("<b>Bcc:</b> %1<br>").arg(deHtml(mail.envelope().bcc().toString()))) |
51 | .arg(mail.envelope().mailDate().isNull() ? tr("(no date)") | 51 | .arg(mail.envelope().mailDate().isNull() ? tr("(no date)") |
52 | : mail.envelope().mailDate()) | 52 | : mail.envelope().mailDate()) |
53 | .arg("%1"); | 53 | .arg("%1"); |
54 | 54 | ||
55 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); | 55 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); |
56 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); | 56 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); |
57 | 57 | ||
58 | attachments->setEnabled(_gotBody); | 58 | attachments->setEnabled(_gotBody); |
59 | browser->setText(QString(_mailHtml).arg(tr("Getting mail body from server. Please wait..."))); | 59 | browser->setText(QString(_mailHtml).arg(tr("Getting mail body from server. Please wait..."))); |
60 | 60 | ||
61 | _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); | 61 | _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); |
62 | connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); | 62 | connect(_handler, SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPUid(IMAPResponse&))); |
63 | } | 63 | } |
64 | 64 | ||
65 | ViewMail::~ViewMail() | 65 | ViewMail::~ViewMail() |
66 | { | 66 | { |
67 | hide(); | 67 | hide(); |
68 | } | 68 | } |
69 | 69 | ||
70 | void ViewMail::hide() | 70 | void ViewMail::hide() |
71 | { | 71 | { |
72 | QWidget::hide(); | 72 | QWidget::hide(); |
73 | 73 | ||
74 | if (_inLoop) { | 74 | if (_inLoop) { |
75 | _inLoop = false; | 75 | _inLoop = false; |
76 | qApp->exit_loop(); | 76 | qApp->exit_loop(); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | void ViewMail::exec() | 80 | void ViewMail::exec() |
81 | { | 81 | { |
82 | show(); | 82 | show(); |
83 | 83 | ||
84 | if (!_inLoop) { | 84 | if (!_inLoop) { |
85 | _inLoop = true; | 85 | _inLoop = true; |
86 | qApp->enter_loop(); | 86 | qApp->enter_loop(); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | QString ViewMail::deHtml(const QString &string) | 90 | QString ViewMail::deHtml(const QString &string) |
91 | { | 91 | { |
92 | QString string_ = string; | 92 | QString string_ = string; |
93 | string_.replace(QRegExp("&"), "&"); | 93 | string_.replace(QRegExp("&"), "&"); |
94 | string_.replace(QRegExp("<"), "<"); | 94 | string_.replace(QRegExp("<"), "<"); |
95 | string_.replace(QRegExp(">"), ">"); | 95 | string_.replace(QRegExp(">"), ">"); |
96 | string_.replace(QRegExp("\\n"), "<br>"); | 96 | string_.replace(QRegExp("\\n"), "<br>"); |
97 | return string_; | 97 | return string_; |
98 | } | 98 | } |
99 | 99 | ||
100 | void ViewMail::slotReply() | 100 | void ViewMail::slotReply() |
101 | { | 101 | { |
102 | if (!_gotBody) { | 102 | if (!_gotBody) { |
103 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 103 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
104 | return; | 104 | return; |
105 | } | 105 | } |
106 | 106 | ||
107 | QString rtext; | 107 | QString rtext; |
108 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 108 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
109 | .arg(_mail.envelope().from()[0].toString()) | 109 | .arg(_mail.envelope().from()[0].toString()) |
110 | .arg(_mail.envelope().mailDate()); | 110 | .arg(_mail.envelope().mailDate()); |
111 | 111 | ||
112 | QString text = _mail.bodyPart(1).data(); | 112 | QString text = _mail.bodyPart(1).data(); |
113 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 113 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
114 | QStringList::Iterator it; | 114 | QStringList::Iterator it; |
115 | for (it = lines.begin(); it != lines.end(); it++) { | 115 | for (it = lines.begin(); it != lines.end(); it++) { |
116 | rtext += "> " + *it + "\n"; | 116 | rtext += "> " + *it + "\n"; |
117 | } | 117 | } |
118 | rtext += "\n"; | 118 | rtext += "\n"; |
119 | 119 | ||
120 | QString prefix; | 120 | QString prefix; |
121 | if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = ""; | 121 | if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = ""; |
122 | else prefix = "Re: "; // no i18n on purpose | 122 | else prefix = "Re: "; // no i18n on purpose |
123 | 123 | ||
124 | SendMail sendMail; | 124 | SendMail sendMail; |
125 | sendMail.setTo(_mail.envelope().from()[0].toString()); | 125 | sendMail.setTo(_mail.envelope().from()[0].toString()); |
126 | sendMail.setSubject(prefix + _mail.envelope().subject()); | 126 | sendMail.setSubject(prefix + _mail.envelope().subject()); |
127 | sendMail.setInReplyTo(_mail.envelope().messageId()); | 127 | sendMail.setInReplyTo(_mail.envelope().messageId()); |
128 | sendMail.setMessage(rtext); | 128 | sendMail.setMessage(rtext); |
129 | 129 | ||
130 | Composer composer(this, 0, true); | 130 | Composer composer(this, 0, true); |
131 | composer.setSendMail(sendMail); | 131 | composer.setSendMail(sendMail); |
132 | composer.showMaximized(); | 132 | composer.showMaximized(); |
133 | composer.exec(); | 133 | composer.exec(); |
134 | } | 134 | } |
135 | 135 | ||
136 | void ViewMail::slotForward() | 136 | void ViewMail::slotForward() |
137 | { | 137 | { |
138 | if (!_gotBody) { | 138 | if (!_gotBody) { |
139 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 139 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | 142 | ||
143 | QString ftext; | 143 | QString ftext; |
144 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 144 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
145 | .arg(_mail.envelope().from()[0].toString()); | 145 | .arg(_mail.envelope().from()[0].toString()); |
146 | if (!_mail.envelope().mailDate().isNull()) | 146 | if (!_mail.envelope().mailDate().isNull()) |
147 | ftext += QString("Date: %1\n") | 147 | ftext += QString("Date: %1\n") |
148 | .arg(_mail.envelope().mailDate()); | 148 | .arg(_mail.envelope().mailDate()); |
149 | if (!_mail.envelope().from()[0].toString().isNull()) | 149 | if (!_mail.envelope().from()[0].toString().isNull()) |
150 | ftext += QString("From: %1\n") | 150 | ftext += QString("From: %1\n") |
151 | .arg(_mail.envelope().from()[0].toString()); | 151 | .arg(_mail.envelope().from()[0].toString()); |
152 | if (!_mail.envelope().to().toString().isNull()) | 152 | if (!_mail.envelope().to().toString().isNull()) |
153 | ftext += QString("To: %1\n") | 153 | ftext += QString("To: %1\n") |
154 | .arg(_mail.envelope().to().toString()); | 154 | .arg(_mail.envelope().to().toString()); |
155 | if (!_mail.envelope().cc().toString().isNull()) | 155 | if (!_mail.envelope().cc().toString().isNull()) |
156 | ftext += QString("Cc: %1\n") | 156 | ftext += QString("Cc: %1\n") |
157 | .arg(_mail.envelope().cc().toString()); | 157 | .arg(_mail.envelope().cc().toString()); |
158 | if (!_mail.envelope().bcc().toString().isNull()) | 158 | if (!_mail.envelope().bcc().toString().isNull()) |
159 | ftext += QString("Bcc: %1\n") | 159 | ftext += QString("Bcc: %1\n") |
160 | .arg(_mail.envelope().bcc().toString()); | 160 | .arg(_mail.envelope().bcc().toString()); |
161 | if (!_mail.envelope().subject().isNull()) | 161 | if (!_mail.envelope().subject().isNull()) |
162 | ftext += QString("Subject: %1\n") | 162 | ftext += QString("Subject: %1\n") |
163 | .arg(_mail.envelope().subject()); | 163 | .arg(_mail.envelope().subject()); |
164 | 164 | ||
165 | ftext += QString("\n%1\n") | 165 | ftext += QString("\n%1\n") |
166 | .arg(_mail.bodyPart(1).data()); | 166 | .arg(_mail.bodyPart(1).data()); |
167 | 167 | ||
168 | ftext += QString("----- End forwarded message -----\n"); | 168 | ftext += QString("----- End forwarded message -----\n"); |
169 | 169 | ||
170 | SendMail sendMail; | 170 | SendMail sendMail; |
171 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); | 171 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); |
172 | sendMail.setMessage(ftext); | 172 | sendMail.setMessage(ftext); |
173 | 173 | ||
174 | Composer composer(this, 0, true); | 174 | Composer composer(this, 0, true); |
175 | composer.setSendMail(sendMail); | 175 | composer.setSendMail(sendMail); |
176 | composer.showMaximized(); | 176 | composer.showMaximized(); |
177 | composer.exec(); | 177 | composer.exec(); |
178 | } | 178 | } |
179 | 179 | ||
180 | void ViewMail::slotIMAPUid(IMAPResponse &response) | 180 | void ViewMail::slotIMAPUid(IMAPResponse &response) |
181 | { | 181 | { |
182 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); | 182 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPUid(IMAPResponse&))); |
183 | 183 | ||
184 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 184 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
185 | QValueList<IMAPResponseBodyPart> bodyParts; | 185 | QValueList<IMAPResponseBodyPart> bodyParts; |
186 | bodyParts.append(response.FETCH()[0].bodyPart(0)); | 186 | bodyParts.append(response.FETCH()[0].bodyPart(0)); |
187 | _mail.setBodyParts(bodyParts); | 187 | _mail.setBodyParts(bodyParts); |
188 | 188 | ||
189 | browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(0).data()))); | 189 | browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(0).data()))); |
190 | 190 | ||
191 | // fillList(response.FETCH()[0].bodyStructure()); | 191 | // fillList(response.FETCH()[0].bodyStructure()); |
192 | 192 | ||
193 | _gotBody = true; | 193 | _gotBody = true; |
194 | } else { | 194 | } else { |
195 | QMessageBox::warning(this, tr("Error"), tr("<p>I was unable to retrieve the mail from the server. You can try again later or give up.</p>"), tr("Ok")); | 195 | QMessageBox::warning(this, tr("Error"), tr("<p>I was unable to retrieve the mail from the server. You can try again later or give up.</p>"), tr("Ok")); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||