author | alwin <alwin> | 2003-12-13 20:39:07 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-13 20:39:07 (UTC) |
commit | 85444223acfafd9d7955032b2cbdad3279ba27ad (patch) (side-by-side diff) | |
tree | 444063490a58ffc7ca085219827a577ad6213442 | |
parent | d161cb46c21ae6a9e9f74dc60fb6ac6ac8e62f1b (diff) | |
download | opie-85444223acfafd9d7955032b2cbdad3279ba27ad.zip opie-85444223acfafd9d7955032b2cbdad3279ba27ad.tar.gz opie-85444223acfafd9d7955032b2cbdad3279ba27ad.tar.bz2 |
imap/pop3 wrapper uses base virtual class so we can forward the pointer
independend of its later use.
ToDo: find a more general interface for it
-rw-r--r-- | noncore/net/mail/abstractmail.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/abstractmail.h | 30 | ||||
-rw-r--r-- | noncore/net/mail/accountview.cpp | 16 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 15 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 5 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.h | 17 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 30 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 5 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 17 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 21 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 11 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 6 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 21 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.h | 11 |
17 files changed, 180 insertions, 56 deletions
diff --git a/noncore/net/mail/abstractmail.cpp b/noncore/net/mail/abstractmail.cpp new file mode 100644 index 0000000..7380c31 --- a/dev/null +++ b/noncore/net/mail/abstractmail.cpp @@ -0,0 +1,13 @@ +#include "abstractmail.h" +#include "imapwrapper.h" +#include "pop3wrapper.h" + +AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) +{ + return new IMAPwrapper(a); +} + +AbstractMail* AbstractMail::getWrapper(POP3account *a) +{ + return new POP3wrapper(a); +} diff --git a/noncore/net/mail/abstractmail.h b/noncore/net/mail/abstractmail.h new file mode 100644 index 0000000..bc8938f --- a/dev/null +++ b/noncore/net/mail/abstractmail.h @@ -0,0 +1,30 @@ +#ifndef __abstract_mail_ +#define __abstract_mail_ + +#include <qobject.h> +#include "settings.h" + +class RecMail; +class RecBody; +class RecPart; +class IMAPwrapper; +class POP3wrapper; +class Folder; + +class AbstractMail:public QObject +{ + Q_OBJECT +public: + AbstractMail(){}; + virtual ~AbstractMail(){} + virtual QList<Folder>* listFolders()=0; + virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; + virtual RecBody fetchBody(const RecMail&mail)=0; + virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false)=0; + virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0; + + static AbstractMail* getWrapper(IMAPaccount *a); + static AbstractMail* getWrapper(POP3account *a); +}; + +#endif diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index c7b1eeb..1069b9f 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -1,7 +1,5 @@ #include "accountview.h" -#include "imapwrapper.h" -#include "pop3wrapper.h" #include "mailtypes.h" #include "defines.h" @@ -12,9 +10,9 @@ POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) : AccountViewItem( parent ) { account = a; - wrapper = new POP3wrapper( account ); + wrapper = AbstractMail::getWrapper( account ); setPixmap( 0, PIXMAP_POP3FOLDER ); setText( 0, account->getAccountName() ); } @@ -25,9 +23,9 @@ POP3viewItem::~POP3viewItem() void POP3viewItem::refresh( QList<RecMail> &target ) { qDebug( "POP3: refresh" ); - wrapper->listMessages( target ); + wrapper->listMessages("INBOX", target ); } RecBody POP3viewItem::fetchBody( const RecMail &mail ) @@ -43,9 +41,9 @@ RecBody POP3viewItem::fetchBody( const RecMail &mail ) IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) : AccountViewItem( parent ) { account = a; - wrapper = new IMAPwrapper( account ); + wrapper = AbstractMail::getWrapper( account ); setPixmap( 0, PIXMAP_IMAPFOLDER ); setText( 0, account->getAccountName() ); setOpen( true ); } @@ -54,25 +52,25 @@ IMAPviewItem::~IMAPviewItem() { delete wrapper; } -IMAPwrapper *IMAPviewItem::getWrapper() +AbstractMail *IMAPviewItem::getWrapper() { return wrapper; } void IMAPviewItem::refresh(QList<RecMail>&) { - QList<IMAPFolder> *folders = wrapper->listFolders(); + QList<Folder> *folders = wrapper->listFolders(); QListViewItem *child = firstChild(); while ( child ) { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } - IMAPFolder *it; + Folder *it; for ( it = folders->first(); it; it = folders->next() ) { (void) new IMAPfolderItem( it, this ); } } @@ -86,9 +84,9 @@ IMAPfolderItem::~IMAPfolderItem() { delete folder; } -IMAPfolderItem::IMAPfolderItem( IMAPFolder *folderInit, IMAPviewItem *parent ) +IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent ) : AccountViewItem( parent ) { folder = folderInit; imap = parent; diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 4cac673..83d49af 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h @@ -5,10 +5,10 @@ #include <qlist.h> #include "settings.h" #include "mailwrapper.h" +#include "abstractmail.h" -class IMAPwrapper; class POP3wrapper; class RecMail; class RecBody; @@ -32,9 +32,9 @@ public: virtual RecBody fetchBody( const RecMail &mail ); private: POP3account *account; - POP3wrapper *wrapper; + AbstractMail *wrapper; }; class IMAPviewItem : public AccountViewItem @@ -44,27 +44,24 @@ public: IMAPviewItem( IMAPaccount *a, QListView *parent ); ~IMAPviewItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); - IMAPwrapper *getWrapper(); - + AbstractMail *getWrapper(); private: IMAPaccount *account; - IMAPwrapper *wrapper; - + AbstractMail *wrapper; }; class IMAPfolderItem : public AccountViewItem { public: - IMAPfolderItem( IMAPFolder *folder, IMAPviewItem *parent ); + IMAPfolderItem( Folder *folder, IMAPviewItem *parent ); ~IMAPfolderItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); - private: - IMAPFolder *folder; + Folder *folder; IMAPviewItem *imap; }; diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index 48e476b..e5eb335 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp @@ -5,8 +5,9 @@ #include "mailtypes.h" #include <libetpan/mailimap.h> IMAPwrapper::IMAPwrapper( IMAPaccount *a ) + : AbstractMail() { account = a; m_imap = 0; } @@ -138,16 +139,16 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) } mailimap_fetch_list_free(result); } -QList<IMAPFolder>* IMAPwrapper::listFolders() +QList<Folder>* IMAPwrapper::listFolders() { const char *path, *mask; int err = MAILIMAP_NO_ERROR; clist *result; clistcell *current; - QList<IMAPFolder> * folders = new QList<IMAPFolder>(); + QList<Folder> * folders = new QList<Folder>(); folders->setAutoDelete( true ); login(); if (!m_imap) { return folders; diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h index 95de215..f88457a 100644 --- a/noncore/net/mail/imapwrapper.h +++ b/noncore/net/mail/imapwrapper.h @@ -2,8 +2,9 @@ #define __IMAPWRAPPER #include <qlist.h> #include "mailwrapper.h" +#include "abstractmail.h" struct mailimap; struct mailimap_body_type_1part; struct mailimap_body_type_text; @@ -11,24 +12,20 @@ struct mailimap_body_type_basic; struct mailimap_body_type_msg; struct mailimap_body_type_mpart; struct mailimap_body_fields; struct mailimap_msg_att; -class RecMail; -class RecBody; -class RecPart; -class IMAPwrapper : public QObject +class IMAPwrapper : public AbstractMail { Q_OBJECT - public: IMAPwrapper( IMAPaccount *a ); virtual ~IMAPwrapper(); - QList<IMAPFolder>* listFolders(); - void listMessages(const QString & mailbox,QList<RecMail>&target ); - RecBody fetchBody(const RecMail&mail); - QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); - QString fetchPart(const RecMail&mail,const RecPart&part); + virtual QList<Folder>* listFolders(); + virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); + virtual RecBody fetchBody(const RecMail&mail); + virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); + virtual QString fetchPart(const RecMail&mail,const RecPart&part); static void imap_progress( size_t current, size_t maximum ); protected: RecMail*parse_list_result(mailimap_msg_att*); diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp new file mode 100644 index 0000000..7380c31 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp @@ -0,0 +1,13 @@ +#include "abstractmail.h" +#include "imapwrapper.h" +#include "pop3wrapper.h" + +AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) +{ + return new IMAPwrapper(a); +} + +AbstractMail* AbstractMail::getWrapper(POP3account *a) +{ + return new POP3wrapper(a); +} diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h new file mode 100644 index 0000000..bc8938f --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/abstractmail.h @@ -0,0 +1,30 @@ +#ifndef __abstract_mail_ +#define __abstract_mail_ + +#include <qobject.h> +#include "settings.h" + +class RecMail; +class RecBody; +class RecPart; +class IMAPwrapper; +class POP3wrapper; +class Folder; + +class AbstractMail:public QObject +{ + Q_OBJECT +public: + AbstractMail(){}; + virtual ~AbstractMail(){} + virtual QList<Folder>* listFolders()=0; + virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; + virtual RecBody fetchBody(const RecMail&mail)=0; + virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false)=0; + virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0; + + static AbstractMail* getWrapper(IMAPaccount *a); + static AbstractMail* getWrapper(POP3account *a); +}; + +#endif diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 48e476b..e5eb335 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp @@ -5,8 +5,9 @@ #include "mailtypes.h" #include <libetpan/mailimap.h> IMAPwrapper::IMAPwrapper( IMAPaccount *a ) + : AbstractMail() { account = a; m_imap = 0; } @@ -138,16 +139,16 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) } mailimap_fetch_list_free(result); } -QList<IMAPFolder>* IMAPwrapper::listFolders() +QList<Folder>* IMAPwrapper::listFolders() { const char *path, *mask; int err = MAILIMAP_NO_ERROR; clist *result; clistcell *current; - QList<IMAPFolder> * folders = new QList<IMAPFolder>(); + QList<Folder> * folders = new QList<Folder>(); folders->setAutoDelete( true ); login(); if (!m_imap) { return folders; diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 95de215..f88457a 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h @@ -2,8 +2,9 @@ #define __IMAPWRAPPER #include <qlist.h> #include "mailwrapper.h" +#include "abstractmail.h" struct mailimap; struct mailimap_body_type_1part; struct mailimap_body_type_text; @@ -11,24 +12,20 @@ struct mailimap_body_type_basic; struct mailimap_body_type_msg; struct mailimap_body_type_mpart; struct mailimap_body_fields; struct mailimap_msg_att; -class RecMail; -class RecBody; -class RecPart; -class IMAPwrapper : public QObject +class IMAPwrapper : public AbstractMail { Q_OBJECT - public: IMAPwrapper( IMAPaccount *a ); virtual ~IMAPwrapper(); - QList<IMAPFolder>* listFolders(); - void listMessages(const QString & mailbox,QList<RecMail>&target ); - RecBody fetchBody(const RecMail&mail); - QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); - QString fetchPart(const RecMail&mail,const RecPart&part); + virtual QList<Folder>* listFolders(); + virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); + virtual RecBody fetchBody(const RecMail&mail); + virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); + virtual QString fetchPart(const RecMail&mail,const RecPart&part); static void imap_progress( size_t current, size_t maximum ); protected: RecMail*parse_list_result(mailimap_msg_att*); diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index abb5a42..49c3b7a 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp @@ -58,9 +58,9 @@ RecBody POP3wrapper::parseBody( const char *message ) return body; } -void POP3wrapper::listMessages( QList<RecMail> &target ) +void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { int err = MAILPOP3_NO_ERROR; char *header; size_t length; @@ -267,4 +267,23 @@ void POP3wrapper::logout() mailpop3_free( m_pop3 ); m_pop3 = NULL; } + +QList<Folder>* POP3wrapper::listFolders() +{ + QList<Folder> * folders = new QList<Folder>(); + folders->setAutoDelete( true ); + Folder*inb=new Folder("INBOX"); + folders->append(inb); + return folders; +} + +QString POP3wrapper::fetchPart(const RecMail&,const QValueList<int>&,bool) +{ + return ""; +} + +QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) +{ + return ""; +} diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index 995bed0..3b24564 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h @@ -1,21 +1,27 @@ #ifndef __POP3WRAPPER #define __POP3WRAPPER #include "mailwrapper.h" +#include "abstractmail.h" class RecMail; class RecBody; struct mailpop3; -class POP3wrapper : public QObject +class POP3wrapper : public AbstractMail { Q_OBJECT public: POP3wrapper( POP3account *a ); virtual ~POP3wrapper(); - void listMessages( QList<RecMail> &target ); + /* mailbox will be ignored */ + virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); + virtual QList<Folder>* listFolders(); + virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); + virtual QString fetchPart(const RecMail&mail,const RecPart&part); + RecBody fetchBody( const RecMail &mail ); static void pop3_progress( size_t current, size_t maximum ); protected: @@ -31,8 +37,7 @@ private: QString parseAddressList( mailimf_address_list *list ); QString parseDateTime( mailimf_date_time *date ); POP3account *account; mailpop3 *m_pop3; - }; #endif diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index 0e7cff6..e7519c6 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro @@ -13,9 +13,10 @@ HEADERS = defines.h \ opiemail.h \ imapwrapper.h \ mailtypes.h \ mailistviewitem.h \ - pop3wrapper.h + pop3wrapper.h \ + abstractmail.h SOURCES = main.cpp \ opiemail.cpp \ mainwindow.cpp \ @@ -29,9 +30,10 @@ SOURCES = main.cpp \ viewmail.cpp \ viewmailbase.cpp \ settings.cpp \ mailtypes.cpp \ - pop3wrapper.cpp + pop3wrapper.cpp \ + abstractmail.cpp INTERFACES = editaccountsui.ui \ selectmailtypeui.ui \ imapconfigui.ui \ diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index 74bce5a..6c1cda0 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h @@ -17,9 +17,8 @@ class MainWindow : public QMainWindow Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); - static QString appName() { return QString::fromLatin1("opiemail"); } public slots: void slotAdjustColumns(); diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h index dcab47c..7bcd818 100644 --- a/noncore/net/mail/opiemail.h +++ b/noncore/net/mail/opiemail.h @@ -9,11 +9,9 @@ class OpieMail : public MainWindow Q_OBJECT public: OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); - - static QString appName() { return QString::fromLatin1("opiemail"); } - + static QString appName() { return QString::fromLatin1("opiemail"); } protected slots: void slotComposeMail(); void slotSendQueued(); void slotSearchMails(); diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp index abb5a42..49c3b7a 100644 --- a/noncore/net/mail/pop3wrapper.cpp +++ b/noncore/net/mail/pop3wrapper.cpp @@ -58,9 +58,9 @@ RecBody POP3wrapper::parseBody( const char *message ) return body; } -void POP3wrapper::listMessages( QList<RecMail> &target ) +void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { int err = MAILPOP3_NO_ERROR; char *header; size_t length; @@ -267,4 +267,23 @@ void POP3wrapper::logout() mailpop3_free( m_pop3 ); m_pop3 = NULL; } + +QList<Folder>* POP3wrapper::listFolders() +{ + QList<Folder> * folders = new QList<Folder>(); + folders->setAutoDelete( true ); + Folder*inb=new Folder("INBOX"); + folders->append(inb); + return folders; +} + +QString POP3wrapper::fetchPart(const RecMail&,const QValueList<int>&,bool) +{ + return ""; +} + +QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) +{ + return ""; +} diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h index 995bed0..3b24564 100644 --- a/noncore/net/mail/pop3wrapper.h +++ b/noncore/net/mail/pop3wrapper.h @@ -1,21 +1,27 @@ #ifndef __POP3WRAPPER #define __POP3WRAPPER #include "mailwrapper.h" +#include "abstractmail.h" class RecMail; class RecBody; struct mailpop3; -class POP3wrapper : public QObject +class POP3wrapper : public AbstractMail { Q_OBJECT public: POP3wrapper( POP3account *a ); virtual ~POP3wrapper(); - void listMessages( QList<RecMail> &target ); + /* mailbox will be ignored */ + virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); + virtual QList<Folder>* listFolders(); + virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); + virtual QString fetchPart(const RecMail&mail,const RecPart&part); + RecBody fetchBody( const RecMail &mail ); static void pop3_progress( size_t current, size_t maximum ); protected: @@ -31,8 +37,7 @@ private: QString parseAddressList( mailimf_address_list *list ); QString parseDateTime( mailimf_date_time *date ); POP3account *account; mailpop3 *m_pop3; - }; #endif |