-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 9 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 16 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 19 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mboxwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 1 |
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 | |||
@@ -63,56 +63,57 @@ encodedString* AbstractMail::decode_String(const encodedString*text,const QStrin | |||
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 | ||
91 | QString AbstractMail::convert_String(const char*text) | 90 | QString 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 */ |
110 | QString AbstractMail::gen_attachment_id() | 111 | QString 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() + "}"; |
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 | |||
@@ -207,32 +207,46 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m | |||
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) { |
@@ -331,33 +345,33 @@ QString Genericwrapper::parseGroup( mailimf_group *group ) | |||
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 | ||
340 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 354 | QString 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 | ||
356 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | 370 | QString 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 | ||
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 | |||
@@ -739,32 +739,51 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t | |||
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 | { |
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 | |||
@@ -112,32 +112,33 @@ RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail ) | |||
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 | ||
136 | void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) | 137 | void 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 | ||
141 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) | 142 | int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) |
142 | { | 143 | { |
143 | QString p = MBOXPath+"/"; | 144 | QString p = MBOXPath+"/"; |
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 | |||
@@ -115,32 +115,33 @@ void MHwrapper::deleteMail(const RecMailP&mail) | |||
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 | ||
125 | void MHwrapper::answeredMail(const RecMailP&) | 125 | void MHwrapper::answeredMail(const RecMailP&) |
126 | { | 126 | { |
127 | } | 127 | } |
128 | 128 | ||
129 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) | 129 | RecBodyP 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 "); |