summaryrefslogtreecommitdiff
path: root/noncore/net/mail/imapwrapper.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/imapwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index 5ce140e..eae85a7 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -206,17 +206,13 @@ QList<IMAPFolder>* IMAPwrapper::listFolders()
206} 206}
207 207
208RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 208RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
209{ 209{
210 RecMail * m = 0; 210 RecMail * m = 0;
211 mailimap_msg_att_item *item=0; 211 mailimap_msg_att_item *item=0;
212 bool named_from = false; 212 clistcell *current,*c,*cf;
213 QString from,date,subject;
214 date = from = subject = "";
215 clistcell *current,*c,*cf, *current_from = NULL;
216 mailimap_address * current_address = NULL;
217 mailimap_msg_att_dynamic*flist; 213 mailimap_msg_att_dynamic*flist;
218 mailimap_flag_fetch*cflag; 214 mailimap_flag_fetch*cflag;
219 QBitArray mFlags(7); 215 QBitArray mFlags(7);
220 QStringList addresslist; 216 QStringList addresslist;
221 217
222 if (!m_att) { 218 if (!m_att) {
@@ -268,19 +264,19 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
268 continue; 264 continue;
269 } 265 }
270 if ( item->msg_att_static->type == MAILIMAP_MSG_ATT_RFC822_HEADER ) { 266 if ( item->msg_att_static->type == MAILIMAP_MSG_ATT_RFC822_HEADER ) {
271 qDebug( "header: \n%s", item->msg_att_static->rfc822_header ); 267 qDebug( "header: \n%s", item->msg_att_static->rfc822_header );
272 } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_ENVELOPE) { 268 } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_ENVELOPE) {
273 mailimap_envelope * head = item->msg_att_static->env; 269 mailimap_envelope * head = item->msg_att_static->env;
274 date = head->date;
275 subject = head->subject;
276 m = new RecMail(); 270 m = new RecMail();
271 m->setDate(head->date);
272 m->setSubject(head->subject);
277 if (head->from!=NULL) { 273 if (head->from!=NULL) {
278 addresslist = address_list_to_stringlist(head->from->list); 274 addresslist = address_list_to_stringlist(head->from->list);
279 if (addresslist.count()) { 275 if (addresslist.count()) {
280 from = addresslist.first(); 276 m->setFrom(addresslist.first());
281 } 277 }
282 } 278 }
283 if (head->to!=NULL) { 279 if (head->to!=NULL) {
284 addresslist = address_list_to_stringlist(head->to->list); 280 addresslist = address_list_to_stringlist(head->to->list);
285 m->setTo(addresslist); 281 m->setTo(addresslist);
286 } 282 }
@@ -289,19 +285,22 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
289 m->setCC(addresslist); 285 m->setCC(addresslist);
290 } 286 }
291 if (head->bcc!=NULL) { 287 if (head->bcc!=NULL) {
292 addresslist = address_list_to_stringlist(head->bcc->list); 288 addresslist = address_list_to_stringlist(head->bcc->list);
293 m->setBcc(addresslist); 289 m->setBcc(addresslist);
294 } 290 }
295 m->setSubject(subject); 291 if (head->reply_to!=NULL) {
296 m->setFrom(from); 292 addresslist = address_list_to_stringlist(head->bcc->list);
297 m->setDate(date); 293 if (addresslist.count()) {
294 m->setReplyto(addresslist.first());
295 }
296 }
298 m->setMsgid(QString(head->message_id)); 297 m->setMsgid(QString(head->message_id));
299 qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s\nMsgid: %s", 298 qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s\nMsgid: %s",
300 from.latin1(), 299 m->getFrom().latin1(),
301 subject.latin1(),date.latin1(),m->Msgid().latin1()); 300 m->getSubject().latin1(),m->getDate().latin1(),m->Msgid().latin1());
302 } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_INTERNALDATE) { 301 } else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_INTERNALDATE) {
303 mailimap_date_time*d = item->msg_att_static->internal_date; 302 mailimap_date_time*d = item->msg_att_static->internal_date;
304 QDateTime da(QDate(d->year,d->month,d->day),QTime(d->hour,d->min,d->sec)); 303 QDateTime da(QDate(d->year,d->month,d->day),QTime(d->hour,d->min,d->sec));
305 qDebug("%i %i %i - %i %i %i",d->year,d->month,d->day,d->hour,d->min,d->sec); 304 qDebug("%i %i %i - %i %i %i",d->year,d->month,d->day,d->hour,d->min,d->sec);
306 qDebug(da.toString()); 305 qDebug(da.toString());
307 } else { 306 } else {
@@ -436,12 +435,13 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
436 clistcell *current = NULL; 435 clistcell *current = NULL;
437 mailimap_address * current_address=NULL; 436 mailimap_address * current_address=NULL;
438 if (!list) { 437 if (!list) {
439 return l; 438 return l;
440 } 439 }
441 current = clist_begin(list); 440 current = clist_begin(list);
441 unsigned int count = 0;
442 while (current!= NULL) { 442 while (current!= NULL) {
443 from = ""; 443 from = "";
444 named_from = false; 444 named_from = false;
445 current_address=(mailimap_address*)current->data; 445 current_address=(mailimap_address*)current->data;
446 current = current->next; 446 current = current->next;
447 if (current_address->personal_name){ 447 if (current_address->personal_name){
@@ -460,9 +460,12 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
460 from+=QString(current_address->host_name); 460 from+=QString(current_address->host_name);
461 } 461 }
462 if (named_from && (current_address->mailbox_name || current_address->host_name)) { 462 if (named_from && (current_address->mailbox_name || current_address->host_name)) {
463 from+=">"; 463 from+=">";
464 } 464 }
465 l.append(QString(from)); 465 l.append(QString(from));
466 if (++count > 99) {
467 break;
468 }
466 } 469 }
467 return l; 470 return l;
468} 471}