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.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp
index 62fa64f..59ccd90 100644
--- a/noncore/unsupported/mailit/emailhandler.cpp
+++ b/noncore/unsupported/mailit/emailhandler.cpp
@@ -30,25 +30,25 @@ QCollection::Item EnclosureList::newItem(QCollection::Item d)
30{ 30{
31 return dupl( (Enclosure *) d); 31 return dupl( (Enclosure *) d);
32} 32}
33 33
34Enclosure* EnclosureList::dupl(Enclosure *in) 34Enclosure* EnclosureList::dupl(Enclosure *in)
35{ 35{
36 ac = new Enclosure(*in); 36 ac = new Enclosure(*in);
37 return ac; 37 return ac;
38} 38}
39 39
40EmailHandler::EmailHandler() 40EmailHandler::EmailHandler()
41{ 41{
42 qDebug("EMailHandler::EmailHandler"); 42 qDebug("EMailHandler::EmailHandler");
43 43
44 smtpClient = new SmtpClient(); 44 smtpClient = new SmtpClient();
45 popClient = new PopClient(); 45 popClient = new PopClient();
46 46
47 connect(smtpClient, SIGNAL(errorOccurred(int)), this, 47 connect(smtpClient, SIGNAL(errorOccurred(int)), this,
48 SIGNAL(smtpError(int)) ); 48 SIGNAL(smtpError(int)) );
49 connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) ); 49 connect(smtpClient, SIGNAL(mailSent()), this, SIGNAL(mailSent()) );
50 connect(smtpClient, SIGNAL(updateStatus(const QString &)), this, 50 connect(smtpClient, SIGNAL(updateStatus(const QString &)), this,
51 SIGNAL(updateSmtpStatus(const QString &)) ); 51 SIGNAL(updateSmtpStatus(const QString &)) );
52 52
53 connect(popClient, SIGNAL(errorOccurred(int)), this, 53 connect(popClient, SIGNAL(errorOccurred(int)), this,
54 SIGNAL(popError(int)) ); 54 SIGNAL(popError(int)) );
@@ -139,25 +139,25 @@ void EmailHandler::getMailByList(MailList *mailList)
139void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) 139void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete)
140{ 140{
141 Email mail; 141 Email mail;
142 142
143 mail.rawMail = message; 143 mail.rawMail = message;
144 mail.serverId = id; 144 mail.serverId = id;
145 mail.size = size; 145 mail.size = size;
146 mail.downloaded = complete; 146 mail.downloaded = complete;
147 147
148 emit mailArrived(mail, FALSE); 148 emit mailArrived(mail, FALSE);
149} 149}
150 150
151bool EmailHandler::parse(QString in, QString lineShift, Email *mail) 151bool EmailHandler::parse(const QString &in, const QString &lineShift, Email *mail)
152{ 152{
153 QString temp, boundary; 153 QString temp, boundary;
154 int pos; 154 int pos;
155 QString delimiter, header, body, mimeHeader, mimeBody; 155 QString delimiter, header, body, mimeHeader, mimeBody;
156 QString content, contentType, contentAttribute, id, encoding; 156 QString content, contentType, contentAttribute, id, encoding;
157 QString fileName, storedName; 157 QString fileName, storedName;
158 int enclosureId = 0; 158 int enclosureId = 0;
159 159
160 mail->rawMail = in; 160 mail->rawMail = in;
161 mail->received = TRUE; 161 mail->received = TRUE;
162 mail->files.setAutoDelete(TRUE); 162 mail->files.setAutoDelete(TRUE);
163 163
@@ -195,39 +195,39 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
195 mail->fromMail = p.getString(&pos, 'z', TRUE); 195 mail->fromMail = p.getString(&pos, 'z', TRUE);
196 if (mail->fromMail.at(mail->fromMail.length()-1) == '>') 196 if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
197 mail->fromMail.truncate(mail->fromMail.length() - 1); 197 mail->fromMail.truncate(mail->fromMail.length() - 1);
198 mail->from=mail->fromMail; 198 mail->from=mail->fromMail;
199 } 199 }
200 } 200 }
201 201
202 pos=0; 202 pos=0;
203 203
204 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To: 204 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To:
205 while((pos = p.find("TO",':', pos+1, TRUE))!=-1) 205 while((pos = p.find("TO",':', pos+1, TRUE))!=-1)
206 { 206 {
207 QString rec; 207 QString rec;
208 208
209 if (p.separatorAt(pos-1)!='-')//The - separator means that this is a Delivered-To: or Reply-To: 209 if (p.separatorAt(pos-1)!='-') //The - separator means that this is a Delivered-To: or Reply-To:
210 { 210 {
211 pos++; 211 pos++;
212 mail->recipients.append(p.getString(&pos, '\r', TRUE)); 212 mail->recipients.append(p.getString(&pos, '\r', TRUE));
213 } 213 }
214 } 214 }
215 // 215 //
216 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") ); 216 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") );
217 217
218 if ((pos = p.find("CC",':', 0, TRUE)) != -1) 218 if ((pos = p.find("CC",':', 0, TRUE)) != -1)
219 { 219 {
220 pos++; 220 pos++;
221 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); 221 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) );
222 } 222 }
223 223
224 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { 224 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
225 pos++; 225 pos++;
226 mail->subject = p.getString(&pos, 'z', TRUE); 226 mail->subject = p.getString(&pos, 'z', TRUE);
227 } 227 }
228 228
229 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { 229 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
230 pos++; 230 pos++;
231 mail->date = p.getString(&pos, 'z', TRUE); 231 mail->date = p.getString(&pos, 'z', TRUE);
232 } 232 }
233 233
@@ -431,26 +431,26 @@ int EmailHandler::parse64base(char *src, char *bufOut) {
431 } 431 }
432 } 432 }
433 return processed; 433 return processed;
434} 434}
435 435
436int EmailHandler::encodeMime(Email *mail) 436int EmailHandler::encodeMime(Email *mail)
437{ 437{
438 438
439 QString fileName, fileType, contentType, newBody, boundary; 439 QString fileName, fileType, contentType, newBody, boundary;
440 Enclosure *ePtr; 440 Enclosure *ePtr;
441 441
442 QString userName = mailAccount.name; 442 QString userName = mailAccount.name;
443 if (userName.length()>0)//only embrace it if there is a user name 443 if (userName.length()>0) //only embrace it if there is a user name
444 userName += " <" + mailAccount.emailAddress + ">"; 444 userName += " <" + mailAccount.emailAddress + ">";
445 445
446 //add standard headers 446 //add standard headers
447 newBody = "From: " + userName + "\r\nTo: "; 447 newBody = "From: " + userName + "\r\nTo: ";
448 for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) { 448 for (QStringList::Iterator it = mail->recipients.begin(); it != mail->recipients.end(); ++it ) {
449 newBody += *it + " "; 449 newBody += *it + " ";
450 } 450 }
451 451
452 newBody += "\r\nCC: "; 452 newBody += "\r\nCC: ";
453 453
454 for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) { 454 for (QStringList::Iterator it = mail->carbonCopies.begin(); it != mail->carbonCopies.end(); ++it ) {
455 newBody += *it + " "; 455 newBody += *it + " ";
456 } 456 }
@@ -501,25 +501,25 @@ int EmailHandler::encodeMime(Email *mail)
501 fi.fileName() + "\"\r\n\r\n"; 501 fi.fileName() + "\"\r\n\r\n";
502 502
503 if (encodeFile(fileName, &newBody) == -1) //file not found? 503 if (encodeFile(fileName, &newBody) == -1) //file not found?
504 return -1; 504 return -1;
505 } 505 }
506 506
507 newBody += "\r\n\r\n--" + boundary + "--"; 507 newBody += "\r\n\r\n--" + boundary + "--";
508 mail->rawMail = newBody; 508 mail->rawMail = newBody;
509 509
510 return 0; 510 return 0;
511} 511}
512 512
513int EmailHandler::encodeFile(QString fileName, QString *toBody) 513int EmailHandler::encodeFile(const QString &fileName, QString *toBody)
514{ 514{
515 char *fileData; 515 char *fileData;
516 char *dataPtr; 516 char *dataPtr;
517 QString temp; 517 QString temp;
518 uint dataSize, count; 518 uint dataSize, count;
519 QFile f(fileName); 519 QFile f(fileName);
520 520
521 if (! f.open(IO_ReadOnly) ) { 521 if (! f.open(IO_ReadOnly) ) {
522 qWarning("could not open file: " + fileName); 522 qWarning("could not open file: " + fileName);
523 return -1; 523 return -1;
524 } 524 }
525 QTextStream s(&f); 525 QTextStream s(&f);