summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountview.cpp33
-rw-r--r--noncore/net/mail/accountview.h4
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h1
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp74
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h1
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp13
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h3
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp11
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h3
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp17
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h4
-rw-r--r--noncore/net/mail/mail.pro9
-rw-r--r--noncore/net/mail/selectstore.cpp19
-rw-r--r--noncore/net/mail/selectstore.h19
-rw-r--r--noncore/net/mail/selectstoreui.ui244
15 files changed, 400 insertions, 55 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 77fa706..faa6982 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,296 +1,321 @@
#include "accountview.h"
#include <libmailwrapper/mailtypes.h>
#include <libmailwrapper/abstractmail.h>
#include "defines.h"
#include "newmaildir.h"
+#include "selectstore.h"
#include <qmessagebox.h>
#include <qpopupmenu.h>
/**
* POP3 Account stuff
*/
POP3viewItem::POP3viewItem( POP3account *a, QListView *parent )
: AccountViewItem( parent )
{
account = a;
wrapper = AbstractMail::getWrapper( account );
setPixmap( 0, PIXMAP_POP3FOLDER );
setText( 0, account->getAccountName() );
setOpen( true );
}
POP3viewItem::~POP3viewItem()
{
delete wrapper;
}
AbstractMail *POP3viewItem::getWrapper()
{
return wrapper;
}
void POP3viewItem::refresh( QList<RecMail> & )
{
QList<Folder> *folders = wrapper->listFolders();
QListViewItem *child = firstChild();
while ( child ) {
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
Folder *it;
QListViewItem*item = 0;
for ( it = folders->first(); it; it = folders->next() ) {
item = new POP3folderItem( it, this , item );
item->setSelectable(it->may_select());
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
folders->setAutoDelete(false);
delete folders;
}
RecBody POP3viewItem::fetchBody( const RecMail &mail )
{
qDebug( "POP3 fetchBody" );
return wrapper->fetchBody( mail );
}
POP3folderItem::~POP3folderItem()
{
delete folder;
}
POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after )
: AccountViewItem( parent,after )
{
folder = folderInit;
pop3 = parent;
if (folder->getDisplayName().lower()!="inbox") {
setPixmap( 0, PIXMAP_POP3FOLDER );
} else {
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
void POP3folderItem::refresh(QList<RecMail>&target)
{
if (folder->may_select())
pop3->getWrapper()->listMessages( folder->getName(),target );
}
RecBody POP3folderItem::fetchBody(const RecMail&aMail)
{
return pop3->getWrapper()->fetchBody(aMail);
}
QPopupMenu * POP3folderItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m) {
m->insertItem(QObject::tr("Refresh header list",contextName),0);
m->insertItem(QObject::tr("Delete all mails",contextName),1);
+ m->insertItem(QObject::tr("Download all mails",contextName),2);
}
return m;
}
+void POP3folderItem::downloadMails()
+{
+ Selectstore sels;
+ sels.showMaximized();
+ sels.exec();
+}
+
void POP3folderItem::contextMenuSelected(int which)
{
AccountView * view = (AccountView*)listView();
switch (which) {
case 0:
+ /* must be 'cause pop3 lists are cached */
+ pop3->getWrapper()->logout();
view->refreshCurrent();
break;
case 1:
deleteAllMail(pop3->getWrapper(),folder);
break;
+ case 2:
+ downloadMails();
+ break;
default:
break;
}
}
/**
* IMAP Account stuff
*/
IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent )
: AccountViewItem( parent )
{
account = a;
wrapper = AbstractMail::getWrapper( account );
setPixmap( 0, PIXMAP_IMAPFOLDER );
setText( 0, account->getAccountName() );
setOpen( true );
}
IMAPviewItem::~IMAPviewItem()
{
delete wrapper;
}
AbstractMail *IMAPviewItem::getWrapper()
{
return wrapper;
}
IMAPfolderItem*IMAPviewItem::findSubItem(const QString&path,IMAPfolderItem*start)
{
IMAPfolderItem*pitem,*sitem;
if (!start) pitem = (IMAPfolderItem*)firstChild();
else pitem = (IMAPfolderItem*)start->firstChild();
while (pitem) {
if (pitem->matchName(path)) {
break;
}
if (pitem->childCount()>0) {
sitem = findSubItem(path,pitem);
if (sitem) {
pitem = sitem;
break;
}
}
pitem=(IMAPfolderItem*)pitem->nextSibling();
}
return pitem;
}
void IMAPviewItem::refresh(QList<RecMail>&)
{
refreshFolders(false);
}
-void IMAPviewItem::refreshFolders(bool force)
+void IMAPviewItem::removeChilds()
{
- if (childCount()>0 && force==false) return;
- QList<Folder> *folders = wrapper->listFolders();
-
QListViewItem *child = firstChild();
while ( child ) {
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
+}
+
+void IMAPviewItem::refreshFolders(bool force)
+{
+ if (childCount()>0 && force==false) return;
+
+ removeChilds();
+
+ QList<Folder> *folders = wrapper->listFolders();
+
Folder *it;
QListViewItem*item = 0;
QListViewItem*titem = 0;
QString fname,del,search;
int pos;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
folders->setAutoDelete(false);
for ( it = folders->first(); it; it = folders->next() ) {
if (it->getDisplayName().lower()=="inbox") {
item = new IMAPfolderItem( it, this , item );
folders->remove(it);
qDebug("inbox found");
break;
}
}
for ( it = folders->first(); it; it = folders->next() ) {
fname = it->getDisplayName();
pos = fname.findRev(it->Separator());
if (pos != -1) {
fname = fname.left(pos);
}
IMAPfolderItem*pitem = findSubItem(fname);
if (pitem) {
titem = item;
item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this);
/* setup the short name */
item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1));
item = titem;
} else {
item = new IMAPfolderItem( it, this , item );
}
}
delete folders;
}
QPopupMenu * IMAPviewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m) {
m->insertItem(QObject::tr("Refresh folder list",contextName),0);
m->insertItem(QObject::tr("Create new folder",contextName),1);
m->insertSeparator();
m->insertItem(QObject::tr("Disconnect",contextName),2);
}
return m;
}
void IMAPviewItem::createNewFolder()
{
Newmdirdlg ndirdlg;
ndirdlg.showMaximized();
if (ndirdlg.exec()) {
QString ndir = ndirdlg.Newdir();
bool makesubs = ndirdlg.subpossible();
QString delemiter = "/";
IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
if (item) {
delemiter = item->Delemiter();
}
if (wrapper->createMbox(ndir,0,delemiter,makesubs)) {
refreshFolders(true);
}
}
}
void IMAPviewItem::contextMenuSelected(int id)
{
qDebug("Id selected: %i",id);
switch (id) {
case 0:
refreshFolders(true);
break;
case 1:
createNewFolder();
break;
+ case 2:
+ removeChilds();
+ wrapper->logout();
+ break;
default:
break;
}
}
RecBody IMAPviewItem::fetchBody(const RecMail&)
{
return RecBody();
}
IMAPfolderItem::~IMAPfolderItem()
{
delete folder;
}
IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
: AccountViewItem( parent , after )
{
folder = folderInit;
imap = parent;
if (folder->getDisplayName().lower()!="inbox") {
setPixmap( 0, PIXMAP_IMAPFOLDER );
} else {
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
: AccountViewItem( parent,after )
{
folder = folderInit;
imap = master;
if (folder->getDisplayName().lower()!="inbox") {
setPixmap( 0, PIXMAP_IMAPFOLDER );
} else {
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
const QString& IMAPfolderItem::Delemiter()const
{
return folder->Separator();
}
bool IMAPfolderItem::matchName(const QString&name)const
{
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index 1d2bf19..7131192 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -10,119 +10,123 @@
class POP3wrapper;
class RecMail;
class RecBody;
class QPopupMenu;
class AccountViewItem : public QListViewItem
{
public:
AccountViewItem( QListView *parent ) : QListViewItem( parent ) {}
AccountViewItem( QListViewItem *parent) : QListViewItem( parent) {}
AccountViewItem( QListViewItem *parent , QListViewItem*after ) : QListViewItem( parent,after ) {}
virtual void refresh(QList<RecMail>&)=0;
virtual RecBody fetchBody(const RecMail&)=0;
virtual QPopupMenu * getContextMenu(){return 0;};
virtual void contextMenuSelected(int){}
protected:
virtual void deleteAllMail(AbstractMail*wrapper,Folder*f);
static const QString contextName;
};
class POP3viewItem : public AccountViewItem
{
public:
POP3viewItem( POP3account *a, QListView *parent );
~POP3viewItem();
virtual void refresh( QList<RecMail> &target );
virtual RecBody fetchBody( const RecMail &mail );
AbstractMail *getWrapper();
private:
POP3account *account;
AbstractMail *wrapper;
};
class POP3folderItem : public AccountViewItem
{
public:
POP3folderItem( Folder *folder, POP3viewItem *parent , QListViewItem*after );
~POP3folderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
+protected:
+ void downloadMails();
+
private:
Folder *folder;
POP3viewItem *pop3;
};
class IMAPfolderItem;
class IMAPviewItem : public AccountViewItem
{
friend class IMAPfolderItem;
public:
IMAPviewItem( IMAPaccount *a, QListView *parent );
~IMAPviewItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
IMAPfolderItem*findSubItem(const QString&path,IMAPfolderItem*start=0);
virtual void refreshFolders(bool force=false);
virtual void createNewFolder();
+ virtual void removeChilds();
private:
IMAPaccount *account;
AbstractMail *wrapper;
};
class IMAPfolderItem : public AccountViewItem
{
public:
IMAPfolderItem( Folder *folder, IMAPviewItem *parent , QListViewItem*after );
IMAPfolderItem( Folder *folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
~IMAPfolderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
bool matchName(const QString&name)const;
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
virtual const QString& Delemiter()const;
protected:
virtual void createNewFolder();
virtual void deleteFolder();
private:
Folder *folder;
IMAPviewItem *imap;
};
class MBOXviewItem : public AccountViewItem
{
friend class MBOXfolderItem;
public:
// MBOXviewItem( MBOXaccount *a, QListView *parent );
MBOXviewItem( const QString&aMboxPath, QListView *parent );
~MBOXviewItem();
virtual void refresh( QList<RecMail> &target );
virtual RecBody fetchBody( const RecMail &mail );
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
virtual void refresh(bool force=false);
virtual void createFolder();
private:
// MBOXaccount *account;
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index 7c060db..9770991 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -1,59 +1,60 @@
#ifndef __abstract_mail_
#define __abstract_mail_
#include <qobject.h>
#include "settings.h"
class RecMail;
class RecBody;
class RecPart;
class IMAPwrapper;
class POP3wrapper;
class Folder;
class encodedString;
struct folderStat;
class AbstractMail:public QObject
{
Q_OBJECT
public:
AbstractMail(){};
virtual ~AbstractMail(){}
virtual QList<Folder>* listFolders()=0;
virtual void listMessages(const QString & mailbox,QList<RecMail>&target )=0;
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0;
virtual RecBody fetchBody(const RecMail&mail)=0;
virtual QString fetchTextPart(const RecMail&mail,const RecPart&part)=0;
virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part)=0;
virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part)=0;
+ virtual encodedString* fetchRawBody(const RecMail&mail)=0;
virtual void deleteMail(const RecMail&mail)=0;
virtual void answeredMail(const RecMail&mail)=0;
virtual int deleteAllMail(const Folder*)=0;
virtual int deleteMbox(const Folder*)=0;
virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
virtual void cleanMimeCache(){};
/* mail box methods */
/* parameter is the box to create.
* if the implementing subclass has prefixes,
* them has to be appended automatic.
*/
virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
virtual void logout()=0;
static AbstractMail* getWrapper(IMAPaccount *a);
static AbstractMail* getWrapper(POP3account *a);
/* mbox only! */
static AbstractMail* getWrapper(const QString&a);
static QString defaultLocalfolder();
virtual const QString&getType()const=0;
protected:
static encodedString*decode_String(const encodedString*text,const QString&enc);
static QString convert_String(const char*text);
static QString gen_attachment_id();
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 95b317a..d252159 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -421,121 +421,132 @@ QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
{
QStringList l;
QString from;
bool named_from;
clistcell *current = NULL;
mailimap_address * current_address=NULL;
if (!list) {
return l;
}
unsigned int count = 0;
for (current=clist_begin(list);current!= NULL;current=clist_next(current)) {
from = "";
named_from = false;
current_address=(mailimap_address*)current->data;
if (current_address->ad_personal_name){
from+=convert_String((const char*)current_address->ad_personal_name);
from+=" ";
named_from = true;
}
if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
from+="<";
}
if (current_address->ad_mailbox_name) {
from+=QString(current_address->ad_mailbox_name);
from+="@";
}
if (current_address->ad_host_name) {
from+=QString(current_address->ad_host_name);
}
if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
from+=">";
}
l.append(QString(from));
if (++count > 99) {
break;
}
}
return l;
}
encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call)
{
encodedString*res=new encodedString;
const char*mb;
int err;
mailimap_fetch_type *fetchType;
mailimap_set *set;
clistcell*current,*cur;
+ mailimap_section_part * section_part = 0;
+ mailimap_section_spec * section_spec = 0;
+ mailimap_section * section = 0;
+ mailimap_fetch_att * fetch_att = 0;
login();
if (!m_imap) {
return res;
}
if (!internal_call) {
mb = mail.getMbox().latin1();
err = mailimap_select( m_imap, (char*)mb);
if ( err != MAILIMAP_NO_ERROR ) {
qDebug("error selecting mailbox: %s",m_imap->imap_response);
return res;
}
}
set = mailimap_set_new_single(mail.getNumber());
- clist*id_list=clist_new();
- for (unsigned j=0; j < path.count();++j) {
- uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
- *p_id = path[j];
- clist_append(id_list,p_id);
- }
- mailimap_section_part * section_part = mailimap_section_part_new(id_list);
- mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
- mailimap_section * section = mailimap_section_new(section_spec);
- mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section);
+ clist*id_list = 0;
+
+ /* if path == empty then its a request for the whole rfc822 mail and generates
+ a "fetch <id> (body[])" statement on imap server */
+ if (path.count()>0 ) {
+ id_list = clist_new();
+ for (unsigned j=0; j < path.count();++j) {
+ uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
+ *p_id = path[j];
+ clist_append(id_list,p_id);
+ }
+ section_part = mailimap_section_part_new(id_list);
+ section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
+ }
+
+ section = mailimap_section_new(section_spec);
+ fetch_att = mailimap_fetch_att_new_body_section(section);
fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
clist*result = 0;
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*msg_att_item;
for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
msg_att_item = (mailimap_msg_att_item*)clist_content(cur);
if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) {
char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
/* detach - we take over the content */
msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length);
}
}
}
} else {
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 RecMail&mail,mailimap_body*body,RecBody&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;
mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
QString id("");
currentPart.setPositionlist(countlist);
for (unsigned int j = 0; j < countlist.count();++j) {
@@ -910,83 +921,94 @@ int IMAPwrapper::createMbox(const QString&folder,const Folder*parentfolder,const
pre+=delemiter;
} else {
Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre));
return 0;
}
}
qDebug("Creating %s",pre.latin1());
int res = mailimap_create(m_imap,pre.latin1());
if (res != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("%1").arg(m_imap->imap_response));
return 0;
}
return 1;
}
int IMAPwrapper::deleteMbox(const Folder*folder)
{
if (!folder) return 0;
login();
if (!m_imap) {return 0;}
int res = mailimap_delete(m_imap,folder->getName());
if (res != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("%1").arg(m_imap->imap_response));
return 0;
}
return 1;
}
void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
{
mailimap_status_att_list * att_list =0;
mailimap_mailbox_data_status * status=0;
clistiter * cur = 0;
int r = 0;
int res = 0;
target_stat.message_count = 0;
target_stat.message_unseen = 0;
target_stat.message_recent = 0;
login();
if (!m_imap) {
return;
}
att_list = mailimap_status_att_list_new_empty();
if (!att_list) return;
r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES);
r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT);
r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN);
r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status);
- for (cur = clist_begin(status->st_info_list);
- cur != NULL ; cur = clist_next(cur)) {
- mailimap_status_info * status_info;
- status_info = (mailimap_status_info *)clist_content(cur);
- switch (status_info->st_att) {
- case MAILIMAP_STATUS_ATT_MESSAGES:
- target_stat.message_count = status_info->st_value;
- break;
- case MAILIMAP_STATUS_ATT_RECENT:
- target_stat.message_recent = status_info->st_value;
- break;
- case MAILIMAP_STATUS_ATT_UNSEEN:
- target_stat.message_unseen = status_info->st_value;
- break;
+ if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) {
+ for (cur = clist_begin(status->st_info_list);
+ cur != NULL ; cur = clist_next(cur)) {
+ mailimap_status_info * status_info;
+ status_info = (mailimap_status_info *)clist_content(cur);
+ switch (status_info->st_att) {
+ case MAILIMAP_STATUS_ATT_MESSAGES:
+ target_stat.message_count = status_info->st_value;
+ break;
+ case MAILIMAP_STATUS_ATT_RECENT:
+ target_stat.message_recent = status_info->st_value;
+ break;
+ case MAILIMAP_STATUS_ATT_UNSEEN:
+ target_stat.message_unseen = status_info->st_value;
+ break;
+ }
}
+ } else {
+ qDebug("Error retrieving status");
}
- mailimap_mailbox_data_status_free(status);
- mailimap_status_att_list_free(att_list);
+ if (status) mailimap_mailbox_data_status_free(status);
+ if (att_list) mailimap_status_att_list_free(att_list);
}
void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
{
login();
if (!m_imap) return;
if (!msg) return;
int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length);
if (r != MAILIMAP_NO_ERROR) {
Global::statusMessage("Error storing mail!");
}
}
const QString&IMAPwrapper::getType()const
{
return account->getType();
}
+
+encodedString* IMAPwrapper::fetchRawBody(const RecMail&mail)
+{
+ // dummy
+ QValueList<int> path;
+ return fetchRawPart(mail,path,false);
+}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 6a9c411..b246f58 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -1,70 +1,71 @@
#ifndef __IMAPWRAPPER
#define __IMAPWRAPPER
#include <qlist.h>
#include "mailwrapper.h"
#include "abstractmail.h"
#include <libetpan/clist.h>
struct mailimap;
struct mailimap_body;
struct mailimap_body_type_1part;
struct mailimap_body_type_text;
struct mailimap_body_type_basic;
struct mailimap_body_type_msg;
struct mailimap_body_type_mpart;
struct mailimap_body_fields;
struct mailimap_msg_att;
class encodedString;
class IMAPwrapper : public AbstractMail
{
Q_OBJECT
public:
IMAPwrapper( IMAPaccount *a );
virtual ~IMAPwrapper();
virtual QList<Folder>* listFolders();
virtual void listMessages(const QString & mailbox,QList<RecMail>&target );
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMail&mail);
virtual void answeredMail(const RecMail&mail);
virtual int deleteAllMail(const Folder*folder);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
virtual RecBody fetchBody(const RecMail&mail);
virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
+ virtual encodedString* fetchRawBody(const RecMail&mail);
virtual int createMbox(const QString&,const Folder*parentfolder=0,const QString& delemiter="/",bool getsubfolder=false);
virtual int deleteMbox(const Folder*folder);
static void imap_progress( size_t current, size_t maximum );
virtual void logout();
virtual const QString&getType()const;
protected:
RecMail*parse_list_result(mailimap_msg_att*);
void login();
virtual QString fetchTextPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
virtual encodedString*fetchRawPart(const RecMail&mail,const QValueList<int>&path,bool internal_call);
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 RecMail&mail,mailimap_body*body,RecBody&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 QStringList address_list_to_stringlist(clist*list);
IMAPaccount *account;
mailimap *m_imap;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 60f7507..3a0b30a 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -127,136 +127,137 @@ RecBody MBOXwrapper::fetchBody( const RecMail &mail )
body = parseMail(msg);
mailmessage_fetch_result_free(msg,data);
mailfolder_free(folder);
mailstorage_free(storage);
return body;
}
void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
{
qDebug("MBOX %i von %i",current,maximum);
}
int MBOXwrapper::createMbox(const QString&folder,const Folder*,const QString&,bool )
{
QString p = MBOXPath+"/";
p+=folder;
QFileInfo fi(p);
if (fi.exists()) {
Global::statusMessage(tr("Mailbox exists."));
return 0;
}
mailmbox_folder*f = 0;
if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error init folder"));
return 0;
}
if (f) mailmbox_done(f);
return 1;
}
void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
{
QString p = MBOXPath+"/";
p+=folder;
mailmbox_folder*f = 0;
int r = mailmbox_init(p.latin1(),0,1,0,&f);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error init folder"));
return;
}
r = mailmbox_append_message(f,msg,length);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error writing to message folder"));
}
mailmbox_done(f);
}
-void MBOXwrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
+encodedString* MBOXwrapper::fetchRawBody(const RecMail&mail)
{
RecBody body;
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);
mailfolder*folder;
folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
r = mailfolder_connect(folder);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error initializing mbox"));
mailfolder_free(folder);
mailstorage_free(storage);
- return;
+ return 0;
}
r = mailsession_get_message(folder->fld_session, mail.getNumber(), &msg);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
mailfolder_free(folder);
mailstorage_free(storage);
- return;
+ return 0;
}
r = mailmessage_fetch(msg,&data,&size);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error fetching mail %i").arg(mail.getNumber()));
mailfolder_free(folder);
mailstorage_free(storage);
mailmessage_free(msg);
- return;
+ return 0;
}
- *target = data;
- *length = size;
+ encodedString*result = new encodedString(data,size);
+
mailfolder_free(folder);
mailstorage_free(storage);
mailmessage_free(msg);
+ return result;
}
void MBOXwrapper::deleteMails(const QString & mailbox,QList<RecMail> &target)
{
QString p = MBOXPath+"/";
p+=mailbox;
mailmbox_folder*f = 0;
int r = mailmbox_init(p.latin1(),0,1,0,&f);
if (r != MAIL_NO_ERROR) {
qDebug("Error init folder");
return;
}
deleteMails(f,target);
mailmbox_done(f);
}
void MBOXwrapper::deleteMails(mailmbox_folder*f,QList<RecMail> &target)
{
if (!f) return;
int r;
for (unsigned int i=0; i < target.count();++i) {
r = mailmbox_delete_msg(f,target.at(i)->getNumber());
if (r!=MAILMBOX_NO_ERROR) {
qDebug("error delete mail");
}
}
r = mailmbox_expunge(f);
if (r != MAILMBOX_NO_ERROR) {
qDebug("error expunge mailbox");
}
}
int MBOXwrapper::deleteAllMail(const Folder*tfolder)
{
if (!tfolder) return 0;
QString p = MBOXPath+tfolder->getDisplayName();
int res = 1;
mailfolder*folder = 0;
mailmessage_list*l=0;
mailstorage*storage = mailstorage_new(NULL);
int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
if (r != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error initializing mbox"));
res = 0;
}
if (res) {
folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index f97fce2..2794014 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -1,44 +1,45 @@
#ifndef __MBOX_WRAPPER_H
#define __MBOX_WRAPPER_H
#include "genericwrapper.h"
#include <qstring.h>
class RecMail;
class RecBody;
+class encodedString;
struct mailmbox_folder;
class MBOXwrapper : public Genericwrapper
{
Q_OBJECT
public:
MBOXwrapper(const QString & dir);
virtual ~MBOXwrapper();
virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
virtual QList<Folder>* listFolders();
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMail&mail);
virtual void answeredMail(const RecMail&mail);
virtual int createMbox(const QString&folder,const Folder*f=0,const QString&d="",bool s=false);
virtual int deleteMbox(const Folder*);
virtual void storeMessage(const char*msg,size_t length, const QString&folder);
virtual RecBody fetchBody( const RecMail &mail );
static void mbox_progress( size_t current, size_t maximum );
- virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length);
+ virtual encodedString* fetchRawBody(const RecMail&mail);
virtual void deleteMails(const QString & mailbox,QList<RecMail> &target);
virtual int deleteAllMail(const Folder*);
virtual const QString&getType()const;
protected:
static void deleteMails(mailmbox_folder*f,QList<RecMail> &target);
QString MBOXPath;
static const QString wrapperType;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 45408dd..72c145b 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -183,60 +183,67 @@ QList<Folder>* POP3wrapper::listFolders()
void POP3wrapper::deleteMail(const RecMail&mail)
{
login();
if (!m_pop3) return;
int err = mailsession_remove_message(m_folder->fld_session,mail.getNumber());
if (err != MAIL_NO_ERROR) {
Global::statusMessage(tr("error deleting mail"));
}
}
void POP3wrapper::answeredMail(const RecMail&)
{
}
int POP3wrapper::deleteAllMail(const Folder*)
{
login();
if (!m_pop3) return 0;
int res = 1;
uint32_t result = 0;
int err = mailsession_messages_number(m_folder->fld_session,NULL,&result);
if (err != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error getting folder info"));
return 0;
}
for (unsigned int i = 0; i < result; ++i) {
err = mailsession_remove_message(m_folder->fld_session,i+1);
if (err != MAIL_NO_ERROR) {
Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
res=0;
}
break;
}
return res;
}
void POP3wrapper::statusFolder(folderStat&target_stat,const QString&)
{
login();
target_stat.message_count = 0;
target_stat.message_unseen = 0;
target_stat.message_recent = 0;
if (!m_pop3) return;
int r = mailsession_status_folder(m_folder->fld_session,0,&target_stat.message_count,
&target_stat.message_recent,&target_stat.message_unseen);
}
-void POP3wrapper::fetchRawBody(const RecMail&mail,char**target,size_t*length)
+encodedString* POP3wrapper::fetchRawBody(const RecMail&mail)
{
+ char*target=0;
+ size_t length=0;
+ encodedString*res = 0;
mailmessage * mailmsg = 0;
int err = mailsession_get_message(m_folder->fld_session, mail.getNumber(), &mailmsg);
- err = mailmessage_fetch(mailmsg,target,length);
+ err = mailmessage_fetch(mailmsg,&target,&length);
if (mailmsg) mailmessage_free(mailmsg);
+ if (target) {
+ res = new encodedString(target,length);
+ }
+ return res;
}
const QString&POP3wrapper::getType()const
{
return account->getType();
}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index b7e8f27..f0307b6 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -1,41 +1,42 @@
#ifndef __POP3WRAPPER
#define __POP3WRAPPER
#include "mailwrapper.h"
#include "genericwrapper.h"
#include <qstring.h>
+class encodedString;
struct mailstorage;
struct mailfolder;
class POP3wrapper : public Genericwrapper
{
Q_OBJECT
public:
POP3wrapper( POP3account *a );
virtual ~POP3wrapper();
/* mailbox will be ignored */
virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
virtual QList<Folder>* listFolders();
/* mailbox will be ignored */
virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
virtual void deleteMail(const RecMail&mail);
virtual void answeredMail(const RecMail&mail);
virtual int deleteAllMail(const Folder*);
virtual RecBody fetchBody( const RecMail &mail );
- virtual void fetchRawBody(const RecMail&mail,char**target,size_t*length);
+ virtual encodedString* fetchRawBody(const RecMail&mail);
virtual void logout();
virtual const QString&getType()const;
static void pop3_progress( size_t current, size_t maximum );
protected:
void login();
POP3account *account;
mailstorage*m_pop3;
mailfolder*m_folder;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index e054365..00181ff 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -440,148 +440,148 @@ clist *SMTPwrapper::createRcptList( mailimf_fields *fields )
field = getField( fields, MAILIMF_FIELD_CC );
if ( field && (field->fld_type == MAILIMF_FIELD_CC)
&& field->fld_data.fld_cc->cc_addr_list ) {
addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list );
}
field = getField( fields, MAILIMF_FIELD_BCC );
if ( field && (field->fld_type == MAILIMF_FIELD_BCC)
&& field->fld_data.fld_bcc->bcc_addr_list ) {
addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list );
}
return rcptList;
}
char *SMTPwrapper::getFrom( mailimf_field *ffrom)
{
char *from = NULL;
if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM)
&& ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) {
clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list;
clistiter *it;
for ( it = clist_begin( cl ); it; it = it->next ) {
mailimf_mailbox *mb = (mailimf_mailbox *) it->data;
from = strdup( mb->mb_addr_spec );
}
}
return from;
}
char *SMTPwrapper::getFrom( mailmime *mail )
{
/* no need to delete - its just a pointer to structure content */
mailimf_field *ffrom = 0;
ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM );
return getFrom(ffrom);
}
void SMTPwrapper::progress( size_t current, size_t maximum )
{
if (SMTPwrapper::sendProgress) {
SMTPwrapper::sendProgress->setSingleMail(current, maximum );
qApp->processEvents();
}
}
-void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box)
+void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box)
{
if (!mail) return;
QString localfolders = AbstractMail::defaultLocalfolder();
MBOXwrapper*wrap = new MBOXwrapper(localfolders);
wrap->storeMessage(mail,length,box);
delete wrap;
}
void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
{
clist *rcpts = 0;
char *from, *data;
size_t size;
if ( smtp == NULL ) {
return;
}
from = data = 0;
mailmessage * msg = 0;
msg = mime_message_init(mail);
mime_message_set_tmpdir(msg,getenv( "HOME" ));
int r = mailmessage_fetch(msg,&data,&size);
mime_message_detach_mime(msg);
mailmessage_free(msg);
if (r != MAIL_NO_ERROR || !data) {
if (data) free(data);
qDebug("Error fetching mime...");
return;
}
QString tmp = data;
tmp.replace(QRegExp("\r+",true,false),"");
msg = 0;
if (later) {
storeMail((char*)tmp.data(),tmp.length(),"Outgoing");
if (data) free( data );
Config cfg( "mail" );
cfg.setGroup( "Status" );
cfg.writeEntry( "outgoing", ++m_queuedMail );
emit queuedMails( m_queuedMail );
return;
}
from = getFrom( mail );
rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
smtpSend(from,rcpts,data,size,smtp);
if (data) {free(data);}
if (from) {free(from);}
if (rcpts) smtp_address_list_free( rcpts );
}
-int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp )
+int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp )
{
char *server, *user, *pass;
bool ssl;
uint16_t port;
mailsmtp *session;
int err,result;
result = 1;
server = user = pass = 0;
server = strdup( smtp->getServer().latin1() );
ssl = smtp->getSSL();
port = smtp->getPort().toUInt();
session = mailsmtp_new( 20, &progress );
if ( session == NULL ) goto free_mem;
qDebug( "Servername %s at port %i", server, port );
if ( ssl ) {
qDebug( "SSL session" );
err = mailsmtp_ssl_connect( session, server, port );
} else {
qDebug( "No SSL session" );
err = mailsmtp_socket_connect( session, server, port );
}
if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;}
err = mailsmtp_init( session );
if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;}
qDebug( "INIT OK" );
if ( smtp->getLogin() ) {
if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) {
// get'em
LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
user = strdup( login.getUser().latin1() );
pass = strdup( login.getPassword().latin1() );
} else {
result = 0; goto free_con_session;
}
} else {
user = strdup( smtp->getUser().latin1() );
pass = strdup( smtp->getPassword().latin1() );
}
qDebug( "session->auth: %i", session->auth);
@@ -595,128 +595,125 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou
qDebug("Error sending mail: %s",mailsmtpError(err).latin1());
result = 0; goto free_con_session;
}
qDebug( "Mail sent." );
storeMail(data,size,"Sent");
free_con_session:
mailsmtp_quit( session );
free_mem_session:
mailsmtp_free( session );
free_mem:
if (server) free( server );
if ( smtp->getLogin() ) {
free( user );
free( pass );
}
return result;
}
void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later )
{
mailmime * mimeMail;
SMTPaccount *smtp = aSmtp;
if (!later && !smtp) {
qDebug("Didn't get any send method - giving up");
return;
}
mimeMail = createMimeMail(mail );
if ( mimeMail == NULL ) {
qDebug( "sendMail: error creating mime mail" );
} else {
sendProgress = new progressMailSend();
sendProgress->show();
sendProgress->setMaxMails(1);
smtpSend( mimeMail,later,smtp);
qDebug("Clean up done");
sendProgress->hide();
delete sendProgress;
sendProgress = 0;
mailmime_free( mimeMail );
}
}
int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
{
- char*data = 0;
- size_t length = 0;
size_t curTok = 0;
mailimf_fields *fields = 0;
mailimf_field*ffrom = 0;
clist *rcpts = 0;
char*from = 0;
int res = 0;
- wrap->fetchRawBody(*which,&data,&length);
+ encodedString * data = wrap->fetchRawBody(*which);
if (!data) return 0;
- int err = mailimf_fields_parse( data, length, &curTok, &fields );
+ int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields );
if (err != MAILIMF_NO_ERROR) {
- free(data);
+ delete data;
delete wrap;
return 0;
}
rcpts = createRcptList( fields );
ffrom = getField(fields, MAILIMF_FIELD_FROM );
from = getFrom(ffrom);
- qDebug("Size: %i vs. %i",length,strlen(data));
if (rcpts && from) {
- res = smtpSend(from,rcpts,data,length,smtp );
+ res = smtpSend(from,rcpts,data->Content(),data->Length(),smtp );
}
if (fields) {
mailimf_fields_free(fields);
fields = 0;
}
if (data) {
- free(data);
+ delete data;
}
if (from) {
free(from);
}
if (rcpts) {
smtp_address_list_free( rcpts );
}
return res;
}
/* this is a special fun */
bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
{
bool returnValue = true;
if (!smtp) return false;
QString localfolders = AbstractMail::defaultLocalfolder();
MBOXwrapper*wrap = new MBOXwrapper(localfolders);
if (!wrap) {
qDebug("memory error");
return false;
}
QList<RecMail> mailsToSend;
QList<RecMail> mailsToRemove;
QString mbox("Outgoing");
wrap->listMessages(mbox,mailsToSend);
if (mailsToSend.count()==0) {
delete wrap;
return false;
}
mailsToSend.setAutoDelete(false);
sendProgress = new progressMailSend();
sendProgress->show();
sendProgress->setMaxMails(mailsToSend.count());
while (mailsToSend.count()>0) {
if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) {
QMessageBox::critical(0,tr("Error sending mail"),
tr("Error sending queued mail - breaking"));
returnValue = false;
break;
}
mailsToRemove.append(mailsToSend.at(0));
mailsToSend.removeFirst();
sendProgress->setCurrentMails(mailsToRemove.count());
}
Config cfg( "mail" );
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h
index 4a4352f..04fc4b0 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h
@@ -2,71 +2,71 @@
#define SMTPwrapper_H
#include <qpe/applnk.h>
#include <qbitarray.h>
#include <qdatetime.h>
#include <libetpan/clist.h>
#include "settings.h"
class Mail;
class MBOXwrapper;
class RecMail;
class Attachment;
struct mailimf_fields;
struct mailimf_field;
struct mailimf_mailbox;
struct mailmime;
struct mailimf_address_list;
class progressMailSend;
class SMTPwrapper : public QObject
{
Q_OBJECT
public:
SMTPwrapper( Settings *s );
virtual ~SMTPwrapper(){}
void sendMail(const Mail& mail,SMTPaccount*smtp,bool later=false );
bool flushOutbox(SMTPaccount*smtp);
static progressMailSend*sendProgress;
signals:
void queuedMails( int );
protected:
mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
mailimf_fields *createImfFields(const Mail &mail );
mailmime *createMimeMail(const Mail&mail );
mailimf_address_list *parseAddresses(const QString&addr );
void addFileParts( mailmime *message,const QList<Attachment>&files );
mailmime *buildTxtPart(const QString&str );
mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content);
void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp );
clist *createRcptList( mailimf_fields *fields );
- static void storeMail(char*mail, size_t length, const QString&box);
+ static void storeMail(const char*mail, size_t length, const QString&box);
static QString mailsmtpError( int err );
static void progress( size_t current, size_t maximum );
static void addRcpts( clist *list, mailimf_address_list *addr_list );
static char *getFrom( mailmime *mail );
static char *getFrom( mailimf_field *ffrom);
static mailimf_field *getField( mailimf_fields *fields, int type );
- int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp );
+ int smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp );
void storeMail(mailmime*mail, const QString&box);
Settings *settings;
int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which);
int m_queuedMail;
static const char* USER_AGENT;
protected slots:
void emitQCop( int queued );
};
#endif
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro
index 96ffaa8..1abd2e8 100644
--- a/noncore/net/mail/mail.pro
+++ b/noncore/net/mail/mail.pro
@@ -1,53 +1,56 @@
CONFIG += qt warn_on debug quick-app
HEADERS = defines.h \
editaccounts.h \
composemail.h \
accountview.h \
mainwindow.h \
viewmail.h \
viewmailbase.h \
opiemail.h \
mailistviewitem.h \
settingsdialog.h \
statuswidget.h \
- newmaildir.h
+ newmaildir.h \
+ selectstore.h
SOURCES = main.cpp \
opiemail.cpp \
mainwindow.cpp \
accountview.cpp \
composemail.cpp \
addresspicker.cpp \
editaccounts.cpp \
viewmail.cpp \
viewmailbase.cpp \
settingsdialog.cpp \
statuswidget.cpp \
- newmaildir.cpp
+ newmaildir.cpp \
+ selectstore.cpp
INTERFACES = editaccountsui.ui \
selectmailtypeui.ui \
imapconfigui.ui \
pop3configui.ui \
nntpconfigui.ui \
smtpconfigui.ui \
addresspickerui.ui \
composemailui.ui \
settingsdialogui.ui \
statuswidgetui.ui \
- newmaildirui.ui
+ newmaildirui.ui \
+ selectstoreui.ui
INCLUDEPATH += $(OPIEDIR)/include
CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
contains( CONFTEST, y ){
LIBS += -lqpe -lopie -lmailwrapper -liconv
}else{
LIBS += -lqpe -lopie -lmailwrapper
}
TARGET = opiemail
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mail/selectstore.cpp b/noncore/net/mail/selectstore.cpp
new file mode 100644
index 0000000..28ab5a8
--- a/dev/null
+++ b/noncore/net/mail/selectstore.cpp
@@ -0,0 +1,19 @@
+#include "selectstore.h"
+
+Selectstore::Selectstore(QWidget* parent, const char* name)
+ :selectstoreui(parent,name,true)
+{
+
+}
+
+Selectstore::~Selectstore()
+{
+}
+
+void Selectstore::slotCreateNewFolder()
+{
+}
+
+void Selectstore::slotMoveMail()
+{
+}
diff --git a/noncore/net/mail/selectstore.h b/noncore/net/mail/selectstore.h
new file mode 100644
index 0000000..8b8e8ee
--- a/dev/null
+++ b/noncore/net/mail/selectstore.h
@@ -0,0 +1,19 @@
+#ifndef _SELECTSTORE_H
+#define _SELECTSTORE_H
+
+#include "selectstoreui.h"
+
+class Selectstore:public selectstoreui
+{
+ Q_OBJECT
+public:
+ Selectstore(QWidget* parent = 0, const char* name = 0);
+ virtual ~Selectstore();
+
+protected:
+ virtual void slotCreateNewFolder();
+ virtual void slotMoveMail();
+protected slots:
+
+};
+#endif
diff --git a/noncore/net/mail/selectstoreui.ui b/noncore/net/mail/selectstoreui.ui
new file mode 100644
index 0000000..3741b71
--- a/dev/null
+++ b/noncore/net/mail/selectstoreui.ui
@@ -0,0 +1,244 @@
+<!DOCTYPE UI><UI>
+<class>selectstoreui</class>
+<widget>
+ <class>QDialog</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>selectstoreui</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>190</width>
+ <height>273</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Select target box</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>2</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>2</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>headlabel</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>&lt;b&gt;Store mail(s) to&lt;/b&gt;</string>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>AlignCenter</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ </widget>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout2</cstring>
+ </property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget row="1" column="1" >
+ <class>QComboBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>folderSelection</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget row="1" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>folderLabel</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Folder:</string>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QComboBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>accountSelection</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget row="0" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>accountlabel</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Account:</string>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget>
+ <class>Line</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Line1</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>newFoldersel</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Create new folder</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>newFolderedit</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget>
+ <class>Line</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Line2</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>selMove</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Move mail(s)</string>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer2</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Vertical</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>selMove</sender>
+ <signal>clicked()</signal>
+ <receiver>selectstoreui</receiver>
+ <slot>slotMoveMail()</slot>
+ </connection>
+ <connection>
+ <sender>newFoldersel</sender>
+ <signal>clicked()</signal>
+ <receiver>selectstoreui</receiver>
+ <slot>slotCreateNewFolder()</slot>
+ </connection>
+ <slot access="protected">slotMoveMail()</slot>
+ <slot access="protected">slotCreateNewFolder()</slot>
+</connections>
+<tabstops>
+ <tabstop>accountSelection</tabstop>
+ <tabstop>folderSelection</tabstop>
+ <tabstop>newFoldersel</tabstop>
+ <tabstop>newFolderedit</tabstop>
+ <tabstop>selMove</tabstop>
+</tabstops>
+</UI>