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.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp
index dc0116d..5da3bcb 100644
--- a/noncore/unsupported/mailit/popclient.cpp
+++ b/noncore/unsupported/mailit/popclient.cpp
@@ -54,25 +54,25 @@ void PopClient::newConnection(const QString &target, int port)
{
if (receiving) {
qWarning("socket in use, connection refused");
return;
}
status = Init;
socket->connectToHost(target, port);
receiving = TRUE;
//selected = FALSE;
- emit updateStatus("DNS lookup");
+ emit updateStatus(tr("DNS lookup"));
}
void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
{
popUserName = popUser;
popPassword = popPasswd;
}
void PopClient::setSynchronize(int lastCount)
{
synchronize = TRUE;
lastSync = lastCount;
@@ -94,26 +94,30 @@ void PopClient::setSelectedMails(MailList *list)
{
selected = TRUE;
mailList = list;
}
void PopClient::connectionEstablished()
{
emit updateStatus(tr("Connection established"));
}
void PopClient::errorHandling(int status)
{
+ errorHandlingWithMsg( status, QString::null );
+}
+void PopClient::errorHandlingWithMsg(int status, const QString & Msg )
+{
emit updateStatus(tr("Error Occured"));
- emit errorOccurred(status);
+ emit errorOccurred(status, Msg);
socket->close();
receiving = FALSE;
}
void PopClient::incomingData()
{
QString response, temp, temp2, timeStamp;
QString md5Source;
int start, end;
// char *md5Digest;
char md5Digest[16];
// if ( !socket->canReadLine() )
@@ -158,25 +162,25 @@ void PopClient::incomingData()
case Pass: {
*stream << "PASS " << popPassword << "\r\n";
status = Stat;
break;
}
//ask for number of messages
case Stat: {
if (response[0] == '+') {
*stream << "STAT" << "\r\n";
status = Mcnt;
- } else errorHandling(ErrLoginFailed);
+ } else errorHandlingWithMsg(ErrLoginFailed, response);
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;
@@ -186,25 +190,25 @@ void PopClient::incomingData()
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);
+ } else errorHandlingWithMsg(ErrUnknownResponse, response);
}
//Read message number x, count upwards to messageCount
case List: {
if (messageCount <= newMessages) {
*stream << "LIST " << messageCount << "\r\n";
status = Size;
temp2.setNum(newMessages - lastSync);
temp.setNum(messageCount - lastSync);
if (!selected) {
emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
} else {
//completing a previously closed transfer
@@ -225,50 +229,50 @@ void PopClient::incomingData()
case Size: {
if (status != Quit) { //because of idiotic switch
if (response[0] == '+') {
temp = response.replace(0, 4, "");
int x = temp.find(" ", 0);
temp = temp.right(temp.length() - ((uint) x + 1) );
mailSize = temp.toInt();
emit currentMailSize(mailSize);
status = Retr;
} else {
//qWarning(response);
- errorHandling(ErrUnknownResponse);
+ errorHandlingWithMsg(ErrUnknownResponse, response);
}
}
}
//Read message number x, count upwards to messageCount
case Retr: {
if (status != Quit) {
if ((selected)||(mailSize <= headerLimit))
{
*stream << "RETR " << messageCount << "\r\n";
} else { //only header
*stream << "TOP " << messageCount << " 0\r\n";
}
messageCount++;
status = Ignore;
break;
} }
case Ignore: {
if (status != Quit) { //because of idiotic switch
if (response[0] == '+') {
message = "";
status = Read;
if (!socket->canReadLine()) //sync. problems
break;
response = socket->readLine();
- } else errorHandling(ErrUnknownResponse);
+ } else errorHandlingWithMsg(ErrUnknownResponse, response);
}
}
//add all incoming lines to body. When size is reached, send
//message, and go back to read new message
case Read: {
if (status != Quit) { //because of idiotic switch
message += response;
while ( socket->canReadLine() ) {
response = socket->readLine();
message += response;
}
emit downloadedSize(message.length());