Diffstat (limited to 'noncore/net/mailit/emailhandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mailit/emailhandler.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp index 1be16d4..9c1c814 100644 --- a/noncore/net/mailit/emailhandler.cpp +++ b/noncore/net/mailit/emailhandler.cpp | |||
@@ -97,49 +97,49 @@ void EmailHandler::setAccount(MailAccount account) | |||
97 | void EmailHandler::getMail() | 97 | void EmailHandler::getMail() |
98 | { | 98 | { |
99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 99 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
100 | if (mailAccount.synchronize) { | 100 | if (mailAccount.synchronize) { |
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 | ||
111 | void EmailHandler::getMailHeaders() | 111 | void EmailHandler::getMailHeaders() |
112 | { | 112 | { |
113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); | 113 | popClient->setAccount(mailAccount.popUserName, mailAccount.popPasswd); |
114 | if (mailAccount.synchronize) { | 114 | if (mailAccount.synchronize) { |
115 | popClient->setSynchronize(mailAccount.lastServerMailCount); | 115 | popClient->setSynchronize(mailAccount.lastServerMailCount); |
116 | } else { | 116 | } else { |
117 | popClient->removeSynchronize(); | 117 | popClient->removeSynchronize(); |
118 | } | 118 | } |
119 | 119 | ||
120 | headers = TRUE; | 120 | headers = TRUE; |
121 | popClient->headersOnly(headers, 2000); //less than 2000, download all | 121 | popClient->headersOnly(headers, mailAccount.syncLimit); //less than requested syncLimit, download all |
122 | popClient->newConnection(mailAccount.popServer, 110); | 122 | popClient->newConnection(mailAccount.popServer, 110); |
123 | } | 123 | } |
124 | 124 | ||
125 | void EmailHandler::getMailByList(MailList *mailList) | 125 | void EmailHandler::getMailByList(MailList *mailList) |
126 | { | 126 | { |
127 | if (mailList->count() == 0) { //should not occur though | 127 | if (mailList->count() == 0) { //should not occur though |
128 | emit mailTransfered(0); | 128 | emit mailTransfered(0); |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | 131 | ||
132 | headers = FALSE; | 132 | headers = FALSE; |
133 | popClient->headersOnly(FALSE, 0); | 133 | popClient->headersOnly(FALSE, 0); |
134 | popClient->newConnection(mailAccount.popServer, 110); | 134 | popClient->newConnection(mailAccount.popServer, 110); |
135 | popClient->setSelectedMails(mailList); | 135 | popClient->setSelectedMails(mailList); |
136 | } | 136 | } |
137 | 137 | ||
138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) | 138 | void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) |
139 | { | 139 | { |
140 | Email mail; | 140 | Email mail; |
141 | 141 | ||
142 | mail.rawMail = message; | 142 | mail.rawMail = message; |
143 | mail.serverId = id; | 143 | mail.serverId = id; |
144 | mail.size = size; | 144 | mail.size = size; |
145 | mail.downloaded = complete; | 145 | mail.downloaded = complete; |
@@ -179,60 +179,69 @@ bool EmailHandler::parse(QString in, QString lineShift, Email *mail) | |||
179 | TextParser p(header, lineShift); | 179 | TextParser p(header, lineShift); |
180 | 180 | ||
181 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { | 181 | if ((pos = p.find("FROM",':', 0, TRUE)) != -1) { |
182 | pos++; | 182 | pos++; |
183 | if (p.separatorAt(pos) == ' ') { | 183 | if (p.separatorAt(pos) == ' ') { |
184 | mail->from = p.getString(&pos, '<', false); | 184 | mail->from = p.getString(&pos, '<', false); |
185 | mail->from = mail->from.stripWhiteSpace(); | 185 | mail->from = mail->from.stripWhiteSpace(); |
186 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { | 186 | if ( (mail->from.length() > 2) && (mail->from[0] == '"') ) { |
187 | mail->from = mail->from.left(mail->from.length() - 1); | 187 | mail->from = mail->from.left(mail->from.length() - 1); |
188 | mail->from = mail->from.right(mail->from.length() - 1); | 188 | mail->from = mail->from.right(mail->from.length() - 1); |
189 | } | 189 | } |
190 | pos++; | 190 | pos++; |
191 | mail->fromMail = p.getString(&pos, '>', false); | 191 | mail->fromMail = p.getString(&pos, '>', false); |
192 | } else { | 192 | } else { |
193 | if ((p.separatorAt(pos) == '<') | 193 | if ((p.separatorAt(pos) == '<') |
194 | || (p.separatorAt(pos) == ' ')) //No name.. nasty | 194 | || (p.separatorAt(pos) == ' ')) //No name.. nasty |
195 | pos++; | 195 | pos++; |
196 | pos++; | 196 | pos++; |
197 | mail->fromMail = p.getString(&pos, 'z', TRUE); | 197 | mail->fromMail = p.getString(&pos, 'z', TRUE); |
198 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') | 198 | if (mail->fromMail.at(mail->fromMail.length()-1) == '>') |
199 | mail->fromMail.truncate(mail->fromMail.length() - 1); | 199 | mail->fromMail.truncate(mail->fromMail.length() - 1); |
200 | mail->from=mail->fromMail; | 200 | mail->from=mail->fromMail; |
201 | } | 201 | } |
202 | } | 202 | } |
203 | |||
204 | //@@@ToDo: Rewrite the parser as To: stops at the first occurence- which is Delivered-To: | ||
205 | if (pos = p.find("TO",':', pos, TRUE) != -1) | ||
206 | { | ||
207 | pos++; | ||
208 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | ||
209 | } | ||
210 | |||
211 | |||
212 | |||
203 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { | 213 | if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { |
204 | pos++; | 214 | pos++; |
205 | mail->subject = p.getString(&pos, 'z', TRUE); | 215 | mail->subject = p.getString(&pos, 'z', TRUE); |
206 | } | 216 | } |
207 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { | 217 | if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { |
208 | pos++; | 218 | pos++; |
209 | mail->date = p.getString(&pos, 'z', true); | 219 | mail->date = p.getString(&pos, 'z', true); |
210 | } | 220 | } |
211 | if ((pos = p.find("TO",':', 0, TRUE)) != -1) { | 221 | |
212 | pos++; | 222 | |
213 | mail->recipients.append (p.getString(&pos, 'z', TRUE) ); | 223 | |
214 | } | ||
215 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { | 224 | if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { |
216 | pos++; | 225 | pos++; |
217 | if ( (p.wordAt(pos).upper() == "ID") && | 226 | if ( (p.wordAt(pos).upper() == "ID") && |
218 | (p.separatorAt(pos) == ':') ) { | 227 | (p.separatorAt(pos) == ':') ) { |
219 | 228 | ||
220 | id = p.getString(&pos, 'z', TRUE); | 229 | id = p.getString(&pos, 'z', TRUE); |
221 | mail->id = id; | 230 | mail->id = id; |
222 | } | 231 | } |
223 | } | 232 | } |
224 | 233 | ||
225 | pos = 0; | 234 | pos = 0; |
226 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { | 235 | while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { |
227 | pos++; | 236 | pos++; |
228 | if ( (p.wordAt(pos).upper() == "VERSION") && | 237 | if ( (p.wordAt(pos).upper() == "VERSION") && |
229 | (p.separatorAt(pos) == ':') ) { | 238 | (p.separatorAt(pos) == ':') ) { |
230 | pos++; | 239 | pos++; |
231 | if (p.getString(&pos, 'z', true) == "1.0") { | 240 | if (p.getString(&pos, 'z', true) == "1.0") { |
232 | mail->mimeType = 1; | 241 | mail->mimeType = 1; |
233 | } | 242 | } |
234 | } | 243 | } |
235 | } | 244 | } |
236 | 245 | ||
237 | if (mail->mimeType == 1) { | 246 | if (mail->mimeType == 1) { |
238 | boundary = ""; | 247 | boundary = ""; |