author | alwin <alwin> | 2003-12-13 02:36:57 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-13 02:36:57 (UTC) |
commit | a170120c655169de904ff282e23461ba4eef2b47 (patch) (side-by-side diff) | |
tree | 0c7f7612fbe9610cf4bc23a5b9aba5f5591d7caf | |
parent | f689ef512cfc0a56fead4839a6b2e24a6ee282e0 (diff) | |
download | opie-a170120c655169de904ff282e23461ba4eef2b47.zip opie-a170120c655169de904ff282e23461ba4eef2b47.tar.gz opie-a170120c655169de904ff282e23461ba4eef2b47.tar.bz2 |
mails will marked as read now
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 7 |
2 files changed, 6 insertions, 8 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index 7b75ffa..3941cec 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp @@ -270,258 +270,257 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) if (head->env_from!=NULL) { addresslist = address_list_to_stringlist(head->env_from->frm_list); if (addresslist.count()) { m->setFrom(addresslist.first()); } } if (head->env_to!=NULL) { addresslist = address_list_to_stringlist(head->env_to->to_list); m->setTo(addresslist); } if (head->env_cc!=NULL) { addresslist = address_list_to_stringlist(head->env_cc->cc_list); m->setCC(addresslist); } if (head->env_bcc!=NULL) { addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); m->setBcc(addresslist); } if (head->env_reply_to!=NULL) { addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); if (addresslist.count()) { m->setReplyto(addresslist.first()); } } m->setMsgid(QString(head->env_message_id)); } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); 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); qDebug(da.toString()); } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { size = item->att_data.att_static->att_data.att_rfc822_size; } } /* msg is already deleted */ if (mFlags.testBit(FLAG_DELETED) && m) { delete m; m = 0; } if (m) { m->setFlags(mFlags); m->setMsgsize(size); } return m; } RecBody IMAPwrapper::fetchBody(const RecMail&mail) { RecBody body; const char *mb; int err = MAILIMAP_NO_ERROR; clist *result; clistcell *current; mailimap_fetch_att *fetchAtt; mailimap_fetch_type *fetchType; mailimap_set *set; mailimap_body*body_desc; mb = mail.getMbox().latin1(); login(); if (!m_imap) { return body; } - /* select mailbox READONLY for operations */ - err = mailimap_examine( m_imap, (char*)mb); + + err = mailimap_select( m_imap, (char*)mb); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error selecting mailbox: %s",m_imap->imap_response); return body; } result = clist_new(); /* the range has to start at 1!!! not with 0!!!! */ set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); fetchAtt = mailimap_fetch_att_new_bodystructure(); fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); err = mailimap_fetch( m_imap, set, fetchType, &result ); mailimap_set_free( set ); mailimap_fetch_type_free( fetchType ); if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { mailimap_msg_att * msg_att; msg_att = (mailimap_msg_att*)current->data; mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; body_desc = item->att_data.att_static->att_data.att_body; if (body_desc->bd_type==MAILIMAP_BODY_1PART) { searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { qDebug("Mulitpart mail"); searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); } } else { qDebug("error fetching body: %s",m_imap->imap_response); } mailimap_fetch_list_free(result); return body; } /* this routine is just called when the mail has only ONE part. for filling the parts of a multi-part-message there are other routines 'cause we can not simply fetch the whole body. */ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) { if (!mailDescription) { return; } QString sub,body_text; RecPart singlePart; QValueList<int> path; fillSinglePart(singlePart,mailDescription); switch (mailDescription->bd_type) { case MAILIMAP_BODY_TYPE_1PART_MSG: path.append(1); body_text = fetchPart(mail,path,true); target_body.setBodytext(body_text); target_body.setDescription(singlePart); break; case MAILIMAP_BODY_TYPE_1PART_TEXT: qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); path.append(1); body_text = fetchPart(mail,path,true); target_body.setBodytext(body_text); target_body.setDescription(singlePart); break; case MAILIMAP_BODY_TYPE_1PART_BASIC: qDebug("Single attachment"); target_body.setBodytext(""); target_body.addPart(singlePart); break; default: break; } return; } QStringList IMAPwrapper::address_list_to_stringlist(clist*list) { QStringList l; QString from; bool named_from; clistcell *current = NULL; mailimap_address * current_address=NULL; if (!list) { return l; } unsigned int count = 0; for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { from = ""; named_from = false; current_address=(mailimap_address*)current->data; if (current_address->ad_personal_name){ from+=QString(current_address->ad_personal_name); from+=" "; named_from = true; } if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { from+="<"; } if (current_address->ad_mailbox_name) { from+=QString(current_address->ad_mailbox_name); from+="@"; } if (current_address->ad_host_name) { from+=QString(current_address->ad_host_name); } if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { from+=">"; } l.append(QString(from)); if (++count > 99) { break; } } return l; } QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) { QString body(""); const char*mb; int err; mailimap_fetch_type *fetchType; mailimap_set *set; clistcell*current,*cur; login(); if (!m_imap) { return body; } if (!internal_call) { mb = mail.getMbox().latin1(); - /* select mailbox READONLY for operations */ - err = mailimap_examine( m_imap, (char*)mb); + err = mailimap_select( m_imap, (char*)mb); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error selecting mailbox: %s",m_imap->imap_response); return body; } } set = mailimap_set_new_single(mail.getNumber()); clist*id_list=clist_new(); for (unsigned j=0; j < path.count();++j) { uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); *p_id = path[j]; clist_append(id_list,p_id); } mailimap_section_part * section_part = mailimap_section_part_new(id_list); mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); mailimap_section * section = mailimap_section_new(section_spec); mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); clist*result = clist_new(); err = mailimap_fetch( m_imap, set, fetchType, &result ); mailimap_set_free( set ); mailimap_fetch_type_free( fetchType ); if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { mailimap_msg_att * msg_att; msg_att = (mailimap_msg_att*)current->data; mailimap_msg_att_item*msg_att_item; for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { msg_att_item = (mailimap_msg_att_item*)clist_content(cur); if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; if (text) { body = QString(text); free(text); } else { body = ""; } } } } } else { qDebug("error fetching text: %s",m_imap->imap_response); } mailimap_fetch_list_free(result); return body; } void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) { /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ if (!mailDescription||current_recursion==10) { return; } clistcell*current; mailimap_body*current_body; unsigned int count = 0; for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { /* the point in the message */ ++count; diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 7b75ffa..3941cec 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp @@ -270,258 +270,257 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) if (head->env_from!=NULL) { addresslist = address_list_to_stringlist(head->env_from->frm_list); if (addresslist.count()) { m->setFrom(addresslist.first()); } } if (head->env_to!=NULL) { addresslist = address_list_to_stringlist(head->env_to->to_list); m->setTo(addresslist); } if (head->env_cc!=NULL) { addresslist = address_list_to_stringlist(head->env_cc->cc_list); m->setCC(addresslist); } if (head->env_bcc!=NULL) { addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); m->setBcc(addresslist); } if (head->env_reply_to!=NULL) { addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); if (addresslist.count()) { m->setReplyto(addresslist.first()); } } m->setMsgid(QString(head->env_message_id)); } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); 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); qDebug(da.toString()); } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { size = item->att_data.att_static->att_data.att_rfc822_size; } } /* msg is already deleted */ if (mFlags.testBit(FLAG_DELETED) && m) { delete m; m = 0; } if (m) { m->setFlags(mFlags); m->setMsgsize(size); } return m; } RecBody IMAPwrapper::fetchBody(const RecMail&mail) { RecBody body; const char *mb; int err = MAILIMAP_NO_ERROR; clist *result; clistcell *current; mailimap_fetch_att *fetchAtt; mailimap_fetch_type *fetchType; mailimap_set *set; mailimap_body*body_desc; mb = mail.getMbox().latin1(); login(); if (!m_imap) { return body; } - /* select mailbox READONLY for operations */ - err = mailimap_examine( m_imap, (char*)mb); + + err = mailimap_select( m_imap, (char*)mb); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error selecting mailbox: %s",m_imap->imap_response); return body; } result = clist_new(); /* the range has to start at 1!!! not with 0!!!! */ set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); fetchAtt = mailimap_fetch_att_new_bodystructure(); fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); err = mailimap_fetch( m_imap, set, fetchType, &result ); mailimap_set_free( set ); mailimap_fetch_type_free( fetchType ); if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { mailimap_msg_att * msg_att; msg_att = (mailimap_msg_att*)current->data; mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; body_desc = item->att_data.att_static->att_data.att_body; if (body_desc->bd_type==MAILIMAP_BODY_1PART) { searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { qDebug("Mulitpart mail"); searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); } } else { qDebug("error fetching body: %s",m_imap->imap_response); } mailimap_fetch_list_free(result); return body; } /* this routine is just called when the mail has only ONE part. for filling the parts of a multi-part-message there are other routines 'cause we can not simply fetch the whole body. */ void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) { if (!mailDescription) { return; } QString sub,body_text; RecPart singlePart; QValueList<int> path; fillSinglePart(singlePart,mailDescription); switch (mailDescription->bd_type) { case MAILIMAP_BODY_TYPE_1PART_MSG: path.append(1); body_text = fetchPart(mail,path,true); target_body.setBodytext(body_text); target_body.setDescription(singlePart); break; case MAILIMAP_BODY_TYPE_1PART_TEXT: qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); path.append(1); body_text = fetchPart(mail,path,true); target_body.setBodytext(body_text); target_body.setDescription(singlePart); break; case MAILIMAP_BODY_TYPE_1PART_BASIC: qDebug("Single attachment"); target_body.setBodytext(""); target_body.addPart(singlePart); break; default: break; } return; } QStringList IMAPwrapper::address_list_to_stringlist(clist*list) { QStringList l; QString from; bool named_from; clistcell *current = NULL; mailimap_address * current_address=NULL; if (!list) { return l; } unsigned int count = 0; for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { from = ""; named_from = false; current_address=(mailimap_address*)current->data; if (current_address->ad_personal_name){ from+=QString(current_address->ad_personal_name); from+=" "; named_from = true; } if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { from+="<"; } if (current_address->ad_mailbox_name) { from+=QString(current_address->ad_mailbox_name); from+="@"; } if (current_address->ad_host_name) { from+=QString(current_address->ad_host_name); } if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { from+=">"; } l.append(QString(from)); if (++count > 99) { break; } } return l; } QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) { QString body(""); const char*mb; int err; mailimap_fetch_type *fetchType; mailimap_set *set; clistcell*current,*cur; login(); if (!m_imap) { return body; } if (!internal_call) { mb = mail.getMbox().latin1(); - /* select mailbox READONLY for operations */ - err = mailimap_examine( m_imap, (char*)mb); + err = mailimap_select( m_imap, (char*)mb); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error selecting mailbox: %s",m_imap->imap_response); return body; } } set = mailimap_set_new_single(mail.getNumber()); clist*id_list=clist_new(); for (unsigned j=0; j < path.count();++j) { uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); *p_id = path[j]; clist_append(id_list,p_id); } mailimap_section_part * section_part = mailimap_section_part_new(id_list); mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); mailimap_section * section = mailimap_section_new(section_spec); mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); clist*result = clist_new(); err = mailimap_fetch( m_imap, set, fetchType, &result ); mailimap_set_free( set ); mailimap_fetch_type_free( fetchType ); if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { mailimap_msg_att * msg_att; msg_att = (mailimap_msg_att*)current->data; mailimap_msg_att_item*msg_att_item; for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { msg_att_item = (mailimap_msg_att_item*)clist_content(cur); if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; if (text) { body = QString(text); free(text); } else { body = ""; } } } } } else { qDebug("error fetching text: %s",m_imap->imap_response); } mailimap_fetch_list_free(result); return body; } void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) { /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ if (!mailDescription||current_recursion==10) { return; } clistcell*current; mailimap_body*current_body; unsigned int count = 0; for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { /* the point in the message */ ++count; |