21 files changed, 93 insertions, 48 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 64557ee..4375044 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp @@ -41,62 +41,62 @@ 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(); imapAccounts.clear(); mhAccounts.clear(); mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); Account *it; for ( it = list.first(); it; it = list.next() ) { - if ( it->getType().compare( "IMAP" ) == 0 ) + if ( it->getType() == MAILLIB::A_IMAP ) { IMAPaccount *imap = static_cast<IMAPaccount *>(it); qDebug( "added IMAP " + imap->getAccountName() ); imapAccounts.append(new IMAPviewItem( imap, this )); } - else if ( it->getType().compare( "POP3" ) == 0 ) + else if ( it->getType() == MAILLIB::A_POP3 ) { POP3account *pop3 = static_cast<POP3account *>(it); qDebug( "added POP3 " + pop3->getAccountName() ); /* must not be hold 'cause it isn't required */ (void) new POP3viewItem( pop3, this ); } - else if ( it->getType().compare( "NNTP" ) == 0 ) + 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); } } diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index f51a8fe..f8ac76f 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp @@ -25,49 +25,49 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m 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 ) { + 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() ) ); } diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index 28d531b..5c4bdf7 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp @@ -1,76 +1,94 @@ #include "defines.h" #include "editaccounts.h" /* OPIE */ #include <qpe/qpeapplication.h> /* QT */ #include <qt.h> #include <qstringlist.h> #include <libmailwrapper/nntpwrapper.h> AccountListItem::AccountListItem( QListView *parent, Account *a) : QListViewItem( parent ) { account = a; setText( 0, account->getAccountName() ); - setText( 1, account->getType() ); + QString ttext = ""; + switch (account->getType()) { + case MAILLIB::A_NNTP: + ttext="NNTP"; + break; + case MAILLIB::A_POP3: + ttext = "POP3"; + break; + case MAILLIB::A_IMAP: + ttext = "IMAP"; + break; + case MAILLIB::A_SMTP: + ttext = "SMTP"; + break; + default: + ttext = "UNKNOWN"; + break; + } + setText( 1, ttext); } EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) : EditAccountsUI( parent, name, modal, flags ) { qDebug( "New Account Configuration Widget" ); settings = s; mailList->addColumn( tr( "Account" ) ); mailList->addColumn( tr( "Type" ) ); newsList->addColumn( tr( "Account" ) ); connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); slotFillLists(); } void EditAccounts::slotFillLists() { mailList->clear(); newsList->clear(); QList<Account> accounts = settings->getAccounts(); Account *it; for ( it = accounts.first(); it; it = accounts.next() ) { - if ( it->getType().compare( "NNTP" ) == 0 ) + if ( it->getType()==MAILLIB::A_NNTP ) { (void) new AccountListItem( newsList, it ); } else { (void) new AccountListItem( mailList, it ); } } } void EditAccounts::slotNewMail() { qDebug( "New Mail Account" ); QString *selection = new QString(); SelectMailType selType( selection, this, 0, true ); selType.show(); if ( QDialog::Accepted == selType.exec() ) { slotNewAccount( *selection ); } } void EditAccounts::slotNewAccount( const QString &type ) { @@ -122,76 +140,76 @@ void EditAccounts::slotNewAccount( const QString &type ) { account->remove(); } } else if ( type.compare( "NNTP" ) == 0 ) { qDebug( "-> config NNTP" ); NNTPaccount *account = new NNTPaccount(); NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) { settings->addAccount( account ); account->save(); slotFillLists(); } else { account->remove(); } } } void EditAccounts::slotEditAccount( Account *account ) { - if ( account->getType().compare( "IMAP" ) == 0 ) + if ( account->getType() == MAILLIB::A_IMAP ) { IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) { slotFillLists(); } } - else if ( account->getType().compare( "POP3" ) == 0 ) + else if ( account->getType()==MAILLIB::A_POP3 ) { POP3account *pop3Acc = static_cast<POP3account *>(account); POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) { slotFillLists(); } } - else if ( account->getType().compare( "SMTP" ) == 0 ) + else if ( account->getType()==MAILLIB::A_SMTP ) { SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) { slotFillLists(); } } - else if ( account->getType().compare( "NNTP" ) == 0 ) + else if ( account->getType()==MAILLIB::A_NNTP) { NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) { slotFillLists(); } } } void EditAccounts::slotDeleteAccount( Account *account ) { if ( QMessageBox::information( this, tr( "Question" ), tr( "<p>Do you really want to delete the selected Account?</p>" ), tr( "Yes" ), tr( "No" ) ) == 0 ) { settings->delAccount( account ); slotFillLists(); } } void EditAccounts::slotEditMail() { qDebug( "Edit Mail Account" ); diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index b6e1538..442ebfe 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h @@ -1,27 +1,29 @@ #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; @@ -34,33 +36,33 @@ public: 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(){}; /* mail box methods */ /* parameter is the box to create. * if the implementing subclass has prefixes, * them has to be appended automatic. */ virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); virtual void logout()=0; static AbstractMail* getWrapper(IMAPaccount *a); static AbstractMail* getWrapper(POP3account *a); static AbstractMail* getWrapper(NNTPaccount *a); /* mbox only! */ static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); static QString defaultLocalfolder(); - virtual const QString&getType()const=0; + 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 350808a..3fe319b 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp @@ -423,90 +423,94 @@ encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&par encodedString*t = it.data(); return t; } QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) { encodedString*t = fetchDecodedPart(mail,part); QString text=t->Content(); delete t; return text; } 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"); } -void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox) +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; 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 (single_fields.fld_to) - mail->setTo( parseAddressList( single_fields.fld_to->to_addr_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)); 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)); } target.append(mail); } if (env_list) { mailmessage_list_free(env_list); } } diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h index e471dc8..b451416 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.h +++ b/noncore/net/mail/libmailwrapper/genericwrapper.h @@ -33,34 +33,34 @@ public: Genericwrapper(); virtual ~Genericwrapper(); virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); virtual void cleanMimeCache(); virtual int deleteMbox(const Folder*){return 1;} virtual void logout(){}; virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; protected: RecMail *parseHeader( const char *header ); RecBody parseMail( mailmessage * msg ); QString parseMailboxList( mailimf_mailbox_list *list ); QString parseMailbox( mailimf_mailbox *box ); QString parseGroup( mailimf_group *group ); QString parseAddressList( mailimf_address_list *list ); QString parseDateTime( mailimf_date_time *date ); void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); static void fillParameters(RecPart&target,clist*parameters); static QString getencoding(mailmime_mechanism*aEnc); - virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); + virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); QString msgTempName; unsigned int last_msg_id; QMap<QString,encodedString*> bodyCache; mailstorage * m_storage; mailfolder*m_folder; }; #endif diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 1dfcc4c..3375e69 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp @@ -1069,49 +1069,49 @@ void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) break; case MAILIMAP_STATUS_ATT_UNSEEN: target_stat.message_unseen = status_info->st_value; break; } } } else { qDebug("Error retrieving status"); } if (status) mailimap_mailbox_data_status_free(status); if (att_list) mailimap_status_att_list_free(att_list); } void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) { login(); if (!m_imap) return; if (!msg) return; int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); if (r != MAILIMAP_NO_ERROR) { Global::statusMessage("Error storing mail!"); } } -const QString&IMAPwrapper::getType()const +MAILLIB::ATYPE IMAPwrapper::getType()const { return account->getType(); } const QString&IMAPwrapper::getName()const { qDebug("Get name: %s",account->getAccountName().latin1()); return account->getAccountName(); } encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail) { // dummy QValueList<int> path; return fetchRawPart(mail,path,false); } void IMAPwrapper::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) { if (targetWrapper != this) { AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); qDebug("Using generic"); return; } diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 0a1fe2c..2623725 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h @@ -25,49 +25,49 @@ public: virtual ~IMAPwrapper(); virtual QList<Folder>* listFolders(); virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); virtual void deleteMail(const RecMail&mail); virtual void answeredMail(const RecMail&mail); virtual int deleteAllMail(const Folder*folder); virtual void storeMessage(const char*msg,size_t length, const QString&folder); 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 RecBody fetchBody(const RecMail&mail); virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); virtual encodedString* fetchRawBody(const RecMail&mail); virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); virtual int deleteMbox(const Folder*folder); static void imap_progress( size_t current, size_t maximum ); virtual void logout(); - virtual const QString&getType()const; + virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; protected: RecMail*parse_list_result(mailimap_msg_att*); void login(); bool start_tls(bool force=true); virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); int selectMbox(const QString&mbox); void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); /* just helpers */ static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); static QStringList address_list_to_stringlist(clist*list); IMAPaccount *account; diff --git a/noncore/net/mail/libmailwrapper/maildefines.h b/noncore/net/mail/libmailwrapper/maildefines.h new file mode 100644 index 0000000..431f9ea --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/maildefines.h @@ -0,0 +1,16 @@ +#ifndef __MAILDEFINES_H +#define __MAILDEFINES_H + +namespace MAILLIB { + enum ATYPE { + A_UNDEFINED, + A_IMAP, + A_POP3, + A_SMTP, + A_MH, + A_MBOX, + A_NNTP, + }; +} + +#endif diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 97f301e..11ffd92 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp @@ -1,33 +1,33 @@ #include "mboxwrapper.h" #include "mailtypes.h" #include "mailwrapper.h" #include <libetpan/libetpan.h> #include <qdir.h> #include <stdlib.h> #include <qpe/global.h> -const QString MBOXwrapper::wrapperType="MBOX"; +const MAILLIB::ATYPE MBOXwrapper::wrapperType=MAILLIB::MBOX; MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) { QDir dir(MBOXPath); if (!dir.exists()) { dir.mkdir(MBOXPath); } } MBOXwrapper::~MBOXwrapper() { } void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) { mailstorage*storage = mailstorage_new(NULL); QString p = MBOXPath+"/"; p+=mailbox; int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); mailfolder*folder; folder = mailfolder_new( storage,(char*)p.latin1(),NULL); r = mailfolder_connect(folder); @@ -305,33 +305,33 @@ int MBOXwrapper::deleteMbox(const Folder*tfolder) } void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) { mailfolder*folder = 0; mailstorage*storage = mailstorage_new(NULL); target_stat.message_count = 0; target_stat.message_unseen = 0; target_stat.message_recent = 0; QString p = MBOXPath+"/"+mailbox; QFile fi(p); if (!fi.exists()) { Global::statusMessage(tr("Mailbox doesn't exist.")); return; } int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); folder = mailfolder_new( storage,(char*)p.latin1(),NULL); r = mailfolder_connect(folder); r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, &target_stat.message_recent,&target_stat.message_unseen); if (folder) mailfolder_free(folder); if (storage) mailstorage_free(storage); } -const QString&MBOXwrapper::getType()const +MAILLIB::ATYPE MBOXwrapper::getType()const { return wrapperType; } const QString&MBOXwrapper::getName()const { return MBOXName; } diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index a579a3d..a12a1dd 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h @@ -14,35 +14,35 @@ class MBOXwrapper : public Genericwrapper Q_OBJECT public: MBOXwrapper(const QString & dir,const QString&name); virtual ~MBOXwrapper(); virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); virtual QList<Folder>* listFolders(); virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); virtual void deleteMail(const RecMail&mail); virtual void answeredMail(const RecMail&mail); virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); virtual int deleteMbox(const Folder*); virtual void storeMessage(const char*msg,size_t length, const QString&folder); virtual RecBody fetchBody( const RecMail &mail ); static void mbox_progress( size_t current, size_t maximum ); virtual encodedString* fetchRawBody(const RecMail&mail); virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); virtual int deleteAllMail(const Folder*); - virtual const QString&getType()const; + virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; protected: static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); QString MBOXPath; QString MBOXName; - static const QString wrapperType; + static const MAILLIB::ATYPE wrapperType; }; #endif diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index df7f773..179bd34 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp @@ -1,35 +1,35 @@ #include "mhwrapper.h" #include "mailtypes.h" #include "mailwrapper.h" #include <libetpan/libetpan.h> #include <qdir.h> #include <qmessagebox.h> #include <stdlib.h> #include <qpe/global.h> #include <opie2/oprocess.h> -const QString MHwrapper::wrapperType="MH"; +const MAILLIB::ATYPE MHwrapper::wrapperType=MAILLIB::A_MH; MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) { if (MHPath.length()>0) { if (MHPath[MHPath.length()-1]=='/') { MHPath=MHPath.left(MHPath.length()-1); } qDebug(MHPath); QDir dir(MHPath); if (!dir.exists()) { dir.mkdir(MHPath); } init_storage(); } } void MHwrapper::init_storage() { int r; QString pre = MHPath; if (!m_storage) { m_storage = mailstorage_new(NULL); r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); @@ -345,49 +345,49 @@ void MHwrapper::processEnded(OProcess *p) void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) { QString lineStr = buffer; QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); removeMboxfailed = true; } void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) { init_storage(); if (!m_storage) { return; } target_stat.message_count = 0; target_stat.message_unseen = 0; target_stat.message_recent = 0; QString f = buildPath(mailbox); int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, &target_stat.message_recent,&target_stat.message_unseen); if (r != MAIL_NO_ERROR) { Global::statusMessage(tr("Error retrieving status")); } } -const QString&MHwrapper::getType()const +MAILLIB::ATYPE MHwrapper::getType()const { return wrapperType; } const QString&MHwrapper::getName()const { return MHName; } void MHwrapper::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) { init_storage(); if (!m_storage) { return; } if (targetWrapper != this) { qDebug("Using generic"); Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); return; } qDebug("Using internal routines for move/copy"); QString tf = buildPath(targetFolder); int r = mailsession_select_folder(m_storage->sto_session,(char*)mail.getMbox().latin1()); if (r != MAIL_NO_ERROR) { qDebug("Error selecting source mailbox"); diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h index b8e380c..c1ba78d 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.h +++ b/noncore/net/mail/libmailwrapper/mhwrapper.h @@ -1,59 +1,61 @@ #ifndef __MH_WRAPPER_H #define __MH_WRAPPER_H +#include "maildefines.h" + #include "genericwrapper.h" #include <qstring.h> class RecMail; class RecBody; class encodedString; struct mailmbox_folder; class OProcess; class MHwrapper : public Genericwrapper { Q_OBJECT public: MHwrapper(const QString & dir,const QString&name); virtual ~MHwrapper(); virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); virtual QList<Folder>* listFolders(); virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); virtual void deleteMail(const RecMail&mail); virtual void answeredMail(const RecMail&mail); virtual void mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); virtual void mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); virtual int deleteMbox(const Folder*); virtual void storeMessage(const char*msg,size_t length, const QString&folder); virtual RecBody fetchBody( const RecMail &mail ); static void mbox_progress( size_t current, size_t maximum ); virtual encodedString* fetchRawBody(const RecMail&mail); virtual void deleteMails(const QString & FolderName,QList<RecMail> &target); virtual int deleteAllMail(const Folder*); - virtual const QString&getType()const; + virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; public slots: /* for deleting maildirs we are using a system call */ virtual void oprocessStderr(OProcess*, char *buffer, int ); virtual void processEnded(OProcess *); protected: QString buildPath(const QString&p); QString MHPath; QString MHName; - static const QString wrapperType; + static const MAILLIB::ATYPE wrapperType; void init_storage(); void clean_storage(); bool removeMboxfailed; }; #endif diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index 5a8c224..1956c61 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp @@ -82,49 +82,49 @@ RecBody NNTPwrapper::fetchBody( const RecMail &mail ) { msg_data = (generic_message_t *)mailmsg->msg_data; msg_data->msg_fetched = 1; msg_data->msg_message = message; msg_data->msg_length = strlen(message); } body = parseMail(mailmsg); /* clean up */ if (mailmsg) mailmessage_free(mailmsg); if (message) free(message); return body; } void NNTPwrapper::listMessages(const QString & which, QList<RecMail> &target ) { login(); if (!m_nntp) return; uint32_t res_messages,res_recent,res_unseen; mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); - parseList(target,m_nntp->sto_session,which); + parseList(target,m_nntp->sto_session,which,true); } void NNTPwrapper::login() { if (account->getOffline()) return; /* we'll hold the line */ if ( m_nntp != NULL ) return; const char *server, *user, *pass; QString User,Pass; uint16_t port; int err = NEWSNNTP_NO_ERROR; server = account->getServer().latin1(); port = account->getPort().toUInt(); user = pass = 0; if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); login.show(); if ( QDialog::Accepted == login.exec() ) { @@ -248,37 +248,37 @@ void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { target_stat.message_unseen = 0; target_stat.message_recent = 0; if (!m_nntp) return; int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, &target_stat.message_recent,&target_stat.message_unseen); } encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { char*target=0; size_t length=0; encodedString*res = 0; mailmessage * mailmsg = 0; int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); err = mailmessage_fetch(mailmsg,&target,&length); if (mailmsg) mailmessage_free(mailmsg); if (target) { res = new encodedString(target,length); } return res; } -const QString&NNTPwrapper::getType()const { +MAILLIB::ATYPE NNTPwrapper::getType()const { return account->getType(); } const QString&NNTPwrapper::getName()const{ return account->getAccountName(); } -void NNTPwrapper::deleteMail(const RecMail&mail) { +void NNTPwrapper::deleteMail(const RecMail&) { } int NNTPwrapper::deleteAllMail(const Folder*) { } diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h index d51c955..955b9f1 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.h +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h @@ -12,37 +12,37 @@ struct mailfolder; class NNTPwrapper : public Genericwrapper { Q_OBJECT public: NNTPwrapper( NNTPaccount *a ); virtual ~NNTPwrapper(); /* mailbox will be ignored */ virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); /* should only get the subscribed one */ virtual QList<Folder>* listFolders(); /* mailbox will be ignored */ virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); QStringList listAllNewsgroups(const QString&mask = QString::null); virtual void deleteMail(const RecMail&mail); virtual void answeredMail(const RecMail&mail); virtual int deleteAllMail(const Folder*); virtual RecBody fetchBody( const RecMail &mail ); virtual encodedString* fetchRawBody(const RecMail&mail); virtual void logout(); - virtual const QString&getType()const; + virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; static void nntp_progress( size_t current, size_t maximum ); protected: void login(); NNTPaccount *account; mailstorage* m_nntp; }; #endif diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 6fab401..0939b22 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp @@ -225,31 +225,31 @@ void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { target_stat.message_count = 0; target_stat.message_unseen = 0; target_stat.message_recent = 0; if (!m_pop3) return; int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, &target_stat.message_recent,&target_stat.message_unseen); } encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) { char*target=0; size_t length=0; encodedString*res = 0; mailmessage * mailmsg = 0; int err = mailsession_get_message(m_pop3->sto_session, mail.getNumber(), &mailmsg); err = mailmessage_fetch(mailmsg,&target,&length); if (mailmsg) mailmessage_free(mailmsg); if (target) { res = new encodedString(target,length); } return res; } -const QString&POP3wrapper::getType()const { +MAILLIB::ATYPE POP3wrapper::getType()const { return account->getType(); } const QString&POP3wrapper::getName()const{ return account->getAccountName(); } diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index a24b9cf..391c841 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h @@ -8,35 +8,35 @@ class encodedString; struct mailstorage; struct mailfolder; class POP3wrapper : public Genericwrapper { Q_OBJECT public: POP3wrapper( POP3account *a ); virtual ~POP3wrapper(); /* mailbox will be ignored */ virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); virtual QList<Folder>* listFolders(); /* mailbox will be ignored */ virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); virtual void deleteMail(const RecMail&mail); virtual void answeredMail(const RecMail&mail); virtual int deleteAllMail(const Folder*); virtual RecBody fetchBody( const RecMail &mail ); virtual encodedString* fetchRawBody(const RecMail&mail); virtual void logout(); - virtual const QString&getType()const; + virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; static void pop3_progress( size_t current, size_t maximum ); protected: void login(); POP3account *account; mailstorage*m_pop3; }; #endif diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 0d34fd5..2c81963 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp @@ -85,79 +85,79 @@ void Settings::updateAccounts() void Settings::saveAccounts() { checkDirectory(); Account *it; for ( it = accounts.first(); it; it = accounts.next() ) { it->save(); } } void Settings::readAccounts() { checkDirectory(); Account *it; for ( it = accounts.first(); it; it = accounts.next() ) { it->read(); } } Account::Account() { accountName = "changeMe"; - type = "changeMe"; + type = MAILLIB::A_UNDEFINED; ssl = false; connectionType = 1; offline = false; } void Account::remove() { QFile file( getFileName() ); file.remove(); } IMAPaccount::IMAPaccount() : Account() { file = IMAPaccount::getUniqueFileName(); accountName = "New IMAP Account"; ssl = false; connectionType = 1; - type = "IMAP"; + type = MAILLIB::A_IMAP; port = IMAP_PORT; } IMAPaccount::IMAPaccount( QString filename ) : Account() { file = filename; accountName = "New IMAP Account"; ssl = false; connectionType = 1; - type = "IMAP"; + type = MAILLIB::A_IMAP; port = IMAP_PORT; } QString IMAPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); QStringList imap = dir.entryList( "imap-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "imap-" + unique ) > 0 ); return unique; } void IMAPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "IMAP Account" ); accountName = conf->readEntry( "Account","" ); if (accountName.isNull()) accountName = ""; @@ -189,60 +189,60 @@ void IMAPaccount::save() conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "ConnectionType", connectionType ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); conf->writeEntry( "MailPrefix",prefix); conf->writeEntry( "Offline",offline); conf->write(); delete conf; } QString IMAPaccount::getFileName() { return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; } POP3account::POP3account() : Account() { file = POP3account::getUniqueFileName(); accountName = "New POP3 Account"; ssl = false; connectionType = 1; - type = "POP3"; + type = MAILLIB::A_POP3; port = POP3_PORT; } POP3account::POP3account( QString filename ) : Account() { file = filename; accountName = "New POP3 Account"; ssl = false; connectionType = 1; - type = "POP3"; + type = MAILLIB::A_POP3; port = POP3_PORT; } QString POP3account::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); QStringList imap = dir.entryList( "pop3-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "pop3-" + unique ) > 0 ); return unique; } void POP3account::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "POP3 Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); @@ -270,61 +270,61 @@ void POP3account::save() conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); conf->writeEntry( "Offline",offline); conf->write(); delete conf; } QString POP3account::getFileName() { return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; } SMTPaccount::SMTPaccount() : Account() { file = SMTPaccount::getUniqueFileName(); accountName = "New SMTP Account"; ssl = false; connectionType = 1; login = false; useCC = false; useBCC = false; useReply = false; - type = "SMTP"; + type = MAILLIB::A_SMTP; port = SMTP_PORT; } SMTPaccount::SMTPaccount( QString filename ) : Account() { file = filename; accountName = "New SMTP Account"; ssl = false; connectionType = 1; login = false; - type = "SMTP"; + type = MAILLIB::A_SMTP; port = SMTP_PORT; } QString SMTPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); QStringList imap = dir.entryList( "smtp-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "smtp-" + unique ) > 0 ); return unique; } void SMTPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "SMTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); @@ -348,60 +348,60 @@ void SMTPaccount::save() conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "ConnectionType", connectionType ); conf->writeEntry( "Login", login ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); conf->write(); delete conf; } QString SMTPaccount::getFileName() { return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; } NNTPaccount::NNTPaccount() : Account() { file = NNTPaccount::getUniqueFileName(); accountName = "New NNTP Account"; ssl = false; login = false; - type = "NNTP"; + type = MAILLIB::A_NNTP; port = NNTP_PORT; } NNTPaccount::NNTPaccount( QString filename ) : Account() { file = filename; accountName = "New NNTP Account"; ssl = false; login = false; - type = "NNTP"; + type = MAILLIB::A_NNTP; port = NNTP_PORT; } QString NNTPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); QStringList imap = dir.entryList( "nntp-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "nntp-" + unique ) > 0 ); return unique; } void NNTPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "NNTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h index 1feedbf..27e2823 100644 --- a/noncore/net/mail/libmailwrapper/settings.h +++ b/noncore/net/mail/libmailwrapper/settings.h @@ -1,73 +1,76 @@ #ifndef SETTINGS_H #define SETTINGS_H +#include "maildefines.h" + #include <qobject.h> #include <qlist.h> class Account { public: Account(); virtual ~Account() {} void remove(); void setAccountName( QString name ) { accountName = name; } const QString&getAccountName()const{ return accountName; } - const QString&getType()const{ return type; } + MAILLIB::ATYPE getType()const{ return type; } void setServer(const QString&str){ server = str; } const QString&getServer()const{ return server; } void setPort(const QString&str) { port = str; } const QString&getPort()const{ return port; } void setUser(const QString&str){ user = str; } const QString&getUser()const{ return user; } void setPassword(const QString&str) { password = str; } const QString&getPassword()const { return password; } void setSSL( bool b ) { ssl = b; } bool getSSL() { return ssl; } void setConnectionType( int x ) { connectionType = x; } int ConnectionType() { return connectionType; } void setOffline(bool b) {offline = b;} bool getOffline()const{return offline;} virtual QString getFileName() { return accountName; } virtual void read() { qDebug( "base reading..." ); } virtual void save() { qDebug( "base saving..." ); } - + protected: - QString accountName, type, server, port, user, password; + QString accountName, server, port, user, password; bool ssl; int connectionType; bool offline; + MAILLIB::ATYPE type; }; class IMAPaccount : public Account { public: IMAPaccount(); IMAPaccount( QString filename ); static QString getUniqueFileName(); virtual void read(); virtual void save(); virtual QString getFileName(); void setPrefix(const QString&str) {prefix=str;} const QString&getPrefix()const{return prefix;} private: QString file,prefix; }; class POP3account : public Account diff --git a/noncore/net/mail/libmailwrapper/statusmail.cpp b/noncore/net/mail/libmailwrapper/statusmail.cpp index 4134e79..b78244d 100644 --- a/noncore/net/mail/libmailwrapper/statusmail.cpp +++ b/noncore/net/mail/libmailwrapper/statusmail.cpp @@ -5,86 +5,86 @@ StatusMail::StatusMail(QList<Account>&list) currentImapStat.message_count=0; currentImapStat.message_unseen=0; currentImapStat.message_recent=0; lastPop3Stat = currentImapStat; currentPop3Stat = currentImapStat; connectionList.setAutoDelete(true); connectionList.clear(); initAccounts(list); } StatusMail::~StatusMail() { } void StatusMail::initAccounts(QList<Account>&accounts) { Account *it; folderStat currentStat; AbstractMail * current = 0; currentPop3Stat.message_count=0; currentPop3Stat.message_recent=0; currentPop3Stat.message_unseen=0; for ( it = accounts.first(); it; it = accounts.next() ) { - if ( it->getType().compare( "IMAP" ) == 0 && !it->getOffline() ) { + if ( it->getType()==MAILLIB::A_IMAP && !it->getOffline() ) { IMAPaccount*ima = static_cast<IMAPaccount *>(it); current = AbstractMail::getWrapper(ima); connectionList.append(current); current->statusFolder(currentStat); currentImapStat.message_count+=currentStat.message_unseen; currentImapStat.message_count+=currentStat.message_recent; currentImapStat.message_count+=currentStat.message_count; - } else if ( it->getType().compare( "POP3" ) == 0 && !it->getOffline() ) { + } else if ( it->getType() == MAILLIB::A_POP3 && !it->getOffline() ) { POP3account *pop3 = static_cast<POP3account *>(it); current = AbstractMail::getWrapper(pop3); connectionList.append(current); current->statusFolder(currentStat); currentPop3Stat.message_count+=currentStat.message_count; } current->logout(); } qDebug("Pop3 init count: %i",currentPop3Stat.message_count); currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; lastPop3Stat.message_unseen = currentPop3Stat.message_unseen; lastPop3Stat.message_recent = currentPop3Stat.message_recent; lastPop3Stat.message_count = currentPop3Stat.message_count; } void StatusMail::reset_status() { lastPop3Stat = currentPop3Stat; } void StatusMail::check_current_stat(folderStat&targetStat) { AbstractMail*it = 0; folderStat currentStat; currentPop3Stat.message_recent = 0; currentPop3Stat.message_count = 0; currentPop3Stat.message_unseen = 0; currentImapStat = currentPop3Stat; for ( it = connectionList.first(); it; it = connectionList.next() ) { it->statusFolder(currentStat); it->logout(); - if (it->getType().lower()=="imap") { + if (it->getType() == MAILLIB::A_IMAP) { currentImapStat.message_unseen+=currentStat.message_unseen; currentImapStat.message_recent+=currentStat.message_recent; currentImapStat.message_count+=currentStat.message_count; - } else if (it->getType().lower()=="pop3") { + } else if (it->getType() == MAILLIB::A_POP3) { currentPop3Stat.message_count+=currentStat.message_count; qDebug("Pop3 count: %i",currentPop3Stat.message_count); } } qDebug("Pop3 last: %i",lastPop3Stat.message_count); if (currentPop3Stat.message_count > lastPop3Stat.message_count) { currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; currentPop3Stat.message_unseen = currentPop3Stat.message_recent; } else { lastPop3Stat.message_count = currentPop3Stat.message_count; currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; } targetStat = currentImapStat; targetStat.message_unseen+=currentPop3Stat.message_unseen; targetStat.message_recent+=currentPop3Stat.message_recent; targetStat.message_count+=currentPop3Stat.message_count; } diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 6bfc824..d8b58b6 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp @@ -61,49 +61,49 @@ void OpieMail::slotwriteMail(const QString&name,const QString&email) compose.setTo(email); } } compose.slotAdjustColumns(); QPEApplication::execDialog( &compose ); } void OpieMail::slotComposeMail() { qDebug( "Compose Mail" ); slotwriteMail(0l,0l); } void OpieMail::slotSendQueued() { qDebug( "Send Queued" ); SMTPaccount *smtp = 0; QList<Account> list = settings->getAccounts(); QList<SMTPaccount> smtpList; smtpList.setAutoDelete(false); Account *it; for ( it = list.first(); it; it = list.next() ) { - if ( it->getType().compare( "SMTP" ) == 0 ) + 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(); } } |