-rw-r--r-- | noncore/net/mail/accountitem.cpp | 17 | ||||
-rw-r--r-- | noncore/net/mail/accountitem.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/accountview.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/composemail.cpp | 90 | ||||
-rw-r--r-- | noncore/net/mail/composemail.h | 25 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 23 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 10 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/libmailwrapper.pro | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/storemail.cpp | 90 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/storemail.h | 29 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/nntpgroupsdlg.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 23 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.h | 1 |
18 files changed, 309 insertions, 39 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index 0d636a4..396dcb7 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp @@ -820,310 +820,321 @@ QPopupMenu * MHviewItem::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->insertItem(QObject::tr("Delete all mails",contextName),2); m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); } return m; } void MHviewItem::createFolder() { Newmdirdlg ndirdlg(0,0,true); if ( QPEApplication::execDialog( &ndirdlg ) ) { QString ndir = ndirdlg.Newdir(); if (wrapper->createMbox(ndir)) { refresh(true); } } } void MHviewItem::downloadMails() { AccountView*bl = accountView(); if (!bl) return; bl->downloadMails(folder,getWrapper()); } QStringList MHviewItem::subFolders() { return currentFolders; } void MHviewItem::contextMenuSelected(int which) { switch (which) { case 0: refresh(true); break; case 1: createFolder(); break; case 2: deleteAllMail(getWrapper(),folder); break; case 3: downloadMails(); break; default: break; } } MHfolderItem::~MHfolderItem() {} MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after ) : AccountViewItem( parent,after ) { folder = folderInit; mbox = parent; initName(); } MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) : AccountViewItem( parent,after ) { folder = folderInit; mbox = master; initName(); } void MHfolderItem::initName() { QString bName = folder->getDisplayName(); if (bName.startsWith("/")&&bName.length()>1) { bName.replace(0,1,""); } int pos = bName.findRev("/"); if (pos > 0) { bName.replace(0,pos+1,""); } if (bName.lower() == "outgoing") { setPixmap( 0, PIXMAP_OUTBOXFOLDER ); } else if (bName.lower() == "inbox") { setPixmap( 0, PIXMAP_INBOXFOLDER); - } - else - { + } else if (bName.lower() == "drafts") { + setPixmap(0, Resource::loadPixmap("inline/edit")); + } else { setPixmap( 0, PIXMAP_MBOXFOLDER ); } setText( 0, bName ); } Folder*MHfolderItem::getFolder() { return folder; } void MHfolderItem::refresh(QList<RecMail>&target) { if (folder->may_select()) mbox->getWrapper()->listMessages( folder->getName(),target ); } RecBody MHfolderItem::fetchBody(const RecMail&aMail) { return mbox->getWrapper()->fetchBody(aMail); } void MHfolderItem::deleteFolder() { int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), QObject::tr("Yes",contextName), QObject::tr("No",contextName),QString::null,1,1); qDebug("Auswahl: %i",yesno); if (yesno == 0) { if (mbox->getWrapper()->deleteMbox(folder)) { QListView*v=listView(); MHviewItem * box = mbox; /* be carefull - after that this object is destroyd so don't use * any member of it after that call!!*/ mbox->refresh(true); if (v) { v->setSelected(box,true); } } } } QPopupMenu * MHfolderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); m->insertItem(QObject::tr("Delete all mails",contextName),0); m->insertItem(QObject::tr("Create new subfolder",contextName),3); m->insertItem(QObject::tr("Delete folder",contextName),1); } return m; } void MHfolderItem::downloadMails() { AccountView*bl = mbox->accountView(); if (!bl) return; bl->downloadMails(folder,mbox->getWrapper()); } void MHfolderItem::createFolder() { Newmdirdlg ndirdlg(0,0,true); if ( QPEApplication::execDialog( &ndirdlg ) ) { QString ndir = ndirdlg.Newdir(); if (mbox->getWrapper()->createMbox(ndir,folder)) { QListView*v=listView(); MHviewItem * box = mbox; /* be carefull - after that this object is destroyd so don't use * any member of it after that call!!*/ mbox->refresh(true); if (v) { v->setSelected(box,true); } } } } void MHfolderItem::contextMenuSelected(int which) { switch(which) { case 0: deleteAllMail(mbox->getWrapper(),folder); break; case 1: deleteFolder(); break; case 2: downloadMails(); break; case 3: createFolder(); break; default: break; } } +bool MHfolderItem::isDraftfolder() +{ + if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; + return false; +} + /** * Generic stuff */ const QString AccountViewItem::contextName="AccountViewItem"; AccountViewItem::AccountViewItem( AccountView *parent ) : QListViewItem( parent ) { init(); m_Backlink = parent; } AccountViewItem::AccountViewItem( QListViewItem *parent) : QListViewItem( parent) { init(); } AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) :QListViewItem( parent,after ) { init(); } void AccountViewItem::init() { m_Backlink = 0; folder = 0; } AccountViewItem::~AccountViewItem() { if (folder) delete folder; } 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) { if (wrapper->deleteAllMail(folder)) { AccountView * view = (AccountView*)listView(); if (view) view->refreshCurrent(); } } } void AccountViewItem::removeChilds() { QListViewItem *child = firstChild(); while ( child ) { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } } bool AccountViewItem::matchName(const QString&name)const { if (!folder) return false; return folder->getDisplayName()==name; } AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) { AccountViewItem*pitem,*sitem; if (!start) pitem = (AccountViewItem*)firstChild(); else pitem = (AccountViewItem*)start->firstChild(); while (pitem) { if (pitem->matchName(path)) { break; } if (pitem->childCount()>0) { sitem = findSubItem(path,pitem); if (sitem) { pitem = sitem; break; } } pitem=(AccountViewItem*)pitem->nextSibling(); } return pitem; } + +bool AccountViewItem::isDraftfolder() +{ + return false; +} diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h index f3c0f5d..eb3baa3 100644 --- a/noncore/net/mail/accountitem.h +++ b/noncore/net/mail/accountitem.h @@ -1,205 +1,207 @@ #ifndef __ACCOUNT_ITEM #define __ACCOUNT_ITEM #include <qlistview.h> #include <qlist.h> class POP3wrapper; class RecMail; class RecBody; class QPopupMenu; class Selectstore; class AccountView; class POP3account; class NNTPaccount; class IMAPaccount; class AbstractMail; class Folder; class AccountViewItem : public QListViewItem { public: 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(); virtual bool matchName(const QString&name)const; + virtual bool isDraftfolder(); protected: AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); virtual void init(); virtual void removeChilds(); virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); static const QString contextName; AccountView*m_Backlink; Folder *folder; }; class POP3viewItem : public AccountViewItem { public: POP3viewItem( POP3account *a, AccountView *parent ); virtual ~POP3viewItem(); virtual void refresh( QList<RecMail> &target ); virtual RecBody fetchBody( const RecMail &mail ); AbstractMail *getWrapper(); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); protected: POP3account *account; virtual void refresh(); AbstractMail *wrapper; void disconnect(); void setOnOffline(); }; class POP3folderItem : public AccountViewItem { public: POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); virtual ~POP3folderItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); protected: void downloadMails(); POP3viewItem *pop3; }; class NNTPviewItem : public AccountViewItem { public: NNTPviewItem( NNTPaccount *a, AccountView *parent ); virtual ~NNTPviewItem(); virtual void refresh( QList<RecMail> &target ); virtual RecBody fetchBody( const RecMail &mail ); AbstractMail *getWrapper(); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); protected: NNTPaccount *account; virtual void refresh(); AbstractMail *wrapper; void disconnect(); void setOnOffline(); void subscribeGroups(); }; class NNTPfolderItem : public AccountViewItem { public: NNTPfolderItem( Folder *folder, NNTPviewItem *parent , QListViewItem*after ); virtual ~NNTPfolderItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); protected: void downloadMails(); NNTPviewItem *nntp; }; class IMAPviewItem : public AccountViewItem { friend class IMAPfolderItem; public: 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: virtual void createNewFolder(); 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 ); virtual ~IMAPfolderItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); virtual const QString& Delemiter()const; protected: virtual void createNewFolder(); virtual void deleteFolder(); virtual void downloadMails(); IMAPviewItem *imap; }; class MHviewItem : public AccountViewItem { friend class MHfolderItem; public: MHviewItem( const QString&aMboxPath, AccountView *parent ); virtual ~MHviewItem(); 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: void downloadMails(); virtual void createFolder(); QString m_Path; AbstractMail *wrapper; QStringList currentFolders; }; class MHfolderItem : public AccountViewItem { public: MHfolderItem( Folder *folder, MHviewItem *parent , QListViewItem*after ); MHfolderItem( Folder *folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); virtual ~MHfolderItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); virtual Folder*getFolder(); + virtual bool isDraftfolder(); protected: void downloadMails(); virtual void createFolder(); virtual void deleteFolder(); void initName(); MHviewItem *mbox; }; #endif diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 4375044..7938d4f 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -75,96 +75,103 @@ void AccountView::populate( QList<Account> list ) /* must not be hold 'cause it isn't required */ (void) new POP3viewItem( pop3, this ); } else if ( it->getType() == MAILLIB::A_NNTP ) { NNTPaccount *nntp = static_cast<NNTPaccount *>(it); qDebug( "added NNTP " + nntp->getAccountName() ); /* must not be hold 'cause it isn't required */ (void) new NNTPviewItem( nntp, 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); } 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) { QPEApplication::showDialog( sels ); QStringList sFolders; unsigned int i = 0; for (i=0; i < mhAccounts.count();++i) { mhAccounts[i]->refresh(false); sFolders = mhAccounts[i]->subFolders(); sels->addAccounts(mhAccounts[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) { 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; } if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { QMessageBox::critical(0,tr("Error creating new Folder"), tr("<center>Error while creating<br>new folder - breaking.</center>")); return; } qDebug("Targetfolder: %s",targetFolder.latin1()); qDebug("Fromfolder: %s",fromFolder->getName().latin1()); fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); refreshCurrent(); } + +bool AccountView::currentisDraft() +{ + AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); + if (!view) return false; + return view->isDraftfolder(); +} diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 9f92090..5000202 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h @@ -1,44 +1,45 @@ #ifndef ACCOUNTVIEW_H #define ACCOUNTVIEW_H #include <qlistview.h> #include <qlist.h> class Selectstore; class RecMail; class RecBody; class Folder; class AbstractMail; class Account; class IMAPviewItem; class MHviewItem; class AccountView : public QListView { Q_OBJECT public: AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); virtual ~AccountView(); virtual void populate( QList<Account> list ); virtual RecBody fetchBody(const RecMail&aMail); virtual void downloadMails(Folder*fromFolder,AbstractMail*fromWrapper); + virtual bool currentisDraft(); 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>*); protected: QListViewItem* m_currentItem; QValueList<IMAPviewItem*> imapAccounts; QValueList<MHviewItem*> mhAccounts; }; #endif diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index b5cd75b..b9c9cbc 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp @@ -1,239 +1,301 @@ #include <qt.h> #include <opie2/ofiledialog.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/contact.h> #include "composemail.h" #include <libmailwrapper/smtpwrapper.h> +#include <libmailwrapper/storemail.h> +#include <libmailwrapper/abstractmail.h> +#include <libmailwrapper/mailtypes.h> ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) : ComposeMailUI( parent, name, modal, flags ) { settings = s; m_replyid = ""; QString vfilename = Global::applicationFileName("addressbook", "businesscard.vcf"); Contact c; if (QFile::exists(vfilename)) { c = Contact::readVCard( vfilename )[0]; } QStringList mails = c.emailList(); QString defmail = c.defaultEmail(); if (defmail.length()!=0) { fromBox->insertItem(defmail); } QStringList::ConstIterator sit = mails.begin(); for (;sit!=mails.end();++sit) { if ( (*sit)==defmail) continue; fromBox->insertItem((*sit)); } senderNameEdit->setText(c.firstName()+" "+c.lastName()); Config cfg( "mail" ); cfg.setGroup( "Compose" ); checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); attList->addColumn( tr( "Name" ) ); attList->addColumn( tr( "Size" ) ); QList<Account> accounts = settings->getAccounts(); Account *it; for ( it = accounts.first(); it; it = accounts.next() ) { if ( it->getType()==MAILLIB::A_SMTP ) { SMTPaccount *smtp = static_cast<SMTPaccount *>(it); smtpAccountBox->insertItem( smtp->getAccountName() ); smtpAccounts.append( smtp ); } } if ( smtpAccounts.count() > 0 ) { fillValues( smtpAccountBox->currentItem() ); } else { QMessageBox::information( this, tr( "Problem" ), tr( "<p>Please create an SMTP account first.</p>" ), tr( "Ok" ) ); return; } connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); } void ComposeMail::pickAddress( QLineEdit *line ) { QString names = AddressPicker::getNames(); if ( line->text().isEmpty() ) { line->setText( names ); } else if ( !names.isEmpty() ) { line->setText( line->text() + ", " + names ); } } void ComposeMail::setTo( const QString & to ) { toLine->setText( to ); } void ComposeMail::setSubject( const QString & subject ) { subjectLine->setText( subject ); } void ComposeMail::setInReplyTo( const QString & messageId ) { m_replyid = messageId; } void ComposeMail::setMessage( const QString & text ) { message->setText( text ); } void ComposeMail::pickAddressTo() { pickAddress( toLine ); } void ComposeMail::pickAddressCC() { pickAddress( ccLine ); } void ComposeMail::pickAddressBCC() { pickAddress( bccLine ); } void ComposeMail::pickAddressReply() { pickAddress( replyLine ); } -void ComposeMail::fillValues( int current ) +void ComposeMail::fillValues( int ) { #if 0 SMTPaccount *smtp = smtpAccounts.at( current ); ccLine->clear(); if ( smtp->getUseCC() ) { ccLine->setText( smtp->getCC() ); } bccLine->clear(); if ( smtp->getUseBCC() ) { bccLine->setText( smtp->getBCC() ); } replyLine->clear(); if ( smtp->getUseReply() ) { replyLine->setText( smtp->getReply() ); } sigMultiLine->setText( smtp->getSignature() ); #endif } void ComposeMail::slotAdjustColumns() { int currPage = tabWidget->currentPageIndex(); tabWidget->showPage( attachTab ); attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); attList->setColumnWidth( 1, 80 ); tabWidget->setCurrentPage( currPage ); } void ComposeMail::addAttachment() { DocLnk lnk = Opie::OFileDialog::getOpenFileName( 1, "/" ); if ( !lnk.name().isEmpty() ) { Attachment *att = new Attachment( lnk ); (void) new AttachViewItem( attList, att ); } } void ComposeMail::removeAttachment() { if ( !attList->currentItem() ) { QMessageBox::information( this, tr( "Error" ), tr( "<p>Please select a File.</p>" ), tr( "Ok" ) ); } else { attList->takeItem( attList->currentItem() ); } } void ComposeMail::accept() { if ( checkBoxLater->isChecked() ) { qDebug( "Send later" ); } #if 0 qDebug( "Sending Mail with " + smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); #endif - Mail *mail = new Mail(); + Mail mail; SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); - mail->setMail(fromBox->currentText()); + mail.setMail(fromBox->currentText()); if ( !toLine->text().isEmpty() ) { - mail->setTo( toLine->text() ); + mail.setTo( toLine->text() ); } else { - qDebug( "No Reciever spezified -> returning" ); + QMessageBox::warning(0,tr("Sending mail"), + tr("No Receiver spezified" ) ); return; } - mail->setName(senderNameEdit->text()); - mail->setCC( ccLine->text() ); - mail->setBCC( bccLine->text() ); - mail->setReply( replyLine->text() ); - mail->setSubject( subjectLine->text() ); + mail.setName(senderNameEdit->text()); + mail.setCC( ccLine->text() ); + mail.setBCC( bccLine->text() ); + mail.setReply( replyLine->text() ); + mail.setSubject( subjectLine->text() ); if (!m_replyid.isEmpty()) { QStringList ids; ids.append(m_replyid); - mail->setInreply(ids); + mail.setInreply(ids); } QString txt = message->text(); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); txt.append( sigMultiLine->text() ); } qDebug(txt); - mail->setMessage( txt ); + mail.setMessage( txt ); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); while ( it != NULL ) { - mail->addAttachment( it->getAttachment() ); + mail.addAttachment( it->getAttachment() ); it = (AttachViewItem *) it->nextSibling(); } SMTPwrapper wrapper( smtp ); - wrapper.sendMail( *mail,checkBoxLater->isChecked() ); + wrapper.sendMail( mail,checkBoxLater->isChecked() ); QDialog::accept(); } +void ComposeMail::reject() +{ + int yesno = QMessageBox::warning(0,tr("Store message"), + tr("Store message into drafts?"), + tr("Yes"), + tr("No"),QString::null,0,1); + + if (yesno == 0) { + Mail mail; + mail.setMail(fromBox->currentText()); + mail.setTo( toLine->text() ); + mail.setName(senderNameEdit->text()); + mail.setCC( ccLine->text() ); + mail.setBCC( bccLine->text() ); + mail.setReply( replyLine->text() ); + mail.setSubject( subjectLine->text() ); + if (!m_replyid.isEmpty()) { + QStringList ids; + ids.append(m_replyid); + mail.setInreply(ids); + } + QString txt = message->text(); + if ( !sigMultiLine->text().isEmpty() ) { + txt.append( "\n--\n" ); + txt.append( sigMultiLine->text() ); + } + qDebug(txt); + mail.setMessage( txt ); + + /* only use the default drafts folder name! */ + Storemail wrapper(AbstractMail::draftFolder()); + wrapper.storeMail(mail); + + AttachViewItem *it = (AttachViewItem *) attList->firstChild(); + /* attachments we will ignore! */ + if ( it != NULL ) { + QMessageBox::warning(0,tr("Store message"), + tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); + } + } + QDialog::reject(); +} + +ComposeMail::~ComposeMail() +{ +} + +void ComposeMail::reEditMail(const RecMail¤t) +{ + RecMail data = current; + message->setText(data.Wrapper()->fetchBody(current).Bodytext()); + subjectLine->setText( data.getSubject()); + toLine->setText(data.To().join(",")); + ccLine->setText(data.CC().join(",")); + bccLine->setText(data.Bcc().join(",")); + replyLine->setText(data.Replyto()); +} + AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) : QListViewItem( parent ) { attachment = att; qDebug( att->getMimeType() ); setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? Resource::loadPixmap( "UnknownDocument-14" ) : attachment->getDocLnk().pixmap() ); setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); setText( 1, QString::number( att->getSize() ) ); } diff --git a/noncore/net/mail/composemail.h b/noncore/net/mail/composemail.h index 886fb1d..1b9fc79 100644 --- a/noncore/net/mail/composemail.h +++ b/noncore/net/mail/composemail.h @@ -1,74 +1,79 @@ #ifndef COMPOSEMAIL_H #define COMPOSEMAIL_H #include <qlineedit.h> #include <qlistview.h> #include "composemailui.h" #include "addresspickerui.h" #include <libmailwrapper/settings.h> #include <libmailwrapper/mailwrapper.h> class AddressPicker : public AddressPickerUI { - Q_OBJECT + Q_OBJECT public: - AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); - static QString getNames(); + AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); + static QString getNames(); protected: - QString selectedNames; - void accept(); + QString selectedNames; + void accept(); }; +class RecMail; class ComposeMail : public ComposeMailUI { Q_OBJECT - + public: ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); + virtual ~ComposeMail(); + + void reEditMail(const RecMail¤t); public slots: void slotAdjustColumns(); void setTo( const QString & to ); void setSubject( const QString & subject ); void setInReplyTo( const QString & messageId ); void setMessage( const QString & text ); protected slots: void accept(); - + void reject(); + private slots: void fillValues( int current ); void pickAddress( QLineEdit *line ); void pickAddressTo(); void pickAddressCC(); void pickAddressBCC(); void pickAddressReply(); void addAttachment(); void removeAttachment(); protected: Settings *settings; QList<SMTPaccount> smtpAccounts; QString m_replyid; }; class AttachViewItem : public QListViewItem { -public: +public: AttachViewItem( QListView *parent, Attachment *att ); - Attachment *getAttachment() { return attachment; } + Attachment *getAttachment() { return attachment; } private: - Attachment *attachment; + Attachment *attachment; }; #endif diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 9960f88..d71d35c 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp @@ -1,143 +1,166 @@ #include "abstractmail.h" #include "imapwrapper.h" #include "pop3wrapper.h" #include "nntpwrapper.h" #include "mhwrapper.h" #include "mailtypes.h" #include <qfile.h> #include <qtextstream.h> #include <stdlib.h> #include <libetpan/mailmime_content.h> #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(NNTPaccount *a) { return new NNTPwrapper(a); } AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) { return new MHwrapper(a,name); } +AbstractMail* AbstractMail::getWrapper(Account*a) +{ + if (!a) return 0; + switch (a->getType()) { + case MAILLIB::A_IMAP: + return new IMAPwrapper((IMAPaccount*)a); + break; + case MAILLIB::A_POP3: + return new POP3wrapper((POP3account*)a); + break; + case MAILLIB::A_NNTP: + return new NNTPwrapper((NNTPaccount*)a); + break; + default: + return 0; + } +} + 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") { mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; } else if (enc.lower()=="base64") { mimetype = MAILMIME_MECHANISM_BASE64; } else if (enc.lower()=="8bit") { mimetype = MAILMIME_MECHANISM_8BIT; } else if (enc.lower()=="binary") { mimetype = MAILMIME_MECHANISM_BINARY; } int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, &result_text,&target_length); encodedString* result = new encodedString(); if (err == MAILIMF_NO_ERROR) { result->setContent(result_text,target_length); } qDebug("Decode string finished"); return result; } QString AbstractMail::convert_String(const char*text) { size_t index = 0; char*res = 0; /* attention - doesn't work with arm systems! */ int err = mailmime_encoded_phrase_parse("iso-8859-1", text, strlen(text),&index, "iso-8859-1",&res); if (err != MAILIMF_NO_ERROR) { if (res) free(res); return QString(text); } if (res) { QString result(res); free(res); return result; } return QString(text); } /* cp & paste from launcher */ QString AbstractMail::gen_attachment_id() { QFile file( "/proc/sys/kernel/random/uuid" ); if (!file.open(IO_ReadOnly ) ) return QString::null; QTextStream stream(&file); return "{" + stream.read().stripWhiteSpace() + "}"; } 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; } +QString AbstractMail::draftFolder() +{ + return QString("Drafts"); +} + /* temporary - will be removed when implemented in all classes */ void AbstractMail::deleteMails(const QString &,QList<RecMail> &) { } void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) { QList<RecMail> t; listMessages(fromFolder->getName(),t); encodedString*st = 0; while (t.count()>0) { RecMail*r = t.at(0); st = fetchRawBody(*r); if (st) { targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); delete st; } t.removeFirst(); } if (moveit) { deleteAllMail(fromFolder); } } void AbstractMail::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) { encodedString*st = 0; st = fetchRawBody(mail); if (st) { targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); delete st; } if (moveit) { deleteMail(mail); } } diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 442ebfe..d377452 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h @@ -1,68 +1,70 @@ #ifndef __abstract_mail_ #define __abstract_mail_ #include "maildefines.h" #include <qobject.h> #include "settings.h" class RecMail; class RecBody; class RecPart; class IMAPwrapper; class POP3wrapper; class Folder; class encodedString; struct folderStat; 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 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 mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); - virtual void cleanMimeCache(){}; + virtual void cleanMimeCache(){}; /* mail box methods */ /* parameter is the box to create. - * if the implementing subclass has prefixes, + * 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); static AbstractMail* getWrapper(NNTPaccount *a); /* mbox only! */ static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); + static AbstractMail* getWrapper(Account*a); static QString defaultLocalfolder(); - + static QString draftFolder(); + virtual MAILLIB::ATYPE 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/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index 137a6ef..ffa049f 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp @@ -357,111 +357,119 @@ QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) void Genericwrapper::cleanMimeCache() { QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); for (;it!=bodyCache.end();++it) { encodedString*t = it.data(); //it.setValue(0); if (t) delete t; } bodyCache.clear(); qDebug("Genericwrapper: cache cleaned"); } QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) { QStringList res; if (!in_replies || !in_replies->mid_list) return res; clistiter * current = 0; for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { QString h((char*)current->data); while (h.length()>0 && h[0]=='<') { h.remove(0,1); } while (h.length()>0 && h[h.length()-1]=='>') { h.remove(h.length()-1,1); } if (h.length()>0) { res.append(h); } } return res; } void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to) { int r; mailmessage_list * env_list = 0; r = mailsession_get_messages_list(session,&env_list); if (r != MAIL_NO_ERROR) { qDebug("Error message list"); return; } r = mailsession_get_envelopes_list(session, env_list); if (r != MAIL_NO_ERROR) { qDebug("Error filling message list"); if (env_list) { mailmessage_list_free(env_list); } return; } mailimf_references * refs = 0; mailimf_in_reply_to * in_replies = 0; uint32_t i = 0; for(; i < carray_count(env_list->msg_tab) ; ++i) { mailmessage * msg; QBitArray mFlags(7); msg = (mailmessage*)carray_get(env_list->msg_tab, i); if (msg->msg_fields == NULL) { //qDebug("could not fetch envelope of message %i", i); continue; } RecMail * mail = new RecMail(); mail->setWrapper(this); mail_flags * flag_result = 0; r = mailmessage_get_flags(msg,&flag_result); if (r == MAIL_ERROR_NOT_IMPLEMENTED) { mFlags.setBit(FLAG_SEEN); } mailimf_single_fields single_fields; mailimf_single_fields_init(&single_fields, msg->msg_fields); mail->setMsgsize(msg->msg_size); mail->setFlags(mFlags); mail->setMbox(mailbox); mail->setNumber(msg->msg_index); if (single_fields.fld_subject) mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); if (single_fields.fld_from) mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); if (!mbox_as_to) { if (single_fields.fld_to) mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); } else { mail->setTo(mailbox); } if (single_fields.fld_cc) mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); if (single_fields.fld_bcc) mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); if (single_fields.fld_orig_date) mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); // crashes when accessing pop3 account? if (single_fields.fld_message_id->mid_value) { mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); qDebug("Msgid == %s",mail->Msgid().latin1()); } + if (single_fields.fld_reply_to) { + QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); + if (t.count()>0) { + mail->setReplyto(t[0]); + } + } +#if 0 refs = single_fields.fld_references; if (refs && refs->mid_list && clist_count(refs->mid_list)) { char * text = (char*)refs->mid_list->first->data; mail->setReplyto(QString(text)); } +#endif if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && clist_count(single_fields.fld_in_reply_to->mid_list)) { mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); } target.append(mail); } if (env_list) { mailmessage_list_free(env_list); } } diff --git a/noncore/net/mail/libmailwrapper/libmailwrapper.pro b/noncore/net/mail/libmailwrapper/libmailwrapper.pro index cb1e573..d28079e 100644 --- a/noncore/net/mail/libmailwrapper/libmailwrapper.pro +++ b/noncore/net/mail/libmailwrapper/libmailwrapper.pro @@ -1,52 +1,54 @@ TEMPLATE = lib CONFIG += qt warn_on debug HEADERS = mailwrapper.h \ imapwrapper.h \ mailtypes.h \ pop3wrapper.h \ abstractmail.h \ smtpwrapper.h \ genericwrapper.h \ mboxwrapper.h \ settings.h \ logindialog.h \ sendmailprogress.h \ statusmail.h \ mhwrapper.h \ nntpwrapper.h \ - generatemail.h + generatemail.h \ + storemail.h SOURCES = imapwrapper.cpp \ mailwrapper.cpp \ mailtypes.cpp \ pop3wrapper.cpp \ abstractmail.cpp \ smtpwrapper.cpp \ genericwrapper.cpp \ mboxwrapper.cpp \ settings.cpp \ logindialog.cpp \ sendmailprogress.cpp \ statusmail.cpp \ mhwrapper.cpp \ nntpwrapper.cpp \ - generatemail.cpp + generatemail.cpp \ + storemail.cpp INTERFACES = logindialogui.ui \ sendmailprogressui.ui INCLUDEPATH += $(OPIEDIR)/include CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) contains( CONFTEST, y ){ LIBS += -lqpe -letpan -lssl -lcrypto -liconv }else{ LIBS += -lqpe -letpan -lssl -lcrypto } DESTDIR = $(OPIEDIR)/lib$(PROJMAK) TARGET = mailwrapper include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index e4646d9..49b3caa 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp @@ -1,134 +1,135 @@ #include "mailtypes.h" #include <stdlib.h> RecMail::RecMail() :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) { init(); } RecMail::RecMail(const RecMail&old) :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) { init(); copy_old(old); qDebug("Copy constructor RecMail"); } RecMail::~RecMail() { wrapper = 0; } void RecMail::copy_old(const RecMail&old) { subject = old.subject; date = old.date; mbox = old.mbox; msg_id = old.msg_id; msg_size = old.msg_size; msg_number = old.msg_number; from = old.from; msg_flags = old.msg_flags; to = old.to; cc = old.cc; bcc = old.bcc; wrapper = old.wrapper; in_reply_to = old.in_reply_to; references = old.references; + replyto = old.replyto; } void RecMail::init() { to.clear(); cc.clear(); bcc.clear(); in_reply_to.clear(); references.clear(); wrapper = 0; } void RecMail::setWrapper(AbstractMail*awrapper) { wrapper = awrapper; } AbstractMail* RecMail::Wrapper() { return wrapper; } void RecMail::setTo(const QStringList&list) { to = list; } const QStringList&RecMail::To()const { return to; } void RecMail::setCC(const QStringList&list) { cc = list; } const QStringList&RecMail::CC()const { return cc; } void RecMail::setBcc(const QStringList&list) { bcc = list; } const QStringList& RecMail::Bcc()const { return bcc; } void RecMail::setInreply(const QStringList&list) { in_reply_to = list; } const QStringList& RecMail::Inreply()const { return in_reply_to; } void RecMail::setReferences(const QStringList&list) { references = list; } const QStringList& RecMail::References()const { return references; } RecPart::RecPart() : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) { m_Parameters.clear(); m_poslist.clear(); } RecPart::~RecPart() { } void RecPart::setSize(unsigned int size) { m_size = size; } const unsigned int RecPart::Size()const { return m_size; } void RecPart::setLines(unsigned int lines) { m_lines = lines; diff --git a/noncore/net/mail/libmailwrapper/storemail.cpp b/noncore/net/mail/libmailwrapper/storemail.cpp new file mode 100644 index 0000000..53101f8 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/storemail.cpp @@ -0,0 +1,90 @@ +#include "storemail.h" +#include "mailwrapper.h" +#include "settings.h" +#include "abstractmail.h" + +#include <libetpan/libetpan.h> + +#include <qstring.h> + +#include <stdlib.h> + +Storemail::Storemail(Account*aAccount,const QString&aFolder) + : Generatemail() +{ + wrapper = 0; + m_Account = aAccount; + m_tfolder = aFolder; + wrapper = AbstractMail::getWrapper(m_Account); + if (wrapper) { + wrapper->createMbox(m_tfolder); + } +} + +Storemail::Storemail(const QString&dir,const QString&aFolder) + : Generatemail() +{ + wrapper = 0; + m_Account = 0; + m_tfolder = aFolder; + wrapper = AbstractMail::getWrapper(dir); + if (wrapper) { + wrapper->createMbox(m_tfolder); + } +} + +Storemail::Storemail(const QString&aFolder) + : Generatemail() +{ + wrapper = 0; + m_Account = 0; + m_tfolder = aFolder; + wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); + if (wrapper) { + wrapper->createMbox(m_tfolder); + } +} + +Storemail::~Storemail() +{ +} + +int Storemail::storeMail(const Mail&mail) +{ + if (!wrapper) return 0; + int ret = 1; + + mailmime * mimeMail = 0; + mimeMail = createMimeMail(mail ); + if ( mimeMail == NULL ) { + qDebug( "storeMail: error creating mime mail" ); + return 0; + } + char *data; + size_t size; + data = 0; + + mailmessage * msg = 0; + msg = mime_message_init(mimeMail); + mime_message_set_tmpdir(msg,getenv( "HOME" )); + int r = mailmessage_fetch(msg,&data,&size); + mime_message_detach_mime(msg); + mailmessage_free(msg); + msg = 0; + if (r != MAIL_NO_ERROR || !data) { + qDebug("Error fetching mime..."); + ret = 0; + } + + if (ret) { + wrapper->storeMessage(data,size,m_tfolder); + } + + if (data) { + free(data); + } + if (mimeMail) { + mailmime_free( mimeMail ); + } + return ret; +} diff --git a/noncore/net/mail/libmailwrapper/storemail.h b/noncore/net/mail/libmailwrapper/storemail.h new file mode 100644 index 0000000..872c981 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/storemail.h @@ -0,0 +1,29 @@ +#ifndef __STORE_MAIL_H +#define __STORE_MAIL_H + +#include <qpe/applnk.h> + +#include "generatemail.h" + +class Account; +class Mail; +class AbstractMail; + +class Storemail : public Generatemail +{ + Q_OBJECT +public: + Storemail(Account*aAccount,const QString&aFolder); + Storemail(const QString&dir,const QString&aFolder); + Storemail(const QString&aFolder); + virtual ~Storemail(); + + int storeMail(const Mail&mail); + +protected: + Account* m_Account; + QString m_tfolder; + AbstractMail*wrapper; +}; + +#endif diff --git a/noncore/net/mail/mailistviewitem.cpp b/noncore/net/mail/mailistviewitem.cpp index f224dc3..75633ef 100644 --- a/noncore/net/mail/mailistviewitem.cpp +++ b/noncore/net/mail/mailistviewitem.cpp @@ -1,65 +1,72 @@ #include "mailistviewitem.h" +#include <libmailwrapper/abstractmail.h> #include <qtextstream.h> #include <qpe/resource.h> MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) :QListViewItem(parent,item),mail_data() { } void MailListViewItem::showEntry() { if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { /* I think it looks nicer if there are not such a log of icons but only on mails replied or new - Alwin*/ //setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); } else { setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") ); } double s = mail_data.Msgsize(); int w; w=0; while (s>1024) { s/=1024; ++w; if (w>=2) break; } QString q=""; QString fsize=""; switch(w) { case 1: q="k"; break; case 2: q="M"; break; default: break; } { QTextOStream o(&fsize); if (w>0) o.precision(2); else o.precision(0); o.setf(QTextStream::fixed); o << s << " " << q << "Byte"; } setText(1,mail_data.getSubject()); setText(2,mail_data.getFrom()); setText(3,fsize); setText(4,mail_data.getDate()); } void MailListViewItem::storeData(const RecMail&data) { mail_data = data; } const RecMail& MailListViewItem::data()const { return mail_data; } + +MAILLIB::ATYPE MailListViewItem::wrapperType() +{ + if (!mail_data.Wrapper()) return MAILLIB::A_UNDEFINED; + return mail_data.Wrapper()->getType(); +} diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h index 3b352a2..f736de0 100644 --- a/noncore/net/mail/mailistviewitem.h +++ b/noncore/net/mail/mailistviewitem.h @@ -1,21 +1,23 @@ #ifndef __MAILLISTVIEWITEM_H #define __MAILLISTVIEWITEM_H #include <qlistview.h> #include <libmailwrapper/mailtypes.h> +#include <libmailwrapper/maildefines.h> class MailListViewItem:public QListViewItem { public: MailListViewItem(QListView * parent, MailListViewItem * after ); virtual ~MailListViewItem(){} - + void storeData(const RecMail&data); const RecMail&data()const; void showEntry(); - + MAILLIB::ATYPE wrapperType(); + protected: RecMail mail_data; }; #endif diff --git a/noncore/net/mail/nntpgroupsdlg.cpp b/noncore/net/mail/nntpgroupsdlg.cpp index 752ce3c..c94d9fa 100644 --- a/noncore/net/mail/nntpgroupsdlg.cpp +++ b/noncore/net/mail/nntpgroupsdlg.cpp @@ -1,29 +1,29 @@ #include "nntpgroupsdlg.h" #include "nntpgroups.h" #include <libmailwrapper/settings.h> #include <qlayout.h> NNTPGroupsDlg::NNTPGroupsDlg(NNTPaccount *account,QWidget * parent, const char * name) - : QDialog(parent,name,true) + : QDialog(parent,name,true,WStyle_ContextHelp) { setCaption(tr("Subscribed newsgroups")); m_Account = account; QVBoxLayout*dlglayout = new QVBoxLayout(this); dlglayout->setSpacing(2); dlglayout->setMargin(1); groupsWidget = new NNTPGroups(account,this); dlglayout->addWidget(groupsWidget); } NNTPGroupsDlg::~NNTPGroupsDlg() { } void NNTPGroupsDlg::accept() { groupsWidget->storeValues(); m_Account->save(); QDialog::accept(); } diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 61e7dc4..d95b3c9 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp @@ -84,178 +84,195 @@ void OpieMail::slotSendQueued() { if ( it->getType() == MAILLIB::A_SMTP ) { smtp = static_cast<SMTPaccount *>(it); smtpList.append(smtp); } } if (smtpList.count()==0) { QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); return; } if (smtpList.count()==1) { smtp = smtpList.at(0); } else { smtp = 0; selectsmtp selsmtp; selsmtp.setSelectionlist(&smtpList); if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) { smtp = selsmtp.selected_smtp(); } } if (smtp) { SMTPwrapper * wrap = new SMTPwrapper(smtp); if ( wrap->flushOutbox() ) { QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); } delete wrap; } } void OpieMail::slotSearchMails() { qDebug( "Search Mails" ); } void OpieMail::slotEditSettings() { SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); QPEApplication::execDialog( &settingsDialog ); } void OpieMail::slotEditAccounts() { qDebug( "Edit Accounts" ); EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); eaDialog.slotAdjustColumns(); QPEApplication::execDialog( &eaDialog ); if ( settings ) delete settings; settings = new Settings(); folderView->populate( settings->getAccounts() ); } void OpieMail::displayMail() { QListViewItem*item = mailView->currentItem(); if (!item) return; RecMail mail = ((MailListViewItem*)item)->data(); RecBody body = folderView->fetchBody(mail); ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); readMail.setBody( body ); readMail.setMail( mail ); readMail.showMaximized(); readMail.exec(); if ( readMail.deleted ) { folderView->refreshCurrent(); } else { ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); } } void OpieMail::slotDeleteMail() { if (!mailView->currentItem()) return; RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { mail.Wrapper()->deleteMail( mail ); folderView->refreshCurrent(); } } void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) { if (!mailView->currentItem()) return; - RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); + MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); /* just the RIGHT button - or hold on pda */ if (button!=2) {return;} qDebug("Event right/hold"); if (!item) return; QPopupMenu *m = new QPopupMenu(0); if (m) { - if (mail.Wrapper()->getType()==MAILLIB::A_NNTP) { + if (mailtype==MAILLIB::A_NNTP) { m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); // m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); } else { + if (folderView->currentisDraft()) { + m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); + } m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); } m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); delete m; } } void OpieMail::slotShowFolders( bool show ) { qDebug( "Show Folders" ); if ( show && folderView->isHidden() ) { qDebug( "-> showing" ); folderView->show(); } else if ( !show && !folderView->isHidden() ) { qDebug( "-> hiding" ); folderView->hide(); } } void OpieMail::refreshMailView(QList<RecMail>*list) { MailListViewItem*item = 0; mailView->clear(); for (unsigned int i = 0; i < list->count();++i) { item = new MailListViewItem(mailView,item); item->storeData(*(list->at(i))); item->showEntry(); } } void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) { /* just LEFT button - or tap with stylus on pda */ if (button!=1) return; if (!item) return; - displayMail(); + if (folderView->currentisDraft()) { + reEditMail(); + } else { + displayMail(); + } } void OpieMail::slotMoveCopyMail() { if (!mailView->currentItem()) return; RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); AbstractMail*targetMail = 0; QString targetFolder = ""; Selectstore sels; folderView->setupFolderselect(&sels); if (!sels.exec()) return; targetMail = sels.currentMail(); targetFolder = sels.currentFolder(); if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || targetFolder.isEmpty()) { return; } if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { QMessageBox::critical(0,tr("Error creating new Folder"), tr("<center>Error while creating<br>new folder - breaking.</center>")); return; } mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); folderView->refreshCurrent(); } + +void OpieMail::reEditMail() +{ + if (!mailView->currentItem()) return; + + ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); + compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); + compose.slotAdjustColumns(); + QPEApplication::execDialog( &compose ); +} diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h index 5821856..88c7ea1 100644 --- a/noncore/net/mail/opiemail.h +++ b/noncore/net/mail/opiemail.h @@ -1,39 +1,40 @@ #ifndef OPIEMAIL_H #define OPIEMAIL_H #include "mainwindow.h" #include <libmailwrapper/settings.h> class OpieMail : public MainWindow { Q_OBJECT public: OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); virtual ~OpieMail(); static QString appName() { return QString::fromLatin1("opiemail"); } public slots: virtual void slotwriteMail(const QString&name,const QString&email); virtual void slotComposeMail(); virtual void appMessage(const QCString &msg, const QByteArray &data); protected slots: virtual void slotSendQueued(); virtual void slotSearchMails(); virtual void slotEditSettings(); virtual void slotEditAccounts(); virtual void displayMail(); virtual void slotDeleteMail(); virtual void mailHold(int, QListViewItem *,const QPoint&,int); virtual void slotShowFolders( bool show ); virtual void refreshMailView(QList<RecMail>*); virtual void mailLeftClicked( int, QListViewItem *,const QPoint&,int ); virtual void slotMoveCopyMail(); + virtual void reEditMail(); private: Settings *settings; }; #endif |