summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper
Unidiff
Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h1
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp74
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h1
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp13
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h3
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp11
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h3
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp17
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h4
9 files changed, 79 insertions, 48 deletions
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 7c060db..9770991 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -27,4 +27,5 @@ public:
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 virtual encodedString* fetchRawBody(const RecMail&mail)=0;
29 30
30 virtual void deleteMail(const RecMail&mail)=0; 31 virtual void deleteMail(const RecMail&mail)=0;
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 95b317a..d252159 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -467,4 +467,8 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
467 mailimap_set *set; 467 mailimap_set *set;
468 clistcell*current,*cur; 468 clistcell*current,*cur;
469 mailimap_section_part * section_part = 0;
470 mailimap_section_spec * section_spec = 0;
471 mailimap_section * section = 0;
472 mailimap_fetch_att * fetch_att = 0;
469 473
470 login(); 474 login();
@@ -481,15 +485,22 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
481 } 485 }
482 set = mailimap_set_new_single(mail.getNumber()); 486 set = mailimap_set_new_single(mail.getNumber());
483 clist*id_list=clist_new();
484 for (unsigned j=0; j < path.count();++j) {
485 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
486 *p_id = path[j];
487 clist_append(id_list,p_id);
488 }
489 mailimap_section_part * section_part = mailimap_section_part_new(id_list);
490 mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
491 mailimap_section * section = mailimap_section_new(section_spec);
492 mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section);
493 487
488 clist*id_list = 0;
489
490 /* if path == empty then its a request for the whole rfc822 mail and generates
491 a "fetch <id> (body[])" statement on imap server */
492 if (path.count()>0 ) {
493 id_list = clist_new();
494 for (unsigned j=0; j < path.count();++j) {
495 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
496 *p_id = path[j];
497 clist_append(id_list,p_id);
498 }
499 section_part = mailimap_section_part_new(id_list);
500 section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
501 }
502
503 section = mailimap_section_new(section_spec);
504 fetch_att = mailimap_fetch_att_new_body_section(section);
494 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); 505 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
495 506
@@ -956,22 +967,26 @@ void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
956 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); 967 r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN);
957 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); 968 r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status);
958 for (cur = clist_begin(status->st_info_list); 969 if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) {
959 cur != NULL ; cur = clist_next(cur)) { 970 for (cur = clist_begin(status->st_info_list);
960 mailimap_status_info * status_info; 971 cur != NULL ; cur = clist_next(cur)) {
961 status_info = (mailimap_status_info *)clist_content(cur); 972 mailimap_status_info * status_info;
962 switch (status_info->st_att) { 973 status_info = (mailimap_status_info *)clist_content(cur);
963 case MAILIMAP_STATUS_ATT_MESSAGES: 974 switch (status_info->st_att) {
964 target_stat.message_count = status_info->st_value; 975 case MAILIMAP_STATUS_ATT_MESSAGES:
965 break; 976 target_stat.message_count = status_info->st_value;
966 case MAILIMAP_STATUS_ATT_RECENT: 977 break;
967 target_stat.message_recent = status_info->st_value; 978 case MAILIMAP_STATUS_ATT_RECENT:
968 break; 979 target_stat.message_recent = status_info->st_value;
969 case MAILIMAP_STATUS_ATT_UNSEEN: 980 break;
970 target_stat.message_unseen = status_info->st_value; 981 case MAILIMAP_STATUS_ATT_UNSEEN:
971 break; 982 target_stat.message_unseen = status_info->st_value;
983 break;
984 }
972 } 985 }
986 } else {
987 qDebug("Error retrieving status");
973 } 988 }
974 mailimap_mailbox_data_status_free(status); 989 if (status) mailimap_mailbox_data_status_free(status);
975 mailimap_status_att_list_free(att_list); 990 if (att_list) mailimap_status_att_list_free(att_list);
976} 991}
977 992
@@ -991,2 +1006,9 @@ const QString&IMAPwrapper::getType()const
991 return account->getType(); 1006 return account->getType();
992} 1007}
1008
1009encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail)
1010{
1011 // dummy
1012 QValueList<int> path;
1013 return fetchRawPart(mail,path,false);
1014}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 6a9c411..b246f58 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -37,4 +37,5 @@ public:
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 virtual encodedString* fetchRawBody(const RecMail&mail);
39 40
40 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false); 41 virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 60f7507..3a0b30a 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -173,5 +173,5 @@ void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folde
173} 173}
174 174
175void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) 175encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail)
176{ 176{
177 RecBody body; 177 RecBody body;
@@ -191,5 +191,5 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
191 mailfolder_free(folder); 191 mailfolder_free(folder);
192 mailstorage_free(storage); 192 mailstorage_free(storage);
193 return; 193 return 0;
194 } 194 }
195 r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg); 195 r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg);
@@ -198,5 +198,5 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
198 mailfolder_free(folder); 198 mailfolder_free(folder);
199 mailstorage_free(storage); 199 mailstorage_free(storage);
200 return; 200 return 0;
201 } 201 }
202 r = mailmessage_fetch(msg,&data,&size); 202 r = mailmessage_fetch(msg,&data,&size);
@@ -206,11 +206,12 @@ void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
206 mailstorage_free(storage); 206 mailstorage_free(storage);
207 mailmessage_free(msg); 207 mailmessage_free(msg);
208 return; 208 return 0;
209 } 209 }
210 *target = data; 210 encodedString*result = new encodedString(data,size);
211 *length = size; 211
212 mailfolder_free(folder); 212 mailfolder_free(folder);
213 mailstorage_free(storage); 213 mailstorage_free(storage);
214 mailmessage_free(msg); 214 mailmessage_free(msg);
215 return result;
215} 216}
216 217
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index f97fce2..2794014 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -7,4 +7,5 @@
7class RecMail; 7class RecMail;
8class RecBody; 8class RecBody;
9class encodedString;
9struct mailmbox_folder; 10struct mailmbox_folder;
10 11
@@ -31,5 +32,5 @@ public:
31 static void mbox_progress( size_t current, size_t maximum ); 32 static void mbox_progress( size_t current, size_t maximum );
32 33
33 virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); 34 virtual encodedString* fetchRawBody(const RecMail&mail);
34 virtual void deleteMails(const QString & mailbox,QList<RecMail> &target); 35 virtual void deleteMails(const QString & mailbox,QList<RecMail> &target);
35 virtual int deleteAllMail(const Folder*); 36 virtual int deleteAllMail(const Folder*);
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 45408dd..72c145b 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -229,10 +229,17 @@ void POP3wrapper::statusFolder(folderStat&target_stat,const QString&)
229} 229}
230 230
231void POP3wrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length) 231encodedString* POP3wrapper::fetchRawBody(const RecMail&mail)
232{ 232{
233 char*target=0;
234 size_t length=0;
235 encodedString*res = 0;
233 mailmessage * mailmsg = 0; 236 mailmessage * mailmsg = 0;
234 int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg); 237 int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg);
235 err = mailmessage_fetch(mailmsg,target,length); 238 err = mailmessage_fetch(mailmsg,&target,&length);
236 if (mailmsg) mailmessage_free(mailmsg); 239 if (mailmsg) mailmessage_free(mailmsg);
240 if (target) {
241 res = new encodedString(target,length);
242 }
243 return res;
237} 244}
238 245
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index b7e8f27..f0307b6 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -6,4 +6,5 @@
6#include <qstring.h> 6#include <qstring.h>
7 7
8class encodedString;
8struct mailstorage; 9struct mailstorage;
9struct mailfolder; 10struct mailfolder;
@@ -27,5 +28,5 @@ public:
27 28
28 virtual RecBody fetchBody( const RecMail &mail ); 29 virtual RecBody fetchBody( const RecMail &mail );
29 virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length); 30 virtual encodedString* fetchRawBody(const RecMail&mail);
30 virtual void logout(); 31 virtual void logout();
31 virtual const QString&getType()const; 32 virtual const QString&getType()const;
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index e054365..00181ff 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -486,5 +486,5 @@ void SMTPwrapper::progress( size_t current, size_t maximum )
486} 486}
487 487
488void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) 488void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box)
489{ 489{
490 if (!mail) return; 490 if (!mail) return;
@@ -537,5 +537,5 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
537} 537}
538 538
539int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) 539int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp )
540{ 540{
541 char *server, *user, *pass; 541 char *server, *user, *pass;
@@ -641,6 +641,4 @@ void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later )
641int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) 641int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
642{ 642{
643 char*data = 0;
644 size_t length = 0;
645 size_t curTok = 0; 643 size_t curTok = 0;
646 mailimf_fields *fields = 0; 644 mailimf_fields *fields = 0;
@@ -650,9 +648,9 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
650 int res = 0; 648 int res = 0;
651 649
652 wrap->fetchRawBody(*which,&data,&length); 650 encodedString * data = wrap->fetchRawBody(*which);
653 if (!data) return 0; 651 if (!data) return 0;
654 int err = mailimf_fields_parse( data, length, &curTok, &fields ); 652 int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields );
655 if (err != MAILIMF_NO_ERROR) { 653 if (err != MAILIMF_NO_ERROR) {
656 free(data); 654 delete data;
657 delete wrap; 655 delete wrap;
658 return 0; 656 return 0;
@@ -663,7 +661,6 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
663 from = getFrom(ffrom); 661 from = getFrom(ffrom);
664 662
665 qDebug("Size: %i vs. %i",length,strlen(data));
666 if (rcpts && from) { 663 if (rcpts && from) {
667 res = smtpSend(from,rcpts,data,length,smtp ); 664 res = smtpSend(from,rcpts,data->Content(),data->Length(),smtp );
668 } 665 }
669 if (fields) { 666 if (fields) {
@@ -672,5 +669,5 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
672 } 669 }
673 if (data) { 670 if (data) {
674 free(data); 671 delete data;
675 } 672 }
676 if (from) { 673 if (from) {
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h
index 4a4352f..04fc4b0 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h
@@ -48,5 +48,5 @@ protected:
48 clist *createRcptList( mailimf_fields *fields ); 48 clist *createRcptList( mailimf_fields *fields );
49 49
50 static void storeMail(char*mail, size_t length, const QString&box); 50 static void storeMail(const char*mail, size_t length, const QString&box);
51 static QString mailsmtpError( int err ); 51 static QString mailsmtpError( int err );
52 static void progress( size_t current, size_t maximum ); 52 static void progress( size_t current, size_t maximum );
@@ -55,5 +55,5 @@ protected:
55 static char *getFrom( mailimf_field *ffrom); 55 static char *getFrom( mailimf_field *ffrom);
56 static mailimf_field *getField( mailimf_fields *fields, int type ); 56 static mailimf_field *getField( mailimf_fields *fields, int type );
57 int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); 57 int smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp );
58 58
59 void storeMail(mailmime*mail, const QString&box); 59 void storeMail(mailmime*mail, const QString&box);