summaryrefslogtreecommitdiff
authoralwin <alwin>2004-03-18 18:00:18 (UTC)
committer alwin <alwin>2004-03-18 18:00:18 (UTC)
commitfef9cec046fcf21a4f762c36454b8f253dd3e25e (patch) (side-by-side diff)
treeb87ee38164e1e9ce635dde34c13677f09388c058
parent69fa0e7b5cab5f4cdfdac736e31ff0fd0fbf4312 (diff)
downloadopie-fef9cec046fcf21a4f762c36454b8f253dd3e25e.zip
opie-fef9cec046fcf21a4f762c36454b8f253dd3e25e.tar.gz
opie-fef9cec046fcf21a4f762c36454b8f253dd3e25e.tar.bz2
some (hopeful) improvements
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/accountitem.cpp18
-rw-r--r--noncore/net/mail/accountitem.h20
-rw-r--r--noncore/net/mail/accountview.cpp4
-rw-r--r--noncore/net/mail/accountview.h2
-rw-r--r--noncore/net/mail/composemail.cpp2
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h8
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp90
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.h14
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp86
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h22
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp40
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h24
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp4
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp4
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp6
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp7
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h2
-rw-r--r--noncore/net/mail/opiemail.cpp2
-rw-r--r--noncore/net/mail/viewmail.cpp40
-rw-r--r--noncore/net/mail/viewmail.h7
23 files changed, 221 insertions, 187 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
index e4bb6c5..54d2da2 100644
--- a/noncore/net/mail/accountitem.cpp
+++ b/noncore/net/mail/accountitem.cpp
@@ -71,17 +71,17 @@ void POP3viewItem::refresh()
for ( it = folders->begin(); it!=folders->end(); ++it)
{
item = new POP3folderItem( (*it), this , item );
item->setSelectable( (*it)->may_select());
}
delete folders;
}
-RecBody POP3viewItem::fetchBody( const RecMailP &mail )
+RECBODYP POP3viewItem::fetchBody( const RecMailP &mail )
{
qDebug( "POP3 fetchBody" );
return wrapper->fetchBody( mail );
}
QPopupMenu * POP3viewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
@@ -156,17 +156,17 @@ POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent ,
}
void POP3folderItem::refresh(QValueList<RecMailP>&target)
{
if (folder->may_select())
pop3->getWrapper()->listMessages( folder->getName(),target );
}
-RecBody POP3folderItem::fetchBody(const RecMailP&aMail)
+RECBODYP POP3folderItem::fetchBody(const RecMailP&aMail)
{
return pop3->getWrapper()->fetchBody(aMail);
}
QPopupMenu * POP3folderItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
@@ -262,17 +262,17 @@ void NNTPviewItem::refresh()
for ( it = folders->begin(); it!=folders->end(); ++it)
{
item = new NNTPfolderItem( (*it), this , item );
item->setSelectable( (*it)->may_select());
}
delete folders;
}
-RecBody NNTPviewItem::fetchBody( const RecMailP &mail )
+RECBODYP NNTPviewItem::fetchBody( const RecMailP &mail )
{
qDebug( "NNTP fetchBody" );
return wrapper->fetchBody( mail );
}
QPopupMenu * NNTPviewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
@@ -360,17 +360,17 @@ NNTPfolderItem::NNTPfolderItem( const FolderP &folderInit, NNTPviewItem *parent
}
void NNTPfolderItem::refresh(QValueList<RecMailP>&target)
{
if (folder->may_select())
nntp->getWrapper()->listMessages( folder->getName(),target );
}
-RecBody NNTPfolderItem::fetchBody(const RecMailP&aMail)
+RECBODYP NNTPfolderItem::fetchBody(const RecMailP&aMail)
{
return nntp->getWrapper()->fetchBody(aMail);
}
QPopupMenu * NNTPfolderItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
@@ -557,19 +557,19 @@ void IMAPviewItem::contextMenuSelected(int id)
SETPIX(PIXMAP_IMAPFOLDER);
refreshFolders(false);
break;
default:
break;
}
}
-RecBody IMAPviewItem::fetchBody(const RecMailP&)
+RECBODYP IMAPviewItem::fetchBody(const RecMailP&)
{
- return RecBody();
+ return new RecBody();
}
bool IMAPviewItem::offline()
{
return account->getOffline();
}
IMAPfolderItem::IMAPfolderItem( const FolderP& folderInit, IMAPviewItem *parent , QListViewItem*after )
@@ -617,17 +617,17 @@ void IMAPfolderItem::refresh(QValueList<RecMailP>&target)
imap->getWrapper()->listMessages( folder->getName(),target );
}
else
{
target.clear();
}
}
-RecBody IMAPfolderItem::fetchBody(const RecMailP&aMail)
+RECBODYP IMAPfolderItem::fetchBody(const RecMailP&aMail)
{
return imap->getWrapper()->fetchBody(aMail);
}
QPopupMenu * IMAPfolderItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
@@ -795,17 +795,17 @@ void MHviewItem::refresh(bool force)
{
item = new MHfolderItem( (*it), this , item );
}
item->setSelectable((*it)->may_select());
}
delete folders;
}
-RecBody MHviewItem::fetchBody( const RecMailP &mail )
+RECBODYP MHviewItem::fetchBody( const RecMailP &mail )
{
qDebug( "MH fetchBody" );
return wrapper->fetchBody( mail );
}
QPopupMenu * MHviewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
@@ -916,17 +916,17 @@ const FolderP&MHfolderItem::getFolder()const
}
void MHfolderItem::refresh(QValueList<RecMailP>&target)
{
if (folder->may_select())
mbox->getWrapper()->listMessages( folder->getName(),target );
}
-RecBody MHfolderItem::fetchBody(const RecMailP&aMail)
+RECBODYP MHfolderItem::fetchBody(const RecMailP&aMail)
{
return mbox->getWrapper()->fetchBody(aMail);
}
void MHfolderItem::deleteFolder()
{
int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h
index 6cdb260..f125eeb 100644
--- a/noncore/net/mail/accountitem.h
+++ b/noncore/net/mail/accountitem.h
@@ -12,28 +12,30 @@ class QPopupMenu;
class Selectstore;
class AccountView;
class POP3account;
class NNTPaccount;
class IMAPaccount;
class AbstractMail;
class Folder;
+#define RECBODYP Opie::Core::OSmartPointer<RecBody>
+
class AccountViewItem : public QListViewItem
{
public:
AccountViewItem( AccountView *parent );
AccountViewItem( QListViewItem *parent);
AccountViewItem( QListViewItem *parent , QListViewItem*after );
AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after );
virtual ~AccountViewItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&)=0;
- virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&)=0;
+ virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&)=0;
virtual QPopupMenu * getContextMenu(){return 0;};
virtual void contextMenuSelected(int){}
virtual AccountView*accountView();
virtual bool matchName(const QString&name)const;
virtual bool isDraftfolder();
protected:
AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0);
@@ -47,17 +49,17 @@ protected:
class POP3viewItem : public AccountViewItem
{
public:
POP3viewItem( POP3account *a, AccountView *parent );
virtual ~POP3viewItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
- virtual RecBody fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
+ virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
POP3account *account;
virtual void refresh();
AbstractMail *wrapper;
@@ -67,34 +69,34 @@ protected:
class POP3folderItem : public AccountViewItem
{
public:
POP3folderItem( const Opie::Core::OSmartPointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after );
virtual ~POP3folderItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
- virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
+ virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
void downloadMails();
POP3viewItem *pop3;
};
class NNTPviewItem : public AccountViewItem
{
public:
NNTPviewItem( NNTPaccount *a, AccountView *parent );
virtual ~NNTPviewItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
- virtual RecBody fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
+ virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
NNTPaccount *account;
virtual void refresh();
AbstractMail *wrapper;
@@ -105,17 +107,17 @@ protected:
class NNTPfolderItem : public AccountViewItem
{
public:
NNTPfolderItem(const Opie::Core::OSmartPointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after );
virtual ~NNTPfolderItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
- virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
+ virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
void downloadMails();
NNTPviewItem *nntp;
};
@@ -123,17 +125,17 @@ protected:
class IMAPviewItem : public AccountViewItem
{
friend class IMAPfolderItem;
public:
IMAPviewItem( IMAPaccount *a, AccountView *parent );
virtual ~IMAPviewItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
- virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
+ virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
const QStringList&subFolders();
virtual void refreshFolders(bool force=false);
bool offline();
protected:
@@ -146,17 +148,17 @@ protected:
class IMAPfolderItem : public AccountViewItem
{
public:
IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after );
IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
virtual ~IMAPfolderItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
- virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
+ virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
virtual const QString& Delemiter()const;
protected:
virtual void createNewFolder();
virtual void deleteFolder();
virtual void downloadMails();
IMAPviewItem *imap;
@@ -165,17 +167,17 @@ protected:
class MHviewItem : public AccountViewItem
{
friend class MHfolderItem;
public:
MHviewItem( const QString&aMboxPath, AccountView *parent );
virtual ~MHviewItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
- virtual RecBody fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
+ virtual RECBODYP fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
QStringList subFolders();
virtual void refresh(bool force=false);
protected:
void downloadMails();
@@ -188,17 +190,17 @@ protected:
class MHfolderItem : public AccountViewItem
{
public:
MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHviewItem *parent , QListViewItem*after );
MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master);
virtual ~MHfolderItem();
virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
- virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
+ virtual RECBODYP fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
virtual const Opie::Core::OSmartPointer<Folder>&getFolder()const;
virtual bool isDraftfolder();
protected:
void downloadMails();
virtual void createFolder();
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 811e57a..f0a163e 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -109,20 +109,20 @@ void AccountView::refreshCurrent()
view->refresh(headerlist);
emit refreshMailview(headerlist);
}
void AccountView::refreshAll()
{
}
-RecBody AccountView::fetchBody(const RecMailP&aMail)
+RecBodyP AccountView::fetchBody(const RecMailP&aMail)
{
QListViewItem*item = selectedItem ();
- if (!item) return RecBody();
+ if (!item) return new RecBody();
AccountViewItem *view = static_cast<AccountViewItem *>(item);
return view->fetchBody(aMail);
}
void AccountView::setupFolderselect(Selectstore*sels)
{
QPEApplication::showDialog( sels );
QStringList sFolders;
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index b082b1f..787b0b0 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -16,17 +16,17 @@ class MHviewItem;
class AccountView : public QListView
{
Q_OBJECT
public:
AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
virtual ~AccountView();
virtual void populate( QList<Account> list );
- virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail);
+ virtual RecBodyP fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail);
virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper);
virtual bool currentisDraft();
public slots:
virtual void refreshAll();
virtual void refresh(QListViewItem *item);
virtual void refreshCurrent();
virtual void slotHold(int, QListViewItem *,const QPoint&,int);
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp
index 5bc2883..988a1d9 100644
--- a/noncore/net/mail/composemail.cpp
+++ b/noncore/net/mail/composemail.cpp
@@ -275,17 +275,17 @@ void ComposeMail::reject()
ComposeMail::~ComposeMail()
{
}
void ComposeMail::reEditMail(const RecMailP&current)
{
RecMailP data = current;
- message->setText(data->Wrapper()->fetchBody(current).Bodytext());
+ message->setText(data->Wrapper()->fetchBody(current)->Bodytext());
subjectLine->setText( data->getSubject());
toLine->setText(data->To().join(","));
ccLine->setText(data->CC().join(","));
bccLine->setText(data->Bcc().join(","));
replyLine->setText(data->Replyto());
}
AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 2d55c83..e5d64a6 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -19,20 +19,20 @@ class AbstractMail:public QObject
{
Q_OBJECT
public:
AbstractMail(){};
virtual ~AbstractMail(){}
virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0;
virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0;
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0;
- virtual RecBody fetchBody(const RecMailP&mail)=0;
- virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part)=0;
- virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part)=0;
- virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part)=0;
+ virtual RecBodyP fetchBody(const RecMailP&mail)=0;
+ virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part)=0;
+ virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part)=0;
+ virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part)=0;
virtual encodedString* fetchRawBody(const RecMailP&mail)=0;
virtual void deleteMail(const RecMailP&mail)=0;
virtual void answeredMail(const RecMailP&mail)=0;
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0;
virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target);
virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0;
virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index f428415..0c68280 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -17,92 +17,92 @@ Genericwrapper::~Genericwrapper()
mailfolder_free(m_folder);
}
if (m_storage) {
mailstorage_free(m_storage);
}
cleanMimeCache();
}
-void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
+void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime)
{
if (!mime) {
return;
}
mailmime_field*field = 0;
mailmime_single_fields fields;
memset(&fields, 0, sizeof(struct mailmime_single_fields));
if (mime->mm_mime_fields != NULL) {
mailmime_single_fields_init(&fields, mime->mm_mime_fields,
mime->mm_content_type);
}
mailmime_content*type = fields.fld_content;
clistcell*current;
if (!type) {
- target.setType("text");
- target.setSubtype("plain");
+ target->setType("text");
+ target->setSubtype("plain");
} else {
- target.setSubtype(type->ct_subtype);
+ target->setSubtype(type->ct_subtype);
switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
case MAILMIME_DISCRETE_TYPE_TEXT:
- target.setType("text");
+ target->setType("text");
break;
case MAILMIME_DISCRETE_TYPE_IMAGE:
- target.setType("image");
+ target->setType("image");
break;
case MAILMIME_DISCRETE_TYPE_AUDIO:
- target.setType("audio");
+ target->setType("audio");
break;
case MAILMIME_DISCRETE_TYPE_VIDEO:
- target.setType("video");
+ target->setType("video");
break;
case MAILMIME_DISCRETE_TYPE_APPLICATION:
- target.setType("application");
+ target->setType("application");
break;
case MAILMIME_DISCRETE_TYPE_EXTENSION:
default:
if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
- target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
+ target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
}
break;
}
if (type->ct_parameters) {
fillParameters(target,type->ct_parameters);
}
}
if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
field = (mailmime_field*)current->data;
switch(field->fld_type) {
case MAILMIME_FIELD_TRANSFER_ENCODING:
- target.setEncoding(getencoding(field->fld_data.fld_encoding));
+ target->setEncoding(getencoding(field->fld_data.fld_encoding));
break;
case MAILMIME_FIELD_ID:
- target.setIdentifier(field->fld_data.fld_id);
+ target->setIdentifier(field->fld_data.fld_id);
break;
case MAILMIME_FIELD_DESCRIPTION:
- target.setDescription(field->fld_data.fld_description);
+ target->setDescription(field->fld_data.fld_description);
break;
default:
break;
}
}
}
}
-void Genericwrapper::fillParameters(RecPart&target,clist*parameters)
+void Genericwrapper::fillParameters(RecPartP&target,clist*parameters)
{
if (!parameters) {return;}
clistcell*current=0;
mailmime_parameter*param;
for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
param = (mailmime_parameter*)current->data;
if (param) {
- target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
+ target->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
}
}
}
QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
{
QString enc="7bit";
if (!aEnc) return enc;
@@ -127,116 +127,116 @@ QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
if (aEnc->enc_token) {
enc = QString(aEnc->enc_token);
}
break;
}
return enc;
}
-void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count)
+void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count)
{
if (current_rec >= 10) {
qDebug("too deep recursion!");
}
if (!message || !mime) {
return;
}
int r;
char*data = 0;
size_t len;
clistiter * cur = 0;
QString b;
- RecPart part;
+ RecPartP part = new RecPart();
switch (mime->mm_type) {
case MAILMIME_SINGLE:
{
QValueList<int>countlist = recList;
countlist.append(current_count);
r = mailmessage_fetch_section(message,mime,&data,&len);
- part.setSize(len);
- part.setPositionlist(countlist);
+ part->setSize(len);
+ part->setPositionlist(countlist);
b = gen_attachment_id();
- part.setIdentifier(b);
+ part->setIdentifier(b);
fillSingleBody(part,message,mime);
- if (part.Type()=="text" && target.Bodytext().isNull()) {
+ if (part->Type()=="text" && target->Bodytext().isNull()) {
encodedString*rs = new encodedString();
rs->setContent(data,len);
- encodedString*res = decode_String(rs,part.Encoding());
+ encodedString*res = decode_String(rs,part->Encoding());
if (countlist.count()>2) {
bodyCache[b]=rs;
- target.addPart(part);
+ target->addPart(part);
} else {
delete rs;
}
b = QString(res->Content());
delete res;
- target.setBodytext(b);
- target.setDescription(part);
+ target->setBodytext(b);
+ target->setDescription(part);
} else {
bodyCache[b]=new encodedString(data,len);
- target.addPart(part);
+ target->addPart(part);
}
}
break;
case MAILMIME_MULTIPLE:
{
unsigned int ccount = 1;
mailmime*cbody=0;
QValueList<int>countlist = recList;
for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
cbody = (mailmime*)clist_content(cur);
if (cbody->mm_type==MAILMIME_MULTIPLE) {
- RecPart targetPart;
- targetPart.setType("multipart");
+ RecPartP targetPart = new RecPart();
+ targetPart->setType("multipart");
countlist.append(current_count);
- targetPart.setPositionlist(countlist);
- target.addPart(targetPart);
+ targetPart->setPositionlist(countlist);
+ target->addPart(targetPart);
}
traverseBody(target,message, cbody,countlist,current_rec+1,ccount);
if (cbody->mm_type==MAILMIME_MULTIPLE) {
countlist = recList;
}
++ccount;
}
}
break;
case MAILMIME_MESSAGE:
{
QValueList<int>countlist = recList;
countlist.append(current_count);
/* the own header is always at recursion 0 - we don't need that */
if (current_rec > 0) {
- part.setPositionlist(countlist);
+ part->setPositionlist(countlist);
r = mailmessage_fetch_section(message,mime,&data,&len);
- part.setSize(len);
- part.setPositionlist(countlist);
+ part->setSize(len);
+ part->setPositionlist(countlist);
b = gen_attachment_id();
- part.setIdentifier(b);
- part.setType("message");
- part.setSubtype("rfc822");
+ part->setIdentifier(b);
+ part->setType("message");
+ part->setSubtype("rfc822");
bodyCache[b]=new encodedString(data,len);
- target.addPart(part);
+ target->addPart(part);
}
if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
}
}
break;
}
}
-RecBody Genericwrapper::parseMail( mailmessage * msg )
+RecBodyP Genericwrapper::parseMail( mailmessage * msg )
{
int err = MAILIMF_NO_ERROR;
mailmime_single_fields fields;
/* is bound to msg and will be freed there */
mailmime * mime=0;
- RecBody body;
+ RecBodyP body = new RecBody();
memset(&fields, 0, sizeof(struct mailmime_single_fields));
err = mailmessage_get_bodystructure(msg,&mime);
QValueList<int>recList;
traverseBody(body,msg,mime,recList);
return body;
}
QString Genericwrapper::parseDateTime( mailimf_date_time *date )
@@ -327,33 +327,33 @@ QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
}
result.append( parseMailbox( box ) );
}
return result;
}
-encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPart&part)
+encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPartP&part)
{
- QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
+ QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier());
if (it==bodyCache.end()) return new encodedString();
- encodedString*t = decode_String(it.data(),part.Encoding());
+ encodedString*t = decode_String(it.data(),part->Encoding());
return t;
}
-encodedString* Genericwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part)
+encodedString* Genericwrapper::fetchRawPart(const RecMailP&,const RecPartP&part)
{
- QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
+ QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part->Identifier());
if (it==bodyCache.end()) return new encodedString();
encodedString*t = it.data();
return t;
}
-QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part)
+QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part)
{
encodedString*t = fetchDecodedPart(mail,part);
QString text=t->Content();
delete t;
return text;
}
void Genericwrapper::cleanMimeCache()
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h
index f5b9504..8be9212 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.h
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.h
@@ -29,35 +29,35 @@ struct mailimf_in_reply_to;
*/
class Genericwrapper : public AbstractMail
{
Q_OBJECT
public:
Genericwrapper();
virtual ~Genericwrapper();
- virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part);
- virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part);
- virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part);
+ virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part);
+ virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part);
+ virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part);
virtual void cleanMimeCache();
virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;}
virtual void logout(){};
virtual void storeMessage(const char*msg,size_t length, const QString&folder){};
protected:
- RecBody parseMail( mailmessage * msg );
+ RecBodyP parseMail( mailmessage * msg );
QString parseMailboxList( mailimf_mailbox_list *list );
QString parseMailbox( mailimf_mailbox *box );
QString parseGroup( mailimf_group *group );
QString parseAddressList( mailimf_address_list *list );
QString parseDateTime( mailimf_date_time *date );
- void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1);
- static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
- static void fillParameters(RecPart&target,clist*parameters);
+ void traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1);
+ static void fillSingleBody(RecPartP&target,mailmessage*message,mailmime*mime);
+ static void fillParameters(RecPartP&target,clist*parameters);
static QString getencoding(mailmime_mechanism*aEnc);
virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false);
QStringList parseInreplies(mailimf_in_reply_to * in_replies);
QString msgTempName;
unsigned int last_msg_id;
QMap<QString,encodedString*> bodyCache;
mailstorage * m_storage;
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 56e7df9..230cf53 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -478,19 +478,19 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
}
if (m) {
m->setFlags(mFlags);
m->setMsgsize(size);
}
return m;
}
-RecBody IMAPwrapper::fetchBody(const RecMailP&mail)
+RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
{
- RecBody body;
+ RecBodyP body = new RecBody();
const char *mb;
int err = MAILIMAP_NO_ERROR;
clist *result = 0;
clistcell *current;
mailimap_fetch_att *fetchAtt = 0;
mailimap_fetch_type *fetchType = 0;
mailimap_set *set = 0;
mailimap_body*body_desc = 0;
@@ -637,71 +637,71 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int
qDebug("error fetching text: %s",m_imap->imap_response);
}
if (result) mailimap_fetch_list_free(result);
return res;
}
/* current_recursion is for recursive calls.
current_count means the position inside the internal loop! */
-void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body,
+void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,
int current_recursion,QValueList<int>recList,int current_count)
{
if (!body || current_recursion>=10) {
return;
}
switch (body->bd_type) {
case MAILIMAP_BODY_1PART:
{
QValueList<int>countlist = recList;
countlist.append(current_count);
- RecPart currentPart;
+ RecPartP currentPart = new RecPart();
mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
QString id("");
- currentPart.setPositionlist(countlist);
+ currentPart->setPositionlist(countlist);
for (unsigned int j = 0; j < countlist.count();++j) {
id+=(j>0?" ":"");
id+=QString("%1").arg(countlist[j]);
}
qDebug("ID = %s",id.latin1());
- currentPart.setIdentifier(id);
+ currentPart->setIdentifier(id);
fillSinglePart(currentPart,part1);
/* important: Check for is NULL 'cause a body can be empty!
And we put it only into the mail if it is the FIRST part */
- if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body.Bodytext().isNull() && countlist[0]==1) {
- QString body_text = fetchTextPart(mail,countlist,true,currentPart.Encoding());
- target_body.setDescription(currentPart);
- target_body.setBodytext(body_text);
+ if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
+ QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
+ target_body->setDescription(currentPart);
+ target_body->setBodytext(body_text);
if (countlist.count()>1) {
- target_body.addPart(currentPart);
+ target_body->addPart(currentPart);
}
} else {
- target_body.addPart(currentPart);
+ target_body->addPart(currentPart);
}
if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
}
}
break;
case MAILIMAP_BODY_MPART:
{
QValueList<int>countlist = recList;
clistcell*current=0;
mailimap_body*current_body=0;
unsigned int ccount = 1;
mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
current_body = (mailimap_body*)current->data;
if (current_body->bd_type==MAILIMAP_BODY_MPART) {
- RecPart targetPart;
- targetPart.setType("multipart");
+ RecPartP targetPart = new RecPart();
+ targetPart->setType("multipart");
fillMultiPart(targetPart,mailDescription);
countlist.append(current_count);
- targetPart.setPositionlist(countlist);
- target_body.addPart(targetPart);
+ targetPart->setPositionlist(countlist);
+ target_body->addPart(targetPart);
QString id("");
for (unsigned int j = 0; j < countlist.count();++j) {
id+=(j>0?" ":"");
id+=QString("%1").arg(countlist[j]);
}
qDebug("ID(mpart) = %s",id.latin1());
}
traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
@@ -712,81 +712,81 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&ta
}
}
break;
default:
break;
}
}
-void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description)
+void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description)
{
if (!Description) {
return;
}
switch (Description->bd_type) {
case MAILIMAP_BODY_TYPE_1PART_TEXT:
- target_part.setType("text");
+ target_part->setType("text");
fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
break;
case MAILIMAP_BODY_TYPE_1PART_BASIC:
fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
break;
case MAILIMAP_BODY_TYPE_1PART_MSG:
- target_part.setType("message");
+ target_part->setType("message");
fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
break;
default:
break;
}
}
-void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which)
+void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which)
{
if (!which) {
return;
}
QString sub;
sub = which->bd_media_text;
qDebug("Type= text/%s",which->bd_media_text);
- target_part.setSubtype(sub.lower());
- target_part.setLines(which->bd_lines);
+ target_part->setSubtype(sub.lower());
+ target_part->setLines(which->bd_lines);
fillBodyFields(target_part,which->bd_fields);
}
-void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which)
+void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which)
{
if (!which) {
return;
}
- target_part.setSubtype("rfc822");
+ target_part->setSubtype("rfc822");
qDebug("Message part");
/* we set this type to text/plain */
- target_part.setLines(which->bd_lines);
+ target_part->setLines(which->bd_lines);
fillBodyFields(target_part,which->bd_fields);
}
-void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which)
+void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which)
{
if (!which) return;
QString sub = which->bd_media_subtype;
- target_part.setSubtype(sub.lower());
+ target_part->setSubtype(sub.lower());
if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
clistcell*cur = 0;
mailimap_single_body_fld_param*param=0;
for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
param = (mailimap_single_body_fld_param*)cur->data;
if (param) {
- target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
+ target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
}
}
}
}
-void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which)
+void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which)
{
if (!which) {
return;
}
QString type,sub;
switch (which->bd_media_basic->med_type) {
case MAILIMAP_MEDIA_BASIC_APPLICATION:
type = "application";
@@ -813,31 +813,31 @@ void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_bas
break;
}
if (which->bd_media_basic->med_subtype) {
sub = which->bd_media_basic->med_subtype;
} else {
sub = "";
}
qDebug("Type = %s/%s",type.latin1(),sub.latin1());
- target_part.setType(type.lower());
- target_part.setSubtype(sub.lower());
+ target_part->setType(type.lower());
+ target_part->setSubtype(sub.lower());
fillBodyFields(target_part,which->bd_fields);
}
-void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
+void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which)
{
if (!which) return;
if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
clistcell*cur;
mailimap_single_body_fld_param*param=0;
for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
param = (mailimap_single_body_fld_param*)cur->data;
if (param) {
- target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
+ target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
}
}
}
mailimap_body_fld_enc*enc = which->bd_encoding;
QString encoding("");
switch (enc->enc_type) {
case MAILIMAP_BODY_FLD_ENC_7BIT:
encoding = "7bit";
@@ -859,20 +859,20 @@ void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
if (enc->enc_value) {
char*t=enc->enc_value;
encoding=QString(enc->enc_value);
enc->enc_value=0L;
free(t);
}
}
if (which->bd_description) {
- target_part.setDescription(QString(which->bd_description));
+ target_part->setDescription(QString(which->bd_description));
}
- target_part.setEncoding(encoding);
- target_part.setSize(which->bd_size);
+ target_part->setEncoding(encoding);
+ target_part->setSize(which->bd_size);
}
void IMAPwrapper::deleteMail(const RecMailP&mail)
{
mailimap_flag_list*flist;
mailimap_set *set;
mailimap_store_att_flags * store_flags;
int err;
@@ -943,32 +943,32 @@ QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&pat
if (r->Length()>0) {
body = r->Content();
}
delete r;
}
return body;
}
-QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part)
+QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part)
{
- return fetchTextPart(mail,part.Positionlist(),false,part.Encoding());
+ return fetchTextPart(mail,part->Positionlist(),false,part->Encoding());
}
-encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPart&part)
+encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part)
{
- encodedString*res = fetchRawPart(mail,part.Positionlist(),false);
- encodedString*r = decode_String(res,part.Encoding());
+ encodedString*res = fetchRawPart(mail,part->Positionlist(),false);
+ encodedString*r = decode_String(res,part->Encoding());
delete res;
return r;
}
-encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part)
+encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part)
{
- return fetchRawPart(mail,part.Positionlist(),false);
+ return fetchRawPart(mail,part->Positionlist(),false);
}
int IMAPwrapper::deleteAllMail(const FolderP&folder)
{
login();
if (!m_imap) {
return 0;
}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 7448acb..e56605a 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -30,20 +30,20 @@ public:
virtual void deleteMail(const RecMailP&mail);
virtual void answeredMail(const RecMailP&mail);
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
- virtual RecBody fetchBody(const RecMailP&mail);
- virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part);
- virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part);
- virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part);
+ virtual RecBodyP fetchBody(const RecMailP&mail);
+ virtual QString fetchTextPart(const RecMailP&mail,const RecPartP&part);
+ virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPartP&part);
+ virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPartP&part);
virtual encodedString* fetchRawBody(const RecMailP&mail);
virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0,
const QString& delemiter="/",bool getsubfolder=false);
virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder);
static void imap_progress( size_t current, size_t maximum );
@@ -55,25 +55,25 @@ protected:
RecMail*parse_list_result(mailimap_msg_att*);
void login();
bool start_tls(bool force=true);
virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call);
int selectMbox(const QString&mbox);
- void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
- void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
- void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
- void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
- void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which);
- void traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
+ void fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description);
+ void fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which);
+ void fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which);
+ void fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which);
+ void fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which);
+ void traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
/* just helpers */
- static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
+ static void fillBodyFields(RecPartP&target_part,mailimap_body_fields*which);
static QStringList address_list_to_stringlist(clist*list);
IMAPaccount *account;
mailimap *m_imap;
QString m_Lastmbox;
};
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp
index fd91fe5..90b8865 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.cpp
+++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp
@@ -106,22 +106,39 @@ void RecMail::setReferences(const QStringList&list)
}
const QStringList& RecMail::References()const
{
return references;
}
RecPart::RecPart()
- : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0)
+ : Opie::Core::ORefCount(),
+ m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0)
{
m_Parameters.clear();
m_poslist.clear();
}
+RecPart::RecPart(const RecPart&old)
+ : Opie::Core::ORefCount(),
+ m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0)
+{
+ m_type = old.m_type;
+ m_subtype = old.m_subtype;
+ m_identifier = old.m_identifier;
+ m_encoding = old.m_encoding;
+ m_description = old.m_description;
+ m_lines = old.m_lines;
+ m_size = old.m_size;
+ m_Parameters = old.m_Parameters;
+ m_poslist = old.m_poslist;
+ qDebug("RecPart copy constructor");
+}
+
RecPart::~RecPart()
{
}
void RecPart::setSize(unsigned int size)
{
m_size = size;
}
@@ -222,57 +239,66 @@ void RecPart::setPositionlist(const QValueList<int>&poslist)
}
const QValueList<int>& RecPart::Positionlist()const
{
return m_poslist;
}
RecBody::RecBody()
- : m_BodyText(),m_PartsList(),m_description()
+ : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart())
{
m_PartsList.clear();
}
+RecBody::RecBody(const RecBody&old)
+ :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart())
+{
+ m_BodyText = old.m_BodyText;
+ m_PartsList = old.m_PartsList;
+ m_description = old.m_description;
+ qDebug("Recbody copy constructor");
+}
+
RecBody::~RecBody()
{
}
void RecBody::setBodytext(const QString&bodyText)
{
m_BodyText = bodyText;
}
const QString& RecBody::Bodytext()const
{
return m_BodyText;
}
-void RecBody::setParts(const QValueList<RecPart>&parts)
+void RecBody::setParts(const QValueList<RecPartP>&parts)
{
m_PartsList.clear();
m_PartsList = parts;
}
-const QValueList<RecPart>& RecBody::Parts()const
+const QValueList<RecPartP>& RecBody::Parts()const
{
return m_PartsList;
}
-void RecBody::addPart(const RecPart& part)
+void RecBody::addPart(const RecPartP& part)
{
m_PartsList.append(part);
}
-void RecBody::setDescription(const RecPart&des)
+void RecBody::setDescription(const RecPartP&des)
{
m_description = des;
}
-const RecPart& RecBody::Description()const
+const RecPartP& RecBody::Description()const
{
return m_description;
}
/* handling encoded content */
encodedString::encodedString()
{
init();
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h
index 941556a..c317880 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.h
+++ b/noncore/net/mail/libmailwrapper/mailtypes.h
@@ -79,27 +79,28 @@ protected:
AbstractMail*wrapper;
void init();
void copy_old(const RecMail&old);
};
typedef Opie::Core::OSmartPointer<RecMail> RecMailP;
typedef QMap<QString,QString> part_plist_t;
-class RecPart
+class RecPart:public Opie::Core::ORefCount
{
protected:
QString m_type,m_subtype,m_identifier,m_encoding,m_description;
unsigned int m_lines,m_size;
part_plist_t m_Parameters;
/* describes the position in the mail */
QValueList<int> m_poslist;
public:
RecPart();
+ RecPart(const 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;
void setIdentifier(const QString&identifier);
@@ -116,37 +117,42 @@ public:
void setParameters(const part_plist_t&list);
const part_plist_t&Parameters()const;
void addParameter(const QString&key,const QString&value);
const QString searchParamter(const QString&key)const;
void setPositionlist(const QValueList<int>&poslist);
const QValueList<int>& Positionlist()const;
};
-class RecBody
+typedef Opie::Core::OSmartPointer<RecPart> RecPartP;
+
+class RecBody:public Opie::Core::ORefCount
{
protected:
QString m_BodyText;
- QValueList<RecPart> m_PartsList;
- RecPart m_description;
+ QValueList<RecPartP> m_PartsList;
+ RecPartP m_description;
public:
RecBody();
+ RecBody(const RecBody&old);
virtual ~RecBody();
void setBodytext(const QString&);
const QString& Bodytext()const;
- void setDescription(const RecPart&des);
- const RecPart& Description()const;
+ void setDescription(const RecPartP&des);
+ const RecPartP& Description()const;
- void setParts(const QValueList<RecPart>&parts);
- const QValueList<RecPart>& Parts()const;
- void addPart(const RecPart&part);
+ void setParts(const QValueList<RecPartP>&parts);
+ const QValueList<RecPartP>& Parts()const;
+ void addPart(const RecPartP&part);
};
+typedef Opie::Core::OSmartPointer<RecBody> RecBodyP;
+
class encodedString
{
public:
encodedString();
/*
creates an new content string.
it makes a deep copy of it!
*/
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 4aee0be..e3c75f3 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -82,19 +82,19 @@ void MBOXwrapper::deleteMail(const RecMailP & mail)
mailfolder_free(folder);
mailstorage_free(storage);
}
void MBOXwrapper::answeredMail(const RecMailP&)
{
}
-RecBody MBOXwrapper::fetchBody( const RecMailP &mail )
+RecBodyP MBOXwrapper::fetchBody( const RecMailP &mail )
{
- RecBody body;
+ RecBodyP body = new RecBody();
mailstorage*storage = mailstorage_new(NULL);
QString p = MBOXPath+"/";
p+=mail->getMbox();
mailmessage * msg;
char*data=0;
size_t size;
int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index a2ecfee..9731b85 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -23,17 +23,17 @@ public:
virtual void answeredMail(const RecMailP&mail);
virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0,
const QString&d="",bool s=false);
virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
- virtual RecBody fetchBody( const RecMailP &mail );
+ virtual RecBodyP fetchBody( const RecMailP &mail );
static void mbox_progress( size_t current, size_t maximum );
virtual encodedString* fetchRawBody(const RecMailP&mail);
virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target);
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
index 5eae31f..12472e9 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
@@ -118,19 +118,19 @@ void MHwrapper::deleteMail(const RecMailP&mail)
qDebug("error deleting mail");
}
}
void MHwrapper::answeredMail(const RecMailP&)
{
}
-RecBody MHwrapper::fetchBody( const RecMailP &mail )
+RecBodyP MHwrapper::fetchBody( const RecMailP &mail )
{
- RecBody body;
+ RecBodyP body = new RecBody();
init_storage();
if (!m_storage) {
return body;
}
mailmessage * msg;
char*data=0;
/* mail should hold the complete path! */
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h
index 0846ec3..4310c84 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.h
@@ -28,17 +28,17 @@ public:
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0,
const QString&d="",bool s=false);
virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
- virtual RecBody fetchBody( const RecMailP &mail );
+ virtual RecBodyP fetchBody( const RecMailP &mail );
static void mbox_progress( size_t current, size_t maximum );
virtual encodedString* fetchRawBody(const RecMailP&mail);
virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target);
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
index 9de958d..cc36f32 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
@@ -28,27 +28,27 @@ NNTPwrapper::~NNTPwrapper() {
}
}
void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) {
qDebug( "NNTP: %i of %i", current, maximum );
}
-RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) {
+RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) {
int err = NEWSNNTP_NO_ERROR;
char *message = 0;
size_t length = 0;
+ RecBodyP body = new RecBody();
login();
if ( !m_nntp ) {
- return RecBody();
+ return body;
}
- RecBody body;
mailmessage * mailmsg;
if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) {
qDebug("Message to large: %i",mail->Msgsize());
return body;
}
QFile msg_cache(msgTempName);
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h
index a87a8e8..2fb82f2 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h
@@ -25,17 +25,17 @@ public:
virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
/* mailbox will be ignored */
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
QStringList listAllNewsgroups(const QString&mask = QString::null);
virtual void deleteMail(const RecMailP&mail);
virtual void answeredMail(const RecMailP&mail);
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
- virtual RecBody fetchBody( const RecMailP &mail );
+ virtual RecBodyP fetchBody( const RecMailP &mail );
virtual encodedString* fetchRawBody(const RecMailP&mail);
virtual void logout();
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
static void nntp_progress( size_t current, size_t maximum );
protected:
void login();
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index f5694fe..1b7a1b4 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -26,27 +26,28 @@ POP3wrapper::~POP3wrapper() {
msg_cache.remove();
}
}
void POP3wrapper::pop3_progress( size_t current, size_t maximum ) {
qDebug( "POP3: %i of %i", current, maximum );
}
-RecBody POP3wrapper::fetchBody( const RecMailP &mail ) {
+RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) {
int err = MAILPOP3_NO_ERROR;
char *message = 0;
size_t length = 0;
+ RecBodyP body = new RecBody();
+
login();
if ( !m_pop3 ) {
- return RecBody();
+ return body;
}
- RecBody body;
mailmessage * mailmsg;
if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) {
qDebug("Message to large: %i",mail->Msgsize());
return body;
}
QFile msg_cache(msgTempName);
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index c46b941..5101fa5 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -21,17 +21,17 @@ public:
virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
/* mailbox will be ignored */
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMailP&mail);
virtual void answeredMail(const RecMailP&mail);
virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
- virtual RecBody fetchBody( const RecMailP &mail );
+ virtual RecBodyP fetchBody( const RecMailP &mail );
virtual encodedString* fetchRawBody(const RecMailP&mail);
virtual void logout();
virtual MAILLIB::ATYPE getType()const;
virtual const QString&getName()const;
static void pop3_progress( size_t current, size_t maximum );
protected:
void login();
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index dd305df..5da2161 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -141,17 +141,17 @@ void OpieMail::slotEditAccounts()
folderView->populate( settings->getAccounts() );
}
void OpieMail::displayMail()
{
QListViewItem*item = mailView->currentItem();
if (!item) return;
RecMailP mail = ((MailListViewItem*)item)->data();
- RecBody body = folderView->fetchBody(mail);
+ RecBodyP body = folderView->fetchBody(mail);
ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
readMail.setBody( body );
readMail.setMail( mail );
readMail.showMaximized();
readMail.exec();
if ( readMail.deleted )
{
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index f00d2cb..156e11d 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -73,32 +73,32 @@ AttachItem* ViewMail::lastChild(AttachItem*parent)
AttachItem*temp=0;
while( (temp=(AttachItem*)item->nextSibling()))
{
item = temp;
}
return item;
}
-void ViewMail::setBody( RecBody body )
+void ViewMail::setBody(const RecBodyP&body )
{
m_body = body;
- m_mail[2] = body.Bodytext();
- attachbutton->setEnabled(body.Parts().count()>0);
- attachments->setEnabled(body.Parts().count()>0);
- if (body.Parts().count()==0)
+ m_mail[2] = body->Bodytext();
+ attachbutton->setEnabled(body->Parts().count()>0);
+ attachments->setEnabled(body->Parts().count()>0);
+ if (body->Parts().count()==0)
{
return;
}
AttachItem * curItem=0;
AttachItem * parentItem = 0;
- QString type=body.Description().Type()+"/"+body.Description().Subtype();
+ QString type=body->Description()->Type()+"/"+body->Description()->Subtype();
QString desc,fsize;
- double s = body.Description().Size();
+ double s = body->Description()->Size();
int w;
w=0;
while (s>1024)
{
s/=1024;
++w;
if (w>=2) break;
@@ -124,33 +124,33 @@ void ViewMail::setBody( RecBody body )
code is it will be destructed after finishing its small job.
*/
QTextOStream o(&fsize);
if (w>0) o.precision(2); else o.precision(0);
o.setf(QTextStream::fixed);
o << s << " " << q << "Byte";
}
- curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist());
+ curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist());
QString filename = "";
- for (unsigned int i = 0; i < body.Parts().count();++i)
+ for (unsigned int i = 0; i < body->Parts().count();++i)
{
filename = "";
- type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype();
- part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin();
- for (;it!=body.Parts()[i].Parameters().end();++it)
+ type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype();
+ part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin();
+ for (;it!=body->Parts()[i]->Parameters().end();++it)
{
qDebug(it.key());
if (it.key().lower()=="name")
{
filename=it.data();
}
}
- s = body.Parts()[i].Size();
+ s = body->Parts()[i]->Size();
w = 0;
while (s>1024)
{
s/=1024;
++w;
if (w>=2) break;
}
switch(w)
@@ -164,29 +164,29 @@ void ViewMail::setBody( RecBody body )
default:
q="";
break;
}
QTextOStream o(&fsize);
if (w>0) o.precision(2); else o.precision(0);
o.setf(QTextStream::fixed);
o << s << " " << q << "Byte";
- desc = body.Parts()[i].Description();
- parentItem = searchParent(body.Parts()[i].Positionlist());
+ desc = body->Parts()[i]->Description();
+ parentItem = searchParent(body->Parts()[i]->Positionlist());
if (parentItem)
{
AttachItem*temp = lastChild(parentItem);
if (temp) curItem = temp;
- curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
+ curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
attachments->setRootIsDecorated(true);
curItem = parentItem;
}
else
{
- curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
+ curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
}
}
}
void ViewMail::slotShowHtml( bool state )
{
m_showHtml = state;
@@ -221,17 +221,17 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
{
MimeTypes types;
types.insert( "all", "*" );
QString str = OFileDialog::getSaveFileName( 1,
"/", item->text( 2 ) , types, 0 );
if( !str.isEmpty() )
{
- encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
+ encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
if (content)
{
QFile output(str);
output.open(IO_WriteOnly);
output.writeBlock(content->Content(),content->Length());
output.close();
delete content;
}
@@ -243,26 +243,26 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int
if ( ( ( AttachItem* )item )->Partnumber() == -1 )
{
setText();
}
else
{
if ( m_recMail->Wrapper() != 0l )
{ // make sure that there is a wrapper , even after delete or simular actions
- browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
+ browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
}
}
break;
}
delete menu;
}
-void ViewMail::setMail( RecMailP mail )
+void ViewMail::setMail(const RecMailP&mail )
{
m_recMail = mail;
m_mail[0] = mail->getFrom();
m_mail[1] = mail->getSubject();
m_mail[3] = mail->getDate();
m_mail[4] = mail->Msgid();
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index 6875e3c..b60fb8e 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -31,18 +31,18 @@ class ViewMail : public ViewMailBase
Q_OBJECT
public:
ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
~ViewMail();
void hide();
void exec();
- void setMail( RecMailP mail );
- void setBody( RecBody body );
+ void setMail(const RecMailP&mail );
+ void setBody(const RecBodyP&body);
bool deleted;
protected:
QString deHtml(const QString &string);
AttachItem* searchParent(const QValueList<int>&path);
AttachItem* lastChild(AttachItem*parent);
protected slots:
@@ -54,20 +54,19 @@ protected slots:
void slotShowHtml( bool );
private:
void readConfig();
bool _inLoop;
QString m_mailHtml;
bool m_gotBody;
- RecBody m_body;
+ RecBodyP m_body;
RecMailP m_recMail;
bool m_showHtml;
// 0 from 1 subject 2 bodytext 3 date
QMap <int,QString> m_mail;
// 0 to 1 cc 2 bcc
QMap <int,QStringList> m_mail2;
-
};
#endif