author | zautrix <zautrix> | 2004-09-01 10:23:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-01 10:23:29 (UTC) |
commit | 6cefbdc9c8f3f3001373f10715361e2740c45395 (patch) (unidiff) | |
tree | cb2c36f57620e698913c27ca4ebe59e4a7c9d46e /kmicromail/libmailwrapper/pop3wrapper.cpp | |
parent | b9257cb225cd29bab5d96fcdaf557926603ee587 (diff) | |
download | kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.zip kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.tar.gz kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.tar.bz2 |
Mail fixes and libetpan updated
Diffstat (limited to 'kmicromail/libmailwrapper/pop3wrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp index 7a84b30..0e6612c 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.cpp +++ b/kmicromail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,22 +1,24 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | #include "logindialog.h" | 5 | #include "logindialog.h" |
6 | #include <libetpan/libetpan.h> | 6 | #include <libetpan/libetpan.h> |
7 | 7 | ||
8 | 8 | ||
9 | #include <qpe/global.h> | 9 | #include <qpe/global.h> |
10 | #include <qfile.h> | 10 | #include <qfile.h> |
11 | #include <qprogressbar.h> | ||
12 | #include <qapplication.h> | ||
11 | 13 | ||
12 | /* we don't fetch messages larger than 5 MB */ | 14 | /* we don't fetch messages larger than 5 MB */ |
13 | #define HARD_MSG_SIZE_LIMIT 5242880 | 15 | #define HARD_MSG_SIZE_LIMIT 5242880 |
14 | 16 | ||
15 | using namespace Opie::Core; | 17 | using namespace Opie::Core; |
16 | POP3wrapper::POP3wrapper( POP3account *a ) | 18 | POP3wrapper::POP3wrapper( POP3account *a ) |
17 | : Genericwrapper() { | 19 | : Genericwrapper() { |
18 | account = a; | 20 | account = a; |
19 | m_pop3 = NULL; | 21 | m_pop3 = NULL; |
20 | msgTempName = a->getFileName()+"_msg_cache"; | 22 | msgTempName = a->getFileName()+"_msg_cache"; |
21 | last_msg_id = 0; | 23 | last_msg_id = 0; |
22 | } | 24 | } |
@@ -184,36 +186,55 @@ void POP3wrapper::logout() | |||
184 | mailstorage_free(m_pop3); | 186 | mailstorage_free(m_pop3); |
185 | m_pop3 = 0; | 187 | m_pop3 = 0; |
186 | } | 188 | } |
187 | 189 | ||
188 | 190 | ||
189 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | 191 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { |
190 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); | 192 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); |
191 | FolderP inb=new Folder("INBOX","/"); | 193 | FolderP inb=new Folder("INBOX","/"); |
192 | folders->append(inb); | 194 | folders->append(inb); |
193 | return folders; | 195 | return folders; |
194 | } | 196 | } |
195 | 197 | ||
196 | void POP3wrapper::deleteMailList(QValueList<RecMailP>&target) | 198 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) |
197 | { | 199 | { |
198 | login(); | 200 | login(); |
199 | if (!m_pop3) | 201 | if (!m_pop3) |
200 | return; | 202 | return; |
201 | int iii = 0; | 203 | int iii = 0; |
202 | int count = target.count(); | 204 | int count = target.count(); |
205 | QProgressBar bar( count,0 ); | ||
206 | bar.setCaption (("Removing mails - close to abort!") ); | ||
207 | int w = 300; | ||
208 | if ( QApplication::desktop()->width() < 320 ) | ||
209 | w = 220; | ||
210 | int h = bar.sizeHint().height() ; | ||
211 | int dw = QApplication::desktop()->width(); | ||
212 | int dh = QApplication::desktop()->height(); | ||
213 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
214 | bar.show(); | ||
215 | int modulo = (count/10)+1; | ||
216 | int incCounter = 0; | ||
203 | while (iii < count ) { | 217 | while (iii < count ) { |
218 | if ( ! bar.isVisible() ) | ||
219 | return ; | ||
220 | if ( incCounter % modulo == 0 ) | ||
221 | bar.setProgress( incCounter ); | ||
222 | ++incCounter; | ||
223 | qApp->processEvents(); | ||
224 | //qDebug("delete "); | ||
204 | RecMailP mail = (*target.at( iii )); | 225 | RecMailP mail = (*target.at( iii )); |
205 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 226 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
206 | if (err != MAIL_NO_ERROR) { | 227 | if (err != MAIL_NO_ERROR) { |
207 | Global::statusMessage(tr("error deleting mail")); | 228 | Global::statusMessage(tr("Error deleting mail")); |
208 | } | 229 | } |
209 | ++iii; | 230 | ++iii; |
210 | } | 231 | } |
211 | } | 232 | } |
212 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 233 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
213 | login(); | 234 | login(); |
214 | if (!m_pop3) | 235 | if (!m_pop3) |
215 | return; | 236 | return; |
216 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 237 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
217 | if (err != MAIL_NO_ERROR) { | 238 | if (err != MAIL_NO_ERROR) { |
218 | Global::statusMessage(tr("error deleting mail")); | 239 | Global::statusMessage(tr("error deleting mail")); |
219 | } | 240 | } |
@@ -224,25 +245,43 @@ void POP3wrapper::answeredMail(const RecMailP&) {} | |||
224 | int POP3wrapper::deleteAllMail(const FolderP&) { | 245 | int POP3wrapper::deleteAllMail(const FolderP&) { |
225 | login(); | 246 | login(); |
226 | if (!m_pop3) | 247 | if (!m_pop3) |
227 | return 0; | 248 | return 0; |
228 | int res = 1; | 249 | int res = 1; |
229 | 250 | ||
230 | uint32_t result = 0; | 251 | uint32_t result = 0; |
231 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 252 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
232 | if (err != MAIL_NO_ERROR) { | 253 | if (err != MAIL_NO_ERROR) { |
233 | Global::statusMessage(tr("Error getting folder info")); | 254 | Global::statusMessage(tr("Error getting folder info")); |
234 | return 0; | 255 | return 0; |
235 | } | 256 | } |
257 | QProgressBar bar( result,0 ); | ||
258 | bar.setCaption (("Deleting mails - close to abort!") ); | ||
259 | int w = 300; | ||
260 | if ( QApplication::desktop()->width() < 320 ) | ||
261 | w = 220; | ||
262 | int h = bar.sizeHint().height() ; | ||
263 | int dw = QApplication::desktop()->width(); | ||
264 | int dh = QApplication::desktop()->height(); | ||
265 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
266 | bar.show(); | ||
267 | int modulo = (result/10)+1; | ||
268 | int incCounter = 0; | ||
236 | for (unsigned int i = 0; i < result; ++i) { | 269 | for (unsigned int i = 0; i < result; ++i) { |
270 | if ( ! bar.isVisible() ) | ||
271 | return 0; | ||
272 | if ( incCounter % modulo == 0 ) | ||
273 | bar.setProgress( incCounter ); | ||
274 | ++incCounter; | ||
275 | qApp->processEvents(); | ||
237 | err = mailsession_remove_message(m_pop3->sto_session,i+1); | 276 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
238 | if (err != MAIL_NO_ERROR) { | 277 | if (err != MAIL_NO_ERROR) { |
239 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 278 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
240 | res=0; | 279 | res=0; |
241 | } | 280 | } |
242 | break; | 281 | break; |
243 | } | 282 | } |
244 | return res; | 283 | return res; |
245 | } | 284 | } |
246 | 285 | ||
247 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 286 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
248 | login(); | 287 | login(); |