summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp10
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/mailstatics.cpp23
-rw-r--r--noncore/net/mail/libmailwrapper/mailstatics.h4
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp18
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h11
-rw-r--r--noncore/net/mail/mailistviewitem.cpp20
-rw-r--r--noncore/net/mail/mailistviewitem.h1
-rw-r--r--noncore/net/mail/mainwindow.cpp3
-rw-r--r--noncore/net/mail/viewmail.cpp2
10 files changed, 66 insertions, 31 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index 703235d..0ac842d 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -375,25 +375,25 @@ QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies)
while (h.length()>0 && h[h.length()-1]=='>') {
h.remove(h.length()-1,1);
}
if (h.length()>0) {
res.append(h);
}
}
return res;
}
void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to)
{
- int r;
+ int r,toffset;
mailmessage_list * env_list = 0;
r = mailsession_get_messages_list(session,&env_list);
if (r != MAIL_NO_ERROR) {
odebug << "Error message list" << oendl;
return;
}
r = mailsession_get_envelopes_list(session, env_list);
if (r != MAIL_NO_ERROR) {
odebug << "Error filling message list" << oendl;
if (env_list) {
mailmessage_list_free(env_list);
}
@@ -428,31 +428,31 @@ void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &
if (single_fields.fld_from)
mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list));
if (!mbox_as_to) {
if (single_fields.fld_to)
mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) );
} else {
mail->setTo(mailbox);
}
if (single_fields.fld_cc)
mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) );
if (single_fields.fld_bcc)
mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) );
- if (single_fields.fld_orig_date)
- mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) );
- // crashes when accessing pop3 account?
+ if (single_fields.fld_orig_date) {
+ QDateTime d = parseDateTime( single_fields.fld_orig_date->dt_date_time,toffset);
+ mail->setDate( d,toffset );
+ }
if (single_fields.fld_message_id && single_fields.fld_message_id->mid_value) {
mail->setMsgid(QString(single_fields.fld_message_id->mid_value));
}
-
if (single_fields.fld_reply_to) {
QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list);
if (t.count()>0) {
mail->setReplyto(t[0]);
}
}
#if 0
refs = single_fields.fld_references;
if (refs && refs->mid_list && clist_count(refs->mid_list)) {
char * text = (char*)refs->mid_list->first->data;
mail->setReplyto(QString(text));
}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 56efa0b..8e5212b 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -363,25 +363,25 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
}
if (result) mailimap_list_result_free( result );
return folders;
}
RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
{
RecMail * m = 0;
mailimap_msg_att_item *item=0;
clistcell *current,*c,*cf;
mailimap_msg_att_dynamic*flist;
mailimap_flag_fetch*cflag;
- int size;
+ int size,toffset;
QBitArray mFlags(7);
QStringList addresslist;
if (!m_att) {
return m;
}
size = 0;
m = new RecMail();
for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
current = c;
item = (mailimap_msg_att_item*)current->data;
if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
@@ -415,25 +415,26 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
break;
default:
break;
}
} else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
mFlags.setBit(FLAG_RECENT);
}
}
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;
- m->setDate(parseDateTime(head->env_date));
+ QDateTime d = parseDateTime(head->env_date,toffset);
+ m->setDate(d,toffset);
m->setSubject(convert_String((const char*)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) {
diff --git a/noncore/net/mail/libmailwrapper/mailstatics.cpp b/noncore/net/mail/libmailwrapper/mailstatics.cpp
index 4878dc9..033ec28 100644
--- a/noncore/net/mail/libmailwrapper/mailstatics.cpp
+++ b/noncore/net/mail/libmailwrapper/mailstatics.cpp
@@ -1,29 +1,30 @@
#include "mailstatics.h"
#include <libetpan/libetpan.h>
-#include <qpe/timestring.h>
+//#include <qpe/timestring.h>
-QString MailStatics::parseDateTime(const mailimf_date_time *date )
+QDateTime MailStatics::parseDateTime(const mailimf_date_time *date,int&offset )
{
- if (!date) return "";
+ offset = 0;
+ if (!date) {
+ return QDateTime();
+ }
QDateTime da(QDate(date->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec));
- QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" ";
- timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" ";
- timestring.sprintf(timestring+" %+05i",date->dt_zone);
- return timestring;
+ offset = date->dt_zone;
+ return da;
}
-QString MailStatics::parseDateTime(const char*date)
+QDateTime MailStatics::parseDateTime(const char*date,int&offset)
{
- mailimf_date_time * date_time;
- QString d = "";
+ mailimf_date_time * date_time=0;
+ QDateTime d;
size_t cur_tok = 0;
if (!date) return d;
int r = mailimf_date_time_parse(date,strlen(date),&cur_tok,&date_time);
if (r==MAILIMF_NO_ERROR) {
- d = parseDateTime(date_time);
+ d = parseDateTime(date_time,offset);
}
if (date_time) {
mailimf_date_time_free(date_time);
}
return d;
} \ No newline at end of file
diff --git a/noncore/net/mail/libmailwrapper/mailstatics.h b/noncore/net/mail/libmailwrapper/mailstatics.h
index 841d14d..c714ead 100644
--- a/noncore/net/mail/libmailwrapper/mailstatics.h
+++ b/noncore/net/mail/libmailwrapper/mailstatics.h
@@ -1,19 +1,19 @@
#ifndef __MAIL_STATICS_H
#define __MAIL_STATICS_H
#include <qdatetime.h>
#include <qstring.h>
struct mailimf_date_time;
class MailStatics
{
protected:
- static QString parseDateTime(const mailimf_date_time * date);
- static QString parseDateTime(const char*date);
+ static QDateTime parseDateTime(const mailimf_date_time * date,int&offset);
+ static QDateTime parseDateTime(const char*date,int&offset);
MailStatics(){};
virtual ~MailStatics(){};
public:
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp
index d4395a2..b009b75 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.cpp
+++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp
@@ -1,41 +1,43 @@
#include "mailtypes.h"
#include <opie2/odebug.h>
+#include <qpe/timestring.h>
#include <stdlib.h>
using namespace Opie::Core;
RecMail::RecMail()
- :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
+ :Opie::Core::ORefCount(),subject(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7),maildate(),date("")
{
init();
}
RecMail::RecMail(const RecMail&old)
- :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
+ :Opie::Core::ORefCount(),subject(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7),maildate(),date("")
{
init();
copy_old(old);
odebug << "Copy constructor RecMail" << oendl;
}
RecMail::~RecMail()
{
wrapper = 0;
}
void RecMail::copy_old(const RecMail&old)
{
subject = old.subject;
+ maildate = old.maildate;
date = old.date;
mbox = old.mbox;
msg_id = old.msg_id;
msg_size = old.msg_size;
msg_number = old.msg_number;
from = old.from;
msg_flags = old.msg_flags;
to = old.to;
cc = old.cc;
bcc = old.bcc;
wrapper = old.wrapper;
in_reply_to = old.in_reply_to;
@@ -44,24 +46,35 @@ void RecMail::copy_old(const RecMail&old)
}
void RecMail::init()
{
to.clear();
cc.clear();
bcc.clear();
in_reply_to.clear();
references.clear();
wrapper = 0;
}
+void RecMail::setDate( const QDateTime&a,int offset)
+{
+ QString timestring = TimeString::numberDateString(a.date())+" ";
+ timestring+=TimeString::timeString(a.time());
+ if (offset > 0) {
+ timestring.sprintf(timestring+" %+05i",offset);
+ }
+ date = timestring;
+ maildate = a;
+}
+
void RecMail::setWrapper(AbstractMail*awrapper)
{
wrapper = awrapper;
}
AbstractMail* RecMail::Wrapper()
{
return wrapper;
}
void RecMail::setTo(const QStringList&list)
{
@@ -387,13 +400,12 @@ void encodedString::setContent(char*nContent,int nSize)
{
content = nContent;
size = nSize;
}
folderStat&folderStat::operator=(const folderStat&old)
{
message_count = old.message_count;
message_unseen = old.message_unseen;
message_recent = old.message_recent;
return *this;
}
-
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h
index c317880..272514c 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.h
+++ b/noncore/net/mail/libmailwrapper/mailtypes.h
@@ -6,49 +6,48 @@
#define FLAG_DELETED 2
#define FLAG_SEEN 3
#define FLAG_DRAFT 4
#define FLAG_RECENT 5
#include <opie2/osmartpointer.h>
#include <qbitarray.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qmap.h>
#include <qvaluelist.h>
+#include <qdatetime.h>
class AbstractMail;
/* a class to describe mails in a mailbox */
/* Attention!
From programmers point of view it would make sense to
store the mail body into this class, too.
But: not from the point of view of the device.
Mailbodies can be real large. So we request them when
needed from the mail-wrapper class direct from the server itself
(imap) or from a file-based cache (pop3?)
So there is no interface "const QString&body()" but you should
make a request to the mailwrapper with this class as parameter to
get the body. Same words for the attachments.
*/
class RecMail:public Opie::Core::ORefCount
{
public:
RecMail();
RecMail(const RecMail&old);
virtual ~RecMail();
const unsigned int getNumber()const{return msg_number;}
void setNumber(unsigned int number){msg_number=number;}
- const QString&getDate()const{ return date; }
- void setDate( const QString&a ) { date = a; }
const QString&getFrom()const{ return from; }
void setFrom( const QString&a ) { from = a; }
const QString&getSubject()const { return subject; }
void setSubject( const QString&s ) { subject = s; }
const QString&getMbox()const{return mbox;}
void setMbox(const QString&box){mbox = box;}
void setMsgid(const QString&id){msg_id=id;}
const QString&Msgid()const{return msg_id;}
void setReplyto(const QString&reply){replyto=reply;}
const QString&Replyto()const{return replyto;}
void setMsgsize(unsigned int size){msg_size = size;}
const unsigned int Msgsize()const{return msg_size;}
@@ -62,32 +61,38 @@ public:
const QStringList&Bcc()const;
void setInreply(const QStringList&list);
const QStringList&Inreply()const;
void setReferences(const QStringList&list);
const QStringList&References()const;
const QBitArray&getFlags()const{return msg_flags;}
void setFlags(const QBitArray&flags){msg_flags = flags;}
void setWrapper(AbstractMail*wrapper);
AbstractMail* Wrapper();
+ const QDateTime&getDate()const{ return maildate; }
+ const QString&getStringDate()const{return date;}
+ void setDate( const QDateTime&a,int offset=0 );
+
protected:
- QString subject,date,from,mbox,msg_id,replyto;
+ QString subject,from,mbox,msg_id,replyto;
unsigned int msg_number,msg_size;
QBitArray msg_flags;
QStringList to,cc,bcc,in_reply_to,references;
AbstractMail*wrapper;
void init();
void copy_old(const RecMail&old);
+ QDateTime maildate;
+ QString date;
};
typedef Opie::Core::OSmartPointer<RecMail> RecMailP;
typedef QMap<QString,QString> part_plist_t;
class RecPart:public Opie::Core::ORefCount
{
protected:
QString m_type,m_subtype,m_identifier,m_encoding,m_description;
unsigned int m_lines,m_size;
part_plist_t m_Parameters;
/* describes the position in the mail */
diff --git a/noncore/net/mail/mailistviewitem.cpp b/noncore/net/mail/mailistviewitem.cpp
index 0b926da..d3a0723 100644
--- a/noncore/net/mail/mailistviewitem.cpp
+++ b/noncore/net/mail/mailistviewitem.cpp
@@ -1,28 +1,29 @@
#include "mailistviewitem.h"
#include <libmailwrapper/abstractmail.h>
#include <qtextstream.h>
#include <qpe/resource.h>
+#include <qpe/timestring.h>
MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
:QListViewItem(parent,item),mail_data()
{
}
void MailListViewItem::showEntry()
{
if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) {
setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") );
} else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) {
- /* I think it looks nicer if there are not such a log of icons but only on mails
+ /* I think it looks nicer if there are not such a lot of icons but only on mails
replied or new - Alwin*/
//setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") );
} else {
setPixmap( 0, Resource::loadPixmap( "mail/kmmsgnew") );
}
double s = mail_data->Msgsize();
int w;
w=0;
while (s>1024) {
s/=1024;
++w;
@@ -39,29 +40,42 @@ void MailListViewItem::showEntry()
q="M";
break;
default:
break;
}
{
QTextOStream o(&fsize);
if (w>0) o.precision(2); else o.precision(0);
o.setf(QTextStream::fixed);
o << s << " " << q << "Byte";
}
-
setText(1,mail_data->getSubject());
setText(2,mail_data->getFrom());
setText(3,fsize);
- setText(4,mail_data->getDate());
+ setText(4,mail_data->getStringDate());
+}
+
+QString MailListViewItem::key(int col,bool) const
+{
+ QString temp;
+ if (col == 4) {
+ temp.sprintf( "%08d",QDateTime().secsTo(mail_data->getDate()));
+ return temp;
+ }
+ if (col == 3) {
+ temp.sprintf( "%020d",mail_data->Msgsize());
+ return temp;
+ }
+ return text(col);
}
void MailListViewItem::storeData(const RecMailP&data)
{
mail_data = data;
}
const RecMailP& MailListViewItem::data()const
{
return mail_data;
}
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h
index d953d83..ce64ca9 100644
--- a/noncore/net/mail/mailistviewitem.h
+++ b/noncore/net/mail/mailistviewitem.h
@@ -7,17 +7,18 @@
class MailListViewItem:public QListViewItem
{
public:
MailListViewItem(QListView * parent, MailListViewItem * after );
virtual ~MailListViewItem(){}
void storeData(const RecMailP&data);
const RecMailP&data()const;
void showEntry();
MAILLIB::ATYPE wrapperType();
+ virtual QString key(int col,bool) const;
protected:
RecMailP mail_data;
};
#endif
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 6252fc2..c115b32 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -94,25 +94,26 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
folderView->setRootIsDecorated( true );
folderView->addColumn( tr( "Mailbox" ) );
layout->addWidget( folderView );
mailView = new QListView( view );
mailView->addColumn( "" );
mailView->addColumn( tr( "Subject" ),QListView::Manual );
mailView->addColumn( tr( "Sender" ),QListView::Manual );
mailView->addColumn( tr( "Size" ),QListView::Manual);
mailView->addColumn( tr( "Date" ));
mailView->setAllColumnsShowFocus(true);
- mailView->setSorting(-1);
+ mailView->setShowSortIndicator(true);
+ mailView->setSorting(4,false);
statusWidget = new StatusWidget( wrapperBox );
statusWidget->hide();
layout->addWidget( mailView );
layout->setStretchFactor( folderView, 1 );
layout->setStretchFactor( mailView, 2 );
slotAdjustLayout();
QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold);
QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold);
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index ce694d5..d5f9b7f 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -280,25 +280,25 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
}
delete menu;
}
void ViewMail::setMail(const RecMailP&mail )
{
m_recMail = mail;
m_mail[0] = mail->getFrom();
m_mail[1] = mail->getSubject();
- m_mail[3] = mail->getDate();
+ m_mail[3] = mail->getStringDate();
m_mail[4] = mail->Msgid();
m_mail2[0] = mail->To();
m_mail2[1] = mail->CC();
m_mail2[2] = mail->Bcc();
setText();
}
ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)