summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/imapwrapper.cpp
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper/imapwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp60
1 files changed, 54 insertions, 6 deletions
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,3 +1,4 @@
1// CHANGED 2004-09-31 Lutz Rogowski
1#include <stdlib.h> 2#include <stdlib.h>
2#include <libetpan/libetpan.h> 3#include <libetpan/libetpan.h>
3#include <qpe/global.h> 4#include <qpe/global.h>
@@ -202,7 +203,7 @@ void IMAPwrapper::logout()
202 m_Lastmbox = ""; 203 m_Lastmbox = "";
203} 204}
204 205
205void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) 206void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb)
206{ 207{
207 int err = MAILIMAP_NO_ERROR; 208 int err = MAILIMAP_NO_ERROR;
208 clist *result = 0; 209 clist *result = 0;
@@ -250,12 +251,14 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma
250 msg_att = (mailimap_msg_att*)current->data; 251 msg_att = (mailimap_msg_att*)current->data;
251 RecMail*m = parse_list_result(msg_att); 252 RecMail*m = parse_list_result(msg_att);
252 if (m) { 253 if (m) {
254 if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) {
253 m->setNumber(i); 255 m->setNumber(i);
254 m->setMbox(mailbox); 256 m->setMbox(mailbox);
255 m->setWrapper(this); 257 m->setWrapper(this);
256 target.append(m); 258 target.append(m);
257 } 259 }
258 } 260 }
261 }
259 Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); 262 Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count()));
260 } else { 263 } else {
261 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); 264 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response));
@@ -866,7 +869,49 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which
866 target_part->setEncoding(encoding); 869 target_part->setEncoding(encoding);
867 target_part->setSize(which->bd_size); 870 target_part->setSize(which->bd_size);
868} 871}
872void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target)
873{
874 mailimap_flag_list*flist;
875 mailimap_set *set;
876 mailimap_store_att_flags * store_flags;
877 int err;
878 login();
879 if (!m_imap) {
880 return;
881 }
882 int iii = 0;
883 int count = target.count();
884 qDebug("imap remove count %d ", count);
885 while (iii < count ) {
886 qDebug("IMAP remove %d ", iii);
887 RecMailP mail = (*target.at( iii ));
869 888
889 err = selectMbox(mail->getMbox());
890 if ( err != MAILIMAP_NO_ERROR ) {
891 return;
892 }
893 flist = mailimap_flag_list_new_empty();
894 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
895 store_flags = mailimap_store_att_flags_new_set_flags(flist);
896 set = mailimap_set_new_single(mail->getNumber());
897 err = mailimap_store(m_imap,set,store_flags);
898 mailimap_set_free( set );
899 mailimap_store_att_flags_free(store_flags);
900
901 if (err != MAILIMAP_NO_ERROR) {
902 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
903 return;
904 }
905 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
906 /* should we realy do that at this moment? */
907
908 err = mailimap_expunge(m_imap);
909 if (err != MAILIMAP_NO_ERROR) {
910 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
911 }
912 ++iii;
913 }
914}
870void IMAPwrapper::deleteMail(const RecMailP&mail) 915void IMAPwrapper::deleteMail(const RecMailP&mail)
871{ 916{
872 mailimap_flag_list*flist; 917 mailimap_flag_list*flist;
@@ -895,11 +940,13 @@ void IMAPwrapper::deleteMail(const RecMailP&mail)
895 } 940 }
896 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; 941 // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
897 /* should we realy do that at this moment? */ 942 /* should we realy do that at this moment? */
943
898 err = mailimap_expunge(m_imap); 944 err = mailimap_expunge(m_imap);
899 if (err != MAILIMAP_NO_ERROR) { 945 if (err != MAILIMAP_NO_ERROR) {
900 // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; 946 Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
901 } 947 }
902 // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; 948 qDebug("IMAPwrapper::deleteMail ");
949
903} 950}
904 951
905void IMAPwrapper::answeredMail(const RecMailP&mail) 952void IMAPwrapper::answeredMail(const RecMailP&mail)
@@ -1120,10 +1167,11 @@ encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail)
1120} 1167}
1121 1168
1122void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, 1169void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
1123 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 1170 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb)
1124{ 1171{
1125 if (targetWrapper != this) { 1172 if (targetWrapper != this || maxSizeInKb > 0 ) {
1126 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); 1173 AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb);
1174 qDebug("IMAPwrapper::mvcpAllMails::Using generic");
1127 // odebug << "Using generic" << oendl; 1175 // odebug << "Using generic" << oendl;
1128 return; 1176 return;
1129 } 1177 }