summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/genericwrapper.cpp
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper/genericwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp
index 0b6adf7..633ab42 100644
--- a/kmicromail/libmailwrapper/genericwrapper.cpp
+++ b/kmicromail/libmailwrapper/genericwrapper.cpp
@@ -1,20 +1,22 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2#include "genericwrapper.h" 2#include "genericwrapper.h"
3#include <libetpan/libetpan.h> 3#include <libetpan/libetpan.h>
4#include "mailtypes.h" 4#include "mailtypes.h"
5 5
6#include <kconfig.h> 6#include <kconfig.h>
7#include <kglobal.h> 7#include <kglobal.h>
8#include <kstandarddirs.h> 8#include <kstandarddirs.h>
9//Added by qt3to4:
10#include <Q3ValueList>
9 11
10 12
11using namespace Opie::Core; 13using namespace Opie::Core;
12Genericwrapper::Genericwrapper() 14Genericwrapper::Genericwrapper()
13 : AbstractMail() 15 : AbstractMail()
14{ 16{
15 bodyCache.clear(); 17 bodyCache.clear();
16 m_storage = 0; 18 m_storage = 0;
17 m_folder = 0; 19 m_folder = 0;
18} 20}
19 21
20Genericwrapper::~Genericwrapper() 22Genericwrapper::~Genericwrapper()
@@ -173,43 +175,43 @@ QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
173 enc = "base64"; 175 enc = "base64";
174 break; 176 break;
175 case MAILMIME_MECHANISM_TOKEN: 177 case MAILMIME_MECHANISM_TOKEN:
176 default: 178 default:
177 if (aEnc->enc_token) { 179 if (aEnc->enc_token) {
178 enc = QString(aEnc->enc_token); 180 enc = QString(aEnc->enc_token);
179 } 181 }
180 break; 182 break;
181 } 183 }
182 return enc; 184 return enc;
183} 185}
184 186
185void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) 187void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,Q3ValueList<int>recList,unsigned int current_rec,int current_count)
186{ 188{
187 if (current_rec >= 10) { 189 if (current_rec >= 10) {
188 ; // odebug << "too deep recursion!" << oendl; 190 ; // odebug << "too deep recursion!" << oendl;
189 } 191 }
190 if (!message || !mime) { 192 if (!message || !mime) {
191 return; 193 return;
192 } 194 }
193 int r; 195 int r;
194 char*data = 0; 196 char*data = 0;
195 size_t len; 197 size_t len;
196 clistiter * cur = 0; 198 clistiter * cur = 0;
197 QString b; 199 QString b;
198 RecPartP part = new RecPart(); 200 RecPartP part = new RecPart();
199 201
200 switch (mime->mm_type) { 202 switch (mime->mm_type) {
201 case MAILMIME_SINGLE: 203 case MAILMIME_SINGLE:
202 { 204 {
203 QValueList<int>countlist = recList; 205 Q3ValueList<int>countlist = recList;
204 countlist.append(current_count); 206 countlist.append(current_count);
205 r = mailmessage_fetch_section(message,mime,&data,&len); 207 r = mailmessage_fetch_section(message,mime,&data,&len);
206 part->setSize(len); 208 part->setSize(len);
207 part->setPositionlist(countlist); 209 part->setPositionlist(countlist);
208 b = gen_attachment_id(); 210 b = gen_attachment_id();
209 part->setIdentifier(b); 211 part->setIdentifier(b);
210 fillSingleBody(part,message,mime); 212 fillSingleBody(part,message,mime);
211 if (part->Type()=="text" && target->Bodytext().isNull()) { 213 if (part->Type()=="text" && target->Bodytext().isNull()) {
212 encodedString*rs = new encodedString(); 214 encodedString*rs = new encodedString();
213 rs->setContent(data,len); 215 rs->setContent(data,len);
214 encodedString*res = decode_String(rs,part->Encoding()); 216 encodedString*res = decode_String(rs,part->Encoding());
215 if (countlist.count()>2) { 217 if (countlist.count()>2) {
@@ -241,45 +243,45 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m
241 target->setBodytext(b); 243 target->setBodytext(b);
242 target->setDescription(part); 244 target->setDescription(part);
243 } else { 245 } else {
244 bodyCache[b]=new encodedString(data,len); 246 bodyCache[b]=new encodedString(data,len);
245 target->addPart(part); 247 target->addPart(part);
246 } 248 }
247 } 249 }
248 break; 250 break;
249 case MAILMIME_MULTIPLE: 251 case MAILMIME_MULTIPLE:
250 { 252 {
251 unsigned int ccount = 1; 253 unsigned int ccount = 1;
252 mailmime*cbody=0; 254 mailmime*cbody=0;
253 QValueList<int>countlist = recList; 255 Q3ValueList<int>countlist = recList;
254 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { 256 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
255 cbody = (mailmime*)clist_content(cur); 257 cbody = (mailmime*)clist_content(cur);
256 if (cbody->mm_type==MAILMIME_MULTIPLE) { 258 if (cbody->mm_type==MAILMIME_MULTIPLE) {
257 RecPartP targetPart = new RecPart(); 259 RecPartP targetPart = new RecPart();
258 targetPart->setType("multipart"); 260 targetPart->setType("multipart");
259 countlist.append(current_count); 261 countlist.append(current_count);
260 targetPart->setPositionlist(countlist); 262 targetPart->setPositionlist(countlist);
261 target->addPart(targetPart); 263 target->addPart(targetPart);
262 } 264 }
263 traverseBody(target,message, cbody,countlist,current_rec+1,ccount); 265 traverseBody(target,message, cbody,countlist,current_rec+1,ccount);
264 if (cbody->mm_type==MAILMIME_MULTIPLE) { 266 if (cbody->mm_type==MAILMIME_MULTIPLE) {
265 countlist = recList; 267 countlist = recList;
266 } 268 }
267 ++ccount; 269 ++ccount;
268 } 270 }
269 } 271 }
270 break; 272 break;
271 case MAILMIME_MESSAGE: 273 case MAILMIME_MESSAGE:
272 { 274 {
273 QValueList<int>countlist = recList; 275 Q3ValueList<int>countlist = recList;
274 countlist.append(current_count); 276 countlist.append(current_count);
275 /* the own header is always at recursion 0 - we don't need that */ 277 /* the own header is always at recursion 0 - we don't need that */
276 if (current_rec > 0) { 278 if (current_rec > 0) {
277 part->setPositionlist(countlist); 279 part->setPositionlist(countlist);
278 r = mailmessage_fetch_section(message,mime,&data,&len); 280 r = mailmessage_fetch_section(message,mime,&data,&len);
279 part->setSize(len); 281 part->setSize(len);
280 part->setPositionlist(countlist); 282 part->setPositionlist(countlist);
281 b = gen_attachment_id(); 283 b = gen_attachment_id();
282 part->setIdentifier(b); 284 part->setIdentifier(b);
283 part->setType("message"); 285 part->setType("message");
284 part->setSubtype("rfc822"); 286 part->setSubtype("rfc822");
285 bodyCache[b]=new encodedString(data,len); 287 bodyCache[b]=new encodedString(data,len);
@@ -293,25 +295,25 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m
293 } 295 }
294} 296}
295 297
296RecBodyP Genericwrapper::parseMail( mailmessage * msg ) 298RecBodyP Genericwrapper::parseMail( mailmessage * msg )
297{ 299{
298 int err = MAILIMF_NO_ERROR; 300 int err = MAILIMF_NO_ERROR;
299 //mailmime_single_fields fields; 301 //mailmime_single_fields fields;
300 /* is bound to msg and will be freed there */ 302 /* is bound to msg and will be freed there */
301 mailmime * mime=0; 303 mailmime * mime=0;
302 RecBodyP body = new RecBody(); 304 RecBodyP body = new RecBody();
303 //memset(&fields, 0, sizeof(struct mailmime_single_fields)); 305 //memset(&fields, 0, sizeof(struct mailmime_single_fields));
304 err = mailmessage_get_bodystructure(msg,&mime); 306 err = mailmessage_get_bodystructure(msg,&mime);
305 QValueList<int>recList; 307 Q3ValueList<int>recList;
306 traverseBody(body,msg,mime,recList); 308 traverseBody(body,msg,mime,recList);
307 return body; 309 return body;
308} 310}
309 311
310 312
311QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 313QString Genericwrapper::parseAddressList( mailimf_address_list *list )
312{ 314{
313 QString result( "" ); 315 QString result( "" );
314 316
315 bool first = true; 317 bool first = true;
316 if (list == 0) return result; 318 if (list == 0) return result;
317 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 319 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
@@ -438,25 +440,25 @@ QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies)
438 h.remove(0,1); 440 h.remove(0,1);
439 } 441 }
440 while (h.length()>0 && h[h.length()-1]=='>') { 442 while (h.length()>0 && h[h.length()-1]=='>') {
441 h.remove(h.length()-1,1); 443 h.remove(h.length()-1,1);
442 } 444 }
443 if (h.length()>0) { 445 if (h.length()>0) {
444 res.append(h); 446 res.append(h);
445 } 447 }
446 } 448 }
447 return res; 449 return res;
448} 450}
449 451
450void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb) 452void Genericwrapper::parseList(Q3ValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to, int maxSizeInKb)
451{ 453{
452 int r; 454 int r;
453 mailmessage_list * env_list = 0; 455 mailmessage_list * env_list = 0;
454 r = mailsession_get_messages_list(session,&env_list); 456 r = mailsession_get_messages_list(session,&env_list);
455 if (r != MAIL_NO_ERROR) { 457 if (r != MAIL_NO_ERROR) {
456 ; // odebug << "Error message list" << oendl; 458 ; // odebug << "Error message list" << oendl;
457 return; 459 return;
458 } 460 }
459 r = mailsession_get_envelopes_list(session, env_list); 461 r = mailsession_get_envelopes_list(session, env_list);
460 if (r != MAIL_NO_ERROR) { 462 if (r != MAIL_NO_ERROR) {
461 ; // odebug << "Error filling message list" << oendl; 463 ; // odebug << "Error filling message list" << oendl;
462 if (env_list) { 464 if (env_list) {