author | alwin <alwin> | 2003-12-09 16:59:57 (UTC) |
---|---|---|
committer | alwin <alwin> | 2003-12-09 16:59:57 (UTC) |
commit | 1999708f1480dbdd19e73671fbd9e422883839b6 (patch) (side-by-side diff) | |
tree | 633887e98f12d63455faa5065c0f6a3cc0fb290d /noncore/net/mail/libmailwrapper | |
parent | c6b105a7bf2bfffa847fd84c422ae9a3850c682f (diff) | |
download | opie-1999708f1480dbdd19e73671fbd9e422883839b6.zip opie-1999708f1480dbdd19e73671fbd9e422883839b6.tar.gz opie-1999708f1480dbdd19e73671fbd9e422883839b6.tar.bz2 |
some interface changes
split class defines into more files
Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 7 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 129 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 98 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.cpp | 12 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailwrapper.h | 54 |
6 files changed, 240 insertions, 72 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 1acc036..725dcc9 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp @@ -1,10 +1,11 @@ #include <stdlib.h> #include "imapwrapper.h" +#include "mailtypes.h" #include <libetpan/mailimap.h> IMAPwrapper::IMAPwrapper( IMAPaccount *a ) { account = a; m_imap = 0; @@ -61,13 +62,13 @@ void IMAPwrapper::logout() err = mailimap_logout( m_imap ); err = mailimap_close( m_imap ); mailimap_free( m_imap ); m_imap = 0; } -void IMAPwrapper::listMessages(const QString&mailbox,Maillist&target ) +void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) { const char *mb; int err = MAILIMAP_NO_ERROR; clist *result; clistcell *current; mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; @@ -326,15 +327,17 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) m->setFlags(mFlags); } return m; } #if 1 -QString IMAPwrapper::fetchBody(const RecMail&mail) +RecBody IMAPwrapper::fetchBody(const RecMail&mail) { - QString body = ""; + RecBody body; + QString body_text; + const char *mb; int err = MAILIMAP_NO_ERROR; clist *result; clistcell *current; mailimap_fetch_att *fetchAtt; mailimap_fetch_type *fetchType; @@ -365,13 +368,14 @@ QString IMAPwrapper::fetchBody(const RecMail&mail) if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { mailimap_msg_att * msg_att; msg_att = (mailimap_msg_att*)current->data; mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->list->first->data; if (item->msg_att_static && item->msg_att_static->rfc822_text) { - body = item->msg_att_static->rfc822_text; + body_text = item->msg_att_static->rfc822_text; + body.setBodytext(body_text); } } else { qDebug("error fetching text: %s",m_imap->response); } clist_free(result); diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index b02d26d..1423faf 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h @@ -1,24 +1,27 @@ #ifndef __IMAPWRAPPER #define __IMAPWRAPPER +#include <qlist.h> #include "mailwrapper.h" struct mailimap; struct mailimap_body_type_1part; +class RecMail; +class RecBody; class IMAPwrapper : public QObject { Q_OBJECT public: IMAPwrapper( IMAPaccount *a ); virtual ~IMAPwrapper(); QList<IMAPFolder>* listFolders(); - void listMessages(const QString & mailbox,Maillist&target ); - QString fetchBody(const RecMail&mail); + void listMessages(const QString & mailbox,QList<RecMail>&target ); + RecBody fetchBody(const RecMail&mail); static void imap_progress( size_t current, size_t maximum ); protected: RecMail*parse_list_result(mailimap_msg_att*); void login(); void logout(); diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp new file mode 100644 index 0000000..9f2c9e3 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp @@ -0,0 +1,129 @@ +#include "mailtypes.h" + + +RecMail::RecMail() + :subject(""),date(""),mbox(""),msg_number(0),msg_flags(7) +{ +} + +void RecMail::setTo(const QStringList&list) +{ + to = list; +} + +const QStringList&RecMail::To()const +{ + return to; +} + +void RecMail::setCC(const QStringList&list) +{ + cc = list; +} + +const QStringList&RecMail::CC()const +{ + return cc; +} + +void RecMail::setBcc(const QStringList&list) +{ + bcc = list; +} + +const QStringList& RecMail::Bcc()const +{ + return bcc; +} + + +RecPart::RecPart() + : m_type(""),m_subtype(""),m_identifier(""),m_encoding("") +{ +} + +RecPart::RecPart(const QString&identifier,const QString&type,const QString&subtype,const QString&encoding) + : m_type(type),m_subtype(subtype),m_identifier(identifier),m_encoding(encoding) +{ +} + +RecPart::~RecPart() +{ +} + +const QString& RecPart::Type()const +{ + return m_type; +} + +void RecPart::setType(const QString&type) +{ + m_type = type; +} + +const QString& RecPart::Subtype()const +{ + return m_subtype; +} + +void RecPart::setSubtype(const QString&subtype) +{ + m_subtype = subtype; +} + +const QString& RecPart::Identifier()const +{ + return m_identifier; +} + +void RecPart::setIdentifier(const QString&identifier) +{ + m_identifier = identifier; +} + +const QString& RecPart::Encoding()const +{ + return m_encoding; +} + +void RecPart::setEncoding(const QString&encoding) +{ + m_encoding = encoding; +} + +RecBody::RecBody() + : m_BodyText(""),m_PartsList() +{ + m_PartsList.setAutoDelete(true); +} + +RecBody::~RecBody() +{ +} + +void RecBody::setBodytext(const QString&bodyText) +{ + m_BodyText = bodyText; +} + +const QString& RecBody::Bodytext()const +{ + return m_BodyText; +} + +void RecBody::setParts(const QList<RecPart>&parts) +{ + m_PartsList = parts; + m_PartsList.setAutoDelete(true); +} + +const QList<RecPart>& RecBody::Parts()const +{ + return m_PartsList; +} + +void RecBody::addPart(const RecPart& part) +{ + RecPart*p = new RecPart(part); + m_PartsList.append(p); +} diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h new file mode 100644 index 0000000..bb6a483 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/mailtypes.h @@ -0,0 +1,98 @@ +#ifndef __MAIL_TYPES_H +#define __MAIL_TYPES_H + +#define FLAG_ANSWERED 0 +#define FLAG_FLAGGED 1 +#define FLAG_DELETED 2 +#define FLAG_SEEN 3 +#define FLAG_DRAFT 4 +#define FLAG_RECENT 5 + +#include <qlist.h> +#include <qbitarray.h> +#include <qstring.h> +#include <qstringlist.h> + +/* a class to describe mails in a mailbox */ +/* Attention! + From programmers point of view it would make sense to + store the mail body into this class, too. + But: not from the point of view of the device. + Mailbodies can be real large. So we request them when + needed from the mail-wrapper class direct from the server itself + (imap) or from a file-based cache (pop3?) + So there is no interface "const QString&body()" but you should + make a request to the mailwrapper with this class as parameter to + get the body. Same words for the attachments. +*/ +class RecMail +{ +public: + RecMail(); + virtual ~RecMail(){} + + const int getNumber()const{return msg_number;} + void setNumber(int number){msg_number=number;} + const QString&getDate()const{ return date; } + void setDate( const QString&a ) { date = a; } + const QString&getFrom()const{ return from; } + void setFrom( const QString&a ) { from = a; } + const QString&getSubject()const { return subject; } + void setSubject( const QString&s ) { subject = s; } + const QString&getMbox()const{return mbox;} + void setMbox(const QString&box){mbox = box;} + + void setTo(const QStringList&list); + const QStringList&To()const; + void setCC(const QStringList&list); + const QStringList&CC()const; + void setBcc(const QStringList&list); + const QStringList&Bcc()const; + + const QBitArray&getFlags()const{return msg_flags;} + void setFlags(const QBitArray&flags){msg_flags = flags;} + +protected: + QString subject,date,from,mbox; + int msg_number; + QBitArray msg_flags; + QStringList to,cc,bcc; +}; + +class RecPart +{ +protected: + QString m_type,m_subtype,m_identifier,m_encoding; +public: + RecPart(); + RecPart(const QString&identifier,const QString&type="",const QString&subtype="",const QString&encoding="BASE64"); + virtual ~RecPart(); + + const QString&Type()const; + void setType(const QString&type); + const QString&Subtype()const; + void setSubtype(const QString&subtype); + const QString&Identifier()const; + void setIdentifier(const QString&identifier); + const QString&Encoding()const; + void setEncoding(const QString&encoding); +}; + +class RecBody +{ +protected: + QString m_BodyText; + QList<RecPart> m_PartsList; + +public: + RecBody(); + virtual ~RecBody(); + void setBodytext(const QString&); + const QString& Bodytext()const; + + void setParts(const QList<RecPart>&parts); + const QList<RecPart>& Parts()const; + void addPart(const RecPart&part); +}; + +#endif diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp index 7f67cd8..898e9d6 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp @@ -624,18 +624,6 @@ void MailWrapper::sendMail( Mail mail ) } Mail::Mail() :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") { } - -RecMail::RecMail() - :subject(""),date(""),mbox(""),msg_number(0),msg_flags(7) -{ -} - -#if 0 -void RecMail::setDate(const QString&aDate) -{ - mDate = QDateTime::fromString(aDate); -} -#endif diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index 332034f..34fd5c5 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h @@ -28,66 +28,12 @@ public: protected: DocLnk doc; int size; }; -#define FLAG_ANSWERED 0 -#define FLAG_FLAGGED 1 -#define FLAG_DELETED 2 -#define FLAG_SEEN 3 -#define FLAG_DRAFT 4 -#define FLAG_RECENT 5 - -/* a class to describe mails in a mailbox */ -/* Attention! - From programmers point of view it would make sense to - store the mail body into this class, too. - But: not from the point of view of the device. - Mailbodies can be real large. So we request them when - needed from the mail-wrapper class direct from the server itself - (imap) or from a file-based cache (pop3?) - So there is no interface "const QString&body()" but you should - make a request to the mailwrapper with this class as parameter to - get the body. Same words for the attachments. -*/ -class RecMail -{ -public: - RecMail(); - virtual ~RecMail(){} - - const int getNumber()const{return msg_number;} - void setNumber(int number){msg_number=number;} - const QString&getDate()const{ return date; } - void setDate( const QString&a ) { date = a; } - const QString&getFrom()const{ return from; } - void setFrom( const QString&a ) { from = a; } - const QString&getSubject()const { return subject; } - void setSubject( const QString&s ) { subject = s; } - const QString&getMbox()const{return mbox;} - void setMbox(const QString&box){mbox = box;} - const QBitArray&getFlags()const{return msg_flags;} - void setFlags(const QBitArray&flags){msg_flags = flags;} - -#if 0 - void setDate(const QString&dstring); - void setDate(const QDateTime&date){mDate = date;} - QString getDate()const{return mDate.toString();} -#endif -protected: - QString subject,date,from,mbox; - int msg_number; - QBitArray msg_flags; -#if 0 - QDateTime mDate; -#endif -}; - -typedef QList<RecMail> Maillist; - class Mail { public: Mail(); /* Possible that this destructor must not be declared virtual * 'cause it seems that it will never have some child classes. |