summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp7
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h2
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp6
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h1
5 files changed, 15 insertions, 6 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 2ce89db..77fa706 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,51 +1,51 @@
1#include <stdlib.h>
2#include "accountview.h" 1#include "accountview.h"
3#include <libmailwrapper/mailtypes.h> 2#include <libmailwrapper/mailtypes.h>
3#include <libmailwrapper/abstractmail.h>
4#include "defines.h" 4#include "defines.h"
5#include "newmaildir.h" 5#include "newmaildir.h"
6#include <qmessagebox.h> 6#include <qmessagebox.h>
7#include <qpopupmenu.h> 7#include <qpopupmenu.h>
8 8
9/** 9/**
10 * POP3 Account stuff 10 * POP3 Account stuff
11 */ 11 */
12POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) 12POP3viewItem::POP3viewItem( POP3account *a, QListView *parent )
13 : AccountViewItem( parent ) 13 : AccountViewItem( parent )
14{ 14{
15 account = a; 15 account = a;
16 wrapper = AbstractMail::getWrapper( account ); 16 wrapper = AbstractMail::getWrapper( account );
17 setPixmap( 0, PIXMAP_POP3FOLDER ); 17 setPixmap( 0, PIXMAP_POP3FOLDER );
18 setText( 0, account->getAccountName() ); 18 setText( 0, account->getAccountName() );
19 setOpen( true ); 19 setOpen( true );
20} 20}
21 21
22POP3viewItem::~POP3viewItem() 22POP3viewItem::~POP3viewItem()
23{ 23{
24 delete wrapper; 24 delete wrapper;
25} 25}
26 26
27AbstractMail *POP3viewItem::getWrapper() 27AbstractMail *POP3viewItem::getWrapper()
28{ 28{
29 return wrapper; 29 return wrapper;
30} 30}
31 31
32void POP3viewItem::refresh( QList<RecMail> & ) 32void POP3viewItem::refresh( QList<RecMail> & )
33{ 33{
34 QList<Folder> *folders = wrapper->listFolders(); 34 QList<Folder> *folders = wrapper->listFolders();
35 QListViewItem *child = firstChild(); 35 QListViewItem *child = firstChild();
36 while ( child ) { 36 while ( child ) {
37 QListViewItem *tmp = child; 37 QListViewItem *tmp = child;
38 child = child->nextSibling(); 38 child = child->nextSibling();
39 delete tmp; 39 delete tmp;
40 } 40 }
41 Folder *it; 41 Folder *it;
42 QListViewItem*item = 0; 42 QListViewItem*item = 0;
43 for ( it = folders->first(); it; it = folders->next() ) { 43 for ( it = folders->first(); it; it = folders->next() ) {
44 item = new POP3folderItem( it, this , item ); 44 item = new POP3folderItem( it, this , item );
45 item->setSelectable(it->may_select()); 45 item->setSelectable(it->may_select());
46 } 46 }
47 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 47 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
48 folders->setAutoDelete(false); 48 folders->setAutoDelete(false);
49 delete folders; 49 delete folders;
50} 50}
51 51
@@ -401,98 +401,97 @@ void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
401 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). 401 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).
402 arg(fname), 402 arg(fname),
403 QObject::tr("Yes",contextName), 403 QObject::tr("Yes",contextName),
404 QObject::tr("No",contextName),QString::null,1,1); 404 QObject::tr("No",contextName),QString::null,1,1);
405 qDebug("Auswahl: %i",yesno); 405 qDebug("Auswahl: %i",yesno);
406 if (yesno == 0) { 406 if (yesno == 0) {
407 if (wrapper->deleteAllMail(folder)) { 407 if (wrapper->deleteAllMail(folder)) {
408 AccountView * view = (AccountView*)listView(); 408 AccountView * view = (AccountView*)listView();
409 if (view) view->refreshCurrent(); 409 if (view) view->refreshCurrent();
410 } 410 }
411 } 411 }
412} 412}
413 413
414AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 414AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
415 : QListView( parent, name, flags ) 415 : QListView( parent, name, flags )
416{ 416{
417 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), 417 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ),
418 SLOT( refresh( QListViewItem * ) ) ); 418 SLOT( refresh( QListViewItem * ) ) );
419 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, 419 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
420 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); 420 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) );
421 421
422 setSorting(0); 422 setSorting(0);
423} 423}
424 424
425void AccountView::slotContextMenu(int id) 425void AccountView::slotContextMenu(int id)
426{ 426{
427 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 427 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
428 if (!view) return; 428 if (!view) return;
429 view->contextMenuSelected(id); 429 view->contextMenuSelected(id);
430} 430}
431 431
432void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) 432void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
433{ 433{
434 if (button==1) {return;} 434 if (button==1) {return;}
435 if (!item) return; 435 if (!item) return;
436 AccountViewItem *view = static_cast<AccountViewItem *>(item); 436 AccountViewItem *view = static_cast<AccountViewItem *>(item);
437 QPopupMenu*m = view->getContextMenu(); 437 QPopupMenu*m = view->getContextMenu();
438 if (!m) return; 438 if (!m) return;
439 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 439 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
440 m->setFocus(); 440 m->setFocus();
441 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 441 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
442 delete m; 442 delete m;
443} 443}
444 444
445void AccountView::populate( QList<Account> list ) 445void AccountView::populate( QList<Account> list )
446{ 446{
447 clear(); 447 clear();
448 448
449 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 449 (void) new MBOXviewItem(AbstractMail::defaultLocalfolder(),this);
450 (void) new MBOXviewItem(localfolders,this);
451 450
452 Account *it; 451 Account *it;
453 for ( it = list.first(); it; it = list.next() ) { 452 for ( it = list.first(); it; it = list.next() ) {
454 if ( it->getType().compare( "IMAP" ) == 0 ) { 453 if ( it->getType().compare( "IMAP" ) == 0 ) {
455 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 454 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
456 qDebug( "added IMAP " + imap->getAccountName() ); 455 qDebug( "added IMAP " + imap->getAccountName() );
457 (void) new IMAPviewItem( imap, this ); 456 (void) new IMAPviewItem( imap, this );
458 } else if ( it->getType().compare( "POP3" ) == 0 ) { 457 } else if ( it->getType().compare( "POP3" ) == 0 ) {
459 POP3account *pop3 = static_cast<POP3account *>(it); 458 POP3account *pop3 = static_cast<POP3account *>(it);
460 qDebug( "added POP3 " + pop3->getAccountName() ); 459 qDebug( "added POP3 " + pop3->getAccountName() );
461 (void) new POP3viewItem( pop3, this ); 460 (void) new POP3viewItem( pop3, this );
462 } 461 }
463 } 462 }
464} 463}
465 464
466void AccountView::refresh(QListViewItem *item) { 465void AccountView::refresh(QListViewItem *item) {
467 466
468 qDebug("AccountView refresh..."); 467 qDebug("AccountView refresh...");
469 if ( item ) { 468 if ( item ) {
470 m_currentItem = item; 469 m_currentItem = item;
471 QList<RecMail> headerlist; 470 QList<RecMail> headerlist;
472 headerlist.setAutoDelete(true); 471 headerlist.setAutoDelete(true);
473 AccountViewItem *view = static_cast<AccountViewItem *>(item); 472 AccountViewItem *view = static_cast<AccountViewItem *>(item);
474 view->refresh(headerlist); 473 view->refresh(headerlist);
475 emit refreshMailview(&headerlist); 474 emit refreshMailview(&headerlist);
476 } 475 }
477} 476}
478 477
479void AccountView::refreshCurrent() 478void AccountView::refreshCurrent()
480{ 479{
481 m_currentItem = currentItem(); 480 m_currentItem = currentItem();
482 if ( !m_currentItem ) return; 481 if ( !m_currentItem ) return;
483 QList<RecMail> headerlist; 482 QList<RecMail> headerlist;
484 headerlist.setAutoDelete(true); 483 headerlist.setAutoDelete(true);
485 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 484 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
486 view->refresh(headerlist); 485 view->refresh(headerlist);
487 emit refreshMailview(&headerlist); 486 emit refreshMailview(&headerlist);
488} 487}
489 488
490void AccountView::refreshAll() 489void AccountView::refreshAll()
491{ 490{
492 491
493} 492}
494 493
495RecBody AccountView::fetchBody(const RecMail&aMail) 494RecBody AccountView::fetchBody(const RecMail&aMail)
496{ 495{
497 QListViewItem*item = selectedItem (); 496 QListViewItem*item = selectedItem ();
498 if (!item) return RecBody(); 497 if (!item) return RecBody();
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index f303d72..80d0b52 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -47,48 +47,55 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin
47 47
48 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, 48 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
49 &result_text,&target_length); 49 &result_text,&target_length);
50 50
51 encodedString* result = new encodedString(); 51 encodedString* result = new encodedString();
52 if (err == MAILIMF_NO_ERROR) { 52 if (err == MAILIMF_NO_ERROR) {
53 result->setContent(result_text,target_length); 53 result->setContent(result_text,target_length);
54 } 54 }
55 qDebug("Decode string finished"); 55 qDebug("Decode string finished");
56 return result; 56 return result;
57} 57}
58 58
59QString AbstractMail::convert_String(const char*text) 59QString AbstractMail::convert_String(const char*text)
60{ 60{
61 size_t index = 0; 61 size_t index = 0;
62 char*res = 0; 62 char*res = 0;
63 63
64 /* attention - doesn't work with arm systems! */ 64 /* attention - doesn't work with arm systems! */
65 int err = mailmime_encoded_phrase_parse("iso-8859-1", 65 int err = mailmime_encoded_phrase_parse("iso-8859-1",
66 text, strlen(text),&index, "iso-8859-1",&res); 66 text, strlen(text),&index, "iso-8859-1",&res);
67 if (err != MAILIMF_NO_ERROR) { 67 if (err != MAILIMF_NO_ERROR) {
68 if (res) free(res); 68 if (res) free(res);
69 return QString(text); 69 return QString(text);
70 } 70 }
71 if (res) { 71 if (res) {
72 QString result(res); 72 QString result(res);
73 free(res); 73 free(res);
74 return result; 74 return result;
75 } 75 }
76 return QString(text); 76 return QString(text);
77} 77}
78 78
79/* cp & paste from launcher */ 79/* cp & paste from launcher */
80QString AbstractMail::gen_attachment_id() 80QString AbstractMail::gen_attachment_id()
81{ 81{
82 QFile file( "/proc/sys/kernel/random/uuid" ); 82 QFile file( "/proc/sys/kernel/random/uuid" );
83 if (!file.open(IO_ReadOnly ) ) 83 if (!file.open(IO_ReadOnly ) )
84 return QString::null; 84 return QString::null;
85 85
86 QTextStream stream(&file); 86 QTextStream stream(&file);
87 87
88 return "{" + stream.read().stripWhiteSpace() + "}"; 88 return "{" + stream.read().stripWhiteSpace() + "}";
89} 89}
90 90
91int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) 91int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool)
92{ 92{
93 return 0; 93 return 0;
94} 94}
95
96QString AbstractMail::defaultLocalfolder()
97{
98 QString f = getenv( "HOME" );
99 f += "/Applications/opiemail/localmail";
100 return f;
101}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index dab9e10..ca9caed 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -1,53 +1,55 @@
1#ifndef __abstract_mail_ 1#ifndef __abstract_mail_
2#define __abstract_mail_ 2#define __abstract_mail_
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include "settings.h" 5#include "settings.h"
6 6
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9class RecPart; 9class RecPart;
10class IMAPwrapper; 10class IMAPwrapper;
11class POP3wrapper; 11class POP3wrapper;
12class Folder; 12class Folder;
13class encodedString; 13class encodedString;
14struct folderStat; 14struct folderStat;
15 15
16class AbstractMail:public QObject 16class AbstractMail:public QObject
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19public: 19public:
20 AbstractMail(){}; 20 AbstractMail(){};
21 virtual ~AbstractMail(){} 21 virtual ~AbstractMail(){}
22 virtual QList<Folder>* listFolders()=0; 22 virtual QList<Folder>* listFolders()=0;
23 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; 23 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
24 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; 24 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0;
25 virtual RecBody fetchBody(const RecMail&mail)=0; 25 virtual RecBody fetchBody(const RecMail&mail)=0;
26 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; 26 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
27 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; 27 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
28 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; 28 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
29 29
30 virtual void deleteMail(const RecMail&mail)=0; 30 virtual void deleteMail(const RecMail&mail)=0;
31 virtual void answeredMail(const RecMail&mail)=0; 31 virtual void answeredMail(const RecMail&mail)=0;
32 virtual void cleanMimeCache(){}; 32 virtual void cleanMimeCache(){};
33 virtual int deleteAllMail(const Folder*){return 1;} 33 virtual int deleteAllMail(const Folder*){return 1;}
34 virtual int deleteMbox(const Folder*){return 1;} 34 virtual int deleteMbox(const Folder*){return 1;}
35 35
36 /* mail box methods */ 36 /* mail box methods */
37 /* parameter is the box to create. 37 /* parameter is the box to create.
38 * if the implementing subclass has prefixes, 38 * if the implementing subclass has prefixes,
39 * them has to be appended automatic. 39 * them has to be appended automatic.
40 */ 40 */
41 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); 41 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
42 42
43 static AbstractMail* getWrapper(IMAPaccount *a); 43 static AbstractMail* getWrapper(IMAPaccount *a);
44 static AbstractMail* getWrapper(POP3account *a); 44 static AbstractMail* getWrapper(POP3account *a);
45 /* mbox only! */ 45 /* mbox only! */
46 static AbstractMail* getWrapper(const QString&a); 46 static AbstractMail* getWrapper(const QString&a);
47 47
48 static QString defaultLocalfolder();
49
48protected: 50protected:
49 static encodedString*decode_String(const encodedString*text,const QString&enc); 51 static encodedString*decode_String(const encodedString*text,const QString&enc);
50 static QString convert_String(const char*text); 52 static QString convert_String(const char*text);
51 static QString gen_attachment_id(); 53 static QString gen_attachment_id();
52}; 54};
53#endif 55#endif
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index b9c4ff2..e054365 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -1,71 +1,71 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <sys/stat.h> 2#include <sys/stat.h>
3#include <sys/types.h> 3#include <sys/types.h>
4#include <unistd.h> 4#include <unistd.h>
5#include <fcntl.h> 5#include <fcntl.h>
6#include <string.h> 6#include <string.h>
7#include <qdir.h> 7#include <qdir.h>
8#include <qt.h> 8#include <qt.h>
9 9
10#include <qpe/config.h> 10#include <qpe/config.h>
11#include <qpe/qcopenvelope_qws.h> 11#include <qpe/qcopenvelope_qws.h>
12 12
13#include <libetpan/libetpan.h> 13#include <libetpan/libetpan.h>
14 14
15#include "smtpwrapper.h" 15#include "smtpwrapper.h"
16#include "mailwrapper.h" 16#include "mailwrapper.h"
17#include "mboxwrapper.h" 17#include "mboxwrapper.h"
18#include "logindialog.h" 18#include "logindialog.h"
19#include "mailtypes.h" 19#include "mailtypes.h"
20//#include "defines.h" 20//#include "defines.h"
21#include "sendmailprogress.h" 21#include "sendmailprogress.h"
22 22
23#define USER_AGENT "OpieMail v0.1" 23const char* SMTPwrapper::USER_AGENT="OpieMail v0.3";
24 24
25progressMailSend*SMTPwrapper::sendProgress = 0; 25progressMailSend*SMTPwrapper::sendProgress = 0;
26 26
27SMTPwrapper::SMTPwrapper( Settings *s ) 27SMTPwrapper::SMTPwrapper( Settings *s )
28 : QObject() 28 : QObject()
29{ 29{
30 settings = s; 30 settings = s;
31 Config cfg( "mail" ); 31 Config cfg( "mail" );
32 cfg.setGroup( "Status" ); 32 cfg.setGroup( "Status" );
33 m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); 33 m_queuedMail = cfg.readNumEntry( "outgoing", 0 );
34 emit queuedMails( m_queuedMail ); 34 emit queuedMails( m_queuedMail );
35 connect( this, SIGNAL( queuedMails( int ) ), this, SLOT( emitQCop( int ) ) ); 35 connect( this, SIGNAL( queuedMails( int ) ), this, SLOT( emitQCop( int ) ) );
36} 36}
37 37
38void SMTPwrapper::emitQCop( int queued ) { 38void SMTPwrapper::emitQCop( int queued ) {
39 QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); 39 QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" );
40 env << queued; 40 env << queued;
41} 41}
42 42
43QString SMTPwrapper::mailsmtpError( int errnum ) 43QString SMTPwrapper::mailsmtpError( int errnum )
44{ 44{
45 switch ( errnum ) { 45 switch ( errnum ) {
46 case MAILSMTP_NO_ERROR: 46 case MAILSMTP_NO_ERROR:
47 return tr( "No error" ); 47 return tr( "No error" );
48 case MAILSMTP_ERROR_UNEXPECTED_CODE: 48 case MAILSMTP_ERROR_UNEXPECTED_CODE:
49 return tr( "Unexpected error code" ); 49 return tr( "Unexpected error code" );
50 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 50 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
51 return tr( "Service not available" ); 51 return tr( "Service not available" );
52 case MAILSMTP_ERROR_STREAM: 52 case MAILSMTP_ERROR_STREAM:
53 return tr( "Stream error" ); 53 return tr( "Stream error" );
54 case MAILSMTP_ERROR_HOSTNAME: 54 case MAILSMTP_ERROR_HOSTNAME:
55 return tr( "gethostname() failed" ); 55 return tr( "gethostname() failed" );
56 case MAILSMTP_ERROR_NOT_IMPLEMENTED: 56 case MAILSMTP_ERROR_NOT_IMPLEMENTED:
57 return tr( "Not implemented" ); 57 return tr( "Not implemented" );
58 case MAILSMTP_ERROR_ACTION_NOT_TAKEN: 58 case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
59 return tr( "Error, action not taken" ); 59 return tr( "Error, action not taken" );
60 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: 60 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
61 return tr( "Data exceeds storage allocation" ); 61 return tr( "Data exceeds storage allocation" );
62 case MAILSMTP_ERROR_IN_PROCESSING: 62 case MAILSMTP_ERROR_IN_PROCESSING:
63 return tr( "Error in processing" ); 63 return tr( "Error in processing" );
64 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: 64 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
65 // return tr( "Insufficient system storage" ); 65 // return tr( "Insufficient system storage" );
66 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: 66 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
67 return tr( "Mailbox unavailable" ); 67 return tr( "Mailbox unavailable" );
68 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: 68 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
69 return tr( "Mailbox name not allowed" ); 69 return tr( "Mailbox name not allowed" );
70 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: 70 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
71 return tr( "Bad command sequence" ); 71 return tr( "Bad command sequence" );
@@ -443,97 +443,97 @@ clist *SMTPwrapper::createRcptList( mailimf_fields *fields )
443 && field->fld_data.fld_cc->cc_addr_list ) { 443 && field->fld_data.fld_cc->cc_addr_list ) {
444 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); 444 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list );
445 } 445 }
446 446
447 field = getField( fields, MAILIMF_FIELD_BCC ); 447 field = getField( fields, MAILIMF_FIELD_BCC );
448 if ( field && (field->fld_type == MAILIMF_FIELD_BCC) 448 if ( field && (field->fld_type == MAILIMF_FIELD_BCC)
449 && field->fld_data.fld_bcc->bcc_addr_list ) { 449 && field->fld_data.fld_bcc->bcc_addr_list ) {
450 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); 450 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list );
451 } 451 }
452 452
453 return rcptList; 453 return rcptList;
454} 454}
455 455
456char *SMTPwrapper::getFrom( mailimf_field *ffrom) 456char *SMTPwrapper::getFrom( mailimf_field *ffrom)
457{ 457{
458 char *from = NULL; 458 char *from = NULL;
459 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) 459 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM)
460 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { 460 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) {
461 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; 461 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list;
462 clistiter *it; 462 clistiter *it;
463 for ( it = clist_begin( cl ); it; it = it->next ) { 463 for ( it = clist_begin( cl ); it; it = it->next ) {
464 mailimf_mailbox *mb = (mailimf_mailbox *) it->data; 464 mailimf_mailbox *mb = (mailimf_mailbox *) it->data;
465 from = strdup( mb->mb_addr_spec ); 465 from = strdup( mb->mb_addr_spec );
466 } 466 }
467 } 467 }
468 468
469 return from; 469 return from;
470} 470}
471 471
472char *SMTPwrapper::getFrom( mailmime *mail ) 472char *SMTPwrapper::getFrom( mailmime *mail )
473{ 473{
474 /* no need to delete - its just a pointer to structure content */ 474 /* no need to delete - its just a pointer to structure content */
475 mailimf_field *ffrom = 0; 475 mailimf_field *ffrom = 0;
476 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); 476 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM );
477 return getFrom(ffrom); 477 return getFrom(ffrom);
478} 478}
479 479
480void SMTPwrapper::progress( size_t current, size_t maximum ) 480void SMTPwrapper::progress( size_t current, size_t maximum )
481{ 481{
482 if (SMTPwrapper::sendProgress) { 482 if (SMTPwrapper::sendProgress) {
483 SMTPwrapper::sendProgress->setSingleMail(current, maximum ); 483 SMTPwrapper::sendProgress->setSingleMail(current, maximum );
484 qApp->processEvents(); 484 qApp->processEvents();
485 } 485 }
486} 486}
487 487
488void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) 488void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box)
489{ 489{
490 if (!mail) return; 490 if (!mail) return;
491 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 491 QString localfolders = AbstractMail::defaultLocalfolder();
492 MBOXwrapper*wrap = new MBOXwrapper(localfolders); 492 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
493 wrap->storeMessage(mail,length,box); 493 wrap->storeMessage(mail,length,box);
494 delete wrap; 494 delete wrap;
495} 495}
496 496
497void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) 497void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
498{ 498{
499 clist *rcpts = 0; 499 clist *rcpts = 0;
500 char *from, *data; 500 char *from, *data;
501 size_t size; 501 size_t size;
502 502
503 if ( smtp == NULL ) { 503 if ( smtp == NULL ) {
504 return; 504 return;
505 } 505 }
506 from = data = 0; 506 from = data = 0;
507 507
508 mailmessage * msg = 0; 508 mailmessage * msg = 0;
509 msg = mime_message_init(mail); 509 msg = mime_message_init(mail);
510 mime_message_set_tmpdir(msg,getenv( "HOME" )); 510 mime_message_set_tmpdir(msg,getenv( "HOME" ));
511 int r = mailmessage_fetch(msg,&data,&size); 511 int r = mailmessage_fetch(msg,&data,&size);
512 mime_message_detach_mime(msg); 512 mime_message_detach_mime(msg);
513 mailmessage_free(msg); 513 mailmessage_free(msg);
514 if (r != MAIL_NO_ERROR || !data) { 514 if (r != MAIL_NO_ERROR || !data) {
515 if (data) free(data); 515 if (data) free(data);
516 qDebug("Error fetching mime..."); 516 qDebug("Error fetching mime...");
517 return; 517 return;
518 } 518 }
519 QString tmp = data; 519 QString tmp = data;
520 tmp.replace(QRegExp("\r+",true,false),""); 520 tmp.replace(QRegExp("\r+",true,false),"");
521 msg = 0; 521 msg = 0;
522 if (later) { 522 if (later) {
523 storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); 523 storeMail((char*)tmp.data(),tmp.length(),"Outgoing");
524 if (data) free( data ); 524 if (data) free( data );
525 Config cfg( "mail" ); 525 Config cfg( "mail" );
526 cfg.setGroup( "Status" ); 526 cfg.setGroup( "Status" );
527 cfg.writeEntry( "outgoing", ++m_queuedMail ); 527 cfg.writeEntry( "outgoing", ++m_queuedMail );
528 emit queuedMails( m_queuedMail ); 528 emit queuedMails( m_queuedMail );
529 return; 529 return;
530 } 530 }
531 from = getFrom( mail ); 531 from = getFrom( mail );
532 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); 532 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
533 smtpSend(from,rcpts,data,size,smtp); 533 smtpSend(from,rcpts,data,size,smtp);
534 if (data) {free(data);} 534 if (data) {free(data);}
535 if (from) {free(from);} 535 if (from) {free(from);}
536 if (rcpts) smtp_address_list_free( rcpts ); 536 if (rcpts) smtp_address_list_free( rcpts );
537} 537}
538 538
539int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) 539int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp )
@@ -644,91 +644,91 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
644 size_t length = 0; 644 size_t length = 0;
645 size_t curTok = 0; 645 size_t curTok = 0;
646 mailimf_fields *fields = 0; 646 mailimf_fields *fields = 0;
647 mailimf_field*ffrom = 0; 647 mailimf_field*ffrom = 0;
648 clist *rcpts = 0; 648 clist *rcpts = 0;
649 char*from = 0; 649 char*from = 0;
650 int res = 0; 650 int res = 0;
651 651
652 wrap->fetchRawBody(*which,&data,&length); 652 wrap->fetchRawBody(*which,&data,&length);
653 if (!data) return 0; 653 if (!data) return 0;
654 int err = mailimf_fields_parse( data, length, &curTok, &fields ); 654 int err = mailimf_fields_parse( data, length, &curTok, &fields );
655 if (err != MAILIMF_NO_ERROR) { 655 if (err != MAILIMF_NO_ERROR) {
656 free(data); 656 free(data);
657 delete wrap; 657 delete wrap;
658 return 0; 658 return 0;
659 } 659 }
660 660
661 rcpts = createRcptList( fields ); 661 rcpts = createRcptList( fields );
662 ffrom = getField(fields, MAILIMF_FIELD_FROM ); 662 ffrom = getField(fields, MAILIMF_FIELD_FROM );
663 from = getFrom(ffrom); 663 from = getFrom(ffrom);
664 664
665 qDebug("Size: %i vs. %i",length,strlen(data)); 665 qDebug("Size: %i vs. %i",length,strlen(data));
666 if (rcpts && from) { 666 if (rcpts && from) {
667 res = smtpSend(from,rcpts,data,length,smtp ); 667 res = smtpSend(from,rcpts,data,length,smtp );
668 } 668 }
669 if (fields) { 669 if (fields) {
670 mailimf_fields_free(fields); 670 mailimf_fields_free(fields);
671 fields = 0; 671 fields = 0;
672 } 672 }
673 if (data) { 673 if (data) {
674 free(data); 674 free(data);
675 } 675 }
676 if (from) { 676 if (from) {
677 free(from); 677 free(from);
678 } 678 }
679 if (rcpts) { 679 if (rcpts) {
680 smtp_address_list_free( rcpts ); 680 smtp_address_list_free( rcpts );
681 } 681 }
682 return res; 682 return res;
683} 683}
684 684
685/* this is a special fun */ 685/* this is a special fun */
686bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) 686bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
687{ 687{
688 bool returnValue = true; 688 bool returnValue = true;
689 689
690 if (!smtp) return false; 690 if (!smtp) return false;
691 691
692 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 692 QString localfolders = AbstractMail::defaultLocalfolder();
693 MBOXwrapper*wrap = new MBOXwrapper(localfolders); 693 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
694 if (!wrap) { 694 if (!wrap) {
695 qDebug("memory error"); 695 qDebug("memory error");
696 return false; 696 return false;
697 } 697 }
698 QList<RecMail> mailsToSend; 698 QList<RecMail> mailsToSend;
699 QList<RecMail> mailsToRemove; 699 QList<RecMail> mailsToRemove;
700 QString mbox("Outgoing"); 700 QString mbox("Outgoing");
701 wrap->listMessages(mbox,mailsToSend); 701 wrap->listMessages(mbox,mailsToSend);
702 if (mailsToSend.count()==0) { 702 if (mailsToSend.count()==0) {
703 delete wrap; 703 delete wrap;
704 return false; 704 return false;
705 } 705 }
706 mailsToSend.setAutoDelete(false); 706 mailsToSend.setAutoDelete(false);
707 sendProgress = new progressMailSend(); 707 sendProgress = new progressMailSend();
708 sendProgress->show(); 708 sendProgress->show();
709 sendProgress->setMaxMails(mailsToSend.count()); 709 sendProgress->setMaxMails(mailsToSend.count());
710 710
711 while (mailsToSend.count()>0) { 711 while (mailsToSend.count()>0) {
712 if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { 712 if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) {
713 QMessageBox::critical(0,tr("Error sending mail"), 713 QMessageBox::critical(0,tr("Error sending mail"),
714 tr("Error sending queued mail - breaking")); 714 tr("Error sending queued mail - breaking"));
715 returnValue = false; 715 returnValue = false;
716 break; 716 break;
717 } 717 }
718 mailsToRemove.append(mailsToSend.at(0)); 718 mailsToRemove.append(mailsToSend.at(0));
719 mailsToSend.removeFirst(); 719 mailsToSend.removeFirst();
720 sendProgress->setCurrentMails(mailsToRemove.count()); 720 sendProgress->setCurrentMails(mailsToRemove.count());
721 } 721 }
722 Config cfg( "mail" ); 722 Config cfg( "mail" );
723 cfg.setGroup( "Status" ); 723 cfg.setGroup( "Status" );
724 m_queuedMail = 0; 724 m_queuedMail = 0;
725 cfg.writeEntry( "outgoing", m_queuedMail ); 725 cfg.writeEntry( "outgoing", m_queuedMail );
726 emit queuedMails( m_queuedMail ); 726 emit queuedMails( m_queuedMail );
727 sendProgress->hide(); 727 sendProgress->hide();
728 delete sendProgress; 728 delete sendProgress;
729 sendProgress = 0; 729 sendProgress = 0;
730 wrap->deleteMails(mbox,mailsToRemove); 730 wrap->deleteMails(mbox,mailsToRemove);
731 mailsToSend.setAutoDelete(true); 731 mailsToSend.setAutoDelete(true);
732 delete wrap; 732 delete wrap;
733 return returnValue; 733 return returnValue;
734} 734}
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h
index 05becf2..4a4352f 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h
@@ -17,55 +17,56 @@ struct mailimf_fields;
17struct mailimf_field; 17struct mailimf_field;
18struct mailimf_mailbox; 18struct mailimf_mailbox;
19struct mailmime; 19struct mailmime;
20struct mailimf_address_list; 20struct mailimf_address_list;
21class progressMailSend; 21class progressMailSend;
22 22
23class SMTPwrapper : public QObject 23class SMTPwrapper : public QObject
24{ 24{
25 Q_OBJECT 25 Q_OBJECT
26 26
27public: 27public:
28 SMTPwrapper( Settings *s ); 28 SMTPwrapper( Settings *s );
29 virtual ~SMTPwrapper(){} 29 virtual ~SMTPwrapper(){}
30 void sendMail(const Mail& mail,SMTPaccount*smtp,bool later=false ); 30 void sendMail(const Mail& mail,SMTPaccount*smtp,bool later=false );
31 bool flushOutbox(SMTPaccount*smtp); 31 bool flushOutbox(SMTPaccount*smtp);
32 32
33 static progressMailSend*sendProgress; 33 static progressMailSend*sendProgress;
34 34
35signals: 35signals:
36 void queuedMails( int ); 36 void queuedMails( int );
37 37
38protected: 38protected:
39 mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); 39 mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
40 mailimf_fields *createImfFields(const Mail &mail ); 40 mailimf_fields *createImfFields(const Mail &mail );
41 mailmime *createMimeMail(const Mail&mail ); 41 mailmime *createMimeMail(const Mail&mail );
42 42
43 mailimf_address_list *parseAddresses(const QString&addr ); 43 mailimf_address_list *parseAddresses(const QString&addr );
44 void addFileParts( mailmime *message,const QList<Attachment>&files ); 44 void addFileParts( mailmime *message,const QList<Attachment>&files );
45 mailmime *buildTxtPart(const QString&str ); 45 mailmime *buildTxtPart(const QString&str );
46 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); 46 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content);
47 void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); 47 void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp );
48 clist *createRcptList( mailimf_fields *fields ); 48 clist *createRcptList( mailimf_fields *fields );
49 49
50 static void storeMail(char*mail, size_t length, const QString&box); 50 static void storeMail(char*mail, size_t length, const QString&box);
51 static QString mailsmtpError( int err ); 51 static QString mailsmtpError( int err );
52 static void progress( size_t current, size_t maximum ); 52 static void progress( size_t current, size_t maximum );
53 static void addRcpts( clist *list, mailimf_address_list *addr_list ); 53 static void addRcpts( clist *list, mailimf_address_list *addr_list );
54 static char *getFrom( mailmime *mail ); 54 static char *getFrom( mailmime *mail );
55 static char *getFrom( mailimf_field *ffrom); 55 static char *getFrom( mailimf_field *ffrom);
56 static mailimf_field *getField( mailimf_fields *fields, int type ); 56 static mailimf_field *getField( mailimf_fields *fields, int type );
57 int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); 57 int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp );
58 58
59 void storeMail(mailmime*mail, const QString&box); 59 void storeMail(mailmime*mail, const QString&box);
60 Settings *settings; 60 Settings *settings;
61 61
62 int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); 62 int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which);
63 63
64 int m_queuedMail; 64 int m_queuedMail;
65 static const char* USER_AGENT;
65 66
66protected slots: 67protected slots:
67 void emitQCop( int queued ); 68 void emitQCop( int queued );
68 69
69}; 70};
70 71
71#endif 72#endif