-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index ca1c7f1..6faa524 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -233,106 +233,110 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma | |||
233 | { | 233 | { |
234 | int err = MAILIMAP_NO_ERROR; | 234 | int err = MAILIMAP_NO_ERROR; |
235 | clist *result = 0; | 235 | clist *result = 0; |
236 | clistcell *current; | 236 | clistcell *current; |
237 | mailimap_fetch_type *fetchType = 0; | 237 | mailimap_fetch_type *fetchType = 0; |
238 | mailimap_set *set = 0; | 238 | mailimap_set *set = 0; |
239 | 239 | ||
240 | login(); | 240 | login(); |
241 | if (!m_imap) { | 241 | if (!m_imap) { |
242 | return; | 242 | return; |
243 | } | 243 | } |
244 | /* select mailbox READONLY for operations */ | 244 | /* select mailbox READONLY for operations */ |
245 | err = selectMbox(mailbox); | 245 | err = selectMbox(mailbox); |
246 | if ( err != MAILIMAP_NO_ERROR ) { | 246 | if ( err != MAILIMAP_NO_ERROR ) { |
247 | return; | 247 | return; |
248 | } | 248 | } |
249 | 249 | ||
250 | int last = m_imap->imap_selection_info->sel_exists; | 250 | int last = m_imap->imap_selection_info->sel_exists; |
251 | 251 | ||
252 | if (last == 0) { | 252 | if (last == 0) { |
253 | Global::statusMessage(tr("Mailbox has no mails")); | 253 | Global::statusMessage(tr("Mailbox has no mails")); |
254 | return; | 254 | return; |
255 | } else { | 255 | } else { |
256 | } | 256 | } |
257 | 257 | ||
258 | Global::statusMessage(tr("Fetching header list")); | ||
259 | qApp->processEvents(); | ||
258 | /* the range has to start at 1!!! not with 0!!!! */ | 260 | /* the range has to start at 1!!! not with 0!!!! */ |
259 | set = mailimap_set_new_interval( 1, last ); | 261 | set = mailimap_set_new_interval( 1, last ); |
260 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 262 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
261 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 263 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
262 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 264 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
263 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 265 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
264 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 266 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
265 | 267 | ||
266 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 268 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
267 | mailimap_set_free( set ); | 269 | mailimap_set_free( set ); |
268 | mailimap_fetch_type_free( fetchType ); | 270 | mailimap_fetch_type_free( fetchType ); |
269 | 271 | ||
270 | QString date,subject,from; | 272 | QString date,subject,from; |
271 | 273 | ||
272 | if ( err == MAILIMAP_NO_ERROR ) { | 274 | if ( err == MAILIMAP_NO_ERROR ) { |
273 | mailimap_msg_att * msg_att; | 275 | mailimap_msg_att * msg_att; |
274 | int i = 0; | 276 | int i = 0; |
275 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 277 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
276 | ++i; | 278 | ++i; |
277 | msg_att = (mailimap_msg_att*)current->data; | 279 | msg_att = (mailimap_msg_att*)current->data; |
278 | RecMail*m = parse_list_result(msg_att); | 280 | RecMail*m = parse_list_result(msg_att); |
279 | if (m) { | 281 | if (m) { |
280 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { | 282 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { |
281 | m->setNumber(i); | 283 | m->setNumber(i); |
282 | m->setMbox(mailbox); | 284 | m->setMbox(mailbox); |
283 | m->setWrapper(this); | 285 | m->setWrapper(this); |
284 | target.append(m); | 286 | target.append(m); |
285 | } | 287 | } |
286 | } | 288 | } |
287 | } | 289 | } |
288 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); | 290 | Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); |
289 | } else { | 291 | } else { |
290 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); | 292 | Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); |
291 | } | 293 | } |
292 | if (result) mailimap_fetch_list_free(result); | 294 | if (result) mailimap_fetch_list_free(result); |
293 | } | 295 | } |
294 | 296 | ||
295 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 297 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
296 | { | 298 | { |
297 | const char *path, *mask; | 299 | const char *path, *mask; |
298 | int err = MAILIMAP_NO_ERROR; | 300 | int err = MAILIMAP_NO_ERROR; |
299 | clist *result = 0; | 301 | clist *result = 0; |
300 | clistcell *current = 0; | 302 | clistcell *current = 0; |
301 | clistcell*cur_flag = 0; | 303 | clistcell*cur_flag = 0; |
302 | mailimap_mbx_list_flags*bflags = 0; | 304 | mailimap_mbx_list_flags*bflags = 0; |
303 | 305 | ||
304 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 306 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
305 | login(); | 307 | login(); |
306 | if (!m_imap) { | 308 | if (!m_imap) { |
307 | return folders; | 309 | return folders; |
308 | } | 310 | } |
309 | 311 | ||
310 | /* | 312 | /* |
311 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 313 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
312 | * We must not forget to filter them out in next loop! | 314 | * We must not forget to filter them out in next loop! |
313 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 315 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
314 | */ | 316 | */ |
317 | Global::statusMessage(tr("Fetching folder list")); | ||
318 | qApp->processEvents(); | ||
315 | QString temp; | 319 | QString temp; |
316 | mask = "INBOX" ; | 320 | mask = "INBOX" ; |
317 | mailimap_mailbox_list *list; | 321 | mailimap_mailbox_list *list; |
318 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 322 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
319 | QString del; | 323 | QString del; |
320 | bool selectable = true; | 324 | bool selectable = true; |
321 | bool no_inferiors = false; | 325 | bool no_inferiors = false; |
322 | if ( err == MAILIMAP_NO_ERROR ) { | 326 | if ( err == MAILIMAP_NO_ERROR ) { |
323 | current = result->first; | 327 | current = result->first; |
324 | for ( int i = result->count; i > 0; i-- ) { | 328 | for ( int i = result->count; i > 0; i-- ) { |
325 | list = (mailimap_mailbox_list *) current->data; | 329 | list = (mailimap_mailbox_list *) current->data; |
326 | // it is better use the deep copy mechanism of qt itself | 330 | // it is better use the deep copy mechanism of qt itself |
327 | // instead of using strdup! | 331 | // instead of using strdup! |
328 | temp = list->mb_name; | 332 | temp = list->mb_name; |
329 | del = list->mb_delimiter; | 333 | del = list->mb_delimiter; |
330 | current = current->next; | 334 | current = current->next; |
331 | if ( (bflags = list->mb_flag) ) { | 335 | if ( (bflags = list->mb_flag) ) { |
332 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 336 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
333 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 337 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
334 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 338 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
335 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 339 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
336 | no_inferiors = true; | 340 | no_inferiors = true; |
337 | } | 341 | } |
338 | } | 342 | } |