From b0a71314013a3367767526b68928a7168b4ad460 Mon Sep 17 00:00:00 2001 From: alwin Date: Sat, 13 Dec 2003 22:35:35 +0000 Subject: deleting a mail in a imap server implemented --- (limited to 'noncore/net') 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 @@ -20,8 +20,8 @@ public: virtual QList* listFolders()=0; virtual void listMessages(const QString & mailbox,QList&target )=0; virtual RecBody fetchBody(const RecMail&mail)=0; - virtual QString fetchPart(const RecMail&mail,const QValueList&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); 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 @@ -696,3 +696,35 @@ 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 @@ -23,14 +23,17 @@ public: virtual QList* listFolders(); virtual void listMessages(const QString & mailbox,QList&target ); virtual RecBody fetchBody(const RecMail&mail); - virtual QString fetchPart(const RecMail&mail,const QValueList&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&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,QValueListrecList=QValueList()); 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 @@ -20,8 +20,8 @@ public: virtual QList* listFolders()=0; virtual void listMessages(const QString & mailbox,QList&target )=0; virtual RecBody fetchBody(const RecMail&mail)=0; - virtual QString fetchPart(const RecMail&mail,const QValueList&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); 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 @@ -696,3 +696,35 @@ 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 @@ -23,14 +23,17 @@ public: virtual QList* listFolders(); virtual void listMessages(const QString & mailbox,QList&target ); virtual RecBody fetchBody(const RecMail&mail); - virtual QString fetchPart(const RecMail&mail,const QValueList&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&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,QValueListrecList=QValueList()); 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 @@ -279,12 +279,11 @@ QList* POP3wrapper::listFolders() return folders; } -QString POP3wrapper::fetchPart(const RecMail&,const QValueList&,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 @@ -18,8 +18,8 @@ public: /* mailbox will be ignored */ virtual void listMessages(const QString & mailbox, QList &target ); virtual QList* listFolders(); - virtual QString fetchPart(const RecMail&mail,const QValueList&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 ); 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 @@ -279,12 +279,11 @@ QList* POP3wrapper::listFolders() return folders; } -QString POP3wrapper::fetchPart(const RecMail&,const QValueList&,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 @@ -18,8 +18,8 @@ public: /* mailbox will be ignored */ virtual void listMessages(const QString & mailbox, QList &target ); virtual QList* listFolders(); - virtual QString fetchPart(const RecMail&mail,const QValueList&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 ); -- cgit v0.9.0.2