-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 29 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.h | 8 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 6 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.h | 3 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 68 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.h | 6 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.h | 3 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/nntpwrapper.cpp | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/nntpwrapper.h | 3 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.cpp | 21 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.h | 4 |
12 files changed, 128 insertions, 33 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index 128a7c0..3998abd 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #include "abstractmail.h" #include "imapwrapper.h" #include "pop3wrapper.h" #include "nntpwrapper.h" @@ -136,26 +137,40 @@ QString AbstractMail::draftFolder() /* temporary - will be removed when implemented in all classes */ void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) { } +void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) +{ + qDebug("AbstractMail::deleteMailList:: Please reimplement! "); +} void AbstractMail::mvcpAllMails(const FolderP&fromFolder, - const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) + const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) +{ + QValueList<RecMailP> t; + listMessages(fromFolder->getName(),t, maxSizeInKb); + mvcpMailList( t,targetFolder,targetWrapper,moveit); + +} +void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, + const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) { - QValueList<RecMailP> t; - listMessages(fromFolder->getName(),t); + encodedString*st = 0; - while (t.count()>0) { - RecMailP r = (*t.begin()); + int iii = 0; + int count = t.count(); + while (iii < count ) { + RecMailP r = (*t.at( iii )); st = fetchRawBody(r); if (st) { targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); delete st; } - t.remove(t.begin()); + ++iii; } if (moveit) { - deleteAllMail(fromFolder); + deleteMailList( t ); + //deleteAllMail(fromFolder); } } void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) diff --git a/kmicromail/libmailwrapper/abstractmail.h b/kmicromail/libmailwrapper/abstractmail.h index e5d64a6..cae83f4 100644 --- a/kmicromail/libmailwrapper/abstractmail.h +++ b/kmicromail/libmailwrapper/abstractmail.h @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #ifndef __abstract_mail_ #define __abstract_mail_ #include "maildefines.h" @@ -21,25 +22,28 @@ class AbstractMail:public QObject public: AbstractMail(){}; virtual ~AbstractMail(){} virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0; - virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0; + virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target, int sizeInKb = 0 )=0; virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; virtual RecBodyP fetchBody(const RecMailP&mail)=0; virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0; virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0; virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0; virtual encodedString* fetchRawBody(const RecMailP&mail)=0; virtual void deleteMail(const RecMailP&mail)=0; + virtual void deleteMailList(const QValueList<RecMailP>&target); virtual void answeredMail(const RecMailP&mail)=0; virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0; virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target); virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0; virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, - const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); + const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int sizeInKb = 0); + virtual void mvcpMailList(const QValueList<RecMailP>& t, + const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); virtual void cleanMimeCache(){}; /* mail box methods */ diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index f804e44..1fd4bb1 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #include "genericwrapper.h" #include <libetpan/libetpan.h> #include "mailtypes.h" @@ -391,9 +392,9 @@ QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) } return res; } -void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) +void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) { int r; mailmessage_list * env_list = 0; r = mailsession_get_messages_list(session,&env_list); @@ -471,9 +472,10 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > & if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && clist_count(single_fields.fld_in_reply_to->mid_list)) { mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); } - target.append(mail); + if ( maxSizeInKb == 0 || mail->Msgsize()<=maxSizeInKb*1024 ) + target.append(mail); } if (env_list) { mailmessage_list_free(env_list); } diff --git a/kmicromail/libmailwrapper/genericwrapper.h b/kmicromail/libmailwrapper/genericwrapper.h index 8be9212..235e116 100644 --- a/kmicromail/libmailwrapper/genericwrapper.h +++ b/kmicromail/libmailwrapper/genericwrapper.h @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #ifndef __GENERIC_WRAPPER_H #define __GENERIC_WRAPPER_H #include "abstractmail.h" @@ -53,9 +54,9 @@ protected: void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime); static void fillParameters(RecPartP&target,clist*parameters); static QString getencoding(mailmime_mechanism*aEnc); - virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); + virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false, int maxSizeInKb = 0); QStringList parseInreplies(mailimf_in_reply_to * in_replies); QString msgTempName; unsigned int last_msg_id; diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index e0fb6f9..bb8bbfc 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #include <stdlib.h> #include <libetpan/libetpan.h> #include <qpe/global.h> #include <qapplication.h> @@ -201,9 +202,9 @@ void IMAPwrapper::logout() m_imap = 0; m_Lastmbox = ""; } -void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) +void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) { int err = MAILIMAP_NO_ERROR; clist *result = 0; clistcell *current; @@ -249,12 +250,14 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma ++i; msg_att = (mailimap_msg_att*)current->data; RecMail*m = parse_list_result(msg_att); if (m) { - m->setNumber(i); - m->setMbox(mailbox); - m->setWrapper(this); - target.append(m); + if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { + m->setNumber(i); + m->setMbox(mailbox); + m->setWrapper(this); + target.append(m); + } } } Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); } else { @@ -865,9 +868,51 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which } target_part->setEncoding(encoding); target_part->setSize(which->bd_size); } +void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) +{ + mailimap_flag_list*flist; + mailimap_set *set; + mailimap_store_att_flags * store_flags; + int err; + login(); + if (!m_imap) { + return; + } + int iii = 0; + int count = target.count(); + qDebug("imap remove count %d ", count); + while (iii < count ) { + qDebug("IMAP remove %d ", iii); + RecMailP mail = (*target.at( iii )); + err = selectMbox(mail->getMbox()); + if ( err != MAILIMAP_NO_ERROR ) { + return; + } + flist = mailimap_flag_list_new_empty(); + mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); + store_flags = mailimap_store_att_flags_new_set_flags(flist); + set = mailimap_set_new_single(mail->getNumber()); + err = mailimap_store(m_imap,set,store_flags); + mailimap_set_free( set ); + mailimap_store_att_flags_free(store_flags); + + if (err != MAILIMAP_NO_ERROR) { + // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; + return; + } + // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; + /* should we realy do that at this moment? */ + + err = mailimap_expunge(m_imap); + if (err != MAILIMAP_NO_ERROR) { + Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); + } + ++iii; + } +} void IMAPwrapper::deleteMail(const RecMailP&mail) { mailimap_flag_list*flist; mailimap_set *set; @@ -894,13 +939,15 @@ void IMAPwrapper::deleteMail(const RecMailP&mail) return; } // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; /* should we realy do that at this moment? */ + err = mailimap_expunge(m_imap); if (err != MAILIMAP_NO_ERROR) { - // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; + Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); } - // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; + qDebug("IMAPwrapper::deleteMail "); + } void IMAPwrapper::answeredMail(const RecMailP&mail) { @@ -1119,12 +1166,13 @@ encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) return fetchRawPart(mail,path,false); } void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, - const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) + const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) { - if (targetWrapper != this) { - AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); + if (targetWrapper != this || maxSizeInKb > 0 ) { + AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); + qDebug("IMAPwrapper::mvcpAllMails::Using generic"); // odebug << "Using generic" << oendl; return; } mailimap_set *set = 0; diff --git a/kmicromail/libmailwrapper/imapwrapper.h b/kmicromail/libmailwrapper/imapwrapper.h index e56605a..222fe95 100644 --- a/kmicromail/libmailwrapper/imapwrapper.h +++ b/kmicromail/libmailwrapper/imapwrapper.h @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #ifndef __IMAPWRAPPER #define __IMAPWRAPPER #include <qlist.h> @@ -23,17 +24,18 @@ class IMAPwrapper : public AbstractMail public: IMAPwrapper( IMAPaccount *a ); virtual ~IMAPwrapper(); virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); - virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target ); + virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target , int sizeInKb = 0); virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); virtual void deleteMail(const RecMailP&mail); + void deleteMailList(const QValueList<RecMailP>&target); virtual void answeredMail(const RecMailP&mail); virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder); virtual void storeMessage(const char*msg,size_t length, const QString&folder); virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, - const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); + const QString&targetFolder,AbstractMail*targetWrapper,bool moveit,int sizeInKb = 0); virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); virtual RecBodyP fetchBody(const RecMailP&mail); virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part); diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp index 7ef9b32..cbc52d9 100644 --- a/kmicromail/libmailwrapper/mhwrapper.cpp +++ b/kmicromail/libmailwrapper/mhwrapper.cpp @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #include "mhwrapper.h" #include "mailtypes.h" #include "mailwrapper.h" #include <libetpan/libetpan.h> @@ -61,9 +62,9 @@ MHwrapper::~MHwrapper() { clean_storage(); } -void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) +void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) { init_storage(); if (!m_storage) { return; @@ -73,9 +74,9 @@ void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSm if (r!=MAIL_NO_ERROR) { qDebug("listMessages: error selecting folder! "); return; } - parseList(target,m_storage->sto_session,f); + parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); } QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() diff --git a/kmicromail/libmailwrapper/mhwrapper.h b/kmicromail/libmailwrapper/mhwrapper.h index 4310c84..550824d 100644 --- a/kmicromail/libmailwrapper/mhwrapper.h +++ b/kmicromail/libmailwrapper/mhwrapper.h @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #ifndef __MH_WRAPPER_H #define __MH_WRAPPER_H #include "maildefines.h" @@ -16,9 +17,9 @@ class MHwrapper : public Genericwrapper public: MHwrapper(const QString & dir,const QString&name); virtual ~MHwrapper(); - virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); + virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); virtual void deleteMail(const RecMailP&mail); diff --git a/kmicromail/libmailwrapper/nntpwrapper.cpp b/kmicromail/libmailwrapper/nntpwrapper.cpp index daa128e..f5d7f16 100644 --- a/kmicromail/libmailwrapper/nntpwrapper.cpp +++ b/kmicromail/libmailwrapper/nntpwrapper.cpp @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #include "nntpwrapper.h" #include "logindialog.h" #include "mailtypes.h" @@ -97,16 +98,16 @@ RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { return body; } -void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) +void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb) { 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,true); + parseList(target,m_nntp->sto_session,which,true, maxSizeInKb); } void NNTPwrapper::login() { diff --git a/kmicromail/libmailwrapper/nntpwrapper.h b/kmicromail/libmailwrapper/nntpwrapper.h index 2fb82f2..5d4e5ce 100644 --- a/kmicromail/libmailwrapper/nntpwrapper.h +++ b/kmicromail/libmailwrapper/nntpwrapper.h @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #ifndef __NNTPWRAPPER #define __NNTPWRAPPER #include "mailwrapper.h" @@ -19,9 +20,9 @@ public: NNTPwrapper( NNTPaccount *a ); virtual ~NNTPwrapper(); /* mailbox will be ignored */ - virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); + virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); /* should only get the subscribed one */ virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); /* mailbox will be ignored */ virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp index e5d083a..7a84b30 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.cpp +++ b/kmicromail/libmailwrapper/pop3wrapper.cpp @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #include <stdlib.h> #include "pop3wrapper.h" #include "mailtypes.h" #include "logindialog.h" @@ -95,16 +96,16 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { return body; } -void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) +void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) { login(); if (!m_pop3) return; uint32_t res_messages,res_recent,res_unseen; mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); - parseList(target,m_pop3->sto_session,"INBOX"); + parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); } void POP3wrapper::login() @@ -191,8 +192,24 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { folders->append(inb); return folders; } +void POP3wrapper::deleteMailList(QValueList<RecMailP>&target) +{ + login(); + if (!m_pop3) + return; + int iii = 0; + int count = target.count(); + while (iii < count ) { + RecMailP mail = (*target.at( iii )); + int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); + if (err != MAIL_NO_ERROR) { + Global::statusMessage(tr("error deleting mail")); + } + ++iii; + } +} void POP3wrapper::deleteMail(const RecMailP&mail) { login(); if (!m_pop3) return; diff --git a/kmicromail/libmailwrapper/pop3wrapper.h b/kmicromail/libmailwrapper/pop3wrapper.h index 5101fa5..ee754a4 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.h +++ b/kmicromail/libmailwrapper/pop3wrapper.h @@ -1,4 +1,5 @@ +// CHANGED 2004-09-31 Lutz Rogowski #ifndef __POP3WRAPPER #define __POP3WRAPPER #include "mailwrapper.h" @@ -16,15 +17,16 @@ class POP3wrapper : public Genericwrapper public: POP3wrapper( POP3account *a ); virtual ~POP3wrapper(); /* mailbox will be ignored */ - virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ); + virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); /* mailbox will be ignored */ virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); virtual void deleteMail(const RecMailP&mail); virtual void answeredMail(const RecMailP&mail); + virtual void deleteMailList(QValueList<RecMailP>&target); virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); virtual RecBodyP fetchBody( const RecMailP &mail ); virtual encodedString* fetchRawBody(const RecMailP&mail); |