-rw-r--r-- | noncore/unsupported/mail2/libmail/configfile.cpp | 4 | ||||
-rw-r--r-- | noncore/unsupported/mail2/libmail/imapbase.cpp | 36 | ||||
-rw-r--r-- | noncore/unsupported/mail2/libmail/imapbase.h | 3 | ||||
-rw-r--r-- | noncore/unsupported/mail2/libmail/imaphandler.cpp | 7 | ||||
-rw-r--r-- | noncore/unsupported/mail2/libmail/imapresponse.cpp | 224 | ||||
-rw-r--r-- | noncore/unsupported/mail2/libmail/imapresponse.h | 5 | ||||
-rw-r--r-- | noncore/unsupported/mail2/viewmail.cpp | 4 |
7 files changed, 194 insertions, 89 deletions
diff --git a/noncore/unsupported/mail2/libmail/configfile.cpp b/noncore/unsupported/mail2/libmail/configfile.cpp index a5c2b49..082b330 100644 --- a/noncore/unsupported/mail2/libmail/configfile.cpp +++ b/noncore/unsupported/mail2/libmail/configfile.cpp | |||
@@ -101,12 +101,12 @@ QString ConfigFile::rot13(const QString &input) | |||
101 | int l = i.length(); | 101 | int l = i.length(); |
102 | while(l--) { | 102 | while(l--) { |
103 | if (i[l] >= QChar('A') && i[l] <= QChar('M') || | 103 | if (i[l] >= QChar('A') && i[l] <= QChar('M') || |
104 | i[l] >= QChar('a') && i[l] <= QChar('m')) | 104 | i[l] >= QChar('a') && i[l] <= QChar('m')) |
105 | i[l] = (char)((int)QChar(l[i])+13); | 105 | i[l] = QChar(i[l].unicode()+13); |
106 | else if (i[l] >= QChar('N') && i[l] <= QChar('Z') || | 106 | else if (i[l] >= QChar('N') && i[l] <= QChar('Z') || |
107 | i[l] >= QChar('n') && i[l] <= QChar('z')) | 107 | i[l] >= QChar('n') && i[l] <= QChar('z')) |
108 | i[l] = (char)((int)QChar(l[i])-13); | 108 | i[l] = QChar(i[l].unicode()-13); |
109 | } | 109 | } |
110 | return i; | 110 | return i; |
111 | } | 111 | } |
112 | 112 | ||
diff --git a/noncore/unsupported/mail2/libmail/imapbase.cpp b/noncore/unsupported/mail2/libmail/imapbase.cpp index 9a2ba47..4753f43 100644 --- a/noncore/unsupported/mail2/libmail/imapbase.cpp +++ b/noncore/unsupported/mail2/libmail/imapbase.cpp | |||
@@ -52,12 +52,16 @@ void IMAPBase::writeCommands() | |||
52 | QStringList::Iterator it; | 52 | QStringList::Iterator it; |
53 | for (it = _commandQueue.begin(); it != _commandQueue.end(); it++) { | 53 | for (it = _commandQueue.begin(); it != _commandQueue.end(); it++) { |
54 | if (!(*it).isEmpty() && _writingAllowed) { | 54 | if (!(*it).isEmpty() && _writingAllowed) { |
55 | #ifndef QT_NO_DEBUG | 55 | #ifndef QT_NO_DEBUG |
56 | qDebug("IMAP > " + (*it).stripWhiteSpace()); | 56 | qDebug("IMAP > " + (*it).stripWhiteSpace().local8Bit ()); |
57 | #endif | 57 | #endif |
58 | _socket->writeBlock((*it).latin1(), (*it).length()); | 58 | _socket->writeBlock((*it).latin1(), (*it).length()); |
59 | _writingAllowed = false; | 59 | _writingAllowed = false; |
60 | if (( *it ). find ( QRegExp ( "^[a-z][0-9]+ " )) == 0 ) | ||
61 | _lasttag = (*it).left(2); | ||
62 | |||
63 | connect(_socket, SIGNAL(readyRead()), SLOT(slotDataAvailiable())); | ||
60 | _commandQueue.remove(it); | 64 | _commandQueue.remove(it); |
61 | break; | 65 | break; |
62 | } | 66 | } |
63 | } | 67 | } |
@@ -92,19 +96,37 @@ void IMAPBase::slotDisconnected() | |||
92 | _connected = false; | 96 | _connected = false; |
93 | emit disconnected(); | 97 | emit disconnected(); |
94 | } | 98 | } |
95 | 99 | ||
100 | #include <unistd.h> | ||
101 | |||
96 | void IMAPBase::slotDataAvailiable() | 102 | void IMAPBase::slotDataAvailiable() |
97 | { | 103 | { |
104 | static bool firstline = true; | ||
105 | |||
98 | while (_socket->canReadLine()) { | 106 | while (_socket->canReadLine()) { |
99 | _data += _socket->readLine(); | 107 | QString tmp = _socket-> readLine ( ); |
100 | if (_socket->atEnd()) { | 108 | |
101 | #ifndef QT_NO_DEBUG | 109 | _data += tmp; |
102 | qDebug("IMAP < " + _data.stripWhiteSpace()); | 110 | qDebug ( "New Line [%d]: '%s'\n", _connected ? 1 : 0, tmp.latin1( )); |
103 | #endif | 111 | |
112 | if ( firstline || tmp. left(2) == _lasttag ) { | ||
113 | firstline = false; | ||
114 | |||
115 | // if ( _socket-> atEnd ( )) | ||
116 | qDebug ( "at end -> emitting\n" ); | ||
117 | |||
118 | QObject::disconnect(_socket, SIGNAL(readyRead()), this, SLOT(slotDataAvailiable())); | ||
104 | emit dataReceived(_data); | 119 | emit dataReceived(_data); |
120 | _data = QString::null; | ||
105 | _writingAllowed = true; | 121 | _writingAllowed = true; |
106 | _data = QString(0); | ||
107 | } | 122 | } |
108 | } | 123 | } |
109 | } | 124 | } |
110 | 125 | ||
126 | void IMAPBase::tryRead ( QString &data ) | ||
127 | { | ||
128 | qDebug ( "Trying to read...\n" ); | ||
129 | |||
130 | while ( _socket-> canReadLine ( )) | ||
131 | data += _socket-> readLine ( ); | ||
132 | } | ||
diff --git a/noncore/unsupported/mail2/libmail/imapbase.h b/noncore/unsupported/mail2/libmail/imapbase.h index e4a0b97..7697ffe 100644 --- a/noncore/unsupported/mail2/libmail/imapbase.h +++ b/noncore/unsupported/mail2/libmail/imapbase.h | |||
@@ -38,15 +38,16 @@ protected slots: | |||
38 | void slotHostFound(); | 38 | void slotHostFound(); |
39 | void slotConnected(); | 39 | void slotConnected(); |
40 | void slotDisconnected(); | 40 | void slotDisconnected(); |
41 | void slotDataAvailiable(); | 41 | void slotDataAvailiable(); |
42 | void tryRead ( QString & ); | ||
42 | 43 | ||
43 | private: | 44 | private: |
44 | Account _account; | 45 | Account _account; |
45 | QString _data; | 46 | QString _data; |
46 | QSocket *_socket; | 47 | QSocket *_socket; |
47 | QStringList _commandQueue; | 48 | QStringList _commandQueue; |
48 | bool _connected, _writingAllowed; | 49 | bool _connected, _writingAllowed; |
49 | 50 | QString _lasttag; | |
50 | }; | 51 | }; |
51 | 52 | ||
52 | #endif | 53 | #endif |
diff --git a/noncore/unsupported/mail2/libmail/imaphandler.cpp b/noncore/unsupported/mail2/libmail/imaphandler.cpp index 7493240..dc97b28 100644 --- a/noncore/unsupported/mail2/libmail/imaphandler.cpp +++ b/noncore/unsupported/mail2/libmail/imaphandler.cpp | |||
@@ -297,13 +297,16 @@ void IMAPHandler::slotDataReceived(const QString &data) | |||
297 | return; | 297 | return; |
298 | } | 298 | } |
299 | 299 | ||
300 | 300 | ||
301 | IMAPResponseParser parser(data); | 301 | IMAPResponseParser parser; |
302 | //connect ( &parser, SIGNAL( needMoreData ( QString & )), _ibase, SLOT( tryRead ( QString & ))); | ||
303 | parser. parse ( data ); | ||
302 | IMAPResponse response = parser.response(); | 304 | IMAPResponse response = parser.response(); |
305 | //disconnect ( &parser, SIGNAL( needMoreData ( QString & )), _ibase, SLOT( tryRead ( QString & ))); | ||
303 | response.setImapHandler(this); | 306 | response.setImapHandler(this); |
304 | 307 | ||
305 | if (!_loggingin) emit gotResponse(response); | 308 | if (!_loggingin) { qDebug("Emitting gotResponse!\n" ); emit gotResponse(response); } |
306 | else { | 309 | else { |
307 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 310 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
308 | _loggingin = false; | 311 | _loggingin = false; |
309 | _loggedin = true; | 312 | _loggedin = true; |
diff --git a/noncore/unsupported/mail2/libmail/imapresponse.cpp b/noncore/unsupported/mail2/libmail/imapresponse.cpp index 06dca33..ce5b18b 100644 --- a/noncore/unsupported/mail2/libmail/imapresponse.cpp +++ b/noncore/unsupported/mail2/libmail/imapresponse.cpp | |||
@@ -1,63 +1,94 @@ | |||
1 | #include "imapresponse.h" | 1 | #include "imapresponse.h" |
2 | 2 | ||
3 | static QString _previousData; | ||
4 | static unsigned int _neededData; | ||
5 | 3 | ||
6 | IMAPResponseParser::IMAPResponseParser(const QString &data) | 4 | IMAPResponseParser::IMAPResponseParser() |
5 | { | ||
6 | } | ||
7 | |||
8 | void IMAPResponseParser::parse ( const QString &_data ) | ||
7 | { | 9 | { |
8 | QString _data = data, more; | 10 | QString data = _data; |
9 | _data.replace((QString)"\r\n", "\n"); | 11 | |
10 | 12 | int pos = 0; | |
11 | QStringList lines = QStringList::split('\n', _data); | 13 | int len = data. length ( ); |
12 | QStringList::Iterator it; | 14 | |
13 | for (it = lines.begin(); it != lines.end(); it++) { | 15 | |
14 | QString tag, lineData; | 16 | while ( pos < len ) { |
15 | 17 | pos = data. find ( QRegExp ( "[^\\s]" ), pos ); | |
16 | if (!_previousData.isNull()) { | 18 | |
17 | qDebug(QString("IMAPResponseParser: got additional data. (%1/%2)").arg(_previousData.length()).arg(_neededData)); | 19 | if (( pos < 0 ) || ( pos >= len )) |
18 | _previousData += *it + "\n"; | 20 | break; |
19 | if (_previousData.length() >= _neededData) { | 21 | |
20 | _previousData += ")"; | 22 | switch ( data [pos]. latin1 ( )) { |
21 | qDebug("IMAPResponseParser: got ALL additional data."); | 23 | case '*': { |
22 | qDebug("Data is: " + _previousData); | 24 | qDebug ( "* ASTERIX\n" ); |
23 | parseResponse(_previousData); | 25 | |
24 | _previousData = QString(0); | 26 | int eol = data. find ( '\n', pos ); |
25 | _neededData = 0; | 27 | int bracket = data. findRev ( '{', eol ); |
26 | } | 28 | int rest = data. find ( QRegExp ( "[^\\s]" ), pos + 1 ); |
27 | } else { | 29 | |
28 | splitTagData(*it, tag, lineData); | 30 | qDebug ( "pos=%d, rest=%d, bracket=%d, eol=%d\n", pos, rest, bracket, eol ); |
29 | if (tag == "*") { | 31 | |
30 | int pos; | 32 | if ( bracket > pos ) { |
31 | if ((pos = data.find(QRegExp("\\{\\d*\\}"))) != -1) { | 33 | uint needdata = data. mid ( bracket + 1, data. find ( '}', bracket + 1 ) - bracket - 1 ). toUInt ( ); |
32 | qDebug("IMAPResponseParser: waiting for additional data..."); | 34 | |
33 | _previousData = lineData + "\n"; | 35 | if ( needdata ) { |
34 | 36 | qDebug ( "nd=%d - hd=%d\n", needdata, ( len - eol - 1 )); | |
35 | QString tmp = data.right(data.length() - pos - 1).stripWhiteSpace(); | 37 | |
36 | tmp.truncate(tmp.length() - 1); | 38 | while ( needdata > ( len - eol - 1 )) { |
37 | 39 | qDebug ( "emitting need more...\n" ); | |
38 | _neededData = tmp.toUInt(); | 40 | emit needMoreData ( data ); |
39 | if (_previousData.length() >= _neededData) { | 41 | len = data. length ( ); |
40 | qDebug("IMAPResponseParser: got ALL additional data. (1st)"); | 42 | } |
41 | parseResponse(_previousData); | 43 | qDebug ( "Got all data...\n" ); |
42 | _previousData = QString(0); | 44 | |
43 | _neededData = 0; | 45 | QString tmp = data. mid ( rest, eol - rest + 1 + needdata ); |
44 | } else { | 46 | |
47 | int tail = 0; | ||
48 | |||
49 | while ( data [eol - rest + 1 + needdata + tail] != ')' ) | ||
50 | tail++; | ||
51 | tmp. append ( data. mid ( eol - rest + 1 + needdata, tail + 1 )); | ||
52 | |||
53 | |||
54 | qDebug ( "Complete parse = |%s|\n", tmp.latin1()); | ||
55 | |||
56 | parseResponse ( tmp ); | ||
57 | |||
58 | pos = rest + needdata + tail + 1; | ||
45 | break; | 59 | break; |
46 | } | 60 | } |
47 | } else { | ||
48 | parseResponse(lineData); | ||
49 | } | 61 | } |
50 | } else if (tag == "+") { | 62 | |
51 | emit needMoreData(_data); | 63 | parseResponse ( data. mid ( rest, eol - rest + 1 ). stripWhiteSpace ( )); |
52 | } else { | 64 | break; |
53 | _iresponse.setTag(tag); | 65 | } |
54 | parseResponse(_data, true); | 66 | case '+': { |
67 | qDebug ( "+ PLUS\n" ); | ||
68 | |||
69 | emit needMoreData ( data ); | ||
70 | len = data. length ( ); | ||
71 | break; | ||
72 | } | ||
73 | default : { | ||
74 | qDebug ( "OTHER: '%s...'\n", data. mid ( pos, 20 ). latin1 ( )); | ||
75 | |||
76 | uint rest = data. find ( ' ', pos + 1 ); | ||
77 | rest = data. find ( QRegExp ( "[^\\s]" ), rest + 1 ); | ||
78 | _iresponse. setTag ( data. mid ( pos, rest - pos ). stripWhiteSpace ( )); | ||
79 | parseResponse ( data. mid ( rest, data. find ( '\n', rest )). stripWhiteSpace ( ), true ); | ||
80 | break; | ||
55 | } | 81 | } |
56 | } | 82 | } |
83 | |||
84 | // skip to end-of-line | ||
85 | while (( pos < len ) && ( data [pos] != '\n' )) | ||
86 | pos++; | ||
57 | } | 87 | } |
58 | } | 88 | } |
59 | 89 | ||
90 | |||
60 | IMAPResponse IMAPResponseParser::response() | 91 | IMAPResponse IMAPResponseParser::response() |
61 | { | 92 | { |
62 | return _iresponse; | 93 | return _iresponse; |
63 | } | 94 | } |
@@ -66,14 +97,18 @@ void IMAPResponseParser::parseResponse(const QString &data, bool tagged) | |||
66 | { | 97 | { |
67 | QString response, line; | 98 | QString response, line; |
68 | int pos; | 99 | int pos; |
69 | bool isNum = false; | 100 | bool isNum = false; |
101 | |||
102 | |||
103 | //qDebug ( "\n\n#### PRD #### : #%s#\n\n", data.latin1()); | ||
104 | |||
70 | if ((pos = data.find(' ')) != -1) { | 105 | if ((pos = data.find(' ')) != -1) { |
71 | response = data.left(pos).upper(); | 106 | response = data.left(pos).upper(); |
72 | response.toInt(&isNum); | 107 | response.toInt(&isNum); |
73 | line = data.right(data.length() - pos - 1); | 108 | line = data.right(data.length() - pos - 1); |
74 | } else { | 109 | } else { |
75 | qWarning("IMAPResponseParser: parseResponse: No response found."); | 110 | qWarning("IMAPResponseParser: parseResponse: No response found."); |
76 | return; | 111 | return; |
77 | } | 112 | } |
78 | 113 | ||
79 | if (response == "OK" && tagged) { | 114 | if (response == "OK" && tagged) { |
@@ -144,9 +179,9 @@ void IMAPResponseParser::parseResponse(const QString &data, bool tagged) | |||
144 | else if (*it == "RECENT") status.setRecent(*(++it)); | 179 | else if (*it == "RECENT") status.setRecent(*(++it)); |
145 | else if (*it == "UIDNEXT") status.setUidnext(*(++it)); | 180 | else if (*it == "UIDNEXT") status.setUidnext(*(++it)); |
146 | else if (*it == "UIDVALIDITY") status.setUidvalidity(*(++it)); | 181 | else if (*it == "UIDVALIDITY") status.setUidvalidity(*(++it)); |
147 | else if (*it == "UNSEEN") status.setUnseen(*(++it)); | 182 | else if (*it == "UNSEEN") status.setUnseen(*(++it)); |
148 | else qWarning("IMAPResponseParser: parseResponse: Unknown status data: " + *(it++) + "|"); | 183 | else qWarning((QString("IMAPResponseParser: parseResponse: Unknown status data: " )+ *(it++) + "|").latin1()); |
149 | } | 184 | } |
150 | _iresponse.addSTATUS(status); | 185 | _iresponse.addSTATUS(status); |
151 | } else if (response == "SEARCH") { | 186 | } else if (response == "SEARCH") { |
152 | IMAPResponseSEARCH search(QStringList::split(' ', line)); | 187 | IMAPResponseSEARCH search(QStringList::split(' ', line)); |
@@ -171,35 +206,46 @@ void IMAPResponseParser::parseResponse(const QString &data, bool tagged) | |||
171 | } else if (list[0] == "FETCH") { | 206 | } else if (list[0] == "FETCH") { |
172 | IMAPResponseFETCH fetch; | 207 | IMAPResponseFETCH fetch; |
173 | QStringList::Iterator it; | 208 | QStringList::Iterator it; |
174 | 209 | ||
210 | qDebug ( "Got FETCH\n" ); | ||
211 | |||
175 | QStringList fetchList = splitData(line, true); | 212 | QStringList fetchList = splitData(line, true); |
176 | QStringList list; | 213 | QStringList list; |
214 | |||
215 | qDebug ( "fl [0]=%s, fl [1]=%s, fl[2]=%s\n", fetchList[0].latin1(),fetchList[1].latin1(),fetchList[2].latin1()); | ||
216 | |||
177 | parseParenthesizedList(fetchList[1], list); | 217 | parseParenthesizedList(fetchList[1], list); |
178 | 218 | ||
179 | for (it = list.begin(); it != list.end(); it++) { | 219 | for (it = list.begin(); it != list.end(); it++) { |
220 | qDebug ( "Checking list[] == %s\n", (*it).latin1()); | ||
221 | |||
180 | if (*it == "BODY") { | 222 | if (*it == "BODY") { |
181 | qDebug("IMAPResponseParser: responseParser: got FETCH::BODY"); | 223 | qDebug("IMAPResponseParser: responseParser: got FETCH::BODY"); |
182 | // XXX | 224 | // XXX |
183 | } else if ((*it).find(QRegExp("BODY\\[\\d+\\]")) != -1) { | 225 | } else if ((*it).find(QRegExp("^BODY\\[\\d+\\]")) != -1) { |
184 | QString bodydata = *(++it); | ||
185 | qDebug("IMAPResponseParser: responseParser: got FETCH::BODY[x]"); | 226 | qDebug("IMAPResponseParser: responseParser: got FETCH::BODY[x]"); |
186 | 227 | ||
187 | QStringList blist; | 228 | QString number = ( *it ). mid ( 5, ( *it ). length ( ) - 6 ); |
188 | parseParenthesizedList(bodydata, blist); | 229 | QString bodydata = *(++it); |
230 | |||
231 | // QStringList blist; | ||
232 | // parseParenthesizedList(bodydata, blist); | ||
189 | 233 | ||
190 | IMAPResponseBodyPart bodypart; | 234 | IMAPResponseBodyPart bodypart; |
191 | QString tmp; | 235 | // QString tmp; |
192 | for (unsigned int i = 2; i < blist.count(); i++) { | 236 | // for (unsigned int i = 2; i < blist.count(); i++) { |
193 | if (i != 2) tmp += " " + blist[i]; | 237 | // if (i != 2) tmp += " " + blist[i]; |
194 | else tmp += blist[i]; | 238 | // else tmp += blist[i]; |
195 | } | 239 | // } |
196 | bodypart.setData(tmp); | 240 | bodypart.setData(bodydata); |
241 | |||
242 | // QString tmp = list[0]; | ||
243 | // tmp.replace(0, 5, ""); | ||
244 | // tmp.truncate(blist[0].length() - 1); | ||
245 | bodypart.setPart(number); | ||
197 | 246 | ||
198 | tmp = list[0]; | 247 | qDebug("added bodypart [%s]: '%s'\n\n", number.latin1(), bodydata.latin1()); |
199 | tmp.replace(0, 5, ""); | ||
200 | tmp.truncate(blist[0].length() - 1); | ||
201 | bodypart.setPart(tmp); | ||
202 | 248 | ||
203 | fetch.addBodyPart(bodypart); | 249 | fetch.addBodyPart(bodypart); |
204 | } else if (*it == "BODYSTRUCTURE") { | 250 | } else if (*it == "BODYSTRUCTURE") { |
205 | qDebug("IMAPResponseParser: responseParser: got FETCH::BODYSTRUCTURE"); | 251 | qDebug("IMAPResponseParser: responseParser: got FETCH::BODYSTRUCTURE"); |
@@ -336,9 +382,10 @@ void IMAPResponseParser::parseResponse(const QString &data, bool tagged) | |||
336 | } | 382 | } |
337 | } | 383 | } |
338 | _iresponse.addFETCH(fetch); | 384 | _iresponse.addFETCH(fetch); |
339 | } | 385 | } |
340 | } else qWarning("IMAPResponseParser: parseResponse: Unknown response: " + response + "|"); | 386 | } else qWarning((QString("IMAPResponseParser: parseResponse: Unknown response: ") + response + "|").latin1()); |
387 | |||
341 | } | 388 | } |
342 | 389 | ||
343 | QStringList IMAPResponseParser::splitData(const QString &data, bool withBrackets) | 390 | QStringList IMAPResponseParser::splitData(const QString &data, bool withBrackets) |
344 | { | 391 | { |
@@ -346,20 +393,50 @@ QStringList IMAPResponseParser::splitData(const QString &data, bool withBrackets | |||
346 | bool a = false, noappend = false, escaped = false; | 393 | bool a = false, noappend = false, escaped = false; |
347 | QString temp; | 394 | QString temp; |
348 | QStringList list; | 395 | QStringList list; |
349 | 396 | ||
397 | qDebug ( "sd: '%s'\n", data.latin1()); | ||
398 | |||
350 | for (unsigned int i = 0; i <= data.length(); i++) { | 399 | for (unsigned int i = 0; i <= data.length(); i++) { |
351 | if (withBrackets && data[i] == '(' && !a) b++; | 400 | if (withBrackets && data[i] == '(' && !a) b++; |
352 | else if (withBrackets && data[i] == ')' && !a) b--; | 401 | else if (withBrackets && data[i] == ')' && !a) b--; |
353 | 402 | ||
354 | if (data[i] == '"' && !escaped) a = !a; | 403 | if (data[i] == '{' && !escaped && !a ) { |
404 | qDebug ( "sd: found a {\n" ); | ||
405 | |||
406 | int p = data. find ( '}', i + 1 ); | ||
407 | int eol = data. find ( '\n', i + 1 ); | ||
408 | |||
409 | if ( p > int( i )) { | ||
410 | int len = data. mid ( i + 1, p - i - 1 ). toInt ( ); | ||
411 | |||
412 | qDebug ( "sd: skipping %d bytes\n", len ); | ||
413 | |||
414 | if ( b == 0 ) { | ||
415 | temp = data. mid ( eol + 1, len ); | ||
416 | noappend = false; | ||
417 | i = eol + len; | ||
418 | continue; | ||
419 | } | ||
420 | else { | ||
421 | temp. append ( '{' ); | ||
422 | temp. append ( QString::number ( len )); | ||
423 | temp. append ( "}\r\n" ); | ||
424 | temp. append ( data. mid ( eol + 1, len )); | ||
425 | i = eol + len; | ||
426 | continue; | ||
427 | } | ||
428 | } | ||
429 | } | ||
430 | |||
431 | if (data[i] == '\"' && !escaped) a = !a; | ||
355 | else escaped = false; | 432 | else escaped = false; |
356 | 433 | ||
357 | if (data[i] == '\\' && data[i + 1] == '"') escaped = true; | 434 | if (data[i] == '\\' && data[i + 1] == '\"') escaped = true; |
358 | 435 | ||
359 | if ((data[i] == ' ' || i == data.length()) && b == 0 && !a) { | 436 | if ((data[i] == ' ' || i == data.length()) && b == 0 && !a) { |
360 | list.append(temp); | 437 | list.append(temp); |
361 | temp = QString(0); | 438 | temp = QString::null; |
362 | if (data[i] == ' ') noappend = true; | 439 | if (data[i] == ' ') noappend = true; |
363 | } | 440 | } |
364 | 441 | ||
365 | if (!noappend) temp += data[i]; | 442 | if (!noappend) temp += data[i]; |
@@ -381,24 +458,25 @@ void IMAPResponseParser::splitTagData(const QString &line, QString &tag, QString | |||
381 | int pos; | 458 | int pos; |
382 | if ((pos = line.find(' ')) != -1) { | 459 | if ((pos = line.find(' ')) != -1) { |
383 | tag = line.left(pos); | 460 | tag = line.left(pos); |
384 | data = line.right(line.length() - pos - 1); | 461 | data = line.right(line.length() - pos - 1); |
385 | } else qWarning("IMAPResponseParser: splitTagData: tag not found. Line was " + line + "|"); | 462 | } else qWarning((QString("IMAPResponseParser: splitTagData: tag not found. Line was ") + line + "|").latin1()); |
386 | } | 463 | } |
387 | 464 | ||
388 | QString IMAPResponseParser::removeLimiters(QString &string, const QChar &sl, const QChar &el) | 465 | QString IMAPResponseParser::removeLimiters(QString &string, const QChar &sl, const QChar &el) |
389 | { | 466 | { |
390 | QString tmpString; | 467 | QString tmpString; |
468 | string = string. stripWhiteSpace ( ); | ||
469 | |||
391 | if (string[0] == sl && string[string.length() - 1] == el) { | 470 | if (string[0] == sl && string[string.length() - 1] == el) { |
392 | string.truncate(string.length() - 1); | 471 | string.truncate(string.length() - 1); |
393 | string.replace(0, 1, ""); | 472 | string.replace(0, 1, ""); |
394 | 473 | ||
395 | for (unsigned int i = 1; i <= string.length(); i++) { | 474 | for (unsigned int i = 1; i <= string.length(); i++) { |
396 | if (string[i - 1] == '\\' && sl == '"') ++i; | 475 | if (string[i - 1] == '\\' && sl == '\"') ++i; |
397 | tmpString += string[i - 1]; | 476 | tmpString += string[i - 1]; |
398 | } | 477 | } |
399 | } | 478 | } |
400 | |||
401 | return tmpString; | 479 | return tmpString; |
402 | } | 480 | } |
403 | 481 | ||
404 | IMAPResponseEnums::IMAPResponseCode IMAPResponseParser::getResponseCode(const QString &line) | 482 | IMAPResponseEnums::IMAPResponseCode IMAPResponseParser::getResponseCode(const QString &line) |
@@ -416,9 +494,9 @@ IMAPResponseEnums::IMAPResponseCode IMAPResponseParser::getResponseCode(const QS | |||
416 | else if (code.find(QRegExp("[TRYCREATE]")) != -1) return TRYCREATE; | 494 | else if (code.find(QRegExp("[TRYCREATE]")) != -1) return TRYCREATE; |
417 | else if (code.find(QRegExp("[UIDVALIDITY \\d*]")) != -1) return UIDVALIDITY; // XXX | 495 | else if (code.find(QRegExp("[UIDVALIDITY \\d*]")) != -1) return UIDVALIDITY; // XXX |
418 | else if (code.find(QRegExp("[UNSEEN \\d*]")) != -1) return UNSEEN; // XXX | 496 | else if (code.find(QRegExp("[UNSEEN \\d*]")) != -1) return UNSEEN; // XXX |
419 | else { | 497 | else { |
420 | qWarning("IMAPResponseParser: getResponseCode: Unknown code: " + code + "|"); | 498 | qWarning((QString("IMAPResponseParser: getResponseCode: Unknown code: ") + code + "|").latin1()); |
421 | return UnknownCode; | 499 | return UnknownCode; |
422 | } | 500 | } |
423 | } | 501 | } |
424 | return NoCode; | 502 | return NoCode; |
@@ -440,9 +518,9 @@ QValueList<IMAPResponseEnums::IMAPResponseFlags> IMAPResponseParser::parseFlagLi | |||
440 | else if (flag == "\\noselect") flags.append(Noselect); | 518 | else if (flag == "\\noselect") flags.append(Noselect); |
441 | else if (flag == "\\marked") flags.append(Marked); | 519 | else if (flag == "\\marked") flags.append(Marked); |
442 | else if (flag == "\\unmarked") flags.append(Unmarked); | 520 | else if (flag == "\\unmarked") flags.append(Unmarked); |
443 | else if (flag.isEmpty()) { } | 521 | else if (flag.isEmpty()) { } |
444 | else qWarning("IMAPResponseParser: parseFlagList: Unknown flag: " + *it + "|"); | 522 | else qWarning((QString("IMAPResponseParser: parseFlagList: Unknown flag: ") + *it + "|").latin1()); |
445 | } | 523 | } |
446 | return flags; | 524 | return flags; |
447 | } | 525 | } |
448 | 526 | ||
diff --git a/noncore/unsupported/mail2/libmail/imapresponse.h b/noncore/unsupported/mail2/libmail/imapresponse.h index 73435ee..5a19b96 100644 --- a/noncore/unsupported/mail2/libmail/imapresponse.h +++ b/noncore/unsupported/mail2/libmail/imapresponse.h | |||
@@ -504,14 +504,15 @@ class IMAPResponseParser : public QObject, public IMAPResponseEnums | |||
504 | { | 504 | { |
505 | Q_OBJECT | 505 | Q_OBJECT |
506 | 506 | ||
507 | public: | 507 | public: |
508 | IMAPResponseParser(const QString &data); | 508 | IMAPResponseParser(); |
509 | void parse ( const QString &data); | ||
509 | 510 | ||
510 | IMAPResponse response(); | 511 | IMAPResponse response(); |
511 | 512 | ||
512 | signals: | 513 | signals: |
513 | void needMoreData(const QString &comment); | 514 | void needMoreData(QString &data); |
514 | 515 | ||
515 | protected: | 516 | protected: |
516 | void parseResponse(const QString &data, bool tagged = false); | 517 | void parseResponse(const QString &data, bool tagged = false); |
517 | 518 | ||
diff --git a/noncore/unsupported/mail2/viewmail.cpp b/noncore/unsupported/mail2/viewmail.cpp index 3c88d99..da6924d 100644 --- a/noncore/unsupported/mail2/viewmail.cpp +++ b/noncore/unsupported/mail2/viewmail.cpp | |||
@@ -182,12 +182,12 @@ void ViewMail::slotIMAPUid(IMAPResponse &response) | |||
182 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); | 182 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); |
183 | 183 | ||
184 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { | 184 | if (response.statusResponse().status() == IMAPResponseEnums::OK) { |
185 | QValueList<IMAPResponseBodyPart> bodyParts; | 185 | QValueList<IMAPResponseBodyPart> bodyParts; |
186 | bodyParts.append(response.FETCH()[0].bodyPart(1)); | 186 | bodyParts.append(response.FETCH()[0].bodyPart(0)); |
187 | _mail.setBodyParts(bodyParts); | 187 | _mail.setBodyParts(bodyParts); |
188 | 188 | ||
189 | browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(1).data()))); | 189 | browser->setText(QString(_mailHtml).arg(deHtml(response.FETCH()[0].bodyPart(0).data()))); |
190 | 190 | ||
191 | // fillList(response.FETCH()[0].bodyStructure()); | 191 | // fillList(response.FETCH()[0].bodyStructure()); |
192 | 192 | ||
193 | _gotBody = true; | 193 | _gotBody = true; |