summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp18
-rw-r--r--noncore/net/mail/accountview.h19
-rw-r--r--noncore/net/mail/imapwrapper.cpp12
-rw-r--r--noncore/net/mail/imapwrapper.h7
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp12
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h7
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp129
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h98
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.cpp12
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.h54
-rw-r--r--noncore/net/mail/mail.pro7
-rw-r--r--noncore/net/mail/mailistviewitem.h21
-rw-r--r--noncore/net/mail/mailtypes.cpp129
-rw-r--r--noncore/net/mail/mailtypes.h98
-rw-r--r--noncore/net/mail/mailwrapper.cpp12
-rw-r--r--noncore/net/mail/mailwrapper.h54
-rw-r--r--noncore/net/mail/mainwindow.cpp34
-rw-r--r--noncore/net/mail/mainwindow.h19
18 files changed, 551 insertions, 191 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 1bde886..df9fc11 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,111 +1,115 @@
#include "accountview.h"
#include "imapwrapper.h"
+#include "mailtypes.h"
#include "defines.h"
IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent )
: AccountViewItem( parent )
{
account = a;
wrapper = new IMAPwrapper( account );
setPixmap( 0, PIXMAP_IMAPFOLDER );
setText( 0, account->getAccountName() );
setOpen( true );
}
IMAPviewItem::~IMAPviewItem()
{
delete wrapper;
}
IMAPwrapper *IMAPviewItem::getWrapper()
{
return wrapper;
}
-void IMAPviewItem::refresh(Maillist&)
+void IMAPviewItem::refresh(QList<RecMail>&)
{
QList<IMAPFolder> *folders = wrapper->listFolders();
QListViewItem *child = firstChild();
while ( child ) {
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
IMAPFolder *it;
for ( it = folders->first(); it; it = folders->next() ) {
(void) new IMAPfolderItem( it, this );
}
}
+RecBody IMAPviewItem::fetchBody(const RecMail&)
+{
+ return RecBody();
+}
IMAPfolderItem::~IMAPfolderItem()
{
delete folder;
}
IMAPfolderItem::IMAPfolderItem( IMAPFolder *folderInit, IMAPviewItem *parent )
: AccountViewItem( parent )
{
folder = folderInit;
imap = parent;
setPixmap( 0, PIXMAP_IMAPFOLDER );
setText( 0, folder->getDisplayName() );
}
-void IMAPfolderItem::refresh(Maillist&target)
+void IMAPfolderItem::refresh(QList<RecMail>&target)
{
imap->getWrapper()->listMessages( folder->getName(),target );
}
-QString IMAPfolderItem::fetchBody(const RecMail&aMail)
+RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
{
return imap->getWrapper()->fetchBody(aMail);
}
AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
: QListView( parent, name, flags )
{
connect( this, SIGNAL( clicked( QListViewItem * ) ),
SLOT( refresh( QListViewItem * ) ) );
}
void AccountView::populate( QList<Account> list )
{
clear();
Account *it;
for ( it = list.first(); it; it = list.next() ) {
if ( it->getType().compare( "IMAP" ) == 0 ) {
IMAPaccount *imap = static_cast<IMAPaccount *>(it);
qDebug( "added IMAP " + imap->getAccountName() );
(void) new IMAPviewItem( imap, this );
}
}
}
void AccountView::refresh(QListViewItem *item) {
qDebug("AccountView refresh...");
if ( item ) {
- Maillist headerlist;
+ QList<RecMail> headerlist;
headerlist.setAutoDelete(true);
AccountViewItem *view = static_cast<AccountViewItem *>(item);
view->refresh(headerlist);
emit refreshMailview(&headerlist);
}
}
void AccountView::refreshAll()
{
}
-QString AccountView::fetchBody(const RecMail&aMail)
+RecBody AccountView::fetchBody(const RecMail&aMail)
{
- QString Body;
QListViewItem*item = selectedItem ();
- if (!item) return Body;
+ if (!item) return RecBody();
AccountViewItem *view = static_cast<AccountViewItem *>(item);
return view->fetchBody(aMail);
}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 2bc8023..805c2b3 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -1,69 +1,72 @@
#ifndef ACCOUNTVIEW_H
#define ACCOUNTVIEW_H
#include <qlistview.h>
+#include <qlist.h>
#include "settings.h"
#include "mailwrapper.h"
class IMAPwrapper;
+class RecMail;
+class RecBody;
class AccountViewItem : public QListViewItem
{
public:
AccountViewItem( QListView *parent ) : QListViewItem( parent ) {}
AccountViewItem( QListViewItem *parent ) : QListViewItem( parent ) {}
- virtual void refresh(Maillist&)=0;
- virtual QString fetchBody(const RecMail&)=0;
+ virtual void refresh(QList<RecMail>&)=0;
+ virtual RecBody fetchBody(const RecMail&)=0;
};
class IMAPviewItem : public AccountViewItem
{
public:
IMAPviewItem( IMAPaccount *a, QListView *parent );
~IMAPviewItem();
- virtual void refresh(Maillist&);
- virtual QString fetchBody(const RecMail&){return "";}
+ virtual void refresh(QList<RecMail>&);
+ virtual RecBody fetchBody(const RecMail&);
IMAPwrapper *getWrapper();
private:
IMAPaccount *account;
IMAPwrapper *wrapper;
};
class IMAPfolderItem : public AccountViewItem
{
public:
IMAPfolderItem( IMAPFolder *folder, IMAPviewItem *parent );
~IMAPfolderItem();
- virtual void refresh(Maillist&);
- virtual QString fetchBody(const RecMail&);
+ virtual void refresh(QList<RecMail>&);
+ virtual RecBody fetchBody(const RecMail&);
private:
IMAPFolder *folder;
IMAPviewItem *imap;
};
class AccountView : public QListView
{
Q_OBJECT
public:
AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
void populate( QList<Account> list );
- QString fetchBody(const RecMail&aMail);
+ RecBody fetchBody(const RecMail&aMail);
public slots:
void refreshAll();
void refresh(QListViewItem *item);
signals:
- void refreshMailview(Maillist*);
+ void refreshMailview(QList<RecMail>*);
};
#endif
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index 1acc036..725dcc9 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -1,99 +1,100 @@
#include <stdlib.h>
#include "imapwrapper.h"
+#include "mailtypes.h"
#include <libetpan/mailimap.h>
IMAPwrapper::IMAPwrapper( IMAPaccount *a )
{
account = a;
m_imap = 0;
}
IMAPwrapper::~IMAPwrapper()
{
logout();
}
void IMAPwrapper::imap_progress( size_t current, size_t maximum )
{
qDebug( "IMAP: %i of %i", current, maximum );
}
void IMAPwrapper::login()
{
logout();
const char *server, *user, *pass;
uint16_t port;
int err = MAILIMAP_NO_ERROR;
server = account->getServer().latin1();
port = account->getPort().toUInt();
user = account->getUser().latin1();
pass = account->getPassword().latin1();
m_imap = mailimap_new( 20, &imap_progress );
/* connect */
err = mailimap_socket_connect( m_imap, (char*)server, port );
if ( err != MAILIMAP_NO_ERROR &&
err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
qDebug("error connecting server: %s",m_imap->response);
mailimap_free( m_imap );
m_imap = 0;
return;
}
/* login */
err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error logging in imap: %s",m_imap->response);
err = mailimap_close( m_imap );
mailimap_free( m_imap );
m_imap = 0;
}
}
void IMAPwrapper::logout()
{
int err = MAILIMAP_NO_ERROR;
if (!m_imap) return;
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;
mailimap_fetch_type *fetchType;
mailimap_set *set;
mb = mailbox.latin1();
login();
if (!m_imap) {
return;
}
/* select mailbox READONLY for operations */
err = mailimap_examine( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error selecting mailbox: %s",m_imap->response);
logout();
return;
}
int last = m_imap->selection_info->exists;
if (last == 0) {
qDebug("mailbox has no mails");
logout();
return;
}
result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
@@ -300,104 +301,107 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
if (named_from && (current_address->mailbox_name || current_address->host_name)) {
from+=">";
}
}
qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s",
from.latin1(),
subject.latin1(),date.latin1());
m = new RecMail();
m->setSubject(subject);
m->setFrom(from);
m->setDate(date);
} else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_INTERNALDATE) {
mailimap_date_time*d = item->msg_att_static->internal_date;
QDateTime da(QDate(d->year,d->month,d->day),QTime(d->hour,d->min,d->sec));
qDebug("%i %i %i - %i %i %i",d->year,d->month,d->day,d->hour,d->min,d->sec);
qDebug(da.toString());
} else {
qDebug("Another type");
}
}
/* msg is already deleted */
if (mFlags.testBit(FLAG_DELETED) && m) {
delete m;
m = 0;
}
if (m) {
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;
mailimap_set *set;
mb = mail.getMbox().latin1();
login();
if (!m_imap) {
return body;
}
/* select mailbox READONLY for operations */
err = mailimap_examine( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error selecting mailbox: %s",m_imap->response);
logout();
return body;
}
result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
fetchAtt = mailimap_fetch_att_new_rfc822_text();
fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
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);
logout();
return body;
}
#else
QString IMAPwrapper::fetchBody(const RecMail&mail)
{
QString body = "";
const char *mb;
int err = MAILIMAP_NO_ERROR;
clist *result;
clistcell *current;
mailimap_fetch_att *fetchAtt;
mailimap_fetch_type *fetchType;
mailimap_set *set;
mailimap_body*body_desc;
mb = mail.getMbox().latin1();
login();
if (!m_imap) {
return body;
}
/* select mailbox READONLY for operations */
err = mailimap_examine( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h
index b02d26d..1423faf 100644
--- a/noncore/net/mail/imapwrapper.h
+++ b/noncore/net/mail/imapwrapper.h
@@ -1,33 +1,36 @@
#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();
QString searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription);
QString getPlainBody(const RecMail&mail);
private:
IMAPaccount *account;
mailimap *m_imap;
};
#endif
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,99 +1,100 @@
#include <stdlib.h>
#include "imapwrapper.h"
+#include "mailtypes.h"
#include <libetpan/mailimap.h>
IMAPwrapper::IMAPwrapper( IMAPaccount *a )
{
account = a;
m_imap = 0;
}
IMAPwrapper::~IMAPwrapper()
{
logout();
}
void IMAPwrapper::imap_progress( size_t current, size_t maximum )
{
qDebug( "IMAP: %i of %i", current, maximum );
}
void IMAPwrapper::login()
{
logout();
const char *server, *user, *pass;
uint16_t port;
int err = MAILIMAP_NO_ERROR;
server = account->getServer().latin1();
port = account->getPort().toUInt();
user = account->getUser().latin1();
pass = account->getPassword().latin1();
m_imap = mailimap_new( 20, &imap_progress );
/* connect */
err = mailimap_socket_connect( m_imap, (char*)server, port );
if ( err != MAILIMAP_NO_ERROR &&
err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
qDebug("error connecting server: %s",m_imap->response);
mailimap_free( m_imap );
m_imap = 0;
return;
}
/* login */
err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error logging in imap: %s",m_imap->response);
err = mailimap_close( m_imap );
mailimap_free( m_imap );
m_imap = 0;
}
}
void IMAPwrapper::logout()
{
int err = MAILIMAP_NO_ERROR;
if (!m_imap) return;
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;
mailimap_fetch_type *fetchType;
mailimap_set *set;
mb = mailbox.latin1();
login();
if (!m_imap) {
return;
}
/* select mailbox READONLY for operations */
err = mailimap_examine( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error selecting mailbox: %s",m_imap->response);
logout();
return;
}
int last = m_imap->selection_info->exists;
if (last == 0) {
qDebug("mailbox has no mails");
logout();
return;
}
result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
@@ -300,104 +301,107 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
if (named_from && (current_address->mailbox_name || current_address->host_name)) {
from+=">";
}
}
qDebug("header: \nFrom: %s\nSubject: %s\nDate: %s",
from.latin1(),
subject.latin1(),date.latin1());
m = new RecMail();
m->setSubject(subject);
m->setFrom(from);
m->setDate(date);
} else if (item->msg_att_static->type==MAILIMAP_MSG_ATT_INTERNALDATE) {
mailimap_date_time*d = item->msg_att_static->internal_date;
QDateTime da(QDate(d->year,d->month,d->day),QTime(d->hour,d->min,d->sec));
qDebug("%i %i %i - %i %i %i",d->year,d->month,d->day,d->hour,d->min,d->sec);
qDebug(da.toString());
} else {
qDebug("Another type");
}
}
/* msg is already deleted */
if (mFlags.testBit(FLAG_DELETED) && m) {
delete m;
m = 0;
}
if (m) {
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;
mailimap_set *set;
mb = mail.getMbox().latin1();
login();
if (!m_imap) {
return body;
}
/* select mailbox READONLY for operations */
err = mailimap_examine( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error selecting mailbox: %s",m_imap->response);
logout();
return body;
}
result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
fetchAtt = mailimap_fetch_att_new_rfc822_text();
fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
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);
logout();
return body;
}
#else
QString IMAPwrapper::fetchBody(const RecMail&mail)
{
QString body = "";
const char *mb;
int err = MAILIMAP_NO_ERROR;
clist *result;
clistcell *current;
mailimap_fetch_att *fetchAtt;
mailimap_fetch_type *fetchType;
mailimap_set *set;
mailimap_body*body_desc;
mb = mail.getMbox().latin1();
login();
if (!m_imap) {
return body;
}
/* select mailbox READONLY for operations */
err = mailimap_examine( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
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,33 +1,36 @@
#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();
QString searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription);
QString getPlainBody(const RecMail&mail);
private:
IMAPaccount *account;
mailimap *m_imap;
};
#endif
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
@@ -598,44 +598,32 @@ void MailWrapper::smtpSend( mailmime *mail )
free_con_session:
mailsmtp_quit( session );
free_mem_session:
mailsmtp_free( session );
free_mem:
smtp_address_list_free( rcpts );
free( data );
free( server );
if ( smtp->getLogin() ) {
free( user );
free( pass );
}
free( from );
}
void MailWrapper::sendMail( Mail mail )
{
mailmime *mimeMail;
mimeMail = createMimeMail( &mail );
if ( mimeMail == NULL ) {
qDebug( "sendMail: error creating mime mail" );
} else {
smtpSend( mimeMail );
mailmime_free( mimeMail );
}
}
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
@@ -2,118 +2,64 @@
#define MAILWRAPPER_H
#include <qpe/applnk.h>
#include <libetpan/mailmime.h>
#include <libetpan/mailimf.h>
#include <libetpan/mailsmtp.h>
#include <libetpan/mailstorage.h>
#include <libetpan/maildriver.h>
#include <qbitarray.h>
#include <qdatetime.h>
#include "settings.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(); }
const QPixmap getPixmap()const{ return doc.pixmap(); }
const int getSize()const { return size; }
DocLnk getDocLnk() { return doc; }
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.
* in this case this object will not get a virtual table -> memory and
* speed will be a little bit better?
*/
virtual ~Mail(){}
void addAttachment( Attachment *att ) { attList.append( att ); }
const QList<Attachment>& getAttachments()const { return attList; }
void removeAttachment( Attachment *att ) { attList.remove( att ); }
const QString&getName()const { return name; }
void setName( QString s ) { name = s; }
const QString&getMail()const{ return mail; }
void setMail( const QString&s ) { mail = s; }
const QString&getTo()const{ return to; }
void setTo( const QString&s ) { to = s; }
const QString&getCC()const{ return cc; }
void setCC( const QString&s ) { cc = s; }
const QString&getBCC()const { return bcc; }
void setBCC( const QString&s ) { bcc = s; }
const QString&getMessage()const { return message; }
void setMessage( const QString&s ) { message = s; }
const QString&getSubject()const { return subject; }
void setSubject( const QString&s ) { subject = s; }
const QString&getReply()const{ return reply; }
void setReply( const QString&a ) { reply = a; }
private:
QList<Attachment> attList;
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro
index 3ae1ddc..55d95ba 100644
--- a/noncore/net/mail/mail.pro
+++ b/noncore/net/mail/mail.pro
@@ -1,44 +1,47 @@
CONFIG += qt warn_on debug quick-app
HEADERS = defines.h \
logindialog.h \
settings.h \
editaccounts.h \
mailwrapper.h \
composemail.h \
accountview.h \
mainwindow.h \
viewmail.h \
viewmailbase.h \
opiemail.h \
- imapwrapper.h
+ imapwrapper.h \
+ mailtypes.h \
+ mailistviewitem.h
SOURCES = main.cpp \
opiemail.cpp \
mainwindow.cpp \
accountview.cpp \
composemail.cpp \
mailwrapper.cpp \
imapwrapper.cpp \
addresspicker.cpp \
editaccounts.cpp \
logindialog.cpp \
viewmail.cpp \
viewmailbase.cpp \
- settings.cpp
+ settings.cpp \
+ mailtypes.cpp
INTERFACES = editaccountsui.ui \
selectmailtypeui.ui \
imapconfigui.ui \
pop3configui.ui \
nntpconfigui.ui \
smtpconfigui.ui \
addresspickerui.ui \
logindialogui.ui \
composemailui.ui
INCLUDEPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie -letpan -lssl -lcrypto -ldb
TARGET = opiemail
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mail/mailistviewitem.h b/noncore/net/mail/mailistviewitem.h
new file mode 100644
index 0000000..60bfdda
--- a/dev/null
+++ b/noncore/net/mail/mailistviewitem.h
@@ -0,0 +1,21 @@
+#ifndef __MAILLISTVIEWITEM_H
+#define __MAILLISTVIEWITEM_H
+
+#include <qlistview.h>
+#include "mailtypes.h"
+
+class MailListViewItem:public QListViewItem
+{
+public:
+ MailListViewItem(QListView * parent, MailListViewItem * after );
+ virtual ~MailListViewItem(){}
+
+ void storeData(const RecMail&data);
+ const RecMail&data()const;
+ void showEntry();
+
+protected:
+ RecMail mail_data;
+};
+
+#endif
diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp
new file mode 100644
index 0000000..9f2c9e3
--- a/dev/null
+++ b/noncore/net/mail/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/mailtypes.h b/noncore/net/mail/mailtypes.h
new file mode 100644
index 0000000..bb6a483
--- a/dev/null
+++ b/noncore/net/mail/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/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp
index 7f67cd8..898e9d6 100644
--- a/noncore/net/mail/mailwrapper.cpp
+++ b/noncore/net/mail/mailwrapper.cpp
@@ -598,44 +598,32 @@ void MailWrapper::smtpSend( mailmime *mail )
free_con_session:
mailsmtp_quit( session );
free_mem_session:
mailsmtp_free( session );
free_mem:
smtp_address_list_free( rcpts );
free( data );
free( server );
if ( smtp->getLogin() ) {
free( user );
free( pass );
}
free( from );
}
void MailWrapper::sendMail( Mail mail )
{
mailmime *mimeMail;
mimeMail = createMimeMail( &mail );
if ( mimeMail == NULL ) {
qDebug( "sendMail: error creating mime mail" );
} else {
smtpSend( mimeMail );
mailmime_free( mimeMail );
}
}
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/mailwrapper.h b/noncore/net/mail/mailwrapper.h
index 332034f..34fd5c5 100644
--- a/noncore/net/mail/mailwrapper.h
+++ b/noncore/net/mail/mailwrapper.h
@@ -2,118 +2,64 @@
#define MAILWRAPPER_H
#include <qpe/applnk.h>
#include <libetpan/mailmime.h>
#include <libetpan/mailimf.h>
#include <libetpan/mailsmtp.h>
#include <libetpan/mailstorage.h>
#include <libetpan/maildriver.h>
#include <qbitarray.h>
#include <qdatetime.h>
#include "settings.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(); }
const QPixmap getPixmap()const{ return doc.pixmap(); }
const int getSize()const { return size; }
DocLnk getDocLnk() { return doc; }
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.
* in this case this object will not get a virtual table -> memory and
* speed will be a little bit better?
*/
virtual ~Mail(){}
void addAttachment( Attachment *att ) { attList.append( att ); }
const QList<Attachment>& getAttachments()const { return attList; }
void removeAttachment( Attachment *att ) { attList.remove( att ); }
const QString&getName()const { return name; }
void setName( QString s ) { name = s; }
const QString&getMail()const{ return mail; }
void setMail( const QString&s ) { mail = s; }
const QString&getTo()const{ return to; }
void setTo( const QString&s ) { to = s; }
const QString&getCC()const{ return cc; }
void setCC( const QString&s ) { cc = s; }
const QString&getBCC()const { return bcc; }
void setBCC( const QString&s ) { bcc = s; }
const QString&getMessage()const { return message; }
void setMessage( const QString&s ) { message = s; }
const QString&getSubject()const { return subject; }
void setSubject( const QString&s ) { subject = s; }
const QString&getReply()const{ return reply; }
void setReply( const QString&a ) { reply = a; }
private:
QList<Attachment> attList;
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 7af7d83..b25db97 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,43 +1,45 @@
#include <qlabel.h>
#include <qvbox.h>
#include <qheader.h>
#include <qtimer.h>
#include <qlayout.h>
#include <qpe/qpeapplication.h>
#include "defines.h"
#include "mainwindow.h"
#include "viewmail.h"
+#include "mailtypes.h"
+#include "mailistviewitem.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
: QMainWindow( parent, name, flags )
{
setCaption( tr( "Opie-Mail" ) );
setToolBarsMovable( false );
toolBar = new QToolBar( this );
menuBar = new QMenuBar( toolBar );
mailMenu = new QPopupMenu( menuBar );
menuBar->insertItem( tr( "Mail" ), mailMenu );
settingsMenu = new QPopupMenu( menuBar );
menuBar->insertItem( tr( "Settings" ), settingsMenu );
addToolBar( toolBar );
toolBar->setHorizontalStretchable( true );
QLabel *spacer = new QLabel( toolBar );
spacer->setBackgroundMode( QWidget::PaletteButton );
toolBar->setStretchableWidget( spacer );
composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
0, 0, this );
composeMail->addTo( toolBar );
composeMail->addTo( mailMenu );
sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
0, 0, this );
sendQueued->addTo( toolBar );
sendQueued->addTo( mailMenu );
syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
@@ -71,101 +73,105 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
QWidget *d = QApplication::desktop();
QBoxLayout *layout;
if ( d->width() < d->height() ) {
layout = new QVBoxLayout( view );
} else {
layout = new QHBoxLayout( view );
}
folderView = new AccountView( view );
folderView->header()->hide();
folderView->addColumn( tr( "Mailbox" ) );
folderView->hide();
layout->addWidget( folderView );
mailView = new QListView( view );
mailView->addColumn( tr( "Subject" ),QListView::Manual );
mailView->addColumn( tr( "Sender" ),QListView::Manual );
mailView->addColumn( tr( "Date" ));
mailView->setAllColumnsShowFocus(true);
mailView->setSorting(-1);
layout->addWidget( mailView );
layout->setStretchFactor( folderView, 1 );
layout->setStretchFactor( mailView, 2 );
connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this,
SLOT( displayMail( QListViewItem * ) ) );
- connect(folderView,SIGNAL(refreshMailview(Maillist*)),this,SLOT(refreshMailView(Maillist*)));
+ connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
}
void MainWindow::slotAdjustColumns()
{
bool hidden = folderView->isHidden();
if ( hidden ) folderView->show();
folderView->setColumnWidth( 0, folderView->visibleWidth() );
if ( hidden ) folderView->hide();
mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 );
mailView->setColumnWidth( 1, 80 );
mailView->setColumnWidth( 2, 50 );
}
void MainWindow::slotShowFolders( bool show )
{
qDebug( "Show Folders" );
if ( show && folderView->isHidden() ) {
qDebug( "-> showing" );
folderView->show();
} else if ( !show && !folderView->isHidden() ) {
qDebug( "-> hiding" );
folderView->hide();
}
}
-void MainWindow::refreshMailView(Maillist*list)
+void MainWindow::refreshMailView(QList<RecMail>*list)
{
MailListViewItem*item = 0;
mailView->clear();
-#if 0
- QFont f = mailView->getFont();
- QFont bf = f;
-#endif
for (unsigned int i = 0; i < list->count();++i) {
item = new MailListViewItem(mailView,item);
item->storeData(*(list->at(i)));
item->showEntry();
-#if 0
- if (!list->at(i)->getFlags().testBit(FLAG_SEEN)) {
- item->setFont(bf);
- }
-#endif
}
}
void MainWindow::displayMail(QListViewItem*item)
{
if (!item) return;
qDebug("View mail");
RecMail mail = ((MailListViewItem*)item)->data();
- QString body = folderView->fetchBody(mail);
+ RecBody body = folderView->fetchBody(mail);
ViewMail readMail( this );
- readMail.setMailInfo( mail.getFrom(), "", mail.getSubject(), "", "", body );
+ readMail.setMailInfo( mail.getFrom(), "", mail.getSubject(), "", "", body.Bodytext() );
readMail.showMaximized();
readMail.exec();
+}
- qDebug(body );
+MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * after )
+ :QListViewItem(parent,after),mail_data()
+{
}
void MailListViewItem::showEntry()
{
setText(0,mail_data.getSubject());
setText(1,mail_data.getFrom());
setText(2,mail_data.getDate());
}
+
+void MailListViewItem::storeData(const RecMail&data)
+{
+ mail_data = data;
+}
+
+const RecMail& MailListViewItem::data()const
+{
+ return mail_data;
+}
diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h
index a5142ab..6c87261 100644
--- a/noncore/net/mail/mainwindow.h
+++ b/noncore/net/mail/mainwindow.h
@@ -1,54 +1,41 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
#include <qlistview.h>
#include <qaction.h>
#include <qtoolbar.h>
#include <qmenubar.h>
#include "accountview.h"
+class RecMail;
+
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
public slots:
void slotAdjustColumns();
protected slots:
virtual void slotShowFolders( bool show );
- virtual void refreshMailView(Maillist*);
+ virtual void refreshMailView(QList<RecMail>*);
virtual void displayMail(QListViewItem*);
protected:
QToolBar *toolBar;
QMenuBar *menuBar;
QPopupMenu *mailMenu, *settingsMenu;
QAction *composeMail, *sendQueued, *showFolders, *searchMails,
*editSettings, *editAccounts, *syncFolders;
AccountView *folderView;
QListView *mailView;
};
-class MailListViewItem:public QListViewItem
-{
-public:
- MailListViewItem(QListView * parent, MailListViewItem * after )
- :QListViewItem(parent,after),mail_data(){}
- virtual ~MailListViewItem(){}
-
- void storeData(const RecMail&data){mail_data = data;}
- const RecMail&data()const{return mail_data;}
- void showEntry();
-
-protected:
- RecMail mail_data;
-};
-
#endif