author | leseb <leseb> | 2002-06-16 16:15:47 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-16 16:15:47 (UTC) |
commit | ea69cfbbde29fef2f792d1eab702699aada088bf (patch) (unidiff) | |
tree | 1b908b905a16deaba7331d2f0b0c844f94235da0 | |
parent | d4414131cdf32677e8d54a18827f2e772718c3f7 (diff) | |
download | opie-ea69cfbbde29fef2f792d1eab702699aada088bf.zip opie-ea69cfbbde29fef2f792d1eab702699aada088bf.tar.gz opie-ea69cfbbde29fef2f792d1eab702699aada088bf.tar.bz2 |
Fix memory leaks
-rw-r--r-- | noncore/unsupported/mail2/composer.cpp | 28 | ||||
-rw-r--r-- | noncore/unsupported/mail2/composer.h | 5 | ||||
-rw-r--r-- | noncore/unsupported/mail2/mainwindow.cpp | 26 | ||||
-rw-r--r-- | noncore/unsupported/mail2/searchdiag.cpp | 6 | ||||
-rw-r--r-- | noncore/unsupported/mail2/viewmail.cpp | 44 | ||||
-rw-r--r-- | noncore/unsupported/mail2/viewmail.h | 5 |
6 files changed, 88 insertions, 26 deletions
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp index 82ed117..7f65dba 100644 --- a/noncore/unsupported/mail2/composer.cpp +++ b/noncore/unsupported/mail2/composer.cpp | |||
@@ -1,218 +1,244 @@ | |||
1 | #include <qmultilineedit.h> | 1 | #include <qmultilineedit.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qpopupmenu.h> | 3 | #include <qpopupmenu.h> |
4 | #include <qcombobox.h> | 4 | #include <qcombobox.h> |
5 | #include <qlineedit.h> | 5 | #include <qlineedit.h> |
6 | #include <qaction.h> | 6 | #include <qaction.h> |
7 | #include <qtimer.h> | 7 | #include <qtimer.h> |
8 | #include <qlabel.h> | 8 | #include <qlabel.h> |
9 | #include <qapplication.h> | ||
9 | 10 | ||
10 | #include <qpe/resource.h> | 11 | #include <qpe/resource.h> |
11 | 12 | ||
12 | #include "addresspicker.h" | 13 | #include "addresspicker.h" |
13 | #include "listviewplus.h" | 14 | #include "listviewplus.h" |
14 | #include "smtphandler.h" | 15 | #include "smtphandler.h" |
15 | #include "attachdiag.h" | 16 | #include "attachdiag.h" |
16 | #include "composer.h" | 17 | #include "composer.h" |
17 | #include "rename.h" | 18 | #include "rename.h" |
18 | 19 | ||
19 | AttachViewItem::AttachViewItem(QListView *parent, Attachment &attachment) | 20 | AttachViewItem::AttachViewItem(QListView *parent, Attachment &attachment) |
20 | : QListViewItem(parent), _attachment(attachment) | 21 | : QListViewItem(parent), _attachment(attachment) |
21 | { | 22 | { |
22 | setPixmap(0, _attachment.docLnk()->pixmap().isNull() ? Resource::loadPixmap("UnknownDocument-14") : _attachment.docLnk()->pixmap()); | 23 | setPixmap(0, _attachment.docLnk()->pixmap().isNull() ? Resource::loadPixmap("UnknownDocument-14") : _attachment.docLnk()->pixmap()); |
23 | setText(0, _attachment.newName().isEmpty() ? _attachment.fileName() : _attachment.newName()); | 24 | setText(0, _attachment.newName().isEmpty() ? _attachment.fileName() : _attachment.newName()); |
24 | setText(1, _attachment.description()); | 25 | setText(1, _attachment.description()); |
25 | } | 26 | } |
26 | 27 | ||
27 | Composer::Composer(QWidget *parent, const char *name, WFlags fl) | 28 | Composer::Composer(QWidget *parent, const char *name, WFlags fl) |
28 | : ComposerBase(parent, name, fl) | 29 | : ComposerBase(parent, name, fl), _inLoop(false) |
29 | { | 30 | { |
30 | abort->setEnabled(false); | 31 | abort->setEnabled(false); |
31 | to->setFocus(); | 32 | to->setFocus(); |
32 | 33 | ||
33 | connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail())); | 34 | connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail())); |
34 | connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker())); | 35 | connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker())); |
35 | connect(addattach, SIGNAL(activated()), SLOT(slotAddAttach())); | 36 | connect(addattach, SIGNAL(activated()), SLOT(slotAddAttach())); |
36 | connect(delattach, SIGNAL(activated()), SLOT(slotDelAttach())); | 37 | connect(delattach, SIGNAL(activated()), SLOT(slotDelAttach())); |
37 | 38 | ||
38 | connect(from, SIGNAL(activated(int)), SLOT(slotFromChanged(int))); | 39 | connect(from, SIGNAL(activated(int)), SLOT(slotFromChanged(int))); |
39 | 40 | ||
40 | connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int))); | 41 | connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int))); |
41 | 42 | ||
42 | QTimer::singleShot(0, this, SLOT(slotFillStuff())); | 43 | QTimer::singleShot(0, this, SLOT(slotFillStuff())); |
43 | QTimer::singleShot(0, this, SLOT(slotResizing())); | 44 | QTimer::singleShot(0, this, SLOT(slotResizing())); |
44 | } | 45 | } |
45 | 46 | ||
47 | Composer::~Composer() | ||
48 | { | ||
49 | hide(); | ||
50 | } | ||
51 | |||
52 | void Composer::hide() | ||
53 | { | ||
54 | QWidget::hide(); | ||
55 | |||
56 | if (_inLoop) { | ||
57 | _inLoop = false; | ||
58 | qApp->exit_loop(); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | void Composer::exec() | ||
63 | { | ||
64 | show(); | ||
65 | |||
66 | if (!_inLoop) { | ||
67 | _inLoop = true; | ||
68 | qApp->enter_loop(); | ||
69 | } | ||
70 | } | ||
71 | |||
46 | void Composer::setSendMail(SendMail &sendMail) | 72 | void Composer::setSendMail(SendMail &sendMail) |
47 | { | 73 | { |
48 | to->setText(sendMail.to()); | 74 | to->setText(sendMail.to()); |
49 | cc->setText(sendMail.cc()); | 75 | cc->setText(sendMail.cc()); |
50 | bcc->setText(sendMail.bcc()); | 76 | bcc->setText(sendMail.bcc()); |
51 | subject->setText(sendMail.subject()); | 77 | subject->setText(sendMail.subject()); |
52 | message->setText(sendMail.message()); | 78 | message->setText(sendMail.message()); |
53 | _inReplyTo = sendMail.inReplyTo(); | 79 | _inReplyTo = sendMail.inReplyTo(); |
54 | 80 | ||
55 | QValueList<Attachment> attachments = sendMail.attachments(); | 81 | QValueList<Attachment> attachments = sendMail.attachments(); |
56 | QValueList<Attachment>::Iterator it; | 82 | QValueList<Attachment>::Iterator it; |
57 | for (it = attachments.begin(); it != attachments.end(); it++) { | 83 | for (it = attachments.begin(); it != attachments.end(); it++) { |
58 | (void) new AttachViewItem(attachView, *it); | 84 | (void) new AttachViewItem(attachView, *it); |
59 | if (attachView->isHidden()) attachView->show(); | 85 | if (attachView->isHidden()) attachView->show(); |
60 | } | 86 | } |
61 | } | 87 | } |
62 | 88 | ||
63 | void Composer::slotResizing() | 89 | void Composer::slotResizing() |
64 | { | 90 | { |
65 | from->setMaximumWidth(width() - fromBox->width()); | 91 | from->setMaximumWidth(width() - fromBox->width()); |
66 | from->resize(width() - fromBox->width(), y()); | 92 | from->resize(width() - fromBox->width(), y()); |
67 | } | 93 | } |
68 | 94 | ||
69 | void Composer::slotPopupHandler(int itemid) | 95 | void Composer::slotPopupHandler(int itemid) |
70 | { | 96 | { |
71 | if (attachView->currentItem() == NULL) { | 97 | if (attachView->currentItem() == NULL) { |
72 | QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok")); | 98 | QMessageBox::information(this, tr("Error"), tr("Please select an entry first."), tr("Ok")); |
73 | return; | 99 | return; |
74 | } | 100 | } |
75 | 101 | ||
76 | if (itemid == POPUP_ATTACH_RENAME) { | 102 | if (itemid == POPUP_ATTACH_RENAME) { |
77 | QString tmp = Rename::rename(attachView->currentItem()->text(0), this); | 103 | QString tmp = Rename::rename(attachView->currentItem()->text(0), this); |
78 | if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp); | 104 | if (tmp != QString(0)) attachView->currentItem()->setText(0, tmp); |
79 | } else if (itemid == POPUP_ATTACH_DESC) { | 105 | } else if (itemid == POPUP_ATTACH_DESC) { |
80 | QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this); | 106 | QString tmp = Rename::getText(tr("Set Description"), tr("<div align=center>Description"), this); |
81 | if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp); | 107 | if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp); |
82 | } else if (itemid == POPUP_ATTACH_REMOVE) { | 108 | } else if (itemid == POPUP_ATTACH_REMOVE) { |
83 | attachView->takeItem(attachView->currentItem()); | 109 | attachView->takeItem(attachView->currentItem()); |
84 | } | 110 | } |
85 | } | 111 | } |
86 | 112 | ||
87 | void Composer::slotSendMail() | 113 | void Composer::slotSendMail() |
88 | { | 114 | { |
89 | if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { | 115 | if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { |
90 | QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); | 116 | QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); |
91 | return; | 117 | return; |
92 | } | 118 | } |
93 | 119 | ||
94 | SendMail smail; | 120 | SendMail smail; |
95 | smail.setFrom(from->currentText()); | 121 | smail.setFrom(from->currentText()); |
96 | smail.setReplyTo(replyto->text()); | 122 | smail.setReplyTo(replyto->text()); |
97 | smail.setTo(to->text()); | 123 | smail.setTo(to->text()); |
98 | smail.setCc(cc->text()); | 124 | smail.setCc(cc->text()); |
99 | smail.setBcc(bcc->text()); | 125 | smail.setBcc(bcc->text()); |
100 | smail.setSubject(subject->text()); | 126 | smail.setSubject(subject->text()); |
101 | smail.setMessage(message->text()); | 127 | smail.setMessage(message->text()); |
102 | smail.setNeedsMime(attachView->childCount() == 0 ? false : true); | 128 | smail.setNeedsMime(attachView->childCount() == 0 ? false : true); |
103 | smail.setAccount(accountsLoaded[from->currentItem()]); | 129 | smail.setAccount(accountsLoaded[from->currentItem()]); |
104 | 130 | ||
105 | if (priority->currentItem() == POPUP_PRIO_LOW) { | 131 | if (priority->currentItem() == POPUP_PRIO_LOW) { |
106 | smail.setPriority("Low");// No i18n on purpose | 132 | smail.setPriority("Low");// No i18n on purpose |
107 | } else if (priority->currentItem() == POPUP_PRIO_NORMAL) { | 133 | } else if (priority->currentItem() == POPUP_PRIO_NORMAL) { |
108 | smail.setPriority("Normal");// No i18n on purpose | 134 | smail.setPriority("Normal");// No i18n on purpose |
109 | } else if (priority->currentItem() == POPUP_PRIO_HIGH) { | 135 | } else if (priority->currentItem() == POPUP_PRIO_HIGH) { |
110 | smail.setPriority("High");// No i18n on purpose | 136 | smail.setPriority("High");// No i18n on purpose |
111 | } | 137 | } |
112 | 138 | ||
113 | QValueList<Attachment> attachments; | 139 | QValueList<Attachment> attachments; |
114 | QListViewItem *item; | 140 | QListViewItem *item; |
115 | for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { | 141 | for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { |
116 | attachments.append(((AttachViewItem *)item)->attachment()); | 142 | attachments.append(((AttachViewItem *)item)->attachment()); |
117 | } | 143 | } |
118 | 144 | ||
119 | smail.setAttachments(attachments); | 145 | smail.setAttachments(attachments); |
120 | 146 | ||
121 | QString header, message; | 147 | QString header, message; |
122 | MailFactory::genMail(header, message, smail, this); | 148 | MailFactory::genMail(header, message, smail, this); |
123 | if (header.isNull() || message.isNull()) return;// Aborted. | 149 | if (header.isNull() || message.isNull()) return;// Aborted. |
124 | 150 | ||
125 | abort->setEnabled(true); | 151 | abort->setEnabled(true); |
126 | 152 | ||
127 | SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text()); | 153 | SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text()); |
128 | connect(handler, SIGNAL(finished()), SLOT(slotSendFinished())); | 154 | connect(handler, SIGNAL(finished()), SLOT(slotSendFinished())); |
129 | connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &))); | 155 | connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &))); |
130 | connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &))); | 156 | connect(handler, SIGNAL(status(const QString &)), status, SLOT(setText(const QString &))); |
131 | } | 157 | } |
132 | 158 | ||
133 | void Composer::slotSendError(const QString &error) | 159 | void Composer::slotSendError(const QString &error) |
134 | { | 160 | { |
135 | status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>")); | 161 | status->setText(tr("<font color=#ff0000>Error occoured during sending.</font>")); |
136 | QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); | 162 | QMessageBox::warning(this, tr("Error"), tr("<p>%1</p").arg(error), tr("Ok")); |
137 | } | 163 | } |
138 | 164 | ||
139 | void Composer::slotSendFinished() | 165 | void Composer::slotSendFinished() |
140 | { | 166 | { |
141 | QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok")); | 167 | QMessageBox::information(this, tr("Success"), tr("<p>The mail was sent successfully.</p>"), tr("Ok")); |
142 | 168 | ||
143 | status->setText(QString(0)); | 169 | status->setText(QString(0)); |
144 | abort->setEnabled(false); | 170 | abort->setEnabled(false); |
145 | } | 171 | } |
146 | 172 | ||
147 | void Composer::slotFillStuff() | 173 | void Composer::slotFillStuff() |
148 | { | 174 | { |
149 | QValueList<Account> accounts = ConfigFile::getAccounts(); | 175 | QValueList<Account> accounts = ConfigFile::getAccounts(); |
150 | int i = 0; | 176 | int i = 0; |
151 | 177 | ||
152 | QValueList<Account>::Iterator it; | 178 | QValueList<Account>::Iterator it; |
153 | for (it = accounts.begin(); it != accounts.end(); it++) { | 179 | for (it = accounts.begin(); it != accounts.end(); it++) { |
154 | if (!(*it).email().isEmpty() && !(*it).smtpServer().isEmpty() && !(*it).smtpPort().isEmpty()) { | 180 | if (!(*it).email().isEmpty() && !(*it).smtpServer().isEmpty() && !(*it).smtpPort().isEmpty()) { |
155 | if (!(*it).realName().isEmpty()) | 181 | if (!(*it).realName().isEmpty()) |
156 | from->insertItem((*it).realName() + " <" + (*it).email() + ">", i); | 182 | from->insertItem((*it).realName() + " <" + (*it).email() + ">", i); |
157 | else | 183 | else |
158 | from->insertItem((*it).email()); | 184 | from->insertItem((*it).email()); |
159 | 185 | ||
160 | accountsLoaded.append(*it); | 186 | accountsLoaded.append(*it); |
161 | i++; | 187 | i++; |
162 | } | 188 | } |
163 | } | 189 | } |
164 | } | 190 | } |
165 | 191 | ||
166 | void Composer::slotFromChanged(int id) | 192 | void Composer::slotFromChanged(int id) |
167 | { | 193 | { |
168 | Account account = accountsLoaded[id]; | 194 | Account account = accountsLoaded[id]; |
169 | 195 | ||
170 | if (account.defaultCc()) cc->setText(account.cc()); | 196 | if (account.defaultCc()) cc->setText(account.cc()); |
171 | if (account.defaultBcc()) bcc->setText(account.bcc()); | 197 | if (account.defaultBcc()) bcc->setText(account.bcc()); |
172 | if (account.defaultReplyTo()) replyto->setText(account.replyTo()); | 198 | if (account.defaultReplyTo()) replyto->setText(account.replyTo()); |
173 | if (!account.signature().isEmpty()) | 199 | if (!account.signature().isEmpty()) |
174 | message->setText(message->text() + "\n\n-- \n" + account.signature()); | 200 | message->setText(message->text() + "\n\n-- \n" + account.signature()); |
175 | } | 201 | } |
176 | 202 | ||
177 | void Composer::slotOpenAddressPicker() | 203 | void Composer::slotOpenAddressPicker() |
178 | { | 204 | { |
179 | if (!to->isHidden() && cc->isHidden() && bcc->isHidden()) { | 205 | if (!to->isHidden() && cc->isHidden() && bcc->isHidden()) { |
180 | if (to->text().isEmpty()) { | 206 | if (to->text().isEmpty()) { |
181 | to->setText(AddressPicker::getNames()); | 207 | to->setText(AddressPicker::getNames()); |
182 | } else { | 208 | } else { |
183 | to->setText(to->text() + ", " + AddressPicker::getNames()); | 209 | to->setText(to->text() + ", " + AddressPicker::getNames()); |
184 | } | 210 | } |
185 | } else if (to->isHidden() && !cc->isHidden() && bcc->isHidden()) { | 211 | } else if (to->isHidden() && !cc->isHidden() && bcc->isHidden()) { |
186 | if (cc->text().isEmpty()) { | 212 | if (cc->text().isEmpty()) { |
187 | cc->setText(AddressPicker::getNames()); | 213 | cc->setText(AddressPicker::getNames()); |
188 | } else { | 214 | } else { |
189 | cc->setText(cc->text() + ", " + AddressPicker::getNames()); | 215 | cc->setText(cc->text() + ", " + AddressPicker::getNames()); |
190 | } | 216 | } |
191 | } else if (to->isHidden() && cc->isHidden() && !bcc->isHidden()) { | 217 | } else if (to->isHidden() && cc->isHidden() && !bcc->isHidden()) { |
192 | if (bcc->text().isEmpty()) { | 218 | if (bcc->text().isEmpty()) { |
193 | bcc->setText(AddressPicker::getNames()); | 219 | bcc->setText(AddressPicker::getNames()); |
194 | } else { | 220 | } else { |
195 | bcc->setText(bcc->text() + ", " + AddressPicker::getNames()); | 221 | bcc->setText(bcc->text() + ", " + AddressPicker::getNames()); |
196 | } | 222 | } |
197 | } | 223 | } |
198 | } | 224 | } |
199 | 225 | ||
200 | void Composer::slotAddAttach() | 226 | void Composer::slotAddAttach() |
201 | { | 227 | { |
202 | DocLnk lnk = AttachDiag::getFile(this); | 228 | DocLnk lnk = AttachDiag::getFile(this); |
203 | if (lnk.name().isEmpty()) return; | 229 | if (lnk.name().isEmpty()) return; |
204 | 230 | ||
205 | Attachment attachment; | 231 | Attachment attachment; |
206 | attachment.setFileName(lnk.file()); | 232 | attachment.setFileName(lnk.file()); |
207 | attachment.setNewName(lnk.name()); | 233 | attachment.setNewName(lnk.name()); |
208 | attachment.setDocLnk(&lnk); | 234 | attachment.setDocLnk(&lnk); |
209 | 235 | ||
210 | (void) new AttachViewItem(attachView, attachment); | 236 | (void) new AttachViewItem(attachView, attachment); |
211 | } | 237 | } |
212 | 238 | ||
213 | void Composer::slotDelAttach() | 239 | void Composer::slotDelAttach() |
214 | { | 240 | { |
215 | if (attachView->currentItem() == NULL) return; | 241 | if (attachView->currentItem() == NULL) return; |
216 | attachView->takeItem(attachView->currentItem()); | 242 | attachView->takeItem(attachView->currentItem()); |
217 | } | 243 | } |
218 | 244 | ||
diff --git a/noncore/unsupported/mail2/composer.h b/noncore/unsupported/mail2/composer.h index a1af121..2640d7e 100644 --- a/noncore/unsupported/mail2/composer.h +++ b/noncore/unsupported/mail2/composer.h | |||
@@ -1,52 +1,57 @@ | |||
1 | #ifndef COMPOSER_H | 1 | #ifndef COMPOSER_H |
2 | #define COMPOSER_H | 2 | #define COMPOSER_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qpe/applnk.h> | 5 | #include <qpe/applnk.h> |
6 | 6 | ||
7 | #include "mailfactory.h" | 7 | #include "mailfactory.h" |
8 | #include "composerbase.h" | 8 | #include "composerbase.h" |
9 | #include "configfile.h" | 9 | #include "configfile.h" |
10 | 10 | ||
11 | class AttachViewItem : public QListViewItem | 11 | class AttachViewItem : public QListViewItem |
12 | { | 12 | { |
13 | public: | 13 | public: |
14 | AttachViewItem(QListView *parent, Attachment &attachment); | 14 | AttachViewItem(QListView *parent, Attachment &attachment); |
15 | 15 | ||
16 | Attachment attachment() { return _attachment; } | 16 | Attachment attachment() { return _attachment; } |
17 | 17 | ||
18 | private: | 18 | private: |
19 | Attachment _attachment; | 19 | Attachment _attachment; |
20 | 20 | ||
21 | }; | 21 | }; |
22 | 22 | ||
23 | class Composer : public ComposerBase | 23 | class Composer : public ComposerBase |
24 | { | 24 | { |
25 | Q_OBJECT | 25 | Q_OBJECT |
26 | 26 | ||
27 | public: | 27 | public: |
28 | Composer(QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); | 28 | Composer(QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); |
29 | ~Composer(); | ||
30 | |||
31 | void hide(); | ||
32 | void exec(); | ||
29 | 33 | ||
30 | void setSendMail(SendMail &sendMail); | 34 | void setSendMail(SendMail &sendMail); |
31 | 35 | ||
32 | protected slots: | 36 | protected slots: |
33 | void slotPopupHandler(int itemid); | 37 | void slotPopupHandler(int itemid); |
34 | void slotSendMail(); | 38 | void slotSendMail(); |
35 | void slotSendError(const QString &); | 39 | void slotSendError(const QString &); |
36 | void slotSendFinished(); | 40 | void slotSendFinished(); |
37 | void slotResizing(); | 41 | void slotResizing(); |
38 | void slotFillStuff(); | 42 | void slotFillStuff(); |
39 | void slotFromChanged(int id); | 43 | void slotFromChanged(int id); |
40 | void slotOpenAddressPicker(); | 44 | void slotOpenAddressPicker(); |
41 | void slotAddAttach(); | 45 | void slotAddAttach(); |
42 | void slotDelAttach(); | 46 | void slotDelAttach(); |
43 | 47 | ||
44 | protected: | 48 | protected: |
45 | QValueList<Account> accountsLoaded; | 49 | QValueList<Account> accountsLoaded; |
46 | 50 | ||
47 | private: | 51 | private: |
52 | bool _inLoop; | ||
48 | QString _inReplyTo; | 53 | QString _inReplyTo; |
49 | 54 | ||
50 | }; | 55 | }; |
51 | 56 | ||
52 | #endif | 57 | #endif |
diff --git a/noncore/unsupported/mail2/mainwindow.cpp b/noncore/unsupported/mail2/mainwindow.cpp index 4d15e23..2230dc0 100644 --- a/noncore/unsupported/mail2/mainwindow.cpp +++ b/noncore/unsupported/mail2/mainwindow.cpp | |||
@@ -1,65 +1,65 @@ | |||
1 | #include <qprogressbar.h> | 1 | #include <qprogressbar.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | 5 | ||
6 | #include "folderwidget.h" | 6 | #include "folderwidget.h" |
7 | #include "mainwindow.h" | 7 | #include "mainwindow.h" |
8 | #include "configdiag.h" | 8 | #include "configdiag.h" |
9 | #include "configfile.h" | 9 | #include "configfile.h" |
10 | #include "searchdiag.h" | 10 | #include "searchdiag.h" |
11 | #include "mailtable.h" | 11 | #include "mailtable.h" |
12 | #include "composer.h" | 12 | #include "composer.h" |
13 | #include "viewmail.h" | 13 | #include "viewmail.h" |
14 | 14 | ||
15 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl) | 15 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl) |
16 | : MainWindowBase(parent, name, fl) | 16 | : MainWindowBase(parent, name, fl) |
17 | { | 17 | { |
18 | stop->setEnabled(false); | 18 | stop->setEnabled(false); |
19 | 19 | ||
20 | connect(folderView, SIGNAL(status(const QString &)), statusLabel, SLOT(setText(const QString &))); | 20 | connect(folderView, SIGNAL(status(const QString &)), statusLabel, SLOT(setText(const QString &))); |
21 | connect(folderView, SIGNAL(folderSelected(Folder)), mailView, SLOT(setFolder(Folder))); | 21 | connect(folderView, SIGNAL(folderSelected(Folder)), mailView, SLOT(setFolder(Folder))); |
22 | 22 | ||
23 | connect(mailView, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(mailClicked(IMAPResponseFETCH, IMAPHandler *))); | 23 | connect(mailView, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(mailClicked(IMAPResponseFETCH, IMAPHandler *))); |
24 | connect(mailView, SIGNAL(status(const QString &)), statusLabel, SLOT(setText(const QString &))); | 24 | connect(mailView, SIGNAL(status(const QString &)), statusLabel, SLOT(setText(const QString &))); |
25 | connect(mailView, SIGNAL(totalSteps(int)), statusProgress, SLOT(setTotalSteps(int))); | 25 | connect(mailView, SIGNAL(totalSteps(int)), statusProgress, SLOT(setTotalSteps(int))); |
26 | connect(mailView, SIGNAL(progress(int)), statusProgress, SLOT(setProgress(int))); | 26 | connect(mailView, SIGNAL(progress(int)), statusProgress, SLOT(setProgress(int))); |
27 | connect(mailView, SIGNAL(resetProgress()), statusProgress, SLOT(reset())); | 27 | connect(mailView, SIGNAL(resetProgress()), statusProgress, SLOT(reset())); |
28 | connect(mailView, SIGNAL(stopEnabled(bool)), stop, SLOT(setEnabled(bool))); | 28 | connect(mailView, SIGNAL(stopEnabled(bool)), stop, SLOT(setEnabled(bool))); |
29 | 29 | ||
30 | connect(stop, SIGNAL(activated()), mailView, SLOT(stop())); | 30 | connect(stop, SIGNAL(activated()), mailView, SLOT(stop())); |
31 | 31 | ||
32 | connect(compose, SIGNAL(activated()), SLOT(slotCompose())); | 32 | connect(compose, SIGNAL(activated()), SLOT(slotCompose())); |
33 | connect(findmails, SIGNAL(activated()), SLOT(slotSearch())); | 33 | connect(findmails, SIGNAL(activated()), SLOT(slotSearch())); |
34 | connect(configure, SIGNAL(activated()), SLOT(slotConfigure())); | 34 | connect(configure, SIGNAL(activated()), SLOT(slotConfigure())); |
35 | } | 35 | } |
36 | 36 | ||
37 | void MainWindow::slotCompose() | 37 | void MainWindow::slotCompose() |
38 | { | 38 | { |
39 | Composer *composer = new Composer(); | 39 | Composer composer(this, 0, true); |
40 | composer->showMaximized(); | 40 | composer.showMaximized(); |
41 | composer->show(); | 41 | composer.exec(); |
42 | } | 42 | } |
43 | 43 | ||
44 | void MainWindow::slotSearch() | 44 | void MainWindow::slotSearch() |
45 | { | 45 | { |
46 | SearchDiag *searchDiag = new SearchDiag(this, 0, true); | 46 | SearchDiag searchDiag(this, 0, true); |
47 | searchDiag->showMaximized(); | 47 | searchDiag.showMaximized(); |
48 | searchDiag->show(); | 48 | searchDiag.exec(); |
49 | } | 49 | } |
50 | 50 | ||
51 | void MainWindow::slotConfigure() | 51 | void MainWindow::slotConfigure() |
52 | { | 52 | { |
53 | ConfigDiag *configDiag = new ConfigDiag(this, 0, true); | 53 | ConfigDiag configDiag(this, 0, true); |
54 | configDiag->showMaximized(); | 54 | configDiag.showMaximized(); |
55 | configDiag->show(); | 55 | configDiag.exec(); |
56 | 56 | ||
57 | connect(configDiag, SIGNAL(changed()), folderView, SLOT(update())); | 57 | connect(&configDiag, SIGNAL(changed()), folderView, SLOT(update())); |
58 | } | 58 | } |
59 | 59 | ||
60 | void MainWindow::mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler) | 60 | void MainWindow::mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler) |
61 | { | 61 | { |
62 | ViewMail *viewMail = new ViewMail(mail, handler); | 62 | ViewMail viewMail(mail, handler, this, 0, true); |
63 | viewMail->showMaximized(); | 63 | viewMail.showMaximized(); |
64 | viewMail->show(); | 64 | viewMail.exec(); |
65 | } | 65 | } |
diff --git a/noncore/unsupported/mail2/searchdiag.cpp b/noncore/unsupported/mail2/searchdiag.cpp index 33b8afb..907f6ff 100644 --- a/noncore/unsupported/mail2/searchdiag.cpp +++ b/noncore/unsupported/mail2/searchdiag.cpp | |||
@@ -1,128 +1,128 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | #include <qcombobox.h> | 3 | #include <qcombobox.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | 5 | ||
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | 7 | ||
8 | #include "imaphandler.h" | 8 | #include "imaphandler.h" |
9 | #include "searchdiag.h" | 9 | #include "searchdiag.h" |
10 | #include "viewmail.h" | 10 | #include "viewmail.h" |
11 | 11 | ||
12 | #define INMENU_BODY0 | 12 | #define INMENU_BODY0 |
13 | #define INMENU_HEADERF1 | 13 | #define INMENU_HEADERF1 |
14 | #define INMENU_SUBJECT2 | 14 | #define INMENU_SUBJECT2 |
15 | #define INMENU_FROM3 | 15 | #define INMENU_FROM3 |
16 | #define INMENU_TO4 | 16 | #define INMENU_TO4 |
17 | 17 | ||
18 | SearchDiag::SearchDiag(QWidget *parent, const char *name, WFlags fl) | 18 | SearchDiag::SearchDiag(QWidget *parent, const char *name, WFlags fl) |
19 | : SearchDiagBase(parent, name, fl) | 19 | : SearchDiagBase(parent, name, fl) |
20 | { | 20 | { |
21 | _selected = false; | 21 | _selected = false; |
22 | 22 | ||
23 | in->insertItem(tr("Body"), INMENU_BODY); | 23 | in->insertItem(tr("Body"), INMENU_BODY); |
24 | in->insertItem(tr("Header Field"), INMENU_HEADERF); | 24 | in->insertItem(tr("Header Field"), INMENU_HEADERF); |
25 | in->insertItem(tr("Subject"), INMENU_SUBJECT); | 25 | in->insertItem(tr("Subject"), INMENU_SUBJECT); |
26 | in->insertItem(tr("From"), INMENU_FROM); | 26 | in->insertItem(tr("From"), INMENU_FROM); |
27 | in->insertItem(tr("To"), INMENU_TO); | 27 | in->insertItem(tr("To"), INMENU_TO); |
28 | 28 | ||
29 | connect(folderView, SIGNAL(folderSelected(Folder)), SLOT(folderSelected(Folder))); | 29 | connect(folderView, SIGNAL(folderSelected(Folder)), SLOT(folderSelected(Folder))); |
30 | connect(in, SIGNAL(activated(int)), SLOT(slotInItemActivated(int))); | 30 | connect(in, SIGNAL(activated(int)), SLOT(slotInItemActivated(int))); |
31 | connect(mailTable, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(slotMailClicked(IMAPResponseFETCH, IMAPHandler *))); | 31 | connect(mailTable, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(slotMailClicked(IMAPResponseFETCH, IMAPHandler *))); |
32 | } | 32 | } |
33 | 33 | ||
34 | void SearchDiag::accept() | 34 | void SearchDiag::accept() |
35 | { | 35 | { |
36 | if (searchFor->text().isEmpty()) { | 36 | if (searchFor->text().isEmpty()) { |
37 | QMessageBox::information(this, tr("Error"), tr("<p>Please enter what to search for.</p>"), tr("Ok")); | 37 | QMessageBox::information(this, tr("Error"), tr("<p>Please enter what to search for.</p>"), tr("Ok")); |
38 | return; | 38 | return; |
39 | } | 39 | } |
40 | 40 | ||
41 | if (!_selected) { | 41 | if (!_selected) { |
42 | QMessageBox::information(this, tr("Error"), tr("<p>Please select a folder.</p>"), tr("Ok")); | 42 | QMessageBox::information(this, tr("Error"), tr("<p>Please select a folder.</p>"), tr("Ok")); |
43 | return; | 43 | return; |
44 | } | 44 | } |
45 | 45 | ||
46 | if (in->currentItem() == INMENU_HEADERF && other->currentText().isEmpty()) { | 46 | if (in->currentItem() == INMENU_HEADERF && other->currentText().isEmpty()) { |
47 | QMessageBox::information(this, tr("Error"), tr("<p>Please enter a header field to search in.</p>"), tr("Ok")); | 47 | QMessageBox::information(this, tr("Error"), tr("<p>Please enter a header field to search in.</p>"), tr("Ok")); |
48 | return; | 48 | return; |
49 | } | 49 | } |
50 | 50 | ||
51 | _folder.topFolder().handler()->iSelect(_folder.fullName()); | 51 | _folder.topFolder().handler()->iSelect(_folder.fullName()); |
52 | connect(_folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSelect(IMAPResponse &))); | 52 | connect(_folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSelect(IMAPResponse &))); |
53 | } | 53 | } |
54 | 54 | ||
55 | void SearchDiag::folderSelected(Folder folder) | 55 | void SearchDiag::folderSelected(Folder folder) |
56 | { | 56 | { |
57 | _selected = true; | 57 | _selected = true; |
58 | _folder = folder; | 58 | _folder = folder; |
59 | } | 59 | } |
60 | 60 | ||
61 | void SearchDiag::slotIMAPSelect(IMAPResponse &response) | 61 | void SearchDiag::slotIMAPSelect(IMAPResponse &response) |
62 | { | 62 | { |
63 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSelect(IMAPResponse &))); | 63 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSelect(IMAPResponse &))); |
64 | 64 | ||
65 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 65 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
66 | if (in->currentItem() == INMENU_BODY) { | 66 | if (in->currentItem() == INMENU_BODY) { |
67 | response.imapHandler()->iSearch("BODY \"" + searchFor->text() + "\""); | 67 | response.imapHandler()->iSearch("BODY \"" + searchFor->text() + "\""); |
68 | } else if (in->currentItem() == INMENU_HEADERF) { | 68 | } else if (in->currentItem() == INMENU_HEADERF) { |
69 | response.imapHandler()->iSearch("HEADER \""+ other->currentText() + "\" \"" + searchFor->text() + "\""); | 69 | response.imapHandler()->iSearch("HEADER \""+ other->currentText() + "\" \"" + searchFor->text() + "\""); |
70 | } else if (in->currentItem() == INMENU_SUBJECT) { | 70 | } else if (in->currentItem() == INMENU_SUBJECT) { |
71 | response.imapHandler()->iSearch("SUBJECT \"" + searchFor->text() + "\""); | 71 | response.imapHandler()->iSearch("SUBJECT \"" + searchFor->text() + "\""); |
72 | } else if (in->currentItem() == INMENU_FROM) { | 72 | } else if (in->currentItem() == INMENU_FROM) { |
73 | response.imapHandler()->iSearch("FROM \"" + searchFor->text() + "\""); | 73 | response.imapHandler()->iSearch("FROM \"" + searchFor->text() + "\""); |
74 | } else if (in->currentItem() == INMENU_TO) { | 74 | } else if (in->currentItem() == INMENU_TO) { |
75 | response.imapHandler()->iSearch("TO \"" + searchFor->text() + "\""); | 75 | response.imapHandler()->iSearch("TO \"" + searchFor->text() + "\""); |
76 | } else return; | 76 | } else return; |
77 | 77 | ||
78 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSearch(IMAPResponse &))); | 78 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSearch(IMAPResponse &))); |
79 | } else { | 79 | } else { |
80 | QMessageBox::warning(this, tr("Error"), tr("<p>Could not select the folder. Aborting. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); | 80 | QMessageBox::warning(this, tr("Error"), tr("<p>Could not select the folder. Aborting. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | void SearchDiag::slotIMAPSearch(IMAPResponse &response) | 84 | void SearchDiag::slotIMAPSearch(IMAPResponse &response) |
85 | { | 85 | { |
86 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &))); | 86 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &))); |
87 | 87 | ||
88 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 88 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
89 | IMAPResponseSEARCH results = response.SEARCH()[0]; | 89 | IMAPResponseSEARCH results = response.SEARCH()[0]; |
90 | if (results.mails().count() == 0) { | 90 | if (results.mails().count() == 0) { |
91 | QMessageBox::information(this, tr("Results"), tr("<p>No mails match your criteria.</p>"), tr("Ok")); | 91 | QMessageBox::information(this, tr("Results"), tr("<p>No mails match your criteria.</p>"), tr("Ok")); |
92 | return; | 92 | return; |
93 | } | 93 | } |
94 | 94 | ||
95 | response.imapHandler()->iFetch(results.mails().join(","), "ENVELOPE FLAGS UID"); | 95 | response.imapHandler()->iFetch(results.mails().join(","), "ENVELOPE FLAGS UID"); |
96 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &))); | 96 | connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &))); |
97 | } else { | 97 | } else { |
98 | QMessageBox::warning(this, tr("Error"), tr("<p>Search failed. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); | 98 | QMessageBox::warning(this, tr("Error"), tr("<p>Search failed. (Server said: %1)").arg(response.statusResponse().comment()), tr("Ok")); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | void SearchDiag::slotIMAPFetch(IMAPResponse &response) | 102 | void SearchDiag::slotIMAPFetch(IMAPResponse &response) |
103 | { | 103 | { |
104 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &))); | 104 | disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSearch(IMAPResponse &))); |
105 | 105 | ||
106 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 106 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
107 | mailTable->setHeaders(response.FETCH()); | 107 | mailTable->setHeaders(response.FETCH()); |
108 | } else { | 108 | } else { |
109 | QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't fetch the mail headers. (Server said: %1)").arg(response.statusResponse().comment())); | 109 | QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't fetch the mail headers. (Server said: %1)").arg(response.statusResponse().comment())); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *) | 113 | void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *) |
114 | { | 114 | { |
115 | ViewMail *viewMail = new ViewMail(fetch, _folder.topFolder().handler()); | 115 | ViewMail viewMail(fetch, _folder.topFolder().handler(), this, 0, true); |
116 | viewMail->showMaximized(); | 116 | viewMail.showMaximized(); |
117 | viewMail->show(); | 117 | viewMail.exec(); |
118 | } | 118 | } |
119 | 119 | ||
120 | void SearchDiag::slotInItemActivated(int index) | 120 | void SearchDiag::slotInItemActivated(int index) |
121 | { | 121 | { |
122 | if (index == INMENU_HEADERF) { | 122 | if (index == INMENU_HEADERF) { |
123 | other->setEnabled(true); | 123 | other->setEnabled(true); |
124 | } else { | 124 | } else { |
125 | other->setEnabled(false); | 125 | other->setEnabled(false); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
diff --git a/noncore/unsupported/mail2/viewmail.cpp b/noncore/unsupported/mail2/viewmail.cpp index ae1f5f3..3c88d99 100644 --- a/noncore/unsupported/mail2/viewmail.cpp +++ b/noncore/unsupported/mail2/viewmail.cpp | |||
@@ -1,172 +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 | 5 | ||
5 | #include "mailfactory.h" | 6 | #include "mailfactory.h" |
6 | #include "composer.h" | 7 | #include "composer.h" |
7 | #include "viewmail.h" | 8 | #include "viewmail.h" |
8 | 9 | ||
9 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) | 10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) |
10 | : QListViewItem(parent), _attachItemStore(attachItemStore) | 11 | : QListViewItem(parent), _attachItemStore(attachItemStore) |
11 | { | 12 | { |
12 | setText(0, _attachItemStore.mimeType()); | 13 | setText(0, _attachItemStore.mimeType()); |
13 | setText(1, _attachItemStore.fileName()); | 14 | setText(1, _attachItemStore.fileName()); |
14 | setText(2, _attachItemStore.description()); | 15 | setText(2, _attachItemStore.description()); |
15 | } | 16 | } |
16 | 17 | ||
17 | AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) | 18 | AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) |
18 | : QListViewItem(parent), _attachItemStore(attachItemStore) | 19 | : QListViewItem(parent), _attachItemStore(attachItemStore) |
19 | { | 20 | { |
20 | setText(0, _attachItemStore.mimeType()); | 21 | setText(0, _attachItemStore.mimeType()); |
21 | setText(1, _attachItemStore.fileName()); | 22 | setText(1, _attachItemStore.fileName()); |
22 | setText(2, _attachItemStore.description()); | 23 | setText(2, _attachItemStore.description()); |
23 | } | 24 | } |
24 | 25 | ||
25 | 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) |
26 | : ViewMailBase(parent, name, fl), _mail(mail), _handler(handler) | 27 | : ViewMailBase(parent, name, fl), _inLoop(false), _mail(mail), _handler(handler) |
27 | { | 28 | { |
28 | setCaption(caption().arg(mail.envelope().from()[0].name())); | 29 | setCaption(caption().arg(mail.envelope().from()[0].name())); |
29 | 30 | ||
30 | _gotBody = false; | 31 | _gotBody = false; |
31 | _mailHtml = tr( | 32 | _mailHtml = tr( |
32 | "<html><body>" | 33 | "<html><body>" |
33 | "<div align=center><b>%1</b></div>" | 34 | "<div align=center><b>%1</b></div>" |
34 | "<b>From:</b> %2<br>" | 35 | "<b>From:</b> %2<br>" |
35 | "<b>To:</b> %3<br>" | 36 | "<b>To:</b> %3<br>" |
36 | "%4" | 37 | "%4" |
37 | "%5" | 38 | "%5" |
38 | "<b>Date:</b> %6<hr>" | 39 | "<b>Date:</b> %6<hr>" |
39 | "<font face=fixed>%7</font>") | 40 | "<font face=fixed>%7</font>") |
40 | .arg(deHtml(mail.envelope().subject().isNull() ? tr("(no subject)") | 41 | .arg(deHtml(mail.envelope().subject().isNull() ? tr("(no subject)") |
41 | : deHtml(mail.envelope().subject()))) | 42 | : deHtml(mail.envelope().subject()))) |
42 | .arg(deHtml(mail.envelope().from().toString().isNull() ? tr("(no from)") | 43 | .arg(deHtml(mail.envelope().from().toString().isNull() ? tr("(no from)") |
43 | : mail.envelope().from().toString())) | 44 | : mail.envelope().from().toString())) |
44 | .arg(deHtml(mail.envelope().to().toString().isNull() ? tr("(no recipient)") | 45 | .arg(deHtml(mail.envelope().to().toString().isNull() ? tr("(no recipient)") |
45 | : mail.envelope().to().toString())) | 46 | : mail.envelope().to().toString())) |
46 | .arg(mail.envelope().cc().toString().isNull() ? QString(0) | 47 | .arg(mail.envelope().cc().toString().isNull() ? QString(0) |
47 | : 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()))) |
48 | .arg(mail.envelope().bcc().toString().isNull() ? QString(0) | 49 | .arg(mail.envelope().bcc().toString().isNull() ? QString(0) |
49 | : 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()))) |
50 | .arg(mail.envelope().mailDate().isNull() ? tr("(no date)") | 51 | .arg(mail.envelope().mailDate().isNull() ? tr("(no date)") |
51 | : mail.envelope().mailDate()) | 52 | : mail.envelope().mailDate()) |
52 | .arg("%1"); | 53 | .arg("%1"); |
53 | 54 | ||
54 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); | 55 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); |
55 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); | 56 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); |
56 | 57 | ||
57 | attachments->setEnabled(_gotBody); | 58 | attachments->setEnabled(_gotBody); |
58 | 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..."))); |
59 | 60 | ||
60 | _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); | 61 | _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); |
61 | connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); | 62 | connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); |
62 | } | 63 | } |
63 | 64 | ||
65 | ViewMail::~ViewMail() | ||
66 | { | ||
67 | hide(); | ||
68 | } | ||
69 | |||
70 | void ViewMail::hide() | ||
71 | { | ||
72 | QWidget::hide(); | ||
73 | |||
74 | if (_inLoop) { | ||
75 | _inLoop = false; | ||
76 | qApp->exit_loop(); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | void ViewMail::exec() | ||
81 | { | ||
82 | show(); | ||
83 | |||
84 | if (!_inLoop) { | ||
85 | _inLoop = true; | ||
86 | qApp->enter_loop(); | ||
87 | } | ||
88 | } | ||
89 | |||
64 | QString ViewMail::deHtml(const QString &string) | 90 | QString ViewMail::deHtml(const QString &string) |
65 | { | 91 | { |
66 | QString string_ = string; | 92 | QString string_ = string; |
67 | string_.replace(QRegExp("&"), "&"); | 93 | string_.replace(QRegExp("&"), "&"); |
68 | string_.replace(QRegExp("<"), "<"); | 94 | string_.replace(QRegExp("<"), "<"); |
69 | string_.replace(QRegExp(">"), ">"); | 95 | string_.replace(QRegExp(">"), ">"); |
70 | string_.replace(QRegExp("\\n"), "<br>"); | 96 | string_.replace(QRegExp("\\n"), "<br>"); |
71 | return string_; | 97 | return string_; |
72 | } | 98 | } |
73 | 99 | ||
74 | void ViewMail::slotReply() | 100 | void ViewMail::slotReply() |
75 | { | 101 | { |
76 | if (!_gotBody) { | 102 | if (!_gotBody) { |
77 | 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")); |
78 | return; | 104 | return; |
79 | } | 105 | } |
80 | 106 | ||
81 | QString rtext; | 107 | QString rtext; |
82 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 108 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
83 | .arg(_mail.envelope().from()[0].toString()) | 109 | .arg(_mail.envelope().from()[0].toString()) |
84 | .arg(_mail.envelope().mailDate()); | 110 | .arg(_mail.envelope().mailDate()); |
85 | 111 | ||
86 | QString text = _mail.bodyPart(1).data(); | 112 | QString text = _mail.bodyPart(1).data(); |
87 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 113 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
88 | QStringList::Iterator it; | 114 | QStringList::Iterator it; |
89 | for (it = lines.begin(); it != lines.end(); it++) { | 115 | for (it = lines.begin(); it != lines.end(); it++) { |
90 | rtext += "> " + *it + "\n"; | 116 | rtext += "> " + *it + "\n"; |
91 | } | 117 | } |
92 | rtext += "\n"; | 118 | rtext += "\n"; |
93 | 119 | ||
94 | QString prefix; | 120 | QString prefix; |
95 | if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = ""; | 121 | if (_mail.envelope().subject().find(QRegExp("^Re: *$")) != -1) prefix = ""; |
96 | else prefix = "Re: "; // no i18n on purpose | 122 | else prefix = "Re: "; // no i18n on purpose |
97 | 123 | ||
98 | SendMail sendMail; | 124 | SendMail sendMail; |
99 | sendMail.setTo(_mail.envelope().from()[0].toString()); | 125 | sendMail.setTo(_mail.envelope().from()[0].toString()); |
100 | sendMail.setSubject(prefix + _mail.envelope().subject()); | 126 | sendMail.setSubject(prefix + _mail.envelope().subject()); |
101 | sendMail.setInReplyTo(_mail.envelope().messageId()); | 127 | sendMail.setInReplyTo(_mail.envelope().messageId()); |
102 | sendMail.setMessage(rtext); | 128 | sendMail.setMessage(rtext); |
103 | 129 | ||
104 | Composer *composer = new Composer(0, 0, Qt::WType_Modal); | 130 | Composer composer(this, 0, true); |
105 | composer->setSendMail(sendMail); | 131 | composer.setSendMail(sendMail); |
106 | composer->showMaximized(); | 132 | composer.showMaximized(); |
107 | composer->show(); | 133 | composer.exec(); |
108 | } | 134 | } |
109 | 135 | ||
110 | void ViewMail::slotForward() | 136 | void ViewMail::slotForward() |
111 | { | 137 | { |
112 | if (!_gotBody) { | 138 | if (!_gotBody) { |
113 | 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")); |
114 | return; | 140 | return; |
115 | } | 141 | } |
116 | 142 | ||
117 | QString ftext; | 143 | QString ftext; |
118 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 144 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
119 | .arg(_mail.envelope().from()[0].toString()); | 145 | .arg(_mail.envelope().from()[0].toString()); |
120 | if (!_mail.envelope().mailDate().isNull()) | 146 | if (!_mail.envelope().mailDate().isNull()) |
121 | ftext += QString("Date: %1\n") | 147 | ftext += QString("Date: %1\n") |
122 | .arg(_mail.envelope().mailDate()); | 148 | .arg(_mail.envelope().mailDate()); |
123 | if (!_mail.envelope().from()[0].toString().isNull()) | 149 | if (!_mail.envelope().from()[0].toString().isNull()) |
124 | ftext += QString("From: %1\n") | 150 | ftext += QString("From: %1\n") |
125 | .arg(_mail.envelope().from()[0].toString()); | 151 | .arg(_mail.envelope().from()[0].toString()); |
126 | if (!_mail.envelope().to().toString().isNull()) | 152 | if (!_mail.envelope().to().toString().isNull()) |
127 | ftext += QString("To: %1\n") | 153 | ftext += QString("To: %1\n") |
128 | .arg(_mail.envelope().to().toString()); | 154 | .arg(_mail.envelope().to().toString()); |
129 | if (!_mail.envelope().cc().toString().isNull()) | 155 | if (!_mail.envelope().cc().toString().isNull()) |
130 | ftext += QString("Cc: %1\n") | 156 | ftext += QString("Cc: %1\n") |
131 | .arg(_mail.envelope().cc().toString()); | 157 | .arg(_mail.envelope().cc().toString()); |
132 | if (!_mail.envelope().bcc().toString().isNull()) | 158 | if (!_mail.envelope().bcc().toString().isNull()) |
133 | ftext += QString("Bcc: %1\n") | 159 | ftext += QString("Bcc: %1\n") |
134 | .arg(_mail.envelope().bcc().toString()); | 160 | .arg(_mail.envelope().bcc().toString()); |
135 | if (!_mail.envelope().subject().isNull()) | 161 | if (!_mail.envelope().subject().isNull()) |
136 | ftext += QString("Subject: %1\n") | 162 | ftext += QString("Subject: %1\n") |
137 | .arg(_mail.envelope().subject()); | 163 | .arg(_mail.envelope().subject()); |
138 | 164 | ||
139 | ftext += QString("\n%1\n") | 165 | ftext += QString("\n%1\n") |
140 | .arg(_mail.bodyPart(1).data()); | 166 | .arg(_mail.bodyPart(1).data()); |
141 | 167 | ||
142 | ftext += QString("----- End forwarded message -----\n"); | 168 | ftext += QString("----- End forwarded message -----\n"); |
143 | 169 | ||
144 | SendMail sendMail; | 170 | SendMail sendMail; |
145 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); | 171 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); |
146 | sendMail.setMessage(ftext); | 172 | sendMail.setMessage(ftext); |
147 | 173 | ||
148 | Composer *composer = new Composer(0, 0, Qt::WType_Modal); | 174 | Composer composer(this, 0, true); |
149 | composer->setSendMail(sendMail); | 175 | composer.setSendMail(sendMail); |
150 | composer->showMaximized(); | 176 | composer.showMaximized(); |
151 | composer->show(); | 177 | composer.exec(); |
152 | } | 178 | } |
153 | 179 | ||
154 | void ViewMail::slotIMAPUid(IMAPResponse &response) | 180 | void ViewMail::slotIMAPUid(IMAPResponse &response) |
155 | { | 181 | { |
156 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); | 182 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); |
157 | 183 | ||
158 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 184 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
159 | QValueList<IMAPResponseBodyPart> bodyParts; | 185 | QValueList<IMAPResponseBodyPart> bodyParts; |
160 | bodyParts.append(response.FETCH()[0].bodyPart(1)); | 186 | bodyParts.append(response.FETCH()[0].bodyPart(1)); |
161 | _mail.setBodyParts(bodyParts); | 187 | _mail.setBodyParts(bodyParts); |
162 | 188 | ||
163 | browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(1).data()))); | 189 | browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(1).data()))); |
164 | 190 | ||
165 | // fillList(response.FETCH()[0].bodyStructure()); | 191 | // fillList(response.FETCH()[0].bodyStructure()); |
166 | 192 | ||
167 | _gotBody = true; | 193 | _gotBody = true; |
168 | } else { | 194 | } else { |
169 | 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")); |
170 | } | 196 | } |
171 | } | 197 | } |
172 | 198 | ||
diff --git a/noncore/unsupported/mail2/viewmail.h b/noncore/unsupported/mail2/viewmail.h index a013e43..efc2300 100644 --- a/noncore/unsupported/mail2/viewmail.h +++ b/noncore/unsupported/mail2/viewmail.h | |||
@@ -1,65 +1,70 @@ | |||
1 | #ifndef VIEWMAIL_H | 1 | #ifndef VIEWMAIL_H |
2 | #define VIEWMAIL_H | 2 | #define VIEWMAIL_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | 5 | ||
6 | #include "viewmailbase.h" | 6 | #include "viewmailbase.h" |
7 | #include "imapresponse.h" | 7 | #include "imapresponse.h" |
8 | #include "mailtable.h" | 8 | #include "mailtable.h" |
9 | 9 | ||
10 | class AttachItemStore | 10 | class AttachItemStore |
11 | { | 11 | { |
12 | public: | 12 | public: |
13 | void setMimeType(QString mimeType) { _mimeType = mimeType; } | 13 | void setMimeType(QString mimeType) { _mimeType = mimeType; } |
14 | QString mimeType() { return _mimeType; } | 14 | QString mimeType() { return _mimeType; } |
15 | void setFileName(QString fileName) { _fileName = fileName; } | 15 | void setFileName(QString fileName) { _fileName = fileName; } |
16 | QString fileName() { return _fileName; } | 16 | QString fileName() { return _fileName; } |
17 | void setDescription(QString description) { _description = description; } | 17 | void setDescription(QString description) { _description = description; } |
18 | QString description() { return _description; } | 18 | QString description() { return _description; } |
19 | void setPartNum(QString partNum) { _partNum = partNum; } | 19 | void setPartNum(QString partNum) { _partNum = partNum; } |
20 | QString partNum() { return _partNum; } | 20 | QString partNum() { return _partNum; } |
21 | 21 | ||
22 | private: | 22 | private: |
23 | QString _mimeType, _fileName, _description, _partNum; | 23 | QString _mimeType, _fileName, _description, _partNum; |
24 | 24 | ||
25 | }; | 25 | }; |
26 | 26 | ||
27 | class AttachItem : public QListViewItem | 27 | class AttachItem : public QListViewItem |
28 | { | 28 | { |
29 | public: | 29 | public: |
30 | AttachItem(QListView *parent, AttachItemStore &attachment); | 30 | AttachItem(QListView *parent, AttachItemStore &attachment); |
31 | AttachItem(QListViewItem *parent, AttachItemStore &attachment); | 31 | AttachItem(QListViewItem *parent, AttachItemStore &attachment); |
32 | 32 | ||
33 | AttachItemStore attachItemStore() { return _attachItemStore; } | 33 | AttachItemStore attachItemStore() { return _attachItemStore; } |
34 | 34 | ||
35 | private: | 35 | private: |
36 | AttachItemStore _attachItemStore; | 36 | AttachItemStore _attachItemStore; |
37 | 37 | ||
38 | }; | 38 | }; |
39 | 39 | ||
40 | class ViewMail : public ViewMailBase | 40 | class ViewMail : public ViewMailBase |
41 | { | 41 | { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | 43 | ||
44 | public: | 44 | public: |
45 | ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); | 45 | ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); |
46 | ~ViewMail(); | ||
47 | |||
48 | void hide(); | ||
49 | void exec(); | ||
46 | 50 | ||
47 | protected: | 51 | protected: |
48 | //void fillList(IMAPResponseBODYSTRUCTURE &structure); | 52 | //void fillList(IMAPResponseBODYSTRUCTURE &structure); |
49 | QString deHtml(const QString &string); | 53 | QString deHtml(const QString &string); |
50 | 54 | ||
51 | protected slots: | 55 | protected slots: |
52 | void slotReply(); | 56 | void slotReply(); |
53 | void slotForward(); | 57 | void slotForward(); |
54 | 58 | ||
55 | void slotIMAPUid(IMAPResponse &response); | 59 | void slotIMAPUid(IMAPResponse &response); |
56 | 60 | ||
57 | private: | 61 | private: |
62 | bool _inLoop; | ||
58 | IMAPResponseFETCH _mail; | 63 | IMAPResponseFETCH _mail; |
59 | IMAPHandler *_handler; | 64 | IMAPHandler *_handler; |
60 | QString _mailHtml; | 65 | QString _mailHtml; |
61 | bool _gotBody; | 66 | bool _gotBody; |
62 | 67 | ||
63 | }; | 68 | }; |
64 | 69 | ||
65 | #endif | 70 | #endif |