-rw-r--r-- | noncore/net/mail/accountview.cpp | 234 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 71 | ||||
-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, 415 insertions, 78 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 @@ -1,70 +1,117 @@ #include "accountview.h" #include <libmailwrapper/mailtypes.h> #include <libmailwrapper/abstractmail.h> #include "defines.h" #include "newmaildir.h" #include "selectstore.h" #include <qmessagebox.h> #include <qpopupmenu.h> /** * POP3 Account stuff */ -POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) +POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) : AccountViewItem( parent ) { account = a; wrapper = AbstractMail::getWrapper( account ); setPixmap( 0, PIXMAP_POP3FOLDER ); setText( 0, account->getAccountName() ); setOpen( true ); } POP3viewItem::~POP3viewItem() { delete wrapper; } AbstractMail *POP3viewItem::getWrapper() { return wrapper; } void POP3viewItem::refresh( QList<RecMail> & ) { + if (account->getOffline()) return; QList<Folder> *folders = wrapper->listFolders(); QListViewItem *child = firstChild(); while ( child ) { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } Folder *it; QListViewItem*item = 0; for ( it = folders->first(); it; it = folders->next() ) { item = new POP3folderItem( it, this , item ); item->setSelectable(it->may_select()); } // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! folders->setAutoDelete(false); delete folders; } RecBody POP3viewItem::fetchBody( const RecMail &mail ) { qDebug( "POP3 fetchBody" ); return wrapper->fetchBody( 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() { delete folder; } POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) : AccountViewItem( parent,after ) { folder = folderInit; pop3 = parent; if (folder->getDisplayName().lower()!="inbox") { setPixmap( 0, PIXMAP_POP3FOLDER ); @@ -82,34 +129,34 @@ void POP3folderItem::refresh(QList<RecMail>&target) RecBody POP3folderItem::fetchBody(const RecMail&aMail) { return pop3->getWrapper()->fetchBody(aMail); } QPopupMenu * POP3folderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { 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; } void POP3folderItem::downloadMails() { - Selectstore sels; - sels.showMaximized(); - sels.exec(); + AccountView*bl = pop3->accountView(); + if (!bl) return; + bl->downloadMails(folder,pop3->getWrapper()); } void POP3folderItem::contextMenuSelected(int which) { AccountView * view = (AccountView*)listView(); switch (which) { case 0: /* must be 'cause pop3 lists are cached */ pop3->getWrapper()->logout(); view->refreshCurrent(); break; case 1: @@ -117,25 +164,25 @@ void POP3folderItem::contextMenuSelected(int which) break; case 2: downloadMails(); break; default: break; } } /** * IMAP Account stuff */ -IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) +IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) : AccountViewItem( parent ) { account = a; wrapper = AbstractMail::getWrapper( account ); setPixmap( 0, PIXMAP_IMAPFOLDER ); setText( 0, account->getAccountName() ); setOpen( true ); } IMAPviewItem::~IMAPviewItem() { delete wrapper; @@ -174,76 +221,88 @@ void IMAPviewItem::refresh(QList<RecMail>&) void IMAPviewItem::removeChilds() { QListViewItem *child = firstChild(); while ( child ) { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } } +const QStringList&IMAPviewItem::subFolders() +{ + return currentFolders; +} + void IMAPviewItem::refreshFolders(bool force) { if (childCount()>0 && force==false) return; - - removeChilds(); + if (account->getOffline()) return; + removeChilds(); + currentFolders.clear(); QList<Folder> *folders = wrapper->listFolders(); Folder *it; QListViewItem*item = 0; QListViewItem*titem = 0; QString fname,del,search; int pos; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! folders->setAutoDelete(false); for ( it = folders->first(); it; it = folders->next() ) { if (it->getDisplayName().lower()=="inbox") { item = new IMAPfolderItem( it, this , item ); folders->remove(it); qDebug("inbox found"); break; } } for ( it = folders->first(); it; it = folders->next() ) { fname = it->getDisplayName(); + currentFolders.append(it->getName()); pos = fname.findRev(it->Separator()); if (pos != -1) { fname = fname.left(pos); } IMAPfolderItem*pitem = findSubItem(fname); if (pitem) { titem = item; item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); /* setup the short name */ item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); item = titem; } else { item = new IMAPfolderItem( it, this , item ); } } delete folders; } QPopupMenu * IMAPviewItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { - 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); + 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; } void IMAPviewItem::createNewFolder() { Newmdirdlg ndirdlg; ndirdlg.showMaximized(); if (ndirdlg.exec()) { QString ndir = ndirdlg.Newdir(); bool makesubs = ndirdlg.subpossible(); QString delemiter = "/"; @@ -262,37 +321,46 @@ void IMAPviewItem::contextMenuSelected(int id) qDebug("Id selected: %i",id); switch (id) { case 0: refreshFolders(true); break; case 1: createNewFolder(); break; case 2: removeChilds(); wrapper->logout(); break; + case 3: + if (account->getOffline()==false) { + removeChilds(); + wrapper->logout(); + } + account->setOffline(!account->getOffline()); + account->save(); + refreshFolders(false); + break; default: break; } } RecBody IMAPviewItem::fetchBody(const RecMail&) { return RecBody(); } -IMAPfolderItem::~IMAPfolderItem() +bool IMAPviewItem::offline() { - delete folder; + return account->getOffline(); } IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) : AccountViewItem( parent , after ) { folder = folderInit; imap = parent; if (folder->getDisplayName().lower()!="inbox") { setPixmap( 0, PIXMAP_IMAPFOLDER ); } else { setPixmap( 0, PIXMAP_INBOXFOLDER); } @@ -303,24 +371,29 @@ IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QLi : AccountViewItem( parent,after ) { folder = folderInit; imap = master; if (folder->getDisplayName().lower()!="inbox") { setPixmap( 0, PIXMAP_IMAPFOLDER ); } else { setPixmap( 0, PIXMAP_INBOXFOLDER); } setText( 0, folder->getDisplayName() ); } +IMAPfolderItem::~IMAPfolderItem() +{ + delete folder; +} + const QString& IMAPfolderItem::Delemiter()const { return folder->Separator(); } bool IMAPfolderItem::matchName(const QString&name)const { return folder->getDisplayName()==name; } void IMAPfolderItem::refresh(QList<RecMail>&target) { @@ -333,24 +406,25 @@ void IMAPfolderItem::refresh(QList<RecMail>&target) RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) { return imap->getWrapper()->fetchBody(aMail); } QPopupMenu * IMAPfolderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { 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); } if (folder->no_inferior()==false) { m->insertItem(QObject::tr("Create new subfolder",contextName),2); } if (folder->getDisplayName().lower()!="inbox") { m->insertItem(QObject::tr("Delete folder",contextName),3); } } return m; } @@ -380,52 +454,89 @@ void IMAPfolderItem::deleteFolder() QListView*v=listView(); IMAPviewItem * box = imap; /* be carefull - after that this object is destroyd so don't use * any member of it after that call!!*/ imap->refreshFolders(true); if (v) { v->setSelected(box,true); } } } } +void IMAPfolderItem::downloadMails() +{ + AccountView*bl = imap->accountView(); + if (!bl) return; + bl->downloadMails(folder,imap->getWrapper()); +} + void IMAPfolderItem::contextMenuSelected(int id) { qDebug("Selected id: %i",id); AccountView * view = (AccountView*)listView(); switch(id) { case 0: view->refreshCurrent(); break; case 1: deleteAllMail(imap->getWrapper(),folder); break; case 2: createNewFolder(); break; case 3: deleteFolder(); break; + case 4: + downloadMails(); + break; default: break; } } /** * Generic stuff */ 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) { if (!wrapper) return; QString fname=""; if (folder) fname = folder->getDisplayName(); int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). arg(fname), QObject::tr("Yes",contextName), QObject::tr("No",contextName),QString::null,1,1); qDebug("Auswahl: %i",yesno); if (yesno == 0) { @@ -438,110 +549,167 @@ void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) : QListView( parent, name, flags ) { connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), SLOT( refresh( QListViewItem * ) ) ); connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); setSorting(0); } +AccountView::~AccountView() +{ + imapAccounts.clear(); + mboxAccounts.clear(); +} + void AccountView::slotContextMenu(int id) { AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); if (!view) return; view->contextMenuSelected(id); } void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) { if (button==1) {return;} if (!item) return; AccountViewItem *view = static_cast<AccountViewItem *>(item); QPopupMenu*m = view->getContextMenu(); if (!m) return; connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); delete m; } 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; for ( it = list.first(); it; it = list.next() ) { if ( it->getType().compare( "IMAP" ) == 0 ) { 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 ); } } } void AccountView::refresh(QListViewItem *item) { qDebug("AccountView refresh..."); if ( item ) { m_currentItem = item; QList<RecMail> headerlist; headerlist.setAutoDelete(true); AccountViewItem *view = static_cast<AccountViewItem *>(item); view->refresh(headerlist); emit refreshMailview(&headerlist); } } void AccountView::refreshCurrent() { m_currentItem = currentItem(); - if ( !m_currentItem ) return; - QList<RecMail> headerlist; - headerlist.setAutoDelete(true); - AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); - view->refresh(headerlist); - emit refreshMailview(&headerlist); + if ( !m_currentItem ) return; + QList<RecMail> headerlist; + headerlist.setAutoDelete(true); + AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); + view->refresh(headerlist); + emit refreshMailview(&headerlist); } void AccountView::refreshAll() { } RecBody AccountView::fetchBody(const RecMail&aMail) { QListViewItem*item = selectedItem (); if (!item) return RecBody(); AccountViewItem *view = static_cast<AccountViewItem *>(item); return view->fetchBody(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" ); setOpen( true ); } MBOXviewItem::~MBOXviewItem() { delete wrapper; } AbstractMail *MBOXviewItem::getWrapper() { @@ -593,24 +761,37 @@ QPopupMenu * MBOXviewItem::getContextMenu() void MBOXviewItem::createFolder() { Newmdirdlg ndirdlg(0,0,true); ndirdlg.showMaximized(); if (ndirdlg.exec()) { QString ndir = ndirdlg.Newdir(); if (wrapper->createMbox(ndir)) { refresh(true); } } } +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) { switch (which) { case 0: refresh(true); break; case 1: createFolder(); break; default: break; } @@ -627,24 +808,29 @@ MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QList folder = folderInit; mbox = parent; if (folder->getDisplayName().lower() == "outgoing") { setPixmap( 0, PIXMAP_OUTBOXFOLDER ); } else if (folder->getDisplayName().lower() == "inbox") { setPixmap( 0, PIXMAP_INBOXFOLDER); } else { setPixmap( 0, PIXMAP_MBOXFOLDER ); } setText( 0, folder->getDisplayName() ); } +Folder*MBOXfolderItem::getFolder() +{ + return folder; +} + void MBOXfolderItem::refresh(QList<RecMail>&target) { if (folder->may_select()) mbox->getWrapper()->listMessages( folder->getName(),target ); } RecBody MBOXfolderItem::fetchBody(const RecMail&aMail) { return mbox->getWrapper()->fetchBody(aMail); } void MBOXfolderItem::deleteFolder() 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 @@ -3,177 +3,186 @@ #include <qlistview.h> #include <qlist.h> #include <libmailwrapper/settings.h> #include <libmailwrapper/mailwrapper.h> #include <libmailwrapper/abstractmail.h> class POP3wrapper; class RecMail; class RecBody; class QPopupMenu; +class Selectstore; +class AccountView; 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; }; 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(); }; 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&); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); protected: void downloadMails(); - -private: Folder *folder; POP3viewItem *pop3; }; class IMAPfolderItem; 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&); AbstractMail *getWrapper(); 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; }; class IMAPfolderItem : public AccountViewItem { 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&); bool matchName(const QString&name)const; virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); virtual const QString& Delemiter()const; protected: virtual void createNewFolder(); virtual void deleteFolder(); - -private: + virtual void downloadMails(); Folder *folder; IMAPviewItem *imap; }; class MBOXviewItem : public AccountViewItem { friend class MBOXfolderItem; 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 ); AbstractMail *getWrapper(); 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; }; 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; }; class AccountView : public QListView { Q_OBJECT 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: virtual void refreshAll(); virtual void refresh(QListViewItem *item); virtual void refreshCurrent(); virtual void slotHold(int, QListViewItem *,const QPoint&,int); virtual void slotContextMenu(int id); + void setupFolderselect(Selectstore*sels); signals: void refreshMailview(QList<RecMail>*); -private: - QListViewItem* m_currentItem; +protected: + QListViewItem* m_currentItem; + QValueList<IMAPviewItem*> imapAccounts; + QValueList<MBOXviewItem*> mboxAccounts; }; #endif 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 @@ -12,27 +12,27 @@ #include <libetpan/mailmime.h> AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) { return new IMAPwrapper(a); } AbstractMail* AbstractMail::getWrapper(POP3account *a) { return new POP3wrapper(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); } encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) { qDebug("Decode string start"); char*result_text; size_t index = 0; /* reset for recursive use! */ size_t target_length = 0; result_text = 0; int mimetype = MAILMIME_MECHANISM_7BIT; if (enc.lower()=="quoted-printable") { @@ -90,12 +90,17 @@ QString AbstractMail::gen_attachment_id() int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) { return 0; } QString AbstractMail::defaultLocalfolder() { QString f = getenv( "HOME" ); f += "/Applications/opiemail/localmail"; 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 @@ -22,39 +22,41 @@ public: virtual QList<Folder>* listFolders()=0; virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; virtual RecBody fetchBody(const RecMail&mail)=0; virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; virtual encodedString* fetchRawBody(const RecMail&mail)=0; virtual void deleteMail(const RecMail&mail)=0; 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; virtual void cleanMimeCache(){}; /* mail box methods */ /* parameter is the box to create. * if the implementing subclass has prefixes, * them has to be appended automatic. */ virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); virtual void logout()=0; static AbstractMail* getWrapper(IMAPaccount *a); 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: static encodedString*decode_String(const encodedString*text,const QString&enc); static QString convert_String(const char*text); static QString gen_attachment_id(); }; #endif 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 @@ -20,24 +20,25 @@ IMAPwrapper::~IMAPwrapper() void IMAPwrapper::imap_progress( size_t current, size_t maximum ) { qDebug( "IMAP: %i of %i", current, maximum ); } void IMAPwrapper::login() { const char *server, *user, *pass; uint16_t port; 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 */ if (m_imap) { err = mailimap_noop(m_imap); if (err!=MAILIMAP_NO_ERROR) { logout(); } else { mailstream_flush(m_imap->imap_stream); return; } } server = account->getServer().latin1(); @@ -997,18 +998,23 @@ void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folde if (!msg) return; int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); if (r != MAILIMAP_NO_ERROR) { Global::statusMessage("Error storing mail!"); } } const QString&IMAPwrapper::getType()const { return account->getType(); } +const QString&IMAPwrapper::getName()const +{ + return account->getAccountName(); +} + encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) { // dummy QValueList<int> path; return fetchRawPart(mail,path,false); } 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 @@ -36,24 +36,26 @@ public: virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); virtual encodedString* fetchRawBody(const RecMail&mail); virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); virtual int deleteMbox(const Folder*folder); static void imap_progress( size_t current, size_t maximum ); virtual void logout(); virtual const QString&getType()const; + virtual const QString&getName()const; + protected: RecMail*parse_list_result(mailimap_msg_att*); void login(); virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); 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 @@ -1,24 +1,24 @@ #include "mboxwrapper.h" #include "mailtypes.h" #include "mailwrapper.h" #include <libetpan/libetpan.h> #include <qdir.h> #include <stdlib.h> #include <qpe/global.h> 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); if (!dir.exists()) { dir.mkdir(MBOXPath); } } MBOXwrapper::~MBOXwrapper() { } void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) @@ -321,12 +321,17 @@ void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) folder = mailfolder_new( storage,(char*)p.latin1(),NULL); r = mailfolder_connect(folder); r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, &target_stat.message_recent,&target_stat.message_unseen); if (folder) mailfolder_free(folder); if (storage) mailstorage_free(storage); } 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 @@ -4,42 +4,44 @@ #include "genericwrapper.h" #include <qstring.h> class RecMail; class RecBody; class encodedString; struct mailmbox_folder; class MBOXwrapper : public Genericwrapper { Q_OBJECT public: - MBOXwrapper(const QString & dir); + MBOXwrapper(const QString & dir,const QString&name); virtual ~MBOXwrapper(); virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); virtual QList<Folder>* listFolders(); virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); virtual void deleteMail(const RecMail&mail); virtual void answeredMail(const RecMail&mail); virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); virtual int deleteMbox(const Folder*); virtual void storeMessage(const char*msg,size_t length, const QString&folder); virtual RecBody fetchBody( const RecMail &mail ); static void mbox_progress( size_t current, size_t maximum ); 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; }; #endif 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 @@ -99,24 +99,25 @@ RecBody POP3wrapper::fetchBody( const RecMail &mail ) void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) { login(); if (!m_pop3) return; uint32_t res_messages,res_recent,res_unseen; mailsession_status_folder(m_folder->fld_session,"INBOX",&res_messages,&res_recent,&res_unseen); parseList(target,m_folder->fld_session,"INBOX"); Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); } void POP3wrapper::login() { + if (account->getOffline()) return; /* we'll hold the line */ if ( m_pop3 != NULL ) return; const char *server, *user, *pass; uint16_t port; int err = MAILPOP3_NO_ERROR; server = account->getServer().latin1(); port = account->getPort().toUInt(); if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); @@ -240,12 +241,17 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) err = mailmessage_fetch(mailmsg,&target,&length); if (mailmsg) mailmessage_free(mailmsg); if (target) { res = new encodedString(target,length); } return res; } 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 @@ -21,22 +21,23 @@ public: virtual QList<Folder>* listFolders(); /* mailbox will be ignored */ virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); virtual void deleteMail(const RecMail&mail); virtual void answeredMail(const RecMail&mail); virtual int deleteAllMail(const Folder*); virtual RecBody fetchBody( const RecMail &mail ); virtual encodedString* fetchRawBody(const RecMail&mail); virtual void logout(); virtual const QString&getType()const; + virtual const QString&getName()const; static void pop3_progress( size_t current, size_t maximum ); protected: void login(); POP3account *account; mailstorage*m_pop3; mailfolder*m_folder; }; #endif 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 @@ -159,41 +159,45 @@ void IMAPaccount::read() if (accountName.isNull()) accountName = ""; server = conf->readEntry( "Server","" ); if (server.isNull()) server=""; port = conf->readEntry( "Port","" ); if (port.isNull()) port="143"; ssl = conf->readBoolEntry( "SSL",false ); user = conf->readEntry( "User","" ); if (user.isNull()) user = ""; password = conf->readEntryCrypt( "Password","" ); if (password.isNull()) password = ""; prefix = conf->readEntry("MailPrefix",""); if (prefix.isNull()) prefix = ""; + offline = conf->readBoolEntry("Offline",false); + delete conf; } void IMAPaccount::save() { qDebug( "saving " + getFileName() ); Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "IMAP Account" ); conf->writeEntry( "Account", accountName ); conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); conf->writeEntry( "MailPrefix",prefix); + conf->writeEntry( "Offline",offline); conf->write(); + delete conf; } QString IMAPaccount::getFileName() { return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; } POP3account::POP3account() : Account() { file = POP3account::getUniqueFileName(); @@ -229,40 +233,44 @@ QString POP3account::getUniqueFileName() } void POP3account::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "POP3 Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); + offline = conf->readBoolEntry("Offline",false); + delete conf; } void POP3account::save() { qDebug( "saving " + getFileName() ); Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "POP3 Account" ); conf->writeEntry( "Account", accountName ); conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); + conf->writeEntry( "Offline",offline); conf->write(); + delete conf; } QString POP3account::getFileName() { return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; } SMTPaccount::SMTPaccount() : Account() { file = SMTPaccount::getUniqueFileName(); @@ -304,41 +312,43 @@ QString SMTPaccount::getUniqueFileName() void SMTPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "SMTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); + delete conf; } void SMTPaccount::save() { qDebug( "saving " + getFileName() ); Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "SMTP Account" ); conf->writeEntry( "Account", accountName ); conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "Login", login ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); conf->write(); + delete conf; } QString SMTPaccount::getFileName() { return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; } NNTPaccount::NNTPaccount() : Account() { file = NNTPaccount::getUniqueFileName(); @@ -377,37 +387,39 @@ QString NNTPaccount::getUniqueFileName() void NNTPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "NNTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); + delete conf; } void NNTPaccount::save() { qDebug( "saving " + getFileName() ); Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "NNTP Account" ); conf->writeEntry( "Account", accountName ); conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "Login", login ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); conf->write(); + delete conf; } QString NNTPaccount::getFileName() { return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; } 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 @@ -21,33 +21,36 @@ public: void setPort(const QString&str) { port = str; } const QString&getPort()const{ return port; } void setUser(const QString&str){ user = str; } const QString&getUser()const{ return user; } void setPassword(const QString&str) { password = str; } const QString&getPassword()const { return password; } void setSSL( bool b ) { ssl = b; } 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..." ); } virtual void save() { qDebug( "base saving..." ); } protected: QString accountName, type, server, port, user, password; bool ssl; - + bool offline; }; class IMAPaccount : public Account { public: IMAPaccount(); IMAPaccount( QString filename ); static QString getUniqueFileName(); virtual void read(); 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 @@ -480,25 +480,25 @@ char *SMTPwrapper::getFrom( mailmime *mail ) void SMTPwrapper::progress( size_t current, size_t maximum ) { if (SMTPwrapper::sendProgress) { SMTPwrapper::sendProgress->setSingleMail(current, maximum ); qApp->processEvents(); } } 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; } void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) { clist *rcpts = 0; char *from, *data; size_t size; if ( smtp == NULL ) { return; @@ -507,29 +507,27 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) mailmessage * msg = 0; msg = mime_message_init(mail); mime_message_set_tmpdir(msg,getenv( "HOME" )); int r = mailmessage_fetch(msg,&data,&size); mime_message_detach_mime(msg); mailmessage_free(msg); if (r != MAIL_NO_ERROR || !data) { if (data) free(data); qDebug("Error fetching mime..."); 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" ); cfg.setGroup( "Status" ); cfg.writeEntry( "outgoing", ++m_queuedMail ); emit queuedMails( m_queuedMail ); return; } from = getFrom( mail ); rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); smtpSend(from,rcpts,data,size,smtp); if (data) {free(data);} if (from) {free(from);} @@ -627,25 +625,25 @@ void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) sendProgress = new progressMailSend(); sendProgress->show(); sendProgress->setMaxMails(1); smtpSend( mimeMail,later,smtp); qDebug("Clean up done"); sendProgress->hide(); delete sendProgress; sendProgress = 0; mailmime_free( mimeMail ); } } -int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) +int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which) { size_t curTok = 0; mailimf_fields *fields = 0; mailimf_field*ffrom = 0; clist *rcpts = 0; char*from = 0; int res = 0; encodedString * data = wrap->fetchRawBody(*which); if (!data) return 0; int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); if (err != MAILIMF_NO_ERROR) { @@ -676,25 +674,25 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) } return res; } /* this is a special fun */ bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) { bool returnValue = true; if (!smtp) return false; QString localfolders = AbstractMail::defaultLocalfolder(); - MBOXwrapper*wrap = new MBOXwrapper(localfolders); + AbstractMail*wrap = AbstractMail::getWrapper(localfolders); if (!wrap) { qDebug("memory error"); return false; } QList<RecMail> mailsToSend; QList<RecMail> mailsToRemove; QString mbox("Outgoing"); wrap->listMessages(mbox,mailsToSend); if (mailsToSend.count()==0) { delete wrap; return false; } 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 @@ -1,25 +1,25 @@ #ifndef SMTPwrapper_H #define SMTPwrapper_H #include <qpe/applnk.h> #include <qbitarray.h> #include <qdatetime.h> #include <libetpan/clist.h> #include "settings.h" class Mail; -class MBOXwrapper; +class AbstractMail; class RecMail; class Attachment; struct mailimf_fields; struct mailimf_field; struct mailimf_mailbox; struct mailmime; struct mailimf_address_list; class progressMailSend; class SMTPwrapper : public QObject { Q_OBJECT @@ -50,23 +50,23 @@ protected: static void storeMail(const char*mail, size_t length, const QString&box); static QString mailsmtpError( int err ); static void progress( size_t current, size_t maximum ); static void addRcpts( clist *list, mailimf_address_list *addr_list ); static char *getFrom( mailmime *mail ); static char *getFrom( mailimf_field *ffrom); static mailimf_field *getField( mailimf_fields *fields, int type ); int smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ); void storeMail(mailmime*mail, const QString&box); Settings *settings; - int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); + int sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which); int m_queuedMail; static const char* USER_AGENT; protected slots: void emitQCop( int queued ); }; #endif 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,19 +1,70 @@ #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; } Selectstore::~Selectstore() { } void Selectstore::slotCreateNewFolder() { + bool how = newFoldersel->isChecked(); + folderSelection->setEnabled(!how); + newFolderedit->setEnabled(how); } 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 @@ -1,19 +1,33 @@ #ifndef _SELECTSTORE_H #define _SELECTSTORE_H #include "selectstoreui.h" +#include <qvaluelist.h> +#include <qmap.h> +#include <qstringlist.h> + +class AbstractMail; class Selectstore:public selectstoreui { Q_OBJECT 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 @@ -2,46 +2,46 @@ <class>selectstoreui</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>selectstoreui</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>190</width> + <width>182</width> <height>273</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Select target box</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <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> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>headlabel</cstring> </property> <property stdset="1"> <name>text</name> <string><b>Store mail(s) to</b></string> </property> <property stdset="1"> @@ -165,24 +165,45 @@ <widget> <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>newFolderedit</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> </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"> <name>name</name> <cstring>Line2</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> </widget> <widget> <class>QCheckBox</class> @@ -222,23 +243,37 @@ <connection> <sender>selMove</sender> <signal>clicked()</signal> <receiver>selectstoreui</receiver> <slot>slotMoveMail()</slot> </connection> <connection> <sender>newFoldersel</sender> <signal>clicked()</signal> <receiver>selectstoreui</receiver> <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> <tabstop>accountSelection</tabstop> <tabstop>folderSelection</tabstop> <tabstop>newFoldersel</tabstop> <tabstop>newFolderedit</tabstop> <tabstop>selMove</tabstop> </tabstops> </UI> |