author | llornkcor <llornkcor> | 2003-04-06 18:09:49 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-04-06 18:09:49 (UTC) |
commit | edbdd8c8df7ff99f4273ae0296386fecf4f3b189 (patch) (unidiff) | |
tree | 4d4c68fbf014ff762c3d3402bcdec5814128037e | |
parent | 8bc3b4fff609fa7f4809173724ab197ec08e599a (diff) | |
download | opie-edbdd8c8df7ff99f4273ae0296386fecf4f3b189.zip opie-edbdd8c8df7ff99f4273ae0296386fecf4f3b189.tar.gz opie-edbdd8c8df7ff99f4273ae0296386fecf4f3b189.tar.bz2 |
add some tr to status messages
-rw-r--r-- | noncore/net/mailit/popclient.cpp | 22 | ||||
-rw-r--r-- | noncore/net/mailit/smtpclient.cpp | 8 | ||||
-rw-r--r-- | noncore/unsupported/mailit/popclient.cpp | 22 | ||||
-rw-r--r-- | noncore/unsupported/mailit/smtpclient.cpp | 8 |
4 files changed, 30 insertions, 30 deletions
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp index a406af2..2f14ed2 100644 --- a/noncore/net/mailit/popclient.cpp +++ b/noncore/net/mailit/popclient.cpp | |||
@@ -76,54 +76,54 @@ void PopClient::setSynchronize(int lastCount) | |||
76 | synchronize = TRUE; | 76 | synchronize = TRUE; |
77 | lastSync = lastCount; | 77 | lastSync = lastCount; |
78 | } | 78 | } |
79 | 79 | ||
80 | void PopClient::removeSynchronize() | 80 | void PopClient::removeSynchronize() |
81 | { | 81 | { |
82 | synchronize = FALSE; | 82 | synchronize = FALSE; |
83 | lastSync = 0; | 83 | lastSync = 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | void PopClient::headersOnly(bool headers, int limit) | 86 | void PopClient::headersOnly(bool headers, int limit) |
87 | { | 87 | { |
88 | preview = headers; | 88 | preview = headers; |
89 | headerLimit = limit; | 89 | headerLimit = limit; |
90 | } | 90 | } |
91 | 91 | ||
92 | void PopClient::setSelectedMails(MailList *list) | 92 | void PopClient::setSelectedMails(MailList *list) |
93 | { | 93 | { |
94 | selected = TRUE; | 94 | selected = TRUE; |
95 | mailList = list; | 95 | mailList = list; |
96 | } | 96 | } |
97 | 97 | ||
98 | void PopClient::connectionEstablished() | 98 | void PopClient::connectionEstablished() |
99 | { | 99 | { |
100 | emit updateStatus("Connection established"); | 100 | emit updateStatus(tr("Connection established")); |
101 | } | 101 | } |
102 | 102 | ||
103 | void PopClient::errorHandling(int status) | 103 | void PopClient::errorHandling(int status) |
104 | { | 104 | { |
105 | emit updateStatus("Error Occured"); | 105 | emit updateStatus(tr("Error Occured")); |
106 | emit errorOccurred(status); | 106 | emit errorOccurred(status); |
107 | socket->close(); | 107 | socket->close(); |
108 | receiving = FALSE; | 108 | receiving = FALSE; |
109 | } | 109 | } |
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); | 122 | qDebug(response +" %d", status); |
123 | 123 | ||
124 | switch(status) { | 124 | switch(status) { |
125 | //logging in | 125 | //logging in |
126 | case Init: { | 126 | case Init: { |
127 | #ifdef APOP_TEST | 127 | #ifdef APOP_TEST |
128 | start = response.find('<',0); | 128 | start = response.find('<',0); |
129 | end = response.find('>', start); | 129 | end = response.find('>', start); |
@@ -191,61 +191,61 @@ void PopClient::incomingData() | |||
191 | if (synchronize) { | 191 | if (synchronize) { |
192 | //messages deleted from server, reload all | 192 | //messages deleted from server, reload all |
193 | if (newMessages < lastSync) | 193 | if (newMessages < lastSync) |
194 | lastSync = 0; | 194 | lastSync = 0; |
195 | messageCount = lastSync + 1; | 195 | messageCount = lastSync + 1; |
196 | } | 196 | } |
197 | 197 | ||
198 | if (selected) { | 198 | if (selected) { |
199 | int *ptr = mailList->first(); | 199 | int *ptr = mailList->first(); |
200 | if (ptr != 0) { | 200 | if (ptr != 0) { |
201 | newMessages++; //to ensure no early jumpout | 201 | newMessages++; //to ensure no early jumpout |
202 | messageCount = *(mailList->first()); | 202 | messageCount = *(mailList->first()); |
203 | } else newMessages = 0; | 203 | } else newMessages = 0; |
204 | } | 204 | } |
205 | } else errorHandling(ErrUnknownResponse); | 205 | } else errorHandling(ErrUnknownResponse); |
206 | } | 206 | } |
207 | //Read message number x, count upwards to messageCount | 207 | //Read message number x, count upwards to messageCount |
208 | case List: { | 208 | case List: { |
209 | if (messageCount <= newMessages) { | 209 | if (messageCount <= newMessages) { |
210 | *stream << "LIST " << messageCount << "\r\n"; | 210 | *stream << "LIST " << messageCount << "\r\n"; |
211 | status = Size; | 211 | status = Size; |
212 | temp2.setNum(newMessages - lastSync); | 212 | temp2.setNum(newMessages - lastSync); |
213 | temp.setNum(messageCount - lastSync); | 213 | temp.setNum(messageCount - lastSync); |
214 | if (!selected) { | 214 | if (!selected) { |
215 | emit updateStatus("Retrieving " + temp + "/" + temp2); | 215 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
216 | } else { | 216 | } else { |
217 | //completing a previously closed transfer | 217 | //completing a previously closed transfer |
218 | if ( (messageCount - lastSync) <= 0) { | 218 | if ( (messageCount - lastSync) <= 0) { |
219 | temp.setNum(messageCount); | 219 | temp.setNum(messageCount); |
220 | emit updateStatus("Previous message " + temp); | 220 | emit updateStatus(tr("Previous message ") + temp); |
221 | } else { | 221 | } else { |
222 | emit updateStatus("Completing message " + temp); | 222 | emit updateStatus(tr("Completing message ") + temp); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | break; | 225 | break; |
226 | } else { | 226 | } else { |
227 | emit updateStatus("No new Messages"); | 227 | emit updateStatus(tr("No new Messages")); |
228 | status = Quit; | 228 | status = Quit; |
229 | } | 229 | } |
230 | } | 230 | } |
231 | //get size of message, eg "500 characters in message.." -> int 500 | 231 | //get size of message, eg "500 characters in message.." -> int 500 |
232 | case Size: { | 232 | case Size: { |
233 | if (status != Quit) { //because of idiotic switch | 233 | if (status != Quit) { //because of idiotic switch |
234 | if (response[0] == '+') { | 234 | if (response[0] == '+') { |
235 | temp = response.replace(0, 4, ""); | 235 | temp = response.replace(0, 4, ""); |
236 | int x = temp.find(" ", 0); | 236 | int x = temp.find(" ", 0); |
237 | temp = temp.right(temp.length() - ((uint) x + 1) ); | 237 | temp = temp.right(temp.length() - ((uint) x + 1) ); |
238 | mailSize = temp.toInt(); | 238 | mailSize = temp.toInt(); |
239 | emit currentMailSize(mailSize); | 239 | emit currentMailSize(mailSize); |
240 | 240 | ||
241 | status = Retr; | 241 | status = Retr; |
242 | } else { | 242 | } else { |
243 | qWarning(response); | 243 | qWarning(response); |
244 | errorHandling(ErrUnknownResponse); | 244 | errorHandling(ErrUnknownResponse); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
248 | //Read message number x, count upwards to messageCount | 248 | //Read message number x, count upwards to messageCount |
249 | case Retr: { | 249 | case Retr: { |
250 | if (status != Quit) { | 250 | if (status != Quit) { |
251 | if (!preview || mailSize <= headerLimit) { | 251 | if (!preview || mailSize <= headerLimit) { |
@@ -279,82 +279,82 @@ void PopClient::incomingData() | |||
279 | } | 279 | } |
280 | emit downloadedSize(message.length()); | 280 | emit downloadedSize(message.length()); |
281 | int x = message.find("\r\n.\r\n",-5); | 281 | int x = message.find("\r\n.\r\n",-5); |
282 | if (x == -1) { | 282 | if (x == -1) { |
283 | break; | 283 | break; |
284 | } else { //message reach entire size | 284 | } else { //message reach entire size |
285 | //complete mail downloaded | 285 | //complete mail downloaded |
286 | if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ | 286 | if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ |
287 | emit newMessage(message, messageCount-1, mailSize, TRUE); | 287 | emit newMessage(message, messageCount-1, mailSize, TRUE); |
288 | } else { //incomplete mail downloaded | 288 | } else { //incomplete mail downloaded |
289 | emit newMessage(message, messageCount-1, mailSize, FALSE); | 289 | emit newMessage(message, messageCount-1, mailSize, FALSE); |
290 | } | 290 | } |
291 | if (messageCount > newMessages) //that was the last message | 291 | if (messageCount > newMessages) //that was the last message |
292 | status = Quit; | 292 | status = Quit; |
293 | else { //ask for new message | 293 | else { //ask for new message |
294 | if (selected) { //grab next from queue | 294 | if (selected) { //grab next from queue |
295 | int *ptr = mailList->next(); | 295 | int *ptr = mailList->next(); |
296 | if (ptr != 0) { | 296 | if (ptr != 0) { |
297 | messageCount = *ptr; | 297 | messageCount = *ptr; |
298 | *stream << "LIST " << messageCount << "\r\n"; | 298 | *stream << "LIST " << messageCount << "\r\n"; |
299 | status = Size; | 299 | status = Size; |
300 | //completing a previously closed transfer | 300 | //completing a previously closed transfer |
301 | if ( (messageCount - lastSync) <= 0) { | 301 | if ( (messageCount - lastSync) <= 0) { |
302 | temp.setNum(messageCount); | 302 | temp.setNum(messageCount); |
303 | emit updateStatus("Previous message " + temp); | 303 | emit updateStatus(tr("Previous message ") + temp); |
304 | } else { | 304 | } else { |
305 | temp.setNum(messageCount - lastSync); | 305 | temp.setNum(messageCount - lastSync); |
306 | emit updateStatus("Completing message " + temp); | 306 | emit updateStatus(tr("Completing message ") + temp); |
307 | } | 307 | } |
308 | break; | 308 | break; |
309 | } else { | 309 | } else { |
310 | newMessages--; | 310 | newMessages--; |
311 | status = Quit; | 311 | status = Quit; |
312 | } | 312 | } |
313 | } else { | 313 | } else { |
314 | *stream << "LIST " << messageCount << "\r\n"; | 314 | *stream << "LIST " << messageCount << "\r\n"; |
315 | status = Size; | 315 | status = Size; |
316 | temp2.setNum(newMessages - lastSync); | 316 | temp2.setNum(newMessages - lastSync); |
317 | temp.setNum(messageCount - lastSync); | 317 | temp.setNum(messageCount - lastSync); |
318 | emit updateStatus("Retrieving " + temp + "/" + temp2); | 318 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
319 | 319 | ||
320 | break; | 320 | break; |
321 | } | 321 | } |
322 | } | 322 | } |
323 | } | 323 | } |
324 | if (status != Quit) | 324 | if (status != Quit) |
325 | break; | 325 | break; |
326 | } | 326 | } |
327 | } | 327 | } |
328 | case Quit: { | 328 | case Quit: { |
329 | *stream << "Quit\r\n"; | 329 | *stream << "Quit\r\n"; |
330 | status = Done; | 330 | status = Done; |
331 | int newM = newMessages - lastSync; | 331 | int newM = newMessages - lastSync; |
332 | if (newM > 0) { | 332 | if (newM > 0) { |
333 | temp.setNum(newM); | 333 | temp.setNum(newM); |
334 | emit updateStatus(temp + " new messages"); | 334 | emit updateStatus(temp + tr(" new messages")); |
335 | } else { | 335 | } else { |
336 | emit updateStatus("No new messages"); | 336 | emit updateStatus(tr("No new messages")); |
337 | } | 337 | } |
338 | 338 | ||
339 | socket->close(); | 339 | socket->close(); |
340 | receiving = FALSE; | 340 | receiving = FALSE; |
341 | emit mailTransfered(newM); | 341 | emit mailTransfered(newM); |
342 | break; | 342 | break; |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | } | 346 | } |
347 | 347 | ||
348 | // if( bAPOPAuthentication ) | 348 | // if( bAPOPAuthentication ) |
349 | // { | 349 | // { |
350 | // if( m_strTimeStamp.IsEmpty() ) | 350 | // if( m_strTimeStamp.IsEmpty() ) |
351 | // { | 351 | // { |
352 | // SetLastError("Apop error!"); | 352 | // SetLastError("Apop error!"); |
353 | // return false; | 353 | // return false; |
354 | // } | 354 | // } |
355 | // strMD5Source = m_strTimeStamp+pszPassword; | 355 | // strMD5Source = m_strTimeStamp+pszPassword; |
356 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); | 356 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); |
357 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); | 357 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); |
358 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); | 358 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); |
359 | // if(ret == SOCKET_ERROR) | 359 | // if(ret == SOCKET_ERROR) |
360 | // { | 360 | // { |
diff --git a/noncore/net/mailit/smtpclient.cpp b/noncore/net/mailit/smtpclient.cpp index 7bb7933..3bdc072 100644 --- a/noncore/net/mailit/smtpclient.cpp +++ b/noncore/net/mailit/smtpclient.cpp | |||
@@ -29,66 +29,66 @@ SmtpClient::SmtpClient() | |||
29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); | 29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); |
30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); | 30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); |
31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); | 31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); |
32 | 32 | ||
33 | sending = FALSE; | 33 | sending = FALSE; |
34 | } | 34 | } |
35 | 35 | ||
36 | SmtpClient::~SmtpClient() | 36 | SmtpClient::~SmtpClient() |
37 | { | 37 | { |
38 | delete socket; | 38 | delete socket; |
39 | delete stream; | 39 | delete stream; |
40 | } | 40 | } |
41 | 41 | ||
42 | void SmtpClient::newConnection(QString target, int port) | 42 | void SmtpClient::newConnection(QString target, int port) |
43 | { | 43 | { |
44 | if (sending) { | 44 | if (sending) { |
45 | qWarning("socket in use, connection refused"); | 45 | qWarning("socket in use, connection refused"); |
46 | return; | 46 | return; |
47 | } | 47 | } |
48 | 48 | ||
49 | status = Init; | 49 | status = Init; |
50 | sending = TRUE; | 50 | sending = TRUE; |
51 | socket->connectToHost(target, port); | 51 | socket->connectToHost(target, port); |
52 | 52 | ||
53 | emit updateStatus("DNS lookup"); | 53 | emit updateStatus(tr("DNS lookup")); |
54 | } | 54 | } |
55 | 55 | ||
56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) | 56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) |
57 | { | 57 | { |
58 | RawEmail *mail = new RawEmail; | 58 | RawEmail *mail = new RawEmail; |
59 | 59 | ||
60 | mail->from = from; | 60 | mail->from = from; |
61 | mail->subject = subject; | 61 | mail->subject = subject; |
62 | mail->to = to; | 62 | mail->to = to; |
63 | mail->body = body; | 63 | mail->body = body; |
64 | 64 | ||
65 | mailList.append(mail); | 65 | mailList.append(mail); |
66 | } | 66 | } |
67 | 67 | ||
68 | void SmtpClient::connectionEstablished() | 68 | void SmtpClient::connectionEstablished() |
69 | { | 69 | { |
70 | emit updateStatus("Connection established"); | 70 | emit updateStatus(tr("Connection established")); |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | void SmtpClient::errorHandling(int status) | 74 | void SmtpClient::errorHandling(int status) |
75 | { | 75 | { |
76 | emit errorOccurred(status); | 76 | emit errorOccurred(status); |
77 | socket->close(); | 77 | socket->close(); |
78 | mailList.clear(); | 78 | mailList.clear(); |
79 | sending = FALSE; | 79 | sending = FALSE; |
80 | } | 80 | } |
81 | 81 | ||
82 | void SmtpClient::incomingData() | 82 | void SmtpClient::incomingData() |
83 | { | 83 | { |
84 | QString response; | 84 | QString response; |
85 | 85 | ||
86 | if (!socket->canReadLine()) | 86 | if (!socket->canReadLine()) |
87 | return; | 87 | return; |
88 | 88 | ||
89 | response = socket->readLine(); | 89 | response = socket->readLine(); |
90 | 90 | ||
91 | switch(status) { | 91 | switch(status) { |
92 | case Init: { | 92 | case Init: { |
93 | if (response[0] == '2') { | 93 | if (response[0] == '2') { |
94 | status = From; | 94 | status = From; |
@@ -108,56 +108,56 @@ void SmtpClient::incomingData() | |||
108 | if (response[0] == '2') { | 108 | if (response[0] == '2') { |
109 | it = mailPtr->to.begin(); | 109 | it = mailPtr->to.begin(); |
110 | if (it == NULL) | 110 | if (it == NULL) |
111 | errorHandling(ErrUnknownResponse); | 111 | errorHandling(ErrUnknownResponse); |
112 | *stream << "RCPT TO: <" << *it << ">\r\n"; | 112 | *stream << "RCPT TO: <" << *it << ">\r\n"; |
113 | status = MRcv; | 113 | status = MRcv; |
114 | } else errorHandling(ErrUnknownResponse); | 114 | } else errorHandling(ErrUnknownResponse); |
115 | break; | 115 | break; |
116 | } | 116 | } |
117 | case MRcv: { | 117 | case MRcv: { |
118 | if (response[0] == '2') { | 118 | if (response[0] == '2') { |
119 | it++; | 119 | it++; |
120 | if ( it != mailPtr->to.end() ) { | 120 | if ( it != mailPtr->to.end() ) { |
121 | *stream << "RCPT TO: <" << *it << ">\r\n"; | 121 | *stream << "RCPT TO: <" << *it << ">\r\n"; |
122 | break; | 122 | break; |
123 | } else { | 123 | } else { |
124 | status = Data; | 124 | status = Data; |
125 | } | 125 | } |
126 | } else errorHandling(ErrUnknownResponse); | 126 | } else errorHandling(ErrUnknownResponse); |
127 | } | 127 | } |
128 | case Data: { | 128 | case Data: { |
129 | if (response[0] == '2') { | 129 | if (response[0] == '2') { |
130 | *stream << "DATA\r\n"; | 130 | *stream << "DATA\r\n"; |
131 | status = Body; | 131 | status = Body; |
132 | emit updateStatus("Sending: " + mailPtr->subject); | 132 | emit updateStatus(tr("Sending: ") + mailPtr->subject); |
133 | } else errorHandling(ErrUnknownResponse); | 133 | } else errorHandling(ErrUnknownResponse); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | case Body: { | 136 | case Body: { |
137 | if (response[0] == '3') { | 137 | if (response[0] == '3') { |
138 | *stream << mailPtr->body << "\r\n.\r\n"; | 138 | *stream << mailPtr->body << "\r\n.\r\n"; |
139 | mailPtr = mailList.next(); | 139 | mailPtr = mailList.next(); |
140 | if (mailPtr != NULL) { | 140 | if (mailPtr != NULL) { |
141 | status = From; | 141 | status = From; |
142 | } else { | 142 | } else { |
143 | status = Quit; | 143 | status = Quit; |
144 | } | 144 | } |
145 | } else errorHandling(ErrUnknownResponse); | 145 | } else errorHandling(ErrUnknownResponse); |
146 | break; | 146 | break; |
147 | } | 147 | } |
148 | case Quit: { | 148 | case Quit: { |
149 | if (response[0] == '2') { | 149 | if (response[0] == '2') { |
150 | *stream << "QUIT\r\n"; | 150 | *stream << "QUIT\r\n"; |
151 | status = Done; | 151 | status = Done; |
152 | QString temp; | 152 | QString temp; |
153 | temp.setNum(mailList.count()); | 153 | temp.setNum(mailList.count()); |
154 | emit updateStatus("Sent " + temp + " messages"); | 154 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); |
155 | emit mailSent(); | 155 | emit mailSent(); |
156 | mailList.clear(); | 156 | mailList.clear(); |
157 | sending = FALSE; | 157 | sending = FALSE; |
158 | socket->close(); | 158 | socket->close(); |
159 | } else errorHandling(ErrUnknownResponse); | 159 | } else errorHandling(ErrUnknownResponse); |
160 | break; | 160 | break; |
161 | } | 161 | } |
162 | } | 162 | } |
163 | } | 163 | } |
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp index a406af2..2f14ed2 100644 --- a/noncore/unsupported/mailit/popclient.cpp +++ b/noncore/unsupported/mailit/popclient.cpp | |||
@@ -76,54 +76,54 @@ void PopClient::setSynchronize(int lastCount) | |||
76 | synchronize = TRUE; | 76 | synchronize = TRUE; |
77 | lastSync = lastCount; | 77 | lastSync = lastCount; |
78 | } | 78 | } |
79 | 79 | ||
80 | void PopClient::removeSynchronize() | 80 | void PopClient::removeSynchronize() |
81 | { | 81 | { |
82 | synchronize = FALSE; | 82 | synchronize = FALSE; |
83 | lastSync = 0; | 83 | lastSync = 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | void PopClient::headersOnly(bool headers, int limit) | 86 | void PopClient::headersOnly(bool headers, int limit) |
87 | { | 87 | { |
88 | preview = headers; | 88 | preview = headers; |
89 | headerLimit = limit; | 89 | headerLimit = limit; |
90 | } | 90 | } |
91 | 91 | ||
92 | void PopClient::setSelectedMails(MailList *list) | 92 | void PopClient::setSelectedMails(MailList *list) |
93 | { | 93 | { |
94 | selected = TRUE; | 94 | selected = TRUE; |
95 | mailList = list; | 95 | mailList = list; |
96 | } | 96 | } |
97 | 97 | ||
98 | void PopClient::connectionEstablished() | 98 | void PopClient::connectionEstablished() |
99 | { | 99 | { |
100 | emit updateStatus("Connection established"); | 100 | emit updateStatus(tr("Connection established")); |
101 | } | 101 | } |
102 | 102 | ||
103 | void PopClient::errorHandling(int status) | 103 | void PopClient::errorHandling(int status) |
104 | { | 104 | { |
105 | emit updateStatus("Error Occured"); | 105 | emit updateStatus(tr("Error Occured")); |
106 | emit errorOccurred(status); | 106 | emit errorOccurred(status); |
107 | socket->close(); | 107 | socket->close(); |
108 | receiving = FALSE; | 108 | receiving = FALSE; |
109 | } | 109 | } |
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); | 122 | qDebug(response +" %d", status); |
123 | 123 | ||
124 | switch(status) { | 124 | switch(status) { |
125 | //logging in | 125 | //logging in |
126 | case Init: { | 126 | case Init: { |
127 | #ifdef APOP_TEST | 127 | #ifdef APOP_TEST |
128 | start = response.find('<',0); | 128 | start = response.find('<',0); |
129 | end = response.find('>', start); | 129 | end = response.find('>', start); |
@@ -191,61 +191,61 @@ void PopClient::incomingData() | |||
191 | if (synchronize) { | 191 | if (synchronize) { |
192 | //messages deleted from server, reload all | 192 | //messages deleted from server, reload all |
193 | if (newMessages < lastSync) | 193 | if (newMessages < lastSync) |
194 | lastSync = 0; | 194 | lastSync = 0; |
195 | messageCount = lastSync + 1; | 195 | messageCount = lastSync + 1; |
196 | } | 196 | } |
197 | 197 | ||
198 | if (selected) { | 198 | if (selected) { |
199 | int *ptr = mailList->first(); | 199 | int *ptr = mailList->first(); |
200 | if (ptr != 0) { | 200 | if (ptr != 0) { |
201 | newMessages++; //to ensure no early jumpout | 201 | newMessages++; //to ensure no early jumpout |
202 | messageCount = *(mailList->first()); | 202 | messageCount = *(mailList->first()); |
203 | } else newMessages = 0; | 203 | } else newMessages = 0; |
204 | } | 204 | } |
205 | } else errorHandling(ErrUnknownResponse); | 205 | } else errorHandling(ErrUnknownResponse); |
206 | } | 206 | } |
207 | //Read message number x, count upwards to messageCount | 207 | //Read message number x, count upwards to messageCount |
208 | case List: { | 208 | case List: { |
209 | if (messageCount <= newMessages) { | 209 | if (messageCount <= newMessages) { |
210 | *stream << "LIST " << messageCount << "\r\n"; | 210 | *stream << "LIST " << messageCount << "\r\n"; |
211 | status = Size; | 211 | status = Size; |
212 | temp2.setNum(newMessages - lastSync); | 212 | temp2.setNum(newMessages - lastSync); |
213 | temp.setNum(messageCount - lastSync); | 213 | temp.setNum(messageCount - lastSync); |
214 | if (!selected) { | 214 | if (!selected) { |
215 | emit updateStatus("Retrieving " + temp + "/" + temp2); | 215 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
216 | } else { | 216 | } else { |
217 | //completing a previously closed transfer | 217 | //completing a previously closed transfer |
218 | if ( (messageCount - lastSync) <= 0) { | 218 | if ( (messageCount - lastSync) <= 0) { |
219 | temp.setNum(messageCount); | 219 | temp.setNum(messageCount); |
220 | emit updateStatus("Previous message " + temp); | 220 | emit updateStatus(tr("Previous message ") + temp); |
221 | } else { | 221 | } else { |
222 | emit updateStatus("Completing message " + temp); | 222 | emit updateStatus(tr("Completing message ") + temp); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | break; | 225 | break; |
226 | } else { | 226 | } else { |
227 | emit updateStatus("No new Messages"); | 227 | emit updateStatus(tr("No new Messages")); |
228 | status = Quit; | 228 | status = Quit; |
229 | } | 229 | } |
230 | } | 230 | } |
231 | //get size of message, eg "500 characters in message.." -> int 500 | 231 | //get size of message, eg "500 characters in message.." -> int 500 |
232 | case Size: { | 232 | case Size: { |
233 | if (status != Quit) { //because of idiotic switch | 233 | if (status != Quit) { //because of idiotic switch |
234 | if (response[0] == '+') { | 234 | if (response[0] == '+') { |
235 | temp = response.replace(0, 4, ""); | 235 | temp = response.replace(0, 4, ""); |
236 | int x = temp.find(" ", 0); | 236 | int x = temp.find(" ", 0); |
237 | temp = temp.right(temp.length() - ((uint) x + 1) ); | 237 | temp = temp.right(temp.length() - ((uint) x + 1) ); |
238 | mailSize = temp.toInt(); | 238 | mailSize = temp.toInt(); |
239 | emit currentMailSize(mailSize); | 239 | emit currentMailSize(mailSize); |
240 | 240 | ||
241 | status = Retr; | 241 | status = Retr; |
242 | } else { | 242 | } else { |
243 | qWarning(response); | 243 | qWarning(response); |
244 | errorHandling(ErrUnknownResponse); | 244 | errorHandling(ErrUnknownResponse); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
248 | //Read message number x, count upwards to messageCount | 248 | //Read message number x, count upwards to messageCount |
249 | case Retr: { | 249 | case Retr: { |
250 | if (status != Quit) { | 250 | if (status != Quit) { |
251 | if (!preview || mailSize <= headerLimit) { | 251 | if (!preview || mailSize <= headerLimit) { |
@@ -279,82 +279,82 @@ void PopClient::incomingData() | |||
279 | } | 279 | } |
280 | emit downloadedSize(message.length()); | 280 | emit downloadedSize(message.length()); |
281 | int x = message.find("\r\n.\r\n",-5); | 281 | int x = message.find("\r\n.\r\n",-5); |
282 | if (x == -1) { | 282 | if (x == -1) { |
283 | break; | 283 | break; |
284 | } else { //message reach entire size | 284 | } else { //message reach entire size |
285 | //complete mail downloaded | 285 | //complete mail downloaded |
286 | if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ | 286 | if ( (!preview ) || ((preview) && (mailSize <= headerLimit)) ){ |
287 | emit newMessage(message, messageCount-1, mailSize, TRUE); | 287 | emit newMessage(message, messageCount-1, mailSize, TRUE); |
288 | } else { //incomplete mail downloaded | 288 | } else { //incomplete mail downloaded |
289 | emit newMessage(message, messageCount-1, mailSize, FALSE); | 289 | emit newMessage(message, messageCount-1, mailSize, FALSE); |
290 | } | 290 | } |
291 | if (messageCount > newMessages) //that was the last message | 291 | if (messageCount > newMessages) //that was the last message |
292 | status = Quit; | 292 | status = Quit; |
293 | else { //ask for new message | 293 | else { //ask for new message |
294 | if (selected) { //grab next from queue | 294 | if (selected) { //grab next from queue |
295 | int *ptr = mailList->next(); | 295 | int *ptr = mailList->next(); |
296 | if (ptr != 0) { | 296 | if (ptr != 0) { |
297 | messageCount = *ptr; | 297 | messageCount = *ptr; |
298 | *stream << "LIST " << messageCount << "\r\n"; | 298 | *stream << "LIST " << messageCount << "\r\n"; |
299 | status = Size; | 299 | status = Size; |
300 | //completing a previously closed transfer | 300 | //completing a previously closed transfer |
301 | if ( (messageCount - lastSync) <= 0) { | 301 | if ( (messageCount - lastSync) <= 0) { |
302 | temp.setNum(messageCount); | 302 | temp.setNum(messageCount); |
303 | emit updateStatus("Previous message " + temp); | 303 | emit updateStatus(tr("Previous message ") + temp); |
304 | } else { | 304 | } else { |
305 | temp.setNum(messageCount - lastSync); | 305 | temp.setNum(messageCount - lastSync); |
306 | emit updateStatus("Completing message " + temp); | 306 | emit updateStatus(tr("Completing message ") + temp); |
307 | } | 307 | } |
308 | break; | 308 | break; |
309 | } else { | 309 | } else { |
310 | newMessages--; | 310 | newMessages--; |
311 | status = Quit; | 311 | status = Quit; |
312 | } | 312 | } |
313 | } else { | 313 | } else { |
314 | *stream << "LIST " << messageCount << "\r\n"; | 314 | *stream << "LIST " << messageCount << "\r\n"; |
315 | status = Size; | 315 | status = Size; |
316 | temp2.setNum(newMessages - lastSync); | 316 | temp2.setNum(newMessages - lastSync); |
317 | temp.setNum(messageCount - lastSync); | 317 | temp.setNum(messageCount - lastSync); |
318 | emit updateStatus("Retrieving " + temp + "/" + temp2); | 318 | emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); |
319 | 319 | ||
320 | break; | 320 | break; |
321 | } | 321 | } |
322 | } | 322 | } |
323 | } | 323 | } |
324 | if (status != Quit) | 324 | if (status != Quit) |
325 | break; | 325 | break; |
326 | } | 326 | } |
327 | } | 327 | } |
328 | case Quit: { | 328 | case Quit: { |
329 | *stream << "Quit\r\n"; | 329 | *stream << "Quit\r\n"; |
330 | status = Done; | 330 | status = Done; |
331 | int newM = newMessages - lastSync; | 331 | int newM = newMessages - lastSync; |
332 | if (newM > 0) { | 332 | if (newM > 0) { |
333 | temp.setNum(newM); | 333 | temp.setNum(newM); |
334 | emit updateStatus(temp + " new messages"); | 334 | emit updateStatus(temp + tr(" new messages")); |
335 | } else { | 335 | } else { |
336 | emit updateStatus("No new messages"); | 336 | emit updateStatus(tr("No new messages")); |
337 | } | 337 | } |
338 | 338 | ||
339 | socket->close(); | 339 | socket->close(); |
340 | receiving = FALSE; | 340 | receiving = FALSE; |
341 | emit mailTransfered(newM); | 341 | emit mailTransfered(newM); |
342 | break; | 342 | break; |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | } | 346 | } |
347 | 347 | ||
348 | // if( bAPOPAuthentication ) | 348 | // if( bAPOPAuthentication ) |
349 | // { | 349 | // { |
350 | // if( m_strTimeStamp.IsEmpty() ) | 350 | // if( m_strTimeStamp.IsEmpty() ) |
351 | // { | 351 | // { |
352 | // SetLastError("Apop error!"); | 352 | // SetLastError("Apop error!"); |
353 | // return false; | 353 | // return false; |
354 | // } | 354 | // } |
355 | // strMD5Source = m_strTimeStamp+pszPassword; | 355 | // strMD5Source = m_strTimeStamp+pszPassword; |
356 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); | 356 | // strMD5Dst = MD5_GetMD5( (BYTE*)(const char*)strMD5Source , strMD5Source.GetLength() ); |
357 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); | 357 | // sprintf(msg , "apop %s %s\r\n" , pszUser , strMD5Dst); |
358 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); | 358 | // ret = send(m_sPop3Socket , msg , strlen(msg) , NULL); |
359 | // if(ret == SOCKET_ERROR) | 359 | // if(ret == SOCKET_ERROR) |
360 | // { | 360 | // { |
diff --git a/noncore/unsupported/mailit/smtpclient.cpp b/noncore/unsupported/mailit/smtpclient.cpp index 7bb7933..3bdc072 100644 --- a/noncore/unsupported/mailit/smtpclient.cpp +++ b/noncore/unsupported/mailit/smtpclient.cpp | |||
@@ -29,66 +29,66 @@ SmtpClient::SmtpClient() | |||
29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); | 29 | connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); |
30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); | 30 | connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); |
31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); | 31 | connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); |
32 | 32 | ||
33 | sending = FALSE; | 33 | sending = FALSE; |
34 | } | 34 | } |
35 | 35 | ||
36 | SmtpClient::~SmtpClient() | 36 | SmtpClient::~SmtpClient() |
37 | { | 37 | { |
38 | delete socket; | 38 | delete socket; |
39 | delete stream; | 39 | delete stream; |
40 | } | 40 | } |
41 | 41 | ||
42 | void SmtpClient::newConnection(QString target, int port) | 42 | void SmtpClient::newConnection(QString target, int port) |
43 | { | 43 | { |
44 | if (sending) { | 44 | if (sending) { |
45 | qWarning("socket in use, connection refused"); | 45 | qWarning("socket in use, connection refused"); |
46 | return; | 46 | return; |
47 | } | 47 | } |
48 | 48 | ||
49 | status = Init; | 49 | status = Init; |
50 | sending = TRUE; | 50 | sending = TRUE; |
51 | socket->connectToHost(target, port); | 51 | socket->connectToHost(target, port); |
52 | 52 | ||
53 | emit updateStatus("DNS lookup"); | 53 | emit updateStatus(tr("DNS lookup")); |
54 | } | 54 | } |
55 | 55 | ||
56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) | 56 | void SmtpClient::addMail(QString from, QString subject, QStringList to, QString body) |
57 | { | 57 | { |
58 | RawEmail *mail = new RawEmail; | 58 | RawEmail *mail = new RawEmail; |
59 | 59 | ||
60 | mail->from = from; | 60 | mail->from = from; |
61 | mail->subject = subject; | 61 | mail->subject = subject; |
62 | mail->to = to; | 62 | mail->to = to; |
63 | mail->body = body; | 63 | mail->body = body; |
64 | 64 | ||
65 | mailList.append(mail); | 65 | mailList.append(mail); |
66 | } | 66 | } |
67 | 67 | ||
68 | void SmtpClient::connectionEstablished() | 68 | void SmtpClient::connectionEstablished() |
69 | { | 69 | { |
70 | emit updateStatus("Connection established"); | 70 | emit updateStatus(tr("Connection established")); |
71 | 71 | ||
72 | } | 72 | } |
73 | 73 | ||
74 | void SmtpClient::errorHandling(int status) | 74 | void SmtpClient::errorHandling(int status) |
75 | { | 75 | { |
76 | emit errorOccurred(status); | 76 | emit errorOccurred(status); |
77 | socket->close(); | 77 | socket->close(); |
78 | mailList.clear(); | 78 | mailList.clear(); |
79 | sending = FALSE; | 79 | sending = FALSE; |
80 | } | 80 | } |
81 | 81 | ||
82 | void SmtpClient::incomingData() | 82 | void SmtpClient::incomingData() |
83 | { | 83 | { |
84 | QString response; | 84 | QString response; |
85 | 85 | ||
86 | if (!socket->canReadLine()) | 86 | if (!socket->canReadLine()) |
87 | return; | 87 | return; |
88 | 88 | ||
89 | response = socket->readLine(); | 89 | response = socket->readLine(); |
90 | 90 | ||
91 | switch(status) { | 91 | switch(status) { |
92 | case Init: { | 92 | case Init: { |
93 | if (response[0] == '2') { | 93 | if (response[0] == '2') { |
94 | status = From; | 94 | status = From; |
@@ -108,56 +108,56 @@ void SmtpClient::incomingData() | |||
108 | if (response[0] == '2') { | 108 | if (response[0] == '2') { |
109 | it = mailPtr->to.begin(); | 109 | it = mailPtr->to.begin(); |
110 | if (it == NULL) | 110 | if (it == NULL) |
111 | errorHandling(ErrUnknownResponse); | 111 | errorHandling(ErrUnknownResponse); |
112 | *stream << "RCPT TO: <" << *it << ">\r\n"; | 112 | *stream << "RCPT TO: <" << *it << ">\r\n"; |
113 | status = MRcv; | 113 | status = MRcv; |
114 | } else errorHandling(ErrUnknownResponse); | 114 | } else errorHandling(ErrUnknownResponse); |
115 | break; | 115 | break; |
116 | } | 116 | } |
117 | case MRcv: { | 117 | case MRcv: { |
118 | if (response[0] == '2') { | 118 | if (response[0] == '2') { |
119 | it++; | 119 | it++; |
120 | if ( it != mailPtr->to.end() ) { | 120 | if ( it != mailPtr->to.end() ) { |
121 | *stream << "RCPT TO: <" << *it << ">\r\n"; | 121 | *stream << "RCPT TO: <" << *it << ">\r\n"; |
122 | break; | 122 | break; |
123 | } else { | 123 | } else { |
124 | status = Data; | 124 | status = Data; |
125 | } | 125 | } |
126 | } else errorHandling(ErrUnknownResponse); | 126 | } else errorHandling(ErrUnknownResponse); |
127 | } | 127 | } |
128 | case Data: { | 128 | case Data: { |
129 | if (response[0] == '2') { | 129 | if (response[0] == '2') { |
130 | *stream << "DATA\r\n"; | 130 | *stream << "DATA\r\n"; |
131 | status = Body; | 131 | status = Body; |
132 | emit updateStatus("Sending: " + mailPtr->subject); | 132 | emit updateStatus(tr("Sending: ") + mailPtr->subject); |
133 | } else errorHandling(ErrUnknownResponse); | 133 | } else errorHandling(ErrUnknownResponse); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | case Body: { | 136 | case Body: { |
137 | if (response[0] == '3') { | 137 | if (response[0] == '3') { |
138 | *stream << mailPtr->body << "\r\n.\r\n"; | 138 | *stream << mailPtr->body << "\r\n.\r\n"; |
139 | mailPtr = mailList.next(); | 139 | mailPtr = mailList.next(); |
140 | if (mailPtr != NULL) { | 140 | if (mailPtr != NULL) { |
141 | status = From; | 141 | status = From; |
142 | } else { | 142 | } else { |
143 | status = Quit; | 143 | status = Quit; |
144 | } | 144 | } |
145 | } else errorHandling(ErrUnknownResponse); | 145 | } else errorHandling(ErrUnknownResponse); |
146 | break; | 146 | break; |
147 | } | 147 | } |
148 | case Quit: { | 148 | case Quit: { |
149 | if (response[0] == '2') { | 149 | if (response[0] == '2') { |
150 | *stream << "QUIT\r\n"; | 150 | *stream << "QUIT\r\n"; |
151 | status = Done; | 151 | status = Done; |
152 | QString temp; | 152 | QString temp; |
153 | temp.setNum(mailList.count()); | 153 | temp.setNum(mailList.count()); |
154 | emit updateStatus("Sent " + temp + " messages"); | 154 | emit updateStatus(tr("Sent ") + temp + tr(" messages")); |
155 | emit mailSent(); | 155 | emit mailSent(); |
156 | mailList.clear(); | 156 | mailList.clear(); |
157 | sending = FALSE; | 157 | sending = FALSE; |
158 | socket->close(); | 158 | socket->close(); |
159 | } else errorHandling(ErrUnknownResponse); | 159 | } else errorHandling(ErrUnknownResponse); |
160 | break; | 160 | break; |
161 | } | 161 | } |
162 | } | 162 | } |
163 | } | 163 | } |