summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mailit/popclient.cpp
Side-by-side diff
Diffstat (limited to 'noncore/unsupported/mailit/popclient.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mailit/popclient.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp
index 6105d09..fedc4e2 100644
--- a/noncore/unsupported/mailit/popclient.cpp
+++ b/noncore/unsupported/mailit/popclient.cpp
@@ -20,24 +20,25 @@
#include "popclient.h"
#include "emailhandler.h"
//#define APOP_TEST
extern "C" {
#include "md5.h"
}
#include <qcstring.h>
PopClient::PopClient()
{
+
socket = new QSocket(this, "popClient");
connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
stream = new QTextStream(socket);
receiving = FALSE;
synchronize = FALSE;
lastSync = 0;
headerLimit = 0;
preview = FALSE;
@@ -108,24 +109,25 @@ void PopClient::errorHandling(int status)
receiving = FALSE;
}
void PopClient::incomingData()
{
QString response, temp, temp2, timeStamp;
QString md5Source;
int start, end;
// char *md5Digest;
char md5Digest[16];
// if ( !socket->canReadLine() )
// return;
+
response = socket->readLine();
switch(status) {
//logging in
case Init: {
#ifdef APOP_TEST
start = response.find('<',0);
end = response.find('>', start);
if( start >= 0 && end > start )
{
timeStamp = response.mid( start , end - start + 1);
@@ -142,54 +144,55 @@ void PopClient::incomingData()
*stream << "APOP " << popUserName << " " << md5Digest << "\r\n";
// qDebug("%s", stream);
status = Stat;
}
else
#endif
{
timeStamp = "";
*stream << "USER " << popUserName << "\r\n";
status = Pass;
}
- break;
+ break;
}
case Pass: {
*stream << "PASS " << popPassword << "\r\n";
- status = Stat;
+ status = Stat;
+
break;
}
//ask for number of messages
case Stat: {
if (response[0] == '+') {
*stream << "STAT" << "\r\n";
- status = Mcnt;
+ status = Mcnt;
} else errorHandling(ErrLoginFailed);
break;
}
//get count of messages, eg "+OK 4 900.." -> int 4
case Mcnt: {
if (response[0] == '+') {
temp = response.replace(0, 4, "");
int x = temp.find(" ", 0);
temp.truncate((uint) x);
newMessages = temp.toInt();
messageCount = 1;
status = List;
if (synchronize) {
//messages deleted from server, reload all
- if (newMessages < lastSync)
- lastSync = 0;
+ if (newMessages < lastSync)
+ lastSync = 0;
messageCount = 1;
}
if (selected) {
int *ptr = mailList->first();
if (ptr != 0) {
newMessages++; //to ensure no early jumpout
messageCount = *ptr;
} else newMessages = 0;
}
} else errorHandling(ErrUnknownResponse);
@@ -264,25 +267,24 @@ void PopClient::incomingData()
case Read: {
if (status != Quit) { //because of idiotic switch
message += response;
while ( socket->canReadLine() ) {
response = socket->readLine();
message += response;
}
emit downloadedSize(message.length());
int x = message.find("\r\n.\r\n",-5);
if (x == -1) {
break;
} else { //message reach entire size
-
if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active
{
emit newMessage(message, messageCount-1, mailSize, TRUE);
} else { //incomplete mail downloaded
emit newMessage(message, messageCount-1, mailSize, FALSE);
}
if ((messageCount > newMessages)||(selected)) //last message ?
{
status = Quit;
if (selected) { //grab next from queue
newMessages--;