Diffstat (limited to 'noncore/net/mail/libmailwrapper/generatemail.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/generatemail.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/noncore/net/mail/libmailwrapper/generatemail.cpp b/noncore/net/mail/libmailwrapper/generatemail.cpp index cb58d82..36ec232 100644 --- a/noncore/net/mail/libmailwrapper/generatemail.cpp +++ b/noncore/net/mail/libmailwrapper/generatemail.cpp | |||
@@ -88,47 +88,47 @@ mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) { | |||
88 | QString s; | 88 | QString s; |
89 | unsigned int i = 0; | 89 | unsigned int i = 0; |
90 | for (; i < addr.length();++i) { | 90 | for (; i < addr.length();++i) { |
91 | switch (addr[i]) { | 91 | switch (addr[i]) { |
92 | case '\"': | 92 | case '\"': |
93 | literal_open = !literal_open; | 93 | literal_open = !literal_open; |
94 | break; | 94 | break; |
95 | case ',': | 95 | case ',': |
96 | if (!literal_open) { | 96 | if (!literal_open) { |
97 | s = addr.mid(startpos,i-startpos); | 97 | s = addr.mid(startpos,i-startpos); |
98 | if (!s.isEmpty()) { | 98 | if (!s.isEmpty()) { |
99 | list.append(s); | 99 | list.append(s); |
100 | qDebug("Appended %s",s.latin1()); | 100 | odebug << "Appended " << s.latin1() << "" << oendl; |
101 | } | 101 | } |
102 | // !!!! this is a MUST BE! | 102 | // !!!! this is a MUST BE! |
103 | startpos = ++i; | 103 | startpos = ++i; |
104 | } | 104 | } |
105 | break; | 105 | break; |
106 | default: | 106 | default: |
107 | break; | 107 | break; |
108 | } | 108 | } |
109 | } | 109 | } |
110 | s = addr.mid(startpos,i-startpos); | 110 | s = addr.mid(startpos,i-startpos); |
111 | if (!s.isEmpty()) { | 111 | if (!s.isEmpty()) { |
112 | list.append(s); | 112 | list.append(s); |
113 | qDebug("Appended %s",s.latin1()); | 113 | odebug << "Appended " << s.latin1() << "" << oendl; |
114 | } | 114 | } |
115 | QStringList::Iterator it; | 115 | QStringList::Iterator it; |
116 | for ( it = list.begin(); it != list.end(); it++ ) { | 116 | for ( it = list.begin(); it != list.end(); it++ ) { |
117 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); | 117 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); |
118 | if ( err != MAILIMF_NO_ERROR ) { | 118 | if ( err != MAILIMF_NO_ERROR ) { |
119 | qDebug( "Error parsing" ); | 119 | odebug << "Error parsing" << oendl; |
120 | qDebug( *it ); | 120 | odebug << *it << oendl; |
121 | } else { | 121 | } else { |
122 | qDebug( "Parse success! %s",(*it).latin1()); | 122 | odebug << "Parse success! " << (*it).latin1() << "" << oendl; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | return addresses; | 125 | return addresses; |
126 | } | 126 | } |
127 | 127 | ||
128 | mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { | 128 | mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { |
129 | mailmime * filePart = 0; | 129 | mailmime * filePart = 0; |
130 | mailmime_fields * fields = 0; | 130 | mailmime_fields * fields = 0; |
131 | mailmime_content * content = 0; | 131 | mailmime_content * content = 0; |
132 | mailmime_parameter * param = 0; | 132 | mailmime_parameter * param = 0; |
133 | char*name = 0; | 133 | char*name = 0; |
134 | char*file = 0; | 134 | char*file = 0; |
@@ -166,25 +166,25 @@ mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimet | |||
166 | clist_append(content->ct_parameters,param); | 166 | clist_append(content->ct_parameters,param); |
167 | param = 0; | 167 | param = 0; |
168 | } | 168 | } |
169 | filePart = mailmime_new_empty( content, fields ); | 169 | filePart = mailmime_new_empty( content, fields ); |
170 | } | 170 | } |
171 | if (filePart) { | 171 | if (filePart) { |
172 | if (filename.length()>0) { | 172 | if (filename.length()>0) { |
173 | err = mailmime_set_body_file( filePart, file ); | 173 | err = mailmime_set_body_file( filePart, file ); |
174 | } else { | 174 | } else { |
175 | err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); | 175 | err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); |
176 | } | 176 | } |
177 | if (err != MAILIMF_NO_ERROR) { | 177 | if (err != MAILIMF_NO_ERROR) { |
178 | qDebug("Error setting body with file %s",file); | 178 | odebug << "Error setting body with file " << file << "" << oendl; |
179 | mailmime_free( filePart ); | 179 | mailmime_free( filePart ); |
180 | filePart = 0; | 180 | filePart = 0; |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | if (!filePart) { | 184 | if (!filePart) { |
185 | if ( param != NULL ) { | 185 | if ( param != NULL ) { |
186 | mailmime_parameter_free( param ); | 186 | mailmime_parameter_free( param ); |
187 | } | 187 | } |
188 | if (content) { | 188 | if (content) { |
189 | mailmime_content_free( content ); | 189 | mailmime_content_free( content ); |
190 | } | 190 | } |
@@ -197,41 +197,41 @@ mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimet | |||
197 | if (file) { | 197 | if (file) { |
198 | free( file ); | 198 | free( file ); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | return filePart; // Success :) | 202 | return filePart; // Success :) |
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) { | 206 | void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) { |
207 | const Attachment *it; | 207 | const Attachment *it; |
208 | unsigned int count = files.count(); | 208 | unsigned int count = files.count(); |
209 | qDebug("List contains %i values",count); | 209 | odebug << "List contains " << count << " values" << oendl; |
210 | for ( unsigned int i = 0; i < count; ++i ) { | 210 | for ( unsigned int i = 0; i < count; ++i ) { |
211 | qDebug( "Adding file" ); | 211 | odebug << "Adding file" << oendl; |
212 | mailmime *filePart; | 212 | mailmime *filePart; |
213 | int err; | 213 | int err; |
214 | it = ((QList<Attachment>)files).at(i); | 214 | it = ((QList<Attachment>)files).at(i); |
215 | 215 | ||
216 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); | 216 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); |
217 | if ( filePart == NULL ) { | 217 | if ( filePart == NULL ) { |
218 | qDebug( "addFileParts: error adding file:" ); | 218 | odebug << "addFileParts: error adding file:" << oendl; |
219 | qDebug( it->getFileName() ); | 219 | odebug << it->getFileName() << oendl; |
220 | continue; | 220 | continue; |
221 | } | 221 | } |
222 | err = mailmime_smart_add_part( message, filePart ); | 222 | err = mailmime_smart_add_part( message, filePart ); |
223 | if ( err != MAILIMF_NO_ERROR ) { | 223 | if ( err != MAILIMF_NO_ERROR ) { |
224 | mailmime_free( filePart ); | 224 | mailmime_free( filePart ); |
225 | qDebug("error smart add"); | 225 | odebug << "error smart add" << oendl; |
226 | } | 226 | } |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | mailmime *Generatemail::buildTxtPart(const QString&str ) { | 230 | mailmime *Generatemail::buildTxtPart(const QString&str ) { |
231 | mailmime *txtPart; | 231 | mailmime *txtPart; |
232 | mailmime_fields *fields; | 232 | mailmime_fields *fields; |
233 | mailmime_content *content; | 233 | mailmime_content *content; |
234 | mailmime_parameter *param; | 234 | mailmime_parameter *param; |
235 | int err; | 235 | int err; |
236 | 236 | ||
237 | param = mailmime_parameter_new( strdup( "charset" ), | 237 | param = mailmime_parameter_new( strdup( "charset" ), |
@@ -261,25 +261,25 @@ mailmime *Generatemail::buildTxtPart(const QString&str ) { | |||
261 | 261 | ||
262 | return txtPart; // Success :) | 262 | return txtPart; // Success :) |
263 | 263 | ||
264 | err_free_txtPart: | 264 | err_free_txtPart: |
265 | mailmime_free( txtPart ); | 265 | mailmime_free( txtPart ); |
266 | err_free_fields: | 266 | err_free_fields: |
267 | mailmime_fields_free( fields ); | 267 | mailmime_fields_free( fields ); |
268 | err_free_content: | 268 | err_free_content: |
269 | mailmime_content_free( content ); | 269 | mailmime_content_free( content ); |
270 | err_free_param: | 270 | err_free_param: |
271 | mailmime_parameter_free( param ); | 271 | mailmime_parameter_free( param ); |
272 | err_free: | 272 | err_free: |
273 | qDebug( "buildTxtPart - error" ); | 273 | odebug << "buildTxtPart - error" << oendl; |
274 | 274 | ||
275 | return NULL; // Error :( | 275 | return NULL; // Error :( |
276 | } | 276 | } |
277 | 277 | ||
278 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { | 278 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { |
279 | return mailimf_mailbox_new( strdup( name.latin1() ), | 279 | return mailimf_mailbox_new( strdup( name.latin1() ), |
280 | strdup( mail.latin1() ) ); | 280 | strdup( mail.latin1() ) ); |
281 | } | 281 | } |
282 | 282 | ||
283 | mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail ) | 283 | mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail ) |
284 | { | 284 | { |
285 | mailimf_fields *fields = NULL; | 285 | mailimf_fields *fields = NULL; |
@@ -336,33 +336,33 @@ mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Ma | |||
336 | h.remove(0,1); | 336 | h.remove(0,1); |
337 | } | 337 | } |
338 | while (h.length()>0 && h[h.length()-1]=='>') { | 338 | while (h.length()>0 && h[h.length()-1]=='>') { |
339 | h.remove(h.length()-1,1); | 339 | h.remove(h.length()-1,1); |
340 | } | 340 | } |
341 | if (h.isEmpty()) continue; | 341 | if (h.isEmpty()) continue; |
342 | nsize = strlen(h.latin1()); | 342 | nsize = strlen(h.latin1()); |
343 | /* yes! must be malloc! */ | 343 | /* yes! must be malloc! */ |
344 | c_reply = (char*)malloc( (nsize+1)*sizeof(char)); | 344 | c_reply = (char*)malloc( (nsize+1)*sizeof(char)); |
345 | memset(c_reply,0,nsize+1); | 345 | memset(c_reply,0,nsize+1); |
346 | memcpy(c_reply,h.latin1(),nsize); | 346 | memcpy(c_reply,h.latin1(),nsize); |
347 | clist_append(in_reply_to,c_reply); | 347 | clist_append(in_reply_to,c_reply); |
348 | qDebug("In reply to: %s",c_reply); | 348 | odebug << "In reply to: " << c_reply << "" << oendl; |
349 | } | 349 | } |
350 | } | 350 | } |
351 | 351 | ||
352 | if (res) { | 352 | if (res) { |
353 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, | 353 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, |
354 | in_reply_to, NULL, subject ); | 354 | in_reply_to, NULL, subject ); |
355 | if ( fields == NULL ) { | 355 | if ( fields == NULL ) { |
356 | qDebug("Error creating mailimf fields"); | 356 | odebug << "Error creating mailimf fields" << oendl; |
357 | res = 0; | 357 | res = 0; |
358 | } | 358 | } |
359 | } | 359 | } |
360 | if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), | 360 | if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), |
361 | strdup( USER_AGENT ) ); | 361 | strdup( USER_AGENT ) ); |
362 | if ( xmailer == NULL ) { | 362 | if ( xmailer == NULL ) { |
363 | res = 0; | 363 | res = 0; |
364 | } else { | 364 | } else { |
365 | err = mailimf_fields_add( fields, xmailer ); | 365 | err = mailimf_fields_add( fields, xmailer ); |
366 | if ( err != MAILIMF_NO_ERROR ) { | 366 | if ( err != MAILIMF_NO_ERROR ) { |
367 | res = 0; | 367 | res = 0; |
368 | } | 368 | } |
@@ -426,25 +426,25 @@ mailmime *Generatemail::createMimeMail(const Opie::Core::OSmartPointer<Mail> &ma | |||
426 | 426 | ||
427 | addFileParts( message, mail->getAttachments() ); | 427 | addFileParts( message, mail->getAttachments() ); |
428 | 428 | ||
429 | return message; // Success :) | 429 | return message; // Success :) |
430 | 430 | ||
431 | err_free_txtPart: | 431 | err_free_txtPart: |
432 | mailmime_free( txtPart ); | 432 | mailmime_free( txtPart ); |
433 | err_free_message: | 433 | err_free_message: |
434 | mailmime_free( message ); | 434 | mailmime_free( message ); |
435 | err_free_fields: | 435 | err_free_fields: |
436 | mailimf_fields_free( fields ); | 436 | mailimf_fields_free( fields ); |
437 | err_free: | 437 | err_free: |
438 | qDebug( "createMimeMail: error" ); | 438 | odebug << "createMimeMail: error" << oendl; |
439 | 439 | ||
440 | return NULL; // Error :( | 440 | return NULL; // Error :( |
441 | } | 441 | } |
442 | 442 | ||
443 | clist *Generatemail::createRcptList( mailimf_fields *fields ) { | 443 | clist *Generatemail::createRcptList( mailimf_fields *fields ) { |
444 | clist *rcptList; | 444 | clist *rcptList; |
445 | mailimf_field *field; | 445 | mailimf_field *field; |
446 | 446 | ||
447 | rcptList = esmtp_address_list_new(); | 447 | rcptList = esmtp_address_list_new(); |
448 | 448 | ||
449 | field = getField( fields, MAILIMF_FIELD_TO ); | 449 | field = getField( fields, MAILIMF_FIELD_TO ); |
450 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) | 450 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) |