summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/imapwrapper.cpp
Side-by-side diff
Diffstat (limited to 'kmicromail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp67
1 files changed, 36 insertions, 31 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index d9496af..93fb7de 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -427,73 +427,78 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
current = c;
size = 0;
item = (mailimap_msg_att_item*)current->data;
if ( !item )
continue;
if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
if (!flist || !flist->att_list) {
continue;
}
cf = flist->att_list->first;
- if( ! cf )
- for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
- cflag = (mailimap_flag_fetch*)cf->data;
- if( ! cflag )
- qDebug("imap:not cflag ");
- if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
- switch (cflag->fl_flag->fl_type) {
- case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
- mFlags.setBit(FLAG_ANSWERED);
- break;
- case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
- mFlags.setBit(FLAG_FLAGGED);
- break;
- case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
- mFlags.setBit(FLAG_DELETED);
- break;
- case MAILIMAP_FLAG_SEEN: /* \Seen flag */
- mFlags.setBit(FLAG_SEEN);
- break;
- case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
- mFlags.setBit(FLAG_DRAFT);
- break;
- case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
- break;
- case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
- break;
- default:
- break;
+ if( cf ) {
+ for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
+ cflag = (mailimap_flag_fetch*)cf->data;
+ if( ! cflag )
+ qDebug("imap:NO cflag ");
+ else {
+ if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
+ switch (cflag->fl_flag->fl_type) {
+ case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
+ mFlags.setBit(FLAG_ANSWERED);
+ break;
+ case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
+ mFlags.setBit(FLAG_FLAGGED);
+ break;
+ case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
+ mFlags.setBit(FLAG_DELETED);
+ break;
+ case MAILIMAP_FLAG_SEEN: /* \Seen flag */
+ mFlags.setBit(FLAG_SEEN);
+ break;
+ case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
+ mFlags.setBit(FLAG_DRAFT);
+ break;
+ case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
+ break;
+ case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
+ break;
+ default:
+ break;
+ }
+ } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
+ mFlags.setBit(FLAG_RECENT);
+ }
}
- } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
- mFlags.setBit(FLAG_RECENT);
}
}
+ //qDebug(" continue");
continue;
}
if ( item->att_data.att_static == NULL )
continue;
if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
if ( head == NULL )
continue;
if ( head->env_date != NULL ) {
m->setDate(head->env_date);
//struct mailimf_date_time result;
struct mailimf_date_time* date;// = &result;
struct mailimf_date_time **re = &date;
size_t length = m->getDate().length();
size_t index = 0;
if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) {
+ //qDebug("parseDateTime ");
QDateTime dt = Genericwrapper::parseDateTime( date );
QString ret;
if ( dt.date() == QDate::currentDate () )
ret = KGlobal::locale()->formatTime( dt.time(),true);
else {
ret = KGlobal::locale()->formatDateTime( dt,true,true);
}
m->setDate( ret );
char tmp[20];
snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i",
dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() );
//qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date);
@@ -598,25 +603,25 @@ RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
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;
QValueList<int> path;
body_desc = item->att_data.att_static->att_data.att_body;
traverseBody(mail,body_desc,body,0,path);
} else {
- //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl;
+ qDebug("error fetching body %d (%d): %s", err, MAILIMAP_NO_ERROR, m_imap->imap_response );
}
if (result) mailimap_fetch_list_free(result);
return body;
}
QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
{
QStringList l;
QString from;
bool named_from;
clistcell *current = NULL;
mailimap_address * current_address=NULL;