-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 | |||
@@ -45,7 +45,7 @@ void IMAPwrapper::login() | |||
45 | if ( err != MAILIMAP_NO_ERROR && | 45 | if ( err != MAILIMAP_NO_ERROR && |
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; |
51 | return; | 51 | return; |
@@ -54,7 +54,7 @@ void IMAPwrapper::login() | |||
54 | /* login */ | 54 | /* 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 ); |
60 | m_imap = 0; | 60 | m_imap = 0; |
@@ -89,12 +89,12 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
89 | /* select mailbox READONLY for operations */ | 89 | /* select mailbox READONLY for operations */ |
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) { |
100 | qDebug("mailbox has no mails"); | 100 | qDebug("mailbox has no mails"); |
@@ -138,7 +138,7 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
138 | current = current->next; | 138 | current = current->next; |
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(); |
144 | clist_free(result); | 144 | clist_free(result); |
@@ -174,12 +174,12 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
174 | list = (mailimap_mailbox_list *) current->data; | 174 | list = (mailimap_mailbox_list *) current->data; |
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 ); |
185 | 185 | ||
@@ -188,6 +188,7 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
188 | */ | 188 | */ |
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); |
193 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 194 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
@@ -197,7 +198,7 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
197 | list = (mailimap_mailbox_list *) current->data; | 198 | list = (mailimap_mailbox_list *) current->data; |
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") |
203 | continue; | 204 | continue; |
@@ -205,7 +206,7 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
205 | 206 | ||
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 ); |
211 | return folders; | 212 | return folders; |
@@ -225,21 +226,21 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
225 | return m; | 226 | return m; |
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); |
245 | break; | 246 | break; |
@@ -262,52 +263,49 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
262 | default: | 263 | default: |
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 | } |
268 | cf = cf->next; | 269 | cf = cf->next; |
269 | } | 270 | } |
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 { |
313 | qDebug("Another type"); | 311 | qDebug("Another type"); |
@@ -345,7 +343,7 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
345 | /* select mailbox READONLY for operations */ | 343 | /* select mailbox READONLY for operations */ |
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; |
351 | } | 349 | } |
@@ -361,15 +359,15 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
361 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 359 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
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 | ||
375 | clist_free(result); | 373 | clist_free(result); |
@@ -382,9 +380,9 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
382 | if (!mailDescription) { | 380 | if (!mailDescription) { |
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: |
390 | break; | 388 | break; |
@@ -392,13 +390,13 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
392 | return; | 390 | return; |
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; |
398 | QString body=""; | 396 | QString body=""; |
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; |
404 | mailimap_set *set; | 402 | mailimap_set *set; |
@@ -410,25 +408,37 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap | |||
410 | } | 408 | } |
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 ); |
418 | mailimap_set_free( set ); | 416 | mailimap_set_free( set ); |
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; |
434 | } | 444 | } |
@@ -450,22 +460,22 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
450 | named_from = false; | 460 | named_from = false; |
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 | } |
471 | l.append(QString(from)); | 481 | l.append(QString(from)); |
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 | |||
@@ -7,6 +7,7 @@ | |||
7 | struct mailimap; | 7 | 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; |
12 | 13 | ||
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 | |||
@@ -45,7 +45,7 @@ void IMAPwrapper::login() | |||
45 | if ( err != MAILIMAP_NO_ERROR && | 45 | if ( err != MAILIMAP_NO_ERROR && |
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; |
51 | return; | 51 | return; |
@@ -54,7 +54,7 @@ void IMAPwrapper::login() | |||
54 | /* login */ | 54 | /* 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 ); |
60 | m_imap = 0; | 60 | m_imap = 0; |
@@ -89,12 +89,12 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
89 | /* select mailbox READONLY for operations */ | 89 | /* select mailbox READONLY for operations */ |
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) { |
100 | qDebug("mailbox has no mails"); | 100 | qDebug("mailbox has no mails"); |
@@ -138,7 +138,7 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | |||
138 | current = current->next; | 138 | current = current->next; |
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(); |
144 | clist_free(result); | 144 | clist_free(result); |
@@ -174,12 +174,12 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
174 | list = (mailimap_mailbox_list *) current->data; | 174 | list = (mailimap_mailbox_list *) current->data; |
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 ); |
185 | 185 | ||
@@ -188,6 +188,7 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
188 | */ | 188 | */ |
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); |
193 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 194 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
@@ -197,7 +198,7 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
197 | list = (mailimap_mailbox_list *) current->data; | 198 | list = (mailimap_mailbox_list *) current->data; |
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") |
203 | continue; | 204 | continue; |
@@ -205,7 +206,7 @@ QList<IMAPFolder>* IMAPwrapper::listFolders() | |||
205 | 206 | ||
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 ); |
211 | return folders; | 212 | return folders; |
@@ -225,21 +226,21 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
225 | return m; | 226 | return m; |
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); |
245 | break; | 246 | break; |
@@ -262,52 +263,49 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
262 | default: | 263 | default: |
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 | } |
268 | cf = cf->next; | 269 | cf = cf->next; |
269 | } | 270 | } |
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 { |
313 | qDebug("Another type"); | 311 | qDebug("Another type"); |
@@ -345,7 +343,7 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
345 | /* select mailbox READONLY for operations */ | 343 | /* select mailbox READONLY for operations */ |
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; |
351 | } | 349 | } |
@@ -361,15 +359,15 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail) | |||
361 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 359 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
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 | ||
375 | clist_free(result); | 373 | clist_free(result); |
@@ -382,9 +380,9 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
382 | if (!mailDescription) { | 380 | if (!mailDescription) { |
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: |
390 | break; | 388 | break; |
@@ -392,13 +390,13 @@ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mai | |||
392 | return; | 390 | return; |
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; |
398 | QString body=""; | 396 | QString body=""; |
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; |
404 | mailimap_set *set; | 402 | mailimap_set *set; |
@@ -410,25 +408,37 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap | |||
410 | } | 408 | } |
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 ); |
418 | mailimap_set_free( set ); | 416 | mailimap_set_free( set ); |
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; |
434 | } | 444 | } |
@@ -450,22 +460,22 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | |||
450 | named_from = false; | 460 | named_from = false; |
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 | } |
471 | l.append(QString(from)); | 481 | l.append(QString(from)); |
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 | |||
@@ -7,6 +7,7 @@ | |||
7 | struct mailimap; | 7 | 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; |
12 | 13 | ||