author | zautrix <zautrix> | 2004-09-11 18:10:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-11 18:10:31 (UTC) |
commit | 53dda80aaab72d7efdbed8a206dc1fa64fed10ee (patch) (unidiff) | |
tree | 23b5248145679628c0d346f7d42c53714634e1a3 /kmicromail/libmailwrapper/pop3wrapper.cpp | |
parent | 438403295657bdcab9ee9e526c6a08894e876f63 (diff) | |
download | kdepimpi-53dda80aaab72d7efdbed8a206dc1fa64fed10ee.zip kdepimpi-53dda80aaab72d7efdbed8a206dc1fa64fed10ee.tar.gz kdepimpi-53dda80aaab72d7efdbed8a206dc1fa64fed10ee.tar.bz2 |
progress fixes
Diffstat (limited to 'kmicromail/libmailwrapper/pop3wrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/pop3wrapper.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp index 1edec9e..9d52f52 100644 --- a/kmicromail/libmailwrapper/pop3wrapper.cpp +++ b/kmicromail/libmailwrapper/pop3wrapper.cpp | |||
@@ -155,139 +155,147 @@ void POP3wrapper::login() | |||
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 %1 initializing folder").arg( err )); | 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 | QWidget wid; | 203 | |
204 | QProgressBar wid ( count ); | ||
205 | wid.setCaption( tr("Deleting ...")); | ||
204 | wid.show(); | 206 | wid.show(); |
205 | while (iii < count ) { | 207 | while (iii < count ) { |
206 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); | 208 | Global::statusMessage(tr("Delete message %1 of %2").arg(iii).arg(count)); |
209 | wid.setProgress( iii ); | ||
207 | wid.raise(); | 210 | wid.raise(); |
208 | qApp->processEvents(); | 211 | qApp->processEvents(); |
209 | //qDebug("delete "); | 212 | //qDebug("delete "); |
210 | RecMailP mail = (*target.at( iii )); | 213 | RecMailP mail = (*target.at( iii )); |
211 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 214 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
212 | if (err != MAIL_NO_ERROR) { | 215 | if (err != MAIL_NO_ERROR) { |
213 | Global::statusMessage(tr("Error deleting mail")); | 216 | Global::statusMessage(tr("Error deleting mail")); |
214 | } | 217 | } |
215 | ++iii; | 218 | ++iii; |
216 | } | 219 | } |
217 | } | 220 | } |
218 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 221 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
219 | login(); | 222 | login(); |
220 | if (!m_pop3) | 223 | if (!m_pop3) |
221 | return; | 224 | return; |
222 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 225 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
223 | if (err != MAIL_NO_ERROR) { | 226 | if (err != MAIL_NO_ERROR) { |
224 | Global::statusMessage(tr("error deleting mail")); | 227 | Global::statusMessage(tr("error deleting mail")); |
225 | } | 228 | } |
226 | } | 229 | } |
227 | 230 | ||
228 | void POP3wrapper::answeredMail(const RecMailP&) {} | 231 | void POP3wrapper::answeredMail(const RecMailP&) {} |
229 | 232 | ||
230 | int POP3wrapper::deleteAllMail(const FolderP&) { | 233 | int POP3wrapper::deleteAllMail(const FolderP&) { |
231 | login(); | 234 | login(); |
232 | if (!m_pop3) | 235 | if (!m_pop3) |
233 | return 0; | 236 | return 0; |
234 | int res = 1; | 237 | int res = 1; |
235 | 238 | ||
236 | uint32_t result = 0; | 239 | uint32_t result = 0; |
237 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 240 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
238 | if (err != MAIL_NO_ERROR) { | 241 | if (err != MAIL_NO_ERROR) { |
239 | Global::statusMessage(tr("Error getting folder info")); | 242 | Global::statusMessage(tr("Error getting folder info")); |
240 | return 0; | 243 | return 0; |
241 | } | 244 | } |
242 | QWidget wid; | 245 | |
246 | |||
247 | |||
248 | QProgressBar wid ( result ); | ||
249 | wid.setCaption( tr("Deleting ...")); | ||
243 | wid.show(); | 250 | wid.show(); |
244 | for (unsigned int i = 0; i < result; ++i) { | 251 | for (unsigned int i = 0; i < result; ++i) { |
245 | Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result)); | 252 | Global::statusMessage(tr("Delete message %1 of %2").arg(i).arg(result)); |
253 | wid.setProgress( i ); | ||
246 | wid.raise(); | 254 | wid.raise(); |
247 | qApp->processEvents(); | 255 | qApp->processEvents(); |
248 | 256 | ||
249 | err = mailsession_remove_message(m_pop3->sto_session,i+1); | 257 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
250 | if (err != MAIL_NO_ERROR) { | 258 | if (err != MAIL_NO_ERROR) { |
251 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 259 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
252 | res=0; | 260 | res=0; |
253 | } | 261 | } |
254 | break; | 262 | break; |
255 | } | 263 | } |
256 | return res; | 264 | return res; |
257 | } | 265 | } |
258 | 266 | ||
259 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 267 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
260 | login(); | 268 | login(); |
261 | target_stat.message_count = 0; | 269 | target_stat.message_count = 0; |
262 | target_stat.message_unseen = 0; | 270 | target_stat.message_unseen = 0; |
263 | target_stat.message_recent = 0; | 271 | target_stat.message_recent = 0; |
264 | if (!m_pop3) | 272 | if (!m_pop3) |
265 | return; | 273 | return; |
266 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, | 274 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, |
267 | &target_stat.message_recent,&target_stat.message_unseen); | 275 | &target_stat.message_recent,&target_stat.message_unseen); |
268 | if (r != MAIL_NO_ERROR) { | 276 | if (r != MAIL_NO_ERROR) { |
269 | ; // odebug << "error getting folter status." << oendl; | 277 | ; // odebug << "error getting folter status." << oendl; |
270 | } | 278 | } |
271 | } | 279 | } |
272 | 280 | ||
273 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { | 281 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { |
274 | char*target=0; | 282 | char*target=0; |
275 | size_t length=0; | 283 | size_t length=0; |
276 | encodedString*res = 0; | 284 | encodedString*res = 0; |
277 | mailmessage * mailmsg = 0; | 285 | mailmessage * mailmsg = 0; |
278 | int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); | 286 | int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
279 | err = mailmessage_fetch(mailmsg,&target,&length); | 287 | err = mailmessage_fetch(mailmsg,&target,&length); |
280 | if (mailmsg) | 288 | if (mailmsg) |
281 | mailmessage_free(mailmsg); | 289 | mailmessage_free(mailmsg); |
282 | if (target) { | 290 | if (target) { |
283 | res = new encodedString(target,length); | 291 | res = new encodedString(target,length); |
284 | } | 292 | } |
285 | return res; | 293 | return res; |
286 | } | 294 | } |
287 | 295 | ||
288 | MAILLIB::ATYPE POP3wrapper::getType()const { | 296 | MAILLIB::ATYPE POP3wrapper::getType()const { |
289 | return account->getType(); | 297 | return account->getType(); |
290 | } | 298 | } |
291 | 299 | ||
292 | const QString&POP3wrapper::getName()const{ | 300 | const QString&POP3wrapper::getName()const{ |
293 | return account->getAccountName(); | 301 | return account->getAccountName(); |