summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mailit/emailhandler.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/mailit/emailhandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mailit/emailhandler.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp
index 59ccd90..39f693d 100644
--- a/noncore/unsupported/mailit/emailhandler.cpp
+++ b/noncore/unsupported/mailit/emailhandler.cpp
@@ -166,26 +166,28 @@ bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mai
166 if (in.right(temp.length()) != temp) { 166 if (in.right(temp.length()) != temp) {
167 mail->rawMail += temp; 167 mail->rawMail += temp;
168 } 168 }
169 169
170 170
171 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" 171 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n"
172 pos = in.find(delimiter, 0, FALSE); 172 pos = in.find(delimiter, 0, FALSE);
173 header = in.left(pos); 173 header = in.left(pos);
174 body = in.right(in.length() - pos - delimiter.length()); 174 body = in.right(in.length() - pos - delimiter.length());
175 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) 175 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n'))
176 body.truncate(body.length()-2); 176 body.truncate(body.length()-2);
177 177
178 TextParser p(header, lineShift); 178 // TextParser p(header, lineShift);
179 179 TextParser * lp = new TextParser(header, lineShift);
180#define p (*lp)
181
180 if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { 182 if ((pos = p.find("FROM",':', 0, TRUE)) != -1) {
181 pos++; 183 pos++;
182 if (p.separatorAt(pos) == ' ') { 184 if (p.separatorAt(pos) == ' ') {
183 mail->from = p.getString(&pos, '<', false); 185 mail->from = p.getString(&pos, '<', false);
184 mail->from = mail->from.stripWhiteSpace(); 186 mail->from = mail->from.stripWhiteSpace();
185 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { 187 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) {
186 mail->from = mail->from.left(mail->from.length() - 1); 188 mail->from = mail->from.left(mail->from.length() - 1);
187 mail->from = mail->from.right(mail->from.length() - 1); 189 mail->from = mail->from.right(mail->from.length() - 1);
188 } 190 }
189 pos++; 191 pos++;
190 mail->fromMail = p.getString(&pos, '>', false); 192 mail->fromMail = p.getString(&pos, '>', false);
191 } else { 193 } else {
@@ -261,24 +263,25 @@ bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mai
261 pos++; 263 pos++;
262 boundary = p.getString(&pos, 'z', true); 264 boundary = p.getString(&pos, 'z', true);
263 if (boundary[0] == '"') { 265 if (boundary[0] == '"') {
264 boundary = boundary.left(boundary.length() - 1); //strip " 266 boundary = boundary.left(boundary.length() - 1); //strip "
265 boundary = boundary.right(boundary.length() - 1); //strip " 267 boundary = boundary.right(boundary.length() - 1); //strip "
266 } 268 }
267 boundary = "--" + boundary; //create boundary field 269 boundary = "--" + boundary; //create boundary field
268 } 270 }
269 271
270 if (boundary == "") { //fooled by Mime-Version 272 if (boundary == "") { //fooled by Mime-Version
271 mail->body = body; 273 mail->body = body;
272 mail->bodyPlain = body; 274 mail->bodyPlain = body;
275 delete lp;
273 return mail; 276 return mail;
274 } 277 }
275 278
276 while (body.length() > 0) { 279 while (body.length() > 0) {
277 pos = body.find(boundary, 0, FALSE); 280 pos = body.find(boundary, 0, FALSE);
278 pos = body.find(delimiter, pos, FALSE); 281 pos = body.find(delimiter, pos, FALSE);
279 mimeHeader = body.left(pos); 282 mimeHeader = body.left(pos);
280 mimeBody = body.right(body.length() - pos - delimiter.length()); 283 mimeBody = body.right(body.length() - pos - delimiter.length());
281 TextParser bp(mimeHeader, lineShift); 284 TextParser bp(mimeHeader, lineShift);
282 285
283 contentType = ""; 286 contentType = "";
284 contentAttribute = ""; 287 contentAttribute = "";
@@ -329,24 +332,25 @@ bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mai
329 mail->body = mimeBody; 332 mail->body = mimeBody;
330 mail->bodyPlain = mimeBody; 333 mail->bodyPlain = mimeBody;
331 } 334 }
332 if (contentAttribute == "HTML") { 335 if (contentAttribute == "HTML") {
333 mail->body = mimeBody; 336 mail->body = mimeBody;
334 } 337 }
335 } 338 }
336 } 339 }
337 } else { 340 } else {
338 mail->bodyPlain = body; 341 mail->bodyPlain = body;
339 mail->body = body; 342 mail->body = body;
340 } 343 }
344 delete lp;
341 return TRUE; 345 return TRUE;
342} 346}
343 347
344bool EmailHandler::getEnclosure(Enclosure *ePtr) 348bool EmailHandler::getEnclosure(Enclosure *ePtr)
345{ 349{
346 QFile f(ePtr->path + ePtr->name); 350 QFile f(ePtr->path + ePtr->name);
347 char src[4]; 351 char src[4];
348 char *destPtr; 352 char *destPtr;
349 QByteArray buffer; 353 QByteArray buffer;
350 uint bufCount, pos, decodedCount, size, x; 354 uint bufCount, pos, decodedCount, size, x;
351 355
352 if (! f.open(IO_WriteOnly) ) { 356 if (! f.open(IO_WriteOnly) ) {