author | alwin <alwin> | 2004-03-08 03:06:39 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-08 03:06:39 (UTC) |
commit | 38301e81221e7e51cc67a5e366498a71df288263 (patch) (unidiff) | |
tree | 47cfc2c2bf399c7f8bec3be4007d4f69a4d0b07a /noncore/net/mail/libmailwrapper | |
parent | a3836842bfabc973f27f2686320f7a207c59b10a (diff) | |
download | opie-38301e81221e7e51cc67a5e366498a71df288263.zip opie-38301e81221e7e51cc67a5e366498a71df288263.tar.gz opie-38301e81221e7e51cc67a5e366498a71df288263.tar.bz2 |
when reply to a mail, a in-reply-to header will generated.
ToDo: setup the reference-list-header.
Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 29 |
4 files changed, 47 insertions, 2 deletions
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index bf91c63..96e0fd5 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -25,31 +25,33 @@ void RecMail::copy_old(const RecMail&old) | |||
25 | subject = old.subject; | 25 | subject = old.subject; |
26 | date = old.date; | 26 | date = old.date; |
27 | mbox = old.mbox; | 27 | mbox = old.mbox; |
28 | msg_id = old.msg_id; | 28 | msg_id = old.msg_id; |
29 | msg_size = old.msg_size; | 29 | msg_size = old.msg_size; |
30 | msg_number = old.msg_number; | 30 | msg_number = old.msg_number; |
31 | from = old.from; | 31 | from = old.from; |
32 | msg_flags = old.msg_flags; | 32 | msg_flags = old.msg_flags; |
33 | to = old.to; | 33 | to = old.to; |
34 | cc = old.cc; | 34 | cc = old.cc; |
35 | bcc = old.bcc; | 35 | bcc = old.bcc; |
36 | wrapper = old.wrapper; | 36 | wrapper = old.wrapper; |
37 | in_reply_to = old.in_reply_to; | ||
37 | } | 38 | } |
38 | 39 | ||
39 | void RecMail::init() | 40 | void RecMail::init() |
40 | { | 41 | { |
41 | to.clear(); | 42 | to.clear(); |
42 | cc.clear(); | 43 | cc.clear(); |
43 | bcc.clear(); | 44 | bcc.clear(); |
45 | in_reply_to.clear(); | ||
44 | wrapper = 0; | 46 | wrapper = 0; |
45 | } | 47 | } |
46 | 48 | ||
47 | void RecMail::setWrapper(AbstractMail*awrapper) | 49 | void RecMail::setWrapper(AbstractMail*awrapper) |
48 | { | 50 | { |
49 | wrapper = awrapper; | 51 | wrapper = awrapper; |
50 | } | 52 | } |
51 | 53 | ||
52 | AbstractMail* RecMail::Wrapper() | 54 | AbstractMail* RecMail::Wrapper() |
53 | { | 55 | { |
54 | return wrapper; | 56 | return wrapper; |
55 | } | 57 | } |
@@ -75,24 +77,35 @@ const QStringList&RecMail::CC()const | |||
75 | } | 77 | } |
76 | 78 | ||
77 | void RecMail::setBcc(const QStringList&list) | 79 | void RecMail::setBcc(const QStringList&list) |
78 | { | 80 | { |
79 | bcc = list; | 81 | bcc = list; |
80 | } | 82 | } |
81 | 83 | ||
82 | const QStringList& RecMail::Bcc()const | 84 | const QStringList& RecMail::Bcc()const |
83 | { | 85 | { |
84 | return bcc; | 86 | return bcc; |
85 | } | 87 | } |
86 | 88 | ||
89 | void RecMail::setInreply(const QStringList&list) | ||
90 | { | ||
91 | in_reply_to = list; | ||
92 | } | ||
93 | |||
94 | const QStringList& RecMail::Inreply()const | ||
95 | { | ||
96 | return in_reply_to; | ||
97 | } | ||
98 | |||
99 | |||
87 | RecPart::RecPart() | 100 | RecPart::RecPart() |
88 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) | 101 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) |
89 | { | 102 | { |
90 | m_Parameters.clear(); | 103 | m_Parameters.clear(); |
91 | m_poslist.clear(); | 104 | m_poslist.clear(); |
92 | } | 105 | } |
93 | 106 | ||
94 | RecPart::~RecPart() | 107 | RecPart::~RecPart() |
95 | { | 108 | { |
96 | } | 109 | } |
97 | 110 | ||
98 | void RecPart::setSize(unsigned int size) | 111 | void RecPart::setSize(unsigned int size) |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index b2047cb..1420f79 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -50,35 +50,37 @@ public: | |||
50 | void setReplyto(const QString&reply){replyto=reply;} | 50 | void setReplyto(const QString&reply){replyto=reply;} |
51 | const QString&Replyto()const{return replyto;} | 51 | const QString&Replyto()const{return replyto;} |
52 | void setMsgsize(int size){msg_size = size;} | 52 | void setMsgsize(int size){msg_size = size;} |
53 | const int Msgsize()const{return msg_size;} | 53 | const int Msgsize()const{return msg_size;} |
54 | 54 | ||
55 | 55 | ||
56 | void setTo(const QStringList&list); | 56 | void setTo(const QStringList&list); |
57 | const QStringList&To()const; | 57 | const QStringList&To()const; |
58 | void setCC(const QStringList&list); | 58 | void setCC(const QStringList&list); |
59 | const QStringList&CC()const; | 59 | const QStringList&CC()const; |
60 | void setBcc(const QStringList&list); | 60 | void setBcc(const QStringList&list); |
61 | const QStringList&Bcc()const; | 61 | const QStringList&Bcc()const; |
62 | void setInreply(const QStringList&list); | ||
63 | const QStringList&Inreply()const; | ||
62 | const QBitArray&getFlags()const{return msg_flags;} | 64 | const QBitArray&getFlags()const{return msg_flags;} |
63 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 65 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
64 | 66 | ||
65 | void setWrapper(AbstractMail*wrapper); | 67 | void setWrapper(AbstractMail*wrapper); |
66 | AbstractMail* Wrapper(); | 68 | AbstractMail* Wrapper(); |
67 | 69 | ||
68 | protected: | 70 | protected: |
69 | QString subject,date,from,mbox,msg_id,replyto; | 71 | QString subject,date,from,mbox,msg_id,replyto; |
70 | int msg_number,msg_size; | 72 | int msg_number,msg_size; |
71 | QBitArray msg_flags; | 73 | QBitArray msg_flags; |
72 | QStringList to,cc,bcc; | 74 | QStringList to,cc,bcc,in_reply_to; |
73 | AbstractMail*wrapper; | 75 | AbstractMail*wrapper; |
74 | void init(); | 76 | void init(); |
75 | void copy_old(const RecMail&old); | 77 | void copy_old(const RecMail&old); |
76 | }; | 78 | }; |
77 | 79 | ||
78 | typedef QMap<QString,QString> part_plist_t; | 80 | typedef QMap<QString,QString> part_plist_t; |
79 | 81 | ||
80 | class RecPart | 82 | class RecPart |
81 | { | 83 | { |
82 | protected: | 84 | protected: |
83 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; | 85 | QString m_type,m_subtype,m_identifier,m_encoding,m_description; |
84 | unsigned int m_lines,m_size; | 86 | unsigned int m_lines,m_size; |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index caaa3a2..3a9f97b 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h | |||
@@ -46,28 +46,31 @@ public: | |||
46 | const QString&getTo()const{ return to; } | 46 | const QString&getTo()const{ return to; } |
47 | void setTo( const QString&s ) { to = s; } | 47 | void setTo( const QString&s ) { to = s; } |
48 | const QString&getCC()const{ return cc; } | 48 | const QString&getCC()const{ return cc; } |
49 | void setCC( const QString&s ) { cc = s; } | 49 | void setCC( const QString&s ) { cc = s; } |
50 | const QString&getBCC()const { return bcc; } | 50 | const QString&getBCC()const { return bcc; } |
51 | void setBCC( const QString&s ) { bcc = s; } | 51 | void setBCC( const QString&s ) { bcc = s; } |
52 | const QString&getMessage()const { return message; } | 52 | const QString&getMessage()const { return message; } |
53 | void setMessage( const QString&s ) { message = s; } | 53 | void setMessage( const QString&s ) { message = s; } |
54 | const QString&getSubject()const { return subject; } | 54 | const QString&getSubject()const { return subject; } |
55 | void setSubject( const QString&s ) { subject = s; } | 55 | void setSubject( const QString&s ) { subject = s; } |
56 | const QString&getReply()const{ return reply; } | 56 | const QString&getReply()const{ return reply; } |
57 | void setReply( const QString&a ) { reply = a; } | 57 | void setReply( const QString&a ) { reply = a; } |
58 | void setInreply(const QStringList&list){m_in_reply_to = list;} | ||
59 | const QStringList&Inreply()const{return m_in_reply_to;} | ||
58 | 60 | ||
59 | private: | 61 | private: |
60 | QList<Attachment> attList; | 62 | QList<Attachment> attList; |
61 | QString name, mail, to, cc, bcc, reply, subject, message; | 63 | QString name, mail, to, cc, bcc, reply, subject, message; |
64 | QStringList m_in_reply_to; | ||
62 | }; | 65 | }; |
63 | 66 | ||
64 | class Folder : public QObject | 67 | class Folder : public QObject |
65 | { | 68 | { |
66 | Q_OBJECT | 69 | Q_OBJECT |
67 | 70 | ||
68 | public: | 71 | public: |
69 | Folder( const QString&init_name,const QString&sep ); | 72 | Folder( const QString&init_name,const QString&sep ); |
70 | const QString&getDisplayName()const { return nameDisplay; } | 73 | const QString&getDisplayName()const { return nameDisplay; } |
71 | const QString&getName()const { return name; } | 74 | const QString&getName()const { return name; } |
72 | const QString&getPrefix()const{return prefix; } | 75 | const QString&getPrefix()const{return prefix; } |
73 | virtual bool may_select()const{return true;} | 76 | virtual bool may_select()const{return true;} |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index d7a005e..63acfd5 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -140,24 +140,25 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) { | |||
140 | qDebug( "Parse success! %s",(*it).latin1()); | 140 | qDebug( "Parse success! %s",(*it).latin1()); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | return addresses; | 143 | return addresses; |
144 | } | 144 | } |
145 | 145 | ||
146 | mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { | 146 | mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { |
147 | mailimf_fields *fields; | 147 | mailimf_fields *fields; |
148 | mailimf_field *xmailer; | 148 | mailimf_field *xmailer; |
149 | mailimf_mailbox *sender=0,*fromBox=0; | 149 | mailimf_mailbox *sender=0,*fromBox=0; |
150 | mailimf_mailbox_list *from=0; | 150 | mailimf_mailbox_list *from=0; |
151 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; | 151 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; |
152 | clist*in_reply_to = 0; | ||
152 | char *subject = strdup( mail.getSubject().latin1() ); | 153 | char *subject = strdup( mail.getSubject().latin1() ); |
153 | int err; | 154 | int err; |
154 | 155 | ||
155 | sender = newMailbox( mail.getName(), mail.getMail() ); | 156 | sender = newMailbox( mail.getName(), mail.getMail() ); |
156 | if ( sender == NULL ) | 157 | if ( sender == NULL ) |
157 | goto err_free; | 158 | goto err_free; |
158 | 159 | ||
159 | fromBox = newMailbox( mail.getName(), mail.getMail() ); | 160 | fromBox = newMailbox( mail.getName(), mail.getMail() ); |
160 | if ( fromBox == NULL ) | 161 | if ( fromBox == NULL ) |
161 | goto err_free_sender; | 162 | goto err_free_sender; |
162 | 163 | ||
163 | from = mailimf_mailbox_list_new_empty(); | 164 | from = mailimf_mailbox_list_new_empty(); |
@@ -166,27 +167,53 @@ mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { | |||
166 | 167 | ||
167 | err = mailimf_mailbox_list_add( from, fromBox ); | 168 | err = mailimf_mailbox_list_add( from, fromBox ); |
168 | if ( err != MAILIMF_NO_ERROR ) | 169 | if ( err != MAILIMF_NO_ERROR ) |
169 | goto err_free_from; | 170 | goto err_free_from; |
170 | 171 | ||
171 | to = parseAddresses( mail.getTo() ); | 172 | to = parseAddresses( mail.getTo() ); |
172 | if ( to == NULL ) | 173 | if ( to == NULL ) |
173 | goto err_free_from; | 174 | goto err_free_from; |
174 | 175 | ||
175 | cc = parseAddresses( mail.getCC() ); | 176 | cc = parseAddresses( mail.getCC() ); |
176 | bcc = parseAddresses( mail.getBCC() ); | 177 | bcc = parseAddresses( mail.getBCC() ); |
177 | reply = parseAddresses( mail.getReply() ); | 178 | reply = parseAddresses( mail.getReply() ); |
179 | |||
180 | if (mail.Inreply().count()>0) { | ||
181 | in_reply_to = clist_new(); | ||
182 | char*c_reply; | ||
183 | unsigned int nsize = 0; | ||
184 | for (QStringList::ConstIterator it=mail.Inreply().begin(); | ||
185 | it != mail.Inreply().end();++it) { | ||
186 | /* yes! must be malloc! */ | ||
187 | if ((*it).isEmpty()) | ||
188 | continue; | ||
189 | QString h((*it)); | ||
190 | while (h.length()>0 && h[0]=='<') { | ||
191 | h.remove(0,1); | ||
192 | } | ||
193 | while (h.length()>0 && h[h.length()-1]=='>') { | ||
194 | h.remove(h.length()-1,1); | ||
195 | } | ||
196 | if (h.isEmpty()) continue; | ||
197 | nsize = strlen(h.latin1()); | ||
198 | c_reply = (char*)malloc( (nsize+1)*sizeof(char)); | ||
199 | memset(c_reply,0,nsize+1); | ||
200 | memcpy(c_reply,h.latin1(),nsize); | ||
201 | clist_append(in_reply_to,c_reply); | ||
202 | qDebug("In reply to: %s",c_reply); | ||
203 | } | ||
204 | } | ||
178 | 205 | ||
179 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, | 206 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, |
180 | NULL, NULL, subject ); | 207 | in_reply_to, NULL, subject ); |
181 | if ( fields == NULL ) | 208 | if ( fields == NULL ) |
182 | goto err_free_reply; | 209 | goto err_free_reply; |
183 | 210 | ||
184 | xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), | 211 | xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), |
185 | strdup( USER_AGENT ) ); | 212 | strdup( USER_AGENT ) ); |
186 | if ( xmailer == NULL ) | 213 | if ( xmailer == NULL ) |
187 | goto err_free_fields; | 214 | goto err_free_fields; |
188 | 215 | ||
189 | err = mailimf_fields_add( fields, xmailer ); | 216 | err = mailimf_fields_add( fields, xmailer ); |
190 | if ( err != MAILIMF_NO_ERROR ) | 217 | if ( err != MAILIMF_NO_ERROR ) |
191 | goto err_free_xmailer; | 218 | goto err_free_xmailer; |
192 | 219 | ||