author | alwin <alwin> | 2004-03-07 02:15:06 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-07 02:15:06 (UTC) |
commit | df4f3107d45976d9276ef96df4683822cf05d38c (patch) (unidiff) | |
tree | 1a9f021791cac577d82a71af7d9d8b57756304b8 | |
parent | 9b3af0c792777462126317a0335d2c355b4d8b13 (diff) | |
download | opie-df4f3107d45976d9276ef96df4683822cf05d38c.zip opie-df4f3107d45976d9276ef96df4683822cf05d38c.tar.gz opie-df4f3107d45976d9276ef96df4683822cf05d38c.tar.bz2 |
removed debug output which will realy slow down things
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index b1e4459..350808a 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -87,426 +87,426 @@ void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) | |||
87 | } | 87 | } |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void Genericwrapper::fillParameters(RecPart&target,clist*parameters) | 91 | void Genericwrapper::fillParameters(RecPart&target,clist*parameters) |
92 | { | 92 | { |
93 | if (!parameters) {return;} | 93 | if (!parameters) {return;} |
94 | clistcell*current=0; | 94 | clistcell*current=0; |
95 | mailmime_parameter*param; | 95 | mailmime_parameter*param; |
96 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { | 96 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { |
97 | param = (mailmime_parameter*)current->data; | 97 | param = (mailmime_parameter*)current->data; |
98 | if (param) { | 98 | if (param) { |
99 | target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 99 | target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | 104 | QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) |
105 | { | 105 | { |
106 | QString enc="7bit"; | 106 | QString enc="7bit"; |
107 | if (!aEnc) return enc; | 107 | if (!aEnc) return enc; |
108 | switch(aEnc->enc_type) { | 108 | switch(aEnc->enc_type) { |
109 | case MAILMIME_MECHANISM_7BIT: | 109 | case MAILMIME_MECHANISM_7BIT: |
110 | enc = "7bit"; | 110 | enc = "7bit"; |
111 | break; | 111 | break; |
112 | case MAILMIME_MECHANISM_8BIT: | 112 | case MAILMIME_MECHANISM_8BIT: |
113 | enc = "8bit"; | 113 | enc = "8bit"; |
114 | break; | 114 | break; |
115 | case MAILMIME_MECHANISM_BINARY: | 115 | case MAILMIME_MECHANISM_BINARY: |
116 | enc = "binary"; | 116 | enc = "binary"; |
117 | break; | 117 | break; |
118 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 118 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
119 | enc = "quoted-printable"; | 119 | enc = "quoted-printable"; |
120 | break; | 120 | break; |
121 | case MAILMIME_MECHANISM_BASE64: | 121 | case MAILMIME_MECHANISM_BASE64: |
122 | enc = "base64"; | 122 | enc = "base64"; |
123 | break; | 123 | break; |
124 | case MAILMIME_MECHANISM_TOKEN: | 124 | case MAILMIME_MECHANISM_TOKEN: |
125 | default: | 125 | default: |
126 | if (aEnc->enc_token) { | 126 | if (aEnc->enc_token) { |
127 | enc = QString(aEnc->enc_token); | 127 | enc = QString(aEnc->enc_token); |
128 | } | 128 | } |
129 | break; | 129 | break; |
130 | } | 130 | } |
131 | return enc; | 131 | return enc; |
132 | } | 132 | } |
133 | 133 | ||
134 | void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 134 | void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
135 | { | 135 | { |
136 | if (current_rec >= 10) { | 136 | if (current_rec >= 10) { |
137 | qDebug("too deep recursion!"); | 137 | qDebug("too deep recursion!"); |
138 | } | 138 | } |
139 | if (!message || !mime) { | 139 | if (!message || !mime) { |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | int r; | 142 | int r; |
143 | char*data = 0; | 143 | char*data = 0; |
144 | size_t len; | 144 | size_t len; |
145 | clistiter * cur = 0; | 145 | clistiter * cur = 0; |
146 | QString b; | 146 | QString b; |
147 | RecPart part; | 147 | RecPart part; |
148 | 148 | ||
149 | switch (mime->mm_type) { | 149 | switch (mime->mm_type) { |
150 | case MAILMIME_SINGLE: | 150 | case MAILMIME_SINGLE: |
151 | { | 151 | { |
152 | QValueList<int>countlist = recList; | 152 | QValueList<int>countlist = recList; |
153 | countlist.append(current_count); | 153 | countlist.append(current_count); |
154 | r = mailmessage_fetch_section(message,mime,&data,&len); | 154 | r = mailmessage_fetch_section(message,mime,&data,&len); |
155 | part.setSize(len); | 155 | part.setSize(len); |
156 | part.setPositionlist(countlist); | 156 | part.setPositionlist(countlist); |
157 | b = gen_attachment_id(); | 157 | b = gen_attachment_id(); |
158 | part.setIdentifier(b); | 158 | part.setIdentifier(b); |
159 | fillSingleBody(part,message,mime); | 159 | fillSingleBody(part,message,mime); |
160 | if (part.Type()=="text" && target.Bodytext().isNull()) { | 160 | if (part.Type()=="text" && target.Bodytext().isNull()) { |
161 | encodedString*r = new encodedString(); | 161 | encodedString*r = new encodedString(); |
162 | r->setContent(data,len); | 162 | r->setContent(data,len); |
163 | encodedString*res = decode_String(r,part.Encoding()); | 163 | encodedString*res = decode_String(r,part.Encoding()); |
164 | if (countlist.count()>2) { | 164 | if (countlist.count()>2) { |
165 | bodyCache[b]=r; | 165 | bodyCache[b]=r; |
166 | target.addPart(part); | 166 | target.addPart(part); |
167 | } else { | 167 | } else { |
168 | delete r; | 168 | delete r; |
169 | } | 169 | } |
170 | b = QString(res->Content()); | 170 | b = QString(res->Content()); |
171 | delete res; | 171 | delete res; |
172 | target.setBodytext(b); | 172 | target.setBodytext(b); |
173 | target.setDescription(part); | 173 | target.setDescription(part); |
174 | } else { | 174 | } else { |
175 | bodyCache[b]=new encodedString(data,len); | 175 | bodyCache[b]=new encodedString(data,len); |
176 | target.addPart(part); | 176 | target.addPart(part); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | break; | 179 | break; |
180 | case MAILMIME_MULTIPLE: | 180 | case MAILMIME_MULTIPLE: |
181 | { | 181 | { |
182 | unsigned int ccount = 1; | 182 | unsigned int ccount = 1; |
183 | mailmime*cbody=0; | 183 | mailmime*cbody=0; |
184 | QValueList<int>countlist = recList; | 184 | QValueList<int>countlist = recList; |
185 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 185 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
186 | cbody = (mailmime*)clist_content(cur); | 186 | cbody = (mailmime*)clist_content(cur); |
187 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 187 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
188 | RecPart targetPart; | 188 | RecPart targetPart; |
189 | targetPart.setType("multipart"); | 189 | targetPart.setType("multipart"); |
190 | countlist.append(current_count); | 190 | countlist.append(current_count); |
191 | targetPart.setPositionlist(countlist); | 191 | targetPart.setPositionlist(countlist); |
192 | target.addPart(targetPart); | 192 | target.addPart(targetPart); |
193 | } | 193 | } |
194 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 194 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
195 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 195 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
196 | countlist = recList; | 196 | countlist = recList; |
197 | } | 197 | } |
198 | ++ccount; | 198 | ++ccount; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | break; | 201 | break; |
202 | case MAILMIME_MESSAGE: | 202 | case MAILMIME_MESSAGE: |
203 | { | 203 | { |
204 | QValueList<int>countlist = recList; | 204 | QValueList<int>countlist = recList; |
205 | countlist.append(current_count); | 205 | countlist.append(current_count); |
206 | /* the own header is always at recursion 0 - we don't need that */ | 206 | /* the own header is always at recursion 0 - we don't need that */ |
207 | if (current_rec > 0) { | 207 | if (current_rec > 0) { |
208 | part.setPositionlist(countlist); | 208 | part.setPositionlist(countlist); |
209 | r = mailmessage_fetch_section(message,mime,&data,&len); | 209 | r = mailmessage_fetch_section(message,mime,&data,&len); |
210 | part.setSize(len); | 210 | part.setSize(len); |
211 | part.setPositionlist(countlist); | 211 | part.setPositionlist(countlist); |
212 | b = gen_attachment_id(); | 212 | b = gen_attachment_id(); |
213 | part.setIdentifier(b); | 213 | part.setIdentifier(b); |
214 | part.setType("message"); | 214 | part.setType("message"); |
215 | part.setSubtype("rfc822"); | 215 | part.setSubtype("rfc822"); |
216 | bodyCache[b]=new encodedString(data,len); | 216 | bodyCache[b]=new encodedString(data,len); |
217 | target.addPart(part); | 217 | target.addPart(part); |
218 | } | 218 | } |
219 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 219 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
220 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 220 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | break; | 223 | break; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | RecBody Genericwrapper::parseMail( mailmessage * msg ) | 227 | RecBody Genericwrapper::parseMail( mailmessage * msg ) |
228 | { | 228 | { |
229 | int err = MAILIMF_NO_ERROR; | 229 | int err = MAILIMF_NO_ERROR; |
230 | mailmime_single_fields fields; | 230 | mailmime_single_fields fields; |
231 | /* is bound to msg and will be freed there */ | 231 | /* is bound to msg and will be freed there */ |
232 | mailmime * mime=0; | 232 | mailmime * mime=0; |
233 | RecBody body; | 233 | RecBody body; |
234 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 234 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
235 | err = mailmessage_get_bodystructure(msg,&mime); | 235 | err = mailmessage_get_bodystructure(msg,&mime); |
236 | QValueList<int>recList; | 236 | QValueList<int>recList; |
237 | traverseBody(body,msg,mime,recList); | 237 | traverseBody(body,msg,mime,recList); |
238 | return body; | 238 | return body; |
239 | } | 239 | } |
240 | 240 | ||
241 | RecMail *Genericwrapper::parseHeader( const char *header ) | 241 | RecMail *Genericwrapper::parseHeader( const char *header ) |
242 | { | 242 | { |
243 | int err = MAILIMF_NO_ERROR; | 243 | int err = MAILIMF_NO_ERROR; |
244 | size_t curTok = 0; | 244 | size_t curTok = 0; |
245 | RecMail *mail = new RecMail(); | 245 | RecMail *mail = new RecMail(); |
246 | mailimf_fields *fields = 0; | 246 | mailimf_fields *fields = 0; |
247 | mailimf_references * refs = 0; | 247 | mailimf_references * refs = 0; |
248 | mailimf_keywords*keys = 0; | 248 | mailimf_keywords*keys = 0; |
249 | QString status; | 249 | QString status; |
250 | QString value; | 250 | QString value; |
251 | QBitArray mFlags(7); | 251 | QBitArray mFlags(7); |
252 | 252 | ||
253 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 253 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
254 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { | 254 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { |
255 | mailimf_field *field = (mailimf_field *) current->data; | 255 | mailimf_field *field = (mailimf_field *) current->data; |
256 | switch ( field->fld_type ) { | 256 | switch ( field->fld_type ) { |
257 | case MAILIMF_FIELD_FROM: | 257 | case MAILIMF_FIELD_FROM: |
258 | mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); | 258 | mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); |
259 | break; | 259 | break; |
260 | case MAILIMF_FIELD_TO: | 260 | case MAILIMF_FIELD_TO: |
261 | mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) ); | 261 | mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) ); |
262 | break; | 262 | break; |
263 | case MAILIMF_FIELD_CC: | 263 | case MAILIMF_FIELD_CC: |
264 | mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); | 264 | mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); |
265 | break; | 265 | break; |
266 | case MAILIMF_FIELD_BCC: | 266 | case MAILIMF_FIELD_BCC: |
267 | mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); | 267 | mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); |
268 | break; | 268 | break; |
269 | case MAILIMF_FIELD_SUBJECT: | 269 | case MAILIMF_FIELD_SUBJECT: |
270 | mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) ); | 270 | mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) ); |
271 | break; | 271 | break; |
272 | case MAILIMF_FIELD_ORIG_DATE: | 272 | case MAILIMF_FIELD_ORIG_DATE: |
273 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); | 273 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); |
274 | break; | 274 | break; |
275 | case MAILIMF_FIELD_MESSAGE_ID: | 275 | case MAILIMF_FIELD_MESSAGE_ID: |
276 | mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value)); | 276 | mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value)); |
277 | break; | 277 | break; |
278 | case MAILIMF_FIELD_REFERENCES: | 278 | case MAILIMF_FIELD_REFERENCES: |
279 | refs = field->fld_data.fld_references; | 279 | refs = field->fld_data.fld_references; |
280 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 280 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
281 | char * text = (char*)refs->mid_list->first->data; | 281 | char * text = (char*)refs->mid_list->first->data; |
282 | mail->setReplyto(QString(text)); | 282 | mail->setReplyto(QString(text)); |
283 | } | 283 | } |
284 | break; | 284 | break; |
285 | case MAILIMF_FIELD_KEYWORDS: | 285 | case MAILIMF_FIELD_KEYWORDS: |
286 | keys = field->fld_data.fld_keywords; | 286 | keys = field->fld_data.fld_keywords; |
287 | for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) { | 287 | for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) { |
288 | qDebug("Keyword: %s",(char*)cur->data); | 288 | qDebug("Keyword: %s",(char*)cur->data); |
289 | } | 289 | } |
290 | break; | 290 | break; |
291 | case MAILIMF_FIELD_OPTIONAL_FIELD: | 291 | case MAILIMF_FIELD_OPTIONAL_FIELD: |
292 | status = field->fld_data.fld_optional_field->fld_name; | 292 | status = field->fld_data.fld_optional_field->fld_name; |
293 | value = field->fld_data.fld_optional_field->fld_value; | 293 | value = field->fld_data.fld_optional_field->fld_value; |
294 | if (status.lower()=="status") { | 294 | if (status.lower()=="status") { |
295 | if (value.lower()=="ro") { | 295 | if (value.lower()=="ro") { |
296 | mFlags.setBit(FLAG_SEEN); | 296 | mFlags.setBit(FLAG_SEEN); |
297 | } | 297 | } |
298 | } else if (status.lower()=="x-status") { | 298 | } else if (status.lower()=="x-status") { |
299 | qDebug("X-Status: %s",value.latin1()); | 299 | qDebug("X-Status: %s",value.latin1()); |
300 | if (value.lower()=="a") { | 300 | if (value.lower()=="a") { |
301 | mFlags.setBit(FLAG_ANSWERED); | 301 | mFlags.setBit(FLAG_ANSWERED); |
302 | } | 302 | } |
303 | } else { | 303 | } else { |
304 | // qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name, | 304 | // qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name, |
305 | // field->fld_data.fld_optional_field->fld_value); | 305 | // field->fld_data.fld_optional_field->fld_value); |
306 | } | 306 | } |
307 | break; | 307 | break; |
308 | default: | 308 | default: |
309 | qDebug("Non parsed field"); | 309 | qDebug("Non parsed field"); |
310 | break; | 310 | break; |
311 | } | 311 | } |
312 | } | 312 | } |
313 | if (fields) mailimf_fields_free(fields); | 313 | if (fields) mailimf_fields_free(fields); |
314 | mail->setFlags(mFlags); | 314 | mail->setFlags(mFlags); |
315 | return mail; | 315 | return mail; |
316 | } | 316 | } |
317 | 317 | ||
318 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | 318 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) |
319 | { | 319 | { |
320 | char tmp[23]; | 320 | char tmp[23]; |
321 | 321 | ||
322 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 322 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
323 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 323 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
324 | 324 | ||
325 | return QString( tmp ); | 325 | return QString( tmp ); |
326 | } | 326 | } |
327 | 327 | ||
328 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 328 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
329 | { | 329 | { |
330 | QString result( "" ); | 330 | QString result( "" ); |
331 | 331 | ||
332 | bool first = true; | 332 | bool first = true; |
333 | if (list == 0) return result; | 333 | if (list == 0) return result; |
334 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 334 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
335 | mailimf_address *addr = (mailimf_address *) current->data; | 335 | mailimf_address *addr = (mailimf_address *) current->data; |
336 | 336 | ||
337 | if ( !first ) { | 337 | if ( !first ) { |
338 | result.append( "," ); | 338 | result.append( "," ); |
339 | } else { | 339 | } else { |
340 | first = false; | 340 | first = false; |
341 | } | 341 | } |
342 | 342 | ||
343 | switch ( addr->ad_type ) { | 343 | switch ( addr->ad_type ) { |
344 | case MAILIMF_ADDRESS_MAILBOX: | 344 | case MAILIMF_ADDRESS_MAILBOX: |
345 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 345 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
346 | break; | 346 | break; |
347 | case MAILIMF_ADDRESS_GROUP: | 347 | case MAILIMF_ADDRESS_GROUP: |
348 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 348 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
349 | break; | 349 | break; |
350 | default: | 350 | default: |
351 | qDebug( "Generic: unkown mailimf address type" ); | 351 | qDebug( "Generic: unkown mailimf address type" ); |
352 | break; | 352 | break; |
353 | } | 353 | } |
354 | } | 354 | } |
355 | 355 | ||
356 | return result; | 356 | return result; |
357 | } | 357 | } |
358 | 358 | ||
359 | QString Genericwrapper::parseGroup( mailimf_group *group ) | 359 | QString Genericwrapper::parseGroup( mailimf_group *group ) |
360 | { | 360 | { |
361 | QString result( "" ); | 361 | QString result( "" ); |
362 | 362 | ||
363 | result.append( group->grp_display_name ); | 363 | result.append( group->grp_display_name ); |
364 | result.append( ": " ); | 364 | result.append( ": " ); |
365 | 365 | ||
366 | if ( group->grp_mb_list != NULL ) { | 366 | if ( group->grp_mb_list != NULL ) { |
367 | result.append( parseMailboxList( group->grp_mb_list ) ); | 367 | result.append( parseMailboxList( group->grp_mb_list ) ); |
368 | } | 368 | } |
369 | 369 | ||
370 | result.append( ";" ); | 370 | result.append( ";" ); |
371 | 371 | ||
372 | return result; | 372 | return result; |
373 | } | 373 | } |
374 | 374 | ||
375 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) | 375 | QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) |
376 | { | 376 | { |
377 | QString result( "" ); | 377 | QString result( "" ); |
378 | 378 | ||
379 | if ( box->mb_display_name == NULL ) { | 379 | if ( box->mb_display_name == NULL ) { |
380 | result.append( box->mb_addr_spec ); | 380 | result.append( box->mb_addr_spec ); |
381 | } else { | 381 | } else { |
382 | result.append( convert_String(box->mb_display_name).latin1() ); | 382 | result.append( convert_String(box->mb_display_name).latin1() ); |
383 | result.append( " <" ); | 383 | result.append( " <" ); |
384 | result.append( box->mb_addr_spec ); | 384 | result.append( box->mb_addr_spec ); |
385 | result.append( ">" ); | 385 | result.append( ">" ); |
386 | } | 386 | } |
387 | 387 | ||
388 | return result; | 388 | return result; |
389 | } | 389 | } |
390 | 390 | ||
391 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | 391 | QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) |
392 | { | 392 | { |
393 | QString result( "" ); | 393 | QString result( "" ); |
394 | 394 | ||
395 | bool first = true; | 395 | bool first = true; |
396 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { | 396 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { |
397 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; | 397 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; |
398 | 398 | ||
399 | if ( !first ) { | 399 | if ( !first ) { |
400 | result.append( "," ); | 400 | result.append( "," ); |
401 | } else { | 401 | } else { |
402 | first = false; | 402 | first = false; |
403 | } | 403 | } |
404 | 404 | ||
405 | result.append( parseMailbox( box ) ); | 405 | result.append( parseMailbox( box ) ); |
406 | } | 406 | } |
407 | 407 | ||
408 | return result; | 408 | return result; |
409 | } | 409 | } |
410 | 410 | ||
411 | encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part) | 411 | encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part) |
412 | { | 412 | { |
413 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); | 413 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); |
414 | if (it==bodyCache.end()) return new encodedString(); | 414 | if (it==bodyCache.end()) return new encodedString(); |
415 | encodedString*t = decode_String(it.data(),part.Encoding()); | 415 | encodedString*t = decode_String(it.data(),part.Encoding()); |
416 | return t; | 416 | return t; |
417 | } | 417 | } |
418 | 418 | ||
419 | encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) | 419 | encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) |
420 | { | 420 | { |
421 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); | 421 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); |
422 | if (it==bodyCache.end()) return new encodedString(); | 422 | if (it==bodyCache.end()) return new encodedString(); |
423 | encodedString*t = it.data(); | 423 | encodedString*t = it.data(); |
424 | return t; | 424 | return t; |
425 | } | 425 | } |
426 | 426 | ||
427 | QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) | 427 | QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) |
428 | { | 428 | { |
429 | encodedString*t = fetchDecodedPart(mail,part); | 429 | encodedString*t = fetchDecodedPart(mail,part); |
430 | QString text=t->Content(); | 430 | QString text=t->Content(); |
431 | delete t; | 431 | delete t; |
432 | return text; | 432 | return text; |
433 | } | 433 | } |
434 | 434 | ||
435 | void Genericwrapper::cleanMimeCache() | 435 | void Genericwrapper::cleanMimeCache() |
436 | { | 436 | { |
437 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); | 437 | QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); |
438 | for (;it!=bodyCache.end();++it) { | 438 | for (;it!=bodyCache.end();++it) { |
439 | encodedString*t = it.data(); | 439 | encodedString*t = it.data(); |
440 | //it.setValue(0); | 440 | //it.setValue(0); |
441 | if (t) delete t; | 441 | if (t) delete t; |
442 | } | 442 | } |
443 | bodyCache.clear(); | 443 | bodyCache.clear(); |
444 | qDebug("Genericwrapper: cache cleaned"); | 444 | qDebug("Genericwrapper: cache cleaned"); |
445 | } | 445 | } |
446 | 446 | ||
447 | void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox) | 447 | void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox) |
448 | { | 448 | { |
449 | int r; | 449 | int r; |
450 | mailmessage_list * env_list = 0; | 450 | mailmessage_list * env_list = 0; |
451 | r = mailsession_get_messages_list(session,&env_list); | 451 | r = mailsession_get_messages_list(session,&env_list); |
452 | if (r != MAIL_NO_ERROR) { | 452 | if (r != MAIL_NO_ERROR) { |
453 | qDebug("Error message list"); | 453 | qDebug("Error message list"); |
454 | return; | 454 | return; |
455 | } | 455 | } |
456 | r = mailsession_get_envelopes_list(session, env_list); | 456 | r = mailsession_get_envelopes_list(session, env_list); |
457 | if (r != MAIL_NO_ERROR) { | 457 | if (r != MAIL_NO_ERROR) { |
458 | qDebug("Error filling message list"); | 458 | qDebug("Error filling message list"); |
459 | if (env_list) { | 459 | if (env_list) { |
460 | mailmessage_list_free(env_list); | 460 | mailmessage_list_free(env_list); |
461 | } | 461 | } |
462 | return; | 462 | return; |
463 | } | 463 | } |
464 | mailimf_references * refs; | 464 | mailimf_references * refs; |
465 | uint32_t i = 0; | 465 | uint32_t i = 0; |
466 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | 466 | for(; i < carray_count(env_list->msg_tab) ; ++i) { |
467 | mailmessage * msg; | 467 | mailmessage * msg; |
468 | QBitArray mFlags(7); | 468 | QBitArray mFlags(7); |
469 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | 469 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); |
470 | if (msg->msg_fields == NULL) { | 470 | if (msg->msg_fields == NULL) { |
471 | qDebug("could not fetch envelope of message %i", i); | 471 | //qDebug("could not fetch envelope of message %i", i); |
472 | continue; | 472 | continue; |
473 | } | 473 | } |
474 | RecMail * mail = new RecMail(); | 474 | RecMail * mail = new RecMail(); |
475 | mail->setWrapper(this); | 475 | mail->setWrapper(this); |
476 | mail_flags * flag_result = 0; | 476 | mail_flags * flag_result = 0; |
477 | r = mailmessage_get_flags(msg,&flag_result); | 477 | r = mailmessage_get_flags(msg,&flag_result); |
478 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | 478 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { |
479 | mFlags.setBit(FLAG_SEEN); | 479 | mFlags.setBit(FLAG_SEEN); |
480 | } | 480 | } |
481 | mailimf_single_fields single_fields; | 481 | mailimf_single_fields single_fields; |
482 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | 482 | mailimf_single_fields_init(&single_fields, msg->msg_fields); |
483 | mail->setMsgsize(msg->msg_size); | 483 | mail->setMsgsize(msg->msg_size); |
484 | mail->setFlags(mFlags); | 484 | mail->setFlags(mFlags); |
485 | mail->setMbox(mailbox); | 485 | mail->setMbox(mailbox); |
486 | mail->setNumber(msg->msg_index); | 486 | mail->setNumber(msg->msg_index); |
487 | if (single_fields.fld_subject) | 487 | if (single_fields.fld_subject) |
488 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | 488 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); |
489 | if (single_fields.fld_from) | 489 | if (single_fields.fld_from) |
490 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | 490 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); |
491 | if (single_fields.fld_to) | 491 | if (single_fields.fld_to) |
492 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | 492 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); |
493 | if (single_fields.fld_cc) | 493 | if (single_fields.fld_cc) |
494 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | 494 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); |
495 | if (single_fields.fld_bcc) | 495 | if (single_fields.fld_bcc) |
496 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | 496 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); |
497 | if (single_fields.fld_orig_date) | 497 | if (single_fields.fld_orig_date) |
498 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | 498 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); |
499 | // crashes when accessing pop3 account | 499 | // crashes when accessing pop3 account |
500 | // if (single_fields.fld_message_id->mid_value) | 500 | // if (single_fields.fld_message_id->mid_value) |
501 | // mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | 501 | // mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); |
502 | refs = single_fields.fld_references; | 502 | refs = single_fields.fld_references; |
503 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | 503 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { |
504 | char * text = (char*)refs->mid_list->first->data; | 504 | char * text = (char*)refs->mid_list->first->data; |
505 | mail->setReplyto(QString(text)); | 505 | mail->setReplyto(QString(text)); |
506 | } | 506 | } |
507 | target.append(mail); | 507 | target.append(mail); |
508 | } | 508 | } |
509 | if (env_list) { | 509 | if (env_list) { |
510 | mailmessage_list_free(env_list); | 510 | mailmessage_list_free(env_list); |
511 | } | 511 | } |
512 | } | 512 | } |