summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h2
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h1
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp7
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h2
7 files changed, 23 insertions, 1 deletions
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index a070fb0..7c060db 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -1,57 +1,59 @@
1#ifndef __abstract_mail_ 1#ifndef __abstract_mail_
2#define __abstract_mail_ 2#define __abstract_mail_
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include "settings.h" 5#include "settings.h"
6 6
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9class RecPart; 9class RecPart;
10class IMAPwrapper; 10class IMAPwrapper;
11class POP3wrapper; 11class POP3wrapper;
12class Folder; 12class Folder;
13class encodedString; 13class encodedString;
14struct folderStat; 14struct folderStat;
15 15
16class AbstractMail:public QObject 16class AbstractMail:public QObject
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19public: 19public:
20 AbstractMail(){}; 20 AbstractMail(){};
21 virtual ~AbstractMail(){} 21 virtual ~AbstractMail(){}
22 virtual QList<Folder>* listFolders()=0; 22 virtual QList<Folder>* listFolders()=0;
23 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; 24 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0;
25 virtual RecBody fetchBody(const RecMail&mail)=0; 25 virtual RecBody fetchBody(const RecMail&mail)=0;
26 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0; 26 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
27 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0; 27 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
28 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0; 28 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
29 29
30 virtual void deleteMail(const RecMail&mail)=0; 30 virtual void deleteMail(const RecMail&mail)=0;
31 virtual void answeredMail(const RecMail&mail)=0; 31 virtual void answeredMail(const RecMail&mail)=0;
32 virtual int deleteAllMail(const Folder*)=0; 32 virtual int deleteAllMail(const Folder*)=0;
33 virtual int deleteMbox(const Folder*)=0; 33 virtual int deleteMbox(const Folder*)=0;
34 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; 34 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
35 35
36 virtual void cleanMimeCache(){}; 36 virtual void cleanMimeCache(){};
37 /* mail box methods */ 37 /* mail box methods */
38 /* parameter is the box to create. 38 /* parameter is the box to create.
39 * if the implementing subclass has prefixes, 39 * if the implementing subclass has prefixes,
40 * them has to be appended automatic. 40 * them has to be appended automatic.
41 */ 41 */
42 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); 42 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
43 virtual void logout()=0; 43 virtual void logout()=0;
44 44
45 static AbstractMail* getWrapper(IMAPaccount *a); 45 static AbstractMail* getWrapper(IMAPaccount *a);
46 static AbstractMail* getWrapper(POP3account *a); 46 static AbstractMail* getWrapper(POP3account *a);
47 /* mbox only! */ 47 /* mbox only! */
48 static AbstractMail* getWrapper(const QString&a); 48 static AbstractMail* getWrapper(const QString&a);
49 49
50 static QString defaultLocalfolder(); 50 static QString defaultLocalfolder();
51 51
52 virtual const QString&getType()const=0;
53
52protected: 54protected:
53 static encodedString*decode_String(const encodedString*text,const QString&enc); 55 static encodedString*decode_String(const encodedString*text,const QString&enc);
54 static QString convert_String(const char*text); 56 static QString convert_String(const char*text);
55 static QString gen_attachment_id(); 57 static QString gen_attachment_id();
56}; 58};
57#endif 59#endif
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 0c1e05e..95b317a 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -892,96 +892,101 @@ int IMAPwrapper::deleteAllMail(const Folder*folder)
892 return 1; 892 return 1;
893} 893}
894 894
895int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const QString& delemiter,bool getsubfolder) 895int 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
925int IMAPwrapper::deleteMbox(const Folder*folder) 925int 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 937
938void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) 938void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
939{ 939{
940 mailimap_status_att_list * att_list =0; 940 mailimap_status_att_list * att_list =0;
941 mailimap_mailbox_data_status * status=0; 941 mailimap_mailbox_data_status * status=0;
942 clistiter * cur = 0; 942 clistiter * cur = 0;
943 int r = 0; 943 int r = 0;
944 int res = 0; 944 int res = 0;
945 target_stat.message_count = 0; 945 target_stat.message_count = 0;
946 target_stat.message_unseen = 0; 946 target_stat.message_unseen = 0;
947 target_stat.message_recent = 0; 947 target_stat.message_recent = 0;
948 login(); 948 login();
949 if (!m_imap) { 949 if (!m_imap) {
950 return; 950 return;
951 } 951 }
952 att_list = mailimap_status_att_list_new_empty(); 952 att_list = mailimap_status_att_list_new_empty();
953 if (!att_list) return; 953 if (!att_list) return;
954 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); 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); 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); 956 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN);
957 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); 957 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status);
958 for (cur = clist_begin(status->st_info_list); 958 for (cur = clist_begin(status->st_info_list);
959 cur != NULL ; cur = clist_next(cur)) { 959 cur != NULL ; cur = clist_next(cur)) {
960 mailimap_status_info * status_info; 960 mailimap_status_info * status_info;
961 status_info = (mailimap_status_info *)clist_content(cur); 961 status_info = (mailimap_status_info *)clist_content(cur);
962 switch (status_info->st_att) { 962 switch (status_info->st_att) {
963 case MAILIMAP_STATUS_ATT_MESSAGES: 963 case MAILIMAP_STATUS_ATT_MESSAGES:
964 target_stat.message_count = status_info->st_value; 964 target_stat.message_count = status_info->st_value;
965 break; 965 break;
966 case MAILIMAP_STATUS_ATT_RECENT: 966 case MAILIMAP_STATUS_ATT_RECENT:
967 target_stat.message_recent = status_info->st_value; 967 target_stat.message_recent = status_info->st_value;
968 break; 968 break;
969 case MAILIMAP_STATUS_ATT_UNSEEN: 969 case MAILIMAP_STATUS_ATT_UNSEEN:
970 target_stat.message_unseen = status_info->st_value; 970 target_stat.message_unseen = status_info->st_value;
971 break; 971 break;
972 } 972 }
973 } 973 }
974 mailimap_mailbox_data_status_free(status); 974 mailimap_mailbox_data_status_free(status);
975 mailimap_status_att_list_free(att_list); 975 mailimap_status_att_list_free(att_list);
976} 976}
977 977
978void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) 978void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
979{ 979{
980 login(); 980 login();
981 if (!m_imap) return; 981 if (!m_imap) return;
982 if (!msg) return; 982 if (!msg) return;
983 int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); 983 int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length);
984 if (r != MAILIMAP_NO_ERROR) { 984 if (r != MAILIMAP_NO_ERROR) {
985 Global::statusMessage("Error storing mail!"); 985 Global::statusMessage("Error storing mail!");
986 } 986 }
987} 987}
988
989const QString&IMAPwrapper::getType()const
990{
991 return account->getType();
992}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index a97f12d..6a9c411 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -1,69 +1,70 @@
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
9struct mailimap; 9struct mailimap;
10struct mailimap_body; 10struct mailimap_body;
11struct mailimap_body_type_1part; 11struct mailimap_body_type_1part;
12struct mailimap_body_type_text; 12struct mailimap_body_type_text;
13struct mailimap_body_type_basic; 13struct mailimap_body_type_basic;
14struct mailimap_body_type_msg; 14struct mailimap_body_type_msg;
15struct mailimap_body_type_mpart; 15struct mailimap_body_type_mpart;
16struct mailimap_body_fields; 16struct mailimap_body_fields;
17struct mailimap_msg_att; 17struct mailimap_msg_att;
18class encodedString; 18class encodedString;
19 19
20class IMAPwrapper : public AbstractMail 20class IMAPwrapper : public AbstractMail
21{ 21{
22 Q_OBJECT 22 Q_OBJECT
23public: 23public:
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 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
29 29
30 virtual void deleteMail(const RecMail&mail); 30 virtual void deleteMail(const RecMail&mail);
31 virtual void answeredMail(const RecMail&mail); 31 virtual void answeredMail(const RecMail&mail);
32 virtual int deleteAllMail(const Folder*folder); 32 virtual int deleteAllMail(const Folder*folder);
33 virtual void storeMessage(const char*msg,size_t length, const QString&folder); 33 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
34 34
35 virtual RecBody fetchBody(const RecMail&mail); 35 virtual RecBody fetchBody(const RecMail&mail);
36 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); 36 virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
37 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); 37 virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
38 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); 38 virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
39 39
40 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); 40 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
41 virtual int deleteMbox(const Folder*folder); 41 virtual int deleteMbox(const Folder*folder);
42 42
43 static void imap_progress( size_t current, size_t maximum ); 43 static void imap_progress( size_t current, size_t maximum );
44 44
45 virtual void logout(); 45 virtual void logout();
46 virtual const QString&getType()const;
46protected: 47protected:
47 RecMail*parse_list_result(mailimap_msg_att*); 48 RecMail*parse_list_result(mailimap_msg_att*);
48 void login(); 49 void login();
49 50
50 virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); 51 virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
51 virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call); 52 virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call);
52 53
53 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); 54 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
54 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); 55 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
55 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); 56 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
56 void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); 57 void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
57 void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); 58 void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which);
58 void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); 59 void traverseBody(const RecMail&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
59 60
60 /* just helpers */ 61 /* just helpers */
61 static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); 62 static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
62 static QStringList address_list_to_stringlist(clist*list); 63 static QStringList address_list_to_stringlist(clist*list);
63 64
64 65
65 IMAPaccount *account; 66 IMAPaccount *account;
66 mailimap *m_imap; 67 mailimap *m_imap;
67}; 68};
68 69
69#endif 70#endif
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 540a971..60f7507 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -1,104 +1,106 @@
1#include "mboxwrapper.h" 1#include "mboxwrapper.h"
2#include "mailtypes.h" 2#include "mailtypes.h"
3#include "mailwrapper.h" 3#include "mailwrapper.h"
4#include <libetpan/libetpan.h> 4#include <libetpan/libetpan.h>
5#include <qdir.h> 5#include <qdir.h>
6#include <stdlib.h> 6#include <stdlib.h>
7#include <qpe/global.h> 7#include <qpe/global.h>
8 8
9const QString MBOXwrapper::wrapperType="MBOX";
10
9MBOXwrapper::MBOXwrapper(const QString & mbox_dir) 11MBOXwrapper::MBOXwrapper(const QString & mbox_dir)
10 : Genericwrapper(),MBOXPath(mbox_dir) 12 : Genericwrapper(),MBOXPath(mbox_dir)
11{ 13{
12 QDir dir(MBOXPath); 14 QDir dir(MBOXPath);
13 if (!dir.exists()) { 15 if (!dir.exists()) {
14 dir.mkdir(MBOXPath); 16 dir.mkdir(MBOXPath);
15 } 17 }
16} 18}
17 19
18MBOXwrapper::~MBOXwrapper() 20MBOXwrapper::~MBOXwrapper()
19{ 21{
20} 22}
21 23
22void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) 24void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
23{ 25{
24 mailstorage*storage = mailstorage_new(NULL); 26 mailstorage*storage = mailstorage_new(NULL);
25 QString p = MBOXPath+"/"; 27 QString p = MBOXPath+"/";
26 p+=mailbox; 28 p+=mailbox;
27 29
28 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 30 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
29 mailfolder*folder; 31 mailfolder*folder;
30 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 32 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
31 r = mailfolder_connect(folder); 33 r = mailfolder_connect(folder);
32 if (r != MAIL_NO_ERROR) { 34 if (r != MAIL_NO_ERROR) {
33 qDebug("Error initializing mbox"); 35 qDebug("Error initializing mbox");
34 mailfolder_free(folder); 36 mailfolder_free(folder);
35 mailstorage_free(storage); 37 mailstorage_free(storage);
36 return; 38 return;
37 } 39 }
38 40
39 parseList(target,folder->fld_session,mailbox); 41 parseList(target,folder->fld_session,mailbox);
40 42
41 mailfolder_disconnect(folder); 43 mailfolder_disconnect(folder);
42 mailfolder_free(folder); 44 mailfolder_free(folder);
43 mailstorage_free(storage); 45 mailstorage_free(storage);
44 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); 46 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count()));
45} 47}
46 48
47QList<Folder>* MBOXwrapper::listFolders() 49QList<Folder>* MBOXwrapper::listFolders()
48{ 50{
49 QList<Folder> * folders = new QList<Folder>(); 51 QList<Folder> * folders = new QList<Folder>();
50 folders->setAutoDelete( false ); 52 folders->setAutoDelete( false );
51 QDir dir(MBOXPath); 53 QDir dir(MBOXPath);
52 if (!dir.exists()) return folders; 54 if (!dir.exists()) return folders;
53 dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); 55 dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable);
54 QStringList entries = dir.entryList(); 56 QStringList entries = dir.entryList();
55 QStringList::ConstIterator it = entries.begin(); 57 QStringList::ConstIterator it = entries.begin();
56 for (;it!=entries.end();++it) { 58 for (;it!=entries.end();++it) {
57 Folder*inb=new Folder(*it,"/"); 59 Folder*inb=new Folder(*it,"/");
58 folders->append(inb); 60 folders->append(inb);
59 } 61 }
60 return folders; 62 return folders;
61} 63}
62 64
63void MBOXwrapper::deleteMail(const RecMail&mail) 65void MBOXwrapper::deleteMail(const RecMail&mail)
64{ 66{
65 mailstorage*storage = mailstorage_new(NULL); 67 mailstorage*storage = mailstorage_new(NULL);
66 QString p = MBOXPath+"/"; 68 QString p = MBOXPath+"/";
67 p+=mail.getMbox(); 69 p+=mail.getMbox();
68 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 70 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
69 mailfolder*folder; 71 mailfolder*folder;
70 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 72 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
71 r = mailfolder_connect(folder); 73 r = mailfolder_connect(folder);
72 if (r != MAIL_NO_ERROR) { 74 if (r != MAIL_NO_ERROR) {
73 qDebug("Error initializing mbox"); 75 qDebug("Error initializing mbox");
74 mailfolder_free(folder); 76 mailfolder_free(folder);
75 mailstorage_free(storage); 77 mailstorage_free(storage);
76 return; 78 return;
77 } 79 }
78 r = mailsession_remove_message(folder->fld_session,mail.getNumber()); 80 r = mailsession_remove_message(folder->fld_session,mail.getNumber());
79 if (r != MAIL_NO_ERROR) { 81 if (r != MAIL_NO_ERROR) {
80 qDebug("error deleting mail"); 82 qDebug("error deleting mail");
81 } 83 }
82 mailfolder_free(folder); 84 mailfolder_free(folder);
83 mailstorage_free(storage); 85 mailstorage_free(storage);
84} 86}
85 87
86void MBOXwrapper::answeredMail(const RecMail&) 88void MBOXwrapper::answeredMail(const RecMail&)
87{ 89{
88} 90}
89 91
90RecBody MBOXwrapper::fetchBody( const RecMail &mail ) 92RecBody MBOXwrapper::fetchBody( const RecMail &mail )
91{ 93{
92 RecBody body; 94 RecBody body;
93 mailstorage*storage = mailstorage_new(NULL); 95 mailstorage*storage = mailstorage_new(NULL);
94 QString p = MBOXPath+"/"; 96 QString p = MBOXPath+"/";
95 p+=mail.getMbox(); 97 p+=mail.getMbox();
96 mailmessage * msg; 98 mailmessage * msg;
97 char*data=0; 99 char*data=0;
98 size_t size; 100 size_t size;
99 101
100 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 102 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
101 mailfolder*folder; 103 mailfolder*folder;
102 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 104 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
103 r = mailfolder_connect(folder); 105 r = mailfolder_connect(folder);
104 if (r != MAIL_NO_ERROR) { 106 if (r != MAIL_NO_ERROR) {
@@ -229,96 +231,101 @@ void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
229void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target) 231void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target)
230{ 232{
231 if (!f) return; 233 if (!f) return;
232 int r; 234 int r;
233 for (unsigned int i=0; i < target.count();++i) { 235 for (unsigned int i=0; i < target.count();++i) {
234 r = mailmbox_delete_msg(f,target.at(i)->getNumber()); 236 r = mailmbox_delete_msg(f,target.at(i)->getNumber());
235 if (r!=MAILMBOX_NO_ERROR) { 237 if (r!=MAILMBOX_NO_ERROR) {
236 qDebug("error delete mail"); 238 qDebug("error delete mail");
237 } 239 }
238 } 240 }
239 r = mailmbox_expunge(f); 241 r = mailmbox_expunge(f);
240 if (r != MAILMBOX_NO_ERROR) { 242 if (r != MAILMBOX_NO_ERROR) {
241 qDebug("error expunge mailbox"); 243 qDebug("error expunge mailbox");
242 } 244 }
243} 245}
244 246
245int MBOXwrapper::deleteAllMail(const Folder*tfolder) 247int MBOXwrapper::deleteAllMail(const Folder*tfolder)
246{ 248{
247 if (!tfolder) return 0; 249 if (!tfolder) return 0;
248 QString p = MBOXPath+tfolder->getDisplayName(); 250 QString p = MBOXPath+tfolder->getDisplayName();
249 int res = 1; 251 int res = 1;
250 252
251 mailfolder*folder = 0; 253 mailfolder*folder = 0;
252 mailmessage_list*l=0; 254 mailmessage_list*l=0;
253 mailstorage*storage = mailstorage_new(NULL); 255 mailstorage*storage = mailstorage_new(NULL);
254 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 256 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
255 if (r != MAIL_NO_ERROR) { 257 if (r != MAIL_NO_ERROR) {
256 Global::statusMessage(tr("Error initializing mbox")); 258 Global::statusMessage(tr("Error initializing mbox"));
257 res = 0; 259 res = 0;
258 } 260 }
259 if (res) { 261 if (res) {
260 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 262 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
261 r = mailfolder_connect(folder); 263 r = mailfolder_connect(folder);
262 if (r != MAIL_NO_ERROR) { 264 if (r != MAIL_NO_ERROR) {
263 Global::statusMessage(tr("Error initializing mbox")); 265 Global::statusMessage(tr("Error initializing mbox"));
264 res = 0; 266 res = 0;
265 } 267 }
266 } 268 }
267 if (res) { 269 if (res) {
268 r = mailsession_get_messages_list(folder->fld_session,&l); 270 r = mailsession_get_messages_list(folder->fld_session,&l);
269 if (r != MAIL_NO_ERROR) { 271 if (r != MAIL_NO_ERROR) {
270 qDebug("Error message list"); 272 qDebug("Error message list");
271 res=0; 273 res=0;
272 } 274 }
273 } 275 }
274 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { 276 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); 277 r = mailsession_remove_message(folder->fld_session,i+1);
276 if (r != MAIL_NO_ERROR) { 278 if (r != MAIL_NO_ERROR) {
277 Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); 279 Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
278 res = 0; 280 res = 0;
279 break; 281 break;
280 } 282 }
281 } 283 }
282 if (l) mailmessage_list_free(l); 284 if (l) mailmessage_list_free(l);
283 if (folder) mailfolder_free(folder); 285 if (folder) mailfolder_free(folder);
284 if (storage) mailstorage_free(storage); 286 if (storage) mailstorage_free(storage);
285 return res; 287 return res;
286} 288}
287 289
288int MBOXwrapper::deleteMbox(const Folder*tfolder) 290int MBOXwrapper::deleteMbox(const Folder*tfolder)
289{ 291{
290 if (!tfolder) return 0; 292 if (!tfolder) return 0;
291 QString p = MBOXPath+tfolder->getDisplayName(); 293 QString p = MBOXPath+tfolder->getDisplayName();
292 QFile fi(p); 294 QFile fi(p);
293 if (!fi.exists()) { 295 if (!fi.exists()) {
294 Global::statusMessage(tr("Mailbox doesn't exist.")); 296 Global::statusMessage(tr("Mailbox doesn't exist."));
295 return 0; 297 return 0;
296 } 298 }
297 if (!fi.remove()) { 299 if (!fi.remove()) {
298 Global::statusMessage(tr("Error deleting Mailbox.")); 300 Global::statusMessage(tr("Error deleting Mailbox."));
299 return 0; 301 return 0;
300 } 302 }
301 return 1; 303 return 1;
302} 304}
303 305
304void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) 306void MBOXwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
305{ 307{
306 mailfolder*folder = 0; 308 mailfolder*folder = 0;
307 mailstorage*storage = mailstorage_new(NULL); 309 mailstorage*storage = mailstorage_new(NULL);
308 target_stat.message_count = 0; 310 target_stat.message_count = 0;
309 target_stat.message_unseen = 0; 311 target_stat.message_unseen = 0;
310 target_stat.message_recent = 0; 312 target_stat.message_recent = 0;
311 QString p = MBOXPath+"/"+mailbox; 313 QString p = MBOXPath+"/"+mailbox;
312 QFile fi(p); 314 QFile fi(p);
313 if (!fi.exists()) { 315 if (!fi.exists()) {
314 Global::statusMessage(tr("Mailbox doesn't exist.")); 316 Global::statusMessage(tr("Mailbox doesn't exist."));
315 return; 317 return;
316 } 318 }
317 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 319 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
318 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 320 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
319 r = mailfolder_connect(folder); 321 r = mailfolder_connect(folder);
320 r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count, 322 r = mailsession_status_folder(folder->fld_session,(char*)mailbox.latin1(),&target_stat.message_count,
321 &target_stat.message_recent,&target_stat.message_unseen); 323 &target_stat.message_recent,&target_stat.message_unseen);
322 if (folder) mailfolder_free(folder); 324 if (folder) mailfolder_free(folder);
323 if (storage) mailstorage_free(storage); 325 if (storage) mailstorage_free(storage);
324} 326}
327
328const QString&MBOXwrapper::getType()const
329{
330 return wrapperType;
331}
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index f822997..f97fce2 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -1,42 +1,44 @@
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
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9struct mailmbox_folder; 9struct mailmbox_folder;
10 10
11class MBOXwrapper : public Genericwrapper 11class MBOXwrapper : public Genericwrapper
12{ 12{
13 Q_OBJECT 13 Q_OBJECT
14public: 14public:
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 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
21 21
22 virtual void deleteMail(const RecMail&mail); 22 virtual void deleteMail(const RecMail&mail);
23 virtual void answeredMail(const RecMail&mail); 23 virtual void answeredMail(const RecMail&mail);
24 24
25 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);
26 virtual int deleteMbox(const Folder*); 26 virtual int deleteMbox(const Folder*);
27 27
28 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);
29 29
30 virtual RecBody fetchBody( const RecMail &mail ); 30 virtual RecBody fetchBody( const RecMail &mail );
31 static void mbox_progress( size_t current, size_t maximum ); 31 static void mbox_progress( size_t current, size_t maximum );
32 32
33 virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); 33 virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length);
34 virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); 34 virtual void deleteMails(const QString & mailbox,QList<RecMail> &target);
35 virtual int deleteAllMail(const Folder*); 35 virtual int deleteAllMail(const Folder*);
36 virtual const QString&getType()const;
36 37
37protected: 38protected:
38 static void deleteMails(mailmbox_folder*f,QList<RecMail> &target); 39 static void deleteMails(mailmbox_folder*f,QList<RecMail> &target);
39 QString MBOXPath; 40 QString MBOXPath;
41 static const QString wrapperType;
40}; 42};
41 43
42#endif 44#endif
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index b4eca6f..45408dd 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -142,96 +142,101 @@ void POP3wrapper::login()
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
163void POP3wrapper::logout() 163void 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
174QList<Folder>* POP3wrapper::listFolders() 174QList<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
183void POP3wrapper::deleteMail(const RecMail&mail) 183void 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
193void POP3wrapper::answeredMail(const RecMail&) 193void POP3wrapper::answeredMail(const RecMail&)
194{ 194{
195} 195}
196 196
197int POP3wrapper::deleteAllMail(const Folder*) 197int 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 219
220void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) 220void POP3wrapper::statusFolder(folderStat&target_stat,const QString&)
221{ 221{
222 login(); 222 login();
223 target_stat.message_count = 0; 223 target_stat.message_count = 0;
224 target_stat.message_unseen = 0; 224 target_stat.message_unseen = 0;
225 target_stat.message_recent = 0; 225 target_stat.message_recent = 0;
226 if (!m_pop3) return; 226 if (!m_pop3) return;
227 int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count, 227 int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count,
228 &target_stat.message_recent,&target_stat.message_unseen); 228 &target_stat.message_recent,&target_stat.message_unseen);
229} 229}
230 230
231void POP3wrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) 231void POP3wrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
232{ 232{
233 mailmessage * mailmsg = 0; 233 mailmessage * mailmsg = 0;
234 int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); 234 int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg);
235 err = mailmessage_fetch(mailmsg,target,length); 235 err = mailmessage_fetch(mailmsg,target,length);
236 if (mailmsg) mailmessage_free(mailmsg); 236 if (mailmsg) mailmessage_free(mailmsg);
237} 237}
238
239const QString&POP3wrapper::getType()const
240{
241 return account->getType();
242}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index 9cba101..b7e8f27 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -1,41 +1,41 @@
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
8struct mailstorage; 8struct mailstorage;
9struct mailfolder; 9struct mailfolder;
10 10
11class POP3wrapper : public Genericwrapper 11class POP3wrapper : public Genericwrapper
12{ 12{
13 Q_OBJECT 13 Q_OBJECT
14 14
15public: 15public:
16 POP3wrapper( POP3account *a ); 16 POP3wrapper( POP3account *a );
17 virtual ~POP3wrapper(); 17 virtual ~POP3wrapper();
18 /* mailbox will be ignored */ 18 /* mailbox will be ignored */
19 virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); 19 virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
20 virtual QList<Folder>* listFolders(); 20 virtual QList<Folder>* listFolders();
21 /* mailbox will be ignored */ 21 /* mailbox will be ignored */
22 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 22 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
23 23
24 virtual void deleteMail(const RecMail&mail); 24 virtual void deleteMail(const RecMail&mail);
25 virtual void answeredMail(const RecMail&mail); 25 virtual void answeredMail(const RecMail&mail);
26 virtual int deleteAllMail(const Folder*); 26 virtual int deleteAllMail(const Folder*);
27 27
28 virtual RecBody fetchBody( const RecMail &mail ); 28 virtual RecBody fetchBody( const RecMail &mail );
29 virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); 29 virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length);
30 virtual void logout(); 30 virtual void logout();
31 31 virtual const QString&getType()const;
32 static void pop3_progress( size_t current, size_t maximum ); 32 static void pop3_progress( size_t current, size_t maximum );
33 33
34protected: 34protected:
35 void login(); 35 void login();
36 POP3account *account; 36 POP3account *account;
37 mailstorage*m_pop3; 37 mailstorage*m_pop3;
38 mailfolder*m_folder; 38 mailfolder*m_folder;
39}; 39};
40 40
41#endif 41#endif