-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,5 +1,3 @@ #include "accountview.h" -#include "imapwrapper.h" -#include "pop3wrapper.h" #include "mailtypes.h" #include "defines.h" @@ -14,5 +12,5 @@ POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) { account = a; - wrapper = new POP3wrapper( account ); + wrapper = AbstractMail::getWrapper( account ); setPixmap( 0, PIXMAP_POP3FOLDER ); setText( 0, account->getAccountName() ); @@ -27,5 +25,5 @@ void POP3viewItem::refresh( QList<RecMail> &target ) { qDebug( "POP3: refresh" ); - wrapper->listMessages( target ); + wrapper->listMessages("INBOX", target ); } @@ -45,5 +43,5 @@ IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) { account = a; - wrapper = new IMAPwrapper( account ); + wrapper = AbstractMail::getWrapper( account ); setPixmap( 0, PIXMAP_IMAPFOLDER ); setText( 0, account->getAccountName() ); @@ -56,5 +54,5 @@ IMAPviewItem::~IMAPviewItem() } -IMAPwrapper *IMAPviewItem::getWrapper() +AbstractMail *IMAPviewItem::getWrapper() { return wrapper; @@ -63,5 +61,5 @@ IMAPwrapper *IMAPviewItem::getWrapper() void IMAPviewItem::refresh(QList<RecMail>&) { - QList<IMAPFolder> *folders = wrapper->listFolders(); + QList<Folder> *folders = wrapper->listFolders(); QListViewItem *child = firstChild(); @@ -72,5 +70,5 @@ void IMAPviewItem::refresh(QList<RecMail>&) } - IMAPFolder *it; + Folder *it; for ( it = folders->first(); it; it = folders->next() ) { (void) new IMAPfolderItem( it, this ); @@ -88,5 +86,5 @@ IMAPfolderItem::~IMAPfolderItem() } -IMAPfolderItem::IMAPfolderItem( IMAPFolder *folderInit, IMAPviewItem *parent ) +IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent ) : AccountViewItem( 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 @@ -7,6 +7,6 @@ #include "settings.h" #include "mailwrapper.h" +#include "abstractmail.h" -class IMAPwrapper; class POP3wrapper; class RecMail; @@ -34,5 +34,5 @@ public: private: POP3account *account; - POP3wrapper *wrapper; + AbstractMail *wrapper; }; @@ -46,10 +46,8 @@ public: virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); - IMAPwrapper *getWrapper(); - + AbstractMail *getWrapper(); private: IMAPaccount *account; - IMAPwrapper *wrapper; - + AbstractMail *wrapper; }; @@ -58,11 +56,10 @@ 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 @@ -7,4 +7,5 @@ IMAPwrapper::IMAPwrapper( IMAPaccount *a ) + : AbstractMail() { account = a; @@ -140,5 +141,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) } -QList<IMAPFolder>* IMAPwrapper::listFolders() +QList<Folder>* IMAPwrapper::listFolders() { const char *path, *mask; @@ -147,5 +148,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() clistcell *current; - QList<IMAPFolder> * folders = new QList<IMAPFolder>(); + QList<Folder> * folders = new QList<Folder>(); folders->setAutoDelete( true ); login(); 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 @@ -4,4 +4,5 @@ #include <qlist.h> #include "mailwrapper.h" +#include "abstractmail.h" struct mailimap; @@ -13,20 +14,16 @@ 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 ); 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 @@ -7,4 +7,5 @@ IMAPwrapper::IMAPwrapper( IMAPaccount *a ) + : AbstractMail() { account = a; @@ -140,5 +141,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) } -QList<IMAPFolder>* IMAPwrapper::listFolders() +QList<Folder>* IMAPwrapper::listFolders() { const char *path, *mask; @@ -147,5 +148,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() clistcell *current; - QList<IMAPFolder> * folders = new QList<IMAPFolder>(); + QList<Folder> * folders = new QList<Folder>(); folders->setAutoDelete( true ); login(); 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 @@ -4,4 +4,5 @@ #include <qlist.h> #include "mailwrapper.h" +#include "abstractmail.h" struct mailimap; @@ -13,20 +14,16 @@ 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 ); 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 @@ -60,5 +60,5 @@ RecBody POP3wrapper::parseBody( const char *message ) } -void POP3wrapper::listMessages( QList<RecMail> &target ) +void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { int err = MAILPOP3_NO_ERROR; @@ -269,2 +269,21 @@ void POP3wrapper::logout() } + +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 @@ -3,4 +3,5 @@ #include "mailwrapper.h" +#include "abstractmail.h" class RecMail; @@ -8,5 +9,5 @@ class RecBody; struct mailpop3; -class POP3wrapper : public QObject +class POP3wrapper : public AbstractMail { Q_OBJECT @@ -15,5 +16,10 @@ 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 ); @@ -33,5 +39,4 @@ private: POP3account *account; mailpop3 *m_pop3; - }; 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 @@ -15,5 +15,6 @@ HEADERS = defines.h \ mailtypes.h \ mailistviewitem.h \ - pop3wrapper.h + pop3wrapper.h \ + abstractmail.h SOURCES = main.cpp \ @@ -31,5 +32,6 @@ SOURCES = main.cpp \ settings.cpp \ mailtypes.cpp \ - pop3wrapper.cpp + pop3wrapper.cpp \ + abstractmail.cpp INTERFACES = editaccountsui.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 @@ -19,5 +19,4 @@ class MainWindow : public QMainWindow public: MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); - static QString appName() { return QString::fromLatin1("opiemail"); } public slots: 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 @@ -11,7 +11,5 @@ class OpieMail : public MainWindow 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(); 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 @@ -60,5 +60,5 @@ RecBody POP3wrapper::parseBody( const char *message ) } -void POP3wrapper::listMessages( QList<RecMail> &target ) +void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { int err = MAILPOP3_NO_ERROR; @@ -269,2 +269,21 @@ void POP3wrapper::logout() } + +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 @@ -3,4 +3,5 @@ #include "mailwrapper.h" +#include "abstractmail.h" class RecMail; @@ -8,5 +9,5 @@ class RecBody; struct mailpop3; -class POP3wrapper : public QObject +class POP3wrapper : public AbstractMail { Q_OBJECT @@ -15,5 +16,10 @@ 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 ); @@ -33,5 +39,4 @@ private: POP3account *account; mailpop3 *m_pop3; - }; |