Diffstat (limited to 'noncore/net/mailit/popclient.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mailit/popclient.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp index f9cc337..67306be 100644 --- a/noncore/net/mailit/popclient.cpp +++ b/noncore/net/mailit/popclient.cpp | |||
@@ -110,70 +110,59 @@ void PopClient::errorHandling(int status) | |||
110 | 110 | ||
111 | void PopClient::incomingData() | 111 | void PopClient::incomingData() |
112 | { | 112 | { |
113 | QString response, temp, temp2, timeStamp; | 113 | QString response, temp, temp2, timeStamp; |
114 | QString md5Source; | 114 | QString md5Source; |
115 | int start, end; | 115 | int start, end; |
116 | // char *md5Digest; | 116 | // char *md5Digest; |
117 | char md5Digest[16]; | 117 | char md5Digest[16]; |
118 | // if ( !socket->canReadLine() ) | 118 | // if ( !socket->canReadLine() ) |
119 | // return; | 119 | // return; |
120 | 120 | ||
121 | response = socket->readLine(); | 121 | response = socket->readLine(); |
122 | //qDebug(response +" %d", status); | ||
123 | 122 | ||
124 | switch(status) { | 123 | switch(status) { |
125 | //logging in | 124 | //logging in |
126 | case Init: { | 125 | case Init: { |
127 | #ifdef APOP_TEST | 126 | #ifdef APOP_TEST |
128 | start = response.find('<',0); | 127 | start = response.find('<',0); |
129 | end = response.find('>', start); | 128 | end = response.find('>', start); |
130 | if( start >= 0 && end > start ) | 129 | if( start >= 0 && end > start ) |
131 | { | 130 | { |
132 | timeStamp = response.mid( start , end - start + 1); | 131 | timeStamp = response.mid( start , end - start + 1); |
133 | md5Source = timeStamp + popPassword; | 132 | md5Source = timeStamp + popPassword; |
134 | //qDebug( md5Source); | ||
135 | // for( int i = 0; i < md5Source.length(); i++) { | ||
136 | // buff[i] = (QChar)md5Source[i]; | ||
137 | // } | ||
138 | 133 | ||
139 | md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); | 134 | md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); |
140 | // md5_buffer(char const *buffer, unsigned int len, char *digest); | ||
141 | |||
142 | // MD5_Init( &ctx); | ||
143 | // MD5_Update( &ctx, buff, sizeof( buff) ); | ||
144 | // MD5_Final( md5Digest, &ctx); | ||
145 | // MD5( buff, md5Source.length(), md5Digest); | ||
146 | 135 | ||
147 | for(int j =0;j < MD5_DIGEST_LENGTH ;j++) | 136 | for(int j =0;j < MD5_DIGEST_LENGTH ;j++) |
148 | { | 137 | { |
149 | printf("%x", md5Digest[j]); | 138 | printf("%x", md5Digest[j]); |
150 | } | 139 | } |
151 | printf("\n"); | 140 | printf("\n"); |
152 | // qDebug(md5Digest); | 141 | // qDebug(md5Digest); |
153 | *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; | 142 | *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; |
154 | // qDebug("%s", stream); | 143 | // qDebug("%s", stream); |
155 | status = Stat; | 144 | status = Stat; |
156 | } | 145 | } |
157 | else | 146 | else |
158 | #endif | 147 | #endif |
159 | { | 148 | { |
160 | timeStamp = ""; | 149 | timeStamp = ""; |
161 | *stream << "USER " << popUserName << "\r\n"; | 150 | *stream << "USER " << popUserName << "\r\n"; |
162 | status = Pass; | 151 | status = Pass; |
163 | } | 152 | } |
164 | 153 | ||
165 | break; | 154 | break; |
166 | } | 155 | } |
167 | //password shhh. don't tell anyone (implement APOP...) | 156 | |
168 | case Pass: { | 157 | case Pass: { |
169 | *stream << "PASS " << popPassword << "\r\n"; | 158 | *stream << "PASS " << popPassword << "\r\n"; |
170 | status = Stat; | 159 | status = Stat; |
171 | break; | 160 | break; |
172 | } | 161 | } |
173 | //ask for number of messages | 162 | //ask for number of messages |
174 | case Stat: { | 163 | case Stat: { |
175 | if (response[0] == '+') { | 164 | if (response[0] == '+') { |
176 | *stream << "STAT" << "\r\n"; | 165 | *stream << "STAT" << "\r\n"; |
177 | status = Mcnt; | 166 | status = Mcnt; |
178 | } else errorHandling(ErrLoginFailed); | 167 | } else errorHandling(ErrLoginFailed); |
179 | break; | 168 | break; |
@@ -239,25 +228,26 @@ void PopClient::incomingData() | |||
239 | emit currentMailSize(mailSize); | 228 | emit currentMailSize(mailSize); |
240 | 229 | ||
241 | status = Retr; | 230 | status = Retr; |
242 | } else { | 231 | } else { |
243 | //qWarning(response); | 232 | //qWarning(response); |
244 | errorHandling(ErrUnknownResponse); | 233 | errorHandling(ErrUnknownResponse); |
245 | } | 234 | } |
246 | } | 235 | } |
247 | } | 236 | } |
248 | //Read message number x, count upwards to messageCount | 237 | //Read message number x, count upwards to messageCount |
249 | case Retr: { | 238 | case Retr: { |
250 | if (status != Quit) { | 239 | if (status != Quit) { |
251 | if (!preview || mailSize <= headerLimit) { | 240 | if (mailSize <= headerLimit) |
241 | { | ||
252 | *stream << "RETR " << messageCount << "\r\n"; | 242 | *stream << "RETR " << messageCount << "\r\n"; |
253 | } else { //only header | 243 | } else { //only header |
254 | *stream << "TOP " << messageCount << " 0\r\n"; | 244 | *stream << "TOP " << messageCount << " 0\r\n"; |
255 | } | 245 | } |
256 | messageCount++; | 246 | messageCount++; |
257 | status = Ignore; | 247 | status = Ignore; |
258 | break; | 248 | break; |
259 | } } | 249 | } } |
260 | case Ignore: { | 250 | case Ignore: { |
261 | if (status != Quit) { //because of idiotic switch | 251 | if (status != Quit) { //because of idiotic switch |
262 | if (response[0] == '+') { | 252 | if (response[0] == '+') { |
263 | message = ""; | 253 | message = ""; |
@@ -274,25 +264,27 @@ void PopClient::incomingData() | |||
274 | if (status != Quit) { //because of idiotic switch | 264 | if (status != Quit) { //because of idiotic switch |
275 | message += response; | 265 | message += response; |
276 | while ( socket->canReadLine() ) { | 266 | while ( socket->canReadLine() ) { |
277 | response = socket->readLine(); | 267 | response = socket->readLine(); |
278 | message += response; | 268 | message += response; |
279 | } | 269 | } |
280 | emit downloadedSize(message.length()); | 270 | emit downloadedSize(message.length()); |
281 | int x = message.find("\r\n.\r\n",-5); | 271 | int x = message.find("\r\n.\r\n",-5); |
282 | if (x == -1) { | 272 | if (x == -1) { |
283 | break; | 273 | break; |
284 | } else { //message reach entire size | 274 | } else { //message reach entire size |
285 | //complete mail downloaded | 275 | //complete mail downloaded |
286 | if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ | 276 | //if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ |
277 | if ( mailSize <= headerLimit) | ||
278 | { | ||
287 | emit newMessage(message, messageCount-1, mailSize, TRUE); | 279 | emit newMessage(message, messageCount-1, mailSize, TRUE); |
288 | } else { //incomplete mail downloaded | 280 | } else { //incomplete mail downloaded |
289 | emit newMessage(message, messageCount-1, mailSize, FALSE); | 281 | emit newMessage(message, messageCount-1, mailSize, FALSE); |
290 | } | 282 | } |
291 | if (messageCount > newMessages) //that was the last message | 283 | if (messageCount > newMessages) //that was the last message |
292 | status = Quit; | 284 | status = Quit; |
293 | else { //ask for new message | 285 | else { //ask for new message |
294 | if (selected) { //grab next from queue | 286 | if (selected) { //grab next from queue |
295 | int *ptr = mailList->next(); | 287 | int *ptr = mailList->next(); |
296 | if (ptr != 0) { | 288 | if (ptr != 0) { |
297 | messageCount = *ptr; | 289 | messageCount = *ptr; |
298 | *stream << "LIST " << messageCount << "\r\n"; | 290 | *stream << "LIST " << messageCount << "\r\n"; |