author | alwin <alwin> | 2003-12-10 21:35:16 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-10 21:35:16 (UTC) |
commit | c80a4d0e0b0ed83757d8494e7f32c8b4b0b6e8d0 (patch) (unidiff) | |
tree | 386ef672e71f46763031df60a83a807b7d325e96 /noncore/net/mail | |
parent | 6dffa571b5bfdd3e353fdabb555a805c2999ef0f (diff) | |
download | opie-c80a4d0e0b0ed83757d8494e7f32c8b4b0b6e8d0.zip opie-c80a4d0e0b0ed83757d8494e7f32c8b4b0b6e8d0.tar.gz opie-c80a4d0e0b0ed83757d8494e7f32c8b4b0b6e8d0.tar.bz2 |
change to work with libetpan 0.3.1
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 144 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 144 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 1 |
4 files changed, 156 insertions, 134 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index dc02780..e6e9fc9 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -46,5 +46,5 @@ void IMAPwrapper::login() | |||
46 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 46 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
47 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 47 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
48 | qDebug("error connecting server: %s",m_imap->response); | 48 | qDebug("error connecting server: %s",m_imap->imap_response); |
49 | mailimap_free( m_imap ); | 49 | mailimap_free( m_imap ); |
50 | m_imap = 0; | 50 | m_imap = 0; |
@@ -55,5 +55,5 @@ void IMAPwrapper::login() | |||
55 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 55 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
56 | if ( err != MAILIMAP_NO_ERROR ) { | 56 | if ( err != MAILIMAP_NO_ERROR ) { |
57 | qDebug("error logging in imap: %s",m_imap->response); | 57 | qDebug("error logging in imap: %s",m_imap->imap_response); |
58 | err = mailimap_close( m_imap ); | 58 | err = mailimap_close( m_imap ); |
59 | mailimap_free( m_imap ); | 59 | mailimap_free( m_imap ); |
@@ -90,10 +90,10 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
90 | err = mailimap_examine( m_imap, (char*)mb); | 90 | err = mailimap_examine( m_imap, (char*)mb); |
91 | if ( err != MAILIMAP_NO_ERROR ) { | 91 | if ( err != MAILIMAP_NO_ERROR ) { |
92 | qDebug("error selecting mailbox: %s",m_imap->response); | 92 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
93 | logout(); | 93 | logout(); |
94 | return; | 94 | return; |
95 | } | 95 | } |
96 | 96 | ||
97 | int last = m_imap->selection_info->exists; | 97 | int last = m_imap->imap_selection_info->sel_exists; |
98 | 98 | ||
99 | if (last == 0) { | 99 | if (last == 0) { |
@@ -139,5 +139,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
139 | } | 139 | } |
140 | } else { | 140 | } else { |
141 | qDebug("Error fetching headers: %s",m_imap->response); | 141 | qDebug("Error fetching headers: %s",m_imap->imap_response); |
142 | } | 142 | } |
143 | logout(); | 143 | logout(); |
@@ -175,10 +175,10 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
175 | // it is better use the deep copy mechanism of qt itself | 175 | // it is better use the deep copy mechanism of qt itself |
176 | // instead of using strdup! | 176 | // instead of using strdup! |
177 | temp = list->mb; | 177 | temp = list->mb_name; |
178 | folders->append( new IMAPFolder(temp)); | 178 | folders->append( new IMAPFolder(temp)); |
179 | current = current->next; | 179 | current = current->next; |
180 | } | 180 | } |
181 | } else { | 181 | } else { |
182 | qDebug("error fetching folders: %s",m_imap->response); | 182 | qDebug("error fetching folders: %s",m_imap->imap_response); |
183 | } | 183 | } |
184 | mailimap_list_result_free( result ); | 184 | mailimap_list_result_free( result ); |
@@ -189,4 +189,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
189 | mask = "*" ; | 189 | mask = "*" ; |
190 | path = account->getPrefix().latin1(); | 190 | path = account->getPrefix().latin1(); |
191 | if (!path) path = ""; | ||
191 | result = clist_new(); | 192 | result = clist_new(); |
192 | qDebug(path); | 193 | qDebug(path); |
@@ -198,5 +199,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
198 | // it is better use the deep copy mechanism of qt itself | 199 | // it is better use the deep copy mechanism of qt itself |
199 | // instead of using strdup! | 200 | // instead of using strdup! |
200 | temp = list->mb; | 201 | temp = list->mb_name; |
201 | current = current->next; | 202 | current = current->next; |
202 | if (temp.lower()=="inbox") | 203 | if (temp.lower()=="inbox") |
@@ -206,5 +207,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
206 | } | 207 | } |
207 | } else { | 208 | } else { |
208 | qDebug("error fetching folders %s",m_imap->response); | 209 | qDebug("error fetching folders %s",m_imap->imap_response); |
209 | } | 210 | } |
210 | mailimap_list_result_free( result ); | 211 | mailimap_list_result_free( result ); |
@@ -226,19 +227,19 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
226 | } | 227 | } |
227 | 228 | ||
228 | c = clist_begin(m_att->list); | 229 | c = clist_begin(m_att->att_list); |
229 | while ( c ) { | 230 | while ( c ) { |
230 | current = c; | 231 | current = c; |
231 | c = c->next; | 232 | c = c->next; |
232 | item = (mailimap_msg_att_item*)current->data; | 233 | item = (mailimap_msg_att_item*)current->data; |
233 | if (item->type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 234 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
234 | flist = (mailimap_msg_att_dynamic*)item->msg_att_dyn; | 235 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
235 | if (!flist->list) { | 236 | if (!flist->att_list) { |
236 | continue; | 237 | continue; |
237 | } | 238 | } |
238 | cf = flist->list->first; | 239 | cf = flist->att_list->first; |
239 | while (cf) { | 240 | while (cf) { |
240 | cflag = (mailimap_flag_fetch*)cf->data; | 241 | cflag = (mailimap_flag_fetch*)cf->data; |
241 | if (cflag->type==MAILIMAP_FLAG_FETCH_OTHER && cflag->flag!=0) { | 242 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
242 | switch (cflag->flag->type) { | 243 | switch (cflag->fl_flag->fl_type) { |
243 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 244 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
244 | mFlags.setBit(FLAG_ANSWERED); | 245 | mFlags.setBit(FLAG_ANSWERED); |
@@ -263,5 +264,5 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
263 | break; | 264 | break; |
264 | } | 265 | } |
265 | } else if (cflag->type==MAILIMAP_FLAG_FETCH_RECENT) { | 266 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
266 | mFlags.setBit(FLAG_RECENT); | 267 | mFlags.setBit(FLAG_RECENT); |
267 | } | 268 | } |
@@ -270,43 +271,40 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
270 | continue; | 271 | continue; |
271 | } | 272 | } |
272 | if ( item->msg_att_static->type == MAILIMAP_MSG_ATT_RFC822_HEADER ) { | 273 | if ( item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_RFC822_HEADER ) { |
273 | qDebug( "header: \n%s", item->msg_att_static->rfc822_header ); | 274 | qDebug( "header: \n%s", item->att_data.att_static->att_data.att_rfc822_header ); |
274 | } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_ENVELOPE) { | 275 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
275 | mailimap_envelope * head = item->msg_att_static->env; | 276 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
276 | m = new RecMail(); | 277 | m = new RecMail(); |
277 | m->setDate(head->date); | 278 | m->setDate(head->env_date); |
278 | m->setSubject(head->subject); | 279 | m->setSubject(head->env_subject); |
279 | if (head->from!=NULL) { | 280 | if (head->env_from!=NULL) { |
280 | addresslist = address_list_to_stringlist(head->from->list); | 281 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
281 | if (addresslist.count()) { | 282 | if (addresslist.count()) { |
282 | m->setFrom(addresslist.first()); | 283 | m->setFrom(addresslist.first()); |
283 | } | 284 | } |
284 | } | 285 | } |
285 | if (head->to!=NULL) { | 286 | if (head->env_to!=NULL) { |
286 | addresslist = address_list_to_stringlist(head->to->list); | 287 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
287 | m->setTo(addresslist); | 288 | m->setTo(addresslist); |
288 | } | 289 | } |
289 | if (head->cc!=NULL) { | 290 | if (head->env_cc!=NULL) { |
290 | addresslist = address_list_to_stringlist(head->cc->list); | 291 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
291 | m->setCC(addresslist); | 292 | m->setCC(addresslist); |
292 | } | 293 | } |
293 | if (head->bcc!=NULL) { | 294 | if (head->env_bcc!=NULL) { |
294 | addresslist = address_list_to_stringlist(head->bcc->list); | 295 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
295 | m->setBcc(addresslist); | 296 | m->setBcc(addresslist); |
296 | } | 297 | } |
297 | if (head->reply_to!=NULL) { | 298 | if (head->env_reply_to!=NULL) { |
298 | addresslist = address_list_to_stringlist(head->bcc->list); | 299 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
299 | if (addresslist.count()) { | 300 | if (addresslist.count()) { |
300 | m->setReplyto(addresslist.first()); | 301 | m->setReplyto(addresslist.first()); |
301 | } | 302 | } |
302 | } | 303 | } |
303 | m->setMsgid(QString(head->message_id)); | 304 | m->setMsgid(QString(head->env_message_id)); |
304 | qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s\nMsgid: %s", | 305 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
305 | m->getFrom().latin1(), | 306 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
306 | m->getSubject().latin1(),m->getDate().latin1(),m->Msgid().latin1()); | 307 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
307 | } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 308 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
308 | mailimap_date_time*d = item->msg_att_static->internal_date; | ||
309 | QDateTime da(QDate(d->year,d->month,d->day),QTime(d->hour,d->min,d->sec)); | ||
310 | qDebug("%i %i %i - %i %i %i",d->year,d->month,d->day,d->hour,d->min,d->sec); | ||
311 | qDebug(da.toString()); | 309 | qDebug(da.toString()); |
312 | } else { | 310 | } else { |
@@ -346,5 +344,5 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
346 | err = mailimap_examine( m_imap, (char*)mb); | 344 | err = mailimap_examine( m_imap, (char*)mb); |
347 | if ( err != MAILIMAP_NO_ERROR ) { | 345 | if ( err != MAILIMAP_NO_ERROR ) { |
348 | qDebug("error selecting mailbox: %s",m_imap->response); | 346 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
349 | logout(); | 347 | logout(); |
350 | return body; | 348 | return body; |
@@ -362,13 +360,13 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
362 | mailimap_msg_att * msg_att; | 360 | mailimap_msg_att * msg_att; |
363 | msg_att = (mailimap_msg_att*)current->data; | 361 | msg_att = (mailimap_msg_att*)current->data; |
364 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | 362 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
365 | body_desc = item->msg_att_static->body; | 363 | body_desc = item->att_data.att_static->att_data.att_body; |
366 | if (body_desc->type==MAILIMAP_BODY_1PART) { | 364 | if (body_desc->bd_type==MAILIMAP_BODY_1PART) { |
367 | searchBodyText(mail,body_desc->body_1part,body); | 365 | searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); |
368 | } else { | 366 | } else { |
369 | } | 367 | } |
370 | 368 | ||
371 | } else { | 369 | } else { |
372 | qDebug("error fetching body: %s",m_imap->response); | 370 | qDebug("error fetching body: %s",m_imap->imap_response); |
373 | } | 371 | } |
374 | 372 | ||
@@ -383,7 +381,7 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
383 | return; | 381 | return; |
384 | } | 382 | } |
385 | switch (mailDescription->type) { | 383 | switch (mailDescription->bd_type) { |
386 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 384 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
387 | fillPlainBody(mail,target_body,mailDescription->body_type_text); | 385 | fillPlainBody(mail,target_body,mailDescription->bd_data.bd_type_text); |
388 | break; | 386 | break; |
389 | default: | 387 | default: |
@@ -393,5 +391,5 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
393 | } | 391 | } |
394 | 392 | ||
395 | void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * text_body) | 393 | void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * bd) |
396 | { | 394 | { |
397 | const char *mb; | 395 | const char *mb; |
@@ -399,5 +397,5 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap | |||
399 | int err = MAILIMAP_NO_ERROR; | 397 | int err = MAILIMAP_NO_ERROR; |
400 | clist *result; | 398 | clist *result; |
401 | clistcell *current; | 399 | clistcell *current,*cur; |
402 | mailimap_fetch_att *fetchAtt; | 400 | mailimap_fetch_att *fetchAtt; |
403 | mailimap_fetch_type *fetchType; | 401 | mailimap_fetch_type *fetchType; |
@@ -411,7 +409,7 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap | |||
411 | 409 | ||
412 | result = clist_new(); | 410 | result = clist_new(); |
413 | /* the range has to start at 1!!! not with 0!!!! */ | 411 | set = set = mailimap_set_new_single(mail.getNumber()); |
414 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 412 | mailimap_section * section = mailimap_section_new_text(); |
415 | fetchAtt = mailimap_fetch_att_new_rfc822_text(); | 413 | fetchAtt = mailimap_fetch_att_new_body_peek_section(section); |
416 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 414 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
417 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 415 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
@@ -419,15 +417,27 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap | |||
419 | mailimap_fetch_type_free( fetchType ); | 417 | mailimap_fetch_type_free( fetchType ); |
420 | 418 | ||
419 | |||
421 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 420 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
422 | mailimap_msg_att * msg_att; | 421 | mailimap_msg_att * msg_att; |
423 | msg_att = (mailimap_msg_att*)current->data; | 422 | msg_att = (mailimap_msg_att*)current->data; |
424 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | 423 | mailimap_msg_att_item*msg_att_item; |
425 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { | 424 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
426 | body = item->msg_att_static->rfc822_text; | 425 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
426 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | ||
427 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | ||
428 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | ||
429 | int length = msg_att_item->att_data.att_static->att_data.att_body_section->sec_length; | ||
430 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | ||
431 | body = QString(text); | ||
432 | free(text); | ||
433 | } | ||
434 | } | ||
427 | } | 435 | } |
436 | |||
428 | } else { | 437 | } else { |
429 | qDebug("error fetching text: %s",m_imap->response); | 438 | qDebug("error fetching text: %s",m_imap->imap_response); |
430 | } | 439 | } |
431 | clist_free(result); | 440 | //clist_free(result); |
441 | mailimap_fetch_list_free(result); | ||
432 | target_body.setBodytext(body); | 442 | target_body.setBodytext(body); |
433 | return; | 443 | return; |
@@ -451,20 +461,20 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
451 | current_address=(mailimap_address*)current->data; | 461 | current_address=(mailimap_address*)current->data; |
452 | current = current->next; | 462 | current = current->next; |
453 | if (current_address->personal_name){ | 463 | if (current_address->ad_personal_name){ |
454 | from+=QString(current_address->personal_name); | 464 | from+=QString(current_address->ad_personal_name); |
455 | from+=" "; | 465 | from+=" "; |
456 | named_from = true; | 466 | named_from = true; |
457 | } | 467 | } |
458 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | 468 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
459 | from+="<"; | 469 | from+="<"; |
460 | } | 470 | } |
461 | if (current_address->mailbox_name) { | 471 | if (current_address->ad_mailbox_name) { |
462 | from+=QString(current_address->mailbox_name); | 472 | from+=QString(current_address->ad_mailbox_name); |
463 | from+="@"; | 473 | from+="@"; |
464 | } | 474 | } |
465 | if (current_address->host_name) { | 475 | if (current_address->ad_host_name) { |
466 | from+=QString(current_address->host_name); | 476 | from+=QString(current_address->ad_host_name); |
467 | } | 477 | } |
468 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | 478 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
469 | from+=">"; | 479 | from+=">"; |
470 | } | 480 | } |
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h index faab43c..90f3004 100644 --- a/noncore/net/mail/imapwrapper.h +++ b/noncore/net/mail/imapwrapper.h | |||
@@ -8,4 +8,5 @@ struct mailimap; | |||
8 | struct mailimap_body_type_1part; | 8 | struct mailimap_body_type_1part; |
9 | struct mailimap_body_type_text; | 9 | struct mailimap_body_type_text; |
10 | struct mailimap_msg_att; | ||
10 | class RecMail; | 11 | class RecMail; |
11 | class RecBody; | 12 | class RecBody; |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index dc02780..e6e9fc9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -46,5 +46,5 @@ void IMAPwrapper::login() | |||
46 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 46 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
47 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 47 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
48 | qDebug("error connecting server: %s",m_imap->response); | 48 | qDebug("error connecting server: %s",m_imap->imap_response); |
49 | mailimap_free( m_imap ); | 49 | mailimap_free( m_imap ); |
50 | m_imap = 0; | 50 | m_imap = 0; |
@@ -55,5 +55,5 @@ void IMAPwrapper::login() | |||
55 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 55 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
56 | if ( err != MAILIMAP_NO_ERROR ) { | 56 | if ( err != MAILIMAP_NO_ERROR ) { |
57 | qDebug("error logging in imap: %s",m_imap->response); | 57 | qDebug("error logging in imap: %s",m_imap->imap_response); |
58 | err = mailimap_close( m_imap ); | 58 | err = mailimap_close( m_imap ); |
59 | mailimap_free( m_imap ); | 59 | mailimap_free( m_imap ); |
@@ -90,10 +90,10 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
90 | err = mailimap_examine( m_imap, (char*)mb); | 90 | err = mailimap_examine( m_imap, (char*)mb); |
91 | if ( err != MAILIMAP_NO_ERROR ) { | 91 | if ( err != MAILIMAP_NO_ERROR ) { |
92 | qDebug("error selecting mailbox: %s",m_imap->response); | 92 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
93 | logout(); | 93 | logout(); |
94 | return; | 94 | return; |
95 | } | 95 | } |
96 | 96 | ||
97 | int last = m_imap->selection_info->exists; | 97 | int last = m_imap->imap_selection_info->sel_exists; |
98 | 98 | ||
99 | if (last == 0) { | 99 | if (last == 0) { |
@@ -139,5 +139,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
139 | } | 139 | } |
140 | } else { | 140 | } else { |
141 | qDebug("Error fetching headers: %s",m_imap->response); | 141 | qDebug("Error fetching headers: %s",m_imap->imap_response); |
142 | } | 142 | } |
143 | logout(); | 143 | logout(); |
@@ -175,10 +175,10 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
175 | // it is better use the deep copy mechanism of qt itself | 175 | // it is better use the deep copy mechanism of qt itself |
176 | // instead of using strdup! | 176 | // instead of using strdup! |
177 | temp = list->mb; | 177 | temp = list->mb_name; |
178 | folders->append( new IMAPFolder(temp)); | 178 | folders->append( new IMAPFolder(temp)); |
179 | current = current->next; | 179 | current = current->next; |
180 | } | 180 | } |
181 | } else { | 181 | } else { |
182 | qDebug("error fetching folders: %s",m_imap->response); | 182 | qDebug("error fetching folders: %s",m_imap->imap_response); |
183 | } | 183 | } |
184 | mailimap_list_result_free( result ); | 184 | mailimap_list_result_free( result ); |
@@ -189,4 +189,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
189 | mask = "*" ; | 189 | mask = "*" ; |
190 | path = account->getPrefix().latin1(); | 190 | path = account->getPrefix().latin1(); |
191 | if (!path) path = ""; | ||
191 | result = clist_new(); | 192 | result = clist_new(); |
192 | qDebug(path); | 193 | qDebug(path); |
@@ -198,5 +199,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
198 | // it is better use the deep copy mechanism of qt itself | 199 | // it is better use the deep copy mechanism of qt itself |
199 | // instead of using strdup! | 200 | // instead of using strdup! |
200 | temp = list->mb; | 201 | temp = list->mb_name; |
201 | current = current->next; | 202 | current = current->next; |
202 | if (temp.lower()=="inbox") | 203 | if (temp.lower()=="inbox") |
@@ -206,5 +207,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
206 | } | 207 | } |
207 | } else { | 208 | } else { |
208 | qDebug("error fetching folders %s",m_imap->response); | 209 | qDebug("error fetching folders %s",m_imap->imap_response); |
209 | } | 210 | } |
210 | mailimap_list_result_free( result ); | 211 | mailimap_list_result_free( result ); |
@@ -226,19 +227,19 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
226 | } | 227 | } |
227 | 228 | ||
228 | c = clist_begin(m_att->list); | 229 | c = clist_begin(m_att->att_list); |
229 | while ( c ) { | 230 | while ( c ) { |
230 | current = c; | 231 | current = c; |
231 | c = c->next; | 232 | c = c->next; |
232 | item = (mailimap_msg_att_item*)current->data; | 233 | item = (mailimap_msg_att_item*)current->data; |
233 | if (item->type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 234 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
234 | flist = (mailimap_msg_att_dynamic*)item->msg_att_dyn; | 235 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
235 | if (!flist->list) { | 236 | if (!flist->att_list) { |
236 | continue; | 237 | continue; |
237 | } | 238 | } |
238 | cf = flist->list->first; | 239 | cf = flist->att_list->first; |
239 | while (cf) { | 240 | while (cf) { |
240 | cflag = (mailimap_flag_fetch*)cf->data; | 241 | cflag = (mailimap_flag_fetch*)cf->data; |
241 | if (cflag->type==MAILIMAP_FLAG_FETCH_OTHER && cflag->flag!=0) { | 242 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
242 | switch (cflag->flag->type) { | 243 | switch (cflag->fl_flag->fl_type) { |
243 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 244 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
244 | mFlags.setBit(FLAG_ANSWERED); | 245 | mFlags.setBit(FLAG_ANSWERED); |
@@ -263,5 +264,5 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
263 | break; | 264 | break; |
264 | } | 265 | } |
265 | } else if (cflag->type==MAILIMAP_FLAG_FETCH_RECENT) { | 266 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
266 | mFlags.setBit(FLAG_RECENT); | 267 | mFlags.setBit(FLAG_RECENT); |
267 | } | 268 | } |
@@ -270,43 +271,40 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
270 | continue; | 271 | continue; |
271 | } | 272 | } |
272 | if ( item->msg_att_static->type == MAILIMAP_MSG_ATT_RFC822_HEADER ) { | 273 | if ( item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_RFC822_HEADER ) { |
273 | qDebug( "header: \n%s", item->msg_att_static->rfc822_header ); | 274 | qDebug( "header: \n%s", item->att_data.att_static->att_data.att_rfc822_header ); |
274 | } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_ENVELOPE) { | 275 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
275 | mailimap_envelope * head = item->msg_att_static->env; | 276 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
276 | m = new RecMail(); | 277 | m = new RecMail(); |
277 | m->setDate(head->date); | 278 | m->setDate(head->env_date); |
278 | m->setSubject(head->subject); | 279 | m->setSubject(head->env_subject); |
279 | if (head->from!=NULL) { | 280 | if (head->env_from!=NULL) { |
280 | addresslist = address_list_to_stringlist(head->from->list); | 281 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
281 | if (addresslist.count()) { | 282 | if (addresslist.count()) { |
282 | m->setFrom(addresslist.first()); | 283 | m->setFrom(addresslist.first()); |
283 | } | 284 | } |
284 | } | 285 | } |
285 | if (head->to!=NULL) { | 286 | if (head->env_to!=NULL) { |
286 | addresslist = address_list_to_stringlist(head->to->list); | 287 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
287 | m->setTo(addresslist); | 288 | m->setTo(addresslist); |
288 | } | 289 | } |
289 | if (head->cc!=NULL) { | 290 | if (head->env_cc!=NULL) { |
290 | addresslist = address_list_to_stringlist(head->cc->list); | 291 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
291 | m->setCC(addresslist); | 292 | m->setCC(addresslist); |
292 | } | 293 | } |
293 | if (head->bcc!=NULL) { | 294 | if (head->env_bcc!=NULL) { |
294 | addresslist = address_list_to_stringlist(head->bcc->list); | 295 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
295 | m->setBcc(addresslist); | 296 | m->setBcc(addresslist); |
296 | } | 297 | } |
297 | if (head->reply_to!=NULL) { | 298 | if (head->env_reply_to!=NULL) { |
298 | addresslist = address_list_to_stringlist(head->bcc->list); | 299 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
299 | if (addresslist.count()) { | 300 | if (addresslist.count()) { |
300 | m->setReplyto(addresslist.first()); | 301 | m->setReplyto(addresslist.first()); |
301 | } | 302 | } |
302 | } | 303 | } |
303 | m->setMsgid(QString(head->message_id)); | 304 | m->setMsgid(QString(head->env_message_id)); |
304 | qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s\nMsgid: %s", | 305 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
305 | m->getFrom().latin1(), | 306 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
306 | m->getSubject().latin1(),m->getDate().latin1(),m->Msgid().latin1()); | 307 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
307 | } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 308 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
308 | mailimap_date_time*d = item->msg_att_static->internal_date; | ||
309 | QDateTime da(QDate(d->year,d->month,d->day),QTime(d->hour,d->min,d->sec)); | ||
310 | qDebug("%i %i %i - %i %i %i",d->year,d->month,d->day,d->hour,d->min,d->sec); | ||
311 | qDebug(da.toString()); | 309 | qDebug(da.toString()); |
312 | } else { | 310 | } else { |
@@ -346,5 +344,5 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
346 | err = mailimap_examine( m_imap, (char*)mb); | 344 | err = mailimap_examine( m_imap, (char*)mb); |
347 | if ( err != MAILIMAP_NO_ERROR ) { | 345 | if ( err != MAILIMAP_NO_ERROR ) { |
348 | qDebug("error selecting mailbox: %s",m_imap->response); | 346 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
349 | logout(); | 347 | logout(); |
350 | return body; | 348 | return body; |
@@ -362,13 +360,13 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
362 | mailimap_msg_att * msg_att; | 360 | mailimap_msg_att * msg_att; |
363 | msg_att = (mailimap_msg_att*)current->data; | 361 | msg_att = (mailimap_msg_att*)current->data; |
364 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | 362 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
365 | body_desc = item->msg_att_static->body; | 363 | body_desc = item->att_data.att_static->att_data.att_body; |
366 | if (body_desc->type==MAILIMAP_BODY_1PART) { | 364 | if (body_desc->bd_type==MAILIMAP_BODY_1PART) { |
367 | searchBodyText(mail,body_desc->body_1part,body); | 365 | searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); |
368 | } else { | 366 | } else { |
369 | } | 367 | } |
370 | 368 | ||
371 | } else { | 369 | } else { |
372 | qDebug("error fetching body: %s",m_imap->response); | 370 | qDebug("error fetching body: %s",m_imap->imap_response); |
373 | } | 371 | } |
374 | 372 | ||
@@ -383,7 +381,7 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
383 | return; | 381 | return; |
384 | } | 382 | } |
385 | switch (mailDescription->type) { | 383 | switch (mailDescription->bd_type) { |
386 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 384 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
387 | fillPlainBody(mail,target_body,mailDescription->body_type_text); | 385 | fillPlainBody(mail,target_body,mailDescription->bd_data.bd_type_text); |
388 | break; | 386 | break; |
389 | default: | 387 | default: |
@@ -393,5 +391,5 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
393 | } | 391 | } |
394 | 392 | ||
395 | void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * text_body) | 393 | void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap_body_type_text * bd) |
396 | { | 394 | { |
397 | const char *mb; | 395 | const char *mb; |
@@ -399,5 +397,5 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap | |||
399 | int err = MAILIMAP_NO_ERROR; | 397 | int err = MAILIMAP_NO_ERROR; |
400 | clist *result; | 398 | clist *result; |
401 | clistcell *current; | 399 | clistcell *current,*cur; |
402 | mailimap_fetch_att *fetchAtt; | 400 | mailimap_fetch_att *fetchAtt; |
403 | mailimap_fetch_type *fetchType; | 401 | mailimap_fetch_type *fetchType; |
@@ -411,7 +409,7 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap | |||
411 | 409 | ||
412 | result = clist_new(); | 410 | result = clist_new(); |
413 | /* the range has to start at 1!!! not with 0!!!! */ | 411 | set = set = mailimap_set_new_single(mail.getNumber()); |
414 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 412 | mailimap_section * section = mailimap_section_new_text(); |
415 | fetchAtt = mailimap_fetch_att_new_rfc822_text(); | 413 | fetchAtt = mailimap_fetch_att_new_body_peek_section(section); |
416 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 414 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
417 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 415 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
@@ -419,15 +417,27 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap | |||
419 | mailimap_fetch_type_free( fetchType ); | 417 | mailimap_fetch_type_free( fetchType ); |
420 | 418 | ||
419 | |||
421 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 420 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
422 | mailimap_msg_att * msg_att; | 421 | mailimap_msg_att * msg_att; |
423 | msg_att = (mailimap_msg_att*)current->data; | 422 | msg_att = (mailimap_msg_att*)current->data; |
424 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; | 423 | mailimap_msg_att_item*msg_att_item; |
425 | if (item->msg_att_static && item->msg_att_static->rfc822_text) { | 424 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
426 | body = item->msg_att_static->rfc822_text; | 425 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
426 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | ||
427 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | ||
428 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | ||
429 | int length = msg_att_item->att_data.att_static->att_data.att_body_section->sec_length; | ||
430 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | ||
431 | body = QString(text); | ||
432 | free(text); | ||
433 | } | ||
434 | } | ||
427 | } | 435 | } |
436 | |||
428 | } else { | 437 | } else { |
429 | qDebug("error fetching text: %s",m_imap->response); | 438 | qDebug("error fetching text: %s",m_imap->imap_response); |
430 | } | 439 | } |
431 | clist_free(result); | 440 | //clist_free(result); |
441 | mailimap_fetch_list_free(result); | ||
432 | target_body.setBodytext(body); | 442 | target_body.setBodytext(body); |
433 | return; | 443 | return; |
@@ -451,20 +461,20 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
451 | current_address=(mailimap_address*)current->data; | 461 | current_address=(mailimap_address*)current->data; |
452 | current = current->next; | 462 | current = current->next; |
453 | if (current_address->personal_name){ | 463 | if (current_address->ad_personal_name){ |
454 | from+=QString(current_address->personal_name); | 464 | from+=QString(current_address->ad_personal_name); |
455 | from+=" "; | 465 | from+=" "; |
456 | named_from = true; | 466 | named_from = true; |
457 | } | 467 | } |
458 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | 468 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
459 | from+="<"; | 469 | from+="<"; |
460 | } | 470 | } |
461 | if (current_address->mailbox_name) { | 471 | if (current_address->ad_mailbox_name) { |
462 | from+=QString(current_address->mailbox_name); | 472 | from+=QString(current_address->ad_mailbox_name); |
463 | from+="@"; | 473 | from+="@"; |
464 | } | 474 | } |
465 | if (current_address->host_name) { | 475 | if (current_address->ad_host_name) { |
466 | from+=QString(current_address->host_name); | 476 | from+=QString(current_address->ad_host_name); |
467 | } | 477 | } |
468 | if (named_from && (current_address->mailbox_name || current_address->host_name)) { | 478 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
469 | from+=">"; | 479 | from+=">"; |
470 | } | 480 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index faab43c..90f3004 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -8,4 +8,5 @@ struct mailimap; | |||
8 | struct mailimap_body_type_1part; | 8 | struct mailimap_body_type_1part; |
9 | struct mailimap_body_type_text; | 9 | struct mailimap_body_type_text; |
10 | struct mailimap_msg_att; | ||
10 | class RecMail; | 11 | class RecMail; |
11 | class RecBody; | 12 | class RecBody; |