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 | |
parent | 157120031b77a3d9f10d780a66b6441dac1399fa (diff) | |
download | kdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.zip kdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.tar.gz kdepimpi-cebdd6de7481514ad5ea0517f7a2e8f4db422be5.tar.bz2 |
Added status info when deleting mails
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 53 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 62 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.h | 4 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.cpp | 49 |
4 files changed, 67 insertions, 101 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index cef4e97..f876235 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -1,31 +1,32 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "abstractmail.h" | 2 | #include "abstractmail.h" |
3 | #include "imapwrapper.h" | 3 | #include "imapwrapper.h" |
4 | #include "pop3wrapper.h" | 4 | #include "pop3wrapper.h" |
5 | #include "nntpwrapper.h" | 5 | #include "nntpwrapper.h" |
6 | #include "mhwrapper.h" | 6 | #include "mhwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include <qpe/global.h> | ||
8 | 9 | ||
9 | 10 | ||
10 | #include <qprogressbar.h> | 11 | #include <qprogressbar.h> |
11 | #include <qapplication.h> | 12 | #include <qapplication.h> |
12 | 13 | ||
13 | #include <kdecore/kstandarddirs.h> | 14 | #include <kdecore/kstandarddirs.h> |
14 | #include <qfile.h> | 15 | #include <qfile.h> |
15 | #include <qtextstream.h> | 16 | #include <qtextstream.h> |
16 | #include <stdlib.h> | 17 | #include <stdlib.h> |
17 | #include <libetpan/mailmime_content.h> | 18 | #include <libetpan/mailmime_content.h> |
18 | #include <libetpan/mailmime.h> | 19 | #include <libetpan/mailmime.h> |
19 | 20 | ||
20 | using namespace Opie::Core; | 21 | using namespace Opie::Core; |
21 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 22 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
22 | { | 23 | { |
23 | return new IMAPwrapper(a); | 24 | return new IMAPwrapper(a); |
24 | } | 25 | } |
25 | 26 | ||
26 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 27 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
27 | { | 28 | { |
28 | return new POP3wrapper(a); | 29 | return new POP3wrapper(a); |
29 | } | 30 | } |
30 | 31 | ||
31 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 32 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
@@ -125,113 +126,85 @@ int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) | |||
125 | 126 | ||
126 | QString AbstractMail::defaultLocalfolder() | 127 | QString AbstractMail::defaultLocalfolder() |
127 | { | 128 | { |
128 | // QString f = getenv( "HOME" ); | 129 | // QString f = getenv( "HOME" ); |
129 | QString f = locateLocal( "data", "kopiemail/localmail"); | 130 | QString f = locateLocal( "data", "kopiemail/localmail"); |
130 | // f += "/Applications/opiemail/localmail"; | 131 | // f += "/Applications/opiemail/localmail"; |
131 | return f; | 132 | return f; |
132 | } | 133 | } |
133 | 134 | ||
134 | QString AbstractMail::draftFolder() | 135 | QString AbstractMail::draftFolder() |
135 | { | 136 | { |
136 | return QString("Drafts"); | 137 | return QString("Drafts"); |
137 | } | 138 | } |
138 | 139 | ||
139 | /* temporary - will be removed when implemented in all classes */ | 140 | /* temporary - will be removed when implemented in all classes */ |
140 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 141 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
141 | { | 142 | { |
142 | } | 143 | } |
143 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | 144 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) |
144 | { | 145 | { |
145 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | 146 | //qDebug("AbstractMail::deleteMailList:: Please reimplement! "); |
146 | // this is currently re-implemented in pop3wrapper and imapwrapper | 147 | // this is currently re-implemented in pop3wrapper and imapwrapper |
147 | int iii = 0; | 148 | int iii = 0; |
148 | int count = target.count(); | 149 | int count = target.count(); |
149 | QProgressBar bar( count,0 ); | 150 | QWidget wid; |
150 | bar.setCaption (("Removing mails - close to abort!") ); | 151 | wid.show(); |
151 | int w = 300; | 152 | while (iii < count ) { |
152 | if ( QApplication::desktop()->width() < 320 ) | 153 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
153 | w = 220; | 154 | wid.raise(); |
154 | int h = bar.sizeHint().height() ; | ||
155 | int dw = QApplication::desktop()->width(); | ||
156 | int dh = QApplication::desktop()->height(); | ||
157 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
158 | bar.show(); | ||
159 | int modulo = (count/10)+1; | ||
160 | int incCounter = 0; | ||
161 | while (iii < count ) { | ||
162 | if ( ! bar.isVisible() ) | ||
163 | return ; | ||
164 | if ( incCounter % modulo == 0 ) | ||
165 | bar.setProgress( incCounter ); | ||
166 | ++incCounter; | ||
167 | qApp->processEvents(); | 155 | qApp->processEvents(); |
168 | RecMailP mail = (*target.at( iii )); | 156 | RecMailP mail = (*target.at( iii )); |
169 | deleteMail(mail); | 157 | deleteMail(mail); |
170 | ++iii; | 158 | ++iii; |
171 | } | 159 | } |
172 | } | 160 | } |
173 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 161 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
174 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 162 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
175 | { | 163 | { |
176 | QValueList<RecMailP> t; | 164 | QValueList<RecMailP> t; |
177 | listMessages(fromFolder->getName(),t, maxSizeInKb); | 165 | listMessages(fromFolder->getName(),t, maxSizeInKb); |
178 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | 166 | mvcpMailList( t,targetFolder,targetWrapper,moveit); |
179 | 167 | ||
180 | } | 168 | } |
181 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, | 169 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, |
182 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 170 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
183 | { | 171 | { |
184 | encodedString*st = 0; | 172 | encodedString*st = 0; |
185 | int iii = 0; | 173 | int iii = 0; |
186 | int count = t.count(); | 174 | int count = t.count(); |
187 | if ( count == 0 ) | 175 | if ( count == 0 ) |
188 | return; | 176 | return; |
189 | 177 | // wel, processevents is qite strange, we need a widget for getting | |
190 | QProgressBar bar( count,0 ); | 178 | // Global::statusMessage(tr("Copy2 message %1").arg(iii)); displayed |
191 | bar.setCaption (("Copying mails - close to abort!") ); | 179 | QWidget wid; |
192 | int w = 300; | 180 | wid.show(); |
193 | if ( QApplication::desktop()->width() < 320 ) | 181 | while (iii < count ) { |
194 | w = 220; | 182 | Global::statusMessage(tr("Copy message %1 of %2").arg(iii).arg(count)); |
195 | int h = bar.sizeHint().height() ; | 183 | wid.raise(); |
196 | int dw = QApplication::desktop()->width(); | ||
197 | int dh = QApplication::desktop()->height(); | ||
198 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
199 | bar.show(); | ||
200 | int modulo = (count/10)+1; | ||
201 | int incCounter = 0; | ||
202 | while (iii < count ) { | ||
203 | if ( ! bar.isVisible() ) | ||
204 | return ; | ||
205 | if ( incCounter % modulo == 0 ) | ||
206 | bar.setProgress( incCounter ); | ||
207 | ++incCounter; | ||
208 | bar.raise(); | ||
209 | qApp->processEvents(); | 184 | qApp->processEvents(); |
210 | //qDebug("copy "); | ||
211 | RecMailP r = (*t.at( iii )); | 185 | RecMailP r = (*t.at( iii )); |
212 | st = fetchRawBody(r); | 186 | st = fetchRawBody(r); |
213 | if (st) { | 187 | if (st) { |
214 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 188 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
215 | delete st; | 189 | delete st; |
216 | } | 190 | } |
217 | ++iii; | 191 | ++iii; |
218 | } | 192 | } |
219 | bar.hide(); | ||
220 | if (moveit) { | 193 | if (moveit) { |
221 | deleteMailList( t ); | 194 | deleteMailList( t ); |
222 | //deleteAllMail(fromFolder); | 195 | //deleteAllMail(fromFolder); |
223 | } | 196 | } |
224 | } | 197 | } |
225 | 198 | ||
226 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 199 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
227 | { | 200 | { |
228 | encodedString*st = 0; | 201 | encodedString*st = 0; |
229 | st = fetchRawBody(mail); | 202 | st = fetchRawBody(mail); |
230 | if (st) { | 203 | if (st) { |
231 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 204 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
232 | delete st; | 205 | delete st; |
233 | } | 206 | } |
234 | if (moveit) { | 207 | if (moveit) { |
235 | deleteMail(mail); | 208 | deleteMail(mail); |
236 | } | 209 | } |
237 | } | 210 | } |
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 | |||
@@ -1,70 +1,95 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
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 | } |
24 | 29 | ||
25 | /* to avoid to often select statements in loops etc. | 30 | /* to avoid to often select statements in loops etc. |
26 | we trust that we are logged in and connection is established!*/ | 31 | we trust that we are logged in and connection is established!*/ |
27 | int IMAPwrapper::selectMbox(const QString&mbox) | 32 | int IMAPwrapper::selectMbox(const QString&mbox) |
28 | { | 33 | { |
29 | if (mbox == m_Lastmbox) { | 34 | if (mbox == m_Lastmbox) { |
30 | return MAILIMAP_NO_ERROR; | 35 | return MAILIMAP_NO_ERROR; |
31 | } | 36 | } |
32 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 37 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
33 | if ( err != MAILIMAP_NO_ERROR ) { | 38 | if ( err != MAILIMAP_NO_ERROR ) { |
34 | m_Lastmbox = ""; | 39 | m_Lastmbox = ""; |
35 | return err; | 40 | return err; |
36 | } | 41 | } |
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 | ||
53 | err = mailimap_capability(m_imap,&cap_data); | 78 | err = mailimap_capability(m_imap,&cap_data); |
54 | if (err != MAILIMAP_NO_ERROR) { | 79 | if (err != MAILIMAP_NO_ERROR) { |
55 | Global::statusMessage("error getting capabilities!"); | 80 | Global::statusMessage("error getting capabilities!"); |
56 | return false; | 81 | return false; |
57 | } | 82 | } |
58 | clistiter * cur; | 83 | clistiter * cur; |
59 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 84 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
60 | struct mailimap_capability * cap; | 85 | struct mailimap_capability * cap; |
61 | cap = (struct mailimap_capability *)clist_content(cur); | 86 | cap = (struct mailimap_capability *)clist_content(cur); |
62 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 87 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
63 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 88 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
64 | try_tls = true; | 89 | try_tls = true; |
65 | break; | 90 | break; |
66 | } | 91 | } |
67 | } | 92 | } |
68 | } | 93 | } |
69 | if (cap_data) { | 94 | if (cap_data) { |
70 | mailimap_capability_data_free(cap_data); | 95 | mailimap_capability_data_free(cap_data); |
@@ -444,50 +469,49 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
444 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 469 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
445 | if (addresslist.count()) { | 470 | if (addresslist.count()) { |
446 | m->setReplyto(addresslist.first()); | 471 | m->setReplyto(addresslist.first()); |
447 | } | 472 | } |
448 | } | 473 | } |
449 | if (head->env_in_reply_to!=NULL) { | 474 | if (head->env_in_reply_to!=NULL) { |
450 | QString h(head->env_in_reply_to); | 475 | QString h(head->env_in_reply_to); |
451 | while (h.length()>0 && h[0]=='<') { | 476 | while (h.length()>0 && h[0]=='<') { |
452 | h.remove(0,1); | 477 | h.remove(0,1); |
453 | } | 478 | } |
454 | while (h.length()>0 && h[h.length()-1]=='>') { | 479 | while (h.length()>0 && h[h.length()-1]=='>') { |
455 | h.remove(h.length()-1,1); | 480 | h.remove(h.length()-1,1); |
456 | } | 481 | } |
457 | if (h.length()>0) { | 482 | if (h.length()>0) { |
458 | m->setInreply(QStringList(h)); | 483 | m->setInreply(QStringList(h)); |
459 | } | 484 | } |
460 | } | 485 | } |
461 | if (head->env_message_id) { | 486 | if (head->env_message_id) { |
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 */ |
476 | if (mFlags.testBit(FLAG_DELETED) && m) { | 500 | if (mFlags.testBit(FLAG_DELETED) && m) { |
477 | delete m; | 501 | delete m; |
478 | m = 0; | 502 | m = 0; |
479 | } | 503 | } |
480 | if (m) { | 504 | if (m) { |
481 | m->setFlags(mFlags); | 505 | m->setFlags(mFlags); |
482 | m->setMsgsize(size); | 506 | m->setMsgsize(size); |
483 | } | 507 | } |
484 | return m; | 508 | return m; |
485 | } | 509 | } |
486 | 510 | ||
487 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 511 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
488 | { | 512 | { |
489 | RecBodyP body = new RecBody(); | 513 | RecBodyP body = new RecBody(); |
490 | const char *mb; | 514 | const char *mb; |
491 | int err = MAILIMAP_NO_ERROR; | 515 | int err = MAILIMAP_NO_ERROR; |
492 | clist *result = 0; | 516 | clist *result = 0; |
493 | clistcell *current; | 517 | clistcell *current; |
@@ -865,67 +889,56 @@ void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which | |||
865 | } | 889 | } |
866 | } | 890 | } |
867 | if (which->bd_description) { | 891 | if (which->bd_description) { |
868 | target_part->setDescription(QString(which->bd_description)); | 892 | target_part->setDescription(QString(which->bd_description)); |
869 | } | 893 | } |
870 | target_part->setEncoding(encoding); | 894 | target_part->setEncoding(encoding); |
871 | target_part->setSize(which->bd_size); | 895 | target_part->setSize(which->bd_size); |
872 | } | 896 | } |
873 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | 897 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) |
874 | { | 898 | { |
875 | //#if 0 | 899 | //#if 0 |
876 | mailimap_flag_list*flist; | 900 | mailimap_flag_list*flist; |
877 | mailimap_set *set; | 901 | mailimap_set *set; |
878 | mailimap_store_att_flags * store_flags; | 902 | mailimap_store_att_flags * store_flags; |
879 | int err; | 903 | int err; |
880 | login(); | 904 | login(); |
881 | //#endif | 905 | //#endif |
882 | if (!m_imap) { | 906 | if (!m_imap) { |
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 ) { |
914 | return; | 927 | return; |
915 | } | 928 | } |
916 | flist = mailimap_flag_list_new_empty(); | 929 | flist = mailimap_flag_list_new_empty(); |
917 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 930 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
918 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 931 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
919 | set = mailimap_set_new_single(mail->getNumber()); | 932 | set = mailimap_set_new_single(mail->getNumber()); |
920 | err = mailimap_store(m_imap,set,store_flags); | 933 | err = mailimap_store(m_imap,set,store_flags); |
921 | mailimap_set_free( set ); | 934 | mailimap_set_free( set ); |
922 | mailimap_store_att_flags_free(store_flags); | 935 | mailimap_store_att_flags_free(store_flags); |
923 | 936 | ||
924 | if (err != MAILIMAP_NO_ERROR) { | 937 | if (err != MAILIMAP_NO_ERROR) { |
925 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 938 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
926 | return; | 939 | return; |
927 | } | 940 | } |
928 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 941 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
929 | /* should we realy do that at this moment? */ | 942 | /* should we realy do that at this moment? */ |
930 | 943 | ||
931 | // err = mailimap_expunge(m_imap); | 944 | // err = mailimap_expunge(m_imap); |
@@ -1178,63 +1191,66 @@ void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folde | |||
1178 | } | 1191 | } |
1179 | } | 1192 | } |
1180 | 1193 | ||
1181 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1194 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1182 | { | 1195 | { |
1183 | return account->getType(); | 1196 | return account->getType(); |
1184 | } | 1197 | } |
1185 | 1198 | ||
1186 | const QString&IMAPwrapper::getName()const | 1199 | const QString&IMAPwrapper::getName()const |
1187 | { | 1200 | { |
1188 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1201 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1189 | return account->getAccountName(); | 1202 | return account->getAccountName(); |
1190 | } | 1203 | } |
1191 | 1204 | ||
1192 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1205 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1193 | { | 1206 | { |
1194 | // dummy | 1207 | // dummy |
1195 | QValueList<int> path; | 1208 | QValueList<int> path; |
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; |
1209 | login(); | 1224 | login(); |
1210 | if (!m_imap) { | 1225 | if (!m_imap) { |
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); |
1223 | Global::statusMessage(error_msg); | 1239 | Global::statusMessage(error_msg); |
1224 | // odebug << error_msg << oendl; | 1240 | // odebug << error_msg << oendl; |
1225 | return; | 1241 | return; |
1226 | } | 1242 | } |
1227 | if (moveit) { | 1243 | if (moveit) { |
1228 | deleteAllMail(fromFolder); | 1244 | deleteAllMail(fromFolder); |
1229 | } | 1245 | } |
1230 | } | 1246 | } |
1231 | 1247 | ||
1232 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1248 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1233 | { | 1249 | { |
1234 | if (targetWrapper != this) { | 1250 | if (targetWrapper != this) { |
1235 | // odebug << "Using generic" << oendl; | 1251 | // odebug << "Using generic" << oendl; |
1236 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1252 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1237 | return; | 1253 | return; |
1238 | } | 1254 | } |
1239 | mailimap_set *set = 0; | 1255 | mailimap_set *set = 0; |
1240 | login(); | 1256 | login(); |
diff --git a/kmicromail/libmailwrapper/imapwrapper.h b/kmicromail/libmailwrapper/imapwrapper.h index 222fe95..db8ab5b 100644 --- a/kmicromail/libmailwrapper/imapwrapper.h +++ b/kmicromail/libmailwrapper/imapwrapper.h | |||
@@ -52,31 +52,33 @@ public: | |||
52 | virtual void logout(); | 52 | virtual void logout(); |
53 | virtual MAILLIB::ATYPE getType()const; | 53 | virtual MAILLIB::ATYPE getType()const; |
54 | virtual const QString&getName()const; | 54 | virtual const QString&getName()const; |
55 | 55 | ||
56 | protected: | 56 | protected: |
57 | RecMail*parse_list_result(mailimap_msg_att*); | 57 | RecMail*parse_list_result(mailimap_msg_att*); |
58 | void login(); | 58 | void login(); |
59 | bool start_tls(bool force=true); | 59 | bool start_tls(bool force=true); |
60 | 60 | ||
61 | virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); | 61 | virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); |
62 | virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); | 62 | virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); |
63 | int selectMbox(const QString&mbox); | 63 | int selectMbox(const QString&mbox); |
64 | 64 | ||
65 | void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description); | 65 | void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description); |
66 | void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which); | 66 | void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which); |
67 | void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which); | 67 | void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which); |
68 | void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which); | 68 | void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which); |
69 | void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which); | 69 | void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which); |
70 | void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1); | 70 | void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1); |
71 | 71 | ||
72 | /* just helpers */ | 72 | /* just helpers */ |
73 | static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); | 73 | static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which); |
74 | static QStringList address_list_to_stringlist(clist*list); | 74 | static QStringList address_list_to_stringlist(clist*list); |
75 | 75 | ||
76 | 76 | static void progress(QString mess = QString::null); | |
77 | static int mCurrent; | ||
78 | static int mMax; | ||
77 | IMAPaccount *account; | 79 | IMAPaccount *account; |
78 | mailimap *m_imap; | 80 | mailimap *m_imap; |
79 | QString m_Lastmbox; | 81 | QString m_Lastmbox; |
80 | }; | 82 | }; |
81 | 83 | ||
82 | #endif | 84 | #endif |
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp index f430121..8d2f778 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.cpp +++ b/kmicromail/libmailwrapper/pop3wrapper.cpp | |||
@@ -105,193 +105,168 @@ void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPoi | |||
105 | if (!m_pop3) | 105 | if (!m_pop3) |
106 | return; | 106 | return; |
107 | uint32_t res_messages,res_recent,res_unseen; | 107 | uint32_t res_messages,res_recent,res_unseen; |
108 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 108 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
109 | parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); | 109 | parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); |
110 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 110 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); |
111 | } | 111 | } |
112 | 112 | ||
113 | void POP3wrapper::login() | 113 | void POP3wrapper::login() |
114 | { | 114 | { |
115 | if (account->getOffline()) | 115 | if (account->getOffline()) |
116 | return; | 116 | return; |
117 | /* we'll hold the line */ | 117 | /* we'll hold the line */ |
118 | if ( m_pop3 != NULL ) | 118 | if ( m_pop3 != NULL ) |
119 | return; | 119 | return; |
120 | 120 | ||
121 | QString server,user, pass; | 121 | QString server,user, pass; |
122 | uint16_t port; | 122 | uint16_t port; |
123 | int err = MAILPOP3_NO_ERROR; | 123 | int err = MAILPOP3_NO_ERROR; |
124 | 124 | ||
125 | server = account->getServer().latin1(); | 125 | server = account->getServer().latin1(); |
126 | port = account->getPort().toUInt(); | 126 | port = account->getPort().toUInt(); |
127 | 127 | ||
128 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 128 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
129 | qApp->processEvents(); | ||
129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 130 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
130 | login.show(); | 131 | login.show(); |
131 | if ( QDialog::Accepted == login.exec() ) { | 132 | if ( QDialog::Accepted == login.exec() ) { |
132 | // ok | 133 | // ok |
133 | qDebug("ok "); | ||
134 | user = login.getUser(); | 134 | user = login.getUser(); |
135 | pass = login.getPassword(); | 135 | pass = login.getPassword(); |
136 | } else { | 136 | } else { |
137 | // cancel | 137 | // cancel |
138 | ; // odebug << "POP3: Login canceled" << oendl; | 138 | ; // odebug << "POP3: Login canceled" << oendl; |
139 | return; | 139 | return; |
140 | } | 140 | } |
141 | } else { | 141 | } else { |
142 | user = account->getUser(); | 142 | user = account->getUser(); |
143 | pass = account->getPassword(); | 143 | pass = account->getPassword(); |
144 | } | 144 | } |
145 | // bool ssl = account->getSSL(); | 145 | // bool ssl = account->getSSL(); |
146 | 146 | ||
147 | m_pop3=mailstorage_new(NULL); | 147 | m_pop3=mailstorage_new(NULL); |
148 | int conntypeset = account->ConnectionType(); | 148 | int conntypeset = account->ConnectionType(); |
149 | int conntype = 0; | 149 | int conntype = 0; |
150 | if ( conntypeset == 3 ) { | 150 | if ( conntypeset == 3 ) { |
151 | conntype = CONNECTION_TYPE_COMMAND; | 151 | conntype = CONNECTION_TYPE_COMMAND; |
152 | } else if ( conntypeset == 2 ) { | 152 | } else if ( conntypeset == 2 ) { |
153 | conntype = CONNECTION_TYPE_TLS; | 153 | conntype = CONNECTION_TYPE_TLS; |
154 | } else if ( conntypeset == 1 ) { | 154 | } else if ( conntypeset == 1 ) { |
155 | conntype = CONNECTION_TYPE_STARTTLS; | 155 | conntype = CONNECTION_TYPE_STARTTLS; |
156 | } else if ( conntypeset == 0 ) { | 156 | } else if ( conntypeset == 0 ) { |
157 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 157 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
158 | } | 158 | } |
159 | 159 | ||
160 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 160 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); |
161 | 161 | ||
162 | pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 162 | pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
163 | (char*)user.latin1(),(char*)pass.latin1(),0,0,0); | 163 | (char*)user.latin1(),(char*)pass.latin1(),0,0,0); |
164 | 164 | ||
165 | err = mailstorage_connect(m_pop3); | 165 | err = mailstorage_connect(m_pop3); |
166 | if (err != MAIL_NO_ERROR) { | 166 | if (err != MAIL_NO_ERROR) { |
167 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 167 | ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
168 | Global::statusMessage(tr("Error initializing folder")); | 168 | Global::statusMessage(tr("Error %1 initializing folder").arg( err )); |
169 | mailstorage_free(m_pop3); | 169 | mailstorage_free(m_pop3); |
170 | m_pop3 = 0; | 170 | m_pop3 = 0; |
171 | } else { | 171 | } else { |
172 | mailsession * session = m_pop3->sto_session; | 172 | mailsession * session = m_pop3->sto_session; |
173 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; | 173 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; |
174 | if (mail) { | 174 | if (mail) { |
175 | mail->pop3_progr_fun = &pop3_progress; | 175 | mail->pop3_progr_fun = &pop3_progress; |
176 | } | 176 | } |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | void POP3wrapper::logout() | 180 | void POP3wrapper::logout() |
181 | { | 181 | { |
182 | if ( m_pop3 == NULL ) | 182 | if ( m_pop3 == NULL ) |
183 | return; | 183 | return; |
184 | mailstorage_free(m_pop3); | 184 | mailstorage_free(m_pop3); |
185 | m_pop3 = 0; | 185 | m_pop3 = 0; |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
189 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | 189 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { |
190 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); | 190 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); |
191 | FolderP inb=new Folder("INBOX","/"); | 191 | FolderP inb=new Folder("INBOX","/"); |
192 | folders->append(inb); | 192 | folders->append(inb); |
193 | return folders; | 193 | return folders; |
194 | } | 194 | } |
195 | 195 | ||
196 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) | 196 | void POP3wrapper::deleteMailList(const QValueList<RecMailP>&target) |
197 | { | 197 | { |
198 | login(); | 198 | login(); |
199 | if (!m_pop3) | 199 | if (!m_pop3) |
200 | return; | 200 | return; |
201 | int iii = 0; | 201 | int iii = 0; |
202 | int count = target.count(); | 202 | int count = target.count(); |
203 | QProgressBar bar( count,0 ); | 203 | QWidget wid; |
204 | bar.setCaption (("Removing mails - close to abort!") ); | 204 | wid.show(); |
205 | int w = 300; | ||
206 | if ( QApplication::desktop()->width() < 320 ) | ||
207 | w = 220; | ||
208 | int h = bar.sizeHint().height() ; | ||
209 | int dw = QApplication::desktop()->width(); | ||
210 | int dh = QApplication::desktop()->height(); | ||
211 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
212 | bar.show(); | ||
213 | int modulo = (count/10)+1; | ||
214 | int incCounter = 0; | ||
215 | while (iii < count ) { | 205 | while (iii < count ) { |
216 | if ( ! bar.isVisible() ) | 206 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
217 | return ; | 207 | wid.raise(); |
218 | if ( incCounter % modulo == 0 ) | ||
219 | bar.setProgress( incCounter ); | ||
220 | ++incCounter; | ||
221 | qApp->processEvents(); | 208 | qApp->processEvents(); |
222 | //qDebug("delete "); | 209 | //qDebug("delete "); |
223 | RecMailP mail = (*target.at( iii )); | 210 | RecMailP mail = (*target.at( iii )); |
224 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 211 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
225 | if (err != MAIL_NO_ERROR) { | 212 | if (err != MAIL_NO_ERROR) { |
226 | Global::statusMessage(tr("Error deleting mail")); | 213 | Global::statusMessage(tr("Error deleting mail")); |
227 | } | 214 | } |
228 | ++iii; | 215 | ++iii; |
229 | } | 216 | } |
230 | } | 217 | } |
231 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 218 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
232 | login(); | 219 | login(); |
233 | if (!m_pop3) | 220 | if (!m_pop3) |
234 | return; | 221 | return; |
235 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 222 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
236 | if (err != MAIL_NO_ERROR) { | 223 | if (err != MAIL_NO_ERROR) { |
237 | Global::statusMessage(tr("error deleting mail")); | 224 | Global::statusMessage(tr("error deleting mail")); |
238 | } | 225 | } |
239 | } | 226 | } |
240 | 227 | ||
241 | void POP3wrapper::answeredMail(const RecMailP&) {} | 228 | void POP3wrapper::answeredMail(const RecMailP&) {} |
242 | 229 | ||
243 | int POP3wrapper::deleteAllMail(const FolderP&) { | 230 | int POP3wrapper::deleteAllMail(const FolderP&) { |
244 | login(); | 231 | login(); |
245 | if (!m_pop3) | 232 | if (!m_pop3) |
246 | return 0; | 233 | return 0; |
247 | int res = 1; | 234 | int res = 1; |
248 | 235 | ||
249 | uint32_t result = 0; | 236 | uint32_t result = 0; |
250 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 237 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
251 | if (err != MAIL_NO_ERROR) { | 238 | if (err != MAIL_NO_ERROR) { |
252 | Global::statusMessage(tr("Error getting folder info")); | 239 | Global::statusMessage(tr("Error getting folder info")); |
253 | return 0; | 240 | return 0; |
254 | } | 241 | } |
255 | QProgressBar bar( result,0 ); | 242 | QWidget wid; |
256 | bar.setCaption (("Deleting mails - close to abort!") ); | 243 | wid.show(); |
257 | int w = 300; | 244 | for (unsigned int i = 0; i < result; ++i) { |
258 | if ( QApplication::desktop()->width() < 320 ) | 245 | Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result)); |
259 | w = 220; | 246 | wid.raise(); |
260 | int h = bar.sizeHint().height() ; | ||
261 | int dw = QApplication::desktop()->width(); | ||
262 | int dh = QApplication::desktop()->height(); | ||
263 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
264 | bar.show(); | ||
265 | int modulo = (result/10)+1; | ||
266 | int incCounter = 0; | ||
267 | for (unsigned int i = 0; i < result; ++i) { | ||
268 | if ( ! bar.isVisible() ) | ||
269 | return 0; | ||
270 | if ( incCounter % modulo == 0 ) | ||
271 | bar.setProgress( incCounter ); | ||
272 | ++incCounter; | ||
273 | qApp->processEvents(); | 247 | qApp->processEvents(); |
248 | |||
274 | err = mailsession_remove_message(m_pop3->sto_session,i+1); | 249 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
275 | if (err != MAIL_NO_ERROR) { | 250 | if (err != MAIL_NO_ERROR) { |
276 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 251 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
277 | res=0; | 252 | res=0; |
278 | } | 253 | } |
279 | break; | 254 | break; |
280 | } | 255 | } |
281 | return res; | 256 | return res; |
282 | } | 257 | } |
283 | 258 | ||
284 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 259 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
285 | login(); | 260 | login(); |
286 | target_stat.message_count = 0; | 261 | target_stat.message_count = 0; |
287 | target_stat.message_unseen = 0; | 262 | target_stat.message_unseen = 0; |
288 | target_stat.message_recent = 0; | 263 | target_stat.message_recent = 0; |
289 | if (!m_pop3) | 264 | if (!m_pop3) |
290 | return; | 265 | return; |
291 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, | 266 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, |
292 | &target_stat.message_recent,&target_stat.message_unseen); | 267 | &target_stat.message_recent,&target_stat.message_unseen); |
293 | if (r != MAIL_NO_ERROR) { | 268 | if (r != MAIL_NO_ERROR) { |
294 | ; // odebug << "error getting folter status." << oendl; | 269 | ; // odebug << "error getting folter status." << oendl; |
295 | } | 270 | } |
296 | } | 271 | } |
297 | 272 | ||