summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/abstractmail.cpp9
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.cpp16
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp19
-rw-r--r--kmicromail/libmailwrapper/mboxwrapper.cpp1
-rw-r--r--kmicromail/libmailwrapper/mhwrapper.cpp1
5 files changed, 41 insertions, 5 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp
index 8ee112c..ed5c898 100644
--- a/kmicromail/libmailwrapper/abstractmail.cpp
+++ b/kmicromail/libmailwrapper/abstractmail.cpp
@@ -55,72 +55,73 @@ AbstractMail* AbstractMail::getWrapper(Account*a)
55 break; 55 break;
56 default: 56 default:
57 return 0; 57 return 0;
58 } 58 }
59} 59}
60 60
61encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) 61encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc)
62{ 62{
63 // odebug << "Decode string start" << oendl; 63 // odebug << "Decode string start" << oendl;
64 char*result_text; 64 char*result_text;
65 size_t index = 0; 65 size_t index = 0;
66 /* reset for recursive use! */ 66 /* reset for recursive use! */
67 size_t target_length = 0; 67 size_t target_length = 0;
68 result_text = 0; 68 result_text = 0;
69 int mimetype = MAILMIME_MECHANISM_7BIT; 69 int mimetype = MAILMIME_MECHANISM_7BIT;
70 if (enc.lower()=="quoted-printable") { 70 if (enc.lower()=="quoted-printable") {
71 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 71 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
72 } else if (enc.lower()=="base64") { 72 } else if (enc.lower()=="base64") {
73 mimetype = MAILMIME_MECHANISM_BASE64; 73 mimetype = MAILMIME_MECHANISM_BASE64;
74 } else if (enc.lower()=="8bit") { 74 } else if (enc.lower()=="8bit") {
75 mimetype = MAILMIME_MECHANISM_8BIT; 75 mimetype = MAILMIME_MECHANISM_8BIT;
76 } else if (enc.lower()=="binary") { 76 } else if (enc.lower()=="binary") {
77 mimetype = MAILMIME_MECHANISM_BINARY; 77 mimetype = MAILMIME_MECHANISM_BINARY;
78 } 78 }
79
80 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, 79 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
81 &result_text,&target_length); 80 &result_text,&target_length);
82 81
83 encodedString* result = new encodedString(); 82 encodedString* result = new encodedString();
84 if (err == MAILIMF_NO_ERROR) { 83 if (err == MAILIMF_NO_ERROR) {
85 result->setContent(result_text,target_length); 84 result->setContent(result_text,target_length);
86 } 85 }
87 //odebug << "Decode string finished" << oendl; 86 //odebug << "Decode string finished" << oendl;
88 return result; 87 return result;
89} 88}
90 89
91QString AbstractMail::convert_String(const char*text) 90QString AbstractMail::convert_String(const char*text)
92{ 91{
93 size_t index = 0; 92 size_t index = 0;
94 char*res = 0; 93 char*res = 0;
95 int err = MAILIMF_NO_ERROR; 94 int err = MAILIMF_NO_ERROR;
96 95
97 QString result(text); 96 QString result(text);
98 97 //qDebug("convert_String %s ", text);
98 //err = mailmime_encoded_phrase_parse("iso-8859-1",
99 // text, strlen(text),&index, "iso-8859-1",&res);
99 err = mailmime_encoded_phrase_parse("iso-8859-1", 100 err = mailmime_encoded_phrase_parse("iso-8859-1",
100 text, strlen(text),&index, "iso-8859-1",&res); 101 text, strlen(text),&index, "utf-8",&res);
101 if (err == MAILIMF_NO_ERROR && res && strlen(res)) { 102 if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
102 result = QString(res); 103 result = QString::fromUtf8(res);
103 } 104 }
104 //qDebug("convert_String:%s ",result.latin1() ); 105 //qDebug("convert_String:%s ",result.latin1() );
105 if (res) free(res); 106 if (res) free(res);
106 return result; 107 return result;
107} 108}
108 109
109/* cp & paste from launcher */ 110/* cp & paste from launcher */
110QString AbstractMail::gen_attachment_id() 111QString AbstractMail::gen_attachment_id()
111{ 112{
112 QFile file( "/proc/sys/kernel/random/uuid" ); 113 QFile file( "/proc/sys/kernel/random/uuid" );
113 if (!file.open(IO_ReadOnly ) ) 114 if (!file.open(IO_ReadOnly ) )
114 return QString::null; 115 return QString::null;
115 116
116 QTextStream stream(&file); 117 QTextStream stream(&file);
117 118
118 return "{" + stream.read().stripWhiteSpace() + "}"; 119 return "{" + stream.read().stripWhiteSpace() + "}";
119} 120}
120 121
121int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) 122int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool)
122{ 123{
123 return 0; 124 return 0;
124} 125}
125 126
126QString AbstractMail::defaultLocalfolder() 127QString AbstractMail::defaultLocalfolder()
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp
index d89a5f9..49227dd 100644
--- a/kmicromail/libmailwrapper/genericwrapper.cpp
+++ b/kmicromail/libmailwrapper/genericwrapper.cpp
@@ -199,48 +199,62 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m
199 199
200 switch (mime->mm_type) { 200 switch (mime->mm_type) {
201 case MAILMIME_SINGLE: 201 case MAILMIME_SINGLE:
202 { 202 {
203 QValueList<int>countlist = recList; 203 QValueList<int>countlist = recList;
204 countlist.append(current_count); 204 countlist.append(current_count);
205 r = mailmessage_fetch_section(message,mime,&data,&len); 205 r = mailmessage_fetch_section(message,mime,&data,&len);
206 part->setSize(len); 206 part->setSize(len);
207 part->setPositionlist(countlist); 207 part->setPositionlist(countlist);
208 b = gen_attachment_id(); 208 b = gen_attachment_id();
209 part->setIdentifier(b); 209 part->setIdentifier(b);
210 fillSingleBody(part,message,mime); 210 fillSingleBody(part,message,mime);
211 if (part->Type()=="text" && target->Bodytext().isNull()) { 211 if (part->Type()=="text" && target->Bodytext().isNull()) {
212 encodedString*rs = new encodedString(); 212 encodedString*rs = new encodedString();
213 rs->setContent(data,len); 213 rs->setContent(data,len);
214 encodedString*res = decode_String(rs,part->Encoding()); 214 encodedString*res = decode_String(rs,part->Encoding());
215 if (countlist.count()>2) { 215 if (countlist.count()>2) {
216 bodyCache[b]=rs; 216 bodyCache[b]=rs;
217 target->addPart(part); 217 target->addPart(part);
218 } else { 218 } else {
219 delete rs; 219 delete rs;
220 } 220 }
221 b = QString(res->Content()); 221 b = QString(res->Content());
222 delete res; 222 delete res;
223 size_t index = 0;
224 char*resu = 0;
225 int err = MAILIMF_NO_ERROR;
226 QString charset = part->searchParamter( "charset");
227 qDebug("CHARSET %s ",charset.latin1() );
228 if ( !charset.isEmpty() ) {
229 err = mailmime_encoded_phrase_parse(charset.latin1(),
230 b.latin1(), b.length(),&index, "utf-8",&resu);
231 if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) {
232 //qDebug("res %d %s ", index, resu);
233 b = QString::fromUtf8(resu);
234 }
235 if (resu) free(resu);
236 }
223 target->setBodytext(b); 237 target->setBodytext(b);
224 target->setDescription(part); 238 target->setDescription(part);
225 } else { 239 } else {
226 bodyCache[b]=new encodedString(data,len); 240 bodyCache[b]=new encodedString(data,len);
227 target->addPart(part); 241 target->addPart(part);
228 } 242 }
229 } 243 }
230 break; 244 break;
231 case MAILMIME_MULTIPLE: 245 case MAILMIME_MULTIPLE:
232 { 246 {
233 unsigned int ccount = 1; 247 unsigned int ccount = 1;
234 mailmime*cbody=0; 248 mailmime*cbody=0;
235 QValueList<int>countlist = recList; 249 QValueList<int>countlist = recList;
236 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { 250 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
237 cbody = (mailmime*)clist_content(cur); 251 cbody = (mailmime*)clist_content(cur);
238 if (cbody->mm_type==MAILMIME_MULTIPLE) { 252 if (cbody->mm_type==MAILMIME_MULTIPLE) {
239 RecPartP targetPart = new RecPart(); 253 RecPartP targetPart = new RecPart();
240 targetPart->setType("multipart"); 254 targetPart->setType("multipart");
241 countlist.append(current_count); 255 countlist.append(current_count);
242 targetPart->setPositionlist(countlist); 256 targetPart->setPositionlist(countlist);
243 target->addPart(targetPart); 257 target->addPart(targetPart);
244 } 258 }
245 traverseBody(target,message, cbody,countlist,current_rec+1,ccount); 259 traverseBody(target,message, cbody,countlist,current_rec+1,ccount);
246 if (cbody->mm_type==MAILMIME_MULTIPLE) { 260 if (cbody->mm_type==MAILMIME_MULTIPLE) {
@@ -323,49 +337,49 @@ QString Genericwrapper::parseAddressList( mailimf_address_list *list )
323 337
324QString Genericwrapper::parseGroup( mailimf_group *group ) 338QString Genericwrapper::parseGroup( mailimf_group *group )
325{ 339{
326 QString result( "" ); 340 QString result( "" );
327 341
328 result.append( group->grp_display_name ); 342 result.append( group->grp_display_name );
329 result.append( ": " ); 343 result.append( ": " );
330 344
331 if ( group->grp_mb_list != NULL ) { 345 if ( group->grp_mb_list != NULL ) {
332 result.append( parseMailboxList( group->grp_mb_list ) ); 346 result.append( parseMailboxList( group->grp_mb_list ) );
333 } 347 }
334 348
335 result.append( ";" ); 349 result.append( ";" );
336 350
337 return result; 351 return result;
338} 352}
339 353
340QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) 354QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
341{ 355{
342 QString result( "" ); 356 QString result( "" );
343 357
344 if ( box->mb_display_name == NULL ) { 358 if ( box->mb_display_name == NULL ) {
345 result.append( box->mb_addr_spec ); 359 result.append( box->mb_addr_spec );
346 } else { 360 } else {
347 result.append( convert_String(box->mb_display_name).latin1() ); 361 result.append( convert_String(box->mb_display_name) );
348 result.append( " <" ); 362 result.append( " <" );
349 result.append( box->mb_addr_spec ); 363 result.append( box->mb_addr_spec );
350 result.append( ">" ); 364 result.append( ">" );
351 } 365 }
352 366
353 return result; 367 return result;
354} 368}
355 369
356QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) 370QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
357{ 371{
358 QString result( "" ); 372 QString result( "" );
359 373
360 bool first = true; 374 bool first = true;
361 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { 375 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
362 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 376 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
363 377
364 if ( !first ) { 378 if ( !first ) {
365 result.append( "," ); 379 result.append( "," );
366 } else { 380 } else {
367 first = false; 381 first = false;
368 } 382 }
369 383
370 result.append( parseMailbox( box ) ); 384 result.append( parseMailbox( box ) );
371 } 385 }
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index d90a8d2..eb2b47d 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -731,48 +731,67 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t
731{ 731{
732 if (!body || current_recursion>=10) { 732 if (!body || current_recursion>=10) {
733 return; 733 return;
734 } 734 }
735 switch (body->bd_type) { 735 switch (body->bd_type) {
736 case MAILIMAP_BODY_1PART: 736 case MAILIMAP_BODY_1PART:
737 { 737 {
738 QValueList<int>countlist = recList; 738 QValueList<int>countlist = recList;
739 countlist.append(current_count); 739 countlist.append(current_count);
740 RecPartP currentPart = new RecPart(); 740 RecPartP currentPart = new RecPart();
741 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; 741 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
742 QString id(""); 742 QString id("");
743 currentPart->setPositionlist(countlist); 743 currentPart->setPositionlist(countlist);
744 for (unsigned int j = 0; j < countlist.count();++j) { 744 for (unsigned int j = 0; j < countlist.count();++j) {
745 id+=(j>0?" ":""); 745 id+=(j>0?" ":"");
746 id+=QString("%1").arg(countlist[j]); 746 id+=QString("%1").arg(countlist[j]);
747 } 747 }
748 //odebug << "ID = " << id.latin1() << "" << oendl; 748 //odebug << "ID = " << id.latin1() << "" << oendl;
749 currentPart->setIdentifier(id); 749 currentPart->setIdentifier(id);
750 fillSinglePart(currentPart,part1); 750 fillSinglePart(currentPart,part1);
751 /* important: Check for is NULL 'cause a body can be empty! 751 /* important: Check for is NULL 'cause a body can be empty!
752 And we put it only into the mail if it is the FIRST part */ 752 And we put it only into the mail if it is the FIRST part */
753 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { 753 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
754 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); 754 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
755
756 size_t index = 0;
757 char*res = 0;
758 int err = MAILIMF_NO_ERROR;
759
760 QString charset = currentPart->searchParamter( "charset");
761 qDebug("CHARSET %s ",charset.latin1() );
762 //if ( false ) {
763 if ( !charset.isEmpty() ) {
764 //err = mailmime_encoded_phrase_parse("iso-8859-1",
765 // text, strlen(text),&index, "iso-8859-1",&res);
766 err = mailmime_encoded_phrase_parse(charset.latin1(),
767 body_text.latin1(), body_text.length(),&index, "utf-8",&res);
768 if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
769 //qDebug("res %d %s ", index, res);
770 body_text = QString::fromUtf8(res);
771 }
772 if (res) free(res);
773 }
755 //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); 774 //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() );
756 target_body->setDescription(currentPart); 775 target_body->setDescription(currentPart);
757 target_body->setBodytext(body_text); 776 target_body->setBodytext(body_text);
758 if (countlist.count()>1) { 777 if (countlist.count()>1) {
759 target_body->addPart(currentPart); 778 target_body->addPart(currentPart);
760 } 779 }
761 } else { 780 } else {
762 target_body->addPart(currentPart); 781 target_body->addPart(currentPart);
763 } 782 }
764 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { 783 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
765 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); 784 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
766 } 785 }
767 } 786 }
768 break; 787 break;
769 case MAILIMAP_BODY_MPART: 788 case MAILIMAP_BODY_MPART:
770 { 789 {
771 QValueList<int>countlist = recList; 790 QValueList<int>countlist = recList;
772 clistcell*current=0; 791 clistcell*current=0;
773 mailimap_body*current_body=0; 792 mailimap_body*current_body=0;
774 unsigned int ccount = 1; 793 unsigned int ccount = 1;
775 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; 794 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
776 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { 795 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
777 current_body = (mailimap_body*)current->data; 796 current_body = (mailimap_body*)current->data;
778 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 797 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
diff --git a/kmicromail/libmailwrapper/mboxwrapper.cpp b/kmicromail/libmailwrapper/mboxwrapper.cpp
index 0cdbae4..87f8c8a 100644
--- a/kmicromail/libmailwrapper/mboxwrapper.cpp
+++ b/kmicromail/libmailwrapper/mboxwrapper.cpp
@@ -104,48 +104,49 @@ RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail )
104 mailfolder*folder; 104 mailfolder*folder;
105 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 105 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
106 r = mailfolder_connect(folder); 106 r = mailfolder_connect(folder);
107 if (r != MAIL_NO_ERROR) { 107 if (r != MAIL_NO_ERROR) {
108 ; // << "Error initializing mbox" << oendl; 108 ; // << "Error initializing mbox" << oendl;
109 mailfolder_free(folder); 109 mailfolder_free(folder);
110 mailstorage_free(storage); 110 mailstorage_free(storage);
111 return body; 111 return body;
112 } 112 }
113 r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); 113 r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg);
114 if (r != MAIL_NO_ERROR) { 114 if (r != MAIL_NO_ERROR) {
115 ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; 115 ; // << "Error fetching mail " << mail->getNumber() << "" << oendl;
116 mailfolder_free(folder); 116 mailfolder_free(folder);
117 mailstorage_free(storage); 117 mailstorage_free(storage);
118 return body; 118 return body;
119 } 119 }
120 r = mailmessage_fetch(msg,&data,&size); 120 r = mailmessage_fetch(msg,&data,&size);
121 if (r != MAIL_NO_ERROR) { 121 if (r != MAIL_NO_ERROR) {
122 ; // << "Error fetching mail " << mail->getNumber() << "" << oendl; 122 ; // << "Error fetching mail " << mail->getNumber() << "" << oendl;
123 mailfolder_free(folder); 123 mailfolder_free(folder);
124 mailstorage_free(storage); 124 mailstorage_free(storage);
125 mailmessage_free(msg); 125 mailmessage_free(msg);
126 return body; 126 return body;
127 } 127 }
128 qDebug("MBOXwrapper::fetchBody ");
128 body = parseMail(msg); 129 body = parseMail(msg);
129 mailmessage_fetch_result_free(msg,data); 130 mailmessage_fetch_result_free(msg,data);
130 mailfolder_free(folder); 131 mailfolder_free(folder);
131 mailstorage_free(storage); 132 mailstorage_free(storage);
132 133
133 return body; 134 return body;
134} 135}
135 136
136void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) 137void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
137{ 138{
138 ; // << "MBOX " << current << " von " << maximum << "" << oendl; 139 ; // << "MBOX " << current << " von " << maximum << "" << oendl;
139} 140}
140 141
141int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) 142int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool )
142{ 143{
143 QString p = MBOXPath+"/"; 144 QString p = MBOXPath+"/";
144 p+=folder; 145 p+=folder;
145 QFileInfo fi(p); 146 QFileInfo fi(p);
146 if (fi.exists()) { 147 if (fi.exists()) {
147 Global::statusMessage(i18n("Mailbox exists.")); 148 Global::statusMessage(i18n("Mailbox exists."));
148 return 0; 149 return 0;
149 } 150 }
150 mailmbox_folder*f = 0; 151 mailmbox_folder*f = 0;
151 if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { 152 if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) {
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp
index 90b5d23..982d7a6 100644
--- a/kmicromail/libmailwrapper/mhwrapper.cpp
+++ b/kmicromail/libmailwrapper/mhwrapper.cpp
@@ -107,48 +107,49 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders()
107 107
108void MHwrapper::deleteMail(const RecMailP&mail) 108void MHwrapper::deleteMail(const RecMailP&mail)
109{ 109{
110 init_storage(); 110 init_storage();
111 if (!m_storage) { 111 if (!m_storage) {
112 return; 112 return;
113 } 113 }
114 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 114 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
115 if (r!=MAIL_NO_ERROR) { 115 if (r!=MAIL_NO_ERROR) {
116 qDebug("error selecting folder! "); 116 qDebug("error selecting folder! ");
117 return; 117 return;
118 } 118 }
119 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); 119 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber());
120 if (r != MAIL_NO_ERROR) { 120 if (r != MAIL_NO_ERROR) {
121 qDebug("error deleting mail "); 121 qDebug("error deleting mail ");
122 } 122 }
123} 123}
124 124
125void MHwrapper::answeredMail(const RecMailP&) 125void MHwrapper::answeredMail(const RecMailP&)
126{ 126{
127} 127}
128 128
129RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) 129RecBodyP MHwrapper::fetchBody( const RecMailP &mail )
130{ 130{
131 qDebug("MHwrapper::fetchBody ");
131 RecBodyP body = new RecBody(); 132 RecBodyP body = new RecBody();
132 init_storage(); 133 init_storage();
133 if (!m_storage) { 134 if (!m_storage) {
134 return body; 135 return body;
135 } 136 }
136 mailmessage * msg; 137 mailmessage * msg;
137 char*data=0; 138 char*data=0;
138 139
139 /* mail should hold the complete path! */ 140 /* mail should hold the complete path! */
140 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 141 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
141 if (r != MAIL_NO_ERROR) { 142 if (r != MAIL_NO_ERROR) {
142 return body; 143 return body;
143 } 144 }
144 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); 145 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
145 if (r != MAIL_NO_ERROR) { 146 if (r != MAIL_NO_ERROR) {
146 qDebug("Error fetching mail "); 147 qDebug("Error fetching mail ");
147 148
148 return body; 149 return body;
149 } 150 }
150 body = parseMail(msg); 151 body = parseMail(msg);
151 mailmessage_fetch_result_free(msg,data); 152 mailmessage_fetch_result_free(msg,data);
152 return body; 153 return body;
153} 154}
154 155