summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/emailhandler.cpp4
-rw-r--r--noncore/unsupported/mailit/emailhandler.cpp4
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/net/mailit/emailhandler.cpp b/noncore/net/mailit/emailhandler.cpp
index a086dfc..2144899 100644
--- a/noncore/net/mailit/emailhandler.cpp
+++ b/noncore/net/mailit/emailhandler.cpp
@@ -88,200 +88,200 @@ void EmailHandler::sendMail(QList<Email> *mailList)
88 } 88 }
89 smtpClient->newConnection(mailAccount.smtpServer, 25); 89 smtpClient->newConnection(mailAccount.smtpServer, 25);
90} 90}
91 91
92void EmailHandler::setAccount(MailAccount account) 92void EmailHandler::setAccount(MailAccount account)
93{ 93{
94 mailAccount = account; 94 mailAccount = account;
95} 95}
96 96
97void EmailHandler::getMail() 97void 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
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 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, 2000); //less than 2000, download all
122 popClient->newConnection(mailAccount.popServer, 110); 122 popClient->newConnection(mailAccount.popServer, 110);
123} 123}
124 124
125void EmailHandler::getMailByList(MailList *mailList) 125void 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
138void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) 138void 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;
146 146
147 emit mailArrived(mail, FALSE); 147 emit mailArrived(mail, FALSE);
148} 148}
149 149
150bool EmailHandler::parse(QString in, QString lineShift, Email *mail) 150bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
151{ 151{
152 QString temp, boundary; 152 QString temp, boundary;
153 int pos; 153 int pos;
154 QString delimiter, header, body, mimeHeader, mimeBody; 154 QString delimiter, header, body, mimeHeader, mimeBody;
155 QString content, contentType, contentAttribute, id, encoding; 155 QString content, contentType, contentAttribute, id, encoding;
156 QString fileName, storedName; 156 QString fileName, storedName;
157 int enclosureId = 0; 157 int enclosureId = 0;
158 158
159 mail->rawMail = in; 159 mail->rawMail = in;
160 mail->received = TRUE; 160 mail->received = TRUE;
161 mail->files.setAutoDelete(TRUE); 161 mail->files.setAutoDelete(TRUE);
162 162
163 temp = lineShift + "." + lineShift; 163 temp = lineShift + "." + lineShift;
164 164
165 if (in.right(temp.length()) != temp) { 165 if (in.right(temp.length()) != temp) {
166 qWarning(in.right(temp.length())); 166 qWarning(in.right(temp.length()));
167 qWarning(" . added at end of email as separator"); 167 qWarning(" . added at end of email as separator");
168 mail->rawMail += temp; 168 mail->rawMail += temp;
169 } 169 }
170 170
171 171
172 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" 172 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n"
173 pos = in.find(delimiter, 0, FALSE); 173 pos = in.find(delimiter, 0, FALSE);
174 header = in.left(pos); 174 header = in.left(pos);
175 body = in.right(in.length() - pos - delimiter.length()); 175 body = in.right(in.length() - pos - delimiter.length());
176 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) 176 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n'))
177 body.truncate(body.length()-2); 177 body.truncate(body.length()-2);
178 178
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, '<'); 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, '>'); 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 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { 203 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
204 pos++; 204 pos++;
205 mail->subject = p.getString(&pos, 'z', TRUE); 205 mail->subject = p.getString(&pos, 'z', TRUE);
206 } 206 }
207 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { 207 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
208 pos++; 208 pos++;
209 mail->date = p.getString(&pos, 'z', true); 209 mail->date = p.getString(&pos, 'z', true);
210 } 210 }
211 if ((pos = p.find("TO",':', 0, TRUE)) != -1) { 211 if ((pos = p.find("TO",':', 0, TRUE)) != -1) {
212 pos++; 212 pos++;
213 mail->recipients.append (p.getString(&pos, 'z', TRUE) ); 213 mail->recipients.append (p.getString(&pos, 'z', TRUE) );
214 } 214 }
215 if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { 215 if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) {
216 pos++; 216 pos++;
217 if ( (p.wordAt(pos).upper() == "ID") && 217 if ( (p.wordAt(pos).upper() == "ID") &&
218 (p.separatorAt(pos) == ':') ) { 218 (p.separatorAt(pos) == ':') ) {
219 219
220 id = p.getString(&pos, 'z', TRUE); 220 id = p.getString(&pos, 'z', TRUE);
221 mail->id = id; 221 mail->id = id;
222 } 222 }
223 } 223 }
224 224
225 pos = 0; 225 pos = 0;
226 while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { 226 while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) {
227 pos++; 227 pos++;
228 if ( (p.wordAt(pos).upper() == "VERSION") && 228 if ( (p.wordAt(pos).upper() == "VERSION") &&
229 (p.separatorAt(pos) == ':') ) { 229 (p.separatorAt(pos) == ':') ) {
230 pos++; 230 pos++;
231 if (p.getString(&pos, 'z', true) == "1.0") { 231 if (p.getString(&pos, 'z', true) == "1.0") {
232 mail->mimeType = 1; 232 mail->mimeType = 1;
233 } 233 }
234 } 234 }
235 } 235 }
236 236
237 if (mail->mimeType == 1) { 237 if (mail->mimeType == 1) {
238 boundary = ""; 238 boundary = "";
239 if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { 239 if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) {
240 pos++; 240 pos++;
241 boundary = p.getString(&pos, 'z', true); 241 boundary = p.getString(&pos, 'z', true);
242 if (boundary[0] == '"') { 242 if (boundary[0] == '"') {
243 boundary = boundary.left(boundary.length() - 1); //strip " 243 boundary = boundary.left(boundary.length() - 1); //strip "
244 boundary = boundary.right(boundary.length() - 1); //strip " 244 boundary = boundary.right(boundary.length() - 1); //strip "
245 } 245 }
246 boundary = "--" + boundary; //create boundary field 246 boundary = "--" + boundary; //create boundary field
247 } 247 }
248 248
249 if (boundary == "") { //fooled by Mime-Version 249 if (boundary == "") { //fooled by Mime-Version
250 mail->body = body; 250 mail->body = body;
251 mail->bodyPlain = body; 251 mail->bodyPlain = body;
252 return mail; 252 return mail;
253 } 253 }
254 254
255 while (body.length() > 0) { 255 while (body.length() > 0) {
256 pos = body.find(boundary, 0, FALSE); 256 pos = body.find(boundary, 0, FALSE);
257 pos = body.find(delimiter, pos, FALSE); 257 pos = body.find(delimiter, pos, FALSE);
258 mimeHeader = body.left(pos); 258 mimeHeader = body.left(pos);
259 mimeBody = body.right(body.length() - pos - delimiter.length()); 259 mimeBody = body.right(body.length() - pos - delimiter.length());
260 TextParser bp(mimeHeader, lineShift); 260 TextParser bp(mimeHeader, lineShift);
261 261
262 contentType = ""; 262 contentType = "";
263 contentAttribute = ""; 263 contentAttribute = "";
264 fileName = ""; 264 fileName = "";
265 if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { 265 if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) {
266 pos++; 266 pos++;
267 if ( (bp.wordAt(pos).upper() == "TYPE") && 267 if ( (bp.wordAt(pos).upper() == "TYPE") &&
268 (bp.separatorAt(pos) == ':') ) { 268 (bp.separatorAt(pos) == ':') ) {
269 contentType = bp.nextWord().upper(); 269 contentType = bp.nextWord().upper();
270 if (bp.nextSeparator() == '/') 270 if (bp.nextSeparator() == '/')
271 contentAttribute = bp.nextWord().upper(); 271 contentAttribute = bp.nextWord().upper();
272 content = contentType + "/" + contentAttribute; 272 content = contentType + "/" + contentAttribute;
273 } 273 }
274 if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { 274 if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) {
275 pos++; 275 pos++;
276 encoding = bp.getString(&pos, 'z', TRUE); 276 encoding = bp.getString(&pos, 'z', TRUE);
277 } 277 }
278 278
279 if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { 279 if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) {
280 pos++; 280 pos++;
281 fileName = bp.getString(&pos, 'z', TRUE); 281 fileName = bp.getString(&pos, 'z', TRUE);
282 fileName = fileName.right(fileName.length() - 1); 282 fileName = fileName.right(fileName.length() - 1);
283 fileName = fileName.left(fileName.length() - 1); 283 fileName = fileName.left(fileName.length() - 1);
284 } 284 }
285 285
286 } 286 }
287 pos = mimeBody.find(boundary, 0, FALSE); 287 pos = mimeBody.find(boundary, 0, FALSE);
diff --git a/noncore/unsupported/mailit/emailhandler.cpp b/noncore/unsupported/mailit/emailhandler.cpp
index a086dfc..2144899 100644
--- a/noncore/unsupported/mailit/emailhandler.cpp
+++ b/noncore/unsupported/mailit/emailhandler.cpp
@@ -88,200 +88,200 @@ void EmailHandler::sendMail(QList<Email> *mailList)
88 } 88 }
89 smtpClient->newConnection(mailAccount.smtpServer, 25); 89 smtpClient->newConnection(mailAccount.smtpServer, 25);
90} 90}
91 91
92void EmailHandler::setAccount(MailAccount account) 92void EmailHandler::setAccount(MailAccount account)
93{ 93{
94 mailAccount = account; 94 mailAccount = account;
95} 95}
96 96
97void EmailHandler::getMail() 97void 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
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 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, 2000); //less than 2000, download all
122 popClient->newConnection(mailAccount.popServer, 110); 122 popClient->newConnection(mailAccount.popServer, 110);
123} 123}
124 124
125void EmailHandler::getMailByList(MailList *mailList) 125void 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
138void EmailHandler::messageArrived(const QString &message, int id, uint size, bool complete) 138void 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;
146 146
147 emit mailArrived(mail, FALSE); 147 emit mailArrived(mail, FALSE);
148} 148}
149 149
150bool EmailHandler::parse(QString in, QString lineShift, Email *mail) 150bool EmailHandler::parse(QString in, QString lineShift, Email *mail)
151{ 151{
152 QString temp, boundary; 152 QString temp, boundary;
153 int pos; 153 int pos;
154 QString delimiter, header, body, mimeHeader, mimeBody; 154 QString delimiter, header, body, mimeHeader, mimeBody;
155 QString content, contentType, contentAttribute, id, encoding; 155 QString content, contentType, contentAttribute, id, encoding;
156 QString fileName, storedName; 156 QString fileName, storedName;
157 int enclosureId = 0; 157 int enclosureId = 0;
158 158
159 mail->rawMail = in; 159 mail->rawMail = in;
160 mail->received = TRUE; 160 mail->received = TRUE;
161 mail->files.setAutoDelete(TRUE); 161 mail->files.setAutoDelete(TRUE);
162 162
163 temp = lineShift + "." + lineShift; 163 temp = lineShift + "." + lineShift;
164 164
165 if (in.right(temp.length()) != temp) { 165 if (in.right(temp.length()) != temp) {
166 qWarning(in.right(temp.length())); 166 qWarning(in.right(temp.length()));
167 qWarning(" . added at end of email as separator"); 167 qWarning(" . added at end of email as separator");
168 mail->rawMail += temp; 168 mail->rawMail += temp;
169 } 169 }
170 170
171 171
172 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n" 172 delimiter = lineShift + lineShift; // "\n\n" or "\r\n\r\n"
173 pos = in.find(delimiter, 0, FALSE); 173 pos = in.find(delimiter, 0, FALSE);
174 header = in.left(pos); 174 header = in.left(pos);
175 body = in.right(in.length() - pos - delimiter.length()); 175 body = in.right(in.length() - pos - delimiter.length());
176 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n')) 176 if ((body.at(body.length()-2) == '.') && (body.at(body.length()-3) == '\n'))
177 body.truncate(body.length()-2); 177 body.truncate(body.length()-2);
178 178
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, '<'); 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, '>'); 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 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) { 203 if ((pos = p.find("SUBJECT",':', 0, TRUE)) != -1) {
204 pos++; 204 pos++;
205 mail->subject = p.getString(&pos, 'z', TRUE); 205 mail->subject = p.getString(&pos, 'z', TRUE);
206 } 206 }
207 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) { 207 if ((pos = p.find("DATE",':', 0, TRUE)) != -1) {
208 pos++; 208 pos++;
209 mail->date = p.getString(&pos, 'z', true); 209 mail->date = p.getString(&pos, 'z', true);
210 } 210 }
211 if ((pos = p.find("TO",':', 0, TRUE)) != -1) { 211 if ((pos = p.find("TO",':', 0, TRUE)) != -1) {
212 pos++; 212 pos++;
213 mail->recipients.append (p.getString(&pos, 'z', TRUE) ); 213 mail->recipients.append (p.getString(&pos, 'z', TRUE) );
214 } 214 }
215 if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) { 215 if ((pos = p.find("MESSAGE",'-', 0, TRUE)) != -1) {
216 pos++; 216 pos++;
217 if ( (p.wordAt(pos).upper() == "ID") && 217 if ( (p.wordAt(pos).upper() == "ID") &&
218 (p.separatorAt(pos) == ':') ) { 218 (p.separatorAt(pos) == ':') ) {
219 219
220 id = p.getString(&pos, 'z', TRUE); 220 id = p.getString(&pos, 'z', TRUE);
221 mail->id = id; 221 mail->id = id;
222 } 222 }
223 } 223 }
224 224
225 pos = 0; 225 pos = 0;
226 while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) { 226 while ( ((pos = p.find("MIME",'-', pos, TRUE)) != -1) ) {
227 pos++; 227 pos++;
228 if ( (p.wordAt(pos).upper() == "VERSION") && 228 if ( (p.wordAt(pos).upper() == "VERSION") &&
229 (p.separatorAt(pos) == ':') ) { 229 (p.separatorAt(pos) == ':') ) {
230 pos++; 230 pos++;
231 if (p.getString(&pos, 'z', true) == "1.0") { 231 if (p.getString(&pos, 'z', true) == "1.0") {
232 mail->mimeType = 1; 232 mail->mimeType = 1;
233 } 233 }
234 } 234 }
235 } 235 }
236 236
237 if (mail->mimeType == 1) { 237 if (mail->mimeType == 1) {
238 boundary = ""; 238 boundary = "";
239 if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) { 239 if ((pos = p.find("BOUNDARY", '=', 0, TRUE)) != -1) {
240 pos++; 240 pos++;
241 boundary = p.getString(&pos, 'z', true); 241 boundary = p.getString(&pos, 'z', true);
242 if (boundary[0] == '"') { 242 if (boundary[0] == '"') {
243 boundary = boundary.left(boundary.length() - 1); //strip " 243 boundary = boundary.left(boundary.length() - 1); //strip "
244 boundary = boundary.right(boundary.length() - 1); //strip " 244 boundary = boundary.right(boundary.length() - 1); //strip "
245 } 245 }
246 boundary = "--" + boundary; //create boundary field 246 boundary = "--" + boundary; //create boundary field
247 } 247 }
248 248
249 if (boundary == "") { //fooled by Mime-Version 249 if (boundary == "") { //fooled by Mime-Version
250 mail->body = body; 250 mail->body = body;
251 mail->bodyPlain = body; 251 mail->bodyPlain = body;
252 return mail; 252 return mail;
253 } 253 }
254 254
255 while (body.length() > 0) { 255 while (body.length() > 0) {
256 pos = body.find(boundary, 0, FALSE); 256 pos = body.find(boundary, 0, FALSE);
257 pos = body.find(delimiter, pos, FALSE); 257 pos = body.find(delimiter, pos, FALSE);
258 mimeHeader = body.left(pos); 258 mimeHeader = body.left(pos);
259 mimeBody = body.right(body.length() - pos - delimiter.length()); 259 mimeBody = body.right(body.length() - pos - delimiter.length());
260 TextParser bp(mimeHeader, lineShift); 260 TextParser bp(mimeHeader, lineShift);
261 261
262 contentType = ""; 262 contentType = "";
263 contentAttribute = ""; 263 contentAttribute = "";
264 fileName = ""; 264 fileName = "";
265 if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) { 265 if ((pos = bp.find("CONTENT",'-', 0, TRUE)) != -1) {
266 pos++; 266 pos++;
267 if ( (bp.wordAt(pos).upper() == "TYPE") && 267 if ( (bp.wordAt(pos).upper() == "TYPE") &&
268 (bp.separatorAt(pos) == ':') ) { 268 (bp.separatorAt(pos) == ':') ) {
269 contentType = bp.nextWord().upper(); 269 contentType = bp.nextWord().upper();
270 if (bp.nextSeparator() == '/') 270 if (bp.nextSeparator() == '/')
271 contentAttribute = bp.nextWord().upper(); 271 contentAttribute = bp.nextWord().upper();
272 content = contentType + "/" + contentAttribute; 272 content = contentType + "/" + contentAttribute;
273 } 273 }
274 if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) { 274 if ((pos = bp.find("ENCODING",':', 0, TRUE)) != -1) {
275 pos++; 275 pos++;
276 encoding = bp.getString(&pos, 'z', TRUE); 276 encoding = bp.getString(&pos, 'z', TRUE);
277 } 277 }
278 278
279 if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) { 279 if ( (pos = bp.find("FILENAME",'=', 0, TRUE)) != -1) {
280 pos++; 280 pos++;
281 fileName = bp.getString(&pos, 'z', TRUE); 281 fileName = bp.getString(&pos, 'z', TRUE);
282 fileName = fileName.right(fileName.length() - 1); 282 fileName = fileName.right(fileName.length() - 1);
283 fileName = fileName.left(fileName.length() - 1); 283 fileName = fileName.left(fileName.length() - 1);
284 } 284 }
285 285
286 } 286 }
287 pos = mimeBody.find(boundary, 0, FALSE); 287 pos = mimeBody.find(boundary, 0, FALSE);