author | alwin <alwin> | 2004-03-18 18:00:18 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-18 18:00:18 (UTC) |
commit | fef9cec046fcf21a4f762c36454b8f253dd3e25e (patch) (unidiff) | |
tree | b87ee38164e1e9ce635dde34c13677f09388c058 /noncore/net/mail/libmailwrapper/genericwrapper.cpp | |
parent | 69fa0e7b5cab5f4cdfdac736e31ff0fd0fbf4312 (diff) | |
download | opie-fef9cec046fcf21a4f762c36454b8f253dd3e25e.zip opie-fef9cec046fcf21a4f762c36454b8f253dd3e25e.tar.gz opie-fef9cec046fcf21a4f762c36454b8f253dd3e25e.tar.bz2 |
some (hopeful) improvements
Diffstat (limited to 'noncore/net/mail/libmailwrapper/genericwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index f428415..0c68280 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -22,7 +22,7 @@ Genericwrapper::~Genericwrapper() | |||
22 | cleanMimeCache(); | 22 | cleanMimeCache(); |
23 | } | 23 | } |
24 | 24 | ||
25 | void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) | 25 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
26 | { | 26 | { |
27 | if (!mime) { | 27 | if (!mime) { |
28 | return; | 28 | return; |
@@ -38,30 +38,30 @@ void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) | |||
38 | mailmime_content*type = fields.fld_content; | 38 | mailmime_content*type = fields.fld_content; |
39 | clistcell*current; | 39 | clistcell*current; |
40 | if (!type) { | 40 | if (!type) { |
41 | target.setType("text"); | 41 | target->setType("text"); |
42 | target.setSubtype("plain"); | 42 | target->setSubtype("plain"); |
43 | } else { | 43 | } else { |
44 | target.setSubtype(type->ct_subtype); | 44 | target->setSubtype(type->ct_subtype); |
45 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 45 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
46 | case MAILMIME_DISCRETE_TYPE_TEXT: | 46 | case MAILMIME_DISCRETE_TYPE_TEXT: |
47 | target.setType("text"); | 47 | target->setType("text"); |
48 | break; | 48 | break; |
49 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 49 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
50 | target.setType("image"); | 50 | target->setType("image"); |
51 | break; | 51 | break; |
52 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 52 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
53 | target.setType("audio"); | 53 | target->setType("audio"); |
54 | break; | 54 | break; |
55 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 55 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
56 | target.setType("video"); | 56 | target->setType("video"); |
57 | break; | 57 | break; |
58 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 58 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
59 | target.setType("application"); | 59 | target->setType("application"); |
60 | break; | 60 | break; |
61 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 61 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
62 | default: | 62 | default: |
63 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 63 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
64 | target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 64 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
65 | } | 65 | } |
66 | break; | 66 | break; |
67 | } | 67 | } |
@@ -74,13 +74,13 @@ void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) | |||
74 | field = (mailmime_field*)current->data; | 74 | field = (mailmime_field*)current->data; |
75 | switch(field->fld_type) { | 75 | switch(field->fld_type) { |
76 | case MAILMIME_FIELD_TRANSFER_ENCODING: | 76 | case MAILMIME_FIELD_TRANSFER_ENCODING: |
77 | target.setEncoding(getencoding(field->fld_data.fld_encoding)); | 77 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); |
78 | break; | 78 | break; |
79 | case MAILMIME_FIELD_ID: | 79 | case MAILMIME_FIELD_ID: |
80 | target.setIdentifier(field->fld_data.fld_id); | 80 | target->setIdentifier(field->fld_data.fld_id); |
81 | break; | 81 | break; |
82 | case MAILMIME_FIELD_DESCRIPTION: | 82 | case MAILMIME_FIELD_DESCRIPTION: |
83 | target.setDescription(field->fld_data.fld_description); | 83 | target->setDescription(field->fld_data.fld_description); |
84 | break; | 84 | break; |
85 | default: | 85 | default: |
86 | break; | 86 | break; |
@@ -89,7 +89,7 @@ void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) | |||
89 | } | 89 | } |
90 | } | 90 | } |
91 | 91 | ||
92 | void Genericwrapper::fillParameters(RecPart&target,clist*parameters) | 92 | void Genericwrapper::fillParameters(RecPartP&target,clist*parameters) |
93 | { | 93 | { |
94 | if (!parameters) {return;} | 94 | if (!parameters) {return;} |
95 | clistcell*current=0; | 95 | clistcell*current=0; |
@@ -97,7 +97,7 @@ void Genericwrapper::fillParameters(RecPart&target,clist*parameters) | |||
97 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { | 97 | for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { |
98 | param = (mailmime_parameter*)current->data; | 98 | param = (mailmime_parameter*)current->data; |
99 | if (param) { | 99 | if (param) { |
100 | target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 100 | target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
@@ -132,7 +132,7 @@ QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | |||
132 | return enc; | 132 | return enc; |
133 | } | 133 | } |
134 | 134 | ||
135 | void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) | 135 | void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
136 | { | 136 | { |
137 | if (current_rec >= 10) { | 137 | if (current_rec >= 10) { |
138 | qDebug("too deep recursion!"); | 138 | qDebug("too deep recursion!"); |
@@ -145,7 +145,7 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi | |||
145 | size_t len; | 145 | size_t len; |
146 | clistiter * cur = 0; | 146 | clistiter * cur = 0; |
147 | QString b; | 147 | QString b; |
148 | RecPart part; | 148 | RecPartP part = new RecPart(); |
149 | 149 | ||
150 | switch (mime->mm_type) { | 150 | switch (mime->mm_type) { |
151 | case MAILMIME_SINGLE: | 151 | case MAILMIME_SINGLE: |
@@ -153,28 +153,28 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi | |||
153 | QValueList<int>countlist = recList; | 153 | QValueList<int>countlist = recList; |
154 | countlist.append(current_count); | 154 | countlist.append(current_count); |
155 | r = mailmessage_fetch_section(message,mime,&data,&len); | 155 | r = mailmessage_fetch_section(message,mime,&data,&len); |
156 | part.setSize(len); | 156 | part->setSize(len); |
157 | part.setPositionlist(countlist); | 157 | part->setPositionlist(countlist); |
158 | b = gen_attachment_id(); | 158 | b = gen_attachment_id(); |
159 | part.setIdentifier(b); | 159 | part->setIdentifier(b); |
160 | fillSingleBody(part,message,mime); | 160 | fillSingleBody(part,message,mime); |
161 | if (part.Type()=="text" && target.Bodytext().isNull()) { | 161 | if (part->Type()=="text" && target->Bodytext().isNull()) { |
162 | encodedString*rs = new encodedString(); | 162 | encodedString*rs = new encodedString(); |
163 | rs->setContent(data,len); | 163 | rs->setContent(data,len); |
164 | encodedString*res = decode_String(rs,part.Encoding()); | 164 | encodedString*res = decode_String(rs,part->Encoding()); |
165 | if (countlist.count()>2) { | 165 | if (countlist.count()>2) { |
166 | bodyCache[b]=rs; | 166 | bodyCache[b]=rs; |
167 | target.addPart(part); | 167 | target->addPart(part); |
168 | } else { | 168 | } else { |
169 | delete rs; | 169 | delete rs; |
170 | } | 170 | } |
171 | b = QString(res->Content()); | 171 | b = QString(res->Content()); |
172 | delete res; | 172 | delete res; |
173 | target.setBodytext(b); | 173 | target->setBodytext(b); |
174 | target.setDescription(part); | 174 | target->setDescription(part); |
175 | } else { | 175 | } else { |
176 | bodyCache[b]=new encodedString(data,len); | 176 | bodyCache[b]=new encodedString(data,len); |
177 | target.addPart(part); | 177 | target->addPart(part); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | break; | 180 | break; |
@@ -186,11 +186,11 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi | |||
186 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 186 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
187 | cbody = (mailmime*)clist_content(cur); | 187 | cbody = (mailmime*)clist_content(cur); |
188 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 188 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
189 | RecPart targetPart; | 189 | RecPartP targetPart = new RecPart(); |
190 | targetPart.setType("multipart"); | 190 | targetPart->setType("multipart"); |
191 | countlist.append(current_count); | 191 | countlist.append(current_count); |
192 | targetPart.setPositionlist(countlist); | 192 | targetPart->setPositionlist(countlist); |
193 | target.addPart(targetPart); | 193 | target->addPart(targetPart); |
194 | } | 194 | } |
195 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); | 195 | traverseBody(target,message, cbody,countlist,current_rec+1,ccount); |
196 | if (cbody->mm_type==MAILMIME_MULTIPLE) { | 196 | if (cbody->mm_type==MAILMIME_MULTIPLE) { |
@@ -206,16 +206,16 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi | |||
206 | countlist.append(current_count); | 206 | countlist.append(current_count); |
207 | /* the own header is always at recursion 0 - we don't need that */ | 207 | /* the own header is always at recursion 0 - we don't need that */ |
208 | if (current_rec > 0) { | 208 | if (current_rec > 0) { |
209 | part.setPositionlist(countlist); | 209 | part->setPositionlist(countlist); |
210 | r = mailmessage_fetch_section(message,mime,&data,&len); | 210 | r = mailmessage_fetch_section(message,mime,&data,&len); |
211 | part.setSize(len); | 211 | part->setSize(len); |
212 | part.setPositionlist(countlist); | 212 | part->setPositionlist(countlist); |
213 | b = gen_attachment_id(); | 213 | b = gen_attachment_id(); |
214 | part.setIdentifier(b); | 214 | part->setIdentifier(b); |
215 | part.setType("message"); | 215 | part->setType("message"); |
216 | part.setSubtype("rfc822"); | 216 | part->setSubtype("rfc822"); |
217 | bodyCache[b]=new encodedString(data,len); | 217 | bodyCache[b]=new encodedString(data,len); |
218 | target.addPart(part); | 218 | target->addPart(part); |
219 | } | 219 | } |
220 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 220 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
221 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); | 221 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
@@ -225,13 +225,13 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi | |||
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | RecBody Genericwrapper::parseMail( mailmessage * msg ) | 228 | RecBodyP Genericwrapper::parseMail( mailmessage * msg ) |
229 | { | 229 | { |
230 | int err = MAILIMF_NO_ERROR; | 230 | int err = MAILIMF_NO_ERROR; |
231 | mailmime_single_fields fields; | 231 | mailmime_single_fields fields; |
232 | /* is bound to msg and will be freed there */ | 232 | /* is bound to msg and will be freed there */ |
233 | mailmime * mime=0; | 233 | mailmime * mime=0; |
234 | RecBody body; | 234 | RecBodyP body = new RecBody(); |
235 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 235 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
236 | err = mailmessage_get_bodystructure(msg,&mime); | 236 | err = mailmessage_get_bodystructure(msg,&mime); |
237 | QValueList<int>recList; | 237 | QValueList<int>recList; |
@@ -332,23 +332,23 @@ QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) | |||
332 | return result; | 332 | return result; |
333 | } | 333 | } |
334 | 334 | ||
335 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPart&part) | 335 | encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part) |
336 | { | 336 | { |
337 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); | 337 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
338 | if (it==bodyCache.end()) return new encodedString(); | 338 | if (it==bodyCache.end()) return new encodedString(); |
339 | encodedString*t = decode_String(it.data(),part.Encoding()); | 339 | encodedString*t = decode_String(it.data(),part->Encoding()); |
340 | return t; | 340 | return t; |
341 | } | 341 | } |
342 | 342 | ||
343 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part) | 343 | encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part) |
344 | { | 344 | { |
345 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); | 345 | QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier()); |
346 | if (it==bodyCache.end()) return new encodedString(); | 346 | if (it==bodyCache.end()) return new encodedString(); |
347 | encodedString*t = it.data(); | 347 | encodedString*t = it.data(); |
348 | return t; | 348 | return t; |
349 | } | 349 | } |
350 | 350 | ||
351 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part) | 351 | QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
352 | { | 352 | { |
353 | encodedString*t = fetchDecodedPart(mail,part); | 353 | encodedString*t = fetchDecodedPart(mail,part); |
354 | QString text=t->Content(); | 354 | QString text=t->Content(); |