summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
authorzautrix <zautrix>2004-11-07 19:40:36 (UTC)
committer zautrix <zautrix>2004-11-07 19:40:36 (UTC)
commit90e33436f6d1c502a5620760ac6592b9881ee4ab (patch) (unidiff)
treef493a1eeecd3dc8124bb4c0373b7bda9e85e9863 /kmicromail/libmailwrapper
parentd90d17044d7daf6677074b0964d59f94407157d5 (diff)
downloadkdepimpi-90e33436f6d1c502a5620760ac6592b9881ee4ab.zip
kdepimpi-90e33436f6d1c502a5620760ac6592b9881ee4ab.tar.gz
kdepimpi-90e33436f6d1c502a5620760ac6592b9881ee4ab.tar.bz2
compile fixes and translation updates
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/genericwrapper.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp
index eac05e5..1ed9f34 100644
--- a/kmicromail/libmailwrapper/genericwrapper.cpp
+++ b/kmicromail/libmailwrapper/genericwrapper.cpp
@@ -132,203 +132,205 @@ void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime)
132 case MAILMIME_FIELD_DESCRIPTION: 132 case MAILMIME_FIELD_DESCRIPTION:
133 target->setDescription(field->fld_data.fld_description); 133 target->setDescription(field->fld_data.fld_description);
134 break; 134 break;
135 default: 135 default:
136 break; 136 break;
137 } 137 }
138 } 138 }
139 } 139 }
140} 140}
141 141
142void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) 142void Genericwrapper::fillParameters(RecPartP&target,clist*parameters)
143{ 143{
144 if (!parameters) {return;} 144 if (!parameters) {return;}
145 clistcell*current=0; 145 clistcell*current=0;
146 mailmime_parameter*param; 146 mailmime_parameter*param;
147 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { 147 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
148 param = (mailmime_parameter*)current->data; 148 param = (mailmime_parameter*)current->data;
149 if (param) { 149 if (param) {
150 target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 150 target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
151 } 151 }
152 } 152 }
153} 153}
154 154
155QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) 155QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
156{ 156{
157 QString enc="7bit"; 157 QString enc="7bit";
158 if (!aEnc) return enc; 158 if (!aEnc) return enc;
159 switch(aEnc->enc_type) { 159 switch(aEnc->enc_type) {
160 case MAILMIME_MECHANISM_7BIT: 160 case MAILMIME_MECHANISM_7BIT:
161 enc = "7bit"; 161 enc = "7bit";
162 break; 162 break;
163 case MAILMIME_MECHANISM_8BIT: 163 case MAILMIME_MECHANISM_8BIT:
164 enc = "8bit"; 164 enc = "8bit";
165 break; 165 break;
166 case MAILMIME_MECHANISM_BINARY: 166 case MAILMIME_MECHANISM_BINARY:
167 enc = "binary"; 167 enc = "binary";
168 break; 168 break;
169 case MAILMIME_MECHANISM_QUOTED_PRINTABLE: 169 case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
170 enc = "quoted-printable"; 170 enc = "quoted-printable";
171 break; 171 break;
172 case MAILMIME_MECHANISM_BASE64: 172 case MAILMIME_MECHANISM_BASE64:
173 enc = "base64"; 173 enc = "base64";
174 break; 174 break;
175 case MAILMIME_MECHANISM_TOKEN: 175 case MAILMIME_MECHANISM_TOKEN:
176 default: 176 default:
177 if (aEnc->enc_token) { 177 if (aEnc->enc_token) {
178 enc = QString(aEnc->enc_token); 178 enc = QString(aEnc->enc_token);
179 } 179 }
180 break; 180 break;
181 } 181 }
182 return enc; 182 return enc;
183} 183}
184 184
185void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) 185void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count)
186{ 186{
187 if (current_rec >= 10) { 187 if (current_rec >= 10) {
188 ; // odebug << "too deep recursion!" << oendl; 188 ; // odebug << "too deep recursion!" << oendl;
189 } 189 }
190 if (!message || !mime) { 190 if (!message || !mime) {
191 return; 191 return;
192 } 192 }
193 int r; 193 int r;
194 char*data = 0; 194 char*data = 0;
195 size_t len; 195 size_t len;
196 clistiter * cur = 0; 196 clistiter * cur = 0;
197 QString b; 197 QString b;
198 RecPartP part = new RecPart(); 198 RecPartP part = new RecPart();
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; 223 size_t index = 0;
224 char*resu = 0; 224 char*resu = 0;
225 int err = MAILIMF_NO_ERROR; 225 int err = MAILIMF_NO_ERROR;
226 QString charset = part->searchParamter( "charset"); 226 QString charset = part->searchParamter( "charset");
227 qDebug("CHARSET %s ",charset.latin1() ); 227 qDebug("CHARSET %s ",charset.latin1() );
228#if 0
228 if (false ) { 229 if (false ) {
229 //if ( !charset.isEmpty() ) { 230 //if ( !charset.isEmpty() ) {
230 target->setCharset( charset ); 231 target->setCharset( charset );
231 err = mailmime_encoded_phrase_parse(charset.latin1(), 232 err = mailmime_encoded_phrase_parse(charset.latin1(),
232 b.latin1(), b.length(),&index, "utf-8",&resu); 233 b.latin1(), b.length(),&index, "utf-8",&resu);
233 if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) { 234 if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) {
234 //qDebug("res %d %s ", index, resu); 235 //qDebug("res %d %s ", index, resu);
235 b = QString::fromUtf8(resu); 236 b = QString::fromUtf8(resu);
236 } 237 }
237 if (resu) free(resu); 238 if (resu) free(resu);
238 } 239 }
240#endif
239 target->setBodytext(b); 241 target->setBodytext(b);
240 target->setDescription(part); 242 target->setDescription(part);
241 } else { 243 } else {
242 bodyCache[b]=new encodedString(data,len); 244 bodyCache[b]=new encodedString(data,len);
243 target->addPart(part); 245 target->addPart(part);
244 } 246 }
245 } 247 }
246 break; 248 break;
247 case MAILMIME_MULTIPLE: 249 case MAILMIME_MULTIPLE:
248 { 250 {
249 unsigned int ccount = 1; 251 unsigned int ccount = 1;
250 mailmime*cbody=0; 252 mailmime*cbody=0;
251 QValueList<int>countlist = recList; 253 QValueList<int>countlist = recList;
252 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { 254 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
253 cbody = (mailmime*)clist_content(cur); 255 cbody = (mailmime*)clist_content(cur);
254 if (cbody->mm_type==MAILMIME_MULTIPLE) { 256 if (cbody->mm_type==MAILMIME_MULTIPLE) {
255 RecPartP targetPart = new RecPart(); 257 RecPartP targetPart = new RecPart();
256 targetPart->setType("multipart"); 258 targetPart->setType("multipart");
257 countlist.append(current_count); 259 countlist.append(current_count);
258 targetPart->setPositionlist(countlist); 260 targetPart->setPositionlist(countlist);
259 target->addPart(targetPart); 261 target->addPart(targetPart);
260 } 262 }
261 traverseBody(target,message, cbody,countlist,current_rec+1,ccount); 263 traverseBody(target,message, cbody,countlist,current_rec+1,ccount);
262 if (cbody->mm_type==MAILMIME_MULTIPLE) { 264 if (cbody->mm_type==MAILMIME_MULTIPLE) {
263 countlist = recList; 265 countlist = recList;
264 } 266 }
265 ++ccount; 267 ++ccount;
266 } 268 }
267 } 269 }
268 break; 270 break;
269 case MAILMIME_MESSAGE: 271 case MAILMIME_MESSAGE:
270 { 272 {
271 QValueList<int>countlist = recList; 273 QValueList<int>countlist = recList;
272 countlist.append(current_count); 274 countlist.append(current_count);
273 /* the own header is always at recursion 0 - we don't need that */ 275 /* the own header is always at recursion 0 - we don't need that */
274 if (current_rec > 0) { 276 if (current_rec > 0) {
275 part->setPositionlist(countlist); 277 part->setPositionlist(countlist);
276 r = mailmessage_fetch_section(message,mime,&data,&len); 278 r = mailmessage_fetch_section(message,mime,&data,&len);
277 part->setSize(len); 279 part->setSize(len);
278 part->setPositionlist(countlist); 280 part->setPositionlist(countlist);
279 b = gen_attachment_id(); 281 b = gen_attachment_id();
280 part->setIdentifier(b); 282 part->setIdentifier(b);
281 part->setType("message"); 283 part->setType("message");
282 part->setSubtype("rfc822"); 284 part->setSubtype("rfc822");
283 bodyCache[b]=new encodedString(data,len); 285 bodyCache[b]=new encodedString(data,len);
284 target->addPart(part); 286 target->addPart(part);
285 } 287 }
286 if (mime->mm_data.mm_message.mm_msg_mime != NULL) { 288 if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
287 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); 289 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
288 } 290 }
289 } 291 }
290 break; 292 break;
291 } 293 }
292} 294}
293 295
294RecBodyP Genericwrapper::parseMail( mailmessage * msg ) 296RecBodyP Genericwrapper::parseMail( mailmessage * msg )
295{ 297{
296 int err = MAILIMF_NO_ERROR; 298 int err = MAILIMF_NO_ERROR;
297 //mailmime_single_fields fields; 299 //mailmime_single_fields fields;
298 /* is bound to msg and will be freed there */ 300 /* is bound to msg and will be freed there */
299 mailmime * mime=0; 301 mailmime * mime=0;
300 RecBodyP body = new RecBody(); 302 RecBodyP body = new RecBody();
301 //memset(&fields, 0, sizeof(struct mailmime_single_fields)); 303 //memset(&fields, 0, sizeof(struct mailmime_single_fields));
302 err = mailmessage_get_bodystructure(msg,&mime); 304 err = mailmessage_get_bodystructure(msg,&mime);
303 QValueList<int>recList; 305 QValueList<int>recList;
304 traverseBody(body,msg,mime,recList); 306 traverseBody(body,msg,mime,recList);
305 return body; 307 return body;
306} 308}
307 309
308 310
309QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 311QString Genericwrapper::parseAddressList( mailimf_address_list *list )
310{ 312{
311 QString result( "" ); 313 QString result( "" );
312 314
313 bool first = true; 315 bool first = true;
314 if (list == 0) return result; 316 if (list == 0) return result;
315 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 317 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
316 mailimf_address *addr = (mailimf_address *) current->data; 318 mailimf_address *addr = (mailimf_address *) current->data;
317 319
318 if ( !first ) { 320 if ( !first ) {
319 result.append( "," ); 321 result.append( "," );
320 } else { 322 } else {
321 first = false; 323 first = false;
322 } 324 }
323 325
324 switch ( addr->ad_type ) { 326 switch ( addr->ad_type ) {
325 case MAILIMF_ADDRESS_MAILBOX: 327 case MAILIMF_ADDRESS_MAILBOX:
326 result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); 328 result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
327 break; 329 break;
328 case MAILIMF_ADDRESS_GROUP: 330 case MAILIMF_ADDRESS_GROUP:
329 result.append( parseGroup( addr->ad_data.ad_group ) ); 331 result.append( parseGroup( addr->ad_data.ad_group ) );
330 break; 332 break;
331 default: 333 default:
332 ; // odebug << "Generic: unkown mailimf address type" << oendl; 334 ; // odebug << "Generic: unkown mailimf address type" << oendl;
333 break; 335 break;
334 } 336 }