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.cpp16
1 files changed, 15 insertions, 1 deletions
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 }