summaryrefslogtreecommitdiff
authoralwin <alwin>2004-03-12 11:21:19 (UTC)
committer alwin <alwin>2004-03-12 11:21:19 (UTC)
commitc71234bda29bd83de34ce04c766f2be641ed86be (patch) (unidiff)
tree85abe5962891fabe7a743b6f518469b6d6f8c40a
parenteb734381bc4414ef5584c51e49582c3fa8930440 (diff)
downloadopie-c71234bda29bd83de34ce04c766f2be641ed86be.zip
opie-c71234bda29bd83de34ce04c766f2be641ed86be.tar.gz
opie-c71234bda29bd83de34ce04c766f2be641ed86be.tar.bz2
fixed a variable name conflict
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index ffa049f..6c8a5a1 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -1,475 +1,475 @@
1#include "genericwrapper.h" 1#include "genericwrapper.h"
2#include <libetpan/libetpan.h> 2#include <libetpan/libetpan.h>
3#include "mailtypes.h" 3#include "mailtypes.h"
4 4
5Genericwrapper::Genericwrapper() 5Genericwrapper::Genericwrapper()
6 : AbstractMail() 6 : AbstractMail()
7{ 7{
8 bodyCache.clear(); 8 bodyCache.clear();
9 m_storage = 0; 9 m_storage = 0;
10 m_folder = 0; 10 m_folder = 0;
11} 11}
12 12
13Genericwrapper::~Genericwrapper() 13Genericwrapper::~Genericwrapper()
14{ 14{
15 if (m_folder) { 15 if (m_folder) {
16 mailfolder_free(m_folder); 16 mailfolder_free(m_folder);
17 } 17 }
18 if (m_storage) { 18 if (m_storage) {
19 mailstorage_free(m_storage); 19 mailstorage_free(m_storage);
20 } 20 }
21 cleanMimeCache(); 21 cleanMimeCache();
22} 22}
23 23
24void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) 24void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
25{ 25{
26 if (!mime) { 26 if (!mime) {
27 return; 27 return;
28 } 28 }
29 mailmime_field*field = 0; 29 mailmime_field*field = 0;
30 mailmime_single_fields fields; 30 mailmime_single_fields fields;
31 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 31 memset(&fields, 0, sizeof(struct mailmime_single_fields));
32 if (mime->mm_mime_fields != NULL) { 32 if (mime->mm_mime_fields != NULL) {
33 mailmime_single_fields_init(&fields, mime->mm_mime_fields, 33 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
34 mime->mm_content_type); 34 mime->mm_content_type);
35 } 35 }
36 36
37 mailmime_content*type = fields.fld_content; 37 mailmime_content*type = fields.fld_content;
38 clistcell*current; 38 clistcell*current;
39 if (!type) { 39 if (!type) {
40 target.setType("text"); 40 target.setType("text");
41 target.setSubtype("plain"); 41 target.setSubtype("plain");
42 } else { 42 } else {
43 target.setSubtype(type->ct_subtype); 43 target.setSubtype(type->ct_subtype);
44 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { 44 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
45 case MAILMIME_DISCRETE_TYPE_TEXT: 45 case MAILMIME_DISCRETE_TYPE_TEXT:
46 target.setType("text"); 46 target.setType("text");
47 break; 47 break;
48 case MAILMIME_DISCRETE_TYPE_IMAGE: 48 case MAILMIME_DISCRETE_TYPE_IMAGE:
49 target.setType("image"); 49 target.setType("image");
50 break; 50 break;
51 case MAILMIME_DISCRETE_TYPE_AUDIO: 51 case MAILMIME_DISCRETE_TYPE_AUDIO:
52 target.setType("audio"); 52 target.setType("audio");
53 break; 53 break;
54 case MAILMIME_DISCRETE_TYPE_VIDEO: 54 case MAILMIME_DISCRETE_TYPE_VIDEO:
55 target.setType("video"); 55 target.setType("video");
56 break; 56 break;
57 case MAILMIME_DISCRETE_TYPE_APPLICATION: 57 case MAILMIME_DISCRETE_TYPE_APPLICATION:
58 target.setType("application"); 58 target.setType("application");
59 break; 59 break;
60 case MAILMIME_DISCRETE_TYPE_EXTENSION: 60 case MAILMIME_DISCRETE_TYPE_EXTENSION:
61 default: 61 default:
62 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { 62 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
63 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); 63 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
64 } 64 }
65 break; 65 break;
66 } 66 }
67 if (type->ct_parameters) { 67 if (type->ct_parameters) {
68 fillParameters(target,type->ct_parameters); 68 fillParameters(target,type->ct_parameters);
69 } 69 }
70 } 70 }
71 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { 71 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
72 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { 72 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
73 field = (mailmime_field*)current->data; 73 field = (mailmime_field*)current->data;
74 switch(field->fld_type) { 74 switch(field->fld_type) {
75 case MAILMIME_FIELD_TRANSFER_ENCODING: 75 case MAILMIME_FIELD_TRANSFER_ENCODING:
76 target.setEncoding(getencoding(field->fld_data.fld_encoding)); 76 target.setEncoding(getencoding(field->fld_data.fld_encoding));
77 break; 77 break;
78 case MAILMIME_FIELD_ID: 78 case MAILMIME_FIELD_ID:
79 target.setIdentifier(field->fld_data.fld_id); 79 target.setIdentifier(field->fld_data.fld_id);
80 break; 80 break;
81 case MAILMIME_FIELD_DESCRIPTION: 81 case MAILMIME_FIELD_DESCRIPTION:
82 target.setDescription(field->fld_data.fld_description); 82 target.setDescription(field->fld_data.fld_description);
83 break; 83 break;
84 default: 84 default:
85 break; 85 break;
86 } 86 }
87 } 87 }
88 } 88 }
89} 89}
90 90
91void Genericwrapper::fillParameters(RecPart&target,clist*parameters) 91void 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
104QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) 104QString 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
134void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) 134void 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*rs = new encodedString();
162 r->setContent(data,len); 162 rs->setContent(data,len);
163 encodedString*res = decode_String(r,part.Encoding()); 163 encodedString*res = decode_String(rs,part.Encoding());
164 if (countlist.count()>2) { 164 if (countlist.count()>2) {
165 bodyCache[b]=r; 165 bodyCache[b]=rs;
166 target.addPart(part); 166 target.addPart(part);
167 } else { 167 } else {
168 delete r; 168 delete rs;
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
227RecBody Genericwrapper::parseMail( mailmessage * msg ) 227RecBody 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
241QString Genericwrapper::parseDateTime( mailimf_date_time *date ) 241QString Genericwrapper::parseDateTime( mailimf_date_time *date )
242{ 242{
243 char tmp[23]; 243 char tmp[23];
244 244
245 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 245 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
246 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 246 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
247 247
248 return QString( tmp ); 248 return QString( tmp );
249} 249}
250 250
251QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 251QString Genericwrapper::parseAddressList( mailimf_address_list *list )
252{ 252{
253 QString result( "" ); 253 QString result( "" );
254 254
255 bool first = true; 255 bool first = true;
256 if (list == 0) return result; 256 if (list == 0) return result;
257 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 257 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
258 mailimf_address *addr = (mailimf_address *) current->data; 258 mailimf_address *addr = (mailimf_address *) current->data;
259 259
260 if ( !first ) { 260 if ( !first ) {
261 result.append( "," ); 261 result.append( "," );
262 } else { 262 } else {
263 first = false; 263 first = false;
264 } 264 }
265 265
266 switch ( addr->ad_type ) { 266 switch ( addr->ad_type ) {
267 case MAILIMF_ADDRESS_MAILBOX: 267 case MAILIMF_ADDRESS_MAILBOX:
268 result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); 268 result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
269 break; 269 break;
270 case MAILIMF_ADDRESS_GROUP: 270 case MAILIMF_ADDRESS_GROUP:
271 result.append( parseGroup( addr->ad_data.ad_group ) ); 271 result.append( parseGroup( addr->ad_data.ad_group ) );
272 break; 272 break;
273 default: 273 default:
274 qDebug( "Generic: unkown mailimf address type" ); 274 qDebug( "Generic: unkown mailimf address type" );
275 break; 275 break;
276 } 276 }
277 } 277 }
278 278
279 return result; 279 return result;
280} 280}
281 281
282QString Genericwrapper::parseGroup( mailimf_group *group ) 282QString Genericwrapper::parseGroup( mailimf_group *group )
283{ 283{
284 QString result( "" ); 284 QString result( "" );
285 285
286 result.append( group->grp_display_name ); 286 result.append( group->grp_display_name );
287 result.append( ": " ); 287 result.append( ": " );
288 288
289 if ( group->grp_mb_list != NULL ) { 289 if ( group->grp_mb_list != NULL ) {
290 result.append( parseMailboxList( group->grp_mb_list ) ); 290 result.append( parseMailboxList( group->grp_mb_list ) );
291 } 291 }
292 292
293 result.append( ";" ); 293 result.append( ";" );
294 294
295 return result; 295 return result;
296} 296}
297 297
298QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) 298QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
299{ 299{
300 QString result( "" ); 300 QString result( "" );
301 301
302 if ( box->mb_display_name == NULL ) { 302 if ( box->mb_display_name == NULL ) {
303 result.append( box->mb_addr_spec ); 303 result.append( box->mb_addr_spec );
304 } else { 304 } else {
305 result.append( convert_String(box->mb_display_name).latin1() ); 305 result.append( convert_String(box->mb_display_name).latin1() );
306 result.append( " <" ); 306 result.append( " <" );
307 result.append( box->mb_addr_spec ); 307 result.append( box->mb_addr_spec );
308 result.append( ">" ); 308 result.append( ">" );
309 } 309 }
310 310
311 return result; 311 return result;
312} 312}
313 313
314QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) 314QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
315{ 315{
316 QString result( "" ); 316 QString result( "" );
317 317
318 bool first = true; 318 bool first = true;
319 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { 319 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
320 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 320 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
321 321
322 if ( !first ) { 322 if ( !first ) {
323 result.append( "," ); 323 result.append( "," );
324 } else { 324 } else {
325 first = false; 325 first = false;
326 } 326 }
327 327
328 result.append( parseMailbox( box ) ); 328 result.append( parseMailbox( box ) );
329 } 329 }
330 330
331 return result; 331 return result;
332} 332}
333 333
334encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part) 334encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part)
335{ 335{
336 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); 336 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
337 if (it==bodyCache.end()) return new encodedString(); 337 if (it==bodyCache.end()) return new encodedString();
338 encodedString*t = decode_String(it.data(),part.Encoding()); 338 encodedString*t = decode_String(it.data(),part.Encoding());
339 return t; 339 return t;
340} 340}
341 341
342encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&part) 342encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&part)
343{ 343{
344 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); 344 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
345 if (it==bodyCache.end()) return new encodedString(); 345 if (it==bodyCache.end()) return new encodedString();
346 encodedString*t = it.data(); 346 encodedString*t = it.data();
347 return t; 347 return t;
348} 348}
349 349
350QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part) 350QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part)
351{ 351{
352 encodedString*t = fetchDecodedPart(mail,part); 352 encodedString*t = fetchDecodedPart(mail,part);
353 QString text=t->Content(); 353 QString text=t->Content();
354 delete t; 354 delete t;
355 return text; 355 return text;
356} 356}
357 357
358void Genericwrapper::cleanMimeCache() 358void Genericwrapper::cleanMimeCache()
359{ 359{
360 QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); 360 QMap<QString,encodedString*>::Iterator it = bodyCache.begin();
361 for (;it!=bodyCache.end();++it) { 361 for (;it!=bodyCache.end();++it) {
362 encodedString*t = it.data(); 362 encodedString*t = it.data();
363 //it.setValue(0); 363 //it.setValue(0);
364 if (t) delete t; 364 if (t) delete t;
365 } 365 }
366 bodyCache.clear(); 366 bodyCache.clear();
367 qDebug("Genericwrapper: cache cleaned"); 367 qDebug("Genericwrapper: cache cleaned");
368} 368}
369 369
370QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) 370QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies)
371{ 371{
372 QStringList res; 372 QStringList res;
373 if (!in_replies || !in_replies->mid_list) return res; 373 if (!in_replies || !in_replies->mid_list) return res;
374 clistiter * current = 0; 374 clistiter * current = 0;
375 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { 375 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) {
376 QString h((char*)current->data); 376 QString h((char*)current->data);
377 while (h.length()>0 && h[0]=='<') { 377 while (h.length()>0 && h[0]=='<') {
378 h.remove(0,1); 378 h.remove(0,1);
379 } 379 }
380 while (h.length()>0 && h[h.length()-1]=='>') { 380 while (h.length()>0 && h[h.length()-1]=='>') {
381 h.remove(h.length()-1,1); 381 h.remove(h.length()-1,1);
382 } 382 }
383 if (h.length()>0) { 383 if (h.length()>0) {
384 res.append(h); 384 res.append(h);
385 } 385 }
386 } 386 }
387 return res; 387 return res;
388} 388}
389 389
390void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to) 390void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox,bool mbox_as_to)
391{ 391{
392 int r; 392 int r;
393 mailmessage_list * env_list = 0; 393 mailmessage_list * env_list = 0;
394 r = mailsession_get_messages_list(session,&env_list); 394 r = mailsession_get_messages_list(session,&env_list);
395 if (r != MAIL_NO_ERROR) { 395 if (r != MAIL_NO_ERROR) {
396 qDebug("Error message list"); 396 qDebug("Error message list");
397 return; 397 return;
398 } 398 }
399 r = mailsession_get_envelopes_list(session, env_list); 399 r = mailsession_get_envelopes_list(session, env_list);
400 if (r != MAIL_NO_ERROR) { 400 if (r != MAIL_NO_ERROR) {
401 qDebug("Error filling message list"); 401 qDebug("Error filling message list");
402 if (env_list) { 402 if (env_list) {
403 mailmessage_list_free(env_list); 403 mailmessage_list_free(env_list);
404 } 404 }
405 return; 405 return;
406 } 406 }
407 mailimf_references * refs = 0; 407 mailimf_references * refs = 0;
408 mailimf_in_reply_to * in_replies = 0; 408 mailimf_in_reply_to * in_replies = 0;
409 uint32_t i = 0; 409 uint32_t i = 0;
410 for(; i < carray_count(env_list->msg_tab) ; ++i) { 410 for(; i < carray_count(env_list->msg_tab) ; ++i) {
411 mailmessage * msg; 411 mailmessage * msg;
412 QBitArray mFlags(7); 412 QBitArray mFlags(7);
413 msg = (mailmessage*)carray_get(env_list->msg_tab, i); 413 msg = (mailmessage*)carray_get(env_list->msg_tab, i);
414 if (msg->msg_fields == NULL) { 414 if (msg->msg_fields == NULL) {
415 //qDebug("could not fetch envelope of message %i", i); 415 //qDebug("could not fetch envelope of message %i", i);
416 continue; 416 continue;
417 } 417 }
418 RecMail * mail = new RecMail(); 418 RecMail * mail = new RecMail();
419 mail->setWrapper(this); 419 mail->setWrapper(this);
420 mail_flags * flag_result = 0; 420 mail_flags * flag_result = 0;
421 r = mailmessage_get_flags(msg,&flag_result); 421 r = mailmessage_get_flags(msg,&flag_result);
422 if (r == MAIL_ERROR_NOT_IMPLEMENTED) { 422 if (r == MAIL_ERROR_NOT_IMPLEMENTED) {
423 mFlags.setBit(FLAG_SEEN); 423 mFlags.setBit(FLAG_SEEN);
424 } 424 }
425 mailimf_single_fields single_fields; 425 mailimf_single_fields single_fields;
426 mailimf_single_fields_init(&single_fields, msg->msg_fields); 426 mailimf_single_fields_init(&single_fields, msg->msg_fields);
427 mail->setMsgsize(msg->msg_size); 427 mail->setMsgsize(msg->msg_size);
428 mail->setFlags(mFlags); 428 mail->setFlags(mFlags);
429 mail->setMbox(mailbox); 429 mail->setMbox(mailbox);
430 mail->setNumber(msg->msg_index); 430 mail->setNumber(msg->msg_index);
431 if (single_fields.fld_subject) 431 if (single_fields.fld_subject)
432 mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); 432 mail->setSubject( convert_String(single_fields.fld_subject->sbj_value));
433 if (single_fields.fld_from) 433 if (single_fields.fld_from)
434 mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); 434 mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list));
435 if (!mbox_as_to) { 435 if (!mbox_as_to) {
436 if (single_fields.fld_to) 436 if (single_fields.fld_to)
437 mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); 437 mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) );
438 } else { 438 } else {
439 mail->setTo(mailbox); 439 mail->setTo(mailbox);
440 } 440 }
441 if (single_fields.fld_cc) 441 if (single_fields.fld_cc)
442 mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); 442 mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) );
443 if (single_fields.fld_bcc) 443 if (single_fields.fld_bcc)
444 mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); 444 mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) );
445 if (single_fields.fld_orig_date) 445 if (single_fields.fld_orig_date)
446 mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); 446 mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) );
447 // crashes when accessing pop3 account? 447 // crashes when accessing pop3 account?
448 if (single_fields.fld_message_id->mid_value) { 448 if (single_fields.fld_message_id->mid_value) {
449 mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); 449 mail->setMsgid(QString(single_fields.fld_message_id->mid_value));
450 qDebug("Msgid == %s",mail->Msgid().latin1()); 450 qDebug("Msgid == %s",mail->Msgid().latin1());
451 } 451 }
452 452
453 if (single_fields.fld_reply_to) { 453 if (single_fields.fld_reply_to) {
454 QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); 454 QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list);
455 if (t.count()>0) { 455 if (t.count()>0) {
456 mail->setReplyto(t[0]); 456 mail->setReplyto(t[0]);
457 } 457 }
458 } 458 }
459#if 0 459#if 0
460 refs = single_fields.fld_references; 460 refs = single_fields.fld_references;
461 if (refs && refs->mid_list && clist_count(refs->mid_list)) { 461 if (refs && refs->mid_list && clist_count(refs->mid_list)) {
462 char * text = (char*)refs->mid_list->first->data; 462 char * text = (char*)refs->mid_list->first->data;
463 mail->setReplyto(QString(text)); 463 mail->setReplyto(QString(text));
464 } 464 }
465#endif 465#endif
466 if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && 466 if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list &&
467 clist_count(single_fields.fld_in_reply_to->mid_list)) { 467 clist_count(single_fields.fld_in_reply_to->mid_list)) {
468 mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); 468 mail->setInreply(parseInreplies(single_fields.fld_in_reply_to));
469 } 469 }
470 target.append(mail); 470 target.append(mail);
471 } 471 }
472 if (env_list) { 472 if (env_list) {
473 mailmessage_list_free(env_list); 473 mailmessage_list_free(env_list);
474 } 474 }
475} 475}