summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/imapwrapper.cpp
Side-by-side diff
Diffstat (limited to 'kmicromail/libmailwrapper/imapwrapper.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index d79df4f..b0dd1b8 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -1,58 +1,59 @@
// CHANGED 2004-09-31 Lutz Rogowski
#include <stdlib.h>
#include <libetpan/libetpan.h>
#include <qpe/global.h>
#include <qapplication.h>
#include "imapwrapper.h"
#include "mailtypes.h"
#include "logindialog.h"
#include <qprogressbar.h>
#include "genericwrapper.h"
+#include <kglobal.h>
using namespace Opie::Core;
int IMAPwrapper::mMax = 0;
int IMAPwrapper::mCurrent = 0;
IMAPwrapper::IMAPwrapper( IMAPaccount *a )
: AbstractMail()
{
account = a;
m_imap = 0;
m_Lastmbox = "";
mCurrent = 0;
mMax = 0;
}
IMAPwrapper::~IMAPwrapper()
{
logout();
}
/* to avoid to often select statements in loops etc.
we trust that we are logged in and connection is established!*/
int IMAPwrapper::selectMbox(const QString&mbox)
{
if (mbox == m_Lastmbox) {
return MAILIMAP_NO_ERROR;
}
int err = mailimap_select( m_imap, (char*)mbox.latin1());
if ( err != MAILIMAP_NO_ERROR ) {
m_Lastmbox = "";
return err;
}
m_Lastmbox = mbox;
return err;
}
void IMAPwrapper::imap_progress( size_t current, size_t maximum )
{
//qDebug("imap progress %d of %d ",current,maximum );
//Global::statusMessage(tr("Downloading message %1 of %2").arg( current).arg(maximum));
//qApp->processEvents()
static int last = 0;
if ( last != current )
IMAPwrapper::progress();
last = current;
}
void IMAPwrapper::progress( QString m )
{
@@ -420,100 +421,108 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
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;
}
} else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
mFlags.setBit(FLAG_RECENT);
}
}
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 ) {
- m->setDate( Genericwrapper::parseDateTime( date ) );
- char tmp[23];
- snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %05i",
- date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
+ 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);
m->setIsoDate( QString( tmp ) );
} else {
m->setIsoDate(head->env_date);
}
}
if ( head->env_subject != NULL )
m->setSubject(convert_String((const char*)head->env_subject));
//m->setSubject(head->env_subject);
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);
}
/* reply to address, eg. email. */
if (head->env_reply_to!=NULL) {
addresslist = address_list_to_stringlist(head->env_reply_to->rt_list);
if (addresslist.count()) {
m->setReplyto(addresslist.first());
}
}
if (head->env_in_reply_to!=NULL) {
QString h(head->env_in_reply_to);
while (h.length()>0 && h[0]=='<') {
h.remove(0,1);
}
while (h.length()>0 && h[h.length()-1]=='>') {
h.remove(h.length()-1,1);
}
if (h.length()>0) {
m->setInreply(QStringList(h));
}
}
if (head->env_message_id != NULL) {
m->setMsgid(QString(head->env_message_id));
}