author | alwin <alwin> | 2004-01-04 12:22:24 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-04 12:22:24 (UTC) |
commit | 1f04dc232d4c0ddd17fc49b6c779bd6b97678e0a (patch) (unidiff) | |
tree | 89e3a13e8dd806c82a0b25d6fd0d06ff7442272c | |
parent | ae4774bdbbe1e6c28f8e4238c5a98d1fb6677880 (diff) | |
download | opie-1f04dc232d4c0ddd17fc49b6c779bd6b97678e0a.zip opie-1f04dc232d4c0ddd17fc49b6c779bd6b97678e0a.tar.gz opie-1f04dc232d4c0ddd17fc49b6c779bd6b97678e0a.tar.bz2 |
some cleanups
-rw-r--r-- | noncore/net/mail/accountview.cpp | 5 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.h | 1 |
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,19 +1,19 @@ | |||
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 | */ |
12 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) | 12 | POP3viewItem::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 ); |
@@ -433,34 +433,33 @@ void 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 | ||
445 | void AccountView::populate( QList<Account> list ) | 445 | void 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 | ||
466 | void AccountView::refresh(QListViewItem *item) { | 465 | void AccountView::refresh(QListViewItem *item) { |
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 | |||
@@ -79,16 +79,23 @@ QString AbstractMail::convert_String(const char*text) | |||
79 | /* cp & paste from launcher */ | 79 | /* cp & paste from launcher */ |
80 | QString AbstractMail::gen_attachment_id() | 80 | QString 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 | ||
91 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) | 91 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) |
92 | { | 92 | { |
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
95 | |||
96 | QString 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 | |||
@@ -32,22 +32,24 @@ public: | |||
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 | |||
48 | protected: | 50 | protected: |
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 | |||
@@ -7,33 +7,33 @@ | |||
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" | 23 | const char* SMTPwrapper::USER_AGENT="OpieMail v0.3"; |
24 | 24 | ||
25 | progressMailSend*SMTPwrapper::sendProgress = 0; | 25 | progressMailSend*SMTPwrapper::sendProgress = 0; |
26 | 26 | ||
27 | SMTPwrapper::SMTPwrapper( Settings *s ) | 27 | SMTPwrapper::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 | ||
38 | void SMTPwrapper::emitQCop( int queued ) { | 38 | void SMTPwrapper::emitQCop( int queued ) { |
39 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); | 39 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); |
@@ -475,33 +475,33 @@ char *SMTPwrapper::getFrom( mailmime *mail ) | |||
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 | ||
480 | void SMTPwrapper::progress( size_t current, size_t maximum ) | 480 | void 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 | ||
488 | void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) | 488 | void 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 | ||
497 | void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) | 497 | void 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 | ||
@@ -676,33 +676,33 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) | |||
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 */ |
686 | bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) | 686 | bool 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(); |
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 | |||
@@ -49,23 +49,24 @@ protected: | |||
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 | ||
66 | protected slots: | 67 | protected slots: |
67 | void emitQCop( int queued ); | 68 | void emitQCop( int queued ); |
68 | 69 | ||
69 | }; | 70 | }; |
70 | 71 | ||
71 | #endif | 72 | #endif |