author | alwin <alwin> | 2004-03-12 11:22:24 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-12 11:22:24 (UTC) |
commit | a1ddbd219fcee196172f3fd684afac467e5f2469 (patch) (unidiff) | |
tree | 7f9206c519ceeff108a24e526bcad978977fa7a4 | |
parent | c71234bda29bd83de34ce04c766f2be641ed86be (diff) | |
download | opie-a1ddbd219fcee196172f3fd684afac467e5f2469.zip opie-a1ddbd219fcee196172f3fd684afac467e5f2469.tar.gz opie-a1ddbd219fcee196172f3fd684afac467e5f2469.tar.bz2 |
start usage of smart-pointers
-rw-r--r-- | noncore/net/mail/libmailwrapper/generatemail.cpp | 30 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/generatemail.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.h | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/storemail.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/storemail.h | 2 |
8 files changed, 31 insertions, 23 deletions
diff --git a/noncore/net/mail/libmailwrapper/generatemail.cpp b/noncore/net/mail/libmailwrapper/generatemail.cpp index 48fa02e..4f7ec0c 100644 --- a/noncore/net/mail/libmailwrapper/generatemail.cpp +++ b/noncore/net/mail/libmailwrapper/generatemail.cpp | |||
@@ -1,24 +1,24 @@ | |||
1 | #include "generatemail.h" | 1 | #include "generatemail.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | 3 | ||
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | 5 | ||
6 | #include <qt.h> | 6 | #include <qt.h> |
7 | 7 | ||
8 | const char* Generatemail::USER_AGENT="OpieMail v0.5"; | 8 | const char* Generatemail::USER_AGENT="OpieMail v0.6"; |
9 | 9 | ||
10 | Generatemail::Generatemail() | 10 | Generatemail::Generatemail() |
11 | { | 11 | { |
12 | } | 12 | } |
13 | 13 | ||
14 | Generatemail::~Generatemail() | 14 | Generatemail::~Generatemail() |
15 | { | 15 | { |
16 | } | 16 | } |
17 | 17 | ||
18 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { | 18 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { |
19 | clistiter *it, *it2; | 19 | clistiter *it, *it2; |
20 | 20 | ||
21 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { | 21 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { |
22 | mailimf_address *addr; | 22 | mailimf_address *addr; |
23 | addr = (mailimf_address *) it->data; | 23 | addr = (mailimf_address *) it->data; |
24 | 24 | ||
@@ -266,81 +266,81 @@ err_free_fields: | |||
266 | mailmime_fields_free( fields ); | 266 | mailmime_fields_free( fields ); |
267 | err_free_content: | 267 | err_free_content: |
268 | mailmime_content_free( content ); | 268 | mailmime_content_free( content ); |
269 | err_free_param: | 269 | err_free_param: |
270 | mailmime_parameter_free( param ); | 270 | mailmime_parameter_free( param ); |
271 | err_free: | 271 | err_free: |
272 | qDebug( "buildTxtPart - error" ); | 272 | qDebug( "buildTxtPart - error" ); |
273 | 273 | ||
274 | return NULL; // Error :( | 274 | return NULL; // Error :( |
275 | } | 275 | } |
276 | 276 | ||
277 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { | 277 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { |
278 | return mailimf_mailbox_new( strdup( name.latin1() ), | 278 | return mailimf_mailbox_new( strdup( name.latin1() ), |
279 | strdup( mail.latin1() ) ); | 279 | strdup( mail.latin1() ) ); |
280 | } | 280 | } |
281 | 281 | ||
282 | mailimf_fields *Generatemail::createImfFields(const Mail&mail ) | 282 | mailimf_fields *Generatemail::createImfFields(const Opie::osmart_pointer<Mail>&mail ) |
283 | { | 283 | { |
284 | mailimf_fields *fields = NULL; | 284 | mailimf_fields *fields = NULL; |
285 | mailimf_field *xmailer = NULL; | 285 | mailimf_field *xmailer = NULL; |
286 | mailimf_mailbox *sender=0,*fromBox=0; | 286 | mailimf_mailbox *sender=0,*fromBox=0; |
287 | mailimf_mailbox_list *from=0; | 287 | mailimf_mailbox_list *from=0; |
288 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; | 288 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; |
289 | clist*in_reply_to = 0; | 289 | clist*in_reply_to = 0; |
290 | char *subject = strdup( mail.getSubject().latin1() ); | 290 | char *subject = strdup( mail->getSubject().latin1() ); |
291 | int err; | 291 | int err; |
292 | int res = 1; | 292 | int res = 1; |
293 | 293 | ||
294 | sender = newMailbox( mail.getName(), mail.getMail() ); | 294 | sender = newMailbox( mail->getName(), mail->getMail() ); |
295 | if ( sender == NULL ) { | 295 | if ( sender == NULL ) { |
296 | res = 0; | 296 | res = 0; |
297 | } | 297 | } |
298 | 298 | ||
299 | if (res) { | 299 | if (res) { |
300 | fromBox = newMailbox( mail.getName(), mail.getMail() ); | 300 | fromBox = newMailbox( mail->getName(), mail->getMail() ); |
301 | } | 301 | } |
302 | if ( fromBox == NULL ) { | 302 | if ( fromBox == NULL ) { |
303 | res = 0; | 303 | res = 0; |
304 | } | 304 | } |
305 | 305 | ||
306 | if (res) { | 306 | if (res) { |
307 | from = mailimf_mailbox_list_new_empty(); | 307 | from = mailimf_mailbox_list_new_empty(); |
308 | } | 308 | } |
309 | if ( from == NULL ) { | 309 | if ( from == NULL ) { |
310 | res = 0; | 310 | res = 0; |
311 | } | 311 | } |
312 | 312 | ||
313 | if (res && from) { | 313 | if (res && from) { |
314 | err = mailimf_mailbox_list_add( from, fromBox ); | 314 | err = mailimf_mailbox_list_add( from, fromBox ); |
315 | if ( err != MAILIMF_NO_ERROR ) { | 315 | if ( err != MAILIMF_NO_ERROR ) { |
316 | res = 0; | 316 | res = 0; |
317 | } | 317 | } |
318 | } | 318 | } |
319 | 319 | ||
320 | if (res) to = parseAddresses( mail.getTo() ); | 320 | if (res) to = parseAddresses( mail->getTo() ); |
321 | if (res) cc = parseAddresses( mail.getCC() ); | 321 | if (res) cc = parseAddresses( mail->getCC() ); |
322 | if (res) bcc = parseAddresses( mail.getBCC() ); | 322 | if (res) bcc = parseAddresses( mail->getBCC() ); |
323 | if (res) reply = parseAddresses( mail.getReply() ); | 323 | if (res) reply = parseAddresses( mail->getReply() ); |
324 | 324 | ||
325 | if (res && mail.Inreply().count()>0) { | 325 | if (res && mail->Inreply().count()>0) { |
326 | in_reply_to = clist_new(); | 326 | in_reply_to = clist_new(); |
327 | char*c_reply; | 327 | char*c_reply; |
328 | unsigned int nsize = 0; | 328 | unsigned int nsize = 0; |
329 | for (QStringList::ConstIterator it=mail.Inreply().begin(); | 329 | for (QStringList::ConstIterator it=mail->Inreply().begin(); |
330 | it != mail.Inreply().end();++it) { | 330 | it != mail->Inreply().end();++it) { |
331 | if ((*it).isEmpty()) | 331 | if ((*it).isEmpty()) |
332 | continue; | 332 | continue; |
333 | QString h((*it)); | 333 | QString h((*it)); |
334 | while (h.length()>0 && h[0]=='<') { | 334 | while (h.length()>0 && h[0]=='<') { |
335 | h.remove(0,1); | 335 | h.remove(0,1); |
336 | } | 336 | } |
337 | while (h.length()>0 && h[h.length()-1]=='>') { | 337 | while (h.length()>0 && h[h.length()-1]=='>') { |
338 | h.remove(h.length()-1,1); | 338 | h.remove(h.length()-1,1); |
339 | } | 339 | } |
340 | if (h.isEmpty()) continue; | 340 | if (h.isEmpty()) continue; |
341 | nsize = strlen(h.latin1()); | 341 | nsize = strlen(h.latin1()); |
342 | /* yes! must be malloc! */ | 342 | /* yes! must be malloc! */ |
343 | c_reply = (char*)malloc( (nsize+1)*sizeof(char)); | 343 | c_reply = (char*)malloc( (nsize+1)*sizeof(char)); |
344 | memset(c_reply,0,nsize+1); | 344 | memset(c_reply,0,nsize+1); |
345 | memcpy(c_reply,h.latin1(),nsize); | 345 | memcpy(c_reply,h.latin1(),nsize); |
346 | clist_append(in_reply_to,c_reply); | 346 | clist_append(in_reply_to,c_reply); |
@@ -386,57 +386,57 @@ mailimf_fields *Generatemail::createImfFields(const Mail&mail ) | |||
386 | if (fromBox) { | 386 | if (fromBox) { |
387 | mailimf_mailbox_free( fromBox ); | 387 | mailimf_mailbox_free( fromBox ); |
388 | } else if (from) { | 388 | } else if (from) { |
389 | mailimf_mailbox_list_free( from ); | 389 | mailimf_mailbox_list_free( from ); |
390 | } | 390 | } |
391 | if (sender) { | 391 | if (sender) { |
392 | mailimf_mailbox_free( sender ); | 392 | mailimf_mailbox_free( sender ); |
393 | } | 393 | } |
394 | if (subject) { | 394 | if (subject) { |
395 | free( subject ); | 395 | free( subject ); |
396 | } | 396 | } |
397 | } | 397 | } |
398 | } | 398 | } |
399 | return fields; | 399 | return fields; |
400 | } | 400 | } |
401 | 401 | ||
402 | mailmime *Generatemail::createMimeMail(const Mail &mail ) { | 402 | mailmime *Generatemail::createMimeMail(const Opie::osmart_pointer<Mail> &mail ) { |
403 | mailmime *message, *txtPart; | 403 | mailmime *message, *txtPart; |
404 | mailimf_fields *fields; | 404 | mailimf_fields *fields; |
405 | int err; | 405 | int err; |
406 | 406 | ||
407 | fields = createImfFields( mail ); | 407 | fields = createImfFields( mail ); |
408 | if ( fields == NULL ) | 408 | if ( fields == NULL ) |
409 | goto err_free; | 409 | goto err_free; |
410 | 410 | ||
411 | message = mailmime_new_message_data( NULL ); | 411 | message = mailmime_new_message_data( NULL ); |
412 | if ( message == NULL ) | 412 | if ( message == NULL ) |
413 | goto err_free_fields; | 413 | goto err_free_fields; |
414 | 414 | ||
415 | mailmime_set_imf_fields( message, fields ); | 415 | mailmime_set_imf_fields( message, fields ); |
416 | 416 | ||
417 | txtPart = buildTxtPart( mail.getMessage() ); | 417 | txtPart = buildTxtPart( mail->getMessage() ); |
418 | 418 | ||
419 | if ( txtPart == NULL ) | 419 | if ( txtPart == NULL ) |
420 | goto err_free_message; | 420 | goto err_free_message; |
421 | 421 | ||
422 | err = mailmime_smart_add_part( message, txtPart ); | 422 | err = mailmime_smart_add_part( message, txtPart ); |
423 | if ( err != MAILIMF_NO_ERROR ) | 423 | if ( err != MAILIMF_NO_ERROR ) |
424 | goto err_free_txtPart; | 424 | goto err_free_txtPart; |
425 | 425 | ||
426 | addFileParts( message, mail.getAttachments() ); | 426 | addFileParts( message, mail->getAttachments() ); |
427 | 427 | ||
428 | return message; // Success :) | 428 | return message; // Success :) |
429 | 429 | ||
430 | err_free_txtPart: | 430 | err_free_txtPart: |
431 | mailmime_free( txtPart ); | 431 | mailmime_free( txtPart ); |
432 | err_free_message: | 432 | err_free_message: |
433 | mailmime_free( message ); | 433 | mailmime_free( message ); |
434 | err_free_fields: | 434 | err_free_fields: |
435 | mailimf_fields_free( fields ); | 435 | mailimf_fields_free( fields ); |
436 | err_free: | 436 | err_free: |
437 | qDebug( "createMimeMail: error" ); | 437 | qDebug( "createMimeMail: error" ); |
438 | 438 | ||
439 | return NULL; // Error :( | 439 | return NULL; // Error :( |
440 | } | 440 | } |
441 | 441 | ||
442 | clist *Generatemail::createRcptList( mailimf_fields *fields ) { | 442 | clist *Generatemail::createRcptList( mailimf_fields *fields ) { |
diff --git a/noncore/net/mail/libmailwrapper/generatemail.h b/noncore/net/mail/libmailwrapper/generatemail.h index 8be5a2b..409a55e 100644 --- a/noncore/net/mail/libmailwrapper/generatemail.h +++ b/noncore/net/mail/libmailwrapper/generatemail.h | |||
@@ -1,44 +1,46 @@ | |||
1 | #ifndef __GENERATE_MAIL_H | 1 | #ifndef __GENERATE_MAIL_H |
2 | #define __GENERATE_MAIL_H | 2 | #define __GENERATE_MAIL_H |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qobject.h> | 6 | #include <qobject.h> |
7 | #include <libetpan/clist.h> | 7 | #include <libetpan/clist.h> |
8 | 8 | ||
9 | #include <opie2/osmart_pointer.h> | ||
10 | |||
9 | class Mail; | 11 | class Mail; |
10 | class RecMail; | 12 | class RecMail; |
11 | class Attachment; | 13 | class Attachment; |
12 | struct mailimf_fields; | 14 | struct mailimf_fields; |
13 | struct mailimf_field; | 15 | struct mailimf_field; |
14 | struct mailimf_mailbox; | 16 | struct mailimf_mailbox; |
15 | struct mailmime; | 17 | struct mailmime; |
16 | struct mailimf_address_list; | 18 | struct mailimf_address_list; |
17 | class progressMailSend; | 19 | class progressMailSend; |
18 | struct mailsmtp; | 20 | struct mailsmtp; |
19 | 21 | ||
20 | class Generatemail : public QObject | 22 | class Generatemail : public QObject |
21 | { | 23 | { |
22 | Q_OBJECT | 24 | Q_OBJECT |
23 | public: | 25 | public: |
24 | Generatemail(); | 26 | Generatemail(); |
25 | virtual ~Generatemail(); | 27 | virtual ~Generatemail(); |
26 | 28 | ||
27 | protected: | 29 | protected: |
28 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); | 30 | static void addRcpts( clist *list, mailimf_address_list *addr_list ); |
29 | static char *getFrom( mailmime *mail ); | 31 | static char *getFrom( mailmime *mail ); |
30 | static char *getFrom( mailimf_field *ffrom); | 32 | static char *getFrom( mailimf_field *ffrom); |
31 | static mailimf_field *getField( mailimf_fields *fields, int type ); | 33 | static mailimf_field *getField( mailimf_fields *fields, int type ); |
32 | mailimf_address_list *parseAddresses(const QString&addr ); | 34 | mailimf_address_list *parseAddresses(const QString&addr ); |
33 | void addFileParts( mailmime *message,const QList<Attachment>&files ); | 35 | void addFileParts( mailmime *message,const QList<Attachment>&files ); |
34 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); | 36 | mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); |
35 | mailmime *buildTxtPart(const QString&str ); | 37 | mailmime *buildTxtPart(const QString&str ); |
36 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); | 38 | mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); |
37 | mailimf_fields *createImfFields(const Mail &mail ); | 39 | mailimf_fields *createImfFields(const Opie::osmart_pointer<Mail> &mail ); |
38 | mailmime *createMimeMail(const Mail&mail ); | 40 | mailmime *createMimeMail(const Opie::osmart_pointer<Mail>&mail ); |
39 | clist *createRcptList( mailimf_fields *fields ); | 41 | clist *createRcptList( mailimf_fields *fields ); |
40 | 42 | ||
41 | static const char* USER_AGENT; | 43 | static const char* USER_AGENT; |
42 | }; | 44 | }; |
43 | 45 | ||
44 | #endif | 46 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index ebdbf4b..6bd98f6 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp | |||
@@ -32,33 +32,35 @@ Folder::Folder(const QString&tmp_name, const QString&sep ) | |||
32 | name = tmp_name; | 32 | name = tmp_name; |
33 | nameDisplay = name; | 33 | nameDisplay = name; |
34 | separator = sep; | 34 | separator = sep; |
35 | prefix = ""; | 35 | prefix = ""; |
36 | } | 36 | } |
37 | 37 | ||
38 | const QString& Folder::Separator()const | 38 | const QString& Folder::Separator()const |
39 | { | 39 | { |
40 | return separator; | 40 | return separator; |
41 | } | 41 | } |
42 | 42 | ||
43 | IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&aprefix ) | 43 | IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&aprefix ) |
44 | : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf) | 44 | : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf) |
45 | { | 45 | { |
46 | // Decode IMAP foldername | 46 | // Decode IMAP foldername |
47 | nameDisplay = IMAPFolder::decodeFolderName( name ); | 47 | nameDisplay = IMAPFolder::decodeFolderName( name ); |
48 | /* | ||
48 | qDebug( "folder " + name + " - displayed as " + nameDisplay ); | 49 | qDebug( "folder " + name + " - displayed as " + nameDisplay ); |
50 | */ | ||
49 | prefix = aprefix; | 51 | prefix = aprefix; |
50 | 52 | ||
51 | if (prefix.length()>0) { | 53 | if (prefix.length()>0) { |
52 | if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { | 54 | if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { |
53 | nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); | 55 | nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); |
54 | } | 56 | } |
55 | } | 57 | } |
56 | } | 58 | } |
57 | 59 | ||
58 | static unsigned char base64chars[] = | 60 | static unsigned char base64chars[] = |
59 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; | 61 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; |
60 | 62 | ||
61 | /** | 63 | /** |
62 | * Decodes base64 encoded parts of the imapfolder name | 64 | * Decodes base64 encoded parts of the imapfolder name |
63 | * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc | 65 | * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc |
64 | */ | 66 | */ |
@@ -132,33 +134,33 @@ QString IMAPFolder::decodeFolderName( const QString &name ) | |||
132 | /* copy it */ | 134 | /* copy it */ |
133 | for (c = 0; c < i; ++c) { | 135 | for (c = 0; c < i; ++c) { |
134 | dst += utf8[c]; | 136 | dst += utf8[c]; |
135 | } | 137 | } |
136 | } | 138 | } |
137 | } | 139 | } |
138 | /* skip over trailing '-' in modified UTF-7 encoding */ | 140 | /* skip over trailing '-' in modified UTF-7 encoding */ |
139 | if (src[srcPtr] == '-') | 141 | if (src[srcPtr] == '-') |
140 | ++srcPtr; | 142 | ++srcPtr; |
141 | } | 143 | } |
142 | } | 144 | } |
143 | 145 | ||
144 | return QString::fromUtf8( dst.data() ); | 146 | return QString::fromUtf8( dst.data() ); |
145 | } | 147 | } |
146 | 148 | ||
147 | Mail::Mail() | 149 | Mail::Mail() |
148 | :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") | 150 | :Opie::oref_count(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") |
149 | { | 151 | { |
150 | } | 152 | } |
151 | 153 | ||
152 | MHFolder::MHFolder(const QString&disp_name,const QString&mbox) | 154 | MHFolder::MHFolder(const QString&disp_name,const QString&mbox) |
153 | : Folder( disp_name,"/" ) | 155 | : Folder( disp_name,"/" ) |
154 | { | 156 | { |
155 | separator = "/"; | 157 | separator = "/"; |
156 | name = mbox; | 158 | name = mbox; |
157 | if (!disp_name.startsWith("/") && disp_name.length()>0) | 159 | if (!disp_name.startsWith("/") && disp_name.length()>0) |
158 | name+="/"; | 160 | name+="/"; |
159 | name+=disp_name; | 161 | name+=disp_name; |
160 | if (disp_name.length()==0) { | 162 | if (disp_name.length()==0) { |
161 | nameDisplay = separator; | 163 | nameDisplay = separator; |
162 | } | 164 | } |
163 | prefix = mbox; | 165 | prefix = mbox; |
164 | } | 166 | } |
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index 3a9f97b..c66572c 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h | |||
@@ -1,45 +1,47 @@ | |||
1 | #ifndef MAILWRAPPER_H | 1 | #ifndef MAILWRAPPER_H |
2 | #define MAILWRAPPER_H | 2 | #define MAILWRAPPER_H |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | 5 | ||
6 | #include <qbitarray.h> | 6 | #include <qbitarray.h> |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | 8 | ||
9 | #include "settings.h" | 9 | #include "settings.h" |
10 | 10 | ||
11 | #include <opie2/osmart_pointer.h> | ||
12 | |||
11 | class Attachment | 13 | class Attachment |
12 | { | 14 | { |
13 | public: | 15 | public: |
14 | Attachment( DocLnk lnk ); | 16 | Attachment( DocLnk lnk ); |
15 | virtual ~Attachment(){} | 17 | virtual ~Attachment(){} |
16 | const QString getFileName()const{ return doc.file(); } | 18 | const QString getFileName()const{ return doc.file(); } |
17 | const QString getName()const{ return doc.name(); } | 19 | const QString getName()const{ return doc.name(); } |
18 | const QString getMimeType()const{ return doc.type(); } | 20 | const QString getMimeType()const{ return doc.type(); } |
19 | const QPixmap getPixmap()const{ return doc.pixmap(); } | 21 | const QPixmap getPixmap()const{ return doc.pixmap(); } |
20 | const int getSize()const { return size; } | 22 | const int getSize()const { return size; } |
21 | DocLnk getDocLnk() { return doc; } | 23 | DocLnk getDocLnk() { return doc; } |
22 | 24 | ||
23 | protected: | 25 | protected: |
24 | DocLnk doc; | 26 | DocLnk doc; |
25 | int size; | 27 | int size; |
26 | 28 | ||
27 | }; | 29 | }; |
28 | 30 | ||
29 | class Mail | 31 | class Mail:public Opie::oref_count |
30 | { | 32 | { |
31 | public: | 33 | public: |
32 | Mail(); | 34 | Mail(); |
33 | /* Possible that this destructor must not be declared virtual | 35 | /* Possible that this destructor must not be declared virtual |
34 | * 'cause it seems that it will never have some child classes. | 36 | * 'cause it seems that it will never have some child classes. |
35 | * in this case this object will not get a virtual table -> memory and | 37 | * in this case this object will not get a virtual table -> memory and |
36 | * speed will be a little bit better? | 38 | * speed will be a little bit better? |
37 | */ | 39 | */ |
38 | virtual ~Mail(){} | 40 | virtual ~Mail(){} |
39 | void addAttachment( Attachment *att ) { attList.append( att ); } | 41 | void addAttachment( Attachment *att ) { attList.append( att ); } |
40 | const QList<Attachment>& getAttachments()const { return attList; } | 42 | const QList<Attachment>& getAttachments()const { return attList; } |
41 | void removeAttachment( Attachment *att ) { attList.remove( att ); } | 43 | void removeAttachment( Attachment *att ) { attList.remove( att ); } |
42 | const QString&getName()const { return name; } | 44 | const QString&getName()const { return name; } |
43 | void setName( QString s ) { name = s; } | 45 | void setName( QString s ) { name = s; } |
44 | const QString&getMail()const{ return mail; } | 46 | const QString&getMail()const{ return mail; } |
45 | void setMail( const QString&s ) { mail = s; } | 47 | void setMail( const QString&s ) { mail = s; } |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index a4e0beb..afc5618 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -299,33 +299,33 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) | |||
299 | failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); | 299 | failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); |
300 | result = 0; | 300 | result = 0; |
301 | } | 301 | } |
302 | } else { | 302 | } else { |
303 | result = 0; | 303 | result = 0; |
304 | } | 304 | } |
305 | 305 | ||
306 | if (!result) { | 306 | if (!result) { |
307 | storeFailedMail(data,size,failuretext); | 307 | storeFailedMail(data,size,failuretext); |
308 | } else { | 308 | } else { |
309 | qDebug( "Mail sent." ); | 309 | qDebug( "Mail sent." ); |
310 | storeMail(data,size,"Sent"); | 310 | storeMail(data,size,"Sent"); |
311 | } | 311 | } |
312 | return result; | 312 | return result; |
313 | } | 313 | } |
314 | 314 | ||
315 | void SMTPwrapper::sendMail(const Mail&mail,bool later ) | 315 | void SMTPwrapper::sendMail(const Opie::osmart_pointer<Mail>&mail,bool later ) |
316 | { | 316 | { |
317 | mailmime * mimeMail; | 317 | mailmime * mimeMail; |
318 | 318 | ||
319 | mimeMail = createMimeMail(mail ); | 319 | mimeMail = createMimeMail(mail ); |
320 | if ( mimeMail == NULL ) { | 320 | if ( mimeMail == NULL ) { |
321 | qDebug( "sendMail: error creating mime mail" ); | 321 | qDebug( "sendMail: error creating mime mail" ); |
322 | } else { | 322 | } else { |
323 | sendProgress = new progressMailSend(); | 323 | sendProgress = new progressMailSend(); |
324 | sendProgress->show(); | 324 | sendProgress->show(); |
325 | sendProgress->setMaxMails(1); | 325 | sendProgress->setMaxMails(1); |
326 | smtpSend( mimeMail,later); | 326 | smtpSend( mimeMail,later); |
327 | qDebug("Clean up done"); | 327 | qDebug("Clean up done"); |
328 | sendProgress->hide(); | 328 | sendProgress->hide(); |
329 | delete sendProgress; | 329 | delete sendProgress; |
330 | sendProgress = 0; | 330 | sendProgress = 0; |
331 | mailmime_free( mimeMail ); | 331 | mailmime_free( mimeMail ); |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index 1796df7..08bde74 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h | |||
@@ -1,40 +1,42 @@ | |||
1 | // -*- Mode: C++; -*- | 1 | // -*- Mode: C++; -*- |
2 | #ifndef SMTPwrapper_H | 2 | #ifndef SMTPwrapper_H |
3 | #define SMTPwrapper_H | 3 | #define SMTPwrapper_H |
4 | 4 | ||
5 | #include <qpe/applnk.h> | 5 | #include <qpe/applnk.h> |
6 | 6 | ||
7 | #include <qbitarray.h> | 7 | #include <qbitarray.h> |
8 | #include <qdatetime.h> | 8 | #include <qdatetime.h> |
9 | #include <libetpan/clist.h> | 9 | #include <libetpan/clist.h> |
10 | 10 | ||
11 | #include "settings.h" | 11 | #include "settings.h" |
12 | #include "generatemail.h" | 12 | #include "generatemail.h" |
13 | 13 | ||
14 | #include <opie2/osmart_pointer.h> | ||
15 | |||
14 | class SMTPaccount; | 16 | class SMTPaccount; |
15 | class AbstractMail; | 17 | class AbstractMail; |
16 | 18 | ||
17 | class SMTPwrapper : public Generatemail | 19 | class SMTPwrapper : public Generatemail |
18 | { | 20 | { |
19 | Q_OBJECT | 21 | Q_OBJECT |
20 | 22 | ||
21 | public: | 23 | public: |
22 | SMTPwrapper(SMTPaccount * aSmtp); | 24 | SMTPwrapper(SMTPaccount * aSmtp); |
23 | virtual ~SMTPwrapper(); | 25 | virtual ~SMTPwrapper(); |
24 | void sendMail(const Mail& mail,bool later=false ); | 26 | void sendMail(const Opie::osmart_pointer<Mail>& mail,bool later=false ); |
25 | bool flushOutbox(); | 27 | bool flushOutbox(); |
26 | 28 | ||
27 | static progressMailSend*sendProgress; | 29 | static progressMailSend*sendProgress; |
28 | 30 | ||
29 | signals: | 31 | signals: |
30 | void queuedMails( int ); | 32 | void queuedMails( int ); |
31 | 33 | ||
32 | protected: | 34 | protected: |
33 | mailsmtp *m_smtp; | 35 | mailsmtp *m_smtp; |
34 | SMTPaccount * m_SmtpAccount; | 36 | SMTPaccount * m_SmtpAccount; |
35 | 37 | ||
36 | void connect_server(); | 38 | void connect_server(); |
37 | void disc_server(); | 39 | void disc_server(); |
38 | int start_smtp_tls(); | 40 | int start_smtp_tls(); |
39 | 41 | ||
40 | 42 | ||
diff --git a/noncore/net/mail/libmailwrapper/storemail.cpp b/noncore/net/mail/libmailwrapper/storemail.cpp index 53101f8..052e0f1 100644 --- a/noncore/net/mail/libmailwrapper/storemail.cpp +++ b/noncore/net/mail/libmailwrapper/storemail.cpp | |||
@@ -36,33 +36,33 @@ Storemail::Storemail(const QString&dir,const QString&aFolder) | |||
36 | Storemail::Storemail(const QString&aFolder) | 36 | Storemail::Storemail(const QString&aFolder) |
37 | : Generatemail() | 37 | : Generatemail() |
38 | { | 38 | { |
39 | wrapper = 0; | 39 | wrapper = 0; |
40 | m_Account = 0; | 40 | m_Account = 0; |
41 | m_tfolder = aFolder; | 41 | m_tfolder = aFolder; |
42 | wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); | 42 | wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); |
43 | if (wrapper) { | 43 | if (wrapper) { |
44 | wrapper->createMbox(m_tfolder); | 44 | wrapper->createMbox(m_tfolder); |
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
48 | Storemail::~Storemail() | 48 | Storemail::~Storemail() |
49 | { | 49 | { |
50 | } | 50 | } |
51 | 51 | ||
52 | int Storemail::storeMail(const Mail&mail) | 52 | int Storemail::storeMail(const Opie::osmart_pointer<Mail>&mail) |
53 | { | 53 | { |
54 | if (!wrapper) return 0; | 54 | if (!wrapper) return 0; |
55 | int ret = 1; | 55 | int ret = 1; |
56 | 56 | ||
57 | mailmime * mimeMail = 0; | 57 | mailmime * mimeMail = 0; |
58 | mimeMail = createMimeMail(mail ); | 58 | mimeMail = createMimeMail(mail ); |
59 | if ( mimeMail == NULL ) { | 59 | if ( mimeMail == NULL ) { |
60 | qDebug( "storeMail: error creating mime mail" ); | 60 | qDebug( "storeMail: error creating mime mail" ); |
61 | return 0; | 61 | return 0; |
62 | } | 62 | } |
63 | char *data; | 63 | char *data; |
64 | size_t size; | 64 | size_t size; |
65 | data = 0; | 65 | data = 0; |
66 | 66 | ||
67 | mailmessage * msg = 0; | 67 | mailmessage * msg = 0; |
68 | msg = mime_message_init(mimeMail); | 68 | msg = mime_message_init(mimeMail); |
diff --git a/noncore/net/mail/libmailwrapper/storemail.h b/noncore/net/mail/libmailwrapper/storemail.h index 872c981..7d8ea3d 100644 --- a/noncore/net/mail/libmailwrapper/storemail.h +++ b/noncore/net/mail/libmailwrapper/storemail.h | |||
@@ -5,25 +5,25 @@ | |||
5 | 5 | ||
6 | #include "generatemail.h" | 6 | #include "generatemail.h" |
7 | 7 | ||
8 | class Account; | 8 | class Account; |
9 | class Mail; | 9 | class Mail; |
10 | class AbstractMail; | 10 | class AbstractMail; |
11 | 11 | ||
12 | class Storemail : public Generatemail | 12 | class Storemail : public Generatemail |
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | public: | 15 | public: |
16 | Storemail(Account*aAccount,const QString&aFolder); | 16 | Storemail(Account*aAccount,const QString&aFolder); |
17 | Storemail(const QString&dir,const QString&aFolder); | 17 | Storemail(const QString&dir,const QString&aFolder); |
18 | Storemail(const QString&aFolder); | 18 | Storemail(const QString&aFolder); |
19 | virtual ~Storemail(); | 19 | virtual ~Storemail(); |
20 | 20 | ||
21 | int storeMail(const Mail&mail); | 21 | int storeMail(const Opie::osmart_pointer<Mail>&mail); |
22 | 22 | ||
23 | protected: | 23 | protected: |
24 | Account* m_Account; | 24 | Account* m_Account; |
25 | QString m_tfolder; | 25 | QString m_tfolder; |
26 | AbstractMail*wrapper; | 26 | AbstractMail*wrapper; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | #endif | 29 | #endif |