-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.cpp | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.h | 18 |
2 files changed, 18 insertions, 5 deletions
diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp index 96d55e6..70a0ab5 100644 --- a/kmicromail/libmailwrapper/mailtypes.cpp +++ b/kmicromail/libmailwrapper/mailtypes.cpp | |||
@@ -1,97 +1,98 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | //#include <opie2/odebug.h> | 3 | //#include <opie2/odebug.h> |
4 | 4 | ||
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
6 | 6 | ||
7 | using namespace Opie::Core; | 7 | using namespace Opie::Core; |
8 | RecMail::RecMail() | 8 | RecMail::RecMail() |
9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) | 9 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) |
10 | { | 10 | { |
11 | init(); | 11 | init(); |
12 | } | 12 | } |
13 | 13 | ||
14 | RecMail::RecMail(const RecMail&old) | 14 | RecMail::RecMail(const RecMail&old) |
15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) | 15 | :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) |
16 | { | 16 | { |
17 | init(); | 17 | init(); |
18 | copy_old(old); | 18 | copy_old(old); |
19 | // odebug << "Copy constructor RecMail" << oendl; | 19 | // odebug << "Copy constructor RecMail" << oendl; |
20 | } | 20 | } |
21 | 21 | ||
22 | RecMail::~RecMail() | 22 | RecMail::~RecMail() |
23 | { | 23 | { |
24 | wrapper = 0; | 24 | wrapper = 0; |
25 | } | 25 | } |
26 | static bool stringCompareRec( const QString& s1, const QString& s2 ) | 26 | static bool stringCompareRec( const QString& s1, const QString& s2 ) |
27 | { | 27 | { |
28 | if ( s1.isEmpty() && s2.isEmpty() ) | 28 | if ( s1.isEmpty() && s2.isEmpty() ) |
29 | return true; | 29 | return true; |
30 | return s1 == s2; | 30 | return s1 == s2; |
31 | } | 31 | } |
32 | 32 | #if 0 | |
33 | const QString RecMail::MsgsizeString() const | 33 | QString RecMail::MsgsizeString() const |
34 | { | 34 | { |
35 | 35 | ||
36 | double s = msg_size; | 36 | double s = msg_size; |
37 | int w = 0; | 37 | int w = 0; |
38 | s/=1024; | 38 | s/=1024; |
39 | if (s>999.0) { | 39 | if (s>999.0) { |
40 | s/=1024.0; | 40 | s/=1024.0; |
41 | ++w; | 41 | ++w; |
42 | } | 42 | } |
43 | QString fsize = QString::number( s, 'f', 2 ); | 43 | QString fsize = QString::number( s, 'f', 2 ); |
44 | if ( w == 0 ) { | 44 | if ( w == 0 ) { |
45 | fsize += "kB" ; | 45 | fsize += "kB" ; |
46 | } else | 46 | } else |
47 | fsize += "MB" ; | 47 | fsize += "MB" ; |
48 | return fsize; | 48 | return fsize; |
49 | } | 49 | } |
50 | #endif | ||
50 | bool RecMail::isEqual( RecMail* r1 ) | 51 | bool RecMail::isEqual( RecMail* r1 ) |
51 | { | 52 | { |
52 | if ( !stringCompareRec( isodate, r1->isodate ) ) { | 53 | if ( !stringCompareRec( isodate, r1->isodate ) ) { |
53 | //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); | 54 | //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); |
54 | return false; | 55 | return false; |
55 | } | 56 | } |
56 | if ( !stringCompareRec( subject.left(40), r1->subject.left(40) ) ) { | 57 | if ( !stringCompareRec( subject.left(40), r1->subject.left(40) ) ) { |
57 | //qDebug("sub *%s* *%s*", subject.latin1(), r1->subject.latin1()); | 58 | //qDebug("sub *%s* *%s*", subject.latin1(), r1->subject.latin1()); |
58 | return false; | 59 | return false; |
59 | } | 60 | } |
60 | 61 | ||
61 | //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); | 62 | //qDebug("date *%s* *%s* ", isodate.latin1(), r1->isodate.latin1()); |
62 | if ( !stringCompareRec( from.left(40), r1->from.left(40)) ) { | 63 | if ( !stringCompareRec( from.left(40), r1->from.left(40)) ) { |
63 | if ( r1->from.find ( from ) < 0 ) { | 64 | if ( r1->from.find ( from ) < 0 ) { |
64 | if ( !stringCompareRec( from.simplifyWhiteSpace ().left(40), r1->from.simplifyWhiteSpace ().left(40)) ) { | 65 | if ( !stringCompareRec( from.simplifyWhiteSpace ().left(40), r1->from.simplifyWhiteSpace ().left(40)) ) { |
65 | //qDebug("from *%s* *%s* ", from.left(40).latin1(), r1->from.left(20).latin1()); | 66 | //qDebug("from *%s* *%s* ", from.left(40).latin1(), r1->from.left(20).latin1()); |
66 | return false; | 67 | return false; |
67 | } | 68 | } |
68 | } | 69 | } |
69 | } | 70 | } |
70 | 71 | ||
71 | return true; | 72 | return true; |
72 | } | 73 | } |
73 | void RecMail::copy_old(const RecMail&old) | 74 | void RecMail::copy_old(const RecMail&old) |
74 | { | 75 | { |
75 | subject = old.subject; | 76 | subject = old.subject; |
76 | date = old.date; | 77 | date = old.date; |
77 | mbox = old.mbox; | 78 | mbox = old.mbox; |
78 | msg_id = old.msg_id; | 79 | msg_id = old.msg_id; |
79 | msg_size = old.msg_size; | 80 | msg_size = old.msg_size; |
80 | msg_number = old.msg_number; | 81 | msg_number = old.msg_number; |
81 | from = old.from; | 82 | from = old.from; |
82 | msg_flags = old.msg_flags; | 83 | msg_flags = old.msg_flags; |
83 | to = old.to; | 84 | to = old.to; |
84 | cc = old.cc; | 85 | cc = old.cc; |
85 | bcc = old.bcc; | 86 | bcc = old.bcc; |
86 | wrapper = old.wrapper; | 87 | wrapper = old.wrapper; |
87 | in_reply_to = old.in_reply_to; | 88 | in_reply_to = old.in_reply_to; |
88 | references = old.references; | 89 | references = old.references; |
89 | replyto = old.replyto; | 90 | replyto = old.replyto; |
90 | } | 91 | } |
91 | 92 | ||
92 | void RecMail::init() | 93 | void RecMail::init() |
93 | { | 94 | { |
94 | to.clear(); | 95 | to.clear(); |
95 | cc.clear(); | 96 | cc.clear(); |
96 | bcc.clear(); | 97 | bcc.clear(); |
97 | in_reply_to.clear(); | 98 | in_reply_to.clear(); |
diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h index 39c0bac..97f10d7 100644 --- a/kmicromail/libmailwrapper/mailtypes.h +++ b/kmicromail/libmailwrapper/mailtypes.h | |||
@@ -10,99 +10,111 @@ | |||
10 | 10 | ||
11 | #include <opie2/osmartpointer.h> | 11 | #include <opie2/osmartpointer.h> |
12 | 12 | ||
13 | #include <qbitarray.h> | 13 | #include <qbitarray.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qstringlist.h> | 15 | #include <qstringlist.h> |
16 | #include <qmap.h> | 16 | #include <qmap.h> |
17 | #include <qvaluelist.h> | 17 | #include <qvaluelist.h> |
18 | 18 | ||
19 | class AbstractMail; | 19 | class AbstractMail; |
20 | /* a class to describe mails in a mailbox */ | 20 | /* a class to describe mails in a mailbox */ |
21 | /* Attention! | 21 | /* Attention! |
22 | From programmers point of view it would make sense to | 22 | From programmers point of view it would make sense to |
23 | store the mail body into this class, too. | 23 | store the mail body into this class, too. |
24 | But: not from the point of view of the device. | 24 | But: not from the point of view of the device. |
25 | Mailbodies can be real large. So we request them when | 25 | Mailbodies can be real large. So we request them when |
26 | needed from the mail-wrapper class direct from the server itself | 26 | needed from the mail-wrapper class direct from the server itself |
27 | (imap) or from a file-based cache (pop3?) | 27 | (imap) or from a file-based cache (pop3?) |
28 | So there is no interface "const QString&body()" but you should | 28 | So there is no interface "const QString&body()" but you should |
29 | make a request to the mailwrapper with this class as parameter to | 29 | make a request to the mailwrapper with this class as parameter to |
30 | get the body. Same words for the attachments. | 30 | get the body. Same words for the attachments. |
31 | */ | 31 | */ |
32 | class RecMail:public Opie::Core::ORefCount | 32 | class RecMail:public Opie::Core::ORefCount |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | RecMail(); | 35 | RecMail(); |
36 | RecMail(const RecMail&old); | 36 | RecMail(const RecMail&old); |
37 | virtual ~RecMail(); | 37 | virtual ~RecMail(); |
38 | bool isEqual( RecMail* r1 ); | 38 | bool isEqual( RecMail* r1 ); |
39 | 39 | ||
40 | const unsigned int getNumber()const{return msg_number;} | 40 | const unsigned int getNumber()const{return msg_number;} |
41 | void setNumber(unsigned int number){msg_number=number;} | 41 | void setNumber(unsigned int number){msg_number=number;} |
42 | const QString&getDate()const{ return date; } | 42 | const QString&getDate()const{ return date; } |
43 | void setDate( const QString&a ) { date = a; } | 43 | void setDate( const QString&a ) { date = a; } |
44 | const QString&getIsoDate()const{ return isodate; } | 44 | const QString&getIsoDate()const{ return isodate; } |
45 | void setIsoDate( const QString&a ) { isodate = a; } | 45 | void setIsoDate( const QString&a ) { isodate = a; } |
46 | const QString&getFrom()const{ return from; } | 46 | const QString&getFrom()const{ return from; } |
47 | void setFrom( const QString&a ) { from = a; } | 47 | void setFrom( const QString&a ) { from = a; } |
48 | const QString&getSubject()const { return subject; } | 48 | const QString&getSubject()const { return subject; } |
49 | void setSubject( const QString&s ) { subject = s; } | 49 | void setSubject( const QString&s ) { subject = s; } |
50 | const QString&getMbox()const{return mbox;} | 50 | const QString&getMbox()const{return mbox;} |
51 | void setMbox(const QString&box){mbox = box;} | 51 | void setMbox(const QString&box){mbox = box;} |
52 | void setMsgid(const QString&id){msg_id=id;} | 52 | void setMsgid(const QString&id){msg_id=id;} |
53 | const QString&Msgid()const{return msg_id;} | 53 | const QString&Msgid()const{return msg_id;} |
54 | void setReplyto(const QString&reply){replyto=reply;} | 54 | void setReplyto(const QString&reply){replyto=reply;} |
55 | const QString&Replyto()const{return replyto;} | 55 | const QString&Replyto()const{return replyto;} |
56 | void setMsgsize(unsigned int size){msg_size = size;} | 56 | void setMsgsize(unsigned int size){msg_size = size;} |
57 | const unsigned int Msgsize()const{return msg_size;} | 57 | const unsigned int Msgsize()const{return msg_size;} |
58 | const QString MsgsizeString()const; | 58 | const QString MsgsizeString()const { |
59 | 59 | double s = msg_size; | |
60 | 60 | int w = 0; | |
61 | s/=1024; | ||
62 | if (s>999.0) { | ||
63 | s/=1024.0; | ||
64 | ++w; | ||
65 | } | ||
66 | QString fsize = QString::number( s, 'f', 2 ); | ||
67 | if ( w == 0 ) { | ||
68 | fsize += "kB" ; | ||
69 | } else | ||
70 | fsize += "MB" ; | ||
71 | return fsize; | ||
72 | }; | ||
61 | void setTo(const QStringList&list); | 73 | void setTo(const QStringList&list); |
62 | const QStringList&To()const; | 74 | const QStringList&To()const; |
63 | void setCC(const QStringList&list); | 75 | void setCC(const QStringList&list); |
64 | const QStringList&CC()const; | 76 | const QStringList&CC()const; |
65 | void setBcc(const QStringList&list); | 77 | void setBcc(const QStringList&list); |
66 | const QStringList&Bcc()const; | 78 | const QStringList&Bcc()const; |
67 | void setInreply(const QStringList&list); | 79 | void setInreply(const QStringList&list); |
68 | const QStringList&Inreply()const; | 80 | const QStringList&Inreply()const; |
69 | void setReferences(const QStringList&list); | 81 | void setReferences(const QStringList&list); |
70 | const QStringList&References()const; | 82 | const QStringList&References()const; |
71 | 83 | ||
72 | const QBitArray&getFlags()const{return msg_flags;} | 84 | const QBitArray&getFlags()const{return msg_flags;} |
73 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 85 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
74 | 86 | ||
75 | void setWrapper(AbstractMail*wrapper); | 87 | void setWrapper(AbstractMail*wrapper); |
76 | AbstractMail* Wrapper(); | 88 | AbstractMail* Wrapper(); |
77 | // public for debugging | 89 | // public for debugging |
78 | QString subject,date,isodate,from,mbox,msg_id,replyto; | 90 | QString subject,date,isodate,from,mbox,msg_id,replyto; |
79 | 91 | ||
80 | protected: | 92 | protected: |
81 | //QString subject,date,isodate,from,mbox,msg_id,replyto; | 93 | //QString subject,date,isodate,from,mbox,msg_id,replyto; |
82 | unsigned int msg_number,msg_size; | 94 | unsigned int msg_number,msg_size; |
83 | QBitArray msg_flags; | 95 | QBitArray msg_flags; |
84 | QStringList to,cc,bcc,in_reply_to,references; | 96 | QStringList to,cc,bcc,in_reply_to,references; |
85 | AbstractMail*wrapper; | 97 | AbstractMail*wrapper; |
86 | void init(); | 98 | void init(); |
87 | void copy_old(const RecMail&old); | 99 | void copy_old(const RecMail&old); |
88 | }; | 100 | }; |
89 | 101 | ||
90 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; | 102 | typedef Opie::Core::OSmartPointer<RecMail> RecMailP; |
91 | typedef QMap<QString,QString> part_plist_t; | 103 | typedef QMap<QString,QString> part_plist_t; |
92 | 104 | ||
93 | class RecPart:public Opie::Core::ORefCount | 105 | class RecPart:public Opie::Core::ORefCount |
94 | { | 106 | { |
95 | protected: | 107 | protected: |
96 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 108 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
97 | unsigned int m_lines,m_size; | 109 | unsigned int m_lines,m_size; |
98 | part_plist_t m_Parameters; | 110 | part_plist_t m_Parameters; |
99 | /* describes the position in the mail */ | 111 | /* describes the position in the mail */ |
100 | QValueList<int> m_poslist; | 112 | QValueList<int> m_poslist; |
101 | 113 | ||
102 | public: | 114 | public: |
103 | RecPart(); | 115 | RecPart(); |
104 | RecPart(const RecPart&); | 116 | RecPart(const RecPart&); |
105 | virtual ~RecPart(); | 117 | virtual ~RecPart(); |
106 | 118 | ||
107 | const QString&Type()const; | 119 | const QString&Type()const; |
108 | void setType(const QString&type); | 120 | void setType(const QString&type); |