author | zautrix <zautrix> | 2005-01-24 18:05:48 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-24 18:05:48 (UTC) |
commit | 77f93c632b66b5c8d92e4c63330362272ca1fc40 (patch) (side-by-side diff) | |
tree | 31f28656062c899b5368f13ab594ff6fa5c657fa /kmicromail/libmailwrapper | |
parent | 6c89efd80c1e94a0c070025d07c7a4c656f2a81e (diff) | |
download | kdepimpi-77f93c632b66b5c8d92e4c63330362272ca1fc40.zip kdepimpi-77f93c632b66b5c8d92e4c63330362272ca1fc40.tar.gz kdepimpi-77f93c632b66b5c8d92e4c63330362272ca1fc40.tar.bz2 |
mail fixes
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.cpp | 17 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp index 89150ad..96d55e6 100644 --- a/kmicromail/libmailwrapper/mailtypes.cpp +++ b/kmicromail/libmailwrapper/mailtypes.cpp @@ -1,224 +1,241 @@ #include "mailtypes.h" //#include <opie2/odebug.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) { init(); } RecMail::RecMail(const RecMail&old) :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) { init(); copy_old(old); // odebug << "Copy constructor RecMail" << oendl; } RecMail::~RecMail() { wrapper = 0; } static bool stringCompareRec( const QString& s1, const QString& s2 ) { if ( s1.isEmpty() && s2.isEmpty() ) return true; return s1 == s2; } +const QString RecMail::MsgsizeString() const +{ + + double s = msg_size; + int w = 0; + s/=1024; + if (s>999.0) { + s/=1024.0; + ++w; + } + QString fsize = QString::number( s, 'f', 2 ); + if ( w == 0 ) { + fsize += "kB" ; + } else + fsize += "MB" ; + return fsize; +} bool RecMail::isEqual( RecMail* r1 ) { if ( !stringCompareRec( isodate, r1->isodate ) ) { //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); return false; } if ( !stringCompareRec( subject.left(40), r1->subject.left(40) ) ) { //qDebug("sub *%s* *%s*", subject.latin1(), r1->subject.latin1()); return false; } //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); if ( !stringCompareRec( from.left(40), r1->from.left(40)) ) { if ( r1->from.find ( from ) < 0 ) { if ( !stringCompareRec( from.simplifyWhiteSpace ().left(40), r1->from.simplifyWhiteSpace ().left(40)) ) { //qDebug("from *%s* *%s* ", from.left(40).latin1(), r1->from.left(20).latin1()); return false; } } } return true; } void RecMail::copy_old(const RecMail&old) { subject = old.subject; 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; references = old.references; replyto = old.replyto; } void RecMail::init() { to.clear(); cc.clear(); bcc.clear(); in_reply_to.clear(); references.clear(); wrapper = 0; } void RecMail::setWrapper(AbstractMail*awrapper) { wrapper = awrapper; } AbstractMail* RecMail::Wrapper() { return wrapper; } void RecMail::setTo(const QStringList&list) { to = list; } const QStringList&RecMail::To()const { return to; } void RecMail::setCC(const QStringList&list) { cc = list; } const QStringList&RecMail::CC()const { return cc; } void RecMail::setBcc(const QStringList&list) { bcc = list; } const QStringList& RecMail::Bcc()const { return bcc; } void RecMail::setInreply(const QStringList&list) { in_reply_to = list; } const QStringList& RecMail::Inreply()const { return in_reply_to; } void RecMail::setReferences(const QStringList&list) { references = list; } const QStringList& RecMail::References()const { return references; } RecPart::RecPart() : Opie::Core::ORefCount(), m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) { m_Parameters.clear(); m_poslist.clear(); } RecPart::RecPart(const RecPart&old) : Opie::Core::ORefCount(), m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) { m_type = old.m_type; m_subtype = old.m_subtype; m_identifier = old.m_identifier; m_encoding = old.m_encoding; m_description = old.m_description; m_lines = old.m_lines; m_size = old.m_size; m_Parameters = old.m_Parameters; m_poslist = old.m_poslist; // odebug << "RecPart copy constructor" << oendl; } RecPart::~RecPart() { } void RecPart::setSize(unsigned int size) { m_size = size; } const unsigned int RecPart::Size()const { return m_size; } void RecPart::setLines(unsigned int lines) { m_lines = lines; } const unsigned int RecPart::Lines()const { return m_lines; } const QString& RecPart::Type()const { return m_type; } void RecPart::setType(const QString&type) { m_type = type; } const QString& RecPart::Subtype()const { return m_subtype; } void RecPart::setSubtype(const QString&subtype) { m_subtype = subtype; } const QString& RecPart::Identifier()const { return m_identifier; } void RecPart::setIdentifier(const QString&identifier) { m_identifier = identifier; } const QString& RecPart::Encoding()const { diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h index 32d92c0..39c0bac 100644 --- a/kmicromail/libmailwrapper/mailtypes.h +++ b/kmicromail/libmailwrapper/mailtypes.h @@ -1,214 +1,215 @@ #ifndef __MAIL_TYPES_H #define __MAIL_TYPES_H #define FLAG_ANSWERED 0 #define FLAG_FLAGGED 1 #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> 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(); bool isEqual( RecMail* r1 ); 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&getIsoDate()const{ return isodate; } void setIsoDate( const QString&a ) { isodate = 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;} + const QString MsgsizeString()const; void setTo(const QStringList&list); const QStringList&To()const; void setCC(const QStringList&list); const QStringList&CC()const; void setBcc(const QStringList&list); 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(); // public for debugging QString subject,date,isodate,from,mbox,msg_id,replyto; protected: //QString subject,date,isodate,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); }; 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 */ QValueList<int> m_poslist; public: RecPart(); RecPart(const RecPart&); virtual ~RecPart(); const QString&Type()const; void setType(const QString&type); const QString&Subtype()const; void setSubtype(const QString&subtype); const QString&Identifier()const; void setIdentifier(const QString&identifier); const QString&Encoding()const; void setEncoding(const QString&encoding); const QString&Description()const; void setDescription(const QString&desc); void setLines(unsigned int lines); const unsigned int Lines()const; void setSize(unsigned int size); const unsigned int Size()const; void setParameters(const part_plist_t&list); const part_plist_t&Parameters()const; void addParameter(const QString&key,const QString&value); const QString searchParamter(const QString&key)const; void setPositionlist(const QValueList<int>&poslist); const QValueList<int>& Positionlist()const; }; typedef Opie::Core::OSmartPointer<RecPart> RecPartP; class RecBody:public Opie::Core::ORefCount { protected: QString m_BodyText; QString mCharset; QValueList<RecPartP> m_PartsList; RecPartP m_description; public: RecBody(); RecBody(const RecBody&old); virtual ~RecBody(); void setBodytext(const QString&); const QString& Bodytext()const; void setCharset(const QString&); QString getCharset()const; void setDescription(const RecPartP&des); const RecPartP& Description()const; void setParts(const QValueList<RecPartP>&parts); const QValueList<RecPartP>& Parts()const; void addPart(const RecPartP&part); }; typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; class encodedString { public: encodedString(); /* creates an new content string. it makes a deep copy of it! */ encodedString(const char*nContent,unsigned int length); /* Take over the nContent. Means: it will just copy the pointer, not the content. so make sure: No one else frees the string, the string has allocated with malloc for compatibility with c-based libs */ encodedString(char*nContent,unsigned int nSize); /* copy construkor - makes ALWAYS a deep copy!!!! */ encodedString(const encodedString&old); /* assign operator - makes ALWAYS a deep copy!!!! */ encodedString& operator=(const encodedString&old); /* destructor - cleans the content */ virtual ~encodedString(); /* returns a pointer to the content - do not delete yoursel! */ const char*Content()const; /* returns the lengths of the content 'cause it must not be a null-terminated string! */ const int Length()const; /* makes a deep copy of nContent! */ void setContent(const char*nContent,int nSize); /* Take over the nContent. Means: it will just copy the pointer, not the content. so make sure: No one else frees the string, the string has allocated with malloc for compatibility with c-based libs */ void setContent(char*nContent,int nSize); protected: char * content; unsigned int size; void init(); void copy_old(const encodedString&old); void clean(); }; struct folderStat { unsigned int message_count; unsigned int message_unseen; unsigned int message_recent; folderStat&operator=(const folderStat&old); }; #endif |