author | alwin <alwin> | 2004-03-08 01:00:18 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-08 01:00:18 (UTC) |
commit | eddc5184f5be6a067b077d18e240a1fe982bbcf4 (patch) (side-by-side diff) | |
tree | 0d9458a10520ca23e1d5d041d9d2ca4150bd8f1c | |
parent | eedafdf1a1d973c083cb108a913005d14a78a9ae (diff) | |
download | opie-eddc5184f5be6a067b077d18e240a1fe982bbcf4.zip opie-eddc5184f5be6a067b077d18e240a1fe982bbcf4.tar.gz opie-eddc5184f5be6a067b077d18e240a1fe982bbcf4.tar.bz2 |
type of mail account will be defined by a enum not with string - comparing
strings all the time makes no sense.
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 @@ -64,3 +64,3 @@ void AccountView::populate( QList<Account> list ) { - if ( it->getType().compare( "IMAP" ) == 0 ) + if ( it->getType() == MAILLIB::A_IMAP ) { @@ -70,3 +70,3 @@ void AccountView::populate( QList<Account> list ) } - else if ( it->getType().compare( "POP3" ) == 0 ) + else if ( it->getType() == MAILLIB::A_POP3 ) { @@ -77,3 +77,3 @@ void AccountView::populate( QList<Account> list ) } - else if ( it->getType().compare( "NNTP" ) == 0 ) + else if ( it->getType() == MAILLIB::A_NNTP ) { 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 @@ -48,3 +48,3 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m 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); 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 @@ -18,3 +18,21 @@ AccountListItem::AccountListItem( QListView *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); } @@ -51,3 +69,3 @@ void EditAccounts::slotFillLists() { - if ( it->getType().compare( "NNTP" ) == 0 ) + if ( it->getType()==MAILLIB::A_NNTP ) { @@ -145,3 +163,3 @@ void EditAccounts::slotEditAccount( Account *account ) { - if ( account->getType().compare( "IMAP" ) == 0 ) + if ( account->getType() == MAILLIB::A_IMAP ) { @@ -154,3 +172,3 @@ void EditAccounts::slotEditAccount( Account *account ) } - else if ( account->getType().compare( "POP3" ) == 0 ) + else if ( account->getType()==MAILLIB::A_POP3 ) { @@ -163,3 +181,3 @@ void EditAccounts::slotEditAccount( Account *account ) } - else if ( account->getType().compare( "SMTP" ) == 0 ) + else if ( account->getType()==MAILLIB::A_SMTP ) { @@ -172,3 +190,3 @@ void EditAccounts::slotEditAccount( Account *account ) } - else if ( account->getType().compare( "NNTP" ) == 0 ) + else if ( account->getType()==MAILLIB::A_NNTP) { 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 @@ -3,2 +3,4 @@ +#include "maildefines.h" + #include <qobject.h> @@ -57,3 +59,3 @@ public: - virtual const QString&getType()const=0; + virtual MAILLIB::ATYPE getType()const=0; virtual const QString&getName()const=0; 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 @@ -446,3 +446,3 @@ void Genericwrapper::cleanMimeCache() -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) { @@ -490,4 +490,8 @@ void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const 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) 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 @@ -56,3 +56,3 @@ protected: 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); 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 @@ -1092,3 +1092,3 @@ void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folde -const QString&IMAPwrapper::getType()const +MAILLIB::ATYPE IMAPwrapper::getType()const { 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 @@ -48,3 +48,3 @@ public: virtual void logout(); - virtual const QString&getType()const; + virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; 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 @@ -8,3 +8,3 @@ -const QString MBOXwrapper::wrapperType="MBOX"; +const MAILLIB::ATYPE MBOXwrapper::wrapperType=MAILLIB::MBOX; @@ -328,3 +328,3 @@ void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) -const QString&MBOXwrapper::getType()const +MAILLIB::ATYPE MBOXwrapper::getType()const { 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 @@ -37,3 +37,3 @@ public: virtual int deleteAllMail(const Folder*); - virtual const QString&getType()const; + virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; @@ -44,3 +44,3 @@ protected: QString MBOXName; - static const QString wrapperType; + static const MAILLIB::ATYPE wrapperType; }; 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 @@ -10,3 +10,3 @@ -const QString MHwrapper::wrapperType="MH"; +const MAILLIB::ATYPE MHwrapper::wrapperType=MAILLIB::A_MH; @@ -368,3 +368,3 @@ void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) -const QString&MHwrapper::getType()const +MAILLIB::ATYPE MHwrapper::getType()const { 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 @@ -3,2 +3,4 @@ +#include "maildefines.h" + #include "genericwrapper.h" @@ -39,3 +41,3 @@ public: virtual int deleteAllMail(const Folder*); - virtual const QString&getType()const; + virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; @@ -50,3 +52,3 @@ protected: QString MHName; - static const QString wrapperType; + static const MAILLIB::ATYPE wrapperType; 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 @@ -105,3 +105,3 @@ void NNTPwrapper::listMessages(const QString & which, QList<RecMail> &target ) 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); } @@ -271,3 +271,3 @@ encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { -const QString&NNTPwrapper::getType()const { +MAILLIB::ATYPE NNTPwrapper::getType()const { return account->getType(); @@ -279,3 +279,3 @@ const QString&NNTPwrapper::getName()const{ -void NNTPwrapper::deleteMail(const RecMail&mail) { +void NNTPwrapper::deleteMail(const RecMail&) { } 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 @@ -35,3 +35,3 @@ public: virtual void logout(); - virtual const QString&getType()const; + virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; 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 @@ -248,3 +248,3 @@ encodedString* POP3wrapper::fetchRawBody(const RecMail&mail) { -const QString&POP3wrapper::getType()const { +MAILLIB::ATYPE POP3wrapper::getType()const { return account->getType(); 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 @@ -31,3 +31,3 @@ public: virtual void logout(); - virtual const QString&getType()const; + virtual MAILLIB::ATYPE getType()const; virtual const QString&getName()const; 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 @@ -108,3 +108,3 @@ Account::Account() accountName = "changeMe"; - type = "changeMe"; + type = MAILLIB::A_UNDEFINED; ssl = false; @@ -127,3 +127,3 @@ IMAPaccount::IMAPaccount() connectionType = 1; - type = "IMAP"; + type = MAILLIB::A_IMAP; port = IMAP_PORT; @@ -138,3 +138,3 @@ IMAPaccount::IMAPaccount( QString filename ) connectionType = 1; - type = "IMAP"; + type = MAILLIB::A_IMAP; port = IMAP_PORT; @@ -212,3 +212,3 @@ POP3account::POP3account() connectionType = 1; - type = "POP3"; + type = MAILLIB::A_POP3; port = POP3_PORT; @@ -223,3 +223,3 @@ POP3account::POP3account( QString filename ) connectionType = 1; - type = "POP3"; + type = MAILLIB::A_POP3; port = POP3_PORT; @@ -293,3 +293,3 @@ SMTPaccount::SMTPaccount() useReply = false; - type = "SMTP"; + type = MAILLIB::A_SMTP; port = SMTP_PORT; @@ -305,3 +305,3 @@ SMTPaccount::SMTPaccount( QString filename ) login = false; - type = "SMTP"; + type = MAILLIB::A_SMTP; port = SMTP_PORT; @@ -371,3 +371,3 @@ NNTPaccount::NNTPaccount() login = false; - type = "NNTP"; + type = MAILLIB::A_NNTP; port = NNTP_PORT; @@ -382,3 +382,3 @@ NNTPaccount::NNTPaccount( QString filename ) login = false; - type = "NNTP"; + type = MAILLIB::A_NNTP; port = NNTP_PORT; 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 @@ -3,2 +3,4 @@ +#include "maildefines.h" + #include <qobject.h> @@ -16,3 +18,3 @@ public: const QString&getAccountName()const{ return accountName; } - const QString&getType()const{ return type; } + MAILLIB::ATYPE getType()const{ return type; } @@ -43,5 +45,5 @@ public: virtual void save() { qDebug( "base saving..." ); } - + protected: - QString accountName, type, server, port, user, password; + QString accountName, server, port, user, password; bool ssl; @@ -49,2 +51,3 @@ protected: bool offline; + MAILLIB::ATYPE type; }; 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 @@ -28,3 +28,3 @@ void StatusMail::initAccounts(QList<Account>&accounts) 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); @@ -36,3 +36,3 @@ void StatusMail::initAccounts(QList<Account>&accounts) 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); @@ -68,3 +68,3 @@ void StatusMail::check_current_stat(folderStat&targetStat) it->logout(); - if (it->getType().lower()=="imap") { + if (it->getType() == MAILLIB::A_IMAP) { currentImapStat.message_unseen+=currentStat.message_unseen; @@ -72,3 +72,3 @@ void StatusMail::check_current_stat(folderStat&targetStat) 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; 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 @@ -84,3 +84,3 @@ void OpieMail::slotSendQueued() { - if ( it->getType().compare( "SMTP" ) == 0 ) + if ( it->getType() == MAILLIB::A_SMTP ) { |