summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-14 17:33:16 (UTC)
committer alwin <alwin>2003-12-14 17:33:16 (UTC)
commit353e1da81b235d7798763bce76428fb473108fb6 (patch) (unidiff)
treee9b8f8cbe3ee37512a1c9fc0409185f4fb6c9883
parent87425f2b26c01cc9bcc9bfac21a707462b410f13 (diff)
downloadopie-353e1da81b235d7798763bce76428fb473108fb6.zip
opie-353e1da81b235d7798763bce76428fb473108fb6.tar.gz
opie-353e1da81b235d7798763bce76428fb473108fb6.tar.bz2
- replied mails will get the flag answered
- text fix in preparing the message for a reply
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/abstractmail.h1
-rw-r--r--noncore/net/mail/imapwrapper.cpp30
-rw-r--r--noncore/net/mail/imapwrapper.h1
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h1
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp30
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h1
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp4
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h1
-rw-r--r--noncore/net/mail/pop3wrapper.cpp4
-rw-r--r--noncore/net/mail/pop3wrapper.h1
-rw-r--r--noncore/net/mail/viewmail.cpp11
11 files changed, 81 insertions, 4 deletions
diff --git a/noncore/net/mail/abstractmail.h b/noncore/net/mail/abstractmail.h
index 0a1719d..62e0715 100644
--- a/noncore/net/mail/abstractmail.h
+++ b/noncore/net/mail/abstractmail.h
@@ -1,30 +1,31 @@
1#ifndef __abstract_mail_ 1#ifndef __abstract_mail_
2#define __abstract_mail_ 2#define __abstract_mail_
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include "settings.h" 5#include "settings.h"
6 6
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9class RecPart; 9class RecPart;
10class IMAPwrapper; 10class IMAPwrapper;
11class POP3wrapper; 11class POP3wrapper;
12class Folder; 12class Folder;
13 13
14class AbstractMail:public QObject 14class AbstractMail:public QObject
15{ 15{
16 Q_OBJECT 16 Q_OBJECT
17public: 17public:
18 AbstractMail(){}; 18 AbstractMail(){};
19 virtual ~AbstractMail(){} 19 virtual ~AbstractMail(){}
20 virtual QList<Folder>* listFolders()=0; 20 virtual QList<Folder>* listFolders()=0;
21 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; 21 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
22 virtual RecBody fetchBody(const RecMail&mail)=0; 22 virtual RecBody fetchBody(const RecMail&mail)=0;
23 virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0; 23 virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0;
24 virtual void deleteMail(const RecMail&mail)=0; 24 virtual void deleteMail(const RecMail&mail)=0;
25 virtual void answeredMail(const RecMail&mail)=0;
25 26
26 static AbstractMail* getWrapper(IMAPaccount *a); 27 static AbstractMail* getWrapper(IMAPaccount *a);
27 static AbstractMail* getWrapper(POP3account *a); 28 static AbstractMail* getWrapper(POP3account *a);
28}; 29};
29 30
30#endif 31#endif
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index 912a412..b253b49 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -694,48 +694,78 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
694 free(t); 694 free(t);
695 } 695 }
696 } 696 }
697 target_part.setEncoding(encoding); 697 target_part.setEncoding(encoding);
698 target_part.setSize(which->bd_size); 698 target_part.setSize(which->bd_size);
699} 699}
700 700
701QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) 701QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part)
702{ 702{
703 return fetchPart(mail,part.Positionlist(),false); 703 return fetchPart(mail,part.Positionlist(),false);
704} 704}
705 705
706void IMAPwrapper::deleteMail(const RecMail&mail) 706void IMAPwrapper::deleteMail(const RecMail&mail)
707{ 707{
708 mailimap_flag_list*flist; 708 mailimap_flag_list*flist;
709 mailimap_set *set; 709 mailimap_set *set;
710 mailimap_store_att_flags * store_flags; 710 mailimap_store_att_flags * store_flags;
711 int err; 711 int err;
712 login(); 712 login();
713 if (!m_imap) { 713 if (!m_imap) {
714 return; 714 return;
715 } 715 }
716 const char *mb = mail.getMbox().latin1(); 716 const char *mb = mail.getMbox().latin1();
717 err = mailimap_select( m_imap, (char*)mb); 717 err = mailimap_select( m_imap, (char*)mb);
718 if ( err != MAILIMAP_NO_ERROR ) { 718 if ( err != MAILIMAP_NO_ERROR ) {
719 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response); 719 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response);
720 return; 720 return;
721 } 721 }
722 flist = mailimap_flag_list_new_empty(); 722 flist = mailimap_flag_list_new_empty();
723 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 723 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
724 store_flags = mailimap_store_att_flags_new_set_flags(flist); 724 store_flags = mailimap_store_att_flags_new_set_flags(flist);
725 set = mailimap_set_new_single(mail.getNumber()); 725 set = mailimap_set_new_single(mail.getNumber());
726 err = mailimap_store(m_imap,set,store_flags); 726 err = mailimap_store(m_imap,set,store_flags);
727 mailimap_set_free( set ); 727 mailimap_set_free( set );
728 mailimap_store_att_flags_free(store_flags); 728 mailimap_store_att_flags_free(store_flags);
729 729
730 if (err != MAILIMAP_NO_ERROR) { 730 if (err != MAILIMAP_NO_ERROR) {
731 qDebug("error deleting mail: %s",m_imap->imap_response); 731 qDebug("error deleting mail: %s",m_imap->imap_response);
732 return; 732 return;
733 } 733 }
734 qDebug("deleting mail: %s",m_imap->imap_response); 734 qDebug("deleting mail: %s",m_imap->imap_response);
735 /* should we realy do that at this moment? */ 735 /* should we realy do that at this moment? */
736 err = mailimap_expunge(m_imap); 736 err = mailimap_expunge(m_imap);
737 if (err != MAILIMAP_NO_ERROR) { 737 if (err != MAILIMAP_NO_ERROR) {
738 qDebug("error deleting mail: %s",m_imap->imap_response); 738 qDebug("error deleting mail: %s",m_imap->imap_response);
739 } 739 }
740 qDebug("Delete successfull %s",m_imap->imap_response); 740 qDebug("Delete successfull %s",m_imap->imap_response);
741} 741}
742
743void IMAPwrapper::answeredMail(const RecMail&mail)
744{
745 mailimap_flag_list*flist;
746 mailimap_set *set;
747 mailimap_store_att_flags * store_flags;
748 int err;
749 login();
750 if (!m_imap) {
751 return;
752 }
753 const char *mb = mail.getMbox().latin1();
754 err = mailimap_select( m_imap, (char*)mb);
755 if ( err != MAILIMAP_NO_ERROR ) {
756 qDebug("error selecting mailbox for mark: %s",m_imap->imap_response);
757 return;
758 }
759 flist = mailimap_flag_list_new_empty();
760 mailimap_flag_list_add(flist,mailimap_flag_new_answered());
761 store_flags = mailimap_store_att_flags_new_set_flags(flist);
762 set = mailimap_set_new_single(mail.getNumber());
763 err = mailimap_store(m_imap,set,store_flags);
764 mailimap_set_free( set );
765 mailimap_store_att_flags_free(store_flags);
766
767 if (err != MAILIMAP_NO_ERROR) {
768 qDebug("error marking mail: %s",m_imap->imap_response);
769 return;
770 }
771}
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h
index 4f4d575..700d512 100644
--- a/noncore/net/mail/imapwrapper.h
+++ b/noncore/net/mail/imapwrapper.h
@@ -1,55 +1,56 @@
1#ifndef __IMAPWRAPPER 1#ifndef __IMAPWRAPPER
2#define __IMAPWRAPPER 2#define __IMAPWRAPPER
3 3
4#include <qlist.h> 4#include <qlist.h>
5#include "mailwrapper.h" 5#include "mailwrapper.h"
6#include "abstractmail.h" 6#include "abstractmail.h"
7 7
8struct mailimap; 8struct mailimap;
9struct mailimap_body_type_1part; 9struct mailimap_body_type_1part;
10struct mailimap_body_type_text; 10struct mailimap_body_type_text;
11struct mailimap_body_type_basic; 11struct mailimap_body_type_basic;
12struct mailimap_body_type_msg; 12struct mailimap_body_type_msg;
13struct mailimap_body_type_mpart; 13struct mailimap_body_type_mpart;
14struct mailimap_body_fields; 14struct mailimap_body_fields;
15struct mailimap_msg_att; 15struct mailimap_msg_att;
16 16
17class IMAPwrapper : public AbstractMail 17class IMAPwrapper : public AbstractMail
18{ 18{
19 Q_OBJECT 19 Q_OBJECT
20public: 20public:
21 IMAPwrapper( IMAPaccount *a ); 21 IMAPwrapper( IMAPaccount *a );
22 virtual ~IMAPwrapper(); 22 virtual ~IMAPwrapper();
23 virtual QList<Folder>* listFolders(); 23 virtual QList<Folder>* listFolders();
24 virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); 24 virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
25 virtual RecBody fetchBody(const RecMail&mail); 25 virtual RecBody fetchBody(const RecMail&mail);
26 virtual QString fetchPart(const RecMail&mail,const RecPart&part); 26 virtual QString fetchPart(const RecMail&mail,const RecPart&part);
27 virtual void deleteMail(const RecMail&mail); 27 virtual void deleteMail(const RecMail&mail);
28 virtual void answeredMail(const RecMail&mail);
28 29
29 static void imap_progress( size_t current, size_t maximum ); 30 static void imap_progress( size_t current, size_t maximum );
30 31
31protected: 32protected:
32 RecMail*parse_list_result(mailimap_msg_att*); 33 RecMail*parse_list_result(mailimap_msg_att*);
33 void login(); 34 void login();
34 void logout(); 35 void logout();
35 36
36 virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); 37 virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false);
37 38
38 void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); 39 void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body);
39 void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); 40 void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>());
40 41
41 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); 42 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
42 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); 43 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
43 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); 44 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
44 void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); 45 void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
45 46
46 /* just helpers */ 47 /* just helpers */
47 static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); 48 static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
48 static QStringList address_list_to_stringlist(clist*list); 49 static QStringList address_list_to_stringlist(clist*list);
49 50
50private: 51private:
51 IMAPaccount *account; 52 IMAPaccount *account;
52 mailimap *m_imap; 53 mailimap *m_imap;
53}; 54};
54 55
55#endif 56#endif
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 0a1719d..62e0715 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -1,30 +1,31 @@
1#ifndef __abstract_mail_ 1#ifndef __abstract_mail_
2#define __abstract_mail_ 2#define __abstract_mail_
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include "settings.h" 5#include "settings.h"
6 6
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9class RecPart; 9class RecPart;
10class IMAPwrapper; 10class IMAPwrapper;
11class POP3wrapper; 11class POP3wrapper;
12class Folder; 12class Folder;
13 13
14class AbstractMail:public QObject 14class AbstractMail:public QObject
15{ 15{
16 Q_OBJECT 16 Q_OBJECT
17public: 17public:
18 AbstractMail(){}; 18 AbstractMail(){};
19 virtual ~AbstractMail(){} 19 virtual ~AbstractMail(){}
20 virtual QList<Folder>* listFolders()=0; 20 virtual QList<Folder>* listFolders()=0;
21 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; 21 virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
22 virtual RecBody fetchBody(const RecMail&mail)=0; 22 virtual RecBody fetchBody(const RecMail&mail)=0;
23 virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0; 23 virtual QString fetchPart(const RecMail&mail,const RecPart&part)=0;
24 virtual void deleteMail(const RecMail&mail)=0; 24 virtual void deleteMail(const RecMail&mail)=0;
25 virtual void answeredMail(const RecMail&mail)=0;
25 26
26 static AbstractMail* getWrapper(IMAPaccount *a); 27 static AbstractMail* getWrapper(IMAPaccount *a);
27 static AbstractMail* getWrapper(POP3account *a); 28 static AbstractMail* getWrapper(POP3account *a);
28}; 29};
29 30
30#endif 31#endif
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 912a412..b253b49 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -694,48 +694,78 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
694 free(t); 694 free(t);
695 } 695 }
696 } 696 }
697 target_part.setEncoding(encoding); 697 target_part.setEncoding(encoding);
698 target_part.setSize(which->bd_size); 698 target_part.setSize(which->bd_size);
699} 699}
700 700
701QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) 701QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part)
702{ 702{
703 return fetchPart(mail,part.Positionlist(),false); 703 return fetchPart(mail,part.Positionlist(),false);
704} 704}
705 705
706void IMAPwrapper::deleteMail(const RecMail&mail) 706void IMAPwrapper::deleteMail(const RecMail&mail)
707{ 707{
708 mailimap_flag_list*flist; 708 mailimap_flag_list*flist;
709 mailimap_set *set; 709 mailimap_set *set;
710 mailimap_store_att_flags * store_flags; 710 mailimap_store_att_flags * store_flags;
711 int err; 711 int err;
712 login(); 712 login();
713 if (!m_imap) { 713 if (!m_imap) {
714 return; 714 return;
715 } 715 }
716 const char *mb = mail.getMbox().latin1(); 716 const char *mb = mail.getMbox().latin1();
717 err = mailimap_select( m_imap, (char*)mb); 717 err = mailimap_select( m_imap, (char*)mb);
718 if ( err != MAILIMAP_NO_ERROR ) { 718 if ( err != MAILIMAP_NO_ERROR ) {
719 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response); 719 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response);
720 return; 720 return;
721 } 721 }
722 flist = mailimap_flag_list_new_empty(); 722 flist = mailimap_flag_list_new_empty();
723 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 723 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
724 store_flags = mailimap_store_att_flags_new_set_flags(flist); 724 store_flags = mailimap_store_att_flags_new_set_flags(flist);
725 set = mailimap_set_new_single(mail.getNumber()); 725 set = mailimap_set_new_single(mail.getNumber());
726 err = mailimap_store(m_imap,set,store_flags); 726 err = mailimap_store(m_imap,set,store_flags);
727 mailimap_set_free( set ); 727 mailimap_set_free( set );
728 mailimap_store_att_flags_free(store_flags); 728 mailimap_store_att_flags_free(store_flags);
729 729
730 if (err != MAILIMAP_NO_ERROR) { 730 if (err != MAILIMAP_NO_ERROR) {
731 qDebug("error deleting mail: %s",m_imap->imap_response); 731 qDebug("error deleting mail: %s",m_imap->imap_response);
732 return; 732 return;
733 } 733 }
734 qDebug("deleting mail: %s",m_imap->imap_response); 734 qDebug("deleting mail: %s",m_imap->imap_response);
735 /* should we realy do that at this moment? */ 735 /* should we realy do that at this moment? */
736 err = mailimap_expunge(m_imap); 736 err = mailimap_expunge(m_imap);
737 if (err != MAILIMAP_NO_ERROR) { 737 if (err != MAILIMAP_NO_ERROR) {
738 qDebug("error deleting mail: %s",m_imap->imap_response); 738 qDebug("error deleting mail: %s",m_imap->imap_response);
739 } 739 }
740 qDebug("Delete successfull %s",m_imap->imap_response); 740 qDebug("Delete successfull %s",m_imap->imap_response);
741} 741}
742
743void IMAPwrapper::answeredMail(const RecMail&mail)
744{
745 mailimap_flag_list*flist;
746 mailimap_set *set;
747 mailimap_store_att_flags * store_flags;
748 int err;
749 login();
750 if (!m_imap) {
751 return;
752 }
753 const char *mb = mail.getMbox().latin1();
754 err = mailimap_select( m_imap, (char*)mb);
755 if ( err != MAILIMAP_NO_ERROR ) {
756 qDebug("error selecting mailbox for mark: %s",m_imap->imap_response);
757 return;
758 }
759 flist = mailimap_flag_list_new_empty();
760 mailimap_flag_list_add(flist,mailimap_flag_new_answered());
761 store_flags = mailimap_store_att_flags_new_set_flags(flist);
762 set = mailimap_set_new_single(mail.getNumber());
763 err = mailimap_store(m_imap,set,store_flags);
764 mailimap_set_free( set );
765 mailimap_store_att_flags_free(store_flags);
766
767 if (err != MAILIMAP_NO_ERROR) {
768 qDebug("error marking mail: %s",m_imap->imap_response);
769 return;
770 }
771}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 4f4d575..700d512 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -1,55 +1,56 @@
1#ifndef __IMAPWRAPPER 1#ifndef __IMAPWRAPPER
2#define __IMAPWRAPPER 2#define __IMAPWRAPPER
3 3
4#include <qlist.h> 4#include <qlist.h>
5#include "mailwrapper.h" 5#include "mailwrapper.h"
6#include "abstractmail.h" 6#include "abstractmail.h"
7 7
8struct mailimap; 8struct mailimap;
9struct mailimap_body_type_1part; 9struct mailimap_body_type_1part;
10struct mailimap_body_type_text; 10struct mailimap_body_type_text;
11struct mailimap_body_type_basic; 11struct mailimap_body_type_basic;
12struct mailimap_body_type_msg; 12struct mailimap_body_type_msg;
13struct mailimap_body_type_mpart; 13struct mailimap_body_type_mpart;
14struct mailimap_body_fields; 14struct mailimap_body_fields;
15struct mailimap_msg_att; 15struct mailimap_msg_att;
16 16
17class IMAPwrapper : public AbstractMail 17class IMAPwrapper : public AbstractMail
18{ 18{
19 Q_OBJECT 19 Q_OBJECT
20public: 20public:
21 IMAPwrapper( IMAPaccount *a ); 21 IMAPwrapper( IMAPaccount *a );
22 virtual ~IMAPwrapper(); 22 virtual ~IMAPwrapper();
23 virtual QList<Folder>* listFolders(); 23 virtual QList<Folder>* listFolders();
24 virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); 24 virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
25 virtual RecBody fetchBody(const RecMail&mail); 25 virtual RecBody fetchBody(const RecMail&mail);
26 virtual QString fetchPart(const RecMail&mail,const RecPart&part); 26 virtual QString fetchPart(const RecMail&mail,const RecPart&part);
27 virtual void deleteMail(const RecMail&mail); 27 virtual void deleteMail(const RecMail&mail);
28 virtual void answeredMail(const RecMail&mail);
28 29
29 static void imap_progress( size_t current, size_t maximum ); 30 static void imap_progress( size_t current, size_t maximum );
30 31
31protected: 32protected:
32 RecMail*parse_list_result(mailimap_msg_att*); 33 RecMail*parse_list_result(mailimap_msg_att*);
33 void login(); 34 void login();
34 void logout(); 35 void logout();
35 36
36 virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); 37 virtual QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false);
37 38
38 void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); 39 void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body);
39 void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); 40 void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>());
40 41
41 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); 42 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
42 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); 43 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
43 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); 44 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
44 void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); 45 void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
45 46
46 /* just helpers */ 47 /* just helpers */
47 static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); 48 static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
48 static QStringList address_list_to_stringlist(clist*list); 49 static QStringList address_list_to_stringlist(clist*list);
49 50
50private: 51private:
51 IMAPaccount *account; 52 IMAPaccount *account;
52 mailimap *m_imap; 53 mailimap *m_imap;
53}; 54};
54 55
55#endif 56#endif
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 5065d29..46c854b 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -242,48 +242,52 @@ void POP3wrapper::login()
242 if ( err != MAILPOP3_NO_ERROR ) { 242 if ( err != MAILPOP3_NO_ERROR ) {
243 qDebug( "pop3: error connecting to %s\n reason: %s", server, 243 qDebug( "pop3: error connecting to %s\n reason: %s", server,
244 m_pop3->pop3_response ); 244 m_pop3->pop3_response );
245 mailpop3_free( m_pop3 ); 245 mailpop3_free( m_pop3 );
246 m_pop3 = NULL; 246 m_pop3 = NULL;
247 return; 247 return;
248 } 248 }
249 qDebug( "POP3: connected!" ); 249 qDebug( "POP3: connected!" );
250 250
251 // login 251 // login
252 // TODO: decide if apop or plain login should be used 252 // TODO: decide if apop or plain login should be used
253 err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); 253 err = mailpop3_login( m_pop3, (char *) user, (char *) pass );
254 if ( err != MAILPOP3_NO_ERROR ) { 254 if ( err != MAILPOP3_NO_ERROR ) {
255 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); 255 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response );
256 logout(); 256 logout();
257 return; 257 return;
258 } 258 }
259 259
260 qDebug( "POP3: logged in!" ); 260 qDebug( "POP3: logged in!" );
261} 261}
262 262
263void POP3wrapper::logout() 263void POP3wrapper::logout()
264{ 264{
265 int err = MAILPOP3_NO_ERROR; 265 int err = MAILPOP3_NO_ERROR;
266 if ( m_pop3 == NULL ) return; 266 if ( m_pop3 == NULL ) return;
267 err = mailpop3_quit( m_pop3 ); 267 err = mailpop3_quit( m_pop3 );
268 mailpop3_free( m_pop3 ); 268 mailpop3_free( m_pop3 );
269 m_pop3 = NULL; 269 m_pop3 = NULL;
270} 270}
271 271
272 272
273QList<Folder>* POP3wrapper::listFolders() 273QList<Folder>* POP3wrapper::listFolders()
274{ 274{
275 QList<Folder> * folders = new QList<Folder>(); 275 QList<Folder> * folders = new QList<Folder>();
276 folders->setAutoDelete( false ); 276 folders->setAutoDelete( false );
277 Folder*inb=new Folder("INBOX"); 277 Folder*inb=new Folder("INBOX");
278 folders->append(inb); 278 folders->append(inb);
279 return folders; 279 return folders;
280} 280}
281 281
282QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) 282QString POP3wrapper::fetchPart(const RecMail&,const RecPart&)
283{ 283{
284 return ""; 284 return "";
285} 285}
286 286
287void POP3wrapper::deleteMail(const RecMail&) 287void POP3wrapper::deleteMail(const RecMail&)
288{ 288{
289} 289}
290
291void POP3wrapper::answeredMail(const RecMail&)
292{
293}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index ef972c8..6ff8d62 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -1,43 +1,44 @@
1#ifndef __POP3WRAPPER 1#ifndef __POP3WRAPPER
2#define __POP3WRAPPER 2#define __POP3WRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5#include "abstractmail.h" 5#include "abstractmail.h"
6 6
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9struct mailpop3; 9struct mailpop3;
10 10
11class POP3wrapper : public AbstractMail 11class POP3wrapper : public AbstractMail
12{ 12{
13 Q_OBJECT 13 Q_OBJECT
14 14
15public: 15public:
16 POP3wrapper( POP3account *a ); 16 POP3wrapper( POP3account *a );
17 virtual ~POP3wrapper(); 17 virtual ~POP3wrapper();
18 /* mailbox will be ignored */ 18 /* mailbox will be ignored */
19 virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); 19 virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
20 virtual QList<Folder>* listFolders(); 20 virtual QList<Folder>* listFolders();
21 virtual QString fetchPart(const RecMail&mail,const RecPart&part); 21 virtual QString fetchPart(const RecMail&mail,const RecPart&part);
22 virtual void deleteMail(const RecMail&mail); 22 virtual void deleteMail(const RecMail&mail);
23 virtual void answeredMail(const RecMail&mail);
23 24
24 RecBody fetchBody( const RecMail &mail ); 25 RecBody fetchBody( const RecMail &mail );
25 static void pop3_progress( size_t current, size_t maximum ); 26 static void pop3_progress( size_t current, size_t maximum );
26 27
27protected: 28protected:
28 void login(); 29 void login();
29 void logout(); 30 void logout();
30 31
31private: 32private:
32 RecMail *parseHeader( const char *header ); 33 RecMail *parseHeader( const char *header );
33 RecBody parseBody( const char *message ); 34 RecBody parseBody( const char *message );
34 QString parseMailboxList( mailimf_mailbox_list *list ); 35 QString parseMailboxList( mailimf_mailbox_list *list );
35 QString parseMailbox( mailimf_mailbox *box ); 36 QString parseMailbox( mailimf_mailbox *box );
36 QString parseGroup( mailimf_group *group ); 37 QString parseGroup( mailimf_group *group );
37 QString parseAddressList( mailimf_address_list *list ); 38 QString parseAddressList( mailimf_address_list *list );
38 QString parseDateTime( mailimf_date_time *date ); 39 QString parseDateTime( mailimf_date_time *date );
39 POP3account *account; 40 POP3account *account;
40 mailpop3 *m_pop3; 41 mailpop3 *m_pop3;
41}; 42};
42 43
43#endif 44#endif
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 5065d29..46c854b 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -242,48 +242,52 @@ void POP3wrapper::login()
242 if ( err != MAILPOP3_NO_ERROR ) { 242 if ( err != MAILPOP3_NO_ERROR ) {
243 qDebug( "pop3: error connecting to %s\n reason: %s", server, 243 qDebug( "pop3: error connecting to %s\n reason: %s", server,
244 m_pop3->pop3_response ); 244 m_pop3->pop3_response );
245 mailpop3_free( m_pop3 ); 245 mailpop3_free( m_pop3 );
246 m_pop3 = NULL; 246 m_pop3 = NULL;
247 return; 247 return;
248 } 248 }
249 qDebug( "POP3: connected!" ); 249 qDebug( "POP3: connected!" );
250 250
251 // login 251 // login
252 // TODO: decide if apop or plain login should be used 252 // TODO: decide if apop or plain login should be used
253 err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); 253 err = mailpop3_login( m_pop3, (char *) user, (char *) pass );
254 if ( err != MAILPOP3_NO_ERROR ) { 254 if ( err != MAILPOP3_NO_ERROR ) {
255 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); 255 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response );
256 logout(); 256 logout();
257 return; 257 return;
258 } 258 }
259 259
260 qDebug( "POP3: logged in!" ); 260 qDebug( "POP3: logged in!" );
261} 261}
262 262
263void POP3wrapper::logout() 263void POP3wrapper::logout()
264{ 264{
265 int err = MAILPOP3_NO_ERROR; 265 int err = MAILPOP3_NO_ERROR;
266 if ( m_pop3 == NULL ) return; 266 if ( m_pop3 == NULL ) return;
267 err = mailpop3_quit( m_pop3 ); 267 err = mailpop3_quit( m_pop3 );
268 mailpop3_free( m_pop3 ); 268 mailpop3_free( m_pop3 );
269 m_pop3 = NULL; 269 m_pop3 = NULL;
270} 270}
271 271
272 272
273QList<Folder>* POP3wrapper::listFolders() 273QList<Folder>* POP3wrapper::listFolders()
274{ 274{
275 QList<Folder> * folders = new QList<Folder>(); 275 QList<Folder> * folders = new QList<Folder>();
276 folders->setAutoDelete( false ); 276 folders->setAutoDelete( false );
277 Folder*inb=new Folder("INBOX"); 277 Folder*inb=new Folder("INBOX");
278 folders->append(inb); 278 folders->append(inb);
279 return folders; 279 return folders;
280} 280}
281 281
282QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) 282QString POP3wrapper::fetchPart(const RecMail&,const RecPart&)
283{ 283{
284 return ""; 284 return "";
285} 285}
286 286
287void POP3wrapper::deleteMail(const RecMail&) 287void POP3wrapper::deleteMail(const RecMail&)
288{ 288{
289} 289}
290
291void POP3wrapper::answeredMail(const RecMail&)
292{
293}
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h
index ef972c8..6ff8d62 100644
--- a/noncore/net/mail/pop3wrapper.h
+++ b/noncore/net/mail/pop3wrapper.h
@@ -1,43 +1,44 @@
1#ifndef __POP3WRAPPER 1#ifndef __POP3WRAPPER
2#define __POP3WRAPPER 2#define __POP3WRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5#include "abstractmail.h" 5#include "abstractmail.h"
6 6
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9struct mailpop3; 9struct mailpop3;
10 10
11class POP3wrapper : public AbstractMail 11class POP3wrapper : public AbstractMail
12{ 12{
13 Q_OBJECT 13 Q_OBJECT
14 14
15public: 15public:
16 POP3wrapper( POP3account *a ); 16 POP3wrapper( POP3account *a );
17 virtual ~POP3wrapper(); 17 virtual ~POP3wrapper();
18 /* mailbox will be ignored */ 18 /* mailbox will be ignored */
19 virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); 19 virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
20 virtual QList<Folder>* listFolders(); 20 virtual QList<Folder>* listFolders();
21 virtual QString fetchPart(const RecMail&mail,const RecPart&part); 21 virtual QString fetchPart(const RecMail&mail,const RecPart&part);
22 virtual void deleteMail(const RecMail&mail); 22 virtual void deleteMail(const RecMail&mail);
23 virtual void answeredMail(const RecMail&mail);
23 24
24 RecBody fetchBody( const RecMail &mail ); 25 RecBody fetchBody( const RecMail &mail );
25 static void pop3_progress( size_t current, size_t maximum ); 26 static void pop3_progress( size_t current, size_t maximum );
26 27
27protected: 28protected:
28 void login(); 29 void login();
29 void logout(); 30 void logout();
30 31
31private: 32private:
32 RecMail *parseHeader( const char *header ); 33 RecMail *parseHeader( const char *header );
33 RecBody parseBody( const char *message ); 34 RecBody parseBody( const char *message );
34 QString parseMailboxList( mailimf_mailbox_list *list ); 35 QString parseMailboxList( mailimf_mailbox_list *list );
35 QString parseMailbox( mailimf_mailbox *box ); 36 QString parseMailbox( mailimf_mailbox *box );
36 QString parseGroup( mailimf_group *group ); 37 QString parseGroup( mailimf_group *group );
37 QString parseAddressList( mailimf_address_list *list ); 38 QString parseAddressList( mailimf_address_list *list );
38 QString parseDateTime( mailimf_date_time *date ); 39 QString parseDateTime( mailimf_date_time *date );
39 POP3account *account; 40 POP3account *account;
40 mailpop3 *m_pop3; 41 mailpop3 *m_pop3;
41}; 42};
42 43
43#endif 44#endif
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index e53f4a3..68d3c51 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -214,114 +214,117 @@ void ViewMail::setText()
214 214
215ViewMail::~ViewMail() 215ViewMail::~ViewMail()
216{ 216{
217 hide(); 217 hide();
218} 218}
219 219
220void ViewMail::hide() 220void ViewMail::hide()
221{ 221{
222 QWidget::hide(); 222 QWidget::hide();
223 223
224 if (_inLoop) { 224 if (_inLoop) {
225 _inLoop = false; 225 _inLoop = false;
226 qApp->exit_loop(); 226 qApp->exit_loop();
227 227
228 } 228 }
229 229
230} 230}
231 231
232void ViewMail::exec() 232void ViewMail::exec()
233{ 233{
234 show(); 234 show();
235 235
236 if (!_inLoop) { 236 if (!_inLoop) {
237 _inLoop = true; 237 _inLoop = true;
238 qApp->enter_loop(); 238 qApp->enter_loop();
239 } 239 }
240 240
241} 241}
242 242
243QString ViewMail::deHtml(const QString &string) 243QString ViewMail::deHtml(const QString &string)
244{ 244{
245 QString string_ = string; 245 QString string_ = string;
246 string_.replace(QRegExp("&"), "&amp;"); 246 string_.replace(QRegExp("&"), "&amp;");
247 string_.replace(QRegExp("<"), "&lt;"); 247 string_.replace(QRegExp("<"), "&lt;");
248 string_.replace(QRegExp(">"), "&gt;"); 248 string_.replace(QRegExp(">"), "&gt;");
249 string_.replace(QRegExp("\\n"), "<br>"); 249 string_.replace(QRegExp("\\n"), "<br>");
250 return string_; 250 return string_;
251} 251}
252 252
253void ViewMail::slotReply() 253void ViewMail::slotReply()
254{ 254{
255 if (!m_gotBody) { 255 if (!m_gotBody) {
256 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 256 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
257 return; 257 return;
258 } 258 }
259 259
260 QString rtext; 260 QString rtext;
261 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 261 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
262 .arg( m_mail[1] ) 262 .arg( m_mail[0] )
263 .arg( m_mail[3] ); 263 .arg( m_mail[3] );
264 264
265 QString text = m_mail[2]; 265 QString text = m_mail[2];
266 QStringList lines = QStringList::split(QRegExp("\\n"), text); 266 QStringList lines = QStringList::split(QRegExp("\\n"), text);
267 QStringList::Iterator it; 267 QStringList::Iterator it;
268 for (it = lines.begin(); it != lines.end(); it++) { 268 for (it = lines.begin(); it != lines.end(); it++) {
269 rtext += "> " + *it + "\n"; 269 rtext += "> " + *it + "\n";
270 } 270 }
271 rtext += "\n"; 271 rtext += "\n";
272 272
273 QString prefix; 273 QString prefix;
274 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; 274 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = "";
275 else prefix = "Re: "; // no i18n on purpose 275 else prefix = "Re: "; // no i18n on purpose
276 276
277 Settings *settings = new Settings(); 277 Settings *settings = new Settings();
278 ComposeMail composer( settings ,this, 0, true); 278 ComposeMail composer( settings ,this, 0, true);
279 composer.setTo( m_mail[0] ); 279 composer.setTo( m_mail[0] );
280 composer.setSubject( "Re: " + m_mail[1] ); 280 composer.setSubject( "Re: " + m_mail[1] );
281 composer.setMessage( rtext ); 281 composer.setMessage( rtext );
282 composer.showMaximized(); 282 composer.showMaximized();
283 composer.exec(); 283 if ( QDialog::Accepted==composer.exec()) {
284 284 m_recMail.Wrapper()->answeredMail(m_recMail);
285 }
285} 286}
286 287
287void ViewMail::slotForward() 288void ViewMail::slotForward()
288{ 289{
289 if (!m_gotBody) { 290 if (!m_gotBody) {
290 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); 291 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
291 return; 292 return;
292 } 293 }
293 294
294 QString ftext; 295 QString ftext;
295 ftext += QString("\n----- Forwarded message from %1 -----\n\n") 296 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
296 .arg( m_mail[0] ); 297 .arg( m_mail[0] );
297 if (!m_mail[3].isNull()) 298 if (!m_mail[3].isNull())
298 ftext += QString("Date: %1\n") 299 ftext += QString("Date: %1\n")
299 .arg( m_mail[3] ); 300 .arg( m_mail[3] );
300 if (!m_mail[0].isNull()) 301 if (!m_mail[0].isNull())
301 ftext += QString("From: %1\n") 302 ftext += QString("From: %1\n")
302 .arg( m_mail[0] ); 303 .arg( m_mail[0] );
303 if (!m_mail[1].isNull()) 304 if (!m_mail[1].isNull())
304 ftext += QString("Subject: %1\n") 305 ftext += QString("Subject: %1\n")
305 .arg( m_mail[1] ); 306 .arg( m_mail[1] );
306 307
307 ftext += QString("\n%1\n") 308 ftext += QString("\n%1\n")
308 .arg( m_mail[2]); 309 .arg( m_mail[2]);
309 310
310 ftext += QString("----- End forwarded message -----\n"); 311 ftext += QString("----- End forwarded message -----\n");
311 312
312 Settings *settings = new Settings(); 313 Settings *settings = new Settings();
313 ComposeMail composer( settings ,this, 0, true); 314 ComposeMail composer( settings ,this, 0, true);
314 composer.setSubject( "Fwd: " + m_mail[1] ); 315 composer.setSubject( "Fwd: " + m_mail[1] );
315 composer.setMessage( ftext ); 316 composer.setMessage( ftext );
316 composer.showMaximized(); 317 composer.showMaximized();
317 composer.exec(); 318 if ( QDialog::Accepted==composer.exec()) {
319
320 }
318} 321}
319 322
320void ViewMail::slotDeleteMail( ) 323void ViewMail::slotDeleteMail( )
321{ 324{
322 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { 325 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
323 m_recMail.Wrapper()->deleteMail( m_recMail ); 326 m_recMail.Wrapper()->deleteMail( m_recMail );
324 hide(); 327 hide();
325 deleted = true; 328 deleted = true;
326 } 329 }
327} 330}