summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/imapwrapper.cpp
authorzautrix <zautrix>2004-08-31 21:01:18 (UTC)
committer zautrix <zautrix>2004-08-31 21:01:18 (UTC)
commit3f5c51234c8068f3d4826a2a0066648ace21a19f (patch) (side-by-side diff)
tree91b76c1c7ddec6628c573e409070070747d99feb /kmicromail/libmailwrapper/imapwrapper.cpp
parent95f8d4f1de557bd25ae38807d970208399cec5d1 (diff)
downloadkdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.zip
kdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.tar.gz
kdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.tar.bz2
Enhancements of kopiemail
Diffstat (limited to 'kmicromail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp68
1 files changed, 58 insertions, 10 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,8 +1,9 @@
+// CHANGED 2004-09-31 Lutz Rogowski
#include <stdlib.h>
#include <libetpan/libetpan.h>
#include <qpe/global.h>
#include <qapplication.h>
#include "imapwrapper.h"
#include "mailtypes.h"
#include "logindialog.h"
@@ -197,17 +198,17 @@ void IMAPwrapper::logout()
if (!m_imap) return;
err = mailimap_logout( m_imap );
err = mailimap_close( m_imap );
mailimap_free( m_imap );
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;
mailimap_fetch_type *fetchType = 0;
mailimap_set *set = 0;
login();
@@ -245,20 +246,22 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma
if ( err == MAILIMAP_NO_ERROR ) {
mailimap_msg_att * msg_att;
int i = 0;
for (current = clist_begin(result); current != 0; current=clist_next(current)) {
++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 {
Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response));
}
if (result) mailimap_fetch_list_free(result);
}
@@ -861,17 +864,59 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which
}
}
if (which->bd_description) {
target_part->setDescription(QString(which->bd_description));
}
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;
mailimap_store_att_flags * store_flags;
int err;
login();
if (!m_imap) {
@@ -890,21 +935,23 @@ void IMAPwrapper::deleteMail(const RecMailP&mail)
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) {
- // 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)
{
mailimap_flag_list*flist;
mailimap_set *set;
mailimap_store_att_flags * store_flags;
int err;
@@ -1115,20 +1162,21 @@ const QString&IMAPwrapper::getName()const
encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail)
{
// dummy
QValueList<int> path;
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;
login();
if (!m_imap) {
return;
}