author | harlekin <harlekin> | 2004-01-04 02:46:56 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2004-01-04 02:46:56 (UTC) |
commit | cda867a4d179eb3320c5a043cb9116014fa736b8 (patch) (side-by-side diff) | |
tree | 1dafac9c041634e19fab18759f181c41500346a5 /noncore | |
parent | 7bfc0889cf761e20402f775a46c8b8508c48ed8f (diff) | |
download | opie-cda867a4d179eb3320c5a043cb9116014fa736b8.zip opie-cda867a4d179eb3320c5a043cb9116014fa736b8.tar.gz opie-cda867a4d179eb3320c5a043cb9116014fa736b8.tar.bz2 |
adapted includes to the new lib
-rw-r--r-- | noncore/net/mail/accountview.cpp | 10 | ||||
-rw-r--r-- | noncore/net/mail/accountview.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/composemail.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/composemail.h | 5 | ||||
-rw-r--r-- | noncore/net/mail/editaccounts.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/mail.pro | 4 | ||||
-rw-r--r-- | noncore/net/mail/mailistviewitem.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.h | 3 |
12 files changed, 33 insertions, 26 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 9f07f56..2ce89db 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -1,276 +1,276 @@ #include <stdlib.h> #include "accountview.h" -#include "mailtypes.h" +#include <libmailwrapper/mailtypes.h> #include "defines.h" #include "newmaildir.h" #include <qmessagebox.h> #include <qpopupmenu.h> /** * POP3 Account stuff */ POP3viewItem::POP3viewItem( POP3account *a, QListView *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> & ) { 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 ); } 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 ); } else { setPixmap( 0, PIXMAP_INBOXFOLDER); } setText( 0, folder->getDisplayName() ); } void POP3folderItem::refresh(QList<RecMail>&target) { if (folder->may_select()) pop3->getWrapper()->listMessages( folder->getName(),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); } return m; } void POP3folderItem::contextMenuSelected(int which) { AccountView * view = (AccountView*)listView(); switch (which) { case 0: view->refreshCurrent(); break; case 1: deleteAllMail(pop3->getWrapper(),folder); break; default: break; } } /** * IMAP Account stuff */ IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) : AccountViewItem( parent ) { account = a; wrapper = AbstractMail::getWrapper( account ); setPixmap( 0, PIXMAP_IMAPFOLDER ); setText( 0, account->getAccountName() ); setOpen( true ); } IMAPviewItem::~IMAPviewItem() { delete wrapper; } AbstractMail *IMAPviewItem::getWrapper() { return wrapper; } IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start) { IMAPfolderItem*pitem,*sitem; if (!start) pitem = (IMAPfolderItem*)firstChild(); else pitem = (IMAPfolderItem*)start->firstChild(); while (pitem) { if (pitem->matchName(path)) { break; } if (pitem->childCount()>0) { sitem = findSubItem(path,pitem); if (sitem) { pitem = sitem; break; } } pitem=(IMAPfolderItem*)pitem->nextSibling(); } return pitem; } void IMAPviewItem::refresh(QList<RecMail>&) { refreshFolders(false); } void IMAPviewItem::refreshFolders(bool force) { if (childCount()>0 && force==false) return; QList<Folder> *folders = wrapper->listFolders(); - QListViewItem *child = firstChild(); + QListViewItem *child = firstChild(); while ( child ) { QListViewItem *tmp = child; child = child->nextSibling(); delete tmp; } 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(); 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); } return m; } void IMAPviewItem::createNewFolder() { Newmdirdlg ndirdlg; ndirdlg.showMaximized(); if (ndirdlg.exec()) { QString ndir = ndirdlg.Newdir(); bool makesubs = ndirdlg.subpossible(); QString delemiter = "/"; IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); if (item) { delemiter = item->Delemiter(); } if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { refreshFolders(true); } } } void IMAPviewItem::contextMenuSelected(int id) { qDebug("Id selected: %i",id); switch (id) { case 0: refreshFolders(true); break; case 1: createNewFolder(); break; default: break; } } RecBody IMAPviewItem::fetchBody(const RecMail&) { return RecBody(); } IMAPfolderItem::~IMAPfolderItem() { delete folder; } 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); } setText( 0, folder->getDisplayName() ); } @@ -324,346 +324,346 @@ QPopupMenu * IMAPfolderItem::getContextMenu() } if (folder->getDisplayName().lower()!="inbox") { m->insertItem(QObject::tr("Delete folder",contextName),3); } } return m; } void IMAPfolderItem::createNewFolder() { Newmdirdlg ndirdlg; ndirdlg.showMaximized(); if (ndirdlg.exec()) { QString ndir = ndirdlg.Newdir(); bool makesubs = ndirdlg.subpossible(); QString delemiter = Delemiter(); if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { imap->refreshFolders(true); } } } void IMAPfolderItem::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 (imap->getWrapper()->deleteMbox(folder)) { 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::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; default: break; } } /** * Generic stuff */ const QString AccountViewItem::contextName="AccountViewItem"; 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(); } } } 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 ) ) ); + SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); setSorting(0); } 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(); QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); (void) new MBOXviewItem(localfolders,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 ); } else if ( it->getType().compare( "POP3" ) == 0 ) { POP3account *pop3 = static_cast<POP3account *>(it); qDebug( "added POP3 " + pop3->getAccountName() ); (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); } 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); } /** * MBOX Account stuff */ MBOXviewItem::MBOXviewItem( const QString&aPath, QListView *parent ) : AccountViewItem( parent ) { m_Path = aPath; wrapper = AbstractMail::getWrapper( m_Path ); setPixmap( 0, PIXMAP_LOCALFOLDER ); setText( 0, " Local Folders" ); setOpen( true ); } MBOXviewItem::~MBOXviewItem() { delete wrapper; } AbstractMail *MBOXviewItem::getWrapper() { return wrapper; } void MBOXviewItem::refresh( QList<RecMail> & ) { refresh(false); } void MBOXviewItem::refresh(bool force) { if (childCount()>0 && force==false) 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 MBOXfolderItem( it, this , item ); item->setSelectable(it->may_select()); } // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! folders->setAutoDelete(false); delete folders; } RecBody MBOXviewItem::fetchBody( const RecMail &mail ) { qDebug( "MBOX fetchBody" ); return wrapper->fetchBody( mail ); } QPopupMenu * MBOXviewItem::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); } return m; } void MBOXviewItem::createFolder() { Newmdirdlg ndirdlg(0,0,true); ndirdlg.showMaximized(); if (ndirdlg.exec()) { QString ndir = ndirdlg.Newdir(); if (wrapper->createMbox(ndir)) { refresh(true); } } } void MBOXviewItem::contextMenuSelected(int which) { switch (which) { case 0: refresh(true); break; case 1: createFolder(); break; default: break; } } MBOXfolderItem::~MBOXfolderItem() { delete folder; } MBOXfolderItem::MBOXfolderItem( Folder *folderInit, MBOXviewItem *parent , QListViewItem*after ) : AccountViewItem( parent,after ) { 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 ); + setPixmap( 0, PIXMAP_MBOXFOLDER ); } setText( 0, folder->getDisplayName() ); } 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() { 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(); MBOXviewItem * 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 * MBOXfolderItem::getContextMenu() { QPopupMenu *m = new QPopupMenu(0); if (m) { m->insertItem(QObject::tr("Delete all mails",contextName),0); m->insertItem(QObject::tr("Delete folder",contextName),1); } return m; } void MBOXfolderItem::contextMenuSelected(int which) { switch(which) { case 0: deleteAllMail(mbox->getWrapper(),folder); break; case 1: deleteFolder(); break; default: break; } } diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h index 361dd86..1d2bf19 100644 --- a/noncore/net/mail/accountview.h +++ b/noncore/net/mail/accountview.h @@ -1,105 +1,105 @@ #ifndef ACCOUNTVIEW_H #define ACCOUNTVIEW_H #include <qlistview.h> #include <qlist.h> -#include "settings.h" -#include "mailwrapper.h" -#include "abstractmail.h" +#include <libmailwrapper/settings.h> +#include <libmailwrapper/mailwrapper.h> +#include <libmailwrapper/abstractmail.h> class POP3wrapper; class RecMail; class RecBody; class QPopupMenu; class AccountViewItem : public QListViewItem { public: AccountViewItem( QListView *parent ) : QListViewItem( parent ) {} AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {} AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {} virtual void refresh(QList<RecMail>&)=0; virtual RecBody fetchBody(const RecMail&)=0; virtual QPopupMenu * getContextMenu(){return 0;}; virtual void contextMenuSelected(int){} protected: virtual void deleteAllMail(AbstractMail*wrapper,Folder*f); static const QString contextName; }; class POP3viewItem : public AccountViewItem { public: POP3viewItem( POP3account *a, QListView *parent ); ~POP3viewItem(); virtual void refresh( QList<RecMail> &target ); virtual RecBody fetchBody( const RecMail &mail ); AbstractMail *getWrapper(); private: POP3account *account; AbstractMail *wrapper; }; class POP3folderItem : public AccountViewItem { public: POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after ); ~POP3folderItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); private: Folder *folder; POP3viewItem *pop3; }; class IMAPfolderItem; class IMAPviewItem : public AccountViewItem { friend class IMAPfolderItem; public: IMAPviewItem( IMAPaccount *a, QListView *parent ); ~IMAPviewItem(); virtual void refresh(QList<RecMail>&); virtual RecBody fetchBody(const RecMail&); AbstractMail *getWrapper(); virtual QPopupMenu * getContextMenu(); virtual void contextMenuSelected(int); protected: IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0); virtual void refreshFolders(bool force=false); virtual void createNewFolder(); private: IMAPaccount *account; AbstractMail *wrapper; }; class IMAPfolderItem : public AccountViewItem { public: IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after ); IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); ~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: Folder *folder; diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index 13c7900..5e823e8 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp @@ -1,239 +1,240 @@ #include <qt.h> #include <opie/ofiledialog.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/contact.h> #include "composemail.h" -#include "smtpwrapper.h" + +#include <libmailwrapper/smtpwrapper.h> ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) : ComposeMailUI( parent, name, modal, flags ) { settings = s; 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().compare( "SMTP" ) == 0 ) { 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 ) { /* QString toline; QStringList toEntry = to; for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { toline += (*it); } toLine->setText( toline ); */ toLine->setText( to ); } void ComposeMail::setSubject( const QString & subject ) { subjectLine->setText( subject ); } void ComposeMail::setInReplyTo( const QString & 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 ) { #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 = 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(); - + SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); mail->setMail(fromBox->currentText()); if ( !toLine->text().isEmpty() ) { mail->setTo( toLine->text() ); } else { qDebug( "No Reciever spezified -> returning" ); return; } mail->setName(senderNameEdit->text()); mail->setCC( ccLine->text() ); mail->setBCC( bccLine->text() ); mail->setReply( replyLine->text() ); mail->setSubject( subjectLine->text() ); QString txt = message->text(); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); txt.append( sigMultiLine->text() ); } qDebug(txt); mail->setMessage( txt ); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); while ( it != NULL ) { mail->addAttachment( it->getAttachment() ); it = (AttachViewItem *) it->nextSibling(); } SMTPwrapper wrapper( settings ); wrapper.sendMail( *mail,smtp,checkBoxLater->isChecked() ); - + QDialog::accept(); } 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 230e397..604c862 100644 --- a/noncore/net/mail/composemail.h +++ b/noncore/net/mail/composemail.h @@ -1,75 +1,76 @@ #ifndef COMPOSEMAIL_H #define COMPOSEMAIL_H #include <qlineedit.h> #include <qlistview.h> #include "composemailui.h" #include "addresspickerui.h" -#include "settings.h" -#include "mailwrapper.h" +#include <libmailwrapper/settings.h> +#include <libmailwrapper/mailwrapper.h> + class AddressPicker : public AddressPickerUI { Q_OBJECT public: AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); static QString getNames(); protected: QString selectedNames; void accept(); }; class ComposeMail : public ComposeMailUI { Q_OBJECT public: ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); 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(); private slots: void fillValues( int current ); void pickAddress( QLineEdit *line ); void pickAddressTo(); void pickAddressCC(); void pickAddressBCC(); void pickAddressReply(); void addAttachment(); void removeAttachment(); private: Settings *settings; QList<SMTPaccount> smtpAccounts; }; class AttachViewItem : public QListViewItem { public: AttachViewItem( QListView *parent, Attachment *att ); Attachment *getAttachment() { return attachment; } private: Attachment *attachment; }; #endif diff --git a/noncore/net/mail/editaccounts.h b/noncore/net/mail/editaccounts.h index 10ed8b8..6022eef 100644 --- a/noncore/net/mail/editaccounts.h +++ b/noncore/net/mail/editaccounts.h @@ -1,109 +1,110 @@ #ifndef EDITACCOUNTS_H #define EDITACCOUNTS_H #include <qstring.h> #include <qlistview.h> #include "editaccountsui.h" #include "selectmailtypeui.h" #include "imapconfigui.h" #include "pop3configui.h" #include "smtpconfigui.h" #include "nntpconfigui.h" -#include "settings.h" +#include <libmailwrapper/settings.h> + class AccountListItem : public QListViewItem { public: AccountListItem( QListView *parent, Account *a); Account *getAccount() { return account; } private: Account *account; }; class EditAccounts : public EditAccountsUI { Q_OBJECT public: EditAccounts( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); public slots: void slotNewAccount( const QString &type ); void slotEditAccount( Account *account ); void slotDeleteAccount( Account * account ); void slotAdjustColumns(); protected slots: void slotFillLists(); void slotNewMail(); void slotEditMail(); void slotDeleteMail(); void slotNewNews(); void slotEditNews(); void slotDeleteNews(); void accept(); private: Settings *settings; }; class SelectMailType : public SelectMailTypeUI { Q_OBJECT public: SelectMailType( QString *selection = 0, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); private slots: void slotSelection( const QString &sel ); private: QString *selected; }; class IMAPconfig : public IMAPconfigUI { Q_OBJECT public: IMAPconfig( IMAPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); public slots: void fillValues(); protected slots: void slotSSL( bool enabled ); void accept(); private: IMAPaccount *data; }; class POP3config : public POP3configUI { Q_OBJECT public: POP3config( POP3account *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); public slots: void fillValues(); protected slots: void slotSSL( bool enabled ); void accept(); private: POP3account *data; }; class SMTPconfig : public SMTPconfigUI { diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index 69e1450..a96c88e 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro @@ -1,52 +1,52 @@ CONFIG += qt warn_on debug quick-app HEADERS = defines.h \ editaccounts.h \ composemail.h \ accountview.h \ mainwindow.h \ viewmail.h \ viewmailbase.h \ opiemail.h \ mailistviewitem.h \ settingsdialog.h \ statuswidget.h \ newmaildir.h SOURCES = main.cpp \ opiemail.cpp \ mainwindow.cpp \ accountview.cpp \ composemail.cpp \ addresspicker.cpp \ editaccounts.cpp \ viewmail.cpp \ viewmailbase.cpp \ settingsdialog.cpp \ statuswidget.cpp \ newmaildir.cpp INTERFACES = editaccountsui.ui \ selectmailtypeui.ui \ imapconfigui.ui \ pop3configui.ui \ nntpconfigui.ui \ smtpconfigui.ui \ addresspickerui.ui \ composemailui.ui \ settingsdialogui.ui \ statuswidgetui.ui \ newmaildirui.ui INCLUDEPATH += $(OPIEDIR)/include CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) contains( CONFTEST, y ){ - LIBS += -lqpe -letpan -lssl -lcrypto -lopie -liconv + LIBS += -lqpe -lopie -lmailwrapper -liconv }else{ - LIBS += -lqpe -lopie -llibmailwrapper + LIBS += -lqpe -lopie -lmailwrapper } TARGET = opiemail include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h index 60bfdda..271f616 100644 --- a/noncore/net/mail/mailistviewitem.h +++ b/noncore/net/mail/mailistviewitem.h @@ -1,21 +1,22 @@ #ifndef __MAILLISTVIEWITEM_H #define __MAILLISTVIEWITEM_H #include <qlistview.h> -#include "mailtypes.h" +#include <libmailwrapper/mailtypes.h> + class MailListViewItem:public QListViewItem { public: MailListViewItem(QListView * parent, MailListViewItem * after ); virtual ~MailListViewItem(){} void storeData(const RecMail&data); const RecMail&data()const; void showEntry(); protected: RecMail mail_data; }; #endif diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 6511b1f..43d02e7 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp @@ -1,111 +1,112 @@ #include <qlabel.h> #include <qvbox.h> #include <qheader.h> #include <qtimer.h> #include <qlayout.h> #include <qmessagebox.h> #include <qtextstream.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> + #include "defines.h" #include "mainwindow.h" #include "viewmail.h" -#include "mailtypes.h" +#include <libmailwrapper/mailtypes.h> #include "mailistviewitem.h" MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) : QMainWindow( parent, name, flags ) { setCaption( tr( "Mail" ) ); setToolBarsMovable( false ); toolBar = new QToolBar( this ); menuBar = new QMenuBar( toolBar ); mailMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Mail" ), mailMenu ); settingsMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Settings" ), settingsMenu ); addToolBar( toolBar ); toolBar->setHorizontalStretchable( true ); QLabel *spacer = new QLabel( toolBar ); spacer->setBackgroundMode( QWidget::PaletteButton ); toolBar->setStretchableWidget( spacer ); composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 0, 0, this ); composeMail->addTo( toolBar ); composeMail->addTo( mailMenu ); sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 0, 0, this ); sendQueued->addTo( toolBar ); sendQueued->addTo( mailMenu ); /* syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 0, 0, this ); syncFolders->addTo( toolBar ); syncFolders->addTo( mailMenu ); */ showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 0, 0, this, 0, true ); showFolders->addTo( toolBar ); showFolders->addTo( mailMenu ); showFolders->setOn( true ); connect(showFolders, SIGNAL( toggled( bool ) ), SLOT( slotShowFolders( bool ) ) ); /* searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, 0, 0, this ); searchMails->addTo( toolBar ); searchMails->addTo( mailMenu ); */ deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); deleteMails->addTo( toolBar ); deleteMails->addTo( mailMenu ); connect( deleteMails, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 0, 0, this ); editSettings->addTo( settingsMenu ); connect( editSettings, SIGNAL( activated() ), SLOT( slotEditSettings() ) ); editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 0, 0, this ); editAccounts->addTo( settingsMenu ); //setCentralWidget( view ); QVBox* wrapperBox = new QVBox( this ); setCentralWidget( wrapperBox ); QWidget *view = new QWidget( wrapperBox ); layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); folderView = new AccountView( view ); folderView->header()->hide(); folderView->setRootIsDecorated( true ); folderView->addColumn( tr( "Mailbox" ) ); layout->addWidget( folderView ); mailView = new QListView( view ); mailView->addColumn( tr( "" ) ); mailView->addColumn( tr( "Subject" ),QListView::Manual ); mailView->addColumn( tr( "Sender" ),QListView::Manual ); mailView->addColumn( tr( "Size" ),QListView::Manual); mailView->addColumn( tr( "Date" )); mailView->setAllColumnsShowFocus(true); mailView->setSorting(-1); diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 54453b7..fcd48e2 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp @@ -1,102 +1,102 @@ #include <qmessagebox.h> #include "settingsdialog.h" #include "opiemail.h" #include "editaccounts.h" #include "composemail.h" -#include "smtpwrapper.h" +#include <libmailwrapper/smtpwrapper.h> #include <qpe/qcopenvelope_qws.h> #include <qaction.h> #include <qapplication.h> OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) : MainWindow( parent, name, flags ) { settings = new Settings(); folderView->populate( settings->getAccounts() ); connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); // Added by Stefan Eilers to allow starting by addressbook.. // copied from old mail2 #if !defined(QT_NO_COP) connect( qApp, SIGNAL( appMessage( const QCString&, const QByteArray& ) ), this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); #endif } void OpieMail::appMessage(const QCString &msg, const QByteArray &data) { // copied from old mail2 if (msg == "writeMail(QString,QString)") { QDataStream stream(data,IO_ReadOnly); QString name, email; stream >> name >> email; // removing the whitespaces at beginning and end is needed! slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); } else if (msg == "newMail()") { slotComposeMail(); } } void OpieMail::slotwriteMail(const QString&name,const QString&email) { ComposeMail compose( settings, this, 0 , true ); if (!email.isEmpty()) { if (!name.isEmpty()) { compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); } else { compose.setTo(email); } } compose.showMaximized(); compose.slotAdjustColumns(); compose.exec(); } void OpieMail::slotComposeMail() { qDebug( "Compose Mail" ); slotwriteMail(0l,0l); } void OpieMail::slotSendQueued() { qDebug( "Send Queued" ); SMTPaccount *smtp = 0; QList<Account> list = settings->getAccounts(); Account *it; // if (list.count()==1) { for ( it = list.first(); it; it = list.next() ) { if ( it->getType().compare( "SMTP" ) == 0 ) { smtp = static_cast<SMTPaccount *>(it); break; } } // } if (smtp) { SMTPwrapper * wrap = new SMTPwrapper(settings); if ( wrap->flushOutbox(smtp) ) { QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); } } } void OpieMail::slotSearchMails() { qDebug( "Search Mails" ); } void OpieMail::slotEditSettings() { SettingsDialog settingsDialog( this, 0, true ); settingsDialog.showMaximized(); settingsDialog.exec(); } diff --git a/noncore/net/mail/opiemail.h b/noncore/net/mail/opiemail.h index 4e3c974..ebed5d8 100644 --- a/noncore/net/mail/opiemail.h +++ b/noncore/net/mail/opiemail.h @@ -1,29 +1,30 @@ #ifndef OPIEMAIL_H #define OPIEMAIL_H #include "mainwindow.h" -#include "settings.h" +#include <libmailwrapper/settings.h> + class OpieMail : public MainWindow { Q_OBJECT public: OpieMail( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); static QString appName() { return QString::fromLatin1("opiemail"); } 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(); private: Settings *settings; }; #endif diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index ed77eb5..9ca6383 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp @@ -1,115 +1,115 @@ #include <qtextbrowser.h> #include <qmessagebox.h> #include <qtextstream.h> #include <qaction.h> #include <qpopupmenu.h> #include <qfile.h> #include <qapplication.h> #include <qvaluelist.h> #include <qpe/config.h> #include <opie/ofiledialog.h> -#include "settings.h" +#include <libmailwrapper/settings.h> #include "composemail.h" #include "viewmail.h" -#include "abstractmail.h" +#include <libmailwrapper/abstractmail.h> #include "accountview.h" -#include "mailtypes.h" +#include <libmailwrapper/mailtypes.h> AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, const QString&fsize,int num,const QValueList<int>&path) : QListViewItem(parent,after),_partNum(num) { _path=path; setText(0, mime); setText(1, desc); setText(2, file); setText(3, fsize); } AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, const QString&fsize,int num,const QValueList<int>&path) : QListViewItem(parent,after),_partNum(num) { _path=path; setText(0, mime); setText(1, desc); setText(2, file); setText(3, fsize); } bool AttachItem::isParentof(const QValueList<int>&path) { /* if not set, then no parent */ if (path.count()==0||_path.count()==0) return false; /* the parent must have one digit less then a child */ if (path.count()!=_path.count()+1) return false; for (unsigned int i=0; i < _path.count();++i) { if (_path[i]!=path[i]) return false; } return true; } AttachItem* ViewMail::searchParent(const QValueList<int>&path) { QListViewItemIterator it( attachments ); for ( ; it.current(); ++it ) { AttachItem*ati = (AttachItem*)it.current(); if (ati->isParentof(path)) return ati; } return 0; } AttachItem* ViewMail::lastChild(AttachItem*parent) { if (!parent) return 0; AttachItem* item = (AttachItem*)parent->firstChild(); if (!item) return item; AttachItem*temp=0; while( (temp=(AttachItem*)item->nextSibling())) { item = temp; } return item; } void ViewMail::setBody( RecBody body ) { m_body = body; m_mail[2] = body.Bodytext(); attachbutton->setEnabled(body.Parts().count()>0); attachments->setEnabled(body.Parts().count()>0); if (body.Parts().count()==0) { return; } AttachItem * curItem=0; AttachItem * parentItem = 0; QString type=body.Description().Type()+"/"+body.Description().Subtype(); QString desc,fsize; double s = body.Description().Size(); int w; w=0; while (s>1024) { s/=1024; ++w; if (w>=2) break; } QString q=""; switch(w) { case 1: q="k"; break; case 2: q="M"; break; default: break; } { /* I did not found a method to make a CONTENT reset on a QTextStream so I use this construct that the stream will re-constructed in each loop. To let it work, the textstream is packed into a own area of diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h index 29681cc..2d0e024 100644 --- a/noncore/net/mail/viewmail.h +++ b/noncore/net/mail/viewmail.h @@ -1,72 +1,73 @@ #ifndef VIEWMAIL_H #define VIEWMAIL_H #include <qlistview.h> #include <qmap.h> #include <qstringlist.h> #include <qvaluelist.h> #include "viewmailbase.h" -#include "mailtypes.h" +#include <libmailwrapper/mailtypes.h> + class AttachItem : public QListViewItem { public: AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, const QString&fsize,int num,const QValueList<int>&path); AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, const QString&fsize,int num,const QValueList<int>&path); int Partnumber() { return _partNum; } bool isParentof(const QValueList<int>&path); private: int _partNum; /* needed for a better display of attachments */ QValueList<int> _path; }; class ViewMail : public ViewMailBase { Q_OBJECT public: ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); ~ViewMail(); void hide(); void exec(); void setMail( RecMail mail ); void setBody( RecBody body ); bool deleted; protected: QString deHtml(const QString &string); AttachItem* searchParent(const QValueList<int>&path); AttachItem* lastChild(AttachItem*parent); protected slots: void slotReply(); void slotForward(); void setText(); void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); void slotDeleteMail( ); void slotShowHtml( bool ); private: void readConfig(); bool _inLoop; QString m_mailHtml; bool m_gotBody; RecBody m_body; RecMail m_recMail; bool m_showHtml; // 0 from 1 subject 2 bodytext 3 date QMap <int,QString> m_mail; // 0 to 1 cc 2 bcc QMap <int,QStringList> m_mail2; }; #endif |