summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/composemail.cpp4
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp154
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h25
-rw-r--r--noncore/net/mail/opiemail.cpp5
4 files changed, 105 insertions, 83 deletions
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp
index 5e823e8..abcc3f6 100644
--- a/noncore/net/mail/composemail.cpp
+++ b/noncore/net/mail/composemail.cpp
@@ -175,66 +175,66 @@ void ComposeMail::removeAttachment()
if ( !attList->currentItem() ) {
QMessageBox::information( this, tr( "Error" ),
tr( "<p>Please select a File.</p>" ),
tr( "Ok" ) );
} else {
attList->takeItem( attList->currentItem() );
}
}
void ComposeMail::accept()
{
if ( checkBoxLater->isChecked() ) {
qDebug( "Send later" );
}
#if 0
qDebug( "Sending Mail with " +
smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() );
#endif
Mail *mail = new Mail();
SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
mail->setMail(fromBox->currentText());
if ( !toLine->text().isEmpty() ) {
mail->setTo( toLine->text() );
} else {
qDebug( "No Reciever spezified -> returning" );
return;
}
mail->setName(senderNameEdit->text());
mail->setCC( ccLine->text() );
mail->setBCC( bccLine->text() );
mail->setReply( replyLine->text() );
mail->setSubject( subjectLine->text() );
QString txt = message->text();
if ( !sigMultiLine->text().isEmpty() ) {
txt.append( "\n--\n" );
txt.append( sigMultiLine->text() );
}
qDebug(txt);
mail->setMessage( txt );
AttachViewItem *it = (AttachViewItem *) attList->firstChild();
while ( it != NULL ) {
mail->addAttachment( it->getAttachment() );
it = (AttachViewItem *) it->nextSibling();
}
- SMTPwrapper wrapper( settings );
- wrapper.sendMail( *mail,smtp,checkBoxLater->isChecked() );
+ SMTPwrapper wrapper( smtp );
+ wrapper.sendMail( *mail,checkBoxLater->isChecked() );
QDialog::accept();
}
AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
: QListViewItem( parent )
{
attachment = att;
qDebug( att->getMimeType() );
setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ?
Resource::loadPixmap( "UnknownDocument-14" ) :
attachment->getDocLnk().pixmap() );
setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
setText( 1, QString::number( att->getSize() ) );
}
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index 3ab6b77..a3c68ae 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -1,82 +1,89 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <qdir.h>
#include <qt.h>
#include <qmessagebox.h>
#include <qpe/config.h>
#include <qpe/qcopenvelope_qws.h>
#include <libetpan/libetpan.h>
#include "smtpwrapper.h"
#include "mailwrapper.h"
#include "abstractmail.h"
#include "logindialog.h"
#include "mailtypes.h"
#include "sendmailprogress.h"
const char* SMTPwrapper::USER_AGENT="OpieMail v0.4";
progressMailSend*SMTPwrapper::sendProgress = 0;
-SMTPwrapper::SMTPwrapper( Settings *s )
-: QObject() {
- settings = s;
+SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp )
+ : QObject()
+{
+ m_SmtpAccount = aSmtp;
Config cfg( "mail" );
cfg.setGroup( "Status" );
m_queuedMail = cfg.readNumEntry( "outgoing", 0 );
emit queuedMails( m_queuedMail );
connect( this, SIGNAL( queuedMails( int ) ), this, SLOT( emitQCop( int ) ) );
+ m_smtp = 0;
+}
+
+SMTPwrapper::~SMTPwrapper()
+{
+ disc_server();
}
void SMTPwrapper::emitQCop( int queued ) {
QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" );
env << queued;
}
QString SMTPwrapper::mailsmtpError( int errnum ) {
switch ( errnum ) {
case MAILSMTP_NO_ERROR:
return tr( "No error" );
case MAILSMTP_ERROR_UNEXPECTED_CODE:
return tr( "Unexpected error code" );
case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
return tr( "Service not available" );
case MAILSMTP_ERROR_STREAM:
return tr( "Stream error" );
case MAILSMTP_ERROR_HOSTNAME:
return tr( "gethostname() failed" );
case MAILSMTP_ERROR_NOT_IMPLEMENTED:
return tr( "Not implemented" );
case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
return tr( "Error, action not taken" );
case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
return tr( "Data exceeds storage allocation" );
case MAILSMTP_ERROR_IN_PROCESSING:
return tr( "Error in processing" );
case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED:
return tr( "Starttls not supported" );
// case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
// return tr( "Insufficient system storage" );
case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
return tr( "Mailbox unavailable" );
case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
return tr( "Mailbox name not allowed" );
case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
return tr( "Bad command sequence" );
case MAILSMTP_ERROR_USER_NOT_LOCAL:
return tr( "User not local" );
case MAILSMTP_ERROR_TRANSACTION_FAILED:
return tr( "Transaction failed" );
case MAILSMTP_ERROR_MEMORY:
return tr( "Memory error" );
case MAILSMTP_ERROR_CONNECTION_REFUSED:
return tr( "Connection refused" );
default:
return tr( "Unknown error code" );
}
@@ -465,397 +472,404 @@ clist *SMTPwrapper::createRcptList( mailimf_fields *fields ) {
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(const char*mail, size_t length, const QString&box) {
if (!mail)
return;
QString localfolders = AbstractMail::defaultLocalfolder();
AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
wrap->createMbox(box);
wrap->storeMessage(mail,length,box);
delete wrap;
}
-void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) {
+void SMTPwrapper::smtpSend( mailmime *mail,bool later) {
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;
}
msg = 0;
if (later) {
storeMail(data,size,"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);
+ smtpSend(from,rcpts,data,size);
if (data) {
free(data);
}
if (from) {
free(from);
}
if (rcpts)
smtp_address_list_free( rcpts );
}
void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage)
{
if (data) {
storeMail(data,size,"Sendfailed");
}
if (failuremessage) {
QMessageBox::critical(0,tr("Error sending mail"),
tr("<center>%1</center>").arg(failuremessage));
}
}
-int SMTPwrapper::start_smtp_tls(mailsmtp *session)
+int SMTPwrapper::start_smtp_tls()
{
- if (!session) {
+ if (!m_smtp) {
return MAILSMTP_ERROR_IN_PROCESSING;
}
- int err = mailesmtp_starttls(session);
+ int err = mailesmtp_starttls(m_smtp);
if (err != MAILSMTP_NO_ERROR) return err;
mailstream_low * low;
mailstream_low * new_low;
- low = mailstream_get_low(session->stream);
+ low = mailstream_get_low(m_smtp->stream);
if (!low) {
return MAILSMTP_ERROR_IN_PROCESSING;
}
int fd = mailstream_low_get_fd(low);
if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) {
mailstream_low_free(low);
- mailstream_set_low(session->stream, new_low);
+ mailstream_set_low(m_smtp->stream, new_low);
} else {
return MAILSMTP_ERROR_IN_PROCESSING;
}
return err;
}
-int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp ) {
+void SMTPwrapper::connect_server()
+{
const char *server, *user, *pass;
bool ssl;
uint16_t port;
- mailsmtp *session;
- int err,result;
- QString failuretext = "";
-
- result = 1;
- server = user = pass = 0;
- server = smtp->getServer().latin1();
-
- // FIXME: currently only TLS and Plain work.
-
ssl = false;
bool try_tls = true;
bool force_tls=false;
+ server = user = pass = 0;
+ QString failuretext = "";
- if ( smtp->ConnectionType() == 2 ) {
+ if (m_smtp || !m_SmtpAccount) {
+ return;
+ }
+ server = m_SmtpAccount->getServer().latin1();
+ if ( m_SmtpAccount->ConnectionType() == 2 ) {
ssl = true;
try_tls = false;
- } else if (smtp->ConnectionType() == 1) {
+ } else if (m_SmtpAccount->ConnectionType() == 1) {
force_tls = true;
}
+ int result = 1;
+ port = m_SmtpAccount->getPort().toUInt();
- port = smtp->getPort().toUInt();
-
- session = mailsmtp_new( 20, &progress );
- if ( session == NULL ) {
+ m_smtp = mailsmtp_new( 20, &progress );
+ if ( m_smtp == NULL ) {
/* no failure message cause this happens when problems with memory - than we
we can not display any messagebox */
- return 0;
+ return;
}
+ int err = MAILSMTP_NO_ERROR;
qDebug( "Servername %s at port %i", server, port );
if ( ssl ) {
qDebug( "SSL session" );
- err = mailsmtp_ssl_connect( session, server, port );
+ err = mailsmtp_ssl_connect( m_smtp, server, port );
} else {
qDebug( "No SSL session" );
- err = mailsmtp_socket_connect( session, server, port );
+ err = mailsmtp_socket_connect( m_smtp, server, port );
}
if ( err != MAILSMTP_NO_ERROR ) {
qDebug("Error init connection");
failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err));
result = 0;
}
/* switch to tls after init 'cause there it will send the ehlo */
if (result) {
- err = mailsmtp_init( session );
+ err = mailsmtp_init( m_smtp );
if (err != MAILSMTP_NO_ERROR) {
result = 0;
failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err));
}
}
if (try_tls) {
- err = start_smtp_tls(session);
+ err = start_smtp_tls();
if (err != MAILSMTP_NO_ERROR) {
try_tls = false;
} else {
- err = mailesmtp_ehlo(session);
+ err = mailesmtp_ehlo(m_smtp);
}
}
if (!try_tls && force_tls) {
result = 0;
failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err));
}
- if (result==1 && smtp->getLogin() ) {
+ if (result==1 && m_SmtpAccount->getLogin() ) {
qDebug("smtp with auth");
- if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) {
+ if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) {
// get'em
- LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true );
+ LoginDialog login( m_SmtpAccount->getUser(),
+ m_SmtpAccount->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
user = login.getUser().latin1();
pass = login.getPassword().latin1();
} else {
result = 0;
failuretext=tr("Login aborted - storing mail to localfolder");
}
} else {
- user = smtp->getUser().latin1();
- pass = smtp->getPassword().latin1();
+ user = m_SmtpAccount->getUser().latin1();
+ pass = m_SmtpAccount->getPassword().latin1();
}
- qDebug( "session->auth: %i", session->auth);
+ qDebug( "session->auth: %i", m_smtp->auth);
if (result) {
- err = mailsmtp_auth( session, (char*)user, (char*)pass );
+ err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass );
if ( err == MAILSMTP_NO_ERROR ) {
qDebug("auth ok");
} else {
failuretext = tr("Authentification failed");
result = 0;
}
}
}
+}
- if (result) {
- err = mailsmtp_send( session, from, rcpts, data, size );
+void SMTPwrapper::disc_server()
+{
+ if (m_smtp) {
+ mailsmtp_quit( m_smtp );
+ mailsmtp_free( m_smtp );
+ m_smtp = 0;
+ }
+}
+
+int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size )
+{
+ int err,result;
+ QString failuretext = "";
+
+ connect_server();
+
+ result = 1;
+ if (m_smtp) {
+ err = mailsmtp_send( m_smtp, from, rcpts, data, size );
if ( err != MAILSMTP_NO_ERROR ) {
failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err));
result = 0;
}
+ } else {
+ result = 0;
}
if (!result) {
storeFailedMail(data,size,failuretext);
} else {
qDebug( "Mail sent." );
storeMail(data,size,"Sent");
}
- if (session) {
- mailsmtp_quit( session );
- mailsmtp_free( session );
- }
return result;
}
-void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) {
+void SMTPwrapper::sendMail(const Mail&mail,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);
+ smtpSend( mimeMail,later);
qDebug("Clean up done");
sendProgress->hide();
delete sendProgress;
sendProgress = 0;
mailmime_free( mimeMail );
}
}
-int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which) {
+int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,RecMail*which) {
size_t curTok = 0;
mailimf_fields *fields = 0;
mailimf_field*ffrom = 0;
clist *rcpts = 0;
char*from = 0;
int res = 0;
encodedString * data = wrap->fetchRawBody(*which);
if (!data)
return 0;
int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields );
if (err != MAILIMF_NO_ERROR) {
delete data;
delete wrap;
return 0;
}
rcpts = createRcptList( fields );
ffrom = getField(fields, MAILIMF_FIELD_FROM );
from = getFrom(ffrom);
if (rcpts && from) {
- res = smtpSend(from,rcpts,data->Content(),data->Length(),smtp );
+ res = smtpSend(from,rcpts,data->Content(),data->Length());
}
if (fields) {
mailimf_fields_free(fields);
fields = 0;
}
if (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 SMTPwrapper::flushOutbox() {
bool returnValue = true;
qDebug("Sending the queue");
- if (!smtp) {
+ if (!m_SmtpAccount) {
qDebug("No smtp account given");
return false;
}
bool reset_user_value = false;
QString localfolders = AbstractMail::defaultLocalfolder();
AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
if (!wrap) {
qDebug("memory error");
return false;
}
QString oldPw, oldUser;
QList<RecMail> mailsToSend;
QList<RecMail> mailsToRemove;
QString mbox("Outgoing");
wrap->listMessages(mbox,mailsToSend);
if (mailsToSend.count()==0) {
delete wrap;
qDebug("No mails to send");
return false;
}
- oldPw = smtp->getPassword();
- oldUser = smtp->getUser();
- if (smtp->getLogin() && (smtp->getUser().isEmpty() || smtp->getPassword().isEmpty()) ) {
+ oldPw = m_SmtpAccount->getPassword();
+ oldUser = m_SmtpAccount->getUser();
+ if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) {
// get'em
QString user,pass;
- LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true );
+ LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
user = login.getUser().latin1();
pass = login.getPassword().latin1();
reset_user_value = true;
- smtp->setUser(user);
- smtp->setPassword(pass);
+ m_SmtpAccount->setUser(user);
+ m_SmtpAccount->setPassword(pass);
} else {
return true;
}
}
mailsToSend.setAutoDelete(false);
sendProgress = new progressMailSend();
sendProgress->show();
sendProgress->setMaxMails(mailsToSend.count());
while (mailsToSend.count()>0) {
- if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) {
+ if (sendQueuedMail(wrap,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());
}
if (reset_user_value) {
- smtp->setUser(oldUser);
- smtp->setPassword(oldPw);
+ m_SmtpAccount->setUser(oldUser);
+ m_SmtpAccount->setPassword(oldPw);
}
Config cfg( "mail" );
cfg.setGroup( "Status" );
m_queuedMail = 0;
cfg.writeEntry( "outgoing", m_queuedMail );
emit queuedMails( m_queuedMail );
sendProgress->hide();
delete sendProgress;
sendProgress = 0;
wrap->deleteMails(mbox,mailsToRemove);
mailsToSend.setAutoDelete(true);
delete wrap;
return returnValue;
}
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h
index 75e4891..7f6aac1 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h
@@ -1,76 +1,83 @@
+// -*- Mode: C++; -*-
#ifndef SMTPwrapper_H
#define SMTPwrapper_H
#include <qpe/applnk.h>
#include <qbitarray.h>
#include <qdatetime.h>
#include <libetpan/clist.h>
#include "settings.h"
class Mail;
class AbstractMail;
class RecMail;
class Attachment;
struct mailimf_fields;
struct mailimf_field;
struct mailimf_mailbox;
struct mailmime;
struct mailimf_address_list;
class progressMailSend;
struct mailsmtp;
+class SMTPaccount;
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);
+ SMTPwrapper(SMTPaccount * aSmtp);
+ virtual ~SMTPwrapper();
+ void sendMail(const Mail& mail,bool later=false );
+ bool flushOutbox();
static progressMailSend*sendProgress;
signals:
void queuedMails( int );
protected:
+ mailsmtp *m_smtp;
+ SMTPaccount * m_SmtpAccount;
+
+ void connect_server();
+ void disc_server();
+ int start_smtp_tls();
+
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 );
+ void smtpSend( mailmime *mail,bool later);
clist *createRcptList( mailimf_fields *fields );
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 );
- static int start_smtp_tls(mailsmtp *session);
- int smtpSend(char*from,clist*rcpts,const char*data,size_t size, SMTPaccount *smtp );
+ int smtpSend(char*from,clist*rcpts,const char*data,size_t size);
void storeMail(mailmime*mail, const QString&box);
- Settings *settings;
- int sendQueuedMail(AbstractMail*wrap,SMTPaccount*smtp,RecMail*which);
+ int sendQueuedMail(AbstractMail*wrap,RecMail*which);
void storeFailedMail(const char*data,unsigned int size, const char*failuremessage);
int m_queuedMail;
static const char* USER_AGENT;
protected slots:
void emitQCop( int queued );
};
#endif
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index ea0019d..0795436 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -49,100 +49,101 @@ void OpieMail::slotwriteMail(const QString&name,const QString&email)
if (!name.isEmpty()) {
compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
} else {
compose.setTo(email);
}
}
compose.showMaximized();
compose.slotAdjustColumns();
compose.exec();
}
void OpieMail::slotComposeMail()
{
qDebug( "Compose Mail" );
slotwriteMail(0l,0l);
}
void OpieMail::slotSendQueued()
{
qDebug( "Send Queued" );
SMTPaccount *smtp = 0;
QList<Account> list = settings->getAccounts();
QList<SMTPaccount> smtpList;
smtpList.setAutoDelete(false);
Account *it;
for ( it = list.first(); it; it = list.next() ) {
if ( it->getType().compare( "SMTP" ) == 0 ) {
smtp = static_cast<SMTPaccount *>(it);
smtpList.append(smtp);
}
}
if (smtpList.count()==0) {
QMessageBox::information(0,tr("Info"),tr("Define a smtp account first"));
return;
}
if (smtpList.count()==1) {
smtp = smtpList.at(0);
} else {
smtp = 0;
selectsmtp selsmtp;
selsmtp.setSelectionlist(&smtpList);
selsmtp.showMaximized();
if (selsmtp.exec()==QDialog::Accepted) {
smtp = selsmtp.selected_smtp();
}
}
if (smtp) {
- SMTPwrapper * wrap = new SMTPwrapper(settings);
- if ( wrap->flushOutbox(smtp) ) {
+ SMTPwrapper * wrap = new SMTPwrapper(smtp);
+ if ( wrap->flushOutbox() ) {
QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
}
+ delete wrap;
}
}
void OpieMail::slotSearchMails()
{
qDebug( "Search Mails" );
}
void OpieMail::slotEditSettings()
{
SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
settingsDialog.showMaximized();
settingsDialog.exec();
}
void OpieMail::slotEditAccounts()
{
qDebug( "Edit Accounts" );
EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
eaDialog.showMaximized();
eaDialog.slotAdjustColumns();
eaDialog.exec();
if ( settings ) delete settings;
settings = new Settings();
folderView->populate( settings->getAccounts() );
}
void OpieMail::displayMail()
{
QListViewItem*item = mailView->currentItem();
if (!item) return;
RecMail mail = ((MailListViewItem*)item)->data();
RecBody body = folderView->fetchBody(mail);
ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
readMail.setBody( body );
readMail.setMail( mail );
readMail.showMaximized();
readMail.exec();
if ( readMail.deleted ) {
folderView->refreshCurrent();
} else {
( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) );
}
}
void OpieMail::slotDeleteMail()