summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 6e54bf4..760e3b0 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,55 +1,56 @@
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 4
5#define protected public 5#define protected public
6#include <qwidget.h> 6#include <qwidget.h>
7#undef protected 7#undef protected
8#include "koprefsdialog.h" 8#include "koprefsdialog.h"
9#include <kapplication.h> 9#include <kapplication.h>
10#include <libkdepim/externalapphandler.h> 10#include <libkdepim/externalapphandler.h>
11#include <libkdepim/kpimglobalprefs.h> 11#include <libkdepim/kpimglobalprefs.h>
12#ifdef MINIKDE_KDIALOG_H 12#ifdef MINIKDE_KDIALOG_H
13#undef MINIKDE_KDIALOG_H 13#undef MINIKDE_KDIALOG_H
14#endif 14#endif
15#include "settingsdialog.h" 15#include "settingsdialog.h"
16#include "opiemail.h" 16#include "opiemail.h"
17#include "editaccounts.h" 17#include "editaccounts.h"
18#include "composemail.h" 18#include "composemail.h"
19#include "mailistviewitem.h" 19#include "mailistviewitem.h"
20#include "viewmail.h" 20#include "viewmail.h"
21#include "selectstore.h" 21#include "selectstore.h"
22#include "selectsmtp.h" 22#include "selectsmtp.h"
23#include "accountitem.h" 23#include "accountitem.h"
24#include "accountview.h"
24#include "klocale.h" 25#include "klocale.h"
25 26
26#include <qmessagebox.h> 27#include <qmessagebox.h>
27#include <qtimer.h> 28#include <qtimer.h>
28#include <qcursor.h> 29#include <qcursor.h>
29#include <qtextbrowser.h> 30#include <qtextbrowser.h>
30#include <qregexp.h> 31#include <qregexp.h>
31#include <qpe/global.h> 32#include <qpe/global.h>
32 33
33#ifdef DESKTOP_VERSION 34#ifdef DESKTOP_VERSION
34#include <qapplication.h> 35#include <qapplication.h>
35#else 36#else
36#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
37#endif 38#endif
38#include <libmailwrapper/smtpwrapper.h> 39#include <libmailwrapper/smtpwrapper.h>
39#include <libmailwrapper/mailtypes.h> 40#include <libmailwrapper/mailtypes.h>
40#include <libmailwrapper/abstractmail.h> 41#include <libmailwrapper/abstractmail.h>
41#include "koprefs.h" 42#include "koprefs.h"
42 43
43//using namespace Opie::Core; 44//using namespace Opie::Core;
44 45
45OpieMail::OpieMail( QWidget *parent, const char *name ) 46OpieMail::OpieMail( QWidget *parent, const char *name )
46 : MainWindow( parent, name) //, WStyle_ContextHelp ) 47 : MainWindow( parent, name) //, WStyle_ContextHelp )
47{ 48{
48 settings = new Settings(); 49 settings = new Settings();
49 tb = 0; 50 tb = 0;
50 setIcon(SmallIcon( "kmicromail" ) ); 51 setIcon(SmallIcon( "kmicromail" ) );
51 folderView->populate( settings->getAccounts() ); 52 folderView->populate( settings->getAccounts() );
52 53
53} 54}
54 55
55OpieMail::~OpieMail() 56OpieMail::~OpieMail()
@@ -284,65 +285,100 @@ void OpieMail::replyMail()
284 } 285 }
285 rtext += "\n"; 286 rtext += "\n";
286 287
287 QString prefix; 288 QString prefix;
288 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; 289 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
289 else prefix = "Re: "; // no i18n on purpose 290 else prefix = "Re: "; // no i18n on purpose
290 291
291 Settings *settings = new Settings(); 292 Settings *settings = new Settings();
292 ComposeMail composer( settings ,this, 0, true); 293 ComposeMail composer( settings ,this, 0, true);
293 if (mail->Replyto().isEmpty()) { 294 if (mail->Replyto().isEmpty()) {
294 composer.setTo( mail->getFrom()); 295 composer.setTo( mail->getFrom());
295 } else { 296 } else {
296 composer.setTo( mail->Replyto()); 297 composer.setTo( mail->Replyto());
297 } 298 }
298 composer.setSubject( prefix + mail->getSubject()); 299 composer.setSubject( prefix + mail->getSubject());
299 composer.setMessage( rtext ); 300 composer.setMessage( rtext );
300 composer.setInReplyTo( mail->Msgid()); 301 composer.setInReplyTo( mail->Msgid());
301 composer.setCharset( body->getCharset() ); 302 composer.setCharset( body->getCharset() );
302 if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) 303 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
303 { 304 {
304 mail->Wrapper()->answeredMail(mail); 305 mail->Wrapper()->answeredMail(mail);
305 } 306 }
306 delete settings; 307 delete settings;
307 308
308} 309}
309void OpieMail::closeViewMail(ViewMail * vm) 310void OpieMail::closeViewMail(ViewMail * vm)
310{ 311{
311 vm->hide(); 312 vm->hide();
312} 313}
313 314
314void OpieMail::slotDownloadMail( ) 315void OpieMail::slotDownloadMail( )
315{ 316{
316 qDebug("slotDownloadMail( ) "); 317 QListViewItem*item = mailView->currentItem();
318 if (!item ) {
319 Global::statusMessage("Error: No item slected!");
320 return;
321 }
322 RecMailP mail = ((MailListViewItem*)item)->data();
323 Account * acc = mail->Wrapper()->getAccount();
324 if ( !acc ) {
325 Global::statusMessage("Mail is already stored locally!");
326 return;
327 }
328 QString lfName = acc->getLocalFolder();
329 //qDebug("local folder " + lfName );
330 if ( lfName.isEmpty() )
331 lfName = acc->getAccountName();
332 AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper();
333 //qDebug("target %d %d ",targetMail,mail->Wrapper() );
334 if ( targetMail == mail->Wrapper() ) {
335 Global::statusMessage("Mail is already locally stored!");
336 return;
337 }
338 if ( !targetMail->createMbox(lfName)) {
339 Global::statusMessage("Error creating folder!");
340 return;
341 }
342 Global::statusMessage("Fetching mail...please wait!");
343 qApp->processEvents();
344 encodedString*st = 0;
345 st = mail->Wrapper()->fetchRawBody(mail);
346 if ( st ) {
347 targetMail->storeMessage(st->Content(),st->Length(),lfName);
348 Global::statusMessage("Mail stored in "+ lfName);
349 delete st;
350 } else {
351 Global::statusMessage("Error: Cannot fetch mail!");
352 }
317} 353}
318 354
319 355
320void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) 356void OpieMail::deleteAndDisplayNextMail(ViewMail * vm)
321{ 357{
322 QListViewItem*item = mailView->currentItem(); 358 QListViewItem*item = mailView->currentItem();
323 if (!item ) { 359 if (!item ) {
324 closeViewMail(vm); 360 closeViewMail(vm);
325 return; 361 return;
326 } 362 }
327 RecMailP mail = ((MailListViewItem*)item)->data(); 363 RecMailP mail = ((MailListViewItem*)item)->data();
328 mail->Wrapper()->deleteMail( mail ); 364 mail->Wrapper()->deleteMail( mail );
329 item = item->itemBelow(); 365 item = item->itemBelow();
330 if (!item ) { 366 if (!item ) {
331 closeViewMail(vm); 367 closeViewMail(vm);
332 return; 368 return;
333 } 369 }
334 mailView->setCurrentItem(item); 370 mailView->setCurrentItem(item);
335 mail = ((MailListViewItem*)item)->data(); 371 mail = ((MailListViewItem*)item)->data();
336 RecBodyP body = folderView->fetchBody(mail); 372 RecBodyP body = folderView->fetchBody(mail);
337 vm->setBody( body ); 373 vm->setBody( body );
338 vm->setMail( mail ); 374 vm->setMail( mail );
339} 375}
340void OpieMail::displayNextMail(ViewMail * vm) 376void OpieMail::displayNextMail(ViewMail * vm)
341{ 377{
342 QListViewItem*item = mailView->currentItem(); 378 QListViewItem*item = mailView->currentItem();
343 if (!item) return; 379 if (!item) return;
344 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 380 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
345 item = item->itemBelow(); 381 item = item->itemBelow();
346 if (!item) { 382 if (!item) {
347 vm->setCaption(i18n("End of List" )); 383 vm->setCaption(i18n("End of List" ));
348 return; 384 return;