summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp47
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h2
-rw-r--r--noncore/net/mail/opiemail.cpp5
-rw-r--r--noncore/net/mail/smtpwrapper.cpp47
-rw-r--r--noncore/net/mail/smtpwrapper.h2
5 files changed, 59 insertions, 44 deletions
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index 770e2b8..a7e4837 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -217,9 +217,9 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
char*file = 0;
int err;
int pos = filename.findRev( '/' );
-
+
if (filename.length()>0) {
QString tmp = filename.right( filename.length() - ( pos + 1 ) );
name = strdup( tmp.latin1() ); // just filename
file = strdup( filename.latin1() ); // full name with path
@@ -227,12 +227,12 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain
int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT;
int mechanism = MAILMIME_MECHANISM_BASE64;
-
+
if ( mimetype.startsWith( "text/" ) ) {
param = mailmime_parameter_new( strdup( "charset" ),
- strdup( "iso-8859-1" ) );
+ strdup( "iso-8859-1" ) );
disptype = MAILMIME_DISPOSITION_TYPE_INLINE;
mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
}
@@ -249,9 +249,9 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
QFileInfo f(filename);
param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1()));
clist_append(content->ct_parameters,param);
param = 0;
- }
+ }
filePart = mailmime_new_empty( content, fields );
}
if (filePart) {
if (filename.length()>0) {
@@ -547,15 +547,15 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
if ( smtp == NULL ) {
return;
}
from = data = 0;
-
+
QString file = getTmpFile();
writeToFile( file, mail );
readFromFile( file, &data, &size );
QFile f( file );
f.remove();
-
+
if (later) {
storeMail(data,size,"Outgoing");
if (data) free( data );
return;
@@ -571,15 +571,15 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou
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 );
@@ -643,17 +643,17 @@ free_mem:
void SMTPwrapper::sendMail(const Mail&mail,bool later )
{
mailmime * mimeMail;
-
+
SMTPaccount *smtp = getAccount(mail.getName());
-
+
mimeMail = createMimeMail(mail );
if ( mimeMail == NULL ) {
qDebug( "sendMail: error creating mime mail" );
} else {
sendProgress = new progressMailSend();
-// sendProgress->showMaximized();
+// sendProgress->showMaximized();
sendProgress->show();
sendProgress->setMaxMails(1);
smtpSend( mimeMail,later,smtp);
mailmime_free( mimeMail );
@@ -675,54 +675,59 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
char*from = 0;
wrap->fetchRawBody(*which,&data,&length);
if (!data) return 0;
- int err = mailimf_fields_parse( data, length, &curTok, &fields );
+ int err = mailimf_fields_parse( data, length, &curTok, &fields );
if (err != MAILIMF_NO_ERROR) {
free(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) {
return smtpSend(from,rcpts,data,strlen(data),smtp );
}
return 0;
}
/* this is a special fun */
-void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
+bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
{
- if (!smtp) return;
- QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
+ bool returnValue = true;
+
+ if (!smtp) return false;
+
+ QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
MBOXwrapper*wrap = new MBOXwrapper(localfolders);
if (!wrap) {
qDebug("memory error");
- return;
+ return false;
}
QList<RecMail> mailsToSend;
QList<RecMail> mailsToRemove;
QString mbox("Outgoing");
wrap->listMessages(mbox,mailsToSend);
if (mailsToSend.count()==0) {
delete wrap;
- return;
+ return false;
}
mailsToSend.setAutoDelete(false);
sendProgress = new progressMailSend();
-// sendProgress->showMaximized();
+// sendProgress->showMaximized();
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();
@@ -733,5 +738,7 @@ void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
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 baa353b..66180b7 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h
@@ -27,9 +27,9 @@ class SMTPwrapper : public QObject
public:
SMTPwrapper( Settings *s );
virtual ~SMTPwrapper(){}
void sendMail(const Mail& mail,bool later=false );
- void flushOutbox(SMTPaccount*smtp);
+ bool flushOutbox(SMTPaccount*smtp);
static progressMailSend*sendProgress;
protected:
mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 833cac2..0dede90 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -67,10 +67,11 @@ void OpieMail::slotSendQueued()
}
// }
if (smtp) {
SMTPwrapper * wrap = new SMTPwrapper(settings);
- wrap->flushOutbox(smtp);
- QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
+ if ( wrap->flushOutbox(smtp) ) {
+ QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
+ }
}
}
void OpieMail::slotSearchMails()
diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp
index 770e2b8..a7e4837 100644
--- a/noncore/net/mail/smtpwrapper.cpp
+++ b/noncore/net/mail/smtpwrapper.cpp
@@ -217,9 +217,9 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
char*file = 0;
int err;
int pos = filename.findRev( '/' );
-
+
if (filename.length()>0) {
QString tmp = filename.right( filename.length() - ( pos + 1 ) );
name = strdup( tmp.latin1() ); // just filename
file = strdup( filename.latin1() ); // full name with path
@@ -227,12 +227,12 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain
int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT;
int mechanism = MAILMIME_MECHANISM_BASE64;
-
+
if ( mimetype.startsWith( "text/" ) ) {
param = mailmime_parameter_new( strdup( "charset" ),
- strdup( "iso-8859-1" ) );
+ strdup( "iso-8859-1" ) );
disptype = MAILMIME_DISPOSITION_TYPE_INLINE;
mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
}
@@ -249,9 +249,9 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
QFileInfo f(filename);
param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1()));
clist_append(content->ct_parameters,param);
param = 0;
- }
+ }
filePart = mailmime_new_empty( content, fields );
}
if (filePart) {
if (filename.length()>0) {
@@ -547,15 +547,15 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
if ( smtp == NULL ) {
return;
}
from = data = 0;
-
+
QString file = getTmpFile();
writeToFile( file, mail );
readFromFile( file, &data, &size );
QFile f( file );
f.remove();
-
+
if (later) {
storeMail(data,size,"Outgoing");
if (data) free( data );
return;
@@ -571,15 +571,15 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou
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 );
@@ -643,17 +643,17 @@ free_mem:
void SMTPwrapper::sendMail(const Mail&mail,bool later )
{
mailmime * mimeMail;
-
+
SMTPaccount *smtp = getAccount(mail.getName());
-
+
mimeMail = createMimeMail(mail );
if ( mimeMail == NULL ) {
qDebug( "sendMail: error creating mime mail" );
} else {
sendProgress = new progressMailSend();
-// sendProgress->showMaximized();
+// sendProgress->showMaximized();
sendProgress->show();
sendProgress->setMaxMails(1);
smtpSend( mimeMail,later,smtp);
mailmime_free( mimeMail );
@@ -675,54 +675,59 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
char*from = 0;
wrap->fetchRawBody(*which,&data,&length);
if (!data) return 0;
- int err = mailimf_fields_parse( data, length, &curTok, &fields );
+ int err = mailimf_fields_parse( data, length, &curTok, &fields );
if (err != MAILIMF_NO_ERROR) {
free(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) {
return smtpSend(from,rcpts,data,strlen(data),smtp );
}
return 0;
}
/* this is a special fun */
-void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
+bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
{
- if (!smtp) return;
- QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
+ bool returnValue = true;
+
+ if (!smtp) return false;
+
+ QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
MBOXwrapper*wrap = new MBOXwrapper(localfolders);
if (!wrap) {
qDebug("memory error");
- return;
+ return false;
}
QList<RecMail> mailsToSend;
QList<RecMail> mailsToRemove;
QString mbox("Outgoing");
wrap->listMessages(mbox,mailsToSend);
if (mailsToSend.count()==0) {
delete wrap;
- return;
+ return false;
}
mailsToSend.setAutoDelete(false);
sendProgress = new progressMailSend();
-// sendProgress->showMaximized();
+// sendProgress->showMaximized();
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();
@@ -733,5 +738,7 @@ void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
sendProgress = 0;
wrap->deleteMails(mbox,mailsToRemove);
mailsToSend.setAutoDelete(true);
delete wrap;
+ return returnValue;
+
}
diff --git a/noncore/net/mail/smtpwrapper.h b/noncore/net/mail/smtpwrapper.h
index baa353b..66180b7 100644
--- a/noncore/net/mail/smtpwrapper.h
+++ b/noncore/net/mail/smtpwrapper.h
@@ -27,9 +27,9 @@ class SMTPwrapper : public QObject
public:
SMTPwrapper( Settings *s );
virtual ~SMTPwrapper(){}
void sendMail(const Mail& mail,bool later=false );
- void flushOutbox(SMTPaccount*smtp);
+ bool flushOutbox(SMTPaccount*smtp);
static progressMailSend*sendProgress;
protected:
mailimf_mailbox *newMailbox(const QString&name,const QString&mail );