-rw-r--r-- | noncore/net/mail/genericwrapper.cpp | 47 | ||||
-rw-r--r-- | noncore/net/mail/genericwrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 47 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.h | 2 |
4 files changed, 78 insertions, 20 deletions
diff --git a/noncore/net/mail/genericwrapper.cpp b/noncore/net/mail/genericwrapper.cpp index bef6ae5..5de9299 100644 --- a/noncore/net/mail/genericwrapper.cpp +++ b/noncore/net/mail/genericwrapper.cpp | |||
@@ -110,91 +110,120 @@ QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | |||
110 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 110 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
111 | enc = "quoted-printable"; | 111 | enc = "quoted-printable"; |
112 | break; | 112 | break; |
113 | case MAILMIME_MECHANISM_BASE64: | 113 | case MAILMIME_MECHANISM_BASE64: |
114 | enc = "base64"; | 114 | enc = "base64"; |
115 | break; | 115 | break; |
116 | case MAILMIME_MECHANISM_TOKEN: | 116 | case MAILMIME_MECHANISM_TOKEN: |
117 | default: | 117 | default: |
118 | if (aEnc->enc_token) { | 118 | if (aEnc->enc_token) { |
119 | enc = QString(aEnc->enc_token); | 119 | enc = QString(aEnc->enc_token); |
120 | } | 120 | } |
121 | break; | 121 | break; |
122 | } | 122 | } |
123 | return enc; | 123 | return enc; |
124 | } | 124 | } |
125 | 125 | ||
126 | void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rec) | 126 | void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
127 | { | 127 | { |
128 | if (current_rec >= 10) { | 128 | if (current_rec >= 10) { |
129 | qDebug("too deep recursion!"); | 129 | qDebug("too deep recursion!"); |
130 | } | 130 | } |
131 | if (!message || !mime) { | 131 | if (!message || !mime) { |
132 | return; | 132 | return; |
133 | } | 133 | } |
134 | int r; | 134 | int r; |
135 | char*data = 0; | 135 | char*data = 0; |
136 | size_t len; | 136 | size_t len; |
137 | clistiter * cur = 0; | 137 | clistiter * cur = 0; |
138 | QString b; | 138 | QString b; |
139 | RecPart part; | 139 | RecPart part; |
140 | 140 | ||
141 | //current_count; | ||
142 | |||
141 | switch (mime->mm_type) { | 143 | switch (mime->mm_type) { |
142 | case MAILMIME_SINGLE: | 144 | case MAILMIME_SINGLE: |
145 | { | ||
146 | QValueList<int>countlist = recList; | ||
147 | countlist.append(current_count); | ||
143 | r = mailmessage_fetch_section(message,mime,&data,&len); | 148 | r = mailmessage_fetch_section(message,mime,&data,&len); |
144 | part.setSize(len); | 149 | part.setSize(len); |
150 | part.setPositionlist(countlist); | ||
151 | b = gen_attachment_id(); | ||
152 | part.setIdentifier(b); | ||
145 | fillSingleBody(part,message,mime); | 153 | fillSingleBody(part,message,mime); |
146 | if (part.Type()=="text" && target.Bodytext().isNull()) { | 154 | if (part.Type()=="text" && target.Bodytext().isNull()) { |
147 | encodedString*r = new encodedString(); | 155 | encodedString*r = new encodedString(); |
148 | r->setContent(data,len); | 156 | r->setContent(data,len); |
149 | encodedString*res = decode_String(r,part.Encoding()); | 157 | encodedString*res = decode_String(r,part.Encoding()); |
150 | b = QString(res->Content()); | 158 | b = QString(res->Content()); |
151 | delete r; | 159 | delete r; |
152 | delete res; | 160 | delete res; |
153 | target.setBodytext(b); | 161 | target.setBodytext(b); |
154 | target.setDescription(part); | 162 | target.setDescription(part); |
155 | } else { | 163 | } else { |
156 | b = gen_attachment_id(); | ||
157 | part.setIdentifier(b); | ||
158 | bodyCache[b]=new encodedString(data,len); | 164 | bodyCache[b]=new encodedString(data,len); |
159 | target.addPart(part); | 165 | target.addPart(part); |
160 | } | 166 | } |
161 | break; | 167 | } |
168 | break; | ||
162 | case MAILMIME_MULTIPLE: | 169 | case MAILMIME_MULTIPLE: |
170 | { | ||
171 | unsigned int ccount = current_count; | ||
163 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 172 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
164 | traverseBody(target,message, (mailmime*)clist_content(cur),current_rec+1); | 173 | traverseBody(target,message, (mailmime*)clist_content(cur),recList,current_rec+1,ccount); |
174 | ++ccount; | ||
165 | } | 175 | } |
166 | break; | 176 | } |
177 | break; | ||
167 | case MAILMIME_MESSAGE: | 178 | case MAILMIME_MESSAGE: |
179 | { | ||
180 | QValueList<int>countlist = recList; | ||
181 | countlist.append(current_count); | ||
182 | /* the own header is always at recursion 0 - we don't need that */ | ||
183 | if (current_rec > 0) { | ||
184 | part.setPositionlist(countlist); | ||
185 | r = mailmessage_fetch_section(message,mime,&data,&len); | ||
186 | part.setSize(len); | ||
187 | part.setPositionlist(countlist); | ||
188 | b = gen_attachment_id(); | ||
189 | part.setIdentifier(b); | ||
190 | part.setType("message"); | ||
191 | part.setSubtype("rfc822"); | ||
192 | bodyCache[b]=new encodedString(data,len); | ||
193 | target.addPart(part); | ||
194 | } | ||
168 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 195 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
169 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,current_rec+1); | 196 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
170 | } | 197 | } |
171 | break; | 198 | } |
199 | break; | ||
172 | } | 200 | } |
173 | } | 201 | } |
174 | 202 | ||
175 | RecBody Genericwrapper::parseMail( mailmessage * msg ) | 203 | RecBody Genericwrapper::parseMail( mailmessage * msg ) |
176 | { | 204 | { |
177 | int err = MAILIMF_NO_ERROR; | 205 | int err = MAILIMF_NO_ERROR; |
178 | mailmime_single_fields fields; | 206 | mailmime_single_fields fields; |
179 | /* is bound to msg and will be freed there */ | 207 | /* is bound to msg and will be freed there */ |
180 | mailmime * mime=0; | 208 | mailmime * mime=0; |
181 | RecBody body; | 209 | RecBody body; |
182 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 210 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
183 | err = mailmessage_get_bodystructure(msg,&mime); | 211 | err = mailmessage_get_bodystructure(msg,&mime); |
184 | traverseBody(body,msg,mime); | 212 | QValueList<int>recList; |
213 | traverseBody(body,msg,mime,recList); | ||
185 | return body; | 214 | return body; |
186 | } | 215 | } |
187 | 216 | ||
188 | RecMail *Genericwrapper::parseHeader( const char *header ) | 217 | RecMail *Genericwrapper::parseHeader( const char *header ) |
189 | { | 218 | { |
190 | int err = MAILIMF_NO_ERROR; | 219 | int err = MAILIMF_NO_ERROR; |
191 | size_t curTok = 0; | 220 | size_t curTok = 0; |
192 | RecMail *mail = new RecMail(); | 221 | RecMail *mail = new RecMail(); |
193 | mailimf_fields *fields = 0; | 222 | mailimf_fields *fields = 0; |
194 | mailimf_references * refs = 0; | 223 | mailimf_references * refs = 0; |
195 | mailimf_keywords*keys = 0; | 224 | mailimf_keywords*keys = 0; |
196 | QString status; | 225 | QString status; |
197 | QString value; | 226 | QString value; |
198 | QBitArray mFlags(7); | 227 | QBitArray mFlags(7); |
199 | 228 | ||
200 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 229 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
diff --git a/noncore/net/mail/genericwrapper.h b/noncore/net/mail/genericwrapper.h index 54d6ea9..c00d864 100644 --- a/noncore/net/mail/genericwrapper.h +++ b/noncore/net/mail/genericwrapper.h | |||
@@ -32,28 +32,28 @@ public: | |||
32 | virtual ~Genericwrapper(); | 32 | virtual ~Genericwrapper(); |
33 | 33 | ||
34 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 34 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
35 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 35 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
37 | virtual void cleanMimeCache(); | 37 | virtual void cleanMimeCache(); |
38 | 38 | ||
39 | protected: | 39 | protected: |
40 | RecMail *parseHeader( const char *header ); | 40 | RecMail *parseHeader( const char *header ); |
41 | RecBody parseMail( mailmessage * msg ); | 41 | RecBody parseMail( mailmessage * msg ); |
42 | QString parseMailboxList( mailimf_mailbox_list *list ); | 42 | QString parseMailboxList( mailimf_mailbox_list *list ); |
43 | QString parseMailbox( mailimf_mailbox *box ); | 43 | QString parseMailbox( mailimf_mailbox *box ); |
44 | QString parseGroup( mailimf_group *group ); | 44 | QString parseGroup( mailimf_group *group ); |
45 | QString parseAddressList( mailimf_address_list *list ); | 45 | QString parseAddressList( mailimf_address_list *list ); |
46 | QString parseDateTime( mailimf_date_time *date ); | 46 | QString parseDateTime( mailimf_date_time *date ); |
47 | 47 | ||
48 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); | 48 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=0); |
49 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); | 49 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); |
50 | static void fillParameters(RecPart&target,clist*parameters); | 50 | static void fillParameters(RecPart&target,clist*parameters); |
51 | static QString getencoding(mailmime_mechanism*aEnc); | 51 | static QString getencoding(mailmime_mechanism*aEnc); |
52 | virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); | 52 | virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); |
53 | 53 | ||
54 | QString msgTempName; | 54 | QString msgTempName; |
55 | unsigned int last_msg_id; | 55 | unsigned int last_msg_id; |
56 | QMap<QString,encodedString*> bodyCache; | 56 | QMap<QString,encodedString*> bodyCache; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | #endif | 59 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index bef6ae5..5de9299 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -110,91 +110,120 @@ QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) | |||
110 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: | 110 | case MAILMIME_MECHANISM_QUOTED_PRINTABLE: |
111 | enc = "quoted-printable"; | 111 | enc = "quoted-printable"; |
112 | break; | 112 | break; |
113 | case MAILMIME_MECHANISM_BASE64: | 113 | case MAILMIME_MECHANISM_BASE64: |
114 | enc = "base64"; | 114 | enc = "base64"; |
115 | break; | 115 | break; |
116 | case MAILMIME_MECHANISM_TOKEN: | 116 | case MAILMIME_MECHANISM_TOKEN: |
117 | default: | 117 | default: |
118 | if (aEnc->enc_token) { | 118 | if (aEnc->enc_token) { |
119 | enc = QString(aEnc->enc_token); | 119 | enc = QString(aEnc->enc_token); |
120 | } | 120 | } |
121 | break; | 121 | break; |
122 | } | 122 | } |
123 | return enc; | 123 | return enc; |
124 | } | 124 | } |
125 | 125 | ||
126 | void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rec) | 126 | void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) |
127 | { | 127 | { |
128 | if (current_rec >= 10) { | 128 | if (current_rec >= 10) { |
129 | qDebug("too deep recursion!"); | 129 | qDebug("too deep recursion!"); |
130 | } | 130 | } |
131 | if (!message || !mime) { | 131 | if (!message || !mime) { |
132 | return; | 132 | return; |
133 | } | 133 | } |
134 | int r; | 134 | int r; |
135 | char*data = 0; | 135 | char*data = 0; |
136 | size_t len; | 136 | size_t len; |
137 | clistiter * cur = 0; | 137 | clistiter * cur = 0; |
138 | QString b; | 138 | QString b; |
139 | RecPart part; | 139 | RecPart part; |
140 | 140 | ||
141 | //current_count; | ||
142 | |||
141 | switch (mime->mm_type) { | 143 | switch (mime->mm_type) { |
142 | case MAILMIME_SINGLE: | 144 | case MAILMIME_SINGLE: |
145 | { | ||
146 | QValueList<int>countlist = recList; | ||
147 | countlist.append(current_count); | ||
143 | r = mailmessage_fetch_section(message,mime,&data,&len); | 148 | r = mailmessage_fetch_section(message,mime,&data,&len); |
144 | part.setSize(len); | 149 | part.setSize(len); |
150 | part.setPositionlist(countlist); | ||
151 | b = gen_attachment_id(); | ||
152 | part.setIdentifier(b); | ||
145 | fillSingleBody(part,message,mime); | 153 | fillSingleBody(part,message,mime); |
146 | if (part.Type()=="text" && target.Bodytext().isNull()) { | 154 | if (part.Type()=="text" && target.Bodytext().isNull()) { |
147 | encodedString*r = new encodedString(); | 155 | encodedString*r = new encodedString(); |
148 | r->setContent(data,len); | 156 | r->setContent(data,len); |
149 | encodedString*res = decode_String(r,part.Encoding()); | 157 | encodedString*res = decode_String(r,part.Encoding()); |
150 | b = QString(res->Content()); | 158 | b = QString(res->Content()); |
151 | delete r; | 159 | delete r; |
152 | delete res; | 160 | delete res; |
153 | target.setBodytext(b); | 161 | target.setBodytext(b); |
154 | target.setDescription(part); | 162 | target.setDescription(part); |
155 | } else { | 163 | } else { |
156 | b = gen_attachment_id(); | ||
157 | part.setIdentifier(b); | ||
158 | bodyCache[b]=new encodedString(data,len); | 164 | bodyCache[b]=new encodedString(data,len); |
159 | target.addPart(part); | 165 | target.addPart(part); |
160 | } | 166 | } |
161 | break; | 167 | } |
168 | break; | ||
162 | case MAILMIME_MULTIPLE: | 169 | case MAILMIME_MULTIPLE: |
170 | { | ||
171 | unsigned int ccount = current_count; | ||
163 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { | 172 | for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { |
164 | traverseBody(target,message, (mailmime*)clist_content(cur),current_rec+1); | 173 | traverseBody(target,message, (mailmime*)clist_content(cur),recList,current_rec+1,ccount); |
174 | ++ccount; | ||
165 | } | 175 | } |
166 | break; | 176 | } |
177 | break; | ||
167 | case MAILMIME_MESSAGE: | 178 | case MAILMIME_MESSAGE: |
179 | { | ||
180 | QValueList<int>countlist = recList; | ||
181 | countlist.append(current_count); | ||
182 | /* the own header is always at recursion 0 - we don't need that */ | ||
183 | if (current_rec > 0) { | ||
184 | part.setPositionlist(countlist); | ||
185 | r = mailmessage_fetch_section(message,mime,&data,&len); | ||
186 | part.setSize(len); | ||
187 | part.setPositionlist(countlist); | ||
188 | b = gen_attachment_id(); | ||
189 | part.setIdentifier(b); | ||
190 | part.setType("message"); | ||
191 | part.setSubtype("rfc822"); | ||
192 | bodyCache[b]=new encodedString(data,len); | ||
193 | target.addPart(part); | ||
194 | } | ||
168 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { | 195 | if (mime->mm_data.mm_message.mm_msg_mime != NULL) { |
169 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,current_rec+1); | 196 | traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); |
170 | } | 197 | } |
171 | break; | 198 | } |
199 | break; | ||
172 | } | 200 | } |
173 | } | 201 | } |
174 | 202 | ||
175 | RecBody Genericwrapper::parseMail( mailmessage * msg ) | 203 | RecBody Genericwrapper::parseMail( mailmessage * msg ) |
176 | { | 204 | { |
177 | int err = MAILIMF_NO_ERROR; | 205 | int err = MAILIMF_NO_ERROR; |
178 | mailmime_single_fields fields; | 206 | mailmime_single_fields fields; |
179 | /* is bound to msg and will be freed there */ | 207 | /* is bound to msg and will be freed there */ |
180 | mailmime * mime=0; | 208 | mailmime * mime=0; |
181 | RecBody body; | 209 | RecBody body; |
182 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 210 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
183 | err = mailmessage_get_bodystructure(msg,&mime); | 211 | err = mailmessage_get_bodystructure(msg,&mime); |
184 | traverseBody(body,msg,mime); | 212 | QValueList<int>recList; |
213 | traverseBody(body,msg,mime,recList); | ||
185 | return body; | 214 | return body; |
186 | } | 215 | } |
187 | 216 | ||
188 | RecMail *Genericwrapper::parseHeader( const char *header ) | 217 | RecMail *Genericwrapper::parseHeader( const char *header ) |
189 | { | 218 | { |
190 | int err = MAILIMF_NO_ERROR; | 219 | int err = MAILIMF_NO_ERROR; |
191 | size_t curTok = 0; | 220 | size_t curTok = 0; |
192 | RecMail *mail = new RecMail(); | 221 | RecMail *mail = new RecMail(); |
193 | mailimf_fields *fields = 0; | 222 | mailimf_fields *fields = 0; |
194 | mailimf_references * refs = 0; | 223 | mailimf_references * refs = 0; |
195 | mailimf_keywords*keys = 0; | 224 | mailimf_keywords*keys = 0; |
196 | QString status; | 225 | QString status; |
197 | QString value; | 226 | QString value; |
198 | QBitArray mFlags(7); | 227 | QBitArray mFlags(7); |
199 | 228 | ||
200 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 229 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h index 54d6ea9..c00d864 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.h +++ b/noncore/net/mail/libmailwrapper/genericwrapper.h | |||
@@ -32,28 +32,28 @@ public: | |||
32 | virtual ~Genericwrapper(); | 32 | virtual ~Genericwrapper(); |
33 | 33 | ||
34 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); | 34 | virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part); |
35 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); | 35 | virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part); |
36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); | 36 | virtual QString fetchTextPart(const RecMail&mail,const RecPart&part); |
37 | virtual void cleanMimeCache(); | 37 | virtual void cleanMimeCache(); |
38 | 38 | ||
39 | protected: | 39 | protected: |
40 | RecMail *parseHeader( const char *header ); | 40 | RecMail *parseHeader( const char *header ); |
41 | RecBody parseMail( mailmessage * msg ); | 41 | RecBody parseMail( mailmessage * msg ); |
42 | QString parseMailboxList( mailimf_mailbox_list *list ); | 42 | QString parseMailboxList( mailimf_mailbox_list *list ); |
43 | QString parseMailbox( mailimf_mailbox *box ); | 43 | QString parseMailbox( mailimf_mailbox *box ); |
44 | QString parseGroup( mailimf_group *group ); | 44 | QString parseGroup( mailimf_group *group ); |
45 | QString parseAddressList( mailimf_address_list *list ); | 45 | QString parseAddressList( mailimf_address_list *list ); |
46 | QString parseDateTime( mailimf_date_time *date ); | 46 | QString parseDateTime( mailimf_date_time *date ); |
47 | 47 | ||
48 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,unsigned int current_rek=0); | 48 | void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=0); |
49 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); | 49 | static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); |
50 | static void fillParameters(RecPart&target,clist*parameters); | 50 | static void fillParameters(RecPart&target,clist*parameters); |
51 | static QString getencoding(mailmime_mechanism*aEnc); | 51 | static QString getencoding(mailmime_mechanism*aEnc); |
52 | virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); | 52 | virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox); |
53 | 53 | ||
54 | QString msgTempName; | 54 | QString msgTempName; |
55 | unsigned int last_msg_id; | 55 | unsigned int last_msg_id; |
56 | QMap<QString,encodedString*> bodyCache; | 56 | QMap<QString,encodedString*> bodyCache; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | #endif | 59 | #endif |