summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-13 21:03:45 (UTC)
committer alwin <alwin>2003-12-13 21:03:45 (UTC)
commitc0e86973b0cd2d01163ccf60340c8d295aa645f4 (patch) (side-by-side diff)
tree4ccb0f7b8071711bf7ebc5320ea5c2f6974d6fb4
parent85444223acfafd9d7955032b2cbdad3279ba27ad (diff)
downloadopie-c0e86973b0cd2d01163ccf60340c8d295aa645f4.zip
opie-c0e86973b0cd2d01163ccf60340c8d295aa645f4.tar.gz
opie-c0e86973b0cd2d01163ccf60340c8d295aa645f4.tar.bz2
the RecMail class get on creation a mailwrapper assigened
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp1
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp1
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp17
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h7
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp1
-rw-r--r--noncore/net/mail/mailtypes.cpp17
-rw-r--r--noncore/net/mail/mailtypes.h7
-rw-r--r--noncore/net/mail/pop3wrapper.cpp1
8 files changed, 50 insertions, 2 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index e5eb335..3222c7e 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -110,48 +110,49 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
set = mailimap_set_new_interval( 1, last );
fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
QString date,subject,from;
if ( err == MAILIMAP_NO_ERROR ) {
mailimap_msg_att * msg_att;
int i = 0;
for (current = clist_begin(result); current != 0; current=clist_next(current)) {
++i;
msg_att = (mailimap_msg_att*)current->data;
RecMail*m = parse_list_result(msg_att);
if (m) {
m->setNumber(i);
m->setMbox(mailbox);
+ m->setWrapper(this);
target.append(m);
}
}
} else {
qDebug("Error fetching headers: %s",m_imap->imap_response);
}
mailimap_fetch_list_free(result);
}
QList<Folder>* IMAPwrapper::listFolders()
{
const char *path, *mask;
int err = MAILIMAP_NO_ERROR;
clist *result;
clistcell *current;
QList<Folder> * folders = new QList<Folder>();
folders->setAutoDelete( true );
login();
if (!m_imap) {
return folders;
}
/*
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index e5eb335..3222c7e 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -110,48 +110,49 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
set = mailimap_set_new_interval( 1, last );
fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
QString date,subject,from;
if ( err == MAILIMAP_NO_ERROR ) {
mailimap_msg_att * msg_att;
int i = 0;
for (current = clist_begin(result); current != 0; current=clist_next(current)) {
++i;
msg_att = (mailimap_msg_att*)current->data;
RecMail*m = parse_list_result(msg_att);
if (m) {
m->setNumber(i);
m->setMbox(mailbox);
+ m->setWrapper(this);
target.append(m);
}
}
} else {
qDebug("Error fetching headers: %s",m_imap->imap_response);
}
mailimap_fetch_list_free(result);
}
QList<Folder>* IMAPwrapper::listFolders()
{
const char *path, *mask;
int err = MAILIMAP_NO_ERROR;
clist *result;
clistcell *current;
QList<Folder> * folders = new QList<Folder>();
folders->setAutoDelete( true );
login();
if (!m_imap) {
return folders;
}
/*
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp
index 5cd45ed..94f5d6f 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.cpp
+++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp
@@ -1,61 +1,78 @@
#include "mailtypes.h"
RecMail::RecMail()
:subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
{
init();
}
RecMail::RecMail(const RecMail&old)
:subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
{
init();
copy_old(old);
qDebug("Copy constructor RecMail");
}
+RecMail::~RecMail()
+{
+ wrapper = 0;
+}
+
void RecMail::copy_old(const RecMail&old)
{
subject = old.subject;
date = old.date;
mbox = old.mbox;
msg_id = old.msg_id;
msg_size = old.msg_size;
msg_number = old.msg_number;
from = old.from;
msg_flags = old.msg_flags;
to = old.to;
cc = old.cc;
bcc = old.bcc;
+ wrapper = old.wrapper;
}
void RecMail::init()
{
to.clear();
cc.clear();
bcc.clear();
+ wrapper = 0;
+}
+
+void RecMail::setWrapper(AbstractMail*awrapper)
+{
+ wrapper = awrapper;
+}
+
+AbstractMail* RecMail::Wrapper()
+{
+ return wrapper;
}
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)
{
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h
index 24518cf..9ef762d 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.h
+++ b/noncore/net/mail/libmailwrapper/mailtypes.h
@@ -1,92 +1,97 @@
#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>
#include <qmap.h>
#include <qvaluelist.h>
+class AbstractMail;
/* 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();
RecMail(const RecMail&old);
- virtual ~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 setMsgid(const QString&id){msg_id=id;}
const QString&Msgid()const{return msg_id;}
void setReplyto(const QString&reply){replyto=reply;}
const QString&Replyto()const{return replyto;}
void setMsgsize(int size){msg_size = size;}
const int Msgsize()const{return msg_size;}
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;}
+
+ void setWrapper(AbstractMail*wrapper);
+ AbstractMail* Wrapper();
protected:
QString subject,date,from,mbox,msg_id,replyto;
int msg_number,msg_size;
QBitArray msg_flags;
QStringList to,cc,bcc;
+ AbstractMail*wrapper;
void init();
void copy_old(const RecMail&old);
};
typedef QMap<QString,QString> part_plist_t;
class RecPart
{
protected:
QString m_type,m_subtype,m_identifier,m_encoding;
unsigned int m_lines,m_size;
part_plist_t m_Parameters;
/* describes the position in the mail */
QValueList<int> m_poslist;
public:
RecPart();
virtual ~RecPart();
const QString&Type()const;
void setType(const QString&type);
const QString&Subtype()const;
void setSubtype(const QString&subtype);
const QString&Identifier()const;
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 49c3b7a..903ef4d 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -60,48 +60,49 @@ RecBody POP3wrapper::parseBody( const char *message )
}
void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
{
int err = MAILPOP3_NO_ERROR;
char *header;
size_t length;
carray *messages;
login();
if (!m_pop3) return;
mailpop3_list( m_pop3, &messages );
for ( int i = carray_count( messages ); i > 0; i-- ) {
mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 );
err = mailpop3_header( m_pop3, info->msg_index, &header, &length );
if ( err != MAILPOP3_NO_ERROR ) {
qDebug( "POP3: error retrieving header msgid: %i", info->msg_index );
logout();
return;
}
RecMail *mail = parseHeader( header );
mail->setNumber( info->msg_index );
+ mail->setWrapper(this);
target.append( mail );
}
logout();
}
RecMail *POP3wrapper::parseHeader( const char *header )
{
int err = MAILIMF_NO_ERROR;
size_t curTok;
RecMail *mail = new RecMail();
mailimf_fields *fields;
err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
mailimf_field *field = (mailimf_field *) current->data;
switch ( field->fld_type ) {
case MAILIMF_FIELD_FROM:
mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
break;
case MAILIMF_FIELD_TO:
mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) );
break;
case MAILIMF_FIELD_CC:
diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp
index 5cd45ed..94f5d6f 100644
--- a/noncore/net/mail/mailtypes.cpp
+++ b/noncore/net/mail/mailtypes.cpp
@@ -1,61 +1,78 @@
#include "mailtypes.h"
RecMail::RecMail()
:subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
{
init();
}
RecMail::RecMail(const RecMail&old)
:subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
{
init();
copy_old(old);
qDebug("Copy constructor RecMail");
}
+RecMail::~RecMail()
+{
+ wrapper = 0;
+}
+
void RecMail::copy_old(const RecMail&old)
{
subject = old.subject;
date = old.date;
mbox = old.mbox;
msg_id = old.msg_id;
msg_size = old.msg_size;
msg_number = old.msg_number;
from = old.from;
msg_flags = old.msg_flags;
to = old.to;
cc = old.cc;
bcc = old.bcc;
+ wrapper = old.wrapper;
}
void RecMail::init()
{
to.clear();
cc.clear();
bcc.clear();
+ wrapper = 0;
+}
+
+void RecMail::setWrapper(AbstractMail*awrapper)
+{
+ wrapper = awrapper;
+}
+
+AbstractMail* RecMail::Wrapper()
+{
+ return wrapper;
}
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)
{
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h
index 24518cf..9ef762d 100644
--- a/noncore/net/mail/mailtypes.h
+++ b/noncore/net/mail/mailtypes.h
@@ -1,92 +1,97 @@
#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>
#include <qmap.h>
#include <qvaluelist.h>
+class AbstractMail;
/* 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();
RecMail(const RecMail&old);
- virtual ~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 setMsgid(const QString&id){msg_id=id;}
const QString&Msgid()const{return msg_id;}
void setReplyto(const QString&reply){replyto=reply;}
const QString&Replyto()const{return replyto;}
void setMsgsize(int size){msg_size = size;}
const int Msgsize()const{return msg_size;}
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;}
+
+ void setWrapper(AbstractMail*wrapper);
+ AbstractMail* Wrapper();
protected:
QString subject,date,from,mbox,msg_id,replyto;
int msg_number,msg_size;
QBitArray msg_flags;
QStringList to,cc,bcc;
+ AbstractMail*wrapper;
void init();
void copy_old(const RecMail&old);
};
typedef QMap<QString,QString> part_plist_t;
class RecPart
{
protected:
QString m_type,m_subtype,m_identifier,m_encoding;
unsigned int m_lines,m_size;
part_plist_t m_Parameters;
/* describes the position in the mail */
QValueList<int> m_poslist;
public:
RecPart();
virtual ~RecPart();
const QString&Type()const;
void setType(const QString&type);
const QString&Subtype()const;
void setSubtype(const QString&subtype);
const QString&Identifier()const;
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 49c3b7a..903ef4d 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -60,48 +60,49 @@ RecBody POP3wrapper::parseBody( const char *message )
}
void POP3wrapper::listMessages(const QString &, QList<RecMail> &target )
{
int err = MAILPOP3_NO_ERROR;
char *header;
size_t length;
carray *messages;
login();
if (!m_pop3) return;
mailpop3_list( m_pop3, &messages );
for ( int i = carray_count( messages ); i > 0; i-- ) {
mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 );
err = mailpop3_header( m_pop3, info->msg_index, &header, &length );
if ( err != MAILPOP3_NO_ERROR ) {
qDebug( "POP3: error retrieving header msgid: %i", info->msg_index );
logout();
return;
}
RecMail *mail = parseHeader( header );
mail->setNumber( info->msg_index );
+ mail->setWrapper(this);
target.append( mail );
}
logout();
}
RecMail *POP3wrapper::parseHeader( const char *header )
{
int err = MAILIMF_NO_ERROR;
size_t curTok;
RecMail *mail = new RecMail();
mailimf_fields *fields;
err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
mailimf_field *field = (mailimf_field *) current->data;
switch ( field->fld_type ) {
case MAILIMF_FIELD_FROM:
mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
break;
case MAILIMF_FIELD_TO:
mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) );
break;
case MAILIMF_FIELD_CC: