summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
authorzautrix <zautrix>2004-07-03 19:26:15 (UTC)
committer zautrix <zautrix>2004-07-03 19:26:15 (UTC)
commitcc67ce39cdd7730caee878da3b191d76cad9479f (patch) (side-by-side diff)
treea19e8297fdf060845e1a81b58afe5272a58c3b61 /kmicromail/libmailwrapper
parent55413f404aa7a59bfbf38f9f91fabb595eca57ad (diff)
downloadkdepimpi-cc67ce39cdd7730caee878da3b191d76cad9479f.zip
kdepimpi-cc67ce39cdd7730caee878da3b191d76cad9479f.tar.gz
kdepimpi-cc67ce39cdd7730caee878da3b191d76cad9479f.tar.bz2
better error handling
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.cpp23
-rw-r--r--kmicromail/libmailwrapper/smtpwrapper.h4
2 files changed, 15 insertions, 12 deletions
diff --git a/kmicromail/libmailwrapper/smtpwrapper.cpp b/kmicromail/libmailwrapper/smtpwrapper.cpp
index 04a21ea..6a1b505 100644
--- a/kmicromail/libmailwrapper/smtpwrapper.cpp
+++ b/kmicromail/libmailwrapper/smtpwrapper.cpp
@@ -97,57 +97,58 @@ void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) {
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) {
+bool SMTPwrapper::smtpSend( mailmime *mail,bool later) {
clist *rcpts = 0;
char *from, *data;
size_t size;
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);
- ; // odebug << "Error fetching mime..." << oendl;
- return;
+ qDebug("Error fetching mime... ");
+ return false;
}
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;
+ return true;
}
from = getFrom( mail );
rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
- smtpSend(from,rcpts,data,size);
+ bool result = smtpSend(from,rcpts,data,size);
if (data) {
free(data);
}
if (from) {
free(from);
}
if (rcpts)
smtp_address_list_free( rcpts );
+ return result;
}
void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage)
{
if (data) {
storeMail(data,size,"Sendfailed");
}
if (failuremessage) {
@@ -311,34 +312,36 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size )
storeFailedMail(data,size,failuretext);
} else {
; // odebug << "Mail sent." << oendl;
storeMail(data,size,"Sent");
}
return result;
}
-void SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later )
+bool SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later )
{
mailmime * mimeMail;
-
+ bool result = true;
mimeMail = createMimeMail(mail );
- if ( mimeMail == NULL ) {
- ; // odebug << "sendMail: error creating mime mail" << oendl;
+ if ( mimeMail == 0 ) {
+ qDebug("SMTP wrapper:Error creating mail! ");
+ return false;
} else {
sendProgress = new progressMailSend();
sendProgress->show();
sendProgress->setMaxMails(1);
- smtpSend( mimeMail,later);
+ result = smtpSend( mimeMail,later);
; // odebug << "Clean up done" << oendl;
sendProgress->hide();
delete sendProgress;
sendProgress = 0;
mailmime_free( mimeMail );
}
+ return result;
}
int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) {
size_t curTok = 0;
mailimf_fields *fields = 0;
mailimf_field*ffrom = 0;
clist *rcpts = 0;
char*from = 0;
diff --git a/kmicromail/libmailwrapper/smtpwrapper.h b/kmicromail/libmailwrapper/smtpwrapper.h
index 6c5bbe8..105cbf5 100644
--- a/kmicromail/libmailwrapper/smtpwrapper.h
+++ b/kmicromail/libmailwrapper/smtpwrapper.h
@@ -18,34 +18,34 @@ class AbstractMail;
class SMTPwrapper : public Generatemail
{
Q_OBJECT
public:
SMTPwrapper(SMTPaccount * aSmtp);
virtual ~SMTPwrapper();
- void sendMail(const Opie::Core::OSmartPointer<Mail>& mail,bool later=false );
+ bool sendMail(const Opie::Core::OSmartPointer<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();
- void smtpSend( mailmime *mail,bool later);
+ bool smtpSend( mailmime *mail,bool later);
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 );
int smtpSend(char*from,clist*rcpts,const char*data,size_t size);
void storeMail(mailmime*mail, const QString&box);