summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mail2
Unidiff
Diffstat (limited to 'noncore/unsupported/mail2') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/bend/bend.cpp4
-rw-r--r--noncore/unsupported/mail2/composer.cpp8
-rw-r--r--noncore/unsupported/mail2/folderwidget.cpp24
-rw-r--r--noncore/unsupported/mail2/libmail/imaphandler.cpp6
-rw-r--r--noncore/unsupported/mail2/listviewplus.cpp4
-rw-r--r--noncore/unsupported/mail2/mailtable.cpp12
-rw-r--r--noncore/unsupported/mail2/mainwindow.cpp14
-rw-r--r--noncore/unsupported/mail2/searchdiag.cpp14
-rw-r--r--noncore/unsupported/mail2/viewmail.cpp4
9 files changed, 45 insertions, 45 deletions
diff --git a/noncore/unsupported/mail2/bend/bend.cpp b/noncore/unsupported/mail2/bend/bend.cpp
index e2ece2a..ab6eb45 100644
--- a/noncore/unsupported/mail2/bend/bend.cpp
+++ b/noncore/unsupported/mail2/bend/bend.cpp
@@ -41,84 +41,84 @@ BenD::BenD(QWidget *parent, const char *name, WFlags fl)
41 _intervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; 41 _intervalMs = _config->readNumEntry("CheckEvery", 5) * 60000;
42 _intervalTimer = new QTimer(); 42 _intervalTimer = new QTimer();
43 _intervalTimer->start(_intervalMs); 43 _intervalTimer->start(_intervalMs);
44 connect(_intervalTimer, SIGNAL(timeout()), SLOT(slotCheck())); 44 connect(_intervalTimer, SIGNAL(timeout()), SLOT(slotCheck()));
45 45
46 QTimer::singleShot(0, this, SLOT(slotCheck())); 46 QTimer::singleShot(0, this, SLOT(slotCheck()));
47 } 47 }
48} 48}
49 49
50void BenD::drawButton(QPainter *) { } 50void BenD::drawButton(QPainter *) { }
51void BenD::drawButtonText(QPainter *) { } 51void BenD::drawButtonText(QPainter *) { }
52 52
53void BenD::slotClicked() 53void BenD::slotClicked()
54{ 54{
55 QCopEnvelope e("QPE/System", "execute(QString)"); 55 QCopEnvelope e("QPE/System", "execute(QString)");
56 e << QString("mail"); 56 e << QString("mail");
57 57
58 ODevice *device = ODevice::inst(); 58 ODevice *device = ODevice::inst();
59 if ( !device-> ledList ( ). isEmpty ( )) { 59 if ( !device-> ledList ( ). isEmpty ( )) {
60 OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; 60 OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0];
61 61
62 device->setLedState(led, Led_Off); 62 device->setLedState(led, Led_Off);
63 } 63 }
64} 64}
65 65
66void BenD::slotCheck() 66void BenD::slotCheck()
67{ 67{
68 // Check wether the check interval has been changed. 68 // Check wether the check interval has been changed.
69 int newIntervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; 69 int newIntervalMs = _config->readNumEntry("CheckEvery", 5) * 60000;
70 if (newIntervalMs != _intervalMs) { 70 if (newIntervalMs != _intervalMs) {
71 _intervalTimer->changeInterval(newIntervalMs); 71 _intervalTimer->changeInterval(newIntervalMs);
72 _intervalMs = newIntervalMs; 72 _intervalMs = newIntervalMs;
73#ifndef QT_NO_DEBUG 73#ifndef QT_NO_DEBUG
74 qWarning("BenD: Detected interval change"); 74 qWarning("BenD: Detected interval change");
75#endif 75#endif
76 } 76 }
77 77
78 QValueList<Account> acList = ConfigFile::getAccounts(); 78 QValueList<Account> acList = ConfigFile::getAccounts();
79 QValueList<Account>::Iterator ot; 79 QValueList<Account>::Iterator ot;
80 for (ot = acList.begin(); ot != acList.end(); ot++) { 80 for (ot = acList.begin(); ot != acList.end(); ot++) {
81 if (!((*ot).imapServer().isEmpty() || 81 if (!((*ot).imapServer().isEmpty() ||
82 (*ot).imapPort().isEmpty() || 82 (*ot).imapPort().isEmpty() ||
83 (*ot).user().isEmpty() || 83 (*ot).user().isEmpty() ||
84 (*ot).pass().isEmpty())) { 84 (*ot).pass().isEmpty())) {
85 if (!((*ot).imapSsl() && 85 if (!((*ot).imapSsl() &&
86 (*ot).imapSslPort().isEmpty())) { 86 (*ot).imapSslPort().isEmpty())) {
87 IMAPHandler *handler = new IMAPHandler(*ot); 87 IMAPHandler *handler = new IMAPHandler(*ot);
88 handler->iStatus("INBOX", "RECENT"); 88 handler->iStatus("INBOX", "RECENT");
89 connect(handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPStatus(IMAPResponse &))); 89 connect(handler, SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPStatus(IMAPResponse&)));
90 } 90 }
91 } 91 }
92 } 92 }
93} 93}
94 94
95void BenD::slotIMAPStatus(IMAPResponse &response) 95void BenD::slotIMAPStatus(IMAPResponse &response)
96{ 96{
97 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPStatus(IMAPResponse &))); 97 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPStatus(IMAPResponse&)));
98 98
99 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 99 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
100 if (response.STATUS()[0].recent().toInt() > 0) { 100 if (response.STATUS()[0].recent().toInt() > 0) {
101 ODevice *device = ODevice::inst(); 101 ODevice *device = ODevice::inst();
102 if (isHidden()) show(); 102 if (isHidden()) show();
103 if (_config->readBoolEntry("BlinkLed", true)) { 103 if (_config->readBoolEntry("BlinkLed", true)) {
104 if ( !device-> ledList ( ). isEmpty ( )) { 104 if ( !device-> ledList ( ). isEmpty ( )) {
105 OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; 105 OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0];
106 106
107 device->setLedState(led, device-> ledStateList ( led ). contains ( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); 107 device->setLedState(led, device-> ledStateList ( led ). contains ( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On );
108 } 108 }
109 } 109 }
110 if (_config->readBoolEntry("PlaySound", false)) 110 if (_config->readBoolEntry("PlaySound", false))
111 device->alarmSound(); 111 device->alarmSound();
112 } else { 112 } else {
113 ODevice *device = ODevice::inst(); 113 ODevice *device = ODevice::inst();
114 if (!isHidden()) hide(); 114 if (!isHidden()) hide();
115 if ( !device-> ledList ( ). isEmpty ( )) { 115 if ( !device-> ledList ( ). isEmpty ( )) {
116 OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; 116 OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0];
117 117
118 device->setLedState(led, Led_Off); 118 device->setLedState(led, Led_Off);
119 } 119 }
120 } 120 }
121 response.imapHandler()->iLogout(); 121 response.imapHandler()->iLogout();
122 } else qWarning("BenD: WARNING: Couldn't retrieve INBOX status."); 122 } else qWarning("BenD: WARNING: Couldn't retrieve INBOX status.");
123} 123}
124 124
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp
index cb80299..da1aee9 100644
--- a/noncore/unsupported/mail2/composer.cpp
+++ b/noncore/unsupported/mail2/composer.cpp
@@ -113,187 +113,187 @@ void Composer::slotPopupHandler(int itemid)
113 if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp); 113 if (tmp != QString(0)) attachView->currentItem()->setText(1, tmp);
114 } else if (itemid == POPUP_ATTACH_REMOVE) { 114 } else if (itemid == POPUP_ATTACH_REMOVE) {
115 attachView->takeItem(attachView->currentItem()); 115 attachView->takeItem(attachView->currentItem());
116 } 116 }
117} 117}
118 118
119void Composer::slotSendMail() 119void Composer::slotSendMail()
120{ 120{
121 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { 121 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) {
122 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); 122 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok"));
123 return; 123 return;
124 } 124 }
125 125
126 SendMail smail; 126 SendMail smail;
127 smail.setFrom(from->currentText()); 127 smail.setFrom(from->currentText());
128 smail.setReplyTo(replyto->text()); 128 smail.setReplyTo(replyto->text());
129 smail.setTo(to->text()); 129 smail.setTo(to->text());
130 smail.setCc(cc->text()); 130 smail.setCc(cc->text());
131 smail.setBcc(bcc->text()); 131 smail.setBcc(bcc->text());
132 smail.setSubject(subject->text()); 132 smail.setSubject(subject->text());
133 smail.setMessage(message->text()); 133 smail.setMessage(message->text());
134 smail.setNeedsMime(attachView->childCount() == 0 ? false : true); 134 smail.setNeedsMime(attachView->childCount() == 0 ? false : true);
135 smail.setAccount(accountsLoaded[from->currentItem()]); 135 smail.setAccount(accountsLoaded[from->currentItem()]);
136 136
137 if (priority->currentItem() == POPUP_PRIO_LOW) { 137 if (priority->currentItem() == POPUP_PRIO_LOW) {
138 smail.setPriority("Low");// No i18n on purpose 138 smail.setPriority("Low");// No i18n on purpose
139 } else if (priority->currentItem() == POPUP_PRIO_NORMAL) { 139 } else if (priority->currentItem() == POPUP_PRIO_NORMAL) {
140 smail.setPriority("Normal");// No i18n on purpose 140 smail.setPriority("Normal");// No i18n on purpose
141 } else if (priority->currentItem() == POPUP_PRIO_HIGH) { 141 } else if (priority->currentItem() == POPUP_PRIO_HIGH) {
142 smail.setPriority("High");// No i18n on purpose 142 smail.setPriority("High");// No i18n on purpose
143 } 143 }
144 144
145 QValueList<Attachment> attachments; 145 QValueList<Attachment> attachments;
146 QListViewItem *item; 146 QListViewItem *item;
147 for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { 147 for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) {
148 attachments.append(((AttachViewItem *)item)->attachment()); 148 attachments.append(((AttachViewItem *)item)->attachment());
149 } 149 }
150 150
151 smail.setAttachments(attachments); 151 smail.setAttachments(attachments);
152 152
153 QString header, message; 153 QString header, message;
154 MailFactory::genMail(header, message, smail, this); 154 MailFactory::genMail(header, message, smail, this);
155 if (header.isNull() || message.isNull()) return;// Aborted. 155 if (header.isNull() || message.isNull()) return;// Aborted.
156 156
157 status->setStopEnabled(true); 157 status->setStopEnabled(true);
158 158
159 SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text()); 159 SmtpHandler *handler = new SmtpHandler(header, message, accountsLoaded[from->currentItem()], to->text());
160 connect(handler, SIGNAL(finished()), SLOT(slotSendFinished())); 160 connect(handler, SIGNAL(finished()), SLOT(slotSendFinished()));
161 connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendError(const QString &))); 161 connect(handler, SIGNAL(error(const QString&)), SLOT(slotSendError(const QString&)));
162 connect(handler, SIGNAL(status(const QString &)), status, SLOT(setStatusText(const QString &))); 162 connect(handler, SIGNAL(status(const QString&)), status, SLOT(setStatusText(const QString&)));
163} 163}
164 164
165void Composer::slotSendQueued() 165void Composer::slotSendQueued()
166{ 166{
167 int effSendCount = 0; 167 int effSendCount = 0;
168 qDebug("Sending queued messages"); 168 qDebug("Sending queued messages");
169 Config cfg( "mailqueue", Config::User ); 169 Config cfg( "mailqueue", Config::User );
170 cfg.setGroup( "Settings" ); 170 cfg.setGroup( "Settings" );
171 _sendCount = 0; 171 _sendCount = 0;
172 _sendError = 0; 172 _sendError = 0;
173 _toSend = cfg.readNumEntry( "count", 0 ); 173 _toSend = cfg.readNumEntry( "count", 0 );
174 174
175 if (_toSend == 0) close(); 175 if (_toSend == 0) close();
176 176
177 qDebug("%i messages to send", _toSend); 177 qDebug("%i messages to send", _toSend);
178 QString str; 178 QString str;
179 for (int i=1;i<=_toSend;i++) 179 for (int i=1;i<=_toSend;i++)
180 { 180 {
181 qDebug("sending message %i",i); 181 qDebug("sending message %i",i);
182 cfg.setGroup( "Mail_" + QString::number(i) ); 182 cfg.setGroup( "Mail_" + QString::number(i) );
183 SendMail smail; 183 SendMail smail;
184 str = cfg.readEntry("from"); 184 str = cfg.readEntry("from");
185 qDebug("setFrom %s",str.latin1()); 185 qDebug("setFrom %s",str.latin1());
186 smail.setFrom( str ); 186 smail.setFrom( str );
187 str = cfg.readEntry("reply"); 187 str = cfg.readEntry("reply");
188 qDebug("setReplyTo %s",str.latin1()); 188 qDebug("setReplyTo %s",str.latin1());
189 smail.setReplyTo( str ); 189 smail.setReplyTo( str );
190 QString toAdr = cfg.readEntry("to"); 190 QString toAdr = cfg.readEntry("to");
191 qDebug("to %s",toAdr.latin1()); 191 qDebug("to %s",toAdr.latin1());
192 smail.setTo( toAdr ); //to->text()); 192 smail.setTo( toAdr ); //to->text());
193 str = cfg.readEntry("cc"); 193 str = cfg.readEntry("cc");
194 qDebug("setCc %s",str.latin1()); 194 qDebug("setCc %s",str.latin1());
195 smail.setCc( str ); //cc->text()); 195 smail.setCc( str ); //cc->text());
196 smail.setBcc( cfg.readEntry("bcc") ); //bcc->text()); 196 smail.setBcc( cfg.readEntry("bcc") ); //bcc->text());
197 str = cfg.readEntry("subject"); 197 str = cfg.readEntry("subject");
198 qDebug("setSubject %s",str.latin1()); 198 qDebug("setSubject %s",str.latin1());
199 smail.setSubject( str ); //subject->text()); 199 smail.setSubject( str ); //subject->text());
200 str = cfg.readEntryCrypt("message"); 200 str = cfg.readEntryCrypt("message");
201 qDebug("setMessage %s",str.latin1()); 201 qDebug("setMessage %s",str.latin1());
202 smail.setMessage( str ); //message->text()); 202 smail.setMessage( str ); //message->text());
203 smail.setNeedsMime( cfg.readBoolEntry("mime") ); //attachView->childCount() == 0 ? false : true); 203 smail.setNeedsMime( cfg.readBoolEntry("mime") ); //attachView->childCount() == 0 ? false : true);
204 204
205 qDebug("setting account [%i]",cfg.readNumEntry("account")); 205 qDebug("setting account [%i]",cfg.readNumEntry("account"));
206 Account accnt = accountsLoaded[ cfg.readNumEntry("account") ]; 206 Account accnt = accountsLoaded[ cfg.readNumEntry("account") ];
207 smail.setAccount( accnt ); //accountsLoaded[from->currentItem()]); 207 smail.setAccount( accnt ); //accountsLoaded[from->currentItem()]);
208 208
209 209
210 int prio = cfg.readNumEntry( "priority" ); 210 int prio = cfg.readNumEntry( "priority" );
211 qDebug("setting priority %i",prio); 211 qDebug("setting priority %i",prio);
212 if (prio == POPUP_PRIO_LOW) { 212 if (prio == POPUP_PRIO_LOW) {
213 smail.setPriority("Low");// No i18n on purpose 213 smail.setPriority("Low");// No i18n on purpose
214 } else if (prio == POPUP_PRIO_NORMAL) { 214 } else if (prio == POPUP_PRIO_NORMAL) {
215 smail.setPriority("Normal");// No i18n on purpose 215 smail.setPriority("Normal");// No i18n on purpose
216 } else if (prio == POPUP_PRIO_HIGH) { 216 } else if (prio == POPUP_PRIO_HIGH) {
217 smail.setPriority("High");// No i18n on purpose 217 smail.setPriority("High");// No i18n on purpose
218 } 218 }
219 219
220 QValueList<Attachment> attachments; 220 QValueList<Attachment> attachments;
221 Attachment a; 221 Attachment a;
222 QString an; 222 QString an;
223 223
224 int ac = cfg.readNumEntry( "attachments", 0 ); 224 int ac = cfg.readNumEntry( "attachments", 0 );
225 qDebug("%i Attachments",ac); 225 qDebug("%i Attachments",ac);
226 for (int j = 0; i < ac; ac++) { 226 for (int j = 0; i < ac; ac++) {
227 an = "Attachment_" + QString::number( j ); 227 an = "Attachment_" + QString::number( j );
228 qDebug(an.latin1()); 228 qDebug(an.latin1());
229 a.setFileName(cfg.readEntry( an + "fileName" )); 229 a.setFileName(cfg.readEntry( an + "fileName" ));
230 a.setNewName(cfg.readEntry( an + "newName" )); 230 a.setNewName(cfg.readEntry( an + "newName" ));
231 a.setDescription(cfg.readEntry( an + "description" )); 231 a.setDescription(cfg.readEntry( an + "description" ));
232 a.setDocLnk( DocLnk( cfg.readEntry( an + "docLnk" )) ); 232 a.setDocLnk( DocLnk( cfg.readEntry( an + "docLnk" )) );
233 attachments.append( a ); 233 attachments.append( a );
234 } 234 }
235 235
236 smail.setAttachments(attachments); 236 smail.setAttachments(attachments);
237 237
238 qDebug("putting mail together"); 238 qDebug("putting mail together");
239 239
240 QString header, message; 240 QString header, message;
241 MailFactory::genMail(header, message, smail, this); 241 MailFactory::genMail(header, message, smail, this);
242 if (header.isNull() || message.isNull()) continue;//return;// Aborted. 242 if (header.isNull() || message.isNull()) continue;//return;// Aborted.
243 243
244 // abort->setEnabled(true); 244 // abort->setEnabled(true);
245 245
246 qDebug("Sending to %s",toAdr.latin1()); 246 qDebug("Sending to %s",toAdr.latin1());
247 SmtpHandler *handler = new SmtpHandler(header, message, accnt ,toAdr); 247 SmtpHandler *handler = new SmtpHandler(header, message, accnt ,toAdr);
248 effSendCount++; 248 effSendCount++;
249 connect(handler, SIGNAL(finished()), SLOT(slotSendQueuedFinished())); 249 connect(handler, SIGNAL(finished()), SLOT(slotSendQueuedFinished()));
250 connect(handler, SIGNAL(error(const QString &)), SLOT(slotSendQueuedError(const QString &))); 250 connect(handler, SIGNAL(error(const QString&)), SLOT(slotSendQueuedError(const QString&)));
251 connect(handler, SIGNAL(status(const QString &)), status, SLOT(setStatusText(const QString &))); 251 connect(handler, SIGNAL(status(const QString&)), status, SLOT(setStatusText(const QString&)));
252 252
253 } 253 }
254 if (effSendCount < _toSend) 254 if (effSendCount < _toSend)
255 { 255 {
256 _toSend = effSendCount; 256 _toSend = effSendCount;
257 QMessageBox::information(this, tr("Error"), tr("<p>There was a problem sending some of the queued mails.</p>"), tr("Ok")); 257 QMessageBox::information(this, tr("Error"), tr("<p>There was a problem sending some of the queued mails.</p>"), tr("Ok"));
258 } 258 }
259} 259}
260 260
261void Composer::slotQueueMail() 261void Composer::slotQueueMail()
262{ 262{
263 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) { 263 if (to->text().find(QRegExp(".*\\@.*\\..*")) == -1) {
264 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok")); 264 QMessageBox::information(this, tr("Error"), tr("<p>You have to specify a recipient.<br>(eg: foo@bar.org)</p>"), tr("Ok"));
265 return; 265 return;
266 } 266 }
267 267
268 Config cfg( "mailqueue", Config::User ); 268 Config cfg( "mailqueue", Config::User );
269 269
270 cfg.setGroup( "Settings" ); 270 cfg.setGroup( "Settings" );
271 int count = cfg.readNumEntry( "count", 0 ); 271 int count = cfg.readNumEntry( "count", 0 );
272 count++; 272 count++;
273 cfg.writeEntry( "count", count ); 273 cfg.writeEntry( "count", count );
274 qDebug("queueing mail %i",count); 274 qDebug("queueing mail %i",count);
275 275
276 cfg.setGroup( "Mail_" + QString::number( count )); 276 cfg.setGroup( "Mail_" + QString::number( count ));
277 cfg.writeEntry( "from", from->currentText() ); 277 cfg.writeEntry( "from", from->currentText() );
278 cfg.writeEntry( "reply", replyto->text()); 278 cfg.writeEntry( "reply", replyto->text());
279 cfg.writeEntry( "to", to->text()); 279 cfg.writeEntry( "to", to->text());
280 cfg.writeEntry( "cc", cc->text()); 280 cfg.writeEntry( "cc", cc->text());
281 cfg.writeEntry( "bcc", bcc->text()); 281 cfg.writeEntry( "bcc", bcc->text());
282 cfg.writeEntry( "subject", subject->text()); 282 cfg.writeEntry( "subject", subject->text());
283 cfg.writeEntryCrypt( "message", message->text()); 283 cfg.writeEntryCrypt( "message", message->text());
284 cfg.writeEntry( "mime", attachView->childCount() == 0 ); 284 cfg.writeEntry( "mime", attachView->childCount() == 0 );
285 cfg.writeEntry( "account", from->currentItem()); 285 cfg.writeEntry( "account", from->currentItem());
286 cfg.writeEntry( "priority", priority->currentItem() ); 286 cfg.writeEntry( "priority", priority->currentItem() );
287 cfg.writeEntry( "attachments", attachView->childCount() ); 287 cfg.writeEntry( "attachments", attachView->childCount() );
288 288
289 Attachment a; 289 Attachment a;
290 QListViewItem *item; 290 QListViewItem *item;
291 QString an; 291 QString an;
292 int i = 0; 292 int i = 0;
293 for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) { 293 for (item = attachView->firstChild(); item != 0; item = item->itemBelow()) {
294 a = ((AttachViewItem *)item)->attachment(); 294 a = ((AttachViewItem *)item)->attachment();
295 an = "Attachment_" + QString::number( i++ ); 295 an = "Attachment_" + QString::number( i++ );
296 cfg.writeEntry( an + "fileName", a.fileName() ); 296 cfg.writeEntry( an + "fileName", a.fileName() );
297 cfg.writeEntry( an + "newName", a.newName() ); 297 cfg.writeEntry( an + "newName", a.newName() );
298 cfg.writeEntry( an + "description", a.description() ); 298 cfg.writeEntry( an + "description", a.description() );
299 cfg.writeEntry( an + "docLnk", a.docLnk().file() ); 299 cfg.writeEntry( an + "docLnk", a.docLnk().file() );
diff --git a/noncore/unsupported/mail2/folderwidget.cpp b/noncore/unsupported/mail2/folderwidget.cpp
index d27968b..a0520b1 100644
--- a/noncore/unsupported/mail2/folderwidget.cpp
+++ b/noncore/unsupported/mail2/folderwidget.cpp
@@ -15,300 +15,300 @@
15#include "rename.h" 15#include "rename.h"
16 16
17FolderWidgetItem::FolderWidgetItem(Folder &folder, QListView *parent) 17FolderWidgetItem::FolderWidgetItem(Folder &folder, QListView *parent)
18 : QListViewItem(parent), _folder(folder) 18 : QListViewItem(parent), _folder(folder)
19{ 19{
20 setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox"))); 20 setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox")));
21 setText(0, _folder.topFolder().account().user() + " (" + _folder.topFolder().account().imapServer() + ")"); 21 setText(0, _folder.topFolder().account().user() + " (" + _folder.topFolder().account().imapServer() + ")");
22 setOpen(true); 22 setOpen(true);
23} 23}
24 24
25FolderWidgetItem::FolderWidgetItem(Folder &folder, FolderWidgetItem *parent) 25FolderWidgetItem::FolderWidgetItem(Folder &folder, FolderWidgetItem *parent)
26 : QListViewItem(parent), _folder(folder) 26 : QListViewItem(parent), _folder(folder)
27{ 27{
28 if (_folder.noCache()) { 28 if (_folder.noCache()) {
29 setText(0, QObject::tr("<Foldertree not known.>")); 29 setText(0, QObject::tr("<Foldertree not known.>"));
30 } else { 30 } else {
31 if (folder.fullName().upper() == "INBOX") { 31 if (folder.fullName().upper() == "INBOX") {
32 setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox"))); 32 setPixmap(0, QPixmap(Resource::loadPixmap("mail/inbox")));
33 setText(0, QObject::tr("Inbox")); 33 setText(0, QObject::tr("Inbox"));
34 } else { 34 } else {
35 setPixmap(0, QPixmap(Resource::loadPixmap("mail/folder"))); 35 setPixmap(0, QPixmap(Resource::loadPixmap("mail/folder")));
36 setText(0, folder.fullName()); 36 setText(0, folder.fullName());
37 } 37 }
38 setOpen(true); 38 setOpen(true);
39 } 39 }
40} 40}
41 41
42FolderWidget::FolderWidget(QWidget *parent, const char *name, WFlags fl) 42FolderWidget::FolderWidget(QWidget *parent, const char *name, WFlags fl)
43 : ListViewPlus(parent, name, fl) 43 : ListViewPlus(parent, name, fl)
44{ 44{
45 header()->hide(); 45 header()->hide();
46 addColumn(""); 46 addColumn("");
47 setSorting(-1); 47 setSorting(-1);
48 48
49 QPopupMenu *menu = new QPopupMenu(); 49 QPopupMenu *menu = new QPopupMenu();
50 menu->insertItem(tr("Rename"), MENU_RENAME); 50 menu->insertItem(tr("Rename"), MENU_RENAME);
51 menu->insertItem(tr("Delete"), MENU_DELETE); 51 menu->insertItem(tr("Delete"), MENU_DELETE);
52 menu->insertItem(tr("Move"), MENU_MOVE); 52 menu->insertItem(tr("Move"), MENU_MOVE);
53 menu->insertItem(tr("Copy"), MENU_COPY); 53 menu->insertItem(tr("Copy"), MENU_COPY);
54 menu->insertSeparator(); 54 menu->insertSeparator();
55 menu->insertItem(tr("Create folder"), MENU_CREATE); 55 menu->insertItem(tr("Create folder"), MENU_CREATE);
56 menu->insertSeparator(); 56 menu->insertSeparator();
57 menu->insertItem(tr("Rescan folder list"), MENU_RESCAN); 57 menu->insertItem(tr("Rescan folder list"), MENU_RESCAN);
58 setPopup(menu); 58 setPopup(menu);
59 59
60 getAccounts(); 60 getAccounts();
61 61
62 connect(menu, SIGNAL(activated(int)), SLOT(slotMenuActivated(int))); 62 connect(menu, SIGNAL(activated(int)), SLOT(slotMenuActivated(int)));
63 connect(this, SIGNAL(clicked(QListViewItem *)), SLOT(slotItemClicked(QListViewItem *))); 63 connect(this, SIGNAL(clicked(QListViewItem*)), SLOT(slotItemClicked(QListViewItem*)));
64} 64}
65 65
66FolderWidget::~FolderWidget() 66FolderWidget::~FolderWidget()
67{ 67{
68 // TODO: Save folder tree. 68 // TODO: Save folder tree.
69} 69}
70 70
71void FolderWidget::update() 71void FolderWidget::update()
72{ 72{
73 getAccounts(); 73 getAccounts();
74} 74}
75 75
76void FolderWidget::getAccounts() 76void FolderWidget::getAccounts()
77{ 77{
78 clear(); 78 clear();
79 79
80 QValueList<Account> accounts = ConfigFile::getAccounts(); 80 QValueList<Account> accounts = ConfigFile::getAccounts();
81 QValueList<Account>::Iterator it; 81 QValueList<Account>::Iterator it;
82 for (it = accounts.begin(); it != accounts.end(); it++) { 82 for (it = accounts.begin(); it != accounts.end(); it++) {
83 FolderWidgetItem *item = addAccount(*it); 83 FolderWidgetItem *item = addAccount(*it);
84 QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + (*it).accountName()); 84 QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + (*it).accountName());
85 if (!f.open(IO_ReadOnly)) { 85 if (!f.open(IO_ReadOnly)) {
86 Folder folder; 86 Folder folder;
87 folder.setNoCache(true); 87 folder.setNoCache(true);
88 addFolder(folder, item); 88 addFolder(folder, item);
89 } else { 89 } else {
90 QTextStream t(&f); 90 QTextStream t(&f);
91 while (!t.atEnd()) { 91 while (!t.atEnd()) {
92 QString separator = t.readLine(); 92 QString separator = t.readLine();
93 QString fullname = t.readLine(); 93 QString fullname = t.readLine();
94 Folder folder; 94 Folder folder;
95 folder.setSeparator(separator); 95 folder.setSeparator(separator);
96 folder.setFullName(fullname); 96 folder.setFullName(fullname);
97 folder.setTopFolder(item->folder().topFolder()); 97 folder.setTopFolder(item->folder().topFolder());
98 addFolder(folder, item); 98 addFolder(folder, item);
99 } 99 }
100 f.close(); 100 f.close();
101 } 101 }
102 } 102 }
103} 103}
104 104
105FolderWidgetItem *FolderWidget::addAccount(Account &account) 105FolderWidgetItem *FolderWidget::addAccount(Account &account)
106{ 106{
107 TopFolder tf; 107 TopFolder tf;
108 tf.setAccount(account); 108 tf.setAccount(account);
109 109
110 // XXX This has to change!!! The folderwidget may not create an 110 // XXX This has to change!!! The folderwidget may not create an
111 // XXX IMAPHandler!!!! Do this in IMAPHandler! 111 // XXX IMAPHandler!!!! Do this in IMAPHandler!
112 tf.setIMAPHandler(new IMAPHandler(account)); 112 tf.setIMAPHandler(new IMAPHandler(account));
113 113
114 Folder folder; 114 Folder folder;
115 folder.setTopFolder(tf); 115 folder.setTopFolder(tf);
116 116
117 connect(tf.handler(), SIGNAL(IMAPLookingUpHost()), SLOT(slotIMAPLookingUpHost())); 117 connect(tf.handler(), SIGNAL(IMAPLookingUpHost()), SLOT(slotIMAPLookingUpHost()));
118 connect(tf.handler(), SIGNAL(IMAPHostFound()), SLOT(slotIMAPHostFound())); 118 connect(tf.handler(), SIGNAL(IMAPHostFound()), SLOT(slotIMAPHostFound()));
119 connect(tf.handler(), SIGNAL(IMAPConnected()), SLOT(slotIMAPConnected())); 119 connect(tf.handler(), SIGNAL(IMAPConnected()), SLOT(slotIMAPConnected()));
120 connect(tf.handler(), SIGNAL(IMAPDisconnected()), SLOT(slotIMAPDisconnected())); 120 connect(tf.handler(), SIGNAL(IMAPDisconnected()), SLOT(slotIMAPDisconnected()));
121 connect(tf.handler(), SIGNAL(IMAPError(int)), SLOT(slotIMAPError(int))); 121 connect(tf.handler(), SIGNAL(IMAPError(int)), SLOT(slotIMAPError(int)));
122 122
123 return new FolderWidgetItem(folder, this); 123 return new FolderWidgetItem(folder, this);
124} 124}
125 125
126FolderWidgetItem *FolderWidget::addFolder(Folder &folder, FolderWidgetItem *folderWidgetItem) 126FolderWidgetItem *FolderWidget::addFolder(Folder &folder, FolderWidgetItem *folderWidgetItem)
127{ 127{
128 return new FolderWidgetItem(folder, folderWidgetItem); 128 return new FolderWidgetItem(folder, folderWidgetItem);
129} 129}
130 130
131void FolderWidget::slotMenuActivated(int itemid) 131void FolderWidget::slotMenuActivated(int itemid)
132{ 132{
133 if (currentItem() == NULL) { 133 if (currentItem() == NULL) {
134 QMessageBox::information(this, tr("Error"), tr("<p>Please select an item first.</p>"), tr("Ok")); 134 QMessageBox::information(this, tr("Error"), tr("<p>Please select an item first.</p>"), tr("Ok"));
135 return; 135 return;
136 } 136 }
137 137
138 if (itemid == MENU_RENAME) { 138 if (itemid == MENU_RENAME) {
139 if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return; 139 if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return;
140 140
141 Folder folder = ((FolderWidgetItem *)currentItem())->folder(); 141 Folder folder = ((FolderWidgetItem *)currentItem())->folder();
142 QString newName = Rename::rename(folder.fullName(), this); 142 QString newName = Rename::rename(folder.fullName(), this);
143 if (newName.isNull()) return; 143 if (newName.isNull()) return;
144 144
145 folder.topFolder().handler()->iRename(folder.fullName(), newName); 145 folder.topFolder().handler()->iRename(folder.fullName(), newName);
146 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPRename(IMAPResponse &))); 146 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPRename(IMAPResponse&)));
147 } else if (itemid == MENU_DELETE) { 147 } else if (itemid == MENU_DELETE) {
148 if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return; 148 if (((FolderWidgetItem *)currentItem())->folder().fullName().isEmpty()) return;
149 149
150 Folder folder = ((FolderWidgetItem *)currentItem())->folder(); 150 Folder folder = ((FolderWidgetItem *)currentItem())->folder();
151 151
152 int ret = QMessageBox::information(this, tr("Question"), tr("<p>Do you really want to delete <pre>%1</pre>?").arg(folder.fullName()), tr("Yes"), tr("No")); 152 int ret = QMessageBox::information(this, tr("Question"), tr("<p>Do you really want to delete <pre>%1</pre>?").arg(folder.fullName()), tr("Yes"), tr("No"));
153 if (ret == 1) return; 153 if (ret == 1) return;
154 154
155 _createFolder = folder; 155 _createFolder = folder;
156 156
157 folder.topFolder().handler()->iDelete(folder.fullName()); 157 folder.topFolder().handler()->iDelete(folder.fullName());
158 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPDelete(IMAPResponse &))); 158 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPDelete(IMAPResponse&)));
159 } else if (itemid == MENU_MOVE) { 159 } else if (itemid == MENU_MOVE) {
160 160
161 } else if (itemid == MENU_COPY) { 161 } else if (itemid == MENU_COPY) {
162 162
163 } else if (itemid == MENU_CREATE) { 163 } else if (itemid == MENU_CREATE) {
164 Folder folder = (((FolderWidgetItem *)currentItem())->folder()); 164 Folder folder = (((FolderWidgetItem *)currentItem())->folder());
165 _createFolder = folder; 165 _createFolder = folder;
166 166
167 QString folderName = Rename::getText(tr("Foldername"), tr("<p>Please enter the name of the new folder.</p>"), this); 167 QString folderName = Rename::getText(tr("Foldername"), tr("<p>Please enter the name of the new folder.</p>"), this);
168 if (folderName.isNull()) return; 168 if (folderName.isNull()) return;
169 169
170 folder.topFolder().handler()->iCreate(folder.fullName() + folder.separator() + folderName); 170 folder.topFolder().handler()->iCreate(folder.fullName() + folder.separator() + folderName);
171 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPCreate(IMAPResponse &))); 171 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPCreate(IMAPResponse&)));
172 } else if (itemid == MENU_RESCAN) { 172 } else if (itemid == MENU_RESCAN) {
173 Folder folder = (((FolderWidgetItem *)currentItem())->folder()); 173 Folder folder = (((FolderWidgetItem *)currentItem())->folder());
174 _rescanAccount = folder.topFolder().account(); 174 _rescanAccount = folder.topFolder().account();
175 175
176 folder.topFolder().handler()->iList("", "*"); 176 folder.topFolder().handler()->iList("", "*");
177 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); 177 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPList(IMAPResponse&)));
178 } 178 }
179} 179}
180 180
181void FolderWidget::slotItemClicked(QListViewItem *item) 181void FolderWidget::slotItemClicked(QListViewItem *item)
182{ 182{
183 if (item == NULL) return; 183 if (item == NULL) return;
184 Folder folder = ((FolderWidgetItem *)item)->folder(); 184 Folder folder = ((FolderWidgetItem *)item)->folder();
185 if (folder.fullName().isEmpty()) return; 185 if (folder.fullName().isEmpty()) return;
186 186
187 emit folderSelected(folder); 187 emit folderSelected(folder);
188} 188}
189 189
190void FolderWidget::slotIMAPLookingUpHost() 190void FolderWidget::slotIMAPLookingUpHost()
191{ 191{
192 emit status(tr("Looking up host...")); 192 emit status(tr("Looking up host..."));
193 emit connecting(); 193 emit connecting();
194} 194}
195 195
196void FolderWidget::slotIMAPHostFound() 196void FolderWidget::slotIMAPHostFound()
197{ 197{
198 emit status(tr("Host found.")); 198 emit status(tr("Host found."));
199} 199}
200 200
201void FolderWidget::slotIMAPConnected() 201void FolderWidget::slotIMAPConnected()
202{ 202{
203 emit status(tr("Connected to host.")); 203 emit status(tr("Connected to host."));
204 emit connected(); 204 emit connected();
205} 205}
206 206
207void FolderWidget::slotIMAPError(int error) 207void FolderWidget::slotIMAPError(int error)
208{ 208{
209 if (error == IMAPBase::IMAPErrConnectionRefused) { 209 if (error == IMAPBase::IMAPErrConnectionRefused) {
210 QMessageBox::warning(this, tr("Error"), tr("<p>The IMAP connection was refused.</p>"), tr("Ok")); 210 QMessageBox::warning(this, tr("Error"), tr("<p>The IMAP connection was refused.</p>"), tr("Ok"));
211 } else if (error == IMAPBase::IMAPErrHostNotFound) { 211 } else if (error == IMAPBase::IMAPErrHostNotFound) {
212 QMessageBox::warning(this, tr("Error"), tr("<p>The host was not found.</p>"), tr("Ok")); 212 QMessageBox::warning(this, tr("Error"), tr("<p>The host was not found.</p>"), tr("Ok"));
213 } else if (error == IMAPBase::IMAPErrSocketRead) { 213 } else if (error == IMAPBase::IMAPErrSocketRead) {
214 QMessageBox::warning(this, tr("Error"), tr("<p>There was an error while reading from the socket.</p>"), tr("Ok")); 214 QMessageBox::warning(this, tr("Error"), tr("<p>There was an error while reading from the socket.</p>"), tr("Ok"));
215 } else if (error == IMAPBase::IMAPErrLoginFailed) { 215 } else if (error == IMAPBase::IMAPErrLoginFailed) {
216 QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Check your password/username.</p>"), tr("Ok")); 216 QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Check your password/username.</p>"), tr("Ok"));
217 } else { 217 } else {
218 QMessageBox::warning(this, tr("Error"), tr("<p>An unknown error was encountered.</p>"), tr("Ok")); 218 QMessageBox::warning(this, tr("Error"), tr("<p>An unknown error was encountered.</p>"), tr("Ok"));
219 } 219 }
220} 220}
221 221
222void FolderWidget::slotIMAPDisconnected() 222void FolderWidget::slotIMAPDisconnected()
223{ 223{
224 emit status(tr("Disconnected.")); 224 emit status(tr("Disconnected."));
225 emit disconnected(); 225 emit disconnected();
226} 226}
227 227
228void FolderWidget::slotIMAPLogin(IMAPResponse &response) 228void FolderWidget::slotIMAPLogin(IMAPResponse &response)
229{ 229{
230 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPLogin(IMAPResponse &))); 230 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPLogin(IMAPResponse&)));
231 231
232 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 232 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
233 emit status(tr("Login successful!")); 233 emit status(tr("Login successful!"));
234 } else { 234 } else {
235 QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Go away.</p>"), tr("Ok")); 235 QMessageBox::warning(this, tr("Error"), tr("<p>Login failed. Go away.</p>"), tr("Ok"));
236 } 236 }
237} 237}
238 238
239void FolderWidget::slotIMAPRename(IMAPResponse &response) 239void FolderWidget::slotIMAPRename(IMAPResponse &response)
240{ 240{
241 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPRename(IMAPResponse &))); 241 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPRename(IMAPResponse&)));
242 242
243 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 243 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
244 emit status(tr("Renaming successful!")); 244 emit status(tr("Renaming successful!"));
245 } else { 245 } else {
246 QMessageBox::warning(this, tr("Error"), tr("<p>Renaming failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); 246 QMessageBox::warning(this, tr("Error"), tr("<p>Renaming failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok"));
247 } 247 }
248} 248}
249 249
250void FolderWidget::slotIMAPDelete(IMAPResponse &response) 250void FolderWidget::slotIMAPDelete(IMAPResponse &response)
251{ 251{
252 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPDelete(IMAPResponse &))); 252 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPDelete(IMAPResponse&)));
253 253
254 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 254 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
255 emit status(tr("Deletion successful!")); 255 emit status(tr("Deletion successful!"));
256 256
257 _rescanAccount = _createFolder.topFolder().account(); 257 _rescanAccount = _createFolder.topFolder().account();
258 258
259 _createFolder.topFolder().handler()->iList(".", "*"); 259 _createFolder.topFolder().handler()->iList(".", "*");
260 connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); 260 connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPList(IMAPResponse&)));
261 } else { 261 } else {
262 QMessageBox::warning(this, tr("Error"), tr("<p>Delete failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); 262 QMessageBox::warning(this, tr("Error"), tr("<p>Delete failed. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok"));
263 } 263 }
264} 264}
265 265
266void FolderWidget::slotIMAPCreate(IMAPResponse &response) 266void FolderWidget::slotIMAPCreate(IMAPResponse &response)
267{ 267{
268 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPCreate(IMAPResponse &))); 268 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPCreate(IMAPResponse&)));
269 269
270 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 270 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
271 emit status(tr("Folder created. Rescanning...")); 271 emit status(tr("Folder created. Rescanning..."));
272 272
273 _rescanAccount = _createFolder.topFolder().account(); 273 _rescanAccount = _createFolder.topFolder().account();
274 274
275 _createFolder.topFolder().handler()->iList(".", "*"); 275 _createFolder.topFolder().handler()->iList(".", "*");
276 connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPList(IMAPResponse &))); 276 connect(_createFolder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPList(IMAPResponse&)));
277 } else { 277 } else {
278 QMessageBox::warning(this, tr("Error"), tr("<p>The folder could not be created. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); 278 QMessageBox::warning(this, tr("Error"), tr("<p>The folder could not be created. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok"));
279 } 279 }
280} 280}
281 281
282void FolderWidget::slotIMAPList(IMAPResponse &response) 282void FolderWidget::slotIMAPList(IMAPResponse &response)
283{ 283{
284 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPList(IMAPResponse &))); 284 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPList(IMAPResponse&)));
285 285
286 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 286 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
287 QDir d((QString) getenv("HOME") + "/Applications/mail/foldercache"); 287 QDir d((QString) getenv("HOME") + "/Applications/mail/foldercache");
288 if (!d.exists()) { 288 if (!d.exists()) {
289 system("mkdir -p $HOME/Applications/mail/foldercache"); 289 system("mkdir -p $HOME/Applications/mail/foldercache");
290 qWarning("Created $HOME/Applications/mail/foldercache."); 290 qWarning("Created $HOME/Applications/mail/foldercache.");
291 } 291 }
292 QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + _rescanAccount.accountName()); 292 QFile f((QString) getenv("HOME") + "/Applications/mail/foldercache/foldercache-" + _rescanAccount.accountName());
293 if (!f.open(IO_WriteOnly)) { 293 if (!f.open(IO_WriteOnly)) {
294 QMessageBox::critical(this, tr("Error"), tr("<p>Couldn't open folder cache file for writing!</p>"), tr("Ok")); 294 QMessageBox::critical(this, tr("Error"), tr("<p>Couldn't open folder cache file for writing!</p>"), tr("Ok"));
295 return; 295 return;
296 } 296 }
297 QTextStream t(&f); 297 QTextStream t(&f);
298 298
299 QValueList<IMAPResponseLIST>::Iterator it; 299 QValueList<IMAPResponseLIST>::Iterator it;
300 QValueList<IMAPResponseLIST> lists = response.LIST(); 300 QValueList<IMAPResponseLIST> lists = response.LIST();
301 for (it = lists.begin(); it != lists.end(); it++) { 301 for (it = lists.begin(); it != lists.end(); it++) {
302 t << (*it).folderSeparator() << "\n"; 302 t << (*it).folderSeparator() << "\n";
303 t << (*it).folder() << "\n"; 303 t << (*it).folder() << "\n";
304 } 304 }
305 305
306 f.close(); 306 f.close();
307 307
308 emit status(tr("Got folder list.")); 308 emit status(tr("Got folder list."));
309 getAccounts(); 309 getAccounts();
310 } else { 310 } else {
311 QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't retrieve the folder list. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); 311 QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't retrieve the folder list. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok"));
312 } 312 }
313} 313}
314 314
diff --git a/noncore/unsupported/mail2/libmail/imaphandler.cpp b/noncore/unsupported/mail2/libmail/imaphandler.cpp
index dc97b28..8da0acd 100644
--- a/noncore/unsupported/mail2/libmail/imaphandler.cpp
+++ b/noncore/unsupported/mail2/libmail/imaphandler.cpp
@@ -1,62 +1,62 @@
1#include "imapresponse.h" 1#include "imapresponse.h"
2#include "imaphandler.h" 2#include "imaphandler.h"
3#include "imapbase.h" 3#include "imapbase.h"
4 4
5IMAPHandler::IMAPHandler(const Account &account) 5IMAPHandler::IMAPHandler(const Account &account)
6 : QObject(), _account(account) 6 : QObject(), _account(account)
7{ 7{
8 _ready = false; 8 _ready = false;
9 _loggingin = false; 9 _loggingin = false;
10 _loggedin = false; 10 _loggedin = false;
11 _tag = 0; 11 _tag = 0;
12 _ibase = new IMAPBase(account); 12 _ibase = new IMAPBase(account);
13 13
14 connect(_ibase, SIGNAL(dataReceived(const QString &)), SLOT(slotDataReceived(const QString &))); 14 connect(_ibase, SIGNAL(dataReceived(const QString&)), SLOT(slotDataReceived(const QString&)));
15 connect(_ibase, SIGNAL(lookingUpHost()), SLOT(slotLookingUpHost())); 15 connect(_ibase, SIGNAL(lookingUpHost()), SLOT(slotLookingUpHost()));
16 connect(_ibase, SIGNAL(hostFound()), SLOT(slotHostFound())); 16 connect(_ibase, SIGNAL(hostFound()), SLOT(slotHostFound()));
17 connect(_ibase, SIGNAL(connected()), SLOT(slotConnected())); 17 connect(_ibase, SIGNAL(connected()), SLOT(slotConnected()));
18 connect(_ibase, SIGNAL(disconnected()), SLOT(slotDisconnected())); 18 connect(_ibase, SIGNAL(disconnected()), SLOT(slotDisconnected()));
19 connect(_ibase, SIGNAL(error(int)), SLOT(slotError(int))); 19 connect(_ibase, SIGNAL(error(int)), SLOT(slotError(int)));
20} 20}
21 21
22void IMAPHandler::doLogin() 22void IMAPHandler::doLogin()
23{ 23{
24 if (_loggedin) return; 24 if (_loggedin) return;
25 if (_loggingin) return; 25 if (_loggingin) return;
26 26
27 _loggingin = true; 27 _loggingin = true;
28 iLogin(_account.user(), _account.pass()); 28 iLogin(_account.user(), _account.pass());
29} 29}
30 30
31QString IMAPHandler::iCapability() 31QString IMAPHandler::iCapability()
32{ 32{
33 _ibase->sendCommand(QString("%1 CAPABILITY\r\n") 33 _ibase->sendCommand(QString("%1 CAPABILITY\r\n")
34 .arg(tag())); 34 .arg(tag()));
35 return tag(false); 35 return tag(false);
36} 36}
37 37
38QString IMAPHandler::iNoop() 38QString IMAPHandler::iNoop()
39{ 39{
40 _ibase->sendCommand(QString("%1 NOOP\r\n") 40 _ibase->sendCommand(QString("%1 NOOP\r\n")
41 .arg(tag())); 41 .arg(tag()));
42 return tag(false); 42 return tag(false);
43} 43}
44 44
45QString IMAPHandler::iLogout() 45QString IMAPHandler::iLogout()
46{ 46{
47 _ibase->sendCommand(QString("%1 LOGOUT\r\n") 47 _ibase->sendCommand(QString("%1 LOGOUT\r\n")
48 .arg(tag())); 48 .arg(tag()));
49 return tag(false); 49 return tag(false);
50} 50}
51 51
52QString IMAPHandler::iAuthenticate(const QString &mechanism) 52QString IMAPHandler::iAuthenticate(const QString &mechanism)
53{ 53{
54 _ibase->sendCommand(QString("%1 AUTHENTICATE \"%2\"\r\n") 54 _ibase->sendCommand(QString("%1 AUTHENTICATE \"%2\"\r\n")
55 .arg(tag()) 55 .arg(tag())
56 .arg(escape(mechanism))); 56 .arg(escape(mechanism)));
57 return tag(false); 57 return tag(false);
58} 58}
59 59
60QString IMAPHandler::iLogin(const QString &user, const QString &pass) 60QString IMAPHandler::iLogin(const QString &user, const QString &pass)
61{ 61{
62 _ibase->sendCommand(QString("%1 LOGIN \"%2\" \"%3\"\r\n") 62 _ibase->sendCommand(QString("%1 LOGIN \"%2\" \"%3\"\r\n")
@@ -254,93 +254,93 @@ QString IMAPHandler::iCopy(const QString &message, const QString &mailbox)
254 .arg(escape(mailbox))); 254 .arg(escape(mailbox)));
255 return tag(false); 255 return tag(false);
256} 256}
257 257
258QString IMAPHandler::iUid(const QString &command, const QString &arguments) 258QString IMAPHandler::iUid(const QString &command, const QString &arguments)
259{ 259{
260 doLogin(); 260 doLogin();
261 261
262 _ibase->sendCommand(QString("%1 UID %2 %3\r\n") 262 _ibase->sendCommand(QString("%1 UID %2 %3\r\n")
263 .arg(tag()) 263 .arg(tag())
264 .arg(command) 264 .arg(command)
265 .arg(arguments)); 265 .arg(arguments));
266 return tag(false); 266 return tag(false);
267} 267}
268 268
269QString IMAPHandler::iX(const QString &commandAtom, const QString &arguments) 269QString IMAPHandler::iX(const QString &commandAtom, const QString &arguments)
270{ 270{
271 doLogin(); 271 doLogin();
272 272
273 _ibase->sendCommand(QString("%1 X%2 %3\r\n") 273 _ibase->sendCommand(QString("%1 X%2 %3\r\n")
274 .arg(tag()) 274 .arg(tag())
275 .arg(commandAtom) 275 .arg(commandAtom)
276 .arg(arguments)); 276 .arg(arguments));
277 return tag(false); 277 return tag(false);
278} 278}
279 279
280QString IMAPHandler::escape(const QString &in) 280QString IMAPHandler::escape(const QString &in)
281{ 281{
282 QString in_ = in; 282 QString in_ = in;
283 return in_.replace(QRegExp("\""), "\\\""); 283 return in_.replace(QRegExp("\""), "\\\"");
284} 284}
285 285
286QString IMAPHandler::tag(bool count) 286QString IMAPHandler::tag(bool count)
287{ 287{
288 return QString("a%1").arg(count ? _tag++ : _tag); 288 return QString("a%1").arg(count ? _tag++ : _tag);
289} 289}
290 290
291void IMAPHandler::slotDataReceived(const QString &data) 291void IMAPHandler::slotDataReceived(const QString &data)
292{ 292{
293 if (!_ready) { 293 if (!_ready) {
294 // The first data is always the greeting string. 294 // The first data is always the greeting string.
295 // We can ignore it. 295 // We can ignore it.
296 _ready = true; 296 _ready = true;
297 return; 297 return;
298 } 298 }
299 299
300 300
301 IMAPResponseParser parser; 301 IMAPResponseParser parser;
302 //connect ( &parser, SIGNAL( needMoreData ( QString & )), _ibase, SLOT( tryRead ( QString & ))); 302 //connect ( &parser, SIGNAL( needMoreData(QString&)), _ibase, SLOT( tryRead(QString&)));
303 parser. parse ( data ); 303 parser. parse ( data );
304 IMAPResponse response = parser.response(); 304 IMAPResponse response = parser.response();
305 //disconnect ( &parser, SIGNAL( needMoreData ( QString & )), _ibase, SLOT( tryRead ( QString & ))); 305 //disconnect ( &parser, SIGNAL( needMoreData(QString&)), _ibase, SLOT( tryRead(QString&)));
306 response.setImapHandler(this); 306 response.setImapHandler(this);
307 307
308 if (!_loggingin) { qDebug("Emitting gotResponse!\n" ); emit gotResponse(response); } 308 if (!_loggingin) { qDebug("Emitting gotResponse!\n" ); emit gotResponse(response); }
309 else { 309 else {
310 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 310 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
311 _loggingin = false; 311 _loggingin = false;
312 _loggedin = true; 312 _loggedin = true;
313 qWarning("OK. Logged in. Leaving loggingin state."); 313 qWarning("OK. Logged in. Leaving loggingin state.");
314 } else { 314 } else {
315 _loggingin = false; 315 _loggingin = false;
316 emit IMAPError(IMAPBase::IMAPErrLoginFailed); 316 emit IMAPError(IMAPBase::IMAPErrLoginFailed);
317 } 317 }
318 } 318 }
319} 319}
320 320
321void IMAPHandler::slotLookingUpHost() 321void IMAPHandler::slotLookingUpHost()
322{ 322{
323 emit IMAPLookingUpHost(); 323 emit IMAPLookingUpHost();
324} 324}
325 325
326void IMAPHandler::slotHostFound() 326void IMAPHandler::slotHostFound()
327{ 327{
328 emit IMAPHostFound(); 328 emit IMAPHostFound();
329} 329}
330 330
331void IMAPHandler::slotConnected() 331void IMAPHandler::slotConnected()
332{ 332{
333 emit IMAPConnected(); 333 emit IMAPConnected();
334} 334}
335 335
336void IMAPHandler::slotDisconnected() 336void IMAPHandler::slotDisconnected()
337{ 337{
338 _loggedin = false; 338 _loggedin = false;
339 emit IMAPDisconnected(); 339 emit IMAPDisconnected();
340} 340}
341 341
342void IMAPHandler::slotError(int err) 342void IMAPHandler::slotError(int err)
343{ 343{
344 emit IMAPError(err); 344 emit IMAPError(err);
345} 345}
346 346
diff --git a/noncore/unsupported/mail2/listviewplus.cpp b/noncore/unsupported/mail2/listviewplus.cpp
index ce5f35f..722b347 100644
--- a/noncore/unsupported/mail2/listviewplus.cpp
+++ b/noncore/unsupported/mail2/listviewplus.cpp
@@ -1,54 +1,54 @@
1#include <qpopupmenu.h> 1#include <qpopupmenu.h>
2#include <qtimer.h> 2#include <qtimer.h>
3 3
4#include "listviewplus.h" 4#include "listviewplus.h"
5 5
6ListViewPlus::ListViewPlus(QWidget *parent, const char *name, WFlags fl) 6ListViewPlus::ListViewPlus(QWidget *parent, const char *name, WFlags fl)
7 : QListView(parent, name, fl) 7 : QListView(parent, name, fl)
8{ 8{
9 9
10} 10}
11 11
12void ListViewPlus::keyPressEvent(QKeyEvent *event) 12void ListViewPlus::keyPressEvent(QKeyEvent *event)
13{ 13{
14 switch(event->key()) { 14 switch(event->key()) {
15 case Qt::Key_Space: // FALLTHROUGH 15 case Qt::Key_Space: // FALLTHROUGH
16 case Qt::Key_Enter: 16 case Qt::Key_Enter:
17 if (currentItem() != 0) 17 if (currentItem() != 0)
18 emit clicked(currentItem()); 18 emit clicked(currentItem());
19 break; 19 break;
20 default: break; 20 default: break;
21 } 21 }
22 22
23 QListView::keyPressEvent(event); 23 QListView::keyPressEvent(event);
24} 24}
25 25
26void ListViewPlus::setPopup(QPopupMenu *popup, int delay) 26void ListViewPlus::setPopup(QPopupMenu *popup, int delay)
27{ 27{
28 _popup = popup; 28 _popup = popup;
29 _delay = delay; 29 _delay = delay;
30 30
31 connect(this, SIGNAL(pressed(QListViewItem *, const QPoint &, int)), SLOT(_initPopup(QListViewItem *, const QPoint &, int))); 31 connect(this, SIGNAL(pressed(QListViewItem*,const QPoint&,int)), SLOT(_initPopup(QListViewItem*,const QPoint&,int)));
32 connect(this, SIGNAL(clicked(QListViewItem *, const QPoint &, int)), SLOT(_cancelPopup(QListViewItem *, const QPoint &, int))); 32 connect(this, SIGNAL(clicked(QListViewItem*,const QPoint&,int)), SLOT(_cancelPopup(QListViewItem*,const QPoint&,int)));
33} 33}
34 34
35void ListViewPlus::_initPopup(QListViewItem *, const QPoint &point, int) 35void ListViewPlus::_initPopup(QListViewItem *, const QPoint &point, int)
36{ 36{
37 _point = point; 37 _point = point;
38 38
39 _timer = new QTimer(); 39 _timer = new QTimer();
40 _timer->start(_delay, true); 40 _timer->start(_delay, true);
41 41
42 connect(_timer, SIGNAL(timeout()), this, SLOT(_showPopup())); 42 connect(_timer, SIGNAL(timeout()), this, SLOT(_showPopup()));
43} 43}
44 44
45void ListViewPlus::_cancelPopup(QListViewItem *, const QPoint &, int) 45void ListViewPlus::_cancelPopup(QListViewItem *, const QPoint &, int)
46{ 46{
47 delete _timer; 47 delete _timer;
48} 48}
49 49
50void ListViewPlus::_showPopup() 50void ListViewPlus::_showPopup()
51{ 51{
52 _popup->popup(_point); 52 _popup->popup(_point);
53} 53}
54 54
diff --git a/noncore/unsupported/mail2/mailtable.cpp b/noncore/unsupported/mail2/mailtable.cpp
index fd179f0..56feab0 100644
--- a/noncore/unsupported/mail2/mailtable.cpp
+++ b/noncore/unsupported/mail2/mailtable.cpp
@@ -29,143 +29,143 @@ MailTableItem::MailTableItem(QListView *parent, IMAPResponseFETCH fetch)
29 29
30void MailTableItem::paintCell(QPainter *painter, const QColorGroup &cg, int col, int width, int align) 30void MailTableItem::paintCell(QPainter *painter, const QColorGroup &cg, int col, int width, int align)
31{ 31{
32 QColor color = cg.color(QColorGroup::Text); 32 QColor color = cg.color(QColorGroup::Text);
33 QFont font = painter->font(); 33 QFont font = painter->font();
34 if (_draft) { 34 if (_draft) {
35 color = QColor("#707070"); 35 color = QColor("#707070");
36 } else if (_new) { 36 } else if (_new) {
37 color = QColor("#ff0000"); 37 color = QColor("#ff0000");
38 font.setBold(true); 38 font.setBold(true);
39 } else if (_unseen) { 39 } else if (_unseen) {
40 font.setBold(true); 40 font.setBold(true);
41 } 41 }
42 42
43 painter->setFont(font); 43 painter->setFont(font);
44 QColorGroup cg_(cg); 44 QColorGroup cg_(cg);
45 cg_.setColor(QColorGroup::Text, color); 45 cg_.setColor(QColorGroup::Text, color);
46 46
47 QListViewItem::paintCell(painter, cg_, col, width, align); 47 QListViewItem::paintCell(painter, cg_, col, width, align);
48} 48}
49 49
50MailTable::MailTable(QWidget *parent, const char *name, WFlags fl) 50MailTable::MailTable(QWidget *parent, const char *name, WFlags fl)
51 : ListViewPlus(parent, name, fl), _parent(parent) 51 : ListViewPlus(parent, name, fl), _parent(parent)
52{ 52{
53 _stopped = false; 53 _stopped = false;
54 54
55 setSorting(-1); 55 setSorting(-1);
56 56
57 setAllColumnsShowFocus(true); 57 setAllColumnsShowFocus(true);
58 addColumn(tr("From"), 100); 58 addColumn(tr("From"), 100);
59 addColumn(tr("Subject"), 100); 59 addColumn(tr("Subject"), 100);
60 addColumn(tr("Date"), 100); 60 addColumn(tr("Date"), 100);
61 61
62 QPopupMenu *menu = new QPopupMenu(this); 62 QPopupMenu *menu = new QPopupMenu(this);
63 menu->insertItem(tr("Copy"), MENU_COPY); 63 menu->insertItem(tr("Copy"), MENU_COPY);
64 64
65 QPopupMenu *markMenu = new QPopupMenu(this); 65 QPopupMenu *markMenu = new QPopupMenu(this);
66 markMenu->insertItem(tr("Seen"), MENU_MARK_READ); 66 markMenu->insertItem(tr("Seen"), MENU_MARK_READ);
67 markMenu->insertItem(tr("Unseen"), MENU_MARK_UNREAD); 67 markMenu->insertItem(tr("Unseen"), MENU_MARK_UNREAD);
68 markMenu->insertSeparator(); 68 markMenu->insertSeparator();
69 markMenu->insertItem(tr("Marked"), MENU_MARK_MARKED); 69 markMenu->insertItem(tr("Marked"), MENU_MARK_MARKED);
70 markMenu->insertItem(tr("Unmarked"), MENU_MARK_UNMARKED); 70 markMenu->insertItem(tr("Unmarked"), MENU_MARK_UNMARKED);
71 71
72 menu->insertItem(tr("Mark as..."), markMenu, MENU_MARK); 72 menu->insertItem(tr("Mark as..."), markMenu, MENU_MARK);
73 menu->insertSeparator(); 73 menu->insertSeparator();
74 menu->insertItem(tr("Delete Mail"), MENU_DELETE); 74 menu->insertItem(tr("Delete Mail"), MENU_DELETE);
75 setPopup(menu); 75 setPopup(menu);
76 76
77 connect(this, SIGNAL(clicked(QListViewItem *)), SLOT(itemClicked(QListViewItem *))); 77 connect(this, SIGNAL(clicked(QListViewItem*)), SLOT(itemClicked(QListViewItem*)));
78} 78}
79 79
80void MailTable::setFolder(Folder folder) 80void MailTable::setFolder(Folder folder)
81{ 81{
82 folder.topFolder().handler()->iSelect(folder.fullName()); 82 folder.topFolder().handler()->iSelect(folder.fullName());
83 _handler = folder.topFolder().handler(); 83 _handler = folder.topFolder().handler();
84 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPSelect(IMAPResponse &))); 84 connect(folder.topFolder().handler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPSelect(IMAPResponse&)));
85} 85}
86 86
87void MailTable::setHeaders(QValueList<IMAPResponseFETCH> response) 87void MailTable::setHeaders(QValueList<IMAPResponseFETCH> response)
88{ 88{
89 clear(); 89 clear();
90 QValueList<IMAPResponseFETCH>::Iterator it; 90 QValueList<IMAPResponseFETCH>::Iterator it;
91 for (it = response.begin(); it != response.end(); it++) { 91 for (it = response.begin(); it != response.end(); it++) {
92 (void) new MailTableItem(this, *it); 92 (void) new MailTableItem(this, *it);
93 } 93 }
94} 94}
95 95
96void MailTable::slotIMAPSelect(IMAPResponse &response) 96void MailTable::slotIMAPSelect(IMAPResponse &response)
97{ 97{
98 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPSelect(IMAPResponse &))); 98 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPSelect(IMAPResponse&)));
99 99
100 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 100 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
101 clear(); 101 clear();
102 QString mails = response.EXISTS()[0].mails(); 102 QString mails = response.EXISTS()[0].mails();
103 if (mails.toInt() == 0) { 103 if (mails.toInt() == 0) {
104 emit status(tr("Mailbox contained no mails.")); 104 emit status(tr("Mailbox contained no mails."));
105 return; 105 return;
106 } 106 }
107 int a = mails.toInt() / 5; 107 int a = mails.toInt() / 5;
108 int b = mails.toInt() % 5; 108 int b = mails.toInt() % 5;
109 109
110 _downloadSteps = a; 110 _downloadSteps = a;
111 if (b > 0) _downloadSteps++; 111 if (b > 0) _downloadSteps++;
112 _lastStep = b; 112 _lastStep = b;
113 _currentProgress = 0; 113 _currentProgress = 0;
114 114
115 emit totalSteps(_downloadSteps); 115 emit totalSteps(_downloadSteps);
116 emit progress(_currentProgress); 116 emit progress(_currentProgress);
117 emit stopEnabled(true); 117 emit stopEnabled(true);
118 118
119 response.imapHandler()->iFetch(QString("1:%1").arg((a == 0) ? b : 5), "ENVELOPE FLAGS UID"); 119 response.imapHandler()->iFetch(QString("1:%1").arg((a == 0) ? b : 5), "ENVELOPE FLAGS UID");
120 emit status(tr("Getting mail headers...")); 120 emit status(tr("Getting mail headers..."));
121 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &))); 121 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPFetch(IMAPResponse&)));
122 } else { 122 } else {
123 QMessageBox::warning(this, tr("Error"), tr("<p>An error occoured during the selection of the mailbox. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok")); 123 QMessageBox::warning(this, tr("Error"), tr("<p>An error occoured during the selection of the mailbox. (Server said: %1)</p>").arg(response.statusResponse().comment()), tr("Ok"));
124 } 124 }
125} 125}
126 126
127void MailTable::slotIMAPFetch(IMAPResponse &response) 127void MailTable::slotIMAPFetch(IMAPResponse &response)
128{ 128{
129 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPFetch(IMAPResponse &))); 129 disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPFetch(IMAPResponse&)));
130 130
131 if (response.statusResponse().status() == IMAPResponseEnums::OK) { 131 if (response.statusResponse().status() == IMAPResponseEnums::OK) {
132 QValueList<IMAPResponseFETCH>::Iterator it; 132 QValueList<IMAPResponseFETCH>::Iterator it;
133 QValueList<IMAPResponseFETCH> fetch = response.FETCH(); 133 QValueList<IMAPResponseFETCH> fetch = response.FETCH();
134 for (it = fetch.begin(); it != fetch.end(); it++) { 134 for (it = fetch.begin(); it != fetch.end(); it++) {
135 (void) new MailTableItem(this, *it); 135 (void) new MailTableItem(this, *it);
136 } 136 }
137 emit progress(++_currentProgress); 137 emit progress(++_currentProgress);
138 138
139 if (_currentProgress != _downloadSteps) { 139 if (_currentProgress != _downloadSteps) {
140 if (_stopped) { 140 if (_stopped) {
141 _currentProgress = 0; 141 _currentProgress = 0;
142 _downloadSteps = 0; 142 _downloadSteps = 0;
143 _lastStep = 0; 143 _lastStep = 0;
144 _stopped = false; 144 _stopped = false;
145 emit status(tr("Stopped")); 145 emit status(tr("Stopped"));
146 emit resetProgress(); 146 emit resetProgress();
147 emit stopEnabled(false); 147 emit stopEnabled(false);
148 } else { 148 } else {
149 response.imapHandler()->iFetch(QString("%1:%2").arg(_currentProgress * 5 + 1).arg((_currentProgress + 1 == _downloadSteps) ? _currentProgress * 5 + _lastStep : _currentProgress * 5 + 5), "ENVELOPE FLAGS UID"); 149 response.imapHandler()->iFetch(QString("%1:%2").arg(_currentProgress * 5 + 1).arg((_currentProgress + 1 == _downloadSteps) ? _currentProgress * 5 + _lastStep : _currentProgress * 5 + 5), "ENVELOPE FLAGS UID");
150 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPFetch(IMAPResponse &))); 150 connect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPFetch(IMAPResponse&)));
151 } 151 }
152 } else { 152 } else {
153 _currentProgress = 0; 153 _currentProgress = 0;
154 _downloadSteps = 0; 154 _downloadSteps = 0;
155 _lastStep = 0; 155 _lastStep = 0;
156 emit status(tr("Got all mail headers.")); 156 emit status(tr("Got all mail headers."));
157 emit resetProgress(); 157 emit resetProgress();
158 emit stopEnabled(false); 158 emit stopEnabled(false);
159 } 159 }
160 } else { 160 } else {
161 emit status(tr("<font color=#ff0000>Couldn't fetch mail.")); 161 emit status(tr("<font color=#ff0000>Couldn't fetch mail."));
162 } 162 }
163} 163}
164 164
165void MailTable::itemClicked(QListViewItem *item) 165void MailTable::itemClicked(QListViewItem *item)
166{ 166{
167 if (item == NULL) return; 167 if (item == NULL) return;
168 emit mailClicked(((MailTableItem *)item)->fetch(), _handler); 168 emit mailClicked(((MailTableItem *)item)->fetch(), _handler);
169} 169}
170 170
171 171
diff --git a/noncore/unsupported/mail2/mainwindow.cpp b/noncore/unsupported/mail2/mainwindow.cpp
index 0d09ec8..ce80391 100644
--- a/noncore/unsupported/mail2/mainwindow.cpp
+++ b/noncore/unsupported/mail2/mainwindow.cpp
@@ -1,94 +1,94 @@
1#include <qmessagebox.h> 1#include <qmessagebox.h>
2#include <qaction.h> 2#include <qaction.h>
3#include <qapplication.h> 3#include <qapplication.h>
4 4
5#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6 6
7#include "mailstatusbar.h" 7#include "mailstatusbar.h"
8#include "folderwidget.h" 8#include "folderwidget.h"
9#include "mainwindow.h" 9#include "mainwindow.h"
10#include "configdiag.h" 10#include "configdiag.h"
11#include "configfile.h" 11#include "configfile.h"
12#include "searchdiag.h" 12#include "searchdiag.h"
13#include "mailtable.h" 13#include "mailtable.h"
14#include "composer.h" 14#include "composer.h"
15#include "viewmail.h" 15#include "viewmail.h"
16#include "mailfactory.h" 16#include "mailfactory.h"
17 17
18MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl) 18MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl)
19 : MainWindowBase(parent, name, fl) 19 : MainWindowBase(parent, name, fl)
20{ 20{
21 status->setStopEnabled(false); 21 status->setStopEnabled(false);
22 22
23 connect(folderView, SIGNAL(status(const QString &)), status, SLOT(setStatusText(const QString &))); 23 connect(folderView, SIGNAL(status(const QString&)), status, SLOT(setStatusText(const QString&)));
24 connect(folderView, SIGNAL(folderSelected(Folder)), mailView, SLOT(setFolder(Folder))); 24 connect(folderView, SIGNAL(folderSelected(Folder)), mailView, SLOT(setFolder(Folder)));
25 25
26 connect(mailView, SIGNAL(mailClicked(IMAPResponseFETCH, IMAPHandler *)), SLOT(mailClicked(IMAPResponseFETCH, IMAPHandler *))); 26 connect(mailView, SIGNAL(mailClicked(IMAPResponseFETCH,IMAPHandler*)), SLOT(mailClicked(IMAPResponseFETCH,IMAPHandler*)));
27 connect(mailView, SIGNAL(status(const QString &)), status, SLOT(setStatusText(const QString &))); 27 connect(mailView, SIGNAL(status(const QString&)), status, SLOT(setStatusText(const QString&)));
28 connect(mailView, SIGNAL(totalSteps(int)), status, SLOT(setProgressTotalSteps(int))); 28 connect(mailView, SIGNAL(totalSteps(int)), status, SLOT(setProgressTotalSteps(int)));
29 connect(mailView, SIGNAL(progress(int)), status, SLOT(setProgress(int))); 29 connect(mailView, SIGNAL(progress(int)), status, SLOT(setProgress(int)));
30 connect(mailView, SIGNAL(resetProgress()), status, SLOT(resetProgress())); 30 connect(mailView, SIGNAL(resetProgress()), status, SLOT(resetProgress()));
31 connect(mailView, SIGNAL(stopEnabled(bool)), status, SLOT(setStopEnabled(bool))); 31 connect(mailView, SIGNAL(stopEnabled(bool)), status, SLOT(setStopEnabled(bool)));
32 32
33 connect(status, SIGNAL(stop()), mailView, SLOT(stop())); 33 connect(status, SIGNAL(stop()), mailView, SLOT(stop()));
34 34
35 connect(compose, SIGNAL(activated()), SLOT(slotComposeNoParams())); 35 connect(compose, SIGNAL(activated()), SLOT(slotComposeNoParams()));
36 connect(sendQueue, SIGNAL(activated()), SLOT(slotSendQueued())); 36 connect(sendQueue, SIGNAL(activated()), SLOT(slotSendQueued()));
37 connect(findmails, SIGNAL(activated()), SLOT(slotSearch())); 37 connect(findmails, SIGNAL(activated()), SLOT(slotSearch()));
38 connect(configure, SIGNAL(activated()), SLOT(slotConfigure())); 38 connect(configure, SIGNAL(activated()), SLOT(slotConfigure()));
39 39
40 // Added by Stefan Eilers to allow starting by addressbook.. 40 // Added by Stefan Eilers to allow starting by addressbook..
41#if !defined(QT_NO_COP) 41#if !defined(QT_NO_COP)
42 // QCopChannel *addressChannel = new QCopChannel("QPE/Application/mail" , this ); 42 // QCopChannel *addressChannel = new QCopChannel("QPE/Application/mail" , this );
43 // connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), 43 // connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)),
44 // this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); 44 // this, SLOT ( appMessage(const QCString&,const QByteArray&) ) );
45 connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), 45 connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ),
46 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 46 this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
47#endif 47#endif
48} 48}
49 49
50// Added by Stefan Eilers to allow starting by addressbook.. 50// Added by Stefan Eilers to allow starting by addressbook..
51void MainWindow::appMessage(const QCString &msg, const QByteArray &data) 51void MainWindow::appMessage(const QCString &msg, const QByteArray &data)
52{ 52{
53 if (msg == "writeMail(QString,QString)") { 53 if (msg == "writeMail(QString,QString)") {
54 QDataStream stream(data,IO_ReadOnly); 54 QDataStream stream(data,IO_ReadOnly);
55 QString name, email; 55 QString name, email;
56 stream >> name >> email; 56 stream >> name >> email;
57 57
58 qWarning("opie-mail:: Should send mail to %s with address %s", name.latin1(), email.latin1() ); 58 qWarning("opie-mail:: Should send mail to %s with address %s", name.latin1(), email.latin1() );
59 59
60 slotCompose( name, email ); 60 slotCompose( name, email );
61 61
62 }else{ 62 }else{
63 QString str_message = msg; 63 QString str_message = msg;
64 qWarning("opie-mail:: Received unknown QCop-Message: %s", str_message.latin1() ); 64 qWarning("opie-mail:: Received unknown QCop-Message: %s", str_message.latin1() );
65 } 65 }
66} 66}
67 67
68void MainWindow::slotCompose( const QString& name, const QString& email ) 68void MainWindow::slotCompose( const QString& name, const QString& email )
69{ 69{
70 Composer composer(this, 0, true); 70 Composer composer(this, 0, true);
71 71
72 // If there is a mailaddress given, create message.. 72 // If there is a mailaddress given, create message..
73 if ( ! name.isEmpty() ){ 73 if ( ! name.isEmpty() ){
74 qWarning("opie-mail:: Compose mail for %s with address %s", name.latin1(), email.latin1() ); 74 qWarning("opie-mail:: Compose mail for %s with address %s", name.latin1(), email.latin1() );
75 SendMail compMail; 75 SendMail compMail;
76 compMail.setTo( "\"" + name + "\"" + " " + "<"+ email + ">"); 76 compMail.setTo( "\"" + name + "\"" + " " + "<"+ email + ">");
77 composer.setSendMail( compMail ); 77 composer.setSendMail( compMail );
78 } 78 }
79 composer.showMaximized(); 79 composer.showMaximized();
80 composer.exec(); 80 composer.exec();
81} 81}
82 82
83void MainWindow::slotComposeNoParams() 83void MainWindow::slotComposeNoParams()
84{ 84{
85 slotCompose( 0l, 0l); 85 slotCompose( 0l, 0l);
86} 86}
87 87
88void MainWindow::slotSendQueued() 88void MainWindow::slotSendQueued()
89{ 89{
90 Composer composer(this, 0, true, true); 90 Composer composer(this, 0, true, true);
91 // composer.sendQueue(); 91 // composer.sendQueue();
92 composer.showMaximized(); 92 composer.showMaximized();
93 composer.exec(); 93 composer.exec();
94 //composer.close(); 94 //composer.close();
diff --git a/noncore/unsupported/mail2/searchdiag.cpp b/noncore/unsupported/mail2/searchdiag.cpp
index 907f6ff..6fb4e4d 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
18SearchDiag::SearchDiag(QWidget *parent, const char *name, WFlags fl) 18SearchDiag::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
34void SearchDiag::accept() 34void 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
55void SearchDiag::folderSelected(Folder folder) 55void SearchDiag::folderSelected(Folder folder)
56{ 56{
57 _selected = true; 57 _selected = true;
58 _folder = folder; 58 _folder = folder;
59} 59}
60 60
61void SearchDiag::slotIMAPSelect(IMAPResponse &response) 61void 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
84void SearchDiag::slotIMAPSearch(IMAPResponse &response) 84void 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
102void SearchDiag::slotIMAPFetch(IMAPResponse &response) 102void 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
113void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *) 113void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *)
114{ 114{
115 ViewMail viewMail(fetch, _folder.topFolder().handler(), this, 0, true); 115 ViewMail viewMail(fetch, _folder.topFolder().handler(), this, 0, true);
116 viewMail.showMaximized(); 116 viewMail.showMaximized();
117 viewMail.exec(); 117 viewMail.exec();
118} 118}
119 119
120void SearchDiag::slotInItemActivated(int index) 120void 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 da6924d..0cfb6e5 100644
--- a/noncore/unsupported/mail2/viewmail.cpp
+++ b/noncore/unsupported/mail2/viewmail.cpp
@@ -14,97 +14,97 @@ AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore)
14 setText(1, _attachItemStore.fileName()); 14 setText(1, _attachItemStore.fileName());
15 setText(2, _attachItemStore.description()); 15 setText(2, _attachItemStore.description());
16} 16}
17 17
18AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) 18AttachItem::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
26ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) 26ViewMail::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
65ViewMail::~ViewMail() 65ViewMail::~ViewMail()
66{ 66{
67 hide(); 67 hide();
68} 68}
69 69
70void ViewMail::hide() 70void 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
80void ViewMail::exec() 80void 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
90QString ViewMail::deHtml(const QString &string) 90QString ViewMail::deHtml(const QString &string)
91{ 91{
92 QString string_ = string; 92 QString string_ = string;
93 string_.replace(QRegExp("&"), "&amp;"); 93 string_.replace(QRegExp("&"), "&amp;");
94 string_.replace(QRegExp("<"), "&lt;"); 94 string_.replace(QRegExp("<"), "&lt;");
95 string_.replace(QRegExp(">"), "&gt;"); 95 string_.replace(QRegExp(">"), "&gt;");
96 string_.replace(QRegExp("\\n"), "<br>"); 96 string_.replace(QRegExp("\\n"), "<br>");
97 return string_; 97 return string_;
98} 98}
99 99
100void ViewMail::slotReply() 100void 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());
@@ -134,65 +134,65 @@ void ViewMail::slotReply()
134} 134}
135 135
136void ViewMail::slotForward() 136void 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
180void ViewMail::slotIMAPUid(IMAPResponse &response) 180void 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