author | alwin <alwin> | 2004-03-12 11:22:24 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-12 11:22:24 (UTC) |
commit | a1ddbd219fcee196172f3fd684afac467e5f2469 (patch) (side-by-side diff) | |
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,16 +1,16 @@ #include "generatemail.h" #include "mailwrapper.h" #include <libetpan/libetpan.h> #include <qt.h> -const char* Generatemail::USER_AGENT="OpieMail v0.5"; +const char* Generatemail::USER_AGENT="OpieMail v0.6"; Generatemail::Generatemail() { } Generatemail::~Generatemail() { } @@ -274,35 +274,35 @@ err_free: return NULL; // Error :( } mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { return mailimf_mailbox_new( strdup( name.latin1() ), strdup( mail.latin1() ) ); } -mailimf_fields *Generatemail::createImfFields(const Mail&mail ) +mailimf_fields *Generatemail::createImfFields(const Opie::osmart_pointer<Mail>&mail ) { mailimf_fields *fields = NULL; mailimf_field *xmailer = NULL; mailimf_mailbox *sender=0,*fromBox=0; mailimf_mailbox_list *from=0; mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; clist*in_reply_to = 0; - char *subject = strdup( mail.getSubject().latin1() ); + char *subject = strdup( mail->getSubject().latin1() ); int err; int res = 1; - sender = newMailbox( mail.getName(), mail.getMail() ); + sender = newMailbox( mail->getName(), mail->getMail() ); if ( sender == NULL ) { res = 0; } if (res) { - fromBox = newMailbox( mail.getName(), mail.getMail() ); + fromBox = newMailbox( mail->getName(), mail->getMail() ); } if ( fromBox == NULL ) { res = 0; } if (res) { from = mailimf_mailbox_list_new_empty(); } @@ -312,27 +312,27 @@ mailimf_fields *Generatemail::createImfFields(const Mail&mail ) if (res && from) { err = mailimf_mailbox_list_add( from, fromBox ); if ( err != MAILIMF_NO_ERROR ) { res = 0; } } - if (res) to = parseAddresses( mail.getTo() ); - if (res) cc = parseAddresses( mail.getCC() ); - if (res) bcc = parseAddresses( mail.getBCC() ); - if (res) reply = parseAddresses( mail.getReply() ); + if (res) to = parseAddresses( mail->getTo() ); + if (res) cc = parseAddresses( mail->getCC() ); + if (res) bcc = parseAddresses( mail->getBCC() ); + if (res) reply = parseAddresses( mail->getReply() ); - if (res && mail.Inreply().count()>0) { + if (res && mail->Inreply().count()>0) { in_reply_to = clist_new(); char*c_reply; unsigned int nsize = 0; - for (QStringList::ConstIterator it=mail.Inreply().begin(); - it != mail.Inreply().end();++it) { + for (QStringList::ConstIterator it=mail->Inreply().begin(); + it != mail->Inreply().end();++it) { if ((*it).isEmpty()) continue; QString h((*it)); while (h.length()>0 && h[0]=='<') { h.remove(0,1); } while (h.length()>0 && h[h.length()-1]=='>') { h.remove(h.length()-1,1); @@ -394,41 +394,41 @@ mailimf_fields *Generatemail::createImfFields(const Mail&mail ) if (subject) { free( subject ); } } } return fields; } -mailmime *Generatemail::createMimeMail(const Mail &mail ) { +mailmime *Generatemail::createMimeMail(const Opie::osmart_pointer<Mail> &mail ) { mailmime *message, *txtPart; mailimf_fields *fields; int err; fields = createImfFields( mail ); if ( fields == NULL ) goto err_free; message = mailmime_new_message_data( NULL ); if ( message == NULL ) goto err_free_fields; mailmime_set_imf_fields( message, fields ); - txtPart = buildTxtPart( mail.getMessage() ); + txtPart = buildTxtPart( mail->getMessage() ); if ( txtPart == NULL ) goto err_free_message; err = mailmime_smart_add_part( message, txtPart ); if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; - addFileParts( message, mail.getAttachments() ); + addFileParts( message, mail->getAttachments() ); return message; // Success :) err_free_txtPart: mailmime_free( txtPart ); err_free_message: mailmime_free( message ); err_free_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,16 +1,18 @@ #ifndef __GENERATE_MAIL_H #define __GENERATE_MAIL_H #include <qpe/applnk.h> #include <qobject.h> #include <libetpan/clist.h> +#include <opie2/osmart_pointer.h> + class Mail; class RecMail; class Attachment; struct mailimf_fields; struct mailimf_field; struct mailimf_mailbox; struct mailmime; struct mailimf_address_list; @@ -29,16 +31,16 @@ protected: static char *getFrom( mailmime *mail ); static char *getFrom( mailimf_field *ffrom); static mailimf_field *getField( mailimf_fields *fields, int type ); mailimf_address_list *parseAddresses(const QString&addr ); void addFileParts( mailmime *message,const QList<Attachment>&files ); mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); mailmime *buildTxtPart(const QString&str ); mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); - mailimf_fields *createImfFields(const Mail &mail ); - mailmime *createMimeMail(const Mail&mail ); + mailimf_fields *createImfFields(const Opie::osmart_pointer<Mail> &mail ); + mailmime *createMimeMail(const Opie::osmart_pointer<Mail>&mail ); clist *createRcptList( mailimf_fields *fields ); static const char* USER_AGENT; }; #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 @@ -40,17 +40,19 @@ const QString& Folder::Separator()const return separator; } IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&aprefix ) : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf) { // Decode IMAP foldername nameDisplay = IMAPFolder::decodeFolderName( name ); + /* qDebug( "folder " + name + " - displayed as " + nameDisplay ); + */ prefix = aprefix; if (prefix.length()>0) { if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); } } } @@ -140,17 +142,17 @@ QString IMAPFolder::decodeFolderName( const QString &name ) ++srcPtr; } } return QString::fromUtf8( dst.data() ); } Mail::Mail() - :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") + :Opie::oref_count(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") { } MHFolder::MHFolder(const QString&disp_name,const QString&mbox) : Folder( disp_name,"/" ) { separator = "/"; name = mbox; 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 @@ -3,16 +3,18 @@ #include <qpe/applnk.h> #include <qbitarray.h> #include <qdatetime.h> #include "settings.h" +#include <opie2/osmart_pointer.h> + class Attachment { public: Attachment( DocLnk lnk ); virtual ~Attachment(){} const QString getFileName()const{ return doc.file(); } const QString getName()const{ return doc.name(); } const QString getMimeType()const{ return doc.type(); } @@ -21,17 +23,17 @@ public: DocLnk getDocLnk() { return doc; } protected: DocLnk doc; int size; }; -class Mail +class Mail:public Opie::oref_count { public: Mail(); /* Possible that this destructor must not be declared virtual * 'cause it seems that it will never have some child classes. * in this case this object will not get a virtual table -> memory and * speed will be a little bit better? */ 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 @@ -307,17 +307,17 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) storeFailedMail(data,size,failuretext); } else { qDebug( "Mail sent." ); storeMail(data,size,"Sent"); } return result; } -void SMTPwrapper::sendMail(const Mail&mail,bool later ) +void SMTPwrapper::sendMail(const Opie::osmart_pointer<Mail>&mail,bool later ) { mailmime * mimeMail; mimeMail = createMimeMail(mail ); if ( mimeMail == NULL ) { qDebug( "sendMail: error creating mime mail" ); } else { sendProgress = new progressMailSend(); 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 @@ -6,27 +6,29 @@ #include <qbitarray.h> #include <qdatetime.h> #include <libetpan/clist.h> #include "settings.h" #include "generatemail.h" +#include <opie2/osmart_pointer.h> + class SMTPaccount; class AbstractMail; class SMTPwrapper : public Generatemail { Q_OBJECT public: SMTPwrapper(SMTPaccount * aSmtp); virtual ~SMTPwrapper(); - void sendMail(const Mail& mail,bool later=false ); + void sendMail(const Opie::osmart_pointer<Mail>& mail,bool later=false ); bool flushOutbox(); static progressMailSend*sendProgress; signals: void queuedMails( int ); protected: 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 @@ -44,17 +44,17 @@ Storemail::Storemail(const QString&aFolder) wrapper->createMbox(m_tfolder); } } Storemail::~Storemail() { } -int Storemail::storeMail(const Mail&mail) +int Storemail::storeMail(const Opie::osmart_pointer<Mail>&mail) { if (!wrapper) return 0; int ret = 1; mailmime * mimeMail = 0; mimeMail = createMimeMail(mail ); if ( mimeMail == NULL ) { qDebug( "storeMail: error creating mime mail" ); 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 @@ -13,17 +13,17 @@ class Storemail : public Generatemail { Q_OBJECT public: Storemail(Account*aAccount,const QString&aFolder); Storemail(const QString&dir,const QString&aFolder); Storemail(const QString&aFolder); virtual ~Storemail(); - int storeMail(const Mail&mail); + int storeMail(const Opie::osmart_pointer<Mail>&mail); protected: Account* m_Account; QString m_tfolder; AbstractMail*wrapper; }; #endif |