summaryrefslogtreecommitdiff
path: root/noncore/net/mailit/popclient.cpp
Unidiff
Diffstat (limited to 'noncore/net/mailit/popclient.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/popclient.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp
index dc0116d..5da3bcb 100644
--- a/noncore/net/mailit/popclient.cpp
+++ b/noncore/net/mailit/popclient.cpp
@@ -60,13 +60,13 @@ void PopClient::newConnection(const QString &target, int port)
60 status = Init; 60 status = Init;
61 61
62 socket->connectToHost(target, port); 62 socket->connectToHost(target, port);
63 receiving = TRUE; 63 receiving = TRUE;
64 //selected = FALSE; 64 //selected = FALSE;
65 65
66 emit updateStatus("DNS lookup"); 66 emit updateStatus(tr("DNS lookup"));
67} 67}
68 68
69void PopClient::setAccount(const QString &popUser, const QString &popPasswd) 69void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
70{ 70{
71 popUserName = popUser; 71 popUserName = popUser;
72 popPassword = popPasswd; 72 popPassword = popPasswd;
@@ -100,14 +100,18 @@ void PopClient::connectionEstablished()
100{ 100{
101 emit updateStatus(tr("Connection established")); 101 emit updateStatus(tr("Connection established"));
102} 102}
103 103
104void PopClient::errorHandling(int status) 104void PopClient::errorHandling(int status)
105{ 105{
106 errorHandlingWithMsg( status, QString::null );
107}
108void PopClient::errorHandlingWithMsg(int status, const QString & Msg )
109{
106 emit updateStatus(tr("Error Occured")); 110 emit updateStatus(tr("Error Occured"));
107 emit errorOccurred(status); 111 emit errorOccurred(status, Msg);
108 socket->close(); 112 socket->close();
109 receiving = FALSE; 113 receiving = FALSE;
110} 114}
111 115
112void PopClient::incomingData() 116void PopClient::incomingData()
113{ 117{
@@ -164,13 +168,13 @@ void PopClient::incomingData()
164 } 168 }
165 //ask for number of messages 169 //ask for number of messages
166 case Stat: { 170 case Stat: {
167 if (response[0] == '+') { 171 if (response[0] == '+') {
168 *stream << "STAT" << "\r\n"; 172 *stream << "STAT" << "\r\n";
169 status = Mcnt; 173 status = Mcnt;
170 } else errorHandling(ErrLoginFailed); 174 } else errorHandlingWithMsg(ErrLoginFailed, response);
171 break; 175 break;
172 } 176 }
173 //get count of messages, eg "+OK 4 900.." -> int 4 177 //get count of messages, eg "+OK 4 900.." -> int 4
174 case Mcnt: { 178 case Mcnt: {
175 if (response[0] == '+') { 179 if (response[0] == '+') {
176 temp = response.replace(0, 4, ""); 180 temp = response.replace(0, 4, "");
@@ -192,13 +196,13 @@ void PopClient::incomingData()
192 if (ptr != 0) { 196 if (ptr != 0) {
193 newMessages++; //to ensure no early jumpout 197 newMessages++; //to ensure no early jumpout
194 messageCount = *ptr; 198 messageCount = *ptr;
195 } else newMessages = 0; 199 } else newMessages = 0;
196 } 200 }
197 201
198 } else errorHandling(ErrUnknownResponse); 202 } else errorHandlingWithMsg(ErrUnknownResponse, response);
199 } 203 }
200 //Read message number x, count upwards to messageCount 204 //Read message number x, count upwards to messageCount
201 case List: { 205 case List: {
202 if (messageCount <= newMessages) { 206 if (messageCount <= newMessages) {
203 *stream << "LIST " << messageCount << "\r\n"; 207 *stream << "LIST " << messageCount << "\r\n";
204 status = Size; 208 status = Size;
@@ -231,13 +235,13 @@ void PopClient::incomingData()
231 mailSize = temp.toInt(); 235 mailSize = temp.toInt();
232 emit currentMailSize(mailSize); 236 emit currentMailSize(mailSize);
233 237
234 status = Retr; 238 status = Retr;
235 } else { 239 } else {
236 //qWarning(response); 240 //qWarning(response);
237 errorHandling(ErrUnknownResponse); 241 errorHandlingWithMsg(ErrUnknownResponse, response);
238 } 242 }
239 } 243 }
240 } 244 }
241 //Read message number x, count upwards to messageCount 245 //Read message number x, count upwards to messageCount
242 case Retr: { 246 case Retr: {
243 if (status != Quit) { 247 if (status != Quit) {
@@ -256,13 +260,13 @@ void PopClient::incomingData()
256 if (response[0] == '+') { 260 if (response[0] == '+') {
257 message = ""; 261 message = "";
258 status = Read; 262 status = Read;
259 if (!socket->canReadLine()) //sync. problems 263 if (!socket->canReadLine()) //sync. problems
260 break; 264 break;
261 response = socket->readLine(); 265 response = socket->readLine();
262 } else errorHandling(ErrUnknownResponse); 266 } else errorHandlingWithMsg(ErrUnknownResponse, response);
263 } 267 }
264 } 268 }
265 //add all incoming lines to body. When size is reached, send 269 //add all incoming lines to body. When size is reached, send
266 //message, and go back to read new message 270 //message, and go back to read new message
267 case Read: { 271 case Read: {
268 if (status != Quit) { //because of idiotic switch 272 if (status != Quit) { //because of idiotic switch