author | alwin <alwin> | 2004-01-03 18:39:24 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-03 18:39:24 (UTC) |
commit | 8dd96feb25472a8c4f8e6b3f9b0553f83c6e3000 (patch) (unidiff) | |
tree | f4f6b9eee00e1b687bfb90bd58949319cf46ec88 | |
parent | 27b84ed363fd7fc52092e3c2d1e49dca079b7ffd (diff) | |
download | opie-8dd96feb25472a8c4f8e6b3f9b0553f83c6e3000.zip opie-8dd96feb25472a8c4f8e6b3f9b0553f83c6e3000.tar.gz opie-8dd96feb25472a8c4f8e6b3f9b0553f83c6e3000.tar.bz2 |
status methods for mailfolder implemented
-rw-r--r-- | noncore/net/mail/abstractmail.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/abstractmail.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 40 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/abstractmail.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 40 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.cpp | 21 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.h | 7 | ||||
-rw-r--r-- | noncore/net/mail/mboxwrapper.cpp | 21 | ||||
-rw-r--r-- | noncore/net/mail/mboxwrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 11 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.h | 2 |
18 files changed, 180 insertions, 2 deletions
diff --git a/noncore/net/mail/abstractmail.cpp b/noncore/net/mail/abstractmail.cpp index 416795b..f303d72 100644 --- a/noncore/net/mail/abstractmail.cpp +++ b/noncore/net/mail/abstractmail.cpp | |||
@@ -1,90 +1,94 @@ | |||
1 | #include "abstractmail.h" | 1 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "mboxwrapper.h" | 4 | #include "mboxwrapper.h" |
5 | #include "mailtypes.h" | 5 | #include "mailtypes.h" |
6 | 6 | ||
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <libetpan/mailmime_content.h> | 11 | #include <libetpan/mailmime_content.h> |
12 | #include <libetpan/mailmime.h> | 12 | #include <libetpan/mailmime.h> |
13 | 13 | ||
14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
15 | { | 15 | { |
16 | return new IMAPwrapper(a); | 16 | return new IMAPwrapper(a); |
17 | } | 17 | } |
18 | 18 | ||
19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
20 | { | 20 | { |
21 | return new POP3wrapper(a); | 21 | return new POP3wrapper(a); |
22 | } | 22 | } |
23 | 23 | ||
24 | AbstractMail* AbstractMail::getWrapper(const QString&a) | 24 | AbstractMail* AbstractMail::getWrapper(const QString&a) |
25 | { | 25 | { |
26 | return new MBOXwrapper(a); | 26 | return new MBOXwrapper(a); |
27 | } | 27 | } |
28 | 28 | ||
29 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 29 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
30 | { | 30 | { |
31 | qDebug("Decode string start"); | 31 | qDebug("Decode string start"); |
32 | char*result_text; | 32 | char*result_text; |
33 | size_t index = 0; | 33 | size_t index = 0; |
34 | /* reset for recursive use! */ | 34 | /* reset for recursive use! */ |
35 | size_t target_length = 0; | 35 | size_t target_length = 0; |
36 | result_text = 0; | 36 | result_text = 0; |
37 | int mimetype = MAILMIME_MECHANISM_7BIT; | 37 | int mimetype = MAILMIME_MECHANISM_7BIT; |
38 | if (enc.lower()=="quoted-printable") { | 38 | if (enc.lower()=="quoted-printable") { |
39 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 39 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
40 | } else if (enc.lower()=="base64") { | 40 | } else if (enc.lower()=="base64") { |
41 | mimetype = MAILMIME_MECHANISM_BASE64; | 41 | mimetype = MAILMIME_MECHANISM_BASE64; |
42 | } else if (enc.lower()=="8bit") { | 42 | } else if (enc.lower()=="8bit") { |
43 | mimetype = MAILMIME_MECHANISM_8BIT; | 43 | mimetype = MAILMIME_MECHANISM_8BIT; |
44 | } else if (enc.lower()=="binary") { | 44 | } else if (enc.lower()=="binary") { |
45 | mimetype = MAILMIME_MECHANISM_BINARY; | 45 | mimetype = MAILMIME_MECHANISM_BINARY; |
46 | } | 46 | } |
47 | 47 | ||
48 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 48 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
49 | &result_text,&target_length); | 49 | &result_text,&target_length); |
50 | 50 | ||
51 | encodedString* result = new encodedString(); | 51 | encodedString* result = new encodedString(); |
52 | if (err == MAILIMF_NO_ERROR) { | 52 | if (err == MAILIMF_NO_ERROR) { |
53 | result->setContent(result_text,target_length); | 53 | result->setContent(result_text,target_length); |
54 | } | 54 | } |
55 | qDebug("Decode string finished"); | 55 | qDebug("Decode string finished"); |
56 | return result; | 56 | return result; |
57 | } | 57 | } |
58 | 58 | ||
59 | QString AbstractMail::convert_String(const char*text) | 59 | QString AbstractMail::convert_String(const char*text) |
60 | { | 60 | { |
61 | size_t index = 0; | 61 | size_t index = 0; |
62 | char*res = 0; | 62 | char*res = 0; |
63 | 63 | ||
64 | /* attention - doesn't work with arm systems! */ | 64 | /* attention - doesn't work with arm systems! */ |
65 | int err = mailmime_encoded_phrase_parse("iso-8859-1", | 65 | int err = mailmime_encoded_phrase_parse("iso-8859-1", |
66 | text, strlen(text),&index, "iso-8859-1",&res); | 66 | text, strlen(text),&index, "iso-8859-1",&res); |
67 | if (err != MAILIMF_NO_ERROR) { | 67 | if (err != MAILIMF_NO_ERROR) { |
68 | if (res) free(res); | 68 | if (res) free(res); |
69 | return QString(text); | 69 | return QString(text); |
70 | } | 70 | } |
71 | if (res) { | 71 | if (res) { |
72 | QString result(res); | 72 | QString result(res); |
73 | free(res); | 73 | free(res); |
74 | return result; | 74 | return result; |
75 | } | 75 | } |
76 | return QString(text); | 76 | return QString(text); |
77 | } | 77 | } |
78 | 78 | ||
79 | /* cp & paste from launcher */ | 79 | /* cp & paste from launcher */ |
80 | QString AbstractMail::gen_attachment_id() | 80 | QString AbstractMail::gen_attachment_id() |
81 | { | 81 | { |
82 | QFile file( "/proc/sys/kernel/random/uuid" ); | 82 | QFile file( "/proc/sys/kernel/random/uuid" ); |
83 | if (!file.open(IO_ReadOnly ) ) | 83 | if (!file.open(IO_ReadOnly ) ) |
84 | return QString::null; | 84 | return QString::null; |
85 | 85 | ||
86 | QTextStream stream(&file); | 86 | QTextStream stream(&file); |
87 | 87 | ||
88 | return "{" + stream.read().stripWhiteSpace() + "}"; | 88 | return "{" + stream.read().stripWhiteSpace() + "}"; |
89 | } | 89 | } |
90 | 90 | ||
91 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) | ||
92 | { | ||
93 | return 0; | ||
94 | } | ||
diff --git a/noncore/net/mail/abstractmail.h b/noncore/net/mail/abstractmail.h index 5dc4cab..dab9e10 100644 --- a/noncore/net/mail/abstractmail.h +++ b/noncore/net/mail/abstractmail.h | |||
@@ -1,51 +1,53 @@ | |||
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 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | class RecPart; | 9 | class RecPart; |
10 | class IMAPwrapper; | 10 | class IMAPwrapper; |
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class Folder; | 12 | class Folder; |
13 | class encodedString; | 13 | class encodedString; |
14 | struct folderStat; | ||
14 | 15 | ||
15 | class AbstractMail:public QObject | 16 | class AbstractMail:public QObject |
16 | { | 17 | { |
17 | Q_OBJECT | 18 | Q_OBJECT |
18 | public: | 19 | public: |
19 | AbstractMail(){}; | 20 | AbstractMail(){}; |
20 | virtual ~AbstractMail(){} | 21 | virtual ~AbstractMail(){} |
21 | virtual QList<Folder>* listFolders()=0; | 22 | virtual QList<Folder>* listFolders()=0; |
22 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 23 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | ||
23 | virtual RecBody fetchBody(const RecMail&mail)=0; | 25 | virtual RecBody fetchBody(const RecMail&mail)=0; |
24 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; | 26 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
25 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | 27 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; |
26 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | 28 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; |
27 | 29 | ||
28 | virtual void deleteMail(const RecMail&mail)=0; | 30 | virtual void deleteMail(const RecMail&mail)=0; |
29 | virtual void answeredMail(const RecMail&mail)=0; | 31 | virtual void answeredMail(const RecMail&mail)=0; |
30 | virtual void cleanMimeCache(){}; | 32 | virtual void cleanMimeCache(){}; |
31 | virtual int deleteAllMail(const Folder*){return 1;} | 33 | virtual int deleteAllMail(const Folder*){return 1;} |
32 | virtual int deleteMbox(const Folder*){return 1;} | 34 | virtual int deleteMbox(const Folder*){return 1;} |
33 | 35 | ||
34 | /* mail box methods */ | 36 | /* mail box methods */ |
35 | /* parameter is the box to create. | 37 | /* parameter is the box to create. |
36 | * if the implementing subclass has prefixes, | 38 | * if the implementing subclass has prefixes, |
37 | * them has to be appended automatic. | 39 | * them has to be appended automatic. |
38 | */ | 40 | */ |
39 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false){return 0;} | 41 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
40 | 42 | ||
41 | static AbstractMail* getWrapper(IMAPaccount *a); | 43 | static AbstractMail* getWrapper(IMAPaccount *a); |
42 | static AbstractMail* getWrapper(POP3account *a); | 44 | static AbstractMail* getWrapper(POP3account *a); |
43 | /* mbox only! */ | 45 | /* mbox only! */ |
44 | static AbstractMail* getWrapper(const QString&a); | 46 | static AbstractMail* getWrapper(const QString&a); |
45 | 47 | ||
46 | protected: | 48 | protected: |
47 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 49 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
48 | static QString convert_String(const char*text); | 50 | static QString convert_String(const char*text); |
49 | static QString gen_attachment_id(); | 51 | static QString gen_attachment_id(); |
50 | }; | 52 | }; |
51 | #endif | 53 | #endif |
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index b437df0..f1d42c2 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -841,96 +841,136 @@ QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | |||
841 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) | 841 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) |
842 | { | 842 | { |
843 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); | 843 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); |
844 | encodedString*r = decode_String(res,part.Encoding()); | 844 | encodedString*r = decode_String(res,part.Encoding()); |
845 | delete res; | 845 | delete res; |
846 | return r; | 846 | return r; |
847 | } | 847 | } |
848 | 848 | ||
849 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | 849 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) |
850 | { | 850 | { |
851 | return fetchRawPart(mail,part.Positionlist(),false); | 851 | return fetchRawPart(mail,part.Positionlist(),false); |
852 | } | 852 | } |
853 | 853 | ||
854 | int IMAPwrapper::deleteAllMail(const Folder*folder) | 854 | int IMAPwrapper::deleteAllMail(const Folder*folder) |
855 | { | 855 | { |
856 | login(); | 856 | login(); |
857 | if (!m_imap) { | 857 | if (!m_imap) { |
858 | return 0; | 858 | return 0; |
859 | } | 859 | } |
860 | mailimap_flag_list*flist; | 860 | mailimap_flag_list*flist; |
861 | mailimap_set *set; | 861 | mailimap_set *set; |
862 | mailimap_store_att_flags * store_flags; | 862 | mailimap_store_att_flags * store_flags; |
863 | int err = mailimap_select( m_imap, folder->getName().latin1()); | 863 | int err = mailimap_select( m_imap, folder->getName().latin1()); |
864 | if ( err != MAILIMAP_NO_ERROR ) { | 864 | if ( err != MAILIMAP_NO_ERROR ) { |
865 | Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response)); | 865 | Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response)); |
866 | return 0; | 866 | return 0; |
867 | } | 867 | } |
868 | int last = m_imap->imap_selection_info->sel_exists; | 868 | int last = m_imap->imap_selection_info->sel_exists; |
869 | if (last == 0) { | 869 | if (last == 0) { |
870 | Global::statusMessage(tr("Mailbox has no mails!")); | 870 | Global::statusMessage(tr("Mailbox has no mails!")); |
871 | return 0; | 871 | return 0; |
872 | } | 872 | } |
873 | flist = mailimap_flag_list_new_empty(); | 873 | flist = mailimap_flag_list_new_empty(); |
874 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 874 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
875 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 875 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
876 | set = mailimap_set_new_interval( 1, last ); | 876 | set = mailimap_set_new_interval( 1, last ); |
877 | err = mailimap_store(m_imap,set,store_flags); | 877 | err = mailimap_store(m_imap,set,store_flags); |
878 | mailimap_set_free( set ); | 878 | mailimap_set_free( set ); |
879 | mailimap_store_att_flags_free(store_flags); | 879 | mailimap_store_att_flags_free(store_flags); |
880 | if (err != MAILIMAP_NO_ERROR) { | 880 | if (err != MAILIMAP_NO_ERROR) { |
881 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 881 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
882 | return 0; | 882 | return 0; |
883 | } | 883 | } |
884 | qDebug("deleting mail: %s",m_imap->imap_response); | 884 | qDebug("deleting mail: %s",m_imap->imap_response); |
885 | /* should we realy do that at this moment? */ | 885 | /* should we realy do that at this moment? */ |
886 | err = mailimap_expunge(m_imap); | 886 | err = mailimap_expunge(m_imap); |
887 | if (err != MAILIMAP_NO_ERROR) { | 887 | if (err != MAILIMAP_NO_ERROR) { |
888 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 888 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
889 | return 0; | 889 | return 0; |
890 | } | 890 | } |
891 | qDebug("Delete successfull %s",m_imap->imap_response); | 891 | qDebug("Delete successfull %s",m_imap->imap_response); |
892 | return 1; | 892 | return 1; |
893 | } | 893 | } |
894 | 894 | ||
895 | int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) | 895 | int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) |
896 | { | 896 | { |
897 | if (folder.length()==0) return 0; | 897 | if (folder.length()==0) return 0; |
898 | login(); | 898 | login(); |
899 | if (!m_imap) {return 0;} | 899 | if (!m_imap) {return 0;} |
900 | QString pre = account->getPrefix(); | 900 | QString pre = account->getPrefix(); |
901 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 901 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { |
902 | pre+=delemiter; | 902 | pre+=delemiter; |
903 | } | 903 | } |
904 | if (parentfolder) { | 904 | if (parentfolder) { |
905 | pre += parentfolder->getDisplayName()+delemiter; | 905 | pre += parentfolder->getDisplayName()+delemiter; |
906 | } | 906 | } |
907 | pre+=folder; | 907 | pre+=folder; |
908 | if (getsubfolder) { | 908 | if (getsubfolder) { |
909 | if (delemiter.length()>0) { | 909 | if (delemiter.length()>0) { |
910 | pre+=delemiter; | 910 | pre+=delemiter; |
911 | } else { | 911 | } else { |
912 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); | 912 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); |
913 | return 0; | 913 | return 0; |
914 | } | 914 | } |
915 | } | 915 | } |
916 | qDebug("Creating %s",pre.latin1()); | 916 | qDebug("Creating %s",pre.latin1()); |
917 | int res = mailimap_create(m_imap,pre.latin1()); | 917 | int res = mailimap_create(m_imap,pre.latin1()); |
918 | if (res != MAILIMAP_NO_ERROR) { | 918 | if (res != MAILIMAP_NO_ERROR) { |
919 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 919 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
920 | return 0; | 920 | return 0; |
921 | } | 921 | } |
922 | return 1; | 922 | return 1; |
923 | } | 923 | } |
924 | 924 | ||
925 | int IMAPwrapper::deleteMbox(const Folder*folder) | 925 | int IMAPwrapper::deleteMbox(const Folder*folder) |
926 | { | 926 | { |
927 | if (!folder) return 0; | 927 | if (!folder) return 0; |
928 | login(); | 928 | login(); |
929 | if (!m_imap) {return 0;} | 929 | if (!m_imap) {return 0;} |
930 | int res = mailimap_delete(m_imap,folder->getName()); | 930 | int res = mailimap_delete(m_imap,folder->getName()); |
931 | if (res != MAILIMAP_NO_ERROR) { | 931 | if (res != MAILIMAP_NO_ERROR) { |
932 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 932 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
933 | return 0; | 933 | return 0; |
934 | } | 934 | } |
935 | return 1; | 935 | return 1; |
936 | } | 936 | } |
937 | |||
938 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | ||
939 | { | ||
940 | mailimap_status_att_list * att_list =0; | ||
941 | mailimap_mailbox_data_status * status=0; | ||
942 | clistiter * cur = 0; | ||
943 | int r = 0; | ||
944 | int res = 0; | ||
945 | target_stat.message_count = 0; | ||
946 | target_stat.message_unseen = 0; | ||
947 | target_stat.message_recent = 0; | ||
948 | login(); | ||
949 | if (!m_imap) { | ||
950 | return; | ||
951 | } | ||
952 | att_list = mailimap_status_att_list_new_empty(); | ||
953 | if (!att_list) return; | ||
954 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | ||
955 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | ||
956 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | ||
957 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | ||
958 | for (cur = clist_begin(status->st_info_list); | ||
959 | cur != NULL ; cur = clist_next(cur)) { | ||
960 | mailimap_status_info * status_info; | ||
961 | status_info = (mailimap_status_info *)clist_content(cur); | ||
962 | switch (status_info->st_att) { | ||
963 | case MAILIMAP_STATUS_ATT_MESSAGES: | ||
964 | target_stat.message_count = status_info->st_value; | ||
965 | break; | ||
966 | case MAILIMAP_STATUS_ATT_RECENT: | ||
967 | target_stat.message_recent = status_info->st_value; | ||
968 | break; | ||
969 | case MAILIMAP_STATUS_ATT_UNSEEN: | ||
970 | target_stat.message_unseen = status_info->st_value; | ||
971 | break; | ||
972 | } | ||
973 | } | ||
974 | mailimap_mailbox_data_status_free(status); | ||
975 | mailimap_status_att_list_free(att_list); | ||
976 | } | ||
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h index 7941046..8f5a2b5 100644 --- a/noncore/net/mail/imapwrapper.h +++ b/noncore/net/mail/imapwrapper.h | |||
@@ -1,67 +1,68 @@ | |||
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 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | struct mailimap; | 9 | struct mailimap; |
10 | struct mailimap_body; | 10 | struct mailimap_body; |
11 | struct mailimap_body_type_1part; | 11 | struct mailimap_body_type_1part; |
12 | struct mailimap_body_type_text; | 12 | struct mailimap_body_type_text; |
13 | struct mailimap_body_type_basic; | 13 | struct mailimap_body_type_basic; |
14 | struct mailimap_body_type_msg; | 14 | struct mailimap_body_type_msg; |
15 | struct mailimap_body_type_mpart; | 15 | struct mailimap_body_type_mpart; |
16 | struct mailimap_body_fields; | 16 | struct mailimap_body_fields; |
17 | struct mailimap_msg_att; | 17 | struct mailimap_msg_att; |
18 | class encodedString; | 18 | class encodedString; |
19 | 19 | ||
20 | class IMAPwrapper : public AbstractMail | 20 | class IMAPwrapper : public AbstractMail |
21 | { | 21 | { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
24 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
25 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
26 | virtual QList<Folder>* listFolders(); | 26 | virtual QList<Folder>* listFolders(); |
27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | ||
28 | 29 | ||
29 | virtual void deleteMail(const RecMail&mail); | 30 | virtual void deleteMail(const RecMail&mail); |
30 | virtual void answeredMail(const RecMail&mail); | 31 | virtual void answeredMail(const RecMail&mail); |
31 | virtual int deleteAllMail(const Folder*folder); | 32 | virtual int deleteAllMail(const Folder*folder); |
32 | 33 | ||
33 | virtual RecBody fetchBody(const RecMail&mail); | 34 | virtual RecBody fetchBody(const RecMail&mail); |
34 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 35 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
35 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 36 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
36 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 37 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
37 | 38 | ||
38 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 39 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
39 | virtual int deleteMbox(const Folder*folder); | 40 | virtual int deleteMbox(const Folder*folder); |
40 | 41 | ||
41 | static void imap_progress( size_t current, size_t maximum ); | 42 | static void imap_progress( size_t current, size_t maximum ); |
42 | 43 | ||
43 | protected: | 44 | protected: |
44 | RecMail*parse_list_result(mailimap_msg_att*); | 45 | RecMail*parse_list_result(mailimap_msg_att*); |
45 | void login(); | 46 | void login(); |
46 | void logout(); | 47 | void logout(); |
47 | 48 | ||
48 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 49 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
49 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | 50 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); |
50 | 51 | ||
51 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 52 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
52 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 53 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
53 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 54 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
54 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 55 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
55 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); | 56 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
56 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 57 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
57 | 58 | ||
58 | /* just helpers */ | 59 | /* just helpers */ |
59 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 60 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
60 | static QStringList address_list_to_stringlist(clist*list); | 61 | static QStringList address_list_to_stringlist(clist*list); |
61 | 62 | ||
62 | 63 | ||
63 | IMAPaccount *account; | 64 | IMAPaccount *account; |
64 | mailimap *m_imap; | 65 | mailimap *m_imap; |
65 | }; | 66 | }; |
66 | 67 | ||
67 | #endif | 68 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 416795b..f303d72 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -1,90 +1,94 @@ | |||
1 | #include "abstractmail.h" | 1 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "mboxwrapper.h" | 4 | #include "mboxwrapper.h" |
5 | #include "mailtypes.h" | 5 | #include "mailtypes.h" |
6 | 6 | ||
7 | #include <qstring.h> | 7 | #include <qstring.h> |
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <libetpan/mailmime_content.h> | 11 | #include <libetpan/mailmime_content.h> |
12 | #include <libetpan/mailmime.h> | 12 | #include <libetpan/mailmime.h> |
13 | 13 | ||
14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
15 | { | 15 | { |
16 | return new IMAPwrapper(a); | 16 | return new IMAPwrapper(a); |
17 | } | 17 | } |
18 | 18 | ||
19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
20 | { | 20 | { |
21 | return new POP3wrapper(a); | 21 | return new POP3wrapper(a); |
22 | } | 22 | } |
23 | 23 | ||
24 | AbstractMail* AbstractMail::getWrapper(const QString&a) | 24 | AbstractMail* AbstractMail::getWrapper(const QString&a) |
25 | { | 25 | { |
26 | return new MBOXwrapper(a); | 26 | return new MBOXwrapper(a); |
27 | } | 27 | } |
28 | 28 | ||
29 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 29 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
30 | { | 30 | { |
31 | qDebug("Decode string start"); | 31 | qDebug("Decode string start"); |
32 | char*result_text; | 32 | char*result_text; |
33 | size_t index = 0; | 33 | size_t index = 0; |
34 | /* reset for recursive use! */ | 34 | /* reset for recursive use! */ |
35 | size_t target_length = 0; | 35 | size_t target_length = 0; |
36 | result_text = 0; | 36 | result_text = 0; |
37 | int mimetype = MAILMIME_MECHANISM_7BIT; | 37 | int mimetype = MAILMIME_MECHANISM_7BIT; |
38 | if (enc.lower()=="quoted-printable") { | 38 | if (enc.lower()=="quoted-printable") { |
39 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 39 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
40 | } else if (enc.lower()=="base64") { | 40 | } else if (enc.lower()=="base64") { |
41 | mimetype = MAILMIME_MECHANISM_BASE64; | 41 | mimetype = MAILMIME_MECHANISM_BASE64; |
42 | } else if (enc.lower()=="8bit") { | 42 | } else if (enc.lower()=="8bit") { |
43 | mimetype = MAILMIME_MECHANISM_8BIT; | 43 | mimetype = MAILMIME_MECHANISM_8BIT; |
44 | } else if (enc.lower()=="binary") { | 44 | } else if (enc.lower()=="binary") { |
45 | mimetype = MAILMIME_MECHANISM_BINARY; | 45 | mimetype = MAILMIME_MECHANISM_BINARY; |
46 | } | 46 | } |
47 | 47 | ||
48 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 48 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
49 | &result_text,&target_length); | 49 | &result_text,&target_length); |
50 | 50 | ||
51 | encodedString* result = new encodedString(); | 51 | encodedString* result = new encodedString(); |
52 | if (err == MAILIMF_NO_ERROR) { | 52 | if (err == MAILIMF_NO_ERROR) { |
53 | result->setContent(result_text,target_length); | 53 | result->setContent(result_text,target_length); |
54 | } | 54 | } |
55 | qDebug("Decode string finished"); | 55 | qDebug("Decode string finished"); |
56 | return result; | 56 | return result; |
57 | } | 57 | } |
58 | 58 | ||
59 | QString AbstractMail::convert_String(const char*text) | 59 | QString AbstractMail::convert_String(const char*text) |
60 | { | 60 | { |
61 | size_t index = 0; | 61 | size_t index = 0; |
62 | char*res = 0; | 62 | char*res = 0; |
63 | 63 | ||
64 | /* attention - doesn't work with arm systems! */ | 64 | /* attention - doesn't work with arm systems! */ |
65 | int err = mailmime_encoded_phrase_parse("iso-8859-1", | 65 | int err = mailmime_encoded_phrase_parse("iso-8859-1", |
66 | text, strlen(text),&index, "iso-8859-1",&res); | 66 | text, strlen(text),&index, "iso-8859-1",&res); |
67 | if (err != MAILIMF_NO_ERROR) { | 67 | if (err != MAILIMF_NO_ERROR) { |
68 | if (res) free(res); | 68 | if (res) free(res); |
69 | return QString(text); | 69 | return QString(text); |
70 | } | 70 | } |
71 | if (res) { | 71 | if (res) { |
72 | QString result(res); | 72 | QString result(res); |
73 | free(res); | 73 | free(res); |
74 | return result; | 74 | return result; |
75 | } | 75 | } |
76 | return QString(text); | 76 | return QString(text); |
77 | } | 77 | } |
78 | 78 | ||
79 | /* cp & paste from launcher */ | 79 | /* cp & paste from launcher */ |
80 | QString AbstractMail::gen_attachment_id() | 80 | QString AbstractMail::gen_attachment_id() |
81 | { | 81 | { |
82 | QFile file( "/proc/sys/kernel/random/uuid" ); | 82 | QFile file( "/proc/sys/kernel/random/uuid" ); |
83 | if (!file.open(IO_ReadOnly ) ) | 83 | if (!file.open(IO_ReadOnly ) ) |
84 | return QString::null; | 84 | return QString::null; |
85 | 85 | ||
86 | QTextStream stream(&file); | 86 | QTextStream stream(&file); |
87 | 87 | ||
88 | return "{" + stream.read().stripWhiteSpace() + "}"; | 88 | return "{" + stream.read().stripWhiteSpace() + "}"; |
89 | } | 89 | } |
90 | 90 | ||
91 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) | ||
92 | { | ||
93 | return 0; | ||
94 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h index 5dc4cab..dab9e10 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.h +++ b/noncore/net/mail/libmailwrapper/abstractmail.h | |||
@@ -1,51 +1,53 @@ | |||
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 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | class RecPart; | 9 | class RecPart; |
10 | class IMAPwrapper; | 10 | class IMAPwrapper; |
11 | class POP3wrapper; | 11 | class POP3wrapper; |
12 | class Folder; | 12 | class Folder; |
13 | class encodedString; | 13 | class encodedString; |
14 | struct folderStat; | ||
14 | 15 | ||
15 | class AbstractMail:public QObject | 16 | class AbstractMail:public QObject |
16 | { | 17 | { |
17 | Q_OBJECT | 18 | Q_OBJECT |
18 | public: | 19 | public: |
19 | AbstractMail(){}; | 20 | AbstractMail(){}; |
20 | virtual ~AbstractMail(){} | 21 | virtual ~AbstractMail(){} |
21 | virtual QList<Folder>* listFolders()=0; | 22 | virtual QList<Folder>* listFolders()=0; |
22 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; | 23 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0; |
24 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; | ||
23 | virtual RecBody fetchBody(const RecMail&mail)=0; | 25 | virtual RecBody fetchBody(const RecMail&mail)=0; |
24 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; | 26 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; |
25 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; | 27 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; |
26 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; | 28 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; |
27 | 29 | ||
28 | virtual void deleteMail(const RecMail&mail)=0; | 30 | virtual void deleteMail(const RecMail&mail)=0; |
29 | virtual void answeredMail(const RecMail&mail)=0; | 31 | virtual void answeredMail(const RecMail&mail)=0; |
30 | virtual void cleanMimeCache(){}; | 32 | virtual void cleanMimeCache(){}; |
31 | virtual int deleteAllMail(const Folder*){return 1;} | 33 | virtual int deleteAllMail(const Folder*){return 1;} |
32 | virtual int deleteMbox(const Folder*){return 1;} | 34 | virtual int deleteMbox(const Folder*){return 1;} |
33 | 35 | ||
34 | /* mail box methods */ | 36 | /* mail box methods */ |
35 | /* parameter is the box to create. | 37 | /* parameter is the box to create. |
36 | * if the implementing subclass has prefixes, | 38 | * if the implementing subclass has prefixes, |
37 | * them has to be appended automatic. | 39 | * them has to be appended automatic. |
38 | */ | 40 | */ |
39 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false){return 0;} | 41 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
40 | 42 | ||
41 | static AbstractMail* getWrapper(IMAPaccount *a); | 43 | static AbstractMail* getWrapper(IMAPaccount *a); |
42 | static AbstractMail* getWrapper(POP3account *a); | 44 | static AbstractMail* getWrapper(POP3account *a); |
43 | /* mbox only! */ | 45 | /* mbox only! */ |
44 | static AbstractMail* getWrapper(const QString&a); | 46 | static AbstractMail* getWrapper(const QString&a); |
45 | 47 | ||
46 | protected: | 48 | protected: |
47 | static encodedString*decode_String(const encodedString*text,const QString&enc); | 49 | static encodedString*decode_String(const encodedString*text,const QString&enc); |
48 | static QString convert_String(const char*text); | 50 | static QString convert_String(const char*text); |
49 | static QString gen_attachment_id(); | 51 | static QString gen_attachment_id(); |
50 | }; | 52 | }; |
51 | #endif | 53 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index b437df0..f1d42c2 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -841,96 +841,136 @@ QString IMAPwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | |||
841 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) | 841 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMail&mail,const RecPart&part) |
842 | { | 842 | { |
843 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); | 843 | encodedString*res = fetchRawPart(mail,part.Positionlist(),false); |
844 | encodedString*r = decode_String(res,part.Encoding()); | 844 | encodedString*r = decode_String(res,part.Encoding()); |
845 | delete res; | 845 | delete res; |
846 | return r; | 846 | return r; |
847 | } | 847 | } |
848 | 848 | ||
849 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | 849 | encodedString* IMAPwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) |
850 | { | 850 | { |
851 | return fetchRawPart(mail,part.Positionlist(),false); | 851 | return fetchRawPart(mail,part.Positionlist(),false); |
852 | } | 852 | } |
853 | 853 | ||
854 | int IMAPwrapper::deleteAllMail(const Folder*folder) | 854 | int IMAPwrapper::deleteAllMail(const Folder*folder) |
855 | { | 855 | { |
856 | login(); | 856 | login(); |
857 | if (!m_imap) { | 857 | if (!m_imap) { |
858 | return 0; | 858 | return 0; |
859 | } | 859 | } |
860 | mailimap_flag_list*flist; | 860 | mailimap_flag_list*flist; |
861 | mailimap_set *set; | 861 | mailimap_set *set; |
862 | mailimap_store_att_flags * store_flags; | 862 | mailimap_store_att_flags * store_flags; |
863 | int err = mailimap_select( m_imap, folder->getName().latin1()); | 863 | int err = mailimap_select( m_imap, folder->getName().latin1()); |
864 | if ( err != MAILIMAP_NO_ERROR ) { | 864 | if ( err != MAILIMAP_NO_ERROR ) { |
865 | Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response)); | 865 | Global::statusMessage(tr("error selecting mailbox: %1").arg(m_imap->imap_response)); |
866 | return 0; | 866 | return 0; |
867 | } | 867 | } |
868 | int last = m_imap->imap_selection_info->sel_exists; | 868 | int last = m_imap->imap_selection_info->sel_exists; |
869 | if (last == 0) { | 869 | if (last == 0) { |
870 | Global::statusMessage(tr("Mailbox has no mails!")); | 870 | Global::statusMessage(tr("Mailbox has no mails!")); |
871 | return 0; | 871 | return 0; |
872 | } | 872 | } |
873 | flist = mailimap_flag_list_new_empty(); | 873 | flist = mailimap_flag_list_new_empty(); |
874 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 874 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
875 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 875 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
876 | set = mailimap_set_new_interval( 1, last ); | 876 | set = mailimap_set_new_interval( 1, last ); |
877 | err = mailimap_store(m_imap,set,store_flags); | 877 | err = mailimap_store(m_imap,set,store_flags); |
878 | mailimap_set_free( set ); | 878 | mailimap_set_free( set ); |
879 | mailimap_store_att_flags_free(store_flags); | 879 | mailimap_store_att_flags_free(store_flags); |
880 | if (err != MAILIMAP_NO_ERROR) { | 880 | if (err != MAILIMAP_NO_ERROR) { |
881 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 881 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
882 | return 0; | 882 | return 0; |
883 | } | 883 | } |
884 | qDebug("deleting mail: %s",m_imap->imap_response); | 884 | qDebug("deleting mail: %s",m_imap->imap_response); |
885 | /* should we realy do that at this moment? */ | 885 | /* should we realy do that at this moment? */ |
886 | err = mailimap_expunge(m_imap); | 886 | err = mailimap_expunge(m_imap); |
887 | if (err != MAILIMAP_NO_ERROR) { | 887 | if (err != MAILIMAP_NO_ERROR) { |
888 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 888 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
889 | return 0; | 889 | return 0; |
890 | } | 890 | } |
891 | qDebug("Delete successfull %s",m_imap->imap_response); | 891 | qDebug("Delete successfull %s",m_imap->imap_response); |
892 | return 1; | 892 | return 1; |
893 | } | 893 | } |
894 | 894 | ||
895 | int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) | 895 | int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) |
896 | { | 896 | { |
897 | if (folder.length()==0) return 0; | 897 | if (folder.length()==0) return 0; |
898 | login(); | 898 | login(); |
899 | if (!m_imap) {return 0;} | 899 | if (!m_imap) {return 0;} |
900 | QString pre = account->getPrefix(); | 900 | QString pre = account->getPrefix(); |
901 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 901 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { |
902 | pre+=delemiter; | 902 | pre+=delemiter; |
903 | } | 903 | } |
904 | if (parentfolder) { | 904 | if (parentfolder) { |
905 | pre += parentfolder->getDisplayName()+delemiter; | 905 | pre += parentfolder->getDisplayName()+delemiter; |
906 | } | 906 | } |
907 | pre+=folder; | 907 | pre+=folder; |
908 | if (getsubfolder) { | 908 | if (getsubfolder) { |
909 | if (delemiter.length()>0) { | 909 | if (delemiter.length()>0) { |
910 | pre+=delemiter; | 910 | pre+=delemiter; |
911 | } else { | 911 | } else { |
912 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); | 912 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); |
913 | return 0; | 913 | return 0; |
914 | } | 914 | } |
915 | } | 915 | } |
916 | qDebug("Creating %s",pre.latin1()); | 916 | qDebug("Creating %s",pre.latin1()); |
917 | int res = mailimap_create(m_imap,pre.latin1()); | 917 | int res = mailimap_create(m_imap,pre.latin1()); |
918 | if (res != MAILIMAP_NO_ERROR) { | 918 | if (res != MAILIMAP_NO_ERROR) { |
919 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 919 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
920 | return 0; | 920 | return 0; |
921 | } | 921 | } |
922 | return 1; | 922 | return 1; |
923 | } | 923 | } |
924 | 924 | ||
925 | int IMAPwrapper::deleteMbox(const Folder*folder) | 925 | int IMAPwrapper::deleteMbox(const Folder*folder) |
926 | { | 926 | { |
927 | if (!folder) return 0; | 927 | if (!folder) return 0; |
928 | login(); | 928 | login(); |
929 | if (!m_imap) {return 0;} | 929 | if (!m_imap) {return 0;} |
930 | int res = mailimap_delete(m_imap,folder->getName()); | 930 | int res = mailimap_delete(m_imap,folder->getName()); |
931 | if (res != MAILIMAP_NO_ERROR) { | 931 | if (res != MAILIMAP_NO_ERROR) { |
932 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 932 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
933 | return 0; | 933 | return 0; |
934 | } | 934 | } |
935 | return 1; | 935 | return 1; |
936 | } | 936 | } |
937 | |||
938 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | ||
939 | { | ||
940 | mailimap_status_att_list * att_list =0; | ||
941 | mailimap_mailbox_data_status * status=0; | ||
942 | clistiter * cur = 0; | ||
943 | int r = 0; | ||
944 | int res = 0; | ||
945 | target_stat.message_count = 0; | ||
946 | target_stat.message_unseen = 0; | ||
947 | target_stat.message_recent = 0; | ||
948 | login(); | ||
949 | if (!m_imap) { | ||
950 | return; | ||
951 | } | ||
952 | att_list = mailimap_status_att_list_new_empty(); | ||
953 | if (!att_list) return; | ||
954 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | ||
955 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | ||
956 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | ||
957 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | ||
958 | for (cur = clist_begin(status->st_info_list); | ||
959 | cur != NULL ; cur = clist_next(cur)) { | ||
960 | mailimap_status_info * status_info; | ||
961 | status_info = (mailimap_status_info *)clist_content(cur); | ||
962 | switch (status_info->st_att) { | ||
963 | case MAILIMAP_STATUS_ATT_MESSAGES: | ||
964 | target_stat.message_count = status_info->st_value; | ||
965 | break; | ||
966 | case MAILIMAP_STATUS_ATT_RECENT: | ||
967 | target_stat.message_recent = status_info->st_value; | ||
968 | break; | ||
969 | case MAILIMAP_STATUS_ATT_UNSEEN: | ||
970 | target_stat.message_unseen = status_info->st_value; | ||
971 | break; | ||
972 | } | ||
973 | } | ||
974 | mailimap_mailbox_data_status_free(status); | ||
975 | mailimap_status_att_list_free(att_list); | ||
976 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 7941046..8f5a2b5 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -1,67 +1,68 @@ | |||
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 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | struct mailimap; | 9 | struct mailimap; |
10 | struct mailimap_body; | 10 | struct mailimap_body; |
11 | struct mailimap_body_type_1part; | 11 | struct mailimap_body_type_1part; |
12 | struct mailimap_body_type_text; | 12 | struct mailimap_body_type_text; |
13 | struct mailimap_body_type_basic; | 13 | struct mailimap_body_type_basic; |
14 | struct mailimap_body_type_msg; | 14 | struct mailimap_body_type_msg; |
15 | struct mailimap_body_type_mpart; | 15 | struct mailimap_body_type_mpart; |
16 | struct mailimap_body_fields; | 16 | struct mailimap_body_fields; |
17 | struct mailimap_msg_att; | 17 | struct mailimap_msg_att; |
18 | class encodedString; | 18 | class encodedString; |
19 | 19 | ||
20 | class IMAPwrapper : public AbstractMail | 20 | class IMAPwrapper : public AbstractMail |
21 | { | 21 | { |
22 | Q_OBJECT | 22 | Q_OBJECT |
23 | public: | 23 | public: |
24 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
25 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
26 | virtual QList<Folder>* listFolders(); | 26 | virtual QList<Folder>* listFolders(); |
27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | virtual void listMessages(const QString & mailbox,QList<RecMail>&target ); |
28 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | ||
28 | 29 | ||
29 | virtual void deleteMail(const RecMail&mail); | 30 | virtual void deleteMail(const RecMail&mail); |
30 | virtual void answeredMail(const RecMail&mail); | 31 | virtual void answeredMail(const RecMail&mail); |
31 | virtual int deleteAllMail(const Folder*folder); | 32 | virtual int deleteAllMail(const Folder*folder); |
32 | 33 | ||
33 | virtual RecBody fetchBody(const RecMail&mail); | 34 | virtual RecBody fetchBody(const RecMail&mail); |
34 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 35 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
35 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 36 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
36 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 37 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
37 | 38 | ||
38 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); | 39 | virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); |
39 | virtual int deleteMbox(const Folder*folder); | 40 | virtual int deleteMbox(const Folder*folder); |
40 | 41 | ||
41 | static void imap_progress( size_t current, size_t maximum ); | 42 | static void imap_progress( size_t current, size_t maximum ); |
42 | 43 | ||
43 | protected: | 44 | protected: |
44 | RecMail*parse_list_result(mailimap_msg_att*); | 45 | RecMail*parse_list_result(mailimap_msg_att*); |
45 | void login(); | 46 | void login(); |
46 | void logout(); | 47 | void logout(); |
47 | 48 | ||
48 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 49 | virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
49 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); | 50 | virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); |
50 | 51 | ||
51 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 52 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
52 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 53 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
53 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 54 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
54 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | 55 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); |
55 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); | 56 | void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); |
56 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 57 | void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
57 | 58 | ||
58 | /* just helpers */ | 59 | /* just helpers */ |
59 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 60 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
60 | static QStringList address_list_to_stringlist(clist*list); | 61 | static QStringList address_list_to_stringlist(clist*list); |
61 | 62 | ||
62 | 63 | ||
63 | IMAPaccount *account; | 64 | IMAPaccount *account; |
64 | mailimap *m_imap; | 65 | mailimap *m_imap; |
65 | }; | 66 | }; |
66 | 67 | ||
67 | #endif | 68 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index abfbe65..05c4816 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -89,97 +89,104 @@ protected: | |||
89 | public: | 89 | public: |
90 | RecPart(); | 90 | RecPart(); |
91 | virtual ~RecPart(); | 91 | virtual ~RecPart(); |
92 | 92 | ||
93 | const QString&Type()const; | 93 | const QString&Type()const; |
94 | void setType(const QString&type); | 94 | void setType(const QString&type); |
95 | const QString&Subtype()const; | 95 | const QString&Subtype()const; |
96 | void setSubtype(const QString&subtype); | 96 | void setSubtype(const QString&subtype); |
97 | const QString&Identifier()const; | 97 | const QString&Identifier()const; |
98 | void setIdentifier(const QString&identifier); | 98 | void setIdentifier(const QString&identifier); |
99 | const QString&Encoding()const; | 99 | const QString&Encoding()const; |
100 | void setEncoding(const QString&encoding); | 100 | void setEncoding(const QString&encoding); |
101 | const QString&Description()const; | 101 | const QString&Description()const; |
102 | void setDescription(const QString&desc); | 102 | void setDescription(const QString&desc); |
103 | void setLines(unsigned int lines); | 103 | void setLines(unsigned int lines); |
104 | const unsigned int Lines()const; | 104 | const unsigned int Lines()const; |
105 | void setSize(unsigned int size); | 105 | void setSize(unsigned int size); |
106 | const unsigned int Size()const; | 106 | const unsigned int Size()const; |
107 | 107 | ||
108 | 108 | ||
109 | void setParameters(const part_plist_t&list); | 109 | void setParameters(const part_plist_t&list); |
110 | const part_plist_t&Parameters()const; | 110 | const part_plist_t&Parameters()const; |
111 | void addParameter(const QString&key,const QString&value); | 111 | void addParameter(const QString&key,const QString&value); |
112 | const QString searchParamter(const QString&key)const; | 112 | const QString searchParamter(const QString&key)const; |
113 | void setPositionlist(const QValueList<int>&poslist); | 113 | void setPositionlist(const QValueList<int>&poslist); |
114 | const QValueList<int>& Positionlist()const; | 114 | const QValueList<int>& Positionlist()const; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | class RecBody | 117 | class RecBody |
118 | { | 118 | { |
119 | protected: | 119 | protected: |
120 | QString m_BodyText; | 120 | QString m_BodyText; |
121 | QValueList<RecPart> m_PartsList; | 121 | QValueList<RecPart> m_PartsList; |
122 | RecPart m_description; | 122 | RecPart m_description; |
123 | 123 | ||
124 | public: | 124 | public: |
125 | RecBody(); | 125 | RecBody(); |
126 | virtual ~RecBody(); | 126 | virtual ~RecBody(); |
127 | void setBodytext(const QString&); | 127 | void setBodytext(const QString&); |
128 | const QString& Bodytext()const; | 128 | const QString& Bodytext()const; |
129 | 129 | ||
130 | void setDescription(const RecPart&des); | 130 | void setDescription(const RecPart&des); |
131 | const RecPart& Description()const; | 131 | const RecPart& Description()const; |
132 | 132 | ||
133 | void setParts(const QValueList<RecPart>&parts); | 133 | void setParts(const QValueList<RecPart>&parts); |
134 | const QValueList<RecPart>& Parts()const; | 134 | const QValueList<RecPart>& Parts()const; |
135 | void addPart(const RecPart&part); | 135 | void addPart(const RecPart&part); |
136 | }; | 136 | }; |
137 | 137 | ||
138 | class encodedString | 138 | class encodedString |
139 | { | 139 | { |
140 | public: | 140 | public: |
141 | encodedString(); | 141 | encodedString(); |
142 | /* | 142 | /* |
143 | creates an new content string. | 143 | creates an new content string. |
144 | it makes a deep copy of it! | 144 | it makes a deep copy of it! |
145 | */ | 145 | */ |
146 | encodedString(const char*nContent,unsigned int length); | 146 | encodedString(const char*nContent,unsigned int length); |
147 | /* | 147 | /* |
148 | Take over the nContent. Means: it will just copy the pointer, not the content. | 148 | Take over the nContent. Means: it will just copy the pointer, not the content. |
149 | so make sure: No one else frees the string, the string has allocated with | 149 | so make sure: No one else frees the string, the string has allocated with |
150 | malloc for compatibility with c-based libs | 150 | malloc for compatibility with c-based libs |
151 | */ | 151 | */ |
152 | encodedString(char*nContent,unsigned int nSize); | 152 | encodedString(char*nContent,unsigned int nSize); |
153 | /* copy construkor - makes ALWAYS a deep copy!!!! */ | 153 | /* copy construkor - makes ALWAYS a deep copy!!!! */ |
154 | encodedString(const encodedString&old); | 154 | encodedString(const encodedString&old); |
155 | /* assign operator - makes ALWAYS a deep copy!!!! */ | 155 | /* assign operator - makes ALWAYS a deep copy!!!! */ |
156 | encodedString& operator=(const encodedString&old); | 156 | encodedString& operator=(const encodedString&old); |
157 | /* destructor - cleans the content */ | 157 | /* destructor - cleans the content */ |
158 | virtual ~encodedString(); | 158 | virtual ~encodedString(); |
159 | 159 | ||
160 | /* returns a pointer to the content - do not delete yoursel! */ | 160 | /* returns a pointer to the content - do not delete yoursel! */ |
161 | const char*Content()const; | 161 | const char*Content()const; |
162 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ | 162 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ |
163 | const int Length()const; | 163 | const int Length()const; |
164 | 164 | ||
165 | /* | 165 | /* |
166 | makes a deep copy of nContent! | 166 | makes a deep copy of nContent! |
167 | */ | 167 | */ |
168 | void setContent(const char*nContent,int nSize); | 168 | void setContent(const char*nContent,int nSize); |
169 | /* | 169 | /* |
170 | Take over the nContent. Means: it will just copy the pointer, not the content. | 170 | Take over the nContent. Means: it will just copy the pointer, not the content. |
171 | so make sure: No one else frees the string, the string has allocated with | 171 | so make sure: No one else frees the string, the string has allocated with |
172 | malloc for compatibility with c-based libs | 172 | malloc for compatibility with c-based libs |
173 | */ | 173 | */ |
174 | void setContent(char*nContent,int nSize); | 174 | void setContent(char*nContent,int nSize); |
175 | 175 | ||
176 | protected: | 176 | protected: |
177 | char * content; | 177 | char * content; |
178 | unsigned int size; | 178 | unsigned int size; |
179 | 179 | ||
180 | void init(); | 180 | void init(); |
181 | void copy_old(const encodedString&old); | 181 | void copy_old(const encodedString&old); |
182 | void clean(); | 182 | void clean(); |
183 | }; | 183 | }; |
184 | 184 | ||
185 | struct folderStat | ||
186 | { | ||
187 | unsigned int message_count; | ||
188 | unsigned int message_unseen; | ||
189 | unsigned int message_recent; | ||
190 | }; | ||
191 | |||
185 | #endif | 192 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 0aa33dd..540a971 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -208,96 +208,117 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | |||
208 | *target = data; | 208 | *target = data; |
209 | *length = size; | 209 | *length = size; |
210 | mailfolder_free(folder); | 210 | mailfolder_free(folder); |
211 | mailstorage_free(storage); | 211 | mailstorage_free(storage); |
212 | mailmessage_free(msg); | 212 | mailmessage_free(msg); |
213 | } | 213 | } |
214 | 214 | ||
215 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 215 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
216 | { | 216 | { |
217 | QString p = MBOXPath+"/"; | 217 | QString p = MBOXPath+"/"; |
218 | p+=mailbox; | 218 | p+=mailbox; |
219 | mailmbox_folder*f = 0; | 219 | mailmbox_folder*f = 0; |
220 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 220 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
221 | if (r != MAIL_NO_ERROR) { | 221 | if (r != MAIL_NO_ERROR) { |
222 | qDebug("Error init folder"); | 222 | qDebug("Error init folder"); |
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | deleteMails(f,target); | 225 | deleteMails(f,target); |
226 | mailmbox_done(f); | 226 | mailmbox_done(f); |
227 | } | 227 | } |
228 | 228 | ||
229 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | 229 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) |
230 | { | 230 | { |
231 | if (!f) return; | 231 | if (!f) return; |
232 | int r; | 232 | int r; |
233 | for (unsigned int i=0; i < target.count();++i) { | 233 | for (unsigned int i=0; i < target.count();++i) { |
234 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); | 234 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); |
235 | if (r!=MAILMBOX_NO_ERROR) { | 235 | if (r!=MAILMBOX_NO_ERROR) { |
236 | qDebug("error delete mail"); | 236 | qDebug("error delete mail"); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | r = mailmbox_expunge(f); | 239 | r = mailmbox_expunge(f); |
240 | if (r != MAILMBOX_NO_ERROR) { | 240 | if (r != MAILMBOX_NO_ERROR) { |
241 | qDebug("error expunge mailbox"); | 241 | qDebug("error expunge mailbox"); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) | 245 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) |
246 | { | 246 | { |
247 | if (!tfolder) return 0; | 247 | if (!tfolder) return 0; |
248 | QString p = MBOXPath+tfolder->getDisplayName(); | 248 | QString p = MBOXPath+tfolder->getDisplayName(); |
249 | int res = 1; | 249 | int res = 1; |
250 | 250 | ||
251 | mailfolder*folder = 0; | 251 | mailfolder*folder = 0; |
252 | mailmessage_list*l=0; | 252 | mailmessage_list*l=0; |
253 | mailstorage*storage = mailstorage_new(NULL); | 253 | mailstorage*storage = mailstorage_new(NULL); |
254 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 254 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
255 | if (r != MAIL_NO_ERROR) { | 255 | if (r != MAIL_NO_ERROR) { |
256 | Global::statusMessage(tr("Error initializing mbox")); | 256 | Global::statusMessage(tr("Error initializing mbox")); |
257 | res = 0; | 257 | res = 0; |
258 | } | 258 | } |
259 | if (res) { | 259 | if (res) { |
260 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 260 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
261 | r = mailfolder_connect(folder); | 261 | r = mailfolder_connect(folder); |
262 | if (r != MAIL_NO_ERROR) { | 262 | if (r != MAIL_NO_ERROR) { |
263 | Global::statusMessage(tr("Error initializing mbox")); | 263 | Global::statusMessage(tr("Error initializing mbox")); |
264 | res = 0; | 264 | res = 0; |
265 | } | 265 | } |
266 | } | 266 | } |
267 | if (res) { | 267 | if (res) { |
268 | r = mailsession_get_messages_list(folder->fld_session,&l); | 268 | r = mailsession_get_messages_list(folder->fld_session,&l); |
269 | if (r != MAIL_NO_ERROR) { | 269 | if (r != MAIL_NO_ERROR) { |
270 | qDebug("Error message list"); | 270 | qDebug("Error message list"); |
271 | res=0; | 271 | res=0; |
272 | } | 272 | } |
273 | } | 273 | } |
274 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 274 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
275 | r = mailsession_remove_message(folder->fld_session,i+1); | 275 | r = mailsession_remove_message(folder->fld_session,i+1); |
276 | if (r != MAIL_NO_ERROR) { | 276 | if (r != MAIL_NO_ERROR) { |
277 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 277 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
278 | res = 0; | 278 | res = 0; |
279 | break; | 279 | break; |
280 | } | 280 | } |
281 | } | 281 | } |
282 | if (l) mailmessage_list_free(l); | 282 | if (l) mailmessage_list_free(l); |
283 | if (folder) mailfolder_free(folder); | 283 | if (folder) mailfolder_free(folder); |
284 | if (storage) mailstorage_free(storage); | 284 | if (storage) mailstorage_free(storage); |
285 | return res; | 285 | return res; |
286 | } | 286 | } |
287 | 287 | ||
288 | int MBOXwrapper::deleteMbox(const Folder*tfolder) | 288 | int MBOXwrapper::deleteMbox(const Folder*tfolder) |
289 | { | 289 | { |
290 | if (!tfolder) return 0; | 290 | if (!tfolder) return 0; |
291 | QString p = MBOXPath+tfolder->getDisplayName(); | 291 | QString p = MBOXPath+tfolder->getDisplayName(); |
292 | QFile fi(p); | 292 | QFile fi(p); |
293 | if (!fi.exists()) { | 293 | if (!fi.exists()) { |
294 | Global::statusMessage(tr("Mailbox doesn't exist.")); | 294 | Global::statusMessage(tr("Mailbox doesn't exist.")); |
295 | return 0; | 295 | return 0; |
296 | } | 296 | } |
297 | if (!fi.remove()) { | 297 | if (!fi.remove()) { |
298 | Global::statusMessage(tr("Error deleting Mailbox.")); | 298 | Global::statusMessage(tr("Error deleting Mailbox.")); |
299 | return 0; | 299 | return 0; |
300 | } | 300 | } |
301 | return 1; | 301 | return 1; |
302 | } | 302 | } |
303 | 303 | ||
304 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | ||
305 | { | ||
306 | mailfolder*folder = 0; | ||
307 | mailstorage*storage = mailstorage_new(NULL); | ||
308 | target_stat.message_count = 0; | ||
309 | target_stat.message_unseen = 0; | ||
310 | target_stat.message_recent = 0; | ||
311 | QString p = MBOXPath+"/"+mailbox; | ||
312 | QFile fi(p); | ||
313 | if (!fi.exists()) { | ||
314 | Global::statusMessage(tr("Mailbox doesn't exist.")); | ||
315 | return; | ||
316 | } | ||
317 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | ||
318 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | ||
319 | r = mailfolder_connect(folder); | ||
320 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, | ||
321 | &target_stat.message_recent,&target_stat.message_unseen); | ||
322 | if (folder) mailfolder_free(folder); | ||
323 | if (storage) mailstorage_free(storage); | ||
324 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h index 226a544..f822997 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.h +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h | |||
@@ -1,41 +1,42 @@ | |||
1 | #ifndef __MBOX_WRAPPER_H | 1 | #ifndef __MBOX_WRAPPER_H |
2 | #define __MBOX_WRAPPER_H | 2 | #define __MBOX_WRAPPER_H |
3 | 3 | ||
4 | #include "genericwrapper.h" | 4 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | struct mailmbox_folder; | 9 | struct mailmbox_folder; |
10 | 10 | ||
11 | class MBOXwrapper : public Genericwrapper | 11 | class MBOXwrapper : public Genericwrapper |
12 | { | 12 | { |
13 | Q_OBJECT | 13 | Q_OBJECT |
14 | public: | 14 | public: |
15 | MBOXwrapper(const QString & dir); | 15 | MBOXwrapper(const QString & dir); |
16 | virtual ~MBOXwrapper(); | 16 | virtual ~MBOXwrapper(); |
17 | 17 | ||
18 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 18 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
19 | virtual QList<Folder>* listFolders(); | 19 | virtual QList<Folder>* listFolders(); |
20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | ||
20 | 21 | ||
21 | virtual void deleteMail(const RecMail&mail); | 22 | virtual void deleteMail(const RecMail&mail); |
22 | virtual void answeredMail(const RecMail&mail); | 23 | virtual void answeredMail(const RecMail&mail); |
23 | 24 | ||
24 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | 25 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); |
25 | virtual int deleteMbox(const Folder*); | 26 | virtual int deleteMbox(const Folder*); |
26 | 27 | ||
27 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 28 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
28 | 29 | ||
29 | virtual RecBody fetchBody( const RecMail &mail ); | 30 | virtual RecBody fetchBody( const RecMail &mail ); |
30 | static void mbox_progress( size_t current, size_t maximum ); | 31 | static void mbox_progress( size_t current, size_t maximum ); |
31 | 32 | ||
32 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); | 33 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); |
33 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); | 34 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); |
34 | virtual int deleteAllMail(const Folder*); | 35 | virtual int deleteAllMail(const Folder*); |
35 | 36 | ||
36 | protected: | 37 | protected: |
37 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | 38 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); |
38 | QString MBOXPath; | 39 | QString MBOXPath; |
39 | }; | 40 | }; |
40 | 41 | ||
41 | #endif | 42 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index de90dd1..d76d82a 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -123,96 +123,107 @@ void POP3wrapper::login() | |||
123 | login.show(); | 123 | login.show(); |
124 | if ( QDialog::Accepted == login.exec() ) { | 124 | if ( QDialog::Accepted == login.exec() ) { |
125 | // ok | 125 | // ok |
126 | user = login.getUser().latin1(); | 126 | user = login.getUser().latin1(); |
127 | pass = login.getPassword().latin1(); | 127 | pass = login.getPassword().latin1(); |
128 | } else { | 128 | } else { |
129 | // cancel | 129 | // cancel |
130 | qDebug( "POP3: Login canceled" ); | 130 | qDebug( "POP3: Login canceled" ); |
131 | return; | 131 | return; |
132 | } | 132 | } |
133 | } else { | 133 | } else { |
134 | user = account->getUser().latin1(); | 134 | user = account->getUser().latin1(); |
135 | pass = account->getPassword().latin1(); | 135 | pass = account->getPassword().latin1(); |
136 | } | 136 | } |
137 | 137 | ||
138 | bool ssl = account->getSSL(); | 138 | bool ssl = account->getSSL(); |
139 | 139 | ||
140 | m_pop3=mailstorage_new(NULL); | 140 | m_pop3=mailstorage_new(NULL); |
141 | pop3_mailstorage_init(m_pop3,(char*)server,port,NULL,CONNECTION_TYPE_TRY_STARTTLS,POP3_AUTH_TYPE_TRY_APOP, | 141 | pop3_mailstorage_init(m_pop3,(char*)server,port,NULL,CONNECTION_TYPE_TRY_STARTTLS,POP3_AUTH_TYPE_TRY_APOP, |
142 | (char*)user,(char*)pass,0,0,0); | 142 | (char*)user,(char*)pass,0,0,0); |
143 | 143 | ||
144 | m_folder = mailfolder_new(m_pop3, NULL, NULL); | 144 | m_folder = mailfolder_new(m_pop3, NULL, NULL); |
145 | 145 | ||
146 | if (m_folder==0) { | 146 | if (m_folder==0) { |
147 | Global::statusMessage(tr("Error initializing folder")); | 147 | Global::statusMessage(tr("Error initializing folder")); |
148 | mailstorage_free(m_pop3); | 148 | mailstorage_free(m_pop3); |
149 | m_pop3 = NULL; | 149 | m_pop3 = NULL; |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | err = mailfolder_connect(m_folder); | 152 | err = mailfolder_connect(m_folder); |
153 | if (err != MAIL_NO_ERROR) { | 153 | if (err != MAIL_NO_ERROR) { |
154 | Global::statusMessage(tr("Error initializing folder")); | 154 | Global::statusMessage(tr("Error initializing folder")); |
155 | mailfolder_free(m_folder); | 155 | mailfolder_free(m_folder); |
156 | m_folder = 0; | 156 | m_folder = 0; |
157 | mailstorage_free(m_pop3); | 157 | mailstorage_free(m_pop3); |
158 | m_pop3 = 0; | 158 | m_pop3 = 0; |
159 | } | 159 | } |
160 | qDebug( "POP3: logged in!" ); | 160 | qDebug( "POP3: logged in!" ); |
161 | } | 161 | } |
162 | 162 | ||
163 | void POP3wrapper::logout() | 163 | void POP3wrapper::logout() |
164 | { | 164 | { |
165 | int err = MAILPOP3_NO_ERROR; | 165 | int err = MAILPOP3_NO_ERROR; |
166 | if ( m_pop3 == NULL ) return; | 166 | if ( m_pop3 == NULL ) return; |
167 | mailfolder_free(m_folder); | 167 | mailfolder_free(m_folder); |
168 | m_folder = 0; | 168 | m_folder = 0; |
169 | mailstorage_free(m_pop3); | 169 | mailstorage_free(m_pop3); |
170 | m_pop3 = 0; | 170 | m_pop3 = 0; |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | QList<Folder>* POP3wrapper::listFolders() | 174 | QList<Folder>* POP3wrapper::listFolders() |
175 | { | 175 | { |
176 | QList<Folder> * folders = new QList<Folder>(); | 176 | QList<Folder> * folders = new QList<Folder>(); |
177 | folders->setAutoDelete( false ); | 177 | folders->setAutoDelete( false ); |
178 | Folder*inb=new Folder("INBOX","/"); | 178 | Folder*inb=new Folder("INBOX","/"); |
179 | folders->append(inb); | 179 | folders->append(inb); |
180 | return folders; | 180 | return folders; |
181 | } | 181 | } |
182 | 182 | ||
183 | void POP3wrapper::deleteMail(const RecMail&mail) | 183 | void POP3wrapper::deleteMail(const RecMail&mail) |
184 | { | 184 | { |
185 | login(); | 185 | login(); |
186 | if (!m_pop3) return; | 186 | if (!m_pop3) return; |
187 | int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); | 187 | int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); |
188 | if (err != MAIL_NO_ERROR) { | 188 | if (err != MAIL_NO_ERROR) { |
189 | Global::statusMessage(tr("error deleting mail")); | 189 | Global::statusMessage(tr("error deleting mail")); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | void POP3wrapper::answeredMail(const RecMail&) | 193 | void POP3wrapper::answeredMail(const RecMail&) |
194 | { | 194 | { |
195 | } | 195 | } |
196 | 196 | ||
197 | int POP3wrapper::deleteAllMail(const Folder*) | 197 | int POP3wrapper::deleteAllMail(const Folder*) |
198 | { | 198 | { |
199 | login(); | 199 | login(); |
200 | if (!m_pop3) return 0; | 200 | if (!m_pop3) return 0; |
201 | int res = 1; | 201 | int res = 1; |
202 | 202 | ||
203 | uint32_t result = 0; | 203 | uint32_t result = 0; |
204 | int err = mailsession_messages_number(m_folder->fld_session,NULL,&result); | 204 | int err = mailsession_messages_number(m_folder->fld_session,NULL,&result); |
205 | if (err != MAIL_NO_ERROR) { | 205 | if (err != MAIL_NO_ERROR) { |
206 | Global::statusMessage(tr("Error getting folder info")); | 206 | Global::statusMessage(tr("Error getting folder info")); |
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | for (unsigned int i = 0; i < result; ++i) { | 209 | for (unsigned int i = 0; i < result; ++i) { |
210 | err = mailsession_remove_message(m_folder->fld_session,i+1); | 210 | err = mailsession_remove_message(m_folder->fld_session,i+1); |
211 | if (err != MAIL_NO_ERROR) { | 211 | if (err != MAIL_NO_ERROR) { |
212 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 212 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
213 | res=0; | 213 | res=0; |
214 | } | 214 | } |
215 | break; | 215 | break; |
216 | } | 216 | } |
217 | return res; | 217 | return res; |
218 | } | 218 | } |
219 | |||
220 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) | ||
221 | { | ||
222 | login(); | ||
223 | target_stat.message_count = 0; | ||
224 | target_stat.message_unseen = 0; | ||
225 | target_stat.message_recent = 0; | ||
226 | if (!m_pop3) return; | ||
227 | int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, | ||
228 | &target_stat.message_recent,&target_stat.message_unseen); | ||
229 | } | ||
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index b3a42be..536cadc 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -1,37 +1,39 @@ | |||
1 | #ifndef __POP3WRAPPER | 1 | #ifndef __POP3WRAPPER |
2 | #define __POP3WRAPPER | 2 | #define __POP3WRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
8 | struct mailstorage; | 8 | struct mailstorage; |
9 | struct mailfolder; | 9 | struct mailfolder; |
10 | 10 | ||
11 | class POP3wrapper : public Genericwrapper | 11 | class POP3wrapper : public Genericwrapper |
12 | { | 12 | { |
13 | Q_OBJECT | 13 | Q_OBJECT |
14 | 14 | ||
15 | public: | 15 | public: |
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 | /* mailbox will be ignored */ | ||
22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | ||
21 | 23 | ||
22 | virtual void deleteMail(const RecMail&mail); | 24 | virtual void deleteMail(const RecMail&mail); |
23 | virtual void answeredMail(const RecMail&mail); | 25 | virtual void answeredMail(const RecMail&mail); |
24 | virtual int deleteAllMail(const Folder*); | 26 | virtual int deleteAllMail(const Folder*); |
25 | 27 | ||
26 | virtual RecBody fetchBody( const RecMail &mail ); | 28 | virtual RecBody fetchBody( const RecMail &mail ); |
27 | static void pop3_progress( size_t current, size_t maximum ); | 29 | static void pop3_progress( size_t current, size_t maximum ); |
28 | 30 | ||
29 | protected: | 31 | protected: |
30 | void login(); | 32 | void login(); |
31 | void logout(); | 33 | void logout(); |
32 | POP3account *account; | 34 | POP3account *account; |
33 | mailstorage*m_pop3; | 35 | mailstorage*m_pop3; |
34 | mailfolder*m_folder; | 36 | mailfolder*m_folder; |
35 | }; | 37 | }; |
36 | 38 | ||
37 | #endif | 39 | #endif |
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h index abfbe65..05c4816 100644 --- a/noncore/net/mail/mailtypes.h +++ b/noncore/net/mail/mailtypes.h | |||
@@ -89,97 +89,104 @@ protected: | |||
89 | public: | 89 | public: |
90 | RecPart(); | 90 | RecPart(); |
91 | virtual ~RecPart(); | 91 | virtual ~RecPart(); |
92 | 92 | ||
93 | const QString&Type()const; | 93 | const QString&Type()const; |
94 | void setType(const QString&type); | 94 | void setType(const QString&type); |
95 | const QString&Subtype()const; | 95 | const QString&Subtype()const; |
96 | void setSubtype(const QString&subtype); | 96 | void setSubtype(const QString&subtype); |
97 | const QString&Identifier()const; | 97 | const QString&Identifier()const; |
98 | void setIdentifier(const QString&identifier); | 98 | void setIdentifier(const QString&identifier); |
99 | const QString&Encoding()const; | 99 | const QString&Encoding()const; |
100 | void setEncoding(const QString&encoding); | 100 | void setEncoding(const QString&encoding); |
101 | const QString&Description()const; | 101 | const QString&Description()const; |
102 | void setDescription(const QString&desc); | 102 | void setDescription(const QString&desc); |
103 | void setLines(unsigned int lines); | 103 | void setLines(unsigned int lines); |
104 | const unsigned int Lines()const; | 104 | const unsigned int Lines()const; |
105 | void setSize(unsigned int size); | 105 | void setSize(unsigned int size); |
106 | const unsigned int Size()const; | 106 | const unsigned int Size()const; |
107 | 107 | ||
108 | 108 | ||
109 | void setParameters(const part_plist_t&list); | 109 | void setParameters(const part_plist_t&list); |
110 | const part_plist_t&Parameters()const; | 110 | const part_plist_t&Parameters()const; |
111 | void addParameter(const QString&key,const QString&value); | 111 | void addParameter(const QString&key,const QString&value); |
112 | const QString searchParamter(const QString&key)const; | 112 | const QString searchParamter(const QString&key)const; |
113 | void setPositionlist(const QValueList<int>&poslist); | 113 | void setPositionlist(const QValueList<int>&poslist); |
114 | const QValueList<int>& Positionlist()const; | 114 | const QValueList<int>& Positionlist()const; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | class RecBody | 117 | class RecBody |
118 | { | 118 | { |
119 | protected: | 119 | protected: |
120 | QString m_BodyText; | 120 | QString m_BodyText; |
121 | QValueList<RecPart> m_PartsList; | 121 | QValueList<RecPart> m_PartsList; |
122 | RecPart m_description; | 122 | RecPart m_description; |
123 | 123 | ||
124 | public: | 124 | public: |
125 | RecBody(); | 125 | RecBody(); |
126 | virtual ~RecBody(); | 126 | virtual ~RecBody(); |
127 | void setBodytext(const QString&); | 127 | void setBodytext(const QString&); |
128 | const QString& Bodytext()const; | 128 | const QString& Bodytext()const; |
129 | 129 | ||
130 | void setDescription(const RecPart&des); | 130 | void setDescription(const RecPart&des); |
131 | const RecPart& Description()const; | 131 | const RecPart& Description()const; |
132 | 132 | ||
133 | void setParts(const QValueList<RecPart>&parts); | 133 | void setParts(const QValueList<RecPart>&parts); |
134 | const QValueList<RecPart>& Parts()const; | 134 | const QValueList<RecPart>& Parts()const; |
135 | void addPart(const RecPart&part); | 135 | void addPart(const RecPart&part); |
136 | }; | 136 | }; |
137 | 137 | ||
138 | class encodedString | 138 | class encodedString |
139 | { | 139 | { |
140 | public: | 140 | public: |
141 | encodedString(); | 141 | encodedString(); |
142 | /* | 142 | /* |
143 | creates an new content string. | 143 | creates an new content string. |
144 | it makes a deep copy of it! | 144 | it makes a deep copy of it! |
145 | */ | 145 | */ |
146 | encodedString(const char*nContent,unsigned int length); | 146 | encodedString(const char*nContent,unsigned int length); |
147 | /* | 147 | /* |
148 | Take over the nContent. Means: it will just copy the pointer, not the content. | 148 | Take over the nContent. Means: it will just copy the pointer, not the content. |
149 | so make sure: No one else frees the string, the string has allocated with | 149 | so make sure: No one else frees the string, the string has allocated with |
150 | malloc for compatibility with c-based libs | 150 | malloc for compatibility with c-based libs |
151 | */ | 151 | */ |
152 | encodedString(char*nContent,unsigned int nSize); | 152 | encodedString(char*nContent,unsigned int nSize); |
153 | /* copy construkor - makes ALWAYS a deep copy!!!! */ | 153 | /* copy construkor - makes ALWAYS a deep copy!!!! */ |
154 | encodedString(const encodedString&old); | 154 | encodedString(const encodedString&old); |
155 | /* assign operator - makes ALWAYS a deep copy!!!! */ | 155 | /* assign operator - makes ALWAYS a deep copy!!!! */ |
156 | encodedString& operator=(const encodedString&old); | 156 | encodedString& operator=(const encodedString&old); |
157 | /* destructor - cleans the content */ | 157 | /* destructor - cleans the content */ |
158 | virtual ~encodedString(); | 158 | virtual ~encodedString(); |
159 | 159 | ||
160 | /* returns a pointer to the content - do not delete yoursel! */ | 160 | /* returns a pointer to the content - do not delete yoursel! */ |
161 | const char*Content()const; | 161 | const char*Content()const; |
162 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ | 162 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ |
163 | const int Length()const; | 163 | const int Length()const; |
164 | 164 | ||
165 | /* | 165 | /* |
166 | makes a deep copy of nContent! | 166 | makes a deep copy of nContent! |
167 | */ | 167 | */ |
168 | void setContent(const char*nContent,int nSize); | 168 | void setContent(const char*nContent,int nSize); |
169 | /* | 169 | /* |
170 | Take over the nContent. Means: it will just copy the pointer, not the content. | 170 | Take over the nContent. Means: it will just copy the pointer, not the content. |
171 | so make sure: No one else frees the string, the string has allocated with | 171 | so make sure: No one else frees the string, the string has allocated with |
172 | malloc for compatibility with c-based libs | 172 | malloc for compatibility with c-based libs |
173 | */ | 173 | */ |
174 | void setContent(char*nContent,int nSize); | 174 | void setContent(char*nContent,int nSize); |
175 | 175 | ||
176 | protected: | 176 | protected: |
177 | char * content; | 177 | char * content; |
178 | unsigned int size; | 178 | unsigned int size; |
179 | 179 | ||
180 | void init(); | 180 | void init(); |
181 | void copy_old(const encodedString&old); | 181 | void copy_old(const encodedString&old); |
182 | void clean(); | 182 | void clean(); |
183 | }; | 183 | }; |
184 | 184 | ||
185 | struct folderStat | ||
186 | { | ||
187 | unsigned int message_count; | ||
188 | unsigned int message_unseen; | ||
189 | unsigned int message_recent; | ||
190 | }; | ||
191 | |||
185 | #endif | 192 | #endif |
diff --git a/noncore/net/mail/mboxwrapper.cpp b/noncore/net/mail/mboxwrapper.cpp index 0aa33dd..540a971 100644 --- a/noncore/net/mail/mboxwrapper.cpp +++ b/noncore/net/mail/mboxwrapper.cpp | |||
@@ -208,96 +208,117 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) | |||
208 | *target = data; | 208 | *target = data; |
209 | *length = size; | 209 | *length = size; |
210 | mailfolder_free(folder); | 210 | mailfolder_free(folder); |
211 | mailstorage_free(storage); | 211 | mailstorage_free(storage); |
212 | mailmessage_free(msg); | 212 | mailmessage_free(msg); |
213 | } | 213 | } |
214 | 214 | ||
215 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) | 215 | void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target) |
216 | { | 216 | { |
217 | QString p = MBOXPath+"/"; | 217 | QString p = MBOXPath+"/"; |
218 | p+=mailbox; | 218 | p+=mailbox; |
219 | mailmbox_folder*f = 0; | 219 | mailmbox_folder*f = 0; |
220 | int r = mailmbox_init(p.latin1(),0,1,0,&f); | 220 | int r = mailmbox_init(p.latin1(),0,1,0,&f); |
221 | if (r != MAIL_NO_ERROR) { | 221 | if (r != MAIL_NO_ERROR) { |
222 | qDebug("Error init folder"); | 222 | qDebug("Error init folder"); |
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | deleteMails(f,target); | 225 | deleteMails(f,target); |
226 | mailmbox_done(f); | 226 | mailmbox_done(f); |
227 | } | 227 | } |
228 | 228 | ||
229 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) | 229 | void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) |
230 | { | 230 | { |
231 | if (!f) return; | 231 | if (!f) return; |
232 | int r; | 232 | int r; |
233 | for (unsigned int i=0; i < target.count();++i) { | 233 | for (unsigned int i=0; i < target.count();++i) { |
234 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); | 234 | r = mailmbox_delete_msg(f,target.at(i)->getNumber()); |
235 | if (r!=MAILMBOX_NO_ERROR) { | 235 | if (r!=MAILMBOX_NO_ERROR) { |
236 | qDebug("error delete mail"); | 236 | qDebug("error delete mail"); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | r = mailmbox_expunge(f); | 239 | r = mailmbox_expunge(f); |
240 | if (r != MAILMBOX_NO_ERROR) { | 240 | if (r != MAILMBOX_NO_ERROR) { |
241 | qDebug("error expunge mailbox"); | 241 | qDebug("error expunge mailbox"); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) | 245 | int MBOXwrapper::deleteAllMail(const Folder*tfolder) |
246 | { | 246 | { |
247 | if (!tfolder) return 0; | 247 | if (!tfolder) return 0; |
248 | QString p = MBOXPath+tfolder->getDisplayName(); | 248 | QString p = MBOXPath+tfolder->getDisplayName(); |
249 | int res = 1; | 249 | int res = 1; |
250 | 250 | ||
251 | mailfolder*folder = 0; | 251 | mailfolder*folder = 0; |
252 | mailmessage_list*l=0; | 252 | mailmessage_list*l=0; |
253 | mailstorage*storage = mailstorage_new(NULL); | 253 | mailstorage*storage = mailstorage_new(NULL); |
254 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 254 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
255 | if (r != MAIL_NO_ERROR) { | 255 | if (r != MAIL_NO_ERROR) { |
256 | Global::statusMessage(tr("Error initializing mbox")); | 256 | Global::statusMessage(tr("Error initializing mbox")); |
257 | res = 0; | 257 | res = 0; |
258 | } | 258 | } |
259 | if (res) { | 259 | if (res) { |
260 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 260 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
261 | r = mailfolder_connect(folder); | 261 | r = mailfolder_connect(folder); |
262 | if (r != MAIL_NO_ERROR) { | 262 | if (r != MAIL_NO_ERROR) { |
263 | Global::statusMessage(tr("Error initializing mbox")); | 263 | Global::statusMessage(tr("Error initializing mbox")); |
264 | res = 0; | 264 | res = 0; |
265 | } | 265 | } |
266 | } | 266 | } |
267 | if (res) { | 267 | if (res) { |
268 | r = mailsession_get_messages_list(folder->fld_session,&l); | 268 | r = mailsession_get_messages_list(folder->fld_session,&l); |
269 | if (r != MAIL_NO_ERROR) { | 269 | if (r != MAIL_NO_ERROR) { |
270 | qDebug("Error message list"); | 270 | qDebug("Error message list"); |
271 | res=0; | 271 | res=0; |
272 | } | 272 | } |
273 | } | 273 | } |
274 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 274 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
275 | r = mailsession_remove_message(folder->fld_session,i+1); | 275 | r = mailsession_remove_message(folder->fld_session,i+1); |
276 | if (r != MAIL_NO_ERROR) { | 276 | if (r != MAIL_NO_ERROR) { |
277 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 277 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
278 | res = 0; | 278 | res = 0; |
279 | break; | 279 | break; |
280 | } | 280 | } |
281 | } | 281 | } |
282 | if (l) mailmessage_list_free(l); | 282 | if (l) mailmessage_list_free(l); |
283 | if (folder) mailfolder_free(folder); | 283 | if (folder) mailfolder_free(folder); |
284 | if (storage) mailstorage_free(storage); | 284 | if (storage) mailstorage_free(storage); |
285 | return res; | 285 | return res; |
286 | } | 286 | } |
287 | 287 | ||
288 | int MBOXwrapper::deleteMbox(const Folder*tfolder) | 288 | int MBOXwrapper::deleteMbox(const Folder*tfolder) |
289 | { | 289 | { |
290 | if (!tfolder) return 0; | 290 | if (!tfolder) return 0; |
291 | QString p = MBOXPath+tfolder->getDisplayName(); | 291 | QString p = MBOXPath+tfolder->getDisplayName(); |
292 | QFile fi(p); | 292 | QFile fi(p); |
293 | if (!fi.exists()) { | 293 | if (!fi.exists()) { |
294 | Global::statusMessage(tr("Mailbox doesn't exist.")); | 294 | Global::statusMessage(tr("Mailbox doesn't exist.")); |
295 | return 0; | 295 | return 0; |
296 | } | 296 | } |
297 | if (!fi.remove()) { | 297 | if (!fi.remove()) { |
298 | Global::statusMessage(tr("Error deleting Mailbox.")); | 298 | Global::statusMessage(tr("Error deleting Mailbox.")); |
299 | return 0; | 299 | return 0; |
300 | } | 300 | } |
301 | return 1; | 301 | return 1; |
302 | } | 302 | } |
303 | 303 | ||
304 | void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | ||
305 | { | ||
306 | mailfolder*folder = 0; | ||
307 | mailstorage*storage = mailstorage_new(NULL); | ||
308 | target_stat.message_count = 0; | ||
309 | target_stat.message_unseen = 0; | ||
310 | target_stat.message_recent = 0; | ||
311 | QString p = MBOXPath+"/"+mailbox; | ||
312 | QFile fi(p); | ||
313 | if (!fi.exists()) { | ||
314 | Global::statusMessage(tr("Mailbox doesn't exist.")); | ||
315 | return; | ||
316 | } | ||
317 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | ||
318 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | ||
319 | r = mailfolder_connect(folder); | ||
320 | r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, | ||
321 | &target_stat.message_recent,&target_stat.message_unseen); | ||
322 | if (folder) mailfolder_free(folder); | ||
323 | if (storage) mailstorage_free(storage); | ||
324 | } | ||
diff --git a/noncore/net/mail/mboxwrapper.h b/noncore/net/mail/mboxwrapper.h index 226a544..f822997 100644 --- a/noncore/net/mail/mboxwrapper.h +++ b/noncore/net/mail/mboxwrapper.h | |||
@@ -1,41 +1,42 @@ | |||
1 | #ifndef __MBOX_WRAPPER_H | 1 | #ifndef __MBOX_WRAPPER_H |
2 | #define __MBOX_WRAPPER_H | 2 | #define __MBOX_WRAPPER_H |
3 | 3 | ||
4 | #include "genericwrapper.h" | 4 | #include "genericwrapper.h" |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | 6 | ||
7 | class RecMail; | 7 | class RecMail; |
8 | class RecBody; | 8 | class RecBody; |
9 | struct mailmbox_folder; | 9 | struct mailmbox_folder; |
10 | 10 | ||
11 | class MBOXwrapper : public Genericwrapper | 11 | class MBOXwrapper : public Genericwrapper |
12 | { | 12 | { |
13 | Q_OBJECT | 13 | Q_OBJECT |
14 | public: | 14 | public: |
15 | MBOXwrapper(const QString & dir); | 15 | MBOXwrapper(const QString & dir); |
16 | virtual ~MBOXwrapper(); | 16 | virtual ~MBOXwrapper(); |
17 | 17 | ||
18 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); | 18 | virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); |
19 | virtual QList<Folder>* listFolders(); | 19 | virtual QList<Folder>* listFolders(); |
20 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | ||
20 | 21 | ||
21 | virtual void deleteMail(const RecMail&mail); | 22 | virtual void deleteMail(const RecMail&mail); |
22 | virtual void answeredMail(const RecMail&mail); | 23 | virtual void answeredMail(const RecMail&mail); |
23 | 24 | ||
24 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); | 25 | virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false); |
25 | virtual int deleteMbox(const Folder*); | 26 | virtual int deleteMbox(const Folder*); |
26 | 27 | ||
27 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 28 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
28 | 29 | ||
29 | virtual RecBody fetchBody( const RecMail &mail ); | 30 | virtual RecBody fetchBody( const RecMail &mail ); |
30 | static void mbox_progress( size_t current, size_t maximum ); | 31 | static void mbox_progress( size_t current, size_t maximum ); |
31 | 32 | ||
32 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); | 33 | virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); |
33 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); | 34 | virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); |
34 | virtual int deleteAllMail(const Folder*); | 35 | virtual int deleteAllMail(const Folder*); |
35 | 36 | ||
36 | protected: | 37 | protected: |
37 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); | 38 | static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); |
38 | QString MBOXPath; | 39 | QString MBOXPath; |
39 | }; | 40 | }; |
40 | 41 | ||
41 | #endif | 42 | #endif |
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp index de90dd1..d76d82a 100644 --- a/noncore/net/mail/pop3wrapper.cpp +++ b/noncore/net/mail/pop3wrapper.cpp | |||
@@ -123,96 +123,107 @@ void POP3wrapper::login() | |||
123 | login.show(); | 123 | login.show(); |
124 | if ( QDialog::Accepted == login.exec() ) { | 124 | if ( QDialog::Accepted == login.exec() ) { |
125 | // ok | 125 | // ok |
126 | user = login.getUser().latin1(); | 126 | user = login.getUser().latin1(); |
127 | pass = login.getPassword().latin1(); | 127 | pass = login.getPassword().latin1(); |
128 | } else { | 128 | } else { |
129 | // cancel | 129 | // cancel |
130 | qDebug( "POP3: Login canceled" ); | 130 | qDebug( "POP3: Login canceled" ); |
131 | return; | 131 | return; |
132 | } | 132 | } |
133 | } else { | 133 | } else { |
134 | user = account->getUser().latin1(); | 134 | user = account->getUser().latin1(); |
135 | pass = account->getPassword().latin1(); | 135 | pass = account->getPassword().latin1(); |
136 | } | 136 | } |
137 | 137 | ||
138 | bool ssl = account->getSSL(); | 138 | bool ssl = account->getSSL(); |
139 | 139 | ||
140 | m_pop3=mailstorage_new(NULL); | 140 | m_pop3=mailstorage_new(NULL); |
141 | pop3_mailstorage_init(m_pop3,(char*)server,port,NULL,CONNECTION_TYPE_TRY_STARTTLS,POP3_AUTH_TYPE_TRY_APOP, | 141 | pop3_mailstorage_init(m_pop3,(char*)server,port,NULL,CONNECTION_TYPE_TRY_STARTTLS,POP3_AUTH_TYPE_TRY_APOP, |
142 | (char*)user,(char*)pass,0,0,0); | 142 | (char*)user,(char*)pass,0,0,0); |
143 | 143 | ||
144 | m_folder = mailfolder_new(m_pop3, NULL, NULL); | 144 | m_folder = mailfolder_new(m_pop3, NULL, NULL); |
145 | 145 | ||
146 | if (m_folder==0) { | 146 | if (m_folder==0) { |
147 | Global::statusMessage(tr("Error initializing folder")); | 147 | Global::statusMessage(tr("Error initializing folder")); |
148 | mailstorage_free(m_pop3); | 148 | mailstorage_free(m_pop3); |
149 | m_pop3 = NULL; | 149 | m_pop3 = NULL; |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | err = mailfolder_connect(m_folder); | 152 | err = mailfolder_connect(m_folder); |
153 | if (err != MAIL_NO_ERROR) { | 153 | if (err != MAIL_NO_ERROR) { |
154 | Global::statusMessage(tr("Error initializing folder")); | 154 | Global::statusMessage(tr("Error initializing folder")); |
155 | mailfolder_free(m_folder); | 155 | mailfolder_free(m_folder); |
156 | m_folder = 0; | 156 | m_folder = 0; |
157 | mailstorage_free(m_pop3); | 157 | mailstorage_free(m_pop3); |
158 | m_pop3 = 0; | 158 | m_pop3 = 0; |
159 | } | 159 | } |
160 | qDebug( "POP3: logged in!" ); | 160 | qDebug( "POP3: logged in!" ); |
161 | } | 161 | } |
162 | 162 | ||
163 | void POP3wrapper::logout() | 163 | void POP3wrapper::logout() |
164 | { | 164 | { |
165 | int err = MAILPOP3_NO_ERROR; | 165 | int err = MAILPOP3_NO_ERROR; |
166 | if ( m_pop3 == NULL ) return; | 166 | if ( m_pop3 == NULL ) return; |
167 | mailfolder_free(m_folder); | 167 | mailfolder_free(m_folder); |
168 | m_folder = 0; | 168 | m_folder = 0; |
169 | mailstorage_free(m_pop3); | 169 | mailstorage_free(m_pop3); |
170 | m_pop3 = 0; | 170 | m_pop3 = 0; |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | QList<Folder>* POP3wrapper::listFolders() | 174 | QList<Folder>* POP3wrapper::listFolders() |
175 | { | 175 | { |
176 | QList<Folder> * folders = new QList<Folder>(); | 176 | QList<Folder> * folders = new QList<Folder>(); |
177 | folders->setAutoDelete( false ); | 177 | folders->setAutoDelete( false ); |
178 | Folder*inb=new Folder("INBOX","/"); | 178 | Folder*inb=new Folder("INBOX","/"); |
179 | folders->append(inb); | 179 | folders->append(inb); |
180 | return folders; | 180 | return folders; |
181 | } | 181 | } |
182 | 182 | ||
183 | void POP3wrapper::deleteMail(const RecMail&mail) | 183 | void POP3wrapper::deleteMail(const RecMail&mail) |
184 | { | 184 | { |
185 | login(); | 185 | login(); |
186 | if (!m_pop3) return; | 186 | if (!m_pop3) return; |
187 | int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); | 187 | int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber()); |
188 | if (err != MAIL_NO_ERROR) { | 188 | if (err != MAIL_NO_ERROR) { |
189 | Global::statusMessage(tr("error deleting mail")); | 189 | Global::statusMessage(tr("error deleting mail")); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | void POP3wrapper::answeredMail(const RecMail&) | 193 | void POP3wrapper::answeredMail(const RecMail&) |
194 | { | 194 | { |
195 | } | 195 | } |
196 | 196 | ||
197 | int POP3wrapper::deleteAllMail(const Folder*) | 197 | int POP3wrapper::deleteAllMail(const Folder*) |
198 | { | 198 | { |
199 | login(); | 199 | login(); |
200 | if (!m_pop3) return 0; | 200 | if (!m_pop3) return 0; |
201 | int res = 1; | 201 | int res = 1; |
202 | 202 | ||
203 | uint32_t result = 0; | 203 | uint32_t result = 0; |
204 | int err = mailsession_messages_number(m_folder->fld_session,NULL,&result); | 204 | int err = mailsession_messages_number(m_folder->fld_session,NULL,&result); |
205 | if (err != MAIL_NO_ERROR) { | 205 | if (err != MAIL_NO_ERROR) { |
206 | Global::statusMessage(tr("Error getting folder info")); | 206 | Global::statusMessage(tr("Error getting folder info")); |
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | for (unsigned int i = 0; i < result; ++i) { | 209 | for (unsigned int i = 0; i < result; ++i) { |
210 | err = mailsession_remove_message(m_folder->fld_session,i+1); | 210 | err = mailsession_remove_message(m_folder->fld_session,i+1); |
211 | if (err != MAIL_NO_ERROR) { | 211 | if (err != MAIL_NO_ERROR) { |
212 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 212 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
213 | res=0; | 213 | res=0; |
214 | } | 214 | } |
215 | break; | 215 | break; |
216 | } | 216 | } |
217 | return res; | 217 | return res; |
218 | } | 218 | } |
219 | |||
220 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) | ||
221 | { | ||
222 | login(); | ||
223 | target_stat.message_count = 0; | ||
224 | target_stat.message_unseen = 0; | ||
225 | target_stat.message_recent = 0; | ||
226 | if (!m_pop3) return; | ||
227 | int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, | ||
228 | &target_stat.message_recent,&target_stat.message_unseen); | ||
229 | } | ||
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h index b3a42be..536cadc 100644 --- a/noncore/net/mail/pop3wrapper.h +++ b/noncore/net/mail/pop3wrapper.h | |||
@@ -1,37 +1,39 @@ | |||
1 | #ifndef __POP3WRAPPER | 1 | #ifndef __POP3WRAPPER |
2 | #define __POP3WRAPPER | 2 | #define __POP3WRAPPER |
3 | 3 | ||
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include "genericwrapper.h" | 5 | #include "genericwrapper.h" |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | 7 | ||
8 | struct mailstorage; | 8 | struct mailstorage; |
9 | struct mailfolder; | 9 | struct mailfolder; |
10 | 10 | ||
11 | class POP3wrapper : public Genericwrapper | 11 | class POP3wrapper : public Genericwrapper |
12 | { | 12 | { |
13 | Q_OBJECT | 13 | Q_OBJECT |
14 | 14 | ||
15 | public: | 15 | public: |
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 | /* mailbox will be ignored */ | ||
22 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | ||
21 | 23 | ||
22 | virtual void deleteMail(const RecMail&mail); | 24 | virtual void deleteMail(const RecMail&mail); |
23 | virtual void answeredMail(const RecMail&mail); | 25 | virtual void answeredMail(const RecMail&mail); |
24 | virtual int deleteAllMail(const Folder*); | 26 | virtual int deleteAllMail(const Folder*); |
25 | 27 | ||
26 | virtual RecBody fetchBody( const RecMail &mail ); | 28 | virtual RecBody fetchBody( const RecMail &mail ); |
27 | static void pop3_progress( size_t current, size_t maximum ); | 29 | static void pop3_progress( size_t current, size_t maximum ); |
28 | 30 | ||
29 | protected: | 31 | protected: |
30 | void login(); | 32 | void login(); |
31 | void logout(); | 33 | void logout(); |
32 | POP3account *account; | 34 | POP3account *account; |
33 | mailstorage*m_pop3; | 35 | mailstorage*m_pop3; |
34 | mailfolder*m_folder; | 36 | mailfolder*m_folder; |
35 | }; | 37 | }; |
36 | 38 | ||
37 | #endif | 39 | #endif |