-rw-r--r-- | noncore/net/mail/accountview.cpp | 212 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 69 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.h | 5 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 10 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/selectstore.cpp | 53 | ||||
-rw-r--r-- | noncore/net/mail/selectstore.h | 18 | ||||
-rw-r--r-- | noncore/net/mail/selectstoreui.ui | 43 |
17 files changed, 403 insertions, 66 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index faa6982..eea021f 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -11,5 +11,5 @@ * POP3 Account stuff */ -POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) +POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) : AccountViewItem( parent ) { @@ -33,4 +33,5 @@ AbstractMail *POP3viewItem::getWrapper() void POP3viewItem::refresh( QList<RecMail> & ) { + if (account->getOffline()) return; QList<Folder> *folders = wrapper->listFolders(); QListViewItem *child = firstChild(); @@ -57,4 +58,50 @@ RecBody POP3viewItem::fetchBody( const RecMail &mail ) } +QPopupMenu * POP3viewItem::getContextMenu() +{ + QPopupMenu *m = new QPopupMenu(0); + if (m) { + if (!account->getOffline()) { + m->insertItem(QObject::tr("Disconnect",contextName),0); + m->insertItem(QObject::tr("Set offline",contextName),1); + } else { + m->insertItem(QObject::tr("Set online",contextName),1); + } + } + return m; +} + +void POP3viewItem::disconnect() +{ + QListViewItem *child = firstChild(); + while ( child ) { + QListViewItem *tmp = child; + child = child->nextSibling(); + delete tmp; + } + wrapper->logout(); +} + +void POP3viewItem::setOnOffline() +{ + if (!account->getOffline()) { + disconnect(); + } + account->setOffline(!account->getOffline()); + account->save(); +} + +void POP3viewItem::contextMenuSelected(int which) +{ + switch (which) { + case 0: + disconnect(); + break; + case 1: + setOnOffline(); + break; + } +} + POP3folderItem::~POP3folderItem() { @@ -92,5 +139,5 @@ QPopupMenu * POP3folderItem::getContextMenu() m->insertItem(QObject::tr("Refresh header list",contextName),0); m->insertItem(QObject::tr("Delete all mails",contextName),1); - m->insertItem(QObject::tr("Download all mails",contextName),2); + m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); } return m; @@ -99,7 +146,7 @@ QPopupMenu * POP3folderItem::getContextMenu() void POP3folderItem::downloadMails() { - Selectstore sels; - sels.showMaximized(); - sels.exec(); + AccountView*bl = pop3->accountView(); + if (!bl) return; + bl->downloadMails(folder,pop3->getWrapper()); } @@ -127,5 +174,5 @@ void POP3folderItem::contextMenuSelected(int which) * IMAP Account stuff */ -IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) +IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) : AccountViewItem( parent ) { @@ -184,10 +231,16 @@ void IMAPviewItem::removeChilds() } +const QStringList&IMAPviewItem::subFolders() +{ + return currentFolders; +} + void IMAPviewItem::refreshFolders(bool force) { if (childCount()>0 && force==false) return; + if (account->getOffline()) return; removeChilds(); - + currentFolders.clear(); QList<Folder> *folders = wrapper->listFolders(); @@ -210,4 +263,5 @@ void IMAPviewItem::refreshFolders(bool force) for ( it = folders->first(); it; it = folders->next() ) { fname = it->getDisplayName(); + currentFolders.append(it->getName()); pos = fname.findRev(it->Separator()); if (pos != -1) { @@ -232,8 +286,13 @@ QPopupMenu * IMAPviewItem::getContextMenu() QPopupMenu *m = new QPopupMenu(0); if (m) { + if (!account->getOffline()) { m->insertItem(QObject::tr("Refresh folder list",contextName),0); m->insertItem(QObject::tr("Create new folder",contextName),1); m->insertSeparator(); m->insertItem(QObject::tr("Disconnect",contextName),2); + m->insertItem(QObject::tr("Set offline",contextName),3); + } else { + m->insertItem(QObject::tr("Set online",contextName),3); + } } return m; @@ -272,4 +331,13 @@ void IMAPviewItem::contextMenuSelected(int id) wrapper->logout(); break; + case 3: + if (account->getOffline()==false) { + removeChilds(); + wrapper->logout(); + } + account->setOffline(!account->getOffline()); + account->save(); + refreshFolders(false); + break; default: break; @@ -282,7 +350,7 @@ RecBody IMAPviewItem::fetchBody(const RecMail&) } -IMAPfolderItem::~IMAPfolderItem() +bool IMAPviewItem::offline() { - delete folder; + return account->getOffline(); } @@ -313,4 +381,9 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QLi } +IMAPfolderItem::~IMAPfolderItem() +{ + delete folder; +} + const QString& IMAPfolderItem::Delemiter()const { @@ -343,4 +416,5 @@ QPopupMenu * IMAPfolderItem::getContextMenu() if (folder->may_select()) { m->insertItem(QObject::tr("Refresh header list",contextName),0); + m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); m->insertItem(QObject::tr("Delete all mails",contextName),1); } @@ -390,4 +464,11 @@ void IMAPfolderItem::deleteFolder() } +void IMAPfolderItem::downloadMails() +{ + AccountView*bl = imap->accountView(); + if (!bl) return; + bl->downloadMails(folder,imap->getWrapper()); +} + void IMAPfolderItem::contextMenuSelected(int id) { @@ -407,4 +488,7 @@ void IMAPfolderItem::contextMenuSelected(int id) deleteFolder(); break; + case 4: + downloadMails(); + break; default: break; @@ -418,4 +502,31 @@ void IMAPfolderItem::contextMenuSelected(int id) const QString AccountViewItem::contextName="AccountViewItem"; +AccountViewItem::AccountViewItem( AccountView *parent ) + : QListViewItem( parent ) +{ + m_Backlink = parent; +} + +AccountViewItem::AccountViewItem( QListViewItem *parent) + : QListViewItem( parent) +{ + m_Backlink = 0; +} + +AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) + :QListViewItem( parent,after ) +{ + m_Backlink = 0; +} + +AccountViewItem::~AccountViewItem() +{ +} + +AccountView*AccountViewItem::accountView() +{ + return m_Backlink; +} + void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) { @@ -448,4 +559,10 @@ AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) } +AccountView::~AccountView() +{ + imapAccounts.clear(); + mboxAccounts.clear(); +} + void AccountView::slotContextMenu(int id) { @@ -472,5 +589,8 @@ void AccountView::populate( QList<Account> list ) clear(); - (void) new MBOXviewItem(AbstractMail::defaultLocalfolder(),this); + imapAccounts.clear(); + mboxAccounts.clear(); + + mboxAccounts.append(new MBOXviewItem(AbstractMail::defaultLocalfolder(),this)); Account *it; @@ -479,8 +599,9 @@ void AccountView::populate( QList<Account> list ) IMAPaccount *imap = static_cast<IMAPaccount *>(it); qDebug( "added IMAP " + imap->getAccountName() ); - (void) new IMAPviewItem( imap, this ); + imapAccounts.append(new IMAPviewItem( imap, this )); } else if ( it->getType().compare( "POP3" ) == 0 ) { POP3account *pop3 = static_cast<POP3account *>(it); qDebug( "added POP3 " + pop3->getAccountName() ); + /* must not be hold 'cause it isn't required */ (void) new POP3viewItem( pop3, this ); } @@ -525,13 +646,60 @@ RecBody AccountView::fetchBody(const RecMail&aMail) } +void AccountView::setupFolderselect(Selectstore*sels) +{ + sels->showMaximized(); + QStringList sFolders; + unsigned int i = 0; + for (i=0; i < mboxAccounts.count();++i) { + mboxAccounts[i]->refresh(false); + sFolders = mboxAccounts[i]->subFolders(); + sels->addAccounts(mboxAccounts[i]->getWrapper(),sFolders); + } + for (i=0; i < imapAccounts.count();++i) { + if (imapAccounts[i]->offline()) + continue; + imapAccounts[i]->refreshFolders(false); + sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); + } +} + +void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) +{ + unsigned int i = 0; + AbstractMail*targetMail = 0; + QString targetFolder = ""; + Selectstore sels; + setupFolderselect(&sels); + if (!sels.exec()) return; + targetMail = sels.currentMail(); + targetFolder = sels.currentFolder(); + if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || + targetFolder.isEmpty()) { + return; + } + + QList<RecMail> t; + fromWrapper->listMessages(fromFolder->getName(),t); + encodedString*st = 0; + for (i = 0; i < t.count();++i) { + RecMail*r = t.at(i); + st = fromWrapper->fetchRawBody(*r); + if (st) { + targetMail->storeMessage(st->Content(),st->Length(),targetFolder); + delete st; + } + } +} + /** * MBOX Account stuff */ -MBOXviewItem::MBOXviewItem( const QString&aPath, QListView *parent ) +MBOXviewItem::MBOXviewItem( const QString&aPath, AccountView *parent ) : AccountViewItem( parent ) { m_Path = aPath; - wrapper = AbstractMail::getWrapper( m_Path ); + /* be carefull - the space within settext is wanted - thats why the string twice */ + wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); setPixmap( 0, PIXMAP_LOCALFOLDER ); setText( 0, " Local Folders" ); @@ -603,4 +771,17 @@ void MBOXviewItem::createFolder() } +QStringList MBOXviewItem::subFolders() +{ + QStringList result; + QListViewItem *child = firstChild(); + while ( child ) { + MBOXfolderItem *tmp = (MBOXfolderItem*)child; + child = child->nextSibling(); + result.append(tmp->getFolder()->getName()); + } + qDebug("Size of result: %i",result.count()); + return result; +} + void MBOXviewItem::contextMenuSelected(int which) { @@ -637,4 +818,9 @@ MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QList } +Folder*MBOXfolderItem::getFolder() +{ + return folder; +} + void MBOXfolderItem::refresh(QList<RecMail>&target) { diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 7131192..48f52c7 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h @@ -13,4 +13,6 @@ class RecMail; class RecBody; class QPopupMenu; +class Selectstore; +class AccountView; class AccountViewItem : public QListViewItem @@ -18,14 +20,17 @@ class AccountViewItem : public QListViewItem public: - AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} - AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} - AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} + AccountViewItem( AccountView *parent ); + AccountViewItem( QListViewItem *parent); + AccountViewItem( QListViewItem *parent , QListViewItem*after ); + virtual ~AccountViewItem(); virtual void refresh(QList<RecMail>&)=0; virtual RecBody fetchBody(const RecMail&)=0; virtual QPopupMenu * getContextMenu(){return 0;}; virtual void contextMenuSelected(int){} + virtual AccountView*accountView(); protected: virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); static const QString contextName; + AccountView*m_Backlink; }; @@ -34,13 +39,17 @@ class POP3viewItem : public AccountViewItem public: - POP3viewItem( POP3account *a, QListView *parent ); - ~POP3viewItem(); + POP3viewItem( POP3account *a, AccountView *parent ); + virtual ~POP3viewItem(); virtual void refresh( QList<RecMail> &target ); virtual RecBody fetchBody( const RecMail &mail ); AbstractMail *getWrapper(); -private: + virtual QPopupMenu * getContextMenu(); + virtual void contextMenuSelected(int); + +protected: POP3account *account; AbstractMail *wrapper; - + void disconnect(); + void setOnOffline(); }; @@ -50,5 +59,5 @@ class POP3folderItem : public AccountViewItem public: POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); - ~POP3folderItem(); + virtual ~POP3folderItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); @@ -58,6 +67,4 @@ public: protected: void downloadMails(); - -private: Folder *folder; POP3viewItem *pop3; @@ -70,6 +77,6 @@ class IMAPviewItem : public AccountViewItem friend class IMAPfolderItem; public: - IMAPviewItem( IMAPaccount *a, QListView *parent ); - ~IMAPviewItem(); + IMAPviewItem( IMAPaccount *a, AccountView *parent ); + virtual ~IMAPviewItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); @@ -77,14 +84,15 @@ public: virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); + const QStringList&subFolders(); + virtual void refreshFolders(bool force=false); + bool offline(); protected: IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); - virtual void refreshFolders(bool force=false); virtual void createNewFolder(); virtual void removeChilds(); - -private: IMAPaccount *account; AbstractMail *wrapper; + QStringList currentFolders; }; @@ -95,5 +103,5 @@ public: IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); - ~IMAPfolderItem(); + virtual ~IMAPfolderItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); @@ -105,6 +113,5 @@ protected: virtual void createNewFolder(); virtual void deleteFolder(); - -private: + virtual void downloadMails(); Folder *folder; IMAPviewItem *imap; @@ -116,7 +123,6 @@ class MBOXviewItem : public AccountViewItem public: -// MBOXviewItem( MBOXaccount *a, QListView *parent ); - MBOXviewItem( const QString&aMboxPath, QListView *parent ); - ~MBOXviewItem(); + MBOXviewItem( const QString&aMboxPath, AccountView *parent ); + virtual ~MBOXviewItem(); virtual void refresh( QList<RecMail> &target ); virtual RecBody fetchBody( const RecMail &mail ); @@ -124,11 +130,9 @@ public: virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); + QStringList subFolders(); + virtual void refresh(bool force=false); protected: - virtual void refresh(bool force=false); virtual void createFolder(); - -private: -// MBOXaccount *account; QString m_Path; AbstractMail *wrapper; @@ -141,13 +145,13 @@ class MBOXfolderItem : public AccountViewItem public: MBOXfolderItem( Folder *folder, MBOXviewItem *parent , QListViewItem*after ); - ~MBOXfolderItem(); + virtual ~MBOXfolderItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); + virtual Folder*getFolder(); protected: virtual void deleteFolder(); -private: Folder *folder; MBOXviewItem *mbox; @@ -160,6 +164,8 @@ class AccountView : public QListView public: AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); - void populate( QList<Account> list ); - RecBody fetchBody(const RecMail&aMail); + virtual ~AccountView(); + virtual void populate( QList<Account> list ); + virtual RecBody fetchBody(const RecMail&aMail); + virtual void downloadMails(Folder*fromFolder,AbstractMail*fromWrapper); public slots: @@ -169,10 +175,13 @@ public slots: virtual void slotHold(int, QListViewItem *,const QPoint&,int); virtual void slotContextMenu(int id); + void setupFolderselect(Selectstore*sels); signals: void refreshMailview(QList<RecMail>*); -private: +protected: QListViewItem* m_currentItem; + QValueList<IMAPviewItem*> imapAccounts; + QValueList<MBOXviewItem*> mboxAccounts; }; diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 80d0b52..3dd2fce 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp @@ -22,7 +22,7 @@ AbstractMail* AbstractMail::getWrapper(POP3account *a) } -AbstractMail* AbstractMail::getWrapper(const QString&a) +AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) { - return new MBOXwrapper(a); + return new MBOXwrapper(a,name); } @@ -100,2 +100,7 @@ QString AbstractMail::defaultLocalfolder() return f; } + +/* temporary - will be removed when implemented in all classes */ +void AbstractMail::deleteMails(const QString &,QList<RecMail> &) +{ +} diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 9770991..15d83cb 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h @@ -32,4 +32,5 @@ public: virtual void answeredMail(const RecMail&mail)=0; virtual int deleteAllMail(const Folder*)=0; + virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); virtual int deleteMbox(const Folder*)=0; virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; @@ -47,9 +48,10 @@ public: static AbstractMail* getWrapper(POP3account *a); /* mbox only! */ - static AbstractMail* getWrapper(const QString&a); + static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); static QString defaultLocalfolder(); virtual const QString&getType()const=0; + virtual const QString&getName()const=0; protected: diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index d252159..bb74de9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp @@ -30,4 +30,5 @@ void IMAPwrapper::login() int err = MAILIMAP_NO_ERROR; + if (account->getOffline()) return; /* we are connected this moment */ /* TODO: setup a timer holding the line or if connection closed - delete the value */ @@ -1007,4 +1008,9 @@ const QString&IMAPwrapper::getType()const } +const QString&IMAPwrapper::getName()const +{ + return account->getAccountName(); +} + encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) { diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index b246f58..b2bd7e9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h @@ -46,4 +46,6 @@ public: virtual void logout(); virtual const QString&getType()const; + virtual const QString&getName()const; + protected: RecMail*parse_list_result(mailimap_msg_att*); diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index bc496f7..97f301e 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp @@ -9,6 +9,6 @@ const QString MBOXwrapper::wrapperType="MBOX"; -MBOXwrapper::MBOXwrapper(const QString & mbox_dir) - : Genericwrapper(),MBOXPath(mbox_dir) +MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) + : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) { QDir dir(MBOXPath); @@ -331,2 +331,7 @@ const QString&MBOXwrapper::getType()const return wrapperType; } + +const QString&MBOXwrapper::getName()const +{ + return MBOXName; +} diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index 2794014..194ff86 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h @@ -14,5 +14,5 @@ class MBOXwrapper : public Genericwrapper Q_OBJECT public: - MBOXwrapper(const QString & dir); + MBOXwrapper(const QString & dir,const QString&name); virtual ~MBOXwrapper(); @@ -33,11 +33,13 @@ public: virtual encodedString* fetchRawBody(const RecMail&mail); - virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); + virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); virtual int deleteAllMail(const Folder*); virtual const QString&getType()const; + virtual const QString&getName()const; protected: static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); QString MBOXPath; + QString MBOXName; static const QString wrapperType; }; diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index cceb22e..67bde38 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp @@ -109,4 +109,5 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) void POP3wrapper::login() { + if (account->getOffline()) return; /* we'll hold the line */ if ( m_pop3 != NULL ) return; @@ -250,2 +251,7 @@ const QString&POP3wrapper::getType()const return account->getType(); } + +const QString&POP3wrapper::getName()const +{ + return account->getAccountName(); +} diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index f0307b6..d2b708d 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h @@ -31,4 +31,5 @@ public: virtual void logout(); virtual const QString&getType()const; + virtual const QString&getName()const; static void pop3_progress( size_t current, size_t maximum ); diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index c5187f5..02a80a3 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp @@ -169,4 +169,6 @@ void IMAPaccount::read() prefix = conf->readEntry("MailPrefix",""); if (prefix.isNull()) prefix = ""; + offline = conf->readBoolEntry("Offline",false); + delete conf; } @@ -185,5 +187,7 @@ void IMAPaccount::save() conf->writeEntryCrypt( "Password", password ); conf->writeEntry( "MailPrefix",prefix); + conf->writeEntry( "Offline",offline); conf->write(); + delete conf; } @@ -239,4 +243,6 @@ void POP3account::read() user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); + offline = conf->readBoolEntry("Offline",false); + delete conf; } @@ -254,5 +260,7 @@ void POP3account::save() conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); + conf->writeEntry( "Offline",offline); conf->write(); + delete conf; } @@ -314,4 +322,5 @@ void SMTPaccount::read() user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); + delete conf; } @@ -331,4 +340,5 @@ void SMTPaccount::save() conf->writeEntryCrypt( "Password", password ); conf->write(); + delete conf; } @@ -387,4 +397,5 @@ void NNTPaccount::read() user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); + delete conf; } @@ -404,4 +415,5 @@ void NNTPaccount::save() conf->writeEntryCrypt( "Password", password ); conf->write(); + delete conf; } diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h index caa5dfc..2104997 100644 --- a/noncore/net/mail/libmailwrapper/settings.h +++ b/noncore/net/mail/libmailwrapper/settings.h @@ -32,4 +32,7 @@ public: bool getSSL() { return ssl; } + void setOffline(bool b) {offline = b;} + bool getOffline()const{return offline;} + virtual QString getFileName() { return accountName; } virtual void read() { qDebug( "base reading..." ); } @@ -39,5 +42,5 @@ protected: QString accountName, type, server, port, user, password; bool ssl; - + bool offline; }; diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index 4764b77..281b88e 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp @@ -490,5 +490,5 @@ void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) if (!mail) return; QString localfolders = AbstractMail::defaultLocalfolder(); - MBOXwrapper*wrap = new MBOXwrapper(localfolders); + AbstractMail*wrap = AbstractMail::getWrapper(localfolders); wrap->storeMessage(mail,length,box); delete wrap; @@ -517,9 +517,7 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) return; } - QString tmp = data; - tmp.replace(QRegExp("\r+",true,false),""); msg = 0; if (later) { - storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); + storeMail(data,size,"Outgoing"); if (data) free( data ); Config cfg( "mail" ); @@ -637,5 +635,5 @@ void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) } -int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) +int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which) { size_t curTok = 0; @@ -686,5 +684,5 @@ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) QString localfolders = AbstractMail::defaultLocalfolder(); - MBOXwrapper*wrap = new MBOXwrapper(localfolders); + AbstractMail*wrap = AbstractMail::getWrapper(localfolders); if (!wrap) { qDebug("memory error"); diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index 04fc4b0..7dcdbfd 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h @@ -11,5 +11,5 @@ class Mail; -class MBOXwrapper; +class AbstractMail; class RecMail; class Attachment; @@ -60,5 +60,5 @@ protected: Settings *settings; - int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); + int sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which); int m_queuedMail; diff --git a/noncore/net/mail/selectstore.cpp b/noncore/net/mail/selectstore.cpp index 28ab5a8..0a07d51 100644 --- a/noncore/net/mail/selectstore.cpp +++ b/noncore/net/mail/selectstore.cpp @@ -1,8 +1,14 @@ #include "selectstore.h" +#include <qlineedit.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <libmailwrapper/abstractmail.h> Selectstore::Selectstore(QWidget* parent, const char* name) :selectstoreui(parent,name,true) { - + folderMap.clear(); + mailMap.clear(); + cMail = 0; } @@ -13,4 +19,7 @@ Selectstore::~Selectstore() void Selectstore::slotCreateNewFolder() { + bool how = newFoldersel->isChecked(); + folderSelection->setEnabled(!how); + newFolderedit->setEnabled(how); } @@ -18,2 +27,44 @@ void Selectstore::slotMoveMail() { } + +void Selectstore::addAccounts(AbstractMail*mail,const QStringList&folders) +{ + accountSelection->insertItem(mail->getName()); + mailMap[accountSelection->count()-1]=mail; + folderMap[accountSelection->count()-1]=folders; + if (accountSelection->count()==1) { + cMail = mail; + folderSelection->insertStringList(folders); + } +} + +void Selectstore::slotAccountselected(int i) +{ + folderSelection->clear(); + folderSelection->insertStringList(folderMap[i]); + cMail = mailMap[i]; +} + +QString Selectstore::currentFolder() +{ + if (newFoldersel->isChecked()) { + return newFolderedit->text(); + } else { + return folderSelection->currentText(); + } +} + +AbstractMail*Selectstore::currentMail() +{ + return cMail; +} + +bool Selectstore::newFolder() +{ + return newFoldersel->isChecked(); +} + +bool Selectstore::moveMails() +{ + return selMove->isChecked(); +} diff --git a/noncore/net/mail/selectstore.h b/noncore/net/mail/selectstore.h index 8b8e8ee..447a6ae 100644 --- a/noncore/net/mail/selectstore.h +++ b/noncore/net/mail/selectstore.h @@ -3,4 +3,9 @@ #include "selectstoreui.h" +#include <qvaluelist.h> +#include <qmap.h> +#include <qstringlist.h> + +class AbstractMail; class Selectstore:public selectstoreui @@ -10,10 +15,19 @@ public: Selectstore(QWidget* parent = 0, const char* name = 0); virtual ~Selectstore(); + virtual void addAccounts(AbstractMail*mail,const QStringList&folders); + virtual QString currentFolder(); + virtual AbstractMail*currentMail(); + bool newFolder(); + bool moveMails(); -protected: +protected slots: virtual void slotCreateNewFolder(); virtual void slotMoveMail(); -protected slots: + virtual void slotAccountselected(int); +protected: + QMap<int,QStringList> folderMap; + QMap<int,AbstractMail*> mailMap; + AbstractMail*cMail; }; #endif diff --git a/noncore/net/mail/selectstoreui.ui b/noncore/net/mail/selectstoreui.ui index 3741b71..5f0e507 100644 --- a/noncore/net/mail/selectstoreui.ui +++ b/noncore/net/mail/selectstoreui.ui @@ -12,5 +12,5 @@ <x>0</x> <y>0</y> - <width>190</width> + <width>182</width> <height>273</height> </rect> @@ -29,9 +29,9 @@ <property stdset="1"> <name>margin</name> - <number>2</number> + <number>1</number> </property> <property stdset="1"> <name>spacing</name> - <number>2</number> + <number>1</number> </property> <widget> @@ -175,4 +175,25 @@ </widget> <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>newFolderLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Prefix will prepend, no need to enter it!</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>WordBreak|AlignCenter</set> + </property> + <property> + <name>hAlign</name> + </property> + <property> + <name>wordwrap</name> + </property> + </widget> + <widget> <class>Line</class> <property stdset="1"> @@ -232,6 +253,20 @@ <slot>slotCreateNewFolder()</slot> </connection> - <slot access="protected">slotMoveMail()</slot> + <connection> + <sender>accountSelection</sender> + <signal>activated(int)</signal> + <receiver>selectstoreui</receiver> + <slot>slotAccountselected(int)</slot> + </connection> + <connection> + <sender>folderSelection</sender> + <signal>activated(int)</signal> + <receiver>selectstoreui</receiver> + <slot>slotFolderSelected(int)</slot> + </connection> + <slot access="protected">slotFolderSelected(int)</slot> + <slot access="protected">slotAccountselected(int)</slot> <slot access="protected">slotCreateNewFolder()</slot> + <slot access="protected">slotMoveMail()</slot> </connections> <tabstops> |