summaryrefslogtreecommitdiff
path: root/noncore/net/mailit/emailhandler.cpp
Unidiff
Diffstat (limited to 'noncore/net/mailit/emailhandler.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mailit/emailhandler.cpp42
1 files changed, 29 insertions, 13 deletions
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp
index f6c6d60..b180051 100644
--- a/noncore/net/mailit/emailhandler.cpp
+++ b/noncore/net/mailit/emailhandler.cpp
@@ -101,24 +101,20 @@ void EmailHandler::getMail()
101 popClient->setSynchronize(mailAccount.lastServerMailCount); 101 popClient->setSynchronize(mailAccount.lastServerMailCount);
102 } else { 102 } else {
103 popClient->removeSynchronize(); 103 popClient->removeSynchronize();
104 } 104 }
105 105
106 headers = FALSE; 106 headers = FALSE;
107 popClient->headersOnly(headers, 0); 107 //popClient->headersOnly(headers, 0);
108 popClient->newConnection(mailAccount.popServer, 110); 108 popClient->newConnection(mailAccount.popServer, 110);
109} 109}
110 110
111void EmailHandler::getMailHeaders() 111void EmailHandler::getMailHeaders()
112{ 112{
113 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); 113 popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd);
114 if (mailAccount.synchronize) { 114 mailAccount.synchronize ? popClient->setSynchronize(mailAccount.lastServerMailCount): popClient->removeSynchronize();
115 popClient->setSynchronize(mailAccount.lastServerMailCount);
116 } else {
117 popClient->removeSynchronize();
118 }
119 115
120 headers = TRUE; 116 headers = TRUE;
121 popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all 117 popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all
122 popClient->newConnection(mailAccount.popServer, 110); 118 popClient->newConnection(mailAccount.popServer, 110);
123} 119}
124 120
@@ -132,20 +128,20 @@ void EmailHandler::getMailByList(MailList *mailList)
132 headers = FALSE; 128 headers = FALSE;
133 popClient->headersOnly(FALSE, 0); 129 popClient->headersOnly(FALSE, 0);
134 popClient->newConnection(mailAccount.popServer, 110); 130 popClient->newConnection(mailAccount.popServer, 110);
135 popClient->setSelectedMails(mailList); 131 popClient->setSelectedMails(mailList);
136} 132}
137 133
138void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) 134void EmailHandler::messageArrived(const QString &message, int id, uint size, bool incomplete)
139{ 135{
140 Email mail; 136 Email mail;
141 137
142 mail.rawMail = message; 138 mail.rawMail = message;
143 mail.serverId = id; 139 mail.serverId = id;
144 mail.size = size; 140 mail.size = size;
145 mail.downloaded = complete; 141 mail.downloaded = incomplete;
146 142
147 emit mailArrived(mail, FALSE); 143 emit mailArrived(mail, FALSE);
148} 144}
149 145
150bool EmailHandler::parse(QString in, QString lineShift, Email *mail) 146bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
151{ 147{
@@ -183,12 +179,13 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
183 mail->from = mail->from.stripWhiteSpace(); 179 mail->from = mail->from.stripWhiteSpace();
184 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { 180 if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) {
185 mail->from = mail->from.left(mail->from.length() - 1); 181 mail->from = mail->from.left(mail->from.length() - 1);
186 mail->from = mail->from.right(mail->from.length() - 1); 182 mail->from = mail->from.right(mail->from.length() - 1);
187 } 183 }
188 pos++; 184 pos++;
185
189 mail->fromMail = p.getString(&pos, '>', false); 186 mail->fromMail = p.getString(&pos, '>', false);
190 } else { 187 } else {
191 if ((p.separatorAt(pos) == '<') 188 if ((p.separatorAt(pos) == '<')
192 || (p.separatorAt(pos) == ' ')) //No name.. nasty 189 || (p.separatorAt(pos) == ' ')) //No name.. nasty
193 pos++; 190 pos++;
194 pos++; 191 pos++;
@@ -196,34 +193,53 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
196 if (mail->fromMail.at(mail->fromMail.length()-1) == '>') 193 if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
197 mail->fromMail.truncate(mail->fromMail.length() - 1); 194 mail->fromMail.truncate(mail->fromMail.length() - 1);
198 mail->from=mail->fromMail; 195 mail->from=mail->fromMail;
199 } 196 }
200 } 197 }
201 198
202 //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: 199 pos=0;
203 if ((pos = p.find("TO",':', 0, TRUE)) != -1) 200
201 //Search for To: after the FROM: attribute to prevent hitting the Delivered-To:
202 while((pos = p.find("TO",':', pos+1, TRUE))!=-1)
203 {
204 QString rec;
205
206 if (p.separatorAt(pos-1)!='-')
204 { 207 {
205 pos++; 208 pos++;
209 mail->recipients.append(p.getString(&pos, '\r', TRUE));
210 }
211 /*else {
212 if ((p.separatorAt(pos) == '<')|| (p.separatorAt(pos) == ' ')) //No name.. nasty
213 pos++;
214 pos++;
215 mail->fromMail = p.getString(&pos, 'z', TRUE);
216 if (mail->fromMail.at(mail->fromMail.length()-1) == '>')
217 mail->fromMail.truncate(mail->fromMail.length() - 1);
218 mail->from=mail->fromMail;
219 }
206 mail->recipients.append (p.getString(&pos, 'z', TRUE) ); 220 mail->recipients.append (p.getString(&pos, 'z', TRUE) );
221 }*/
207 } 222 }
223 //
224 //if (pos==-1) mail->recipients.append (tr("undisclosed recipients") );
208 225
209 //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To:
210 if ((pos = p.find("CC",':', 0, TRUE)) != -1) 226 if ((pos = p.find("CC",':', 0, TRUE)) != -1)
211 { 227 {
212 pos++; 228 pos++;
213 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) ); 229 mail->carbonCopies.append (p.getString(&pos, 'z', TRUE) );
214 } 230 }
215 231
216
217 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { 232 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
218 pos++; 233 pos++;
219 mail->subject = p.getString(&pos, 'z', TRUE); 234 mail->subject = p.getString(&pos, 'z', TRUE);
220 } 235 }
236
221 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { 237 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
222 pos++; 238 pos++;
223 mail->date = p.getString(&pos, 'z', true); 239 mail->date = p.getString(&pos, 'z', TRUE);
224 } 240 }
225 241
226 242
227 243
228 if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { 244 if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) {
229 pos++; 245 pos++;