summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index ec192ea..915b3e8 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,560 +1,587 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3 3
4#include "koprefsdialog.h" 4#include "koprefsdialog.h"
5#include <kapplication.h> 5#include <kapplication.h>
6#include <libkdepim/externalapphandler.h> 6#include <libkdepim/externalapphandler.h>
7#include <libkdepim/kpimglobalprefs.h> 7#include <libkdepim/kpimglobalprefs.h>
8#ifdef MINIKDE_KDIALOG_H 8#ifdef MINIKDE_KDIALOG_H
9#undef MINIKDE_KDIALOG_H 9#undef MINIKDE_KDIALOG_H
10#endif 10#endif
11#include "settingsdialog.h" 11#include "settingsdialog.h"
12#include "opiemail.h" 12#include "opiemail.h"
13#include "editaccounts.h" 13#include "editaccounts.h"
14#include "composemail.h" 14#include "composemail.h"
15#include "mailistviewitem.h" 15#include "mailistviewitem.h"
16#include "viewmail.h" 16#include "viewmail.h"
17#include "selectstore.h" 17#include "selectstore.h"
18#include "selectsmtp.h" 18#include "selectsmtp.h"
19#include "accountitem.h" 19#include "accountitem.h"
20#include "klocale.h" 20#include "klocale.h"
21 21
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qcursor.h> 24#include <qcursor.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qpe/global.h> 26#include <qpe/global.h>
27 27
28#ifdef DESKTOP_VERSION 28#ifdef DESKTOP_VERSION
29#include <qapplication.h> 29#include <qapplication.h>
30#else 30#else
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#endif 32#endif
33#include <libmailwrapper/smtpwrapper.h> 33#include <libmailwrapper/smtpwrapper.h>
34#include <libmailwrapper/mailtypes.h> 34#include <libmailwrapper/mailtypes.h>
35#include <libmailwrapper/abstractmail.h> 35#include <libmailwrapper/abstractmail.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38//using namespace Opie::Core; 38//using namespace Opie::Core;
39 39
40OpieMail::OpieMail( QWidget *parent, const char *name ) 40OpieMail::OpieMail( QWidget *parent, const char *name )
41 : MainWindow( parent, name) //, WStyle_ContextHelp ) 41 : MainWindow( parent, name) //, WStyle_ContextHelp )
42{ 42{
43 settings = new Settings(); 43 settings = new Settings();
44 44
45 setIcon(SmallIcon( "kmicromail" ) ); 45 setIcon(SmallIcon( "kmicromail" ) );
46 folderView->populate( settings->getAccounts() ); 46 folderView->populate( settings->getAccounts() );
47 47
48} 48}
49 49
50OpieMail::~OpieMail() 50OpieMail::~OpieMail()
51{ 51{
52 if (settings) delete settings; 52 if (settings) delete settings;
53} 53}
54 54
55void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 55void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
56{ 56{
57 57
58} 58}
59#include <stdlib.h> 59#include <stdlib.h>
60void OpieMail::message(const QCString &msg, const QByteArray &data) 60void OpieMail::message(const QCString &msg, const QByteArray &data)
61{ 61{
62 // copied from old mail2 62 // copied from old mail2
63 static int ii = 0; 63 static int ii = 0;
64 //qDebug("QCOP CALL ############################# %d ", ii); 64 //qDebug("QCOP CALL ############################# %d ", ii);
65 //QString mess ( msg ); 65 //QString mess ( msg );
66 //qDebug("Message = %s ",mess.latin1()); 66 //qDebug("Message = %s ",mess.latin1());
67 ++ii; 67 ++ii;
68 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 68 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
69 69
70 mPendingEmail = QString::null; 70 mPendingEmail = QString::null;
71 mPendingName = QString::null; 71 mPendingName = QString::null;
72 if (msg == "writeMail(QString,QString)") 72 if (msg == "writeMail(QString,QString)")
73 { 73 {
74 //qDebug("writeMail(QString,QString) "); 74 //qDebug("writeMail(QString,QString) ");
75 QDataStream stream(data,IO_ReadOnly); 75 QDataStream stream(data,IO_ReadOnly);
76 stream >> mPendingName >> mPendingEmail; 76 stream >> mPendingName >> mPendingEmail;
77 // removing the whitespaces at beginning and end is needed! 77 // removing the whitespaces at beginning and end is needed!
78 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 78 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
79 } 79 }
80 else if (msg == "newMail()") 80 else if (msg == "newMail()")
81 { 81 {
82 //qDebug("slotComposeMail() "); 82 //qDebug("slotComposeMail() ");
83 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call 83 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call
84 // and a QCOP call does not like a processevents in his execution 84 // and a QCOP call does not like a processevents in his execution
85 // with the Qtimer we call slotComposeMail() after we reached the main event loop 85 // with the Qtimer we call slotComposeMail() after we reached the main event loop
86 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 86 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
87 // slotComposeMail(); 87 // slotComposeMail();
88 } 88 }
89 else if (msg == "newMail(QString)") 89 else if (msg == "newMail(QString)")
90 { 90 {
91 //qDebug(" newMail(QString)"); 91 //qDebug(" newMail(QString)");
92 QDataStream stream(data,IO_ReadOnly); 92 QDataStream stream(data,IO_ReadOnly);
93 stream >> mPendingName; 93 stream >> mPendingName;
94 // the format is 94 // the format is
95 // NAME <EMAIL>:SUBJECT 95 // NAME <EMAIL>:SUBJECT
96 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 96 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
97 } else { 97 } else {
98 mPendingData = data; 98 mPendingData = data;
99 mPendingMessage = msg; 99 mPendingMessage = msg;
100 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); 100 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) );
101 } 101 }
102 102
103 //qDebug("END OpieMail::message "); 103 //qDebug("END OpieMail::message ");
104} 104}
105void OpieMail::slotExtAppHandler() 105void OpieMail::slotExtAppHandler()
106{ 106{
107 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); 107 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData );
108} 108}
109void OpieMail::slotwriteMail2(const QString& namemail ) 109void OpieMail::slotwriteMail2(const QString& namemail )
110{ 110{
111 //qDebug("OpieMail::slotwriteMail2 "); 111 //qDebug("OpieMail::slotwriteMail2 ");
112 //qApp->processEvents(); 112 //qApp->processEvents();
113 ComposeMail compose( settings, this, 0, true ); 113 ComposeMail compose( settings, this, 0, true );
114 if ( !namemail.isEmpty() ) { 114 if ( !namemail.isEmpty() ) {
115 QString to = namemail; 115 QString to = namemail;
116 if ( namemail.find( " <") > 1 ) { 116 if ( namemail.find( " <") > 1 ) {
117 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 117 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
118 } else 118 } else
119 if ( namemail.find( "<") > 1 ) { 119 if ( namemail.find( "<") > 1 ) {
120 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 120 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
121 } 121 }
122 int sub = to.find( ">:"); 122 int sub = to.find( ">:");
123 if ( sub > 0 ) { 123 if ( sub > 0 ) {
124 compose.setTo( to.left(sub+1) ); 124 compose.setTo( to.left(sub+1) );
125 compose.setSubject( to.mid(sub+2) ); 125 compose.setSubject( to.mid(sub+2) );
126 } else 126 } else
127 compose.setTo( to ); 127 compose.setTo( to );
128 } 128 }
129 compose.slotAdjustColumns(); 129 compose.slotAdjustColumns();
130#ifndef DESKTOP_VERSION 130#ifndef DESKTOP_VERSION
131 compose.showMaximized(); 131 compose.showMaximized();
132#endif 132#endif
133 compose.exec(); 133 compose.exec();
134 raise(); 134 raise();
135 //qDebug("retttich "); 135 //qDebug("retttich ");
136} 136}
137void OpieMail::slotwriteMail(const QString&name,const QString&email) 137void OpieMail::slotwriteMail(const QString&name,const QString&email)
138{ 138{
139 // qDebug("OpieMail::slotwriteMail "); 139 // qDebug("OpieMail::slotwriteMail ");
140 ComposeMail compose( settings, this, 0, true ); 140 ComposeMail compose( settings, this, 0, true );
141 if (!email.isEmpty()) 141 if (!email.isEmpty())
142 { 142 {
143 if (!name.isEmpty()) 143 if (!name.isEmpty())
144 { 144 {
145 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 145 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
146 } 146 }
147 else 147 else
148 { 148 {
149 compose.setTo(email); 149 compose.setTo(email);
150 } 150 }
151 } 151 }
152 compose.slotAdjustColumns(); 152 compose.slotAdjustColumns();
153#ifndef DESKTOP_VERSION 153#ifndef DESKTOP_VERSION
154 compose.showMaximized(); 154 compose.showMaximized();
155#endif 155#endif
156 compose.exec(); 156 compose.exec();
157 raise(); 157 raise();
158} 158}
159 159
160void OpieMail::slotComposeMail() 160void OpieMail::slotComposeMail()
161{ 161{
162 if ( mPendingEmail == QString::null && mPendingName == QString::null) 162 if ( mPendingEmail == QString::null && mPendingName == QString::null)
163 slotwriteMail2( QString () ); 163 slotwriteMail2( QString () );
164 else { 164 else {
165 if ( mPendingEmail == QString::null ) 165 if ( mPendingEmail == QString::null )
166 slotwriteMail2( mPendingName ); 166 slotwriteMail2( mPendingName );
167 else 167 else
168 slotwriteMail( mPendingName, mPendingEmail ); 168 slotwriteMail( mPendingName, mPendingEmail );
169 } 169 }
170 //slotwriteMail(0l,0l); 170 //slotwriteMail(0l,0l);
171} 171}
172 172
173void OpieMail::slotSendQueued() 173void OpieMail::slotSendQueued()
174{ 174{
175 SMTPaccount *smtp = 0; 175 SMTPaccount *smtp = 0;
176 176
177 QList<Account> list = settings->getAccounts(); 177 QList<Account> list = settings->getAccounts();
178 QList<SMTPaccount> smtpList; 178 QList<SMTPaccount> smtpList;
179 smtpList.setAutoDelete(false); 179 smtpList.setAutoDelete(false);
180 Account *it; 180 Account *it;
181 for ( it = list.first(); it; it = list.next() ) 181 for ( it = list.first(); it; it = list.next() )
182 { 182 {
183 if ( it->getType() == MAILLIB::A_SMTP ) 183 if ( it->getType() == MAILLIB::A_SMTP )
184 { 184 {
185 smtp = static_cast<SMTPaccount *>(it); 185 smtp = static_cast<SMTPaccount *>(it);
186 smtpList.append(smtp); 186 smtpList.append(smtp);
187 } 187 }
188 } 188 }
189 if (smtpList.count()==0) 189 if (smtpList.count()==0)
190 { 190 {
191 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); 191 QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n"));
192 return; 192 return;
193 } 193 }
194 if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 194 if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
195 return; 195 return;
196 if (smtpList.count()==1) 196 if (smtpList.count()==1)
197 { 197 {
198 smtp = smtpList.at(0); 198 smtp = smtpList.at(0);
199 } 199 }
200 else 200 else
201 { 201 {
202 smtp = 0; 202 smtp = 0;
203 selectsmtp selsmtp; 203 selectsmtp selsmtp;
204 selsmtp.setSelectionlist(&smtpList); 204 selsmtp.setSelectionlist(&smtpList);
205#ifndef DESKTOP_VERSION 205#ifndef DESKTOP_VERSION
206 selsmtp.showMaximized(); 206 selsmtp.showMaximized();
207#endif 207#endif
208 if ( selsmtp.exec() == QDialog::Accepted ) 208 if ( selsmtp.exec() == QDialog::Accepted )
209 { 209 {
210 smtp = selsmtp.selected_smtp(); 210 smtp = selsmtp.selected_smtp();
211 } 211 }
212 } 212 }
213 if (smtp) 213 if (smtp)
214 { 214 {
215 215
216 Global::statusMessage("Sending mails...!"); 216 Global::statusMessage("Sending mails...!");
217 SMTPwrapper * wrap = new SMTPwrapper(smtp); 217 SMTPwrapper * wrap = new SMTPwrapper(smtp);
218 if ( wrap->flushOutbox() ) 218 if ( wrap->flushOutbox() )
219 { 219 {
220 Global::statusMessage("Mails sent!"); 220 Global::statusMessage("Mails sent!");
221 } 221 }
222 delete wrap; 222 delete wrap;
223 } 223 }
224 // pending refresh list view, if outgoing is displayed 224 // pending refresh list view, if outgoing is displayed
225} 225}
226 226
227void OpieMail::slotSearchMails() 227void OpieMail::slotSearchMails()
228{ 228{
229 qDebug("OpieMail::slotSearchMails():not implemented "); 229 qDebug("OpieMail::slotSearchMails():not implemented ");
230} 230}
231 231
232void OpieMail::slotEditSettings() 232void OpieMail::slotEditSettings()
233{ 233{
234 234
235 KOPrefsDialog settingsDialog( this, "koprefs", true ); 235 KOPrefsDialog settingsDialog( this, "koprefs", true );
236#ifndef DESKTOP_VERSION 236#ifndef DESKTOP_VERSION
237 settingsDialog.showMaximized(); 237 settingsDialog.showMaximized();
238#endif 238#endif
239 settingsDialog.exec(); 239 settingsDialog.exec();
240 240
241 slotSetCodec( KOPrefs::instance()->mCurrentCodec ); 241 slotSetCodec( KOPrefs::instance()->mCurrentCodec );
242 // KApplication::execDialog(settingsDialog); 242 // KApplication::execDialog(settingsDialog);
243} 243}
244 244
245void OpieMail::slotEditAccounts() 245void OpieMail::slotEditAccounts()
246{ 246{
247 EditAccounts eaDialog( settings, this, 0, true ); 247 EditAccounts eaDialog( settings, this, 0, true );
248 eaDialog.slotAdjustColumns(); 248 eaDialog.slotAdjustColumns();
249#ifndef DESKTOP_VERSION 249#ifndef DESKTOP_VERSION
250 eaDialog.showMaximized(); 250 eaDialog.showMaximized();
251#endif 251#endif
252 eaDialog.exec(); 252 eaDialog.exec();
253 if ( settings ) delete settings; 253 if ( settings ) delete settings;
254 settings = new Settings(); 254 settings = new Settings();
255 255
256 folderView->populate( settings->getAccounts() ); 256 folderView->populate( settings->getAccounts() );
257} 257}
258void OpieMail::replyMail() 258void OpieMail::replyMail()
259{ 259{
260 260
261 QListViewItem*item = mailView->currentItem(); 261 QListViewItem*item = mailView->currentItem();
262 if (!item) return; 262 if (!item) return;
263 RecMailP mail = ((MailListViewItem*)item)->data(); 263 RecMailP mail = ((MailListViewItem*)item)->data();
264 RecBodyP body = folderView->fetchBody(mail); 264 RecBodyP body = folderView->fetchBody(mail);
265 265
266 QString rtext; 266 QString rtext;
267 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 267 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
268 .arg( mail->getFrom()) 268 .arg( mail->getFrom())
269 .arg( mail->getDate()); 269 .arg( mail->getDate());
270 270
271 QString text = body->Bodytext(); 271 QString text = body->Bodytext();
272 QStringList lines = QStringList::split(QRegExp("\\n"), text); 272 QStringList lines = QStringList::split(QRegExp("\\n"), text);
273 QStringList::Iterator it; 273 QStringList::Iterator it;
274 for (it = lines.begin(); it != lines.end(); it++) 274 for (it = lines.begin(); it != lines.end(); it++)
275 { 275 {
276 rtext += "> " + *it + "\n"; 276 rtext += "> " + *it + "\n";
277 } 277 }
278 rtext += "\n"; 278 rtext += "\n";
279 279
280 QString prefix; 280 QString prefix;
281 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; 281 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
282 else prefix = "Re: "; // no i18n on purpose 282 else prefix = "Re: "; // no i18n on purpose
283 283
284 Settings *settings = new Settings(); 284 Settings *settings = new Settings();
285 ComposeMail composer( settings ,this, 0, true); 285 ComposeMail composer( settings ,this, 0, true);
286 if (mail->Replyto().isEmpty()) { 286 if (mail->Replyto().isEmpty()) {
287 composer.setTo( mail->getFrom()); 287 composer.setTo( mail->getFrom());
288 } else { 288 } else {
289 composer.setTo( mail->Replyto()); 289 composer.setTo( mail->Replyto());
290 } 290 }
291 composer.setSubject( prefix + mail->getSubject()); 291 composer.setSubject( prefix + mail->getSubject());
292 composer.setMessage( rtext ); 292 composer.setMessage( rtext );
293 composer.setInReplyTo( mail->Msgid()); 293 composer.setInReplyTo( mail->Msgid());
294 composer.setCharset( body->getCharset() ); 294 composer.setCharset( body->getCharset() );
295 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 295 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
296 { 296 {
297 mail->Wrapper()->answeredMail(mail); 297 mail->Wrapper()->answeredMail(mail);
298 } 298 }
299 delete settings; 299 delete settings;
300 300
301} 301}
302void OpieMail::closeViewMail(ViewMail * vm)
303{
304 vm->hide();
305}
306void OpieMail::deleteAndDisplayNextMail(ViewMail * vm)
307{
308 QListViewItem*item = mailView->currentItem();
309 if (!item ) {
310 closeViewMail(vm);
311 return;
312 }
313 RecMailP mail = ((MailListViewItem*)item)->data();
314 mail->Wrapper()->deleteMail( mail );
315 item = item->itemBelow();
316 if (!item ) {
317 closeViewMail(vm);
318 return;
319 }
320 mailView->setCurrentItem(item);
321 mail = ((MailListViewItem*)item)->data();
322 RecBodyP body = folderView->fetchBody(mail);
323 vm->setBody( body );
324 vm->setMail( mail );
325}
302void OpieMail::displayNextMail(ViewMail * vm) 326void OpieMail::displayNextMail(ViewMail * vm)
303{ 327{
304 QListViewItem*item = mailView->currentItem(); 328 QListViewItem*item = mailView->currentItem();
305 if (!item) return; 329 if (!item) return;
330 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
306 item = item->itemBelow(); 331 item = item->itemBelow();
307 if (!item) { 332 if (!item) {
308 vm->setCaption(i18n("End of List" )); 333 vm->setCaption(i18n("End of List" ));
309 return; 334 return;
310 } 335 }
311 mailView->setCurrentItem(item); 336 mailView->setCurrentItem(item);
312 RecMailP mail = ((MailListViewItem*)item)->data(); 337 RecMailP mail = ((MailListViewItem*)item)->data();
313 RecBodyP body = folderView->fetchBody(mail); 338 RecBodyP body = folderView->fetchBody(mail);
314 vm->setBody( body ); 339 vm->setBody( body );
315 vm->setMail( mail ); 340 vm->setMail( mail );
316} 341}
317void OpieMail::displayMail() 342void OpieMail::displayMail()
318{ 343{
319 QListViewItem*item = mailView->currentItem(); 344 QListViewItem*item = mailView->currentItem();
320 if (!item) return; 345 if (!item) return;
321 RecMailP mail = ((MailListViewItem*)item)->data(); 346 RecMailP mail = ((MailListViewItem*)item)->data();
322 RecBodyP body = folderView->fetchBody(mail); 347 RecBodyP body = folderView->fetchBody(mail);
323 ViewMail readMail( this,"", Qt::WType_Modal ); 348 ViewMail readMail( this,"", Qt::WType_Modal );
324 readMail.setBody( body ); 349 readMail.setBody( body );
325 readMail.setMail( mail ); 350 readMail.setMail( mail );
326#ifndef DESKTOP_VERSION 351#ifndef DESKTOP_VERSION
327 readMail.showMaximized(); 352 readMail.showMaximized();
328#else 353#else
329 readMail.resize( 640, 480); 354 readMail.resize( 640, 480);
330#endif 355#endif
331 connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); 356 connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) );
357 connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) );
358
332 readMail.exec(); 359 readMail.exec();
333 360
334 if ( readMail.deleted ) 361 if ( readMail.deleted )
335 { 362 {
336 folderView->refreshCurrent(); 363 folderView->refreshCurrent();
337 } 364 }
338 else 365 else
339 { 366 {
340 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 367 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
341 } 368 }
342} 369}
343void OpieMail::slotGetAllMail() 370void OpieMail::slotGetAllMail()
344{ 371{
345 QListViewItem * item = folderView->firstChild(); 372 QListViewItem * item = folderView->firstChild();
346 while ( item ){ 373 while ( item ){
347 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 374 ((AccountViewItem *)item)->contextMenuSelected( 101 );
348 item = item->nextSibling (); 375 item = item->nextSibling ();
349 } 376 }
350} 377}
351void OpieMail::slotGetMail() 378void OpieMail::slotGetMail()
352{ 379{
353 QListViewItem * item = folderView->currentItem(); 380 QListViewItem * item = folderView->currentItem();
354 if ( ! item ) return; 381 if ( ! item ) return;
355 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 382 ((AccountViewItem *)item)->contextMenuSelected( 101 );
356} 383}
357void OpieMail::slotDeleteMail() 384void OpieMail::slotDeleteMail()
358{ 385{
359 if (!mailView->currentItem()) return; 386 if (!mailView->currentItem()) return;
360 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 387 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
361 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 388 if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
362 { 389 {
363 mail->Wrapper()->deleteMail( mail ); 390 mail->Wrapper()->deleteMail( mail );
364 folderView->refreshCurrent(); 391 folderView->refreshCurrent();
365 } 392 }
366} 393}
367void OpieMail::slotDeleteAllMail() 394void OpieMail::slotDeleteAllMail()
368{ 395{
369 396
370 QValueList<RecMailP> t; 397 QValueList<RecMailP> t;
371 if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 398 if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
372 { 399 {
373 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 400 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
374 while ( item ) { 401 while ( item ) {
375 if ( item->isSelected() ) { 402 if ( item->isSelected() ) {
376 t.append( item->data() ); 403 t.append( item->data() );
377 } 404 }
378 item = (MailListViewItem*)item->nextSibling(); 405 item = (MailListViewItem*)item->nextSibling();
379 } 406 }
380 } 407 }
381 else 408 else
382 return; 409 return;
383 if ( t.count() == 0 ) 410 if ( t.count() == 0 )
384 return; 411 return;
385 RecMailP mail = t.first(); 412 RecMailP mail = t.first();
386 mail->Wrapper()->deleteMailList(t); 413 mail->Wrapper()->deleteMailList(t);
387 folderView->refreshCurrent(); 414 folderView->refreshCurrent();
388 415
389 416
390} 417}
391void OpieMail::clearSelection() 418void OpieMail::clearSelection()
392{ 419{
393 mailView->clearSelection(); 420 mailView->clearSelection();
394 421
395} 422}
396 423
397void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 424void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
398{ 425{
399 if (!mailView->currentItem()) return; 426 if (!mailView->currentItem()) return;
400 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 427 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
401 /* just the RIGHT button - or hold on pda */ 428 /* just the RIGHT button - or hold on pda */
402 if (button!=2) {return;} 429 if (button!=2) {return;}
403 if (!item) return; 430 if (!item) return;
404 QPopupMenu *m = new QPopupMenu(0); 431 QPopupMenu *m = new QPopupMenu(0);
405 if (m) 432 if (m)
406 { 433 {
407 if (mailtype==MAILLIB::A_NNTP) { 434 if (mailtype==MAILLIB::A_NNTP) {
408 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); 435 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail()));
409 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); 436 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail()));
410 m->insertSeparator(); 437 m->insertSeparator();
411 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); 438 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail()));
412 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 439 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
413 } else { 440 } else {
414 if (folderView->currentisDraft()) { 441 if (folderView->currentisDraft()) {
415 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); 442 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail()));
416 } 443 }
417 m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); 444 m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail()));
418 m->insertSeparator(); 445 m->insertSeparator();
419 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); 446 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail()));
420 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); 447 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
421 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); 448 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail()));
422 m->insertSeparator(); 449 m->insertSeparator();
423 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); 450 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
424 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 451 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
425 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 452 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
426 } 453 }
427 m->setFocus(); 454 m->setFocus();
428 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 455 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
429 delete m; 456 delete m;
430 } 457 }
431} 458}
432 459
433void OpieMail::slotShowFolders( bool show ) 460void OpieMail::slotShowFolders( bool show )
434{ 461{
435 if ( show && folderView->isHidden() ) 462 if ( show && folderView->isHidden() )
436 { 463 {
437 folderView->show(); 464 folderView->show();
438 } 465 }
439 else if ( !show && !folderView->isHidden() ) 466 else if ( !show && !folderView->isHidden() )
440 { 467 {
441 folderView->hide(); 468 folderView->hide();
442 } 469 }
443} 470}
444 471
445void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 472void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
446{ 473{
447 MailListViewItem*item = 0; 474 MailListViewItem*item = 0;
448 mailView->clear(); 475 mailView->clear();
449 476
450 QValueList<RecMailP>::ConstIterator it; 477 QValueList<RecMailP>::ConstIterator it;
451 for (it = list.begin(); it != list.end();++it) 478 for (it = list.begin(); it != list.end();++it)
452 { 479 {
453 item = new MailListViewItem(mailView,item); 480 item = new MailListViewItem(mailView,item);
454 item->storeData((*it)); 481 item->storeData((*it));
455 item->showEntry(); 482 item->showEntry();
456 } 483 }
457 mailView->setSorting ( 4, false ); 484 mailView->setSorting ( 4, false );
458} 485}
459 486
460void OpieMail::mailLeftClicked( QListViewItem *item ) 487void OpieMail::mailLeftClicked( QListViewItem *item )
461{ 488{
462 mailView->clearSelection(); 489 mailView->clearSelection();
463 /* just LEFT button - or tap with stylus on pda */ 490 /* just LEFT button - or tap with stylus on pda */
464 //if (button!=1) return; 491 //if (button!=1) return;
465 if (!item) return; 492 if (!item) return;
466 if (folderView->currentisDraft()) { 493 if (folderView->currentisDraft()) {
467 reEditMail(); 494 reEditMail();
468 } else { 495 } else {
469 displayMail(); 496 displayMail();
470 } 497 }
471} 498}
472 499
473void OpieMail::slotMoveCopyMail() 500void OpieMail::slotMoveCopyMail()
474{ 501{
475 if (!mailView->currentItem()) return; 502 if (!mailView->currentItem()) return;
476 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 503 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
477 AbstractMail*targetMail = 0; 504 AbstractMail*targetMail = 0;
478 QString targetFolder = ""; 505 QString targetFolder = "";
479 Selectstore sels; 506 Selectstore sels;
480 folderView->setupFolderselect(&sels); 507 folderView->setupFolderselect(&sels);
481 if (!sels.exec()) return; 508 if (!sels.exec()) return;
482 targetMail = sels.currentMail(); 509 targetMail = sels.currentMail();
483 targetFolder = sels.currentFolder(); 510 targetFolder = sels.currentFolder();
484 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 511 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
485 targetFolder.isEmpty()) 512 targetFolder.isEmpty())
486 { 513 {
487 return; 514 return;
488 } 515 }
489 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 516 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
490 { 517 {
491 QMessageBox::critical(0,i18n("Error creating new Folder"), 518 QMessageBox::critical(0,i18n("Error creating new Folder"),
492 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 519 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
493 return; 520 return;
494 } 521 }
495 sels.hide(); 522 sels.hide();
496 qApp->processEvents(); 523 qApp->processEvents();
497 // qDebug("hiding sels "); 524 // qDebug("hiding sels ");
498 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 525 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
499 folderView->refreshCurrent(); 526 folderView->refreshCurrent();
500} 527}
501 528
502void OpieMail::slotMoveCopyAllMail() 529void OpieMail::slotMoveCopyAllMail()
503{ 530{
504 531
505 if (!mailView->currentItem()) return; 532 if (!mailView->currentItem()) return;
506 QValueList<RecMailP> t; 533 QValueList<RecMailP> t;
507 // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 534 // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
508 { 535 {
509 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 536 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
510 while ( item ) { 537 while ( item ) {
511 if ( item->isSelected() ) { 538 if ( item->isSelected() ) {
512 t.append( item->data() ); 539 t.append( item->data() );
513 } 540 }
514 item = (MailListViewItem*)item->nextSibling(); 541 item = (MailListViewItem*)item->nextSibling();
515 } 542 }
516 } 543 }
517 // else 544 // else
518 // return; 545 // return;
519 if ( t.count() == 0 ) 546 if ( t.count() == 0 )
520 return; 547 return;
521 RecMailP mail = t.first(); 548 RecMailP mail = t.first();
522 AbstractMail*targetMail = 0; 549 AbstractMail*targetMail = 0;
523 QString targetFolder = ""; 550 QString targetFolder = "";
524 Selectstore sels; 551 Selectstore sels;
525 folderView->setupFolderselect(&sels); 552 folderView->setupFolderselect(&sels);
526 if (!sels.exec()) return; 553 if (!sels.exec()) return;
527 targetMail = sels.currentMail(); 554 targetMail = sels.currentMail();
528 targetFolder = sels.currentFolder(); 555 targetFolder = sels.currentFolder();
529 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 556 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
530 targetFolder.isEmpty()) 557 targetFolder.isEmpty())
531 { 558 {
532 return; 559 return;
533 } 560 }
534 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 561 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
535 { 562 {
536 QMessageBox::critical(0,i18n("Error creating new Folder"), 563 QMessageBox::critical(0,i18n("Error creating new Folder"),
537 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 564 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
538 return; 565 return;
539 } 566 }
540 sels.hide(); 567 sels.hide();
541 qApp->processEvents(); 568 qApp->processEvents();
542 //qDebug("hiding sels "); 569 //qDebug("hiding sels ");
543 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); 570 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
544 folderView->refreshCurrent(); 571 folderView->refreshCurrent();
545} 572}
546 573
547void OpieMail::reEditMail() 574void OpieMail::reEditMail()
548{ 575{
549 if (!mailView->currentItem()) return; 576 if (!mailView->currentItem()) return;
550 577
551 ComposeMail compose( settings, this, 0, true ); 578 ComposeMail compose( settings, this, 0, true );
552 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 579 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
553 compose.slotAdjustColumns(); 580 compose.slotAdjustColumns();
554#ifndef DESKTOP_VERSION 581#ifndef DESKTOP_VERSION
555 compose.showMaximized(); 582 compose.showMaximized();
556#else 583#else
557 compose.resize(640,480); 584 compose.resize(640,480);
558#endif 585#endif
559 compose.exec(); 586 compose.exec();
560} 587}