author | zautrix <zautrix> | 2004-09-10 19:57:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-10 19:57:55 (UTC) |
commit | cebdd6de7481514ad5ea0517f7a2e8f4db422be5 (patch) (unidiff) | |
tree | 0b29859b5bbfdcb702724c3b0c721f22b0d0e666 /kmicromail/libmailwrapper/imapwrapper.cpp | |
parent | 157120031b77a3d9f10d780a66b6441dac1399fa (diff) | |
download | kdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.zip kdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.tar.gz kdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.tar.bz2 |
Added status info when deleting mails
Diffstat (limited to 'kmicromail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 021633b..be825ef 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -6,18 +6,23 @@ | |||
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | int IMAPwrapper::mMax = 0; | ||
13 | int IMAPwrapper::mCurrent = 0; | ||
14 | |||
12 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 15 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
13 | : AbstractMail() | 16 | : AbstractMail() |
14 | { | 17 | { |
15 | account = a; | 18 | account = a; |
16 | m_imap = 0; | 19 | m_imap = 0; |
17 | m_Lastmbox = ""; | 20 | m_Lastmbox = ""; |
21 | mCurrent = 0; | ||
22 | mMax = 0; | ||
18 | } | 23 | } |
19 | 24 | ||
20 | IMAPwrapper::~IMAPwrapper() | 25 | IMAPwrapper::~IMAPwrapper() |
21 | { | 26 | { |
22 | logout(); | 27 | logout(); |
23 | } | 28 | } |
@@ -37,16 +42,36 @@ int IMAPwrapper::selectMbox(const QString&mbox) | |||
37 | m_Lastmbox = mbox; | 42 | m_Lastmbox = mbox; |
38 | return err; | 43 | return err; |
39 | } | 44 | } |
40 | 45 | ||
41 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 46 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
42 | { | 47 | { |
48 | //qDebug("imap progress %d of %d ",current,maximum ); | ||
49 | //Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum)); | ||
50 | //qApp->processEvents() | ||
51 | static int last = 0; | ||
52 | if ( last != current ) | ||
53 | IMAPwrapper::progress(); | ||
54 | last = current; | ||
55 | } | ||
56 | void IMAPwrapper::progress( QString m ) | ||
57 | { | ||
58 | |||
59 | static QString mProgrMess; | ||
60 | if ( m != QString::null ) { | ||
61 | mProgrMess = m; | ||
62 | mCurrent = 0; | ||
63 | return; | ||
64 | } | ||
65 | QString mess; | ||
66 | //qDebug("progress "); | ||
67 | if ( mMax ) mess = mProgrMess +tr(" message %1 of %2").arg( mCurrent++).arg(mMax); | ||
68 | else mess = mProgrMess +tr(" message %1").arg( mCurrent++); | ||
69 | Global::statusMessage(mess); | ||
43 | qApp->processEvents(); | 70 | qApp->processEvents(); |
44 | qDebug("imap progress %d of %d ",current,maximum ); | ||
45 | } | 71 | } |
46 | |||
47 | bool IMAPwrapper::start_tls(bool force_tls) | 72 | bool IMAPwrapper::start_tls(bool force_tls) |
48 | { | 73 | { |
49 | int err; | 74 | int err; |
50 | bool try_tls; | 75 | bool try_tls; |
51 | mailimap_capability_data * cap_data = 0; | 76 | mailimap_capability_data * cap_data = 0; |
52 | 77 | ||
@@ -462,14 +487,13 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
462 | m->setMsgid(QString(head->env_message_id)); | 487 | m->setMsgid(QString(head->env_message_id)); |
463 | } | 488 | } |
464 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 489 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
465 | #if 0 | 490 | #if 0 |
466 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 491 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
467 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 492 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
468 | //odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; | 493 | qDebug("time %s ",da.toString().latin1() ); |
469 | //odebug << da.toString() << oendl; | ||
470 | #endif | 494 | #endif |
471 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 495 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
472 | size = item->att_data.att_static->att_data.att_rfc822_size; | 496 | size = item->att_data.att_static->att_data.att_rfc822_size; |
473 | } | 497 | } |
474 | } | 498 | } |
475 | /* msg is already deleted */ | 499 | /* msg is already deleted */ |
@@ -883,31 +907,20 @@ void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | |||
883 | return; | 907 | return; |
884 | } | 908 | } |
885 | int iii = 0; | 909 | int iii = 0; |
886 | int count = target.count(); | 910 | int count = target.count(); |
887 | // qDebug("imap remove count %d ", count); | 911 | // qDebug("imap remove count %d ", count); |
888 | 912 | ||
889 | QProgressBar bar( count,0 ); | 913 | |
890 | bar.setCaption (("Removing mails - close to abort!") ); | 914 | mMax = count; |
891 | int w = 300; | 915 | //progress( tr("Delete")); |
892 | if ( QApplication::desktop()->width() < 320 ) | 916 | QWidget wid; |
893 | w = 220; | 917 | wid.show(); |
894 | int h = bar.sizeHint().height() ; | ||
895 | int dw = QApplication::desktop()->width(); | ||
896 | int dh = QApplication::desktop()->height(); | ||
897 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
898 | bar.show(); | ||
899 | int modulo = (count/10)+1; | ||
900 | int incCounter = 0; | ||
901 | |||
902 | while (iii < count ) { | 918 | while (iii < count ) { |
903 | if ( ! bar.isVisible() ) | 919 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
904 | return ; | 920 | wid.raise(); |
905 | if ( incCounter % modulo == 0 ) | ||
906 | bar.setProgress( incCounter ); | ||
907 | ++incCounter; | ||
908 | qApp->processEvents(); | 921 | qApp->processEvents(); |
909 | RecMailP mail = (*target.at( iii )); | 922 | RecMailP mail = (*target.at( iii )); |
910 | //#if 0 | 923 | //#if 0 |
911 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | 924 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); |
912 | err = selectMbox(mail->getMbox()); | 925 | err = selectMbox(mail->getMbox()); |
913 | if ( err != MAILIMAP_NO_ERROR ) { | 926 | if ( err != MAILIMAP_NO_ERROR ) { |
@@ -1196,13 +1209,15 @@ encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | |||
1196 | return fetchRawPart(mail,path,false); | 1209 | return fetchRawPart(mail,path,false); |
1197 | } | 1210 | } |
1198 | 1211 | ||
1199 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1212 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1200 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 1213 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
1201 | { | 1214 | { |
1202 | if (targetWrapper != this || maxSizeInKb > 0 ) { | 1215 | if (targetWrapper != this || maxSizeInKb > 0 ) { |
1216 | mMax = 0; | ||
1217 | progress( tr("Copy")); | ||
1203 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); | 1218 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); |
1204 | qDebug("IMAPwrapper::mvcpAllMails::Using generic"); | 1219 | qDebug("IMAPwrapper::mvcpAllMails::Using generic"); |
1205 | // odebug << "Using generic" << oendl; | 1220 | // odebug << "Using generic" << oendl; |
1206 | return; | 1221 | return; |
1207 | } | 1222 | } |
1208 | mailimap_set *set = 0; | 1223 | mailimap_set *set = 0; |
@@ -1211,12 +1226,13 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | |||
1211 | return; | 1226 | return; |
1212 | } | 1227 | } |
1213 | int err = selectMbox(fromFolder->getName()); | 1228 | int err = selectMbox(fromFolder->getName()); |
1214 | if ( err != MAILIMAP_NO_ERROR ) { | 1229 | if ( err != MAILIMAP_NO_ERROR ) { |
1215 | return; | 1230 | return; |
1216 | } | 1231 | } |
1232 | Global::statusMessage( tr("Copying mails on server...") ); | ||
1217 | int last = m_imap->imap_selection_info->sel_exists; | 1233 | int last = m_imap->imap_selection_info->sel_exists; |
1218 | set = mailimap_set_new_interval( 1, last ); | 1234 | set = mailimap_set_new_interval( 1, last ); |
1219 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1235 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1220 | mailimap_set_free( set ); | 1236 | mailimap_set_free( set ); |
1221 | if ( err != MAILIMAP_NO_ERROR ) { | 1237 | if ( err != MAILIMAP_NO_ERROR ) { |
1222 | QString error_msg = tr("Error copy mails: %1").arg(m_imap->imap_response); | 1238 | QString error_msg = tr("Error copy mails: %1").arg(m_imap->imap_response); |