author | zautrix <zautrix> | 2004-09-10 22:24:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-10 22:24:25 (UTC) |
commit | c280882f788b31f874f928e23fc29c2aaca991eb (patch) (unidiff) | |
tree | f99de381bb9c4dc083d74a130280ae3f8230c844 /kmicromail | |
parent | 768ce5ccec90c1b062b749e7ad0464d09760b91c (diff) | |
download | kdepimpi-c280882f788b31f874f928e23fc29c2aaca991eb.zip kdepimpi-c280882f788b31f874f928e23fc29c2aaca991eb.tar.gz kdepimpi-c280882f788b31f874f928e23fc29c2aaca991eb.tar.bz2 |
imap enhancements
-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 | |||
@@ -129,314 +129,318 @@ void IMAPwrapper::login() | |||
129 | /* we are connected this moment */ | 129 | /* we are connected this moment */ |
130 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 130 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
131 | if (m_imap) { | 131 | if (m_imap) { |
132 | err = mailimap_noop(m_imap); | 132 | err = mailimap_noop(m_imap); |
133 | if (err!=MAILIMAP_NO_ERROR) { | 133 | if (err!=MAILIMAP_NO_ERROR) { |
134 | logout(); | 134 | logout(); |
135 | } else { | 135 | } else { |
136 | mailstream_flush(m_imap->imap_stream); | 136 | mailstream_flush(m_imap->imap_stream); |
137 | return; | 137 | return; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | server = account->getServer(); | 140 | server = account->getServer(); |
141 | port = account->getPort().toUInt(); | 141 | port = account->getPort().toUInt(); |
142 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 142 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
143 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 143 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
144 | login.show(); | 144 | login.show(); |
145 | if ( QDialog::Accepted == login.exec() ) { | 145 | if ( QDialog::Accepted == login.exec() ) { |
146 | // ok | 146 | // ok |
147 | user = login.getUser(); | 147 | user = login.getUser(); |
148 | pass = login.getPassword(); | 148 | pass = login.getPassword(); |
149 | } else { | 149 | } else { |
150 | // cancel | 150 | // cancel |
151 | return; | 151 | return; |
152 | } | 152 | } |
153 | } else { | 153 | } else { |
154 | user = account->getUser(); | 154 | user = account->getUser(); |
155 | pass = account->getPassword(); | 155 | pass = account->getPassword(); |
156 | } | 156 | } |
157 | 157 | ||
158 | m_imap = mailimap_new( 20, &imap_progress ); | 158 | m_imap = mailimap_new( 20, &imap_progress ); |
159 | 159 | ||
160 | /* connect */ | 160 | /* connect */ |
161 | bool ssl = false; | 161 | bool ssl = false; |
162 | bool try_tls = false; | 162 | bool try_tls = false; |
163 | bool force_tls = false; | 163 | bool force_tls = false; |
164 | 164 | ||
165 | if ( account->ConnectionType() == 2 ) { | 165 | if ( account->ConnectionType() == 2 ) { |
166 | ssl = true; | 166 | ssl = true; |
167 | } | 167 | } |
168 | if (account->ConnectionType()==1) { | 168 | if (account->ConnectionType()==1) { |
169 | force_tls = true; | 169 | force_tls = true; |
170 | } | 170 | } |
171 | 171 | ||
172 | if ( ssl ) { | 172 | if ( ssl ) { |
173 | qDebug("using ssl "); | 173 | qDebug("using ssl "); |
174 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); | 174 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); |
175 | } else { | 175 | } else { |
176 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); | 176 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); |
177 | } | 177 | } |
178 | 178 | ||
179 | if ( err != MAILIMAP_NO_ERROR && | 179 | if ( err != MAILIMAP_NO_ERROR && |
180 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 180 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
181 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 181 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
182 | QString failure = ""; | 182 | QString failure = ""; |
183 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 183 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
184 | failure="Connection refused"; | 184 | failure="Connection refused"; |
185 | } else { | 185 | } else { |
186 | failure="Unknown failure"; | 186 | failure="Unknown failure"; |
187 | } | 187 | } |
188 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); | 188 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); |
189 | mailimap_free( m_imap ); | 189 | mailimap_free( m_imap ); |
190 | m_imap = 0; | 190 | m_imap = 0; |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | 193 | ||
194 | if (!ssl) { | 194 | if (!ssl) { |
195 | try_tls = start_tls(force_tls); | 195 | try_tls = start_tls(force_tls); |
196 | } | 196 | } |
197 | 197 | ||
198 | bool ok = true; | 198 | bool ok = true; |
199 | if (force_tls && !try_tls) { | 199 | if (force_tls && !try_tls) { |
200 | Global::statusMessage(tr("Server has no TLS support!")); | 200 | Global::statusMessage(tr("Server has no TLS support!")); |
201 | ok = false; | 201 | ok = false; |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | /* login */ | 205 | /* login */ |
206 | 206 | ||
207 | if (ok) { | 207 | if (ok) { |
208 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); | 208 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); |
209 | if ( err != MAILIMAP_NO_ERROR ) { | 209 | if ( err != MAILIMAP_NO_ERROR ) { |
210 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 210 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); |
211 | ok = false; | 211 | ok = false; |
212 | } | 212 | } |
213 | } | 213 | } |
214 | if (!ok) { | 214 | if (!ok) { |
215 | err = mailimap_close( m_imap ); | 215 | err = mailimap_close( m_imap ); |
216 | mailimap_free( m_imap ); | 216 | mailimap_free( m_imap ); |
217 | m_imap = 0; | 217 | m_imap = 0; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | void IMAPwrapper::logout() | 221 | void IMAPwrapper::logout() |
222 | { | 222 | { |
223 | int err = MAILIMAP_NO_ERROR; | 223 | int err = MAILIMAP_NO_ERROR; |
224 | if (!m_imap) return; | 224 | if (!m_imap) return; |
225 | err = mailimap_logout( m_imap ); | 225 | err = mailimap_logout( m_imap ); |
226 | err = mailimap_close( m_imap ); | 226 | err = mailimap_close( m_imap ); |
227 | mailimap_free( m_imap ); | 227 | mailimap_free( m_imap ); |
228 | m_imap = 0; | 228 | m_imap = 0; |
229 | m_Lastmbox = ""; | 229 | m_Lastmbox = ""; |
230 | } | 230 | } |
231 | 231 | ||
232 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 232 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
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 | } |
339 | } | 343 | } |
340 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 344 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
341 | } | 345 | } |
342 | } else { | 346 | } else { |
343 | qDebug("error fetching folders: "); | 347 | qDebug("error fetching folders: "); |
344 | 348 | ||
345 | } | 349 | } |
346 | mailimap_list_result_free( result ); | 350 | mailimap_list_result_free( result ); |
347 | 351 | ||
348 | /* | 352 | /* |
349 | * second stage - get the other then inbox folders | 353 | * second stage - get the other then inbox folders |
350 | */ | 354 | */ |
351 | mask = "*" ; | 355 | mask = "*" ; |
352 | path = account->getPrefix().latin1(); | 356 | path = account->getPrefix().latin1(); |
353 | if (!path) path = ""; | 357 | if (!path) path = ""; |
354 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 358 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
355 | if ( err == MAILIMAP_NO_ERROR ) { | 359 | if ( err == MAILIMAP_NO_ERROR ) { |
356 | current = result->first; | 360 | current = result->first; |
357 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 361 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
358 | no_inferiors = false; | 362 | no_inferiors = false; |
359 | list = (mailimap_mailbox_list *) current->data; | 363 | list = (mailimap_mailbox_list *) current->data; |
360 | // it is better use the deep copy mechanism of qt itself | 364 | // it is better use the deep copy mechanism of qt itself |
361 | // instead of using strdup! | 365 | // instead of using strdup! |
362 | temp = list->mb_name; | 366 | temp = list->mb_name; |
363 | if (temp.lower()=="inbox") | 367 | if (temp.lower()=="inbox") |
364 | continue; | 368 | continue; |
365 | if (temp.lower()==account->getPrefix().lower()) | 369 | if (temp.lower()==account->getPrefix().lower()) |
366 | continue; | 370 | continue; |
367 | if ( (bflags = list->mb_flag) ) { | 371 | if ( (bflags = list->mb_flag) ) { |
368 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 372 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
369 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 373 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
370 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 374 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
371 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 375 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
372 | no_inferiors = true; | 376 | no_inferiors = true; |
373 | } | 377 | } |
374 | } | 378 | } |
375 | } | 379 | } |
376 | del = list->mb_delimiter; | 380 | del = list->mb_delimiter; |
377 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 381 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
378 | } | 382 | } |
379 | } else { | 383 | } else { |
380 | qDebug("error fetching folders "); | 384 | qDebug("error fetching folders "); |
381 | 385 | ||
382 | } | 386 | } |
383 | if (result) mailimap_list_result_free( result ); | 387 | if (result) mailimap_list_result_free( result ); |
384 | return folders; | 388 | return folders; |
385 | } | 389 | } |
386 | 390 | ||
387 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 391 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
388 | { | 392 | { |
389 | RecMail * m = 0; | 393 | RecMail * m = 0; |
390 | mailimap_msg_att_item *item=0; | 394 | mailimap_msg_att_item *item=0; |
391 | clistcell *current,*c,*cf; | 395 | clistcell *current,*c,*cf; |
392 | mailimap_msg_att_dynamic*flist; | 396 | mailimap_msg_att_dynamic*flist; |
393 | mailimap_flag_fetch*cflag; | 397 | mailimap_flag_fetch*cflag; |
394 | int size; | 398 | int size; |
395 | QBitArray mFlags(7); | 399 | QBitArray mFlags(7); |
396 | QStringList addresslist; | 400 | QStringList addresslist; |
397 | 401 | ||
398 | if (!m_att) { | 402 | if (!m_att) { |
399 | return m; | 403 | return m; |
400 | } | 404 | } |
401 | m = new RecMail(); | 405 | m = new RecMail(); |
402 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 406 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
403 | current = c; | 407 | current = c; |
404 | size = 0; | 408 | size = 0; |
405 | item = (mailimap_msg_att_item*)current->data; | 409 | item = (mailimap_msg_att_item*)current->data; |
406 | if ( !item ) | 410 | if ( !item ) |
407 | continue; | 411 | continue; |
408 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 412 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
409 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 413 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
410 | if (!flist || !flist->att_list) { | 414 | if (!flist || !flist->att_list) { |
411 | continue; | 415 | continue; |
412 | } | 416 | } |
413 | cf = flist->att_list->first; | 417 | cf = flist->att_list->first; |
414 | if( ! cf ) | 418 | if( ! cf ) |
415 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 419 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
416 | cflag = (mailimap_flag_fetch*)cf->data; | 420 | cflag = (mailimap_flag_fetch*)cf->data; |
417 | if( ! cflag ) | 421 | if( ! cflag ) |
418 | qDebug("imap:not cflag "); | 422 | qDebug("imap:not cflag "); |
419 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 423 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
420 | switch (cflag->fl_flag->fl_type) { | 424 | switch (cflag->fl_flag->fl_type) { |
421 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 425 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
422 | mFlags.setBit(FLAG_ANSWERED); | 426 | mFlags.setBit(FLAG_ANSWERED); |
423 | break; | 427 | break; |
424 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 428 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
425 | mFlags.setBit(FLAG_FLAGGED); | 429 | mFlags.setBit(FLAG_FLAGGED); |
426 | break; | 430 | break; |
427 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 431 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
428 | mFlags.setBit(FLAG_DELETED); | 432 | mFlags.setBit(FLAG_DELETED); |
429 | break; | 433 | break; |
430 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 434 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
431 | mFlags.setBit(FLAG_SEEN); | 435 | mFlags.setBit(FLAG_SEEN); |
432 | break; | 436 | break; |
433 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 437 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
434 | mFlags.setBit(FLAG_DRAFT); | 438 | mFlags.setBit(FLAG_DRAFT); |
435 | break; | 439 | break; |
436 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 440 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
437 | break; | 441 | break; |
438 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 442 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
439 | break; | 443 | break; |
440 | default: | 444 | default: |
441 | break; | 445 | break; |
442 | } | 446 | } |