summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/abstractmail.h2
-rw-r--r--noncore/net/mail/imapwrapper.cpp32
-rw-r--r--noncore/net/mail/imapwrapper.h5
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h2
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp32
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h5
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h2
-rw-r--r--noncore/net/mail/pop3wrapper.cpp5
-rw-r--r--noncore/net/mail/pop3wrapper.h2
10 files changed, 80 insertions, 12 deletions
diff --git a/noncore/net/mail/abstractmail.h b/noncore/net/mail/abstractmail.h
index bc8938f..0a1719d 100644
--- a/noncore/net/mail/abstractmail.h
+++ b/noncore/net/mail/abstractmail.h
@@ -7,24 +7,24 @@
class RecMail;
class RecBody;
class RecPart;
class IMAPwrapper;
class POP3wrapper;
class Folder;
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 RecBody fetchBody(const RecMail&mail)=0;
- virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false)=0;
virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0;
+ virtual void deleteMail(const RecMail&mail)=0;
static AbstractMail* getWrapper(IMAPaccount *a);
static AbstractMail* getWrapper(POP3account *a);
};
#endif
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index 3222c7e..a01a2a9 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -683,16 +683,48 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
default:
if (enc->enc_value) {
char*t=enc->enc_value;
encoding=QString(enc->enc_value);
enc->enc_value=0L;
free(t);
}
}
target_part.setEncoding(encoding);
target_part.setSize(which->bd_size);
}
QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part)
{
return fetchPart(mail,part.Positionlist(),false);
}
+
+void IMAPwrapper::deleteMail(const RecMail&mail)
+{
+ mailimap_flag_list*flist;
+ mailimap_set *set;
+ mailimap_store_att_flags * store_flags;
+ int err;
+ login();
+ if (!m_imap) {
+ return;
+ }
+ const char *mb = mail.getMbox().latin1();
+ err = mailimap_select( m_imap, (char*)mb);
+ if ( err != MAILIMAP_NO_ERROR ) {
+ qDebug("error selecting mailbox for delete: %s",m_imap->imap_response);
+ 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);
+ if (err != MAILIMAP_NO_ERROR) {
+ qDebug("error deleting mail: %s",m_imap->imap_response);
+ return;
+ }
+ err = mailimap_expunge(m_imap);
+ if (err != MAILIMAP_NO_ERROR) {
+ qDebug("error deleting mail: %s",m_imap->imap_response);
+ }
+ qDebug("Delete successfull");
+}
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h
index f88457a..4f4d575 100644
--- a/noncore/net/mail/imapwrapper.h
+++ b/noncore/net/mail/imapwrapper.h
@@ -10,40 +10,43 @@ struct mailimap_body_type_1part;
struct mailimap_body_type_text;
struct mailimap_body_type_basic;
struct mailimap_body_type_msg;
struct mailimap_body_type_mpart;
struct mailimap_body_fields;
struct mailimap_msg_att;
class IMAPwrapper : public AbstractMail
{
Q_OBJECT
public:
IMAPwrapper( IMAPaccount *a );
virtual ~IMAPwrapper();
virtual QList<Folder>* listFolders();
virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
virtual RecBody fetchBody(const RecMail&mail);
- virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false);
virtual QString fetchPart(const RecMail&mail,const RecPart&part);
+ virtual void deleteMail(const RecMail&mail);
+
static void imap_progress( size_t current, size_t maximum );
protected:
RecMail*parse_list_result(mailimap_msg_att*);
void login();
void logout();
+
+ virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false);
void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body);
void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>());
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);
/* just helpers */
static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
static QStringList address_list_to_stringlist(clist*list);
private:
IMAPaccount *account;
mailimap *m_imap;
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index bc8938f..0a1719d 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -7,24 +7,24 @@
class RecMail;
class RecBody;
class RecPart;
class IMAPwrapper;
class POP3wrapper;
class Folder;
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 RecBody fetchBody(const RecMail&mail)=0;
- virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false)=0;
virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0;
+ virtual void deleteMail(const RecMail&mail)=0;
static AbstractMail* getWrapper(IMAPaccount *a);
static AbstractMail* getWrapper(POP3account *a);
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 3222c7e..a01a2a9 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -683,16 +683,48 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
default:
if (enc->enc_value) {
char*t=enc->enc_value;
encoding=QString(enc->enc_value);
enc->enc_value=0L;
free(t);
}
}
target_part.setEncoding(encoding);
target_part.setSize(which->bd_size);
}
QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part)
{
return fetchPart(mail,part.Positionlist(),false);
}
+
+void IMAPwrapper::deleteMail(const RecMail&mail)
+{
+ mailimap_flag_list*flist;
+ mailimap_set *set;
+ mailimap_store_att_flags * store_flags;
+ int err;
+ login();
+ if (!m_imap) {
+ return;
+ }
+ const char *mb = mail.getMbox().latin1();
+ err = mailimap_select( m_imap, (char*)mb);
+ if ( err != MAILIMAP_NO_ERROR ) {
+ qDebug("error selecting mailbox for delete: %s",m_imap->imap_response);
+ 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);
+ if (err != MAILIMAP_NO_ERROR) {
+ qDebug("error deleting mail: %s",m_imap->imap_response);
+ return;
+ }
+ err = mailimap_expunge(m_imap);
+ if (err != MAILIMAP_NO_ERROR) {
+ qDebug("error deleting mail: %s",m_imap->imap_response);
+ }
+ qDebug("Delete successfull");
+}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index f88457a..4f4d575 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -10,40 +10,43 @@ struct mailimap_body_type_1part;
struct mailimap_body_type_text;
struct mailimap_body_type_basic;
struct mailimap_body_type_msg;
struct mailimap_body_type_mpart;
struct mailimap_body_fields;
struct mailimap_msg_att;
class IMAPwrapper : public AbstractMail
{
Q_OBJECT
public:
IMAPwrapper( IMAPaccount *a );
virtual ~IMAPwrapper();
virtual QList<Folder>* listFolders();
virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
virtual RecBody fetchBody(const RecMail&mail);
- virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false);
virtual QString fetchPart(const RecMail&mail,const RecPart&part);
+ virtual void deleteMail(const RecMail&mail);
+
static void imap_progress( size_t current, size_t maximum );
protected:
RecMail*parse_list_result(mailimap_msg_att*);
void login();
void logout();
+
+ virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false);
void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body);
void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>());
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);
/* just helpers */
static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
static QStringList address_list_to_stringlist(clist*list);
private:
IMAPaccount *account;
mailimap *m_imap;
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 903ef4d..62523bf 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -266,25 +266,24 @@ void POP3wrapper::logout()
if ( m_pop3 == NULL ) return;
err = mailpop3_quit( m_pop3 );
mailpop3_free( m_pop3 );
m_pop3 = NULL;
}
QList<Folder>* POP3wrapper::listFolders()
{
QList<Folder> * folders = new QList<Folder>();
folders->setAutoDelete( true );
Folder*inb=new Folder("INBOX");
folders->append(inb);
return folders;
}
-QString POP3wrapper::fetchPart(const RecMail&,const QValueList<int>&,bool)
+QString POP3wrapper::fetchPart(const RecMail&,const RecPart&)
{
return "";
}
-QString POP3wrapper::fetchPart(const RecMail&,const RecPart&)
+void POP3wrapper::deleteMail(const RecMail&)
{
- return "";
}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index 3b24564..ef972c8 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -5,34 +5,34 @@
#include "abstractmail.h"
class RecMail;
class RecBody;
struct mailpop3;
class POP3wrapper : public AbstractMail
{
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();
- virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false);
virtual QString fetchPart(const RecMail&mail,const RecPart&part);
+ virtual void deleteMail(const RecMail&mail);
RecBody fetchBody( const RecMail &mail );
static void pop3_progress( size_t current, size_t maximum );
protected:
void login();
void logout();
private:
RecMail *parseHeader( const char *header );
RecBody parseBody( const char *message );
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 );
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 903ef4d..62523bf 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -266,25 +266,24 @@ void POP3wrapper::logout()
if ( m_pop3 == NULL ) return;
err = mailpop3_quit( m_pop3 );
mailpop3_free( m_pop3 );
m_pop3 = NULL;
}
QList<Folder>* POP3wrapper::listFolders()
{
QList<Folder> * folders = new QList<Folder>();
folders->setAutoDelete( true );
Folder*inb=new Folder("INBOX");
folders->append(inb);
return folders;
}
-QString POP3wrapper::fetchPart(const RecMail&,const QValueList<int>&,bool)
+QString POP3wrapper::fetchPart(const RecMail&,const RecPart&)
{
return "";
}
-QString POP3wrapper::fetchPart(const RecMail&,const RecPart&)
+void POP3wrapper::deleteMail(const RecMail&)
{
- return "";
}
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h
index 3b24564..ef972c8 100644
--- a/noncore/net/mail/pop3wrapper.h
+++ b/noncore/net/mail/pop3wrapper.h
@@ -5,34 +5,34 @@
#include "abstractmail.h"
class RecMail;
class RecBody;
struct mailpop3;
class POP3wrapper : public AbstractMail
{
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();
- virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false);
virtual QString fetchPart(const RecMail&mail,const RecPart&part);
+ virtual void deleteMail(const RecMail&mail);
RecBody fetchBody( const RecMail &mail );
static void pop3_progress( size_t current, size_t maximum );
protected:
void login();
void logout();
private:
RecMail *parseHeader( const char *header );
RecBody parseBody( const char *message );
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 );