summaryrefslogtreecommitdiff
Unidiff
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
@@ -218,7 +218,7 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
218 int err; 218 int err;
219 219
220 int pos = filename.findRev( '/' ); 220 int pos = filename.findRev( '/' );
221 221
222 if (filename.length()>0) { 222 if (filename.length()>0) {
223 QString tmp = filename.right( filename.length() - ( pos + 1 ) ); 223 QString tmp = filename.right( filename.length() - ( pos + 1 ) );
224 name = strdup( tmp.latin1() ); // just filename 224 name = strdup( tmp.latin1() ); // just filename
@@ -228,10 +228,10 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
228 228
229 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; 229 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT;
230 int mechanism = MAILMIME_MECHANISM_BASE64; 230 int mechanism = MAILMIME_MECHANISM_BASE64;
231 231
232 if ( mimetype.startsWith( "text/" ) ) { 232 if ( mimetype.startsWith( "text/" ) ) {
233 param = mailmime_parameter_new( strdup( "charset" ), 233 param = mailmime_parameter_new( strdup( "charset" ),
234 strdup( "iso-8859-1" ) ); 234 strdup( "iso-8859-1" ) );
235 disptype = MAILMIME_DISPOSITION_TYPE_INLINE; 235 disptype = MAILMIME_DISPOSITION_TYPE_INLINE;
236 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 236 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
237 } 237 }
@@ -250,7 +250,7 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
250 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); 250 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1()));
251 clist_append(content->ct_parameters,param); 251 clist_append(content->ct_parameters,param);
252 param = 0; 252 param = 0;
253 } 253 }
254 filePart = mailmime_new_empty( content, fields ); 254 filePart = mailmime_new_empty( content, fields );
255 } 255 }
256 if (filePart) { 256 if (filePart) {
@@ -548,13 +548,13 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
548 return; 548 return;
549 } 549 }
550 from = data = 0; 550 from = data = 0;
551 551
552 QString file = getTmpFile(); 552 QString file = getTmpFile();
553 writeToFile( file, mail ); 553 writeToFile( file, mail );
554 readFromFile( file, &data, &size ); 554 readFromFile( file, &data, &size );
555 QFile f( file ); 555 QFile f( file );
556 f.remove(); 556 f.remove();
557 557
558 if (later) { 558 if (later) {
559 storeMail(data,size,"Outgoing"); 559 storeMail(data,size,"Outgoing");
560 if (data) free( data ); 560 if (data) free( data );
@@ -572,13 +572,13 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou
572 uint16_t port; 572 uint16_t port;
573 mailsmtp *session; 573 mailsmtp *session;
574 int err,result; 574 int err,result;
575 575
576 result = 1; 576 result = 1;
577 server = user = pass = 0; 577 server = user = pass = 0;
578 server = strdup( smtp->getServer().latin1() ); 578 server = strdup( smtp->getServer().latin1() );
579 ssl = smtp->getSSL(); 579 ssl = smtp->getSSL();
580 port = smtp->getPort().toUInt(); 580 port = smtp->getPort().toUInt();
581 581
582 session = mailsmtp_new( 20, &progress ); 582 session = mailsmtp_new( 20, &progress );
583 if ( session == NULL ) goto free_mem; 583 if ( session == NULL ) goto free_mem;
584 584
@@ -644,15 +644,15 @@ free_mem:
644void SMTPwrapper::sendMail(const Mail&mail,bool later ) 644void SMTPwrapper::sendMail(const Mail&mail,bool later )
645{ 645{
646 mailmime * mimeMail; 646 mailmime * mimeMail;
647 647
648 SMTPaccount *smtp = getAccount(mail.getName()); 648 SMTPaccount *smtp = getAccount(mail.getName());
649 649
650 mimeMail = createMimeMail(mail ); 650 mimeMail = createMimeMail(mail );
651 if ( mimeMail == NULL ) { 651 if ( mimeMail == NULL ) {
652 qDebug( "sendMail: error creating mime mail" ); 652 qDebug( "sendMail: error creating mime mail" );
653 } else { 653 } else {
654 sendProgress = new progressMailSend(); 654 sendProgress = new progressMailSend();
655// sendProgress->showMaximized(); 655// sendProgress->showMaximized();
656 sendProgress->show(); 656 sendProgress->show();
657 sendProgress->setMaxMails(1); 657 sendProgress->setMaxMails(1);
658 smtpSend( mimeMail,later,smtp); 658 smtpSend( mimeMail,later,smtp);
@@ -676,17 +676,17 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
676 676
677 wrap->fetchRawBody(*which,&data,&length); 677 wrap->fetchRawBody(*which,&data,&length);
678 if (!data) return 0; 678 if (!data) return 0;
679 int err = mailimf_fields_parse( data, length, &curTok, &fields ); 679 int err = mailimf_fields_parse( data, length, &curTok, &fields );
680 if (err != MAILIMF_NO_ERROR) { 680 if (err != MAILIMF_NO_ERROR) {
681 free(data); 681 free(data);
682 delete wrap; 682 delete wrap;
683 return 0; 683 return 0;
684 } 684 }
685 685
686 rcpts = createRcptList( fields ); 686 rcpts = createRcptList( fields );
687 ffrom = getField(fields, MAILIMF_FIELD_FROM ); 687 ffrom = getField(fields, MAILIMF_FIELD_FROM );
688 from = getFrom(ffrom); 688 from = getFrom(ffrom);
689 689
690 qDebug("Size: %i vs. %i",length,strlen(data)); 690 qDebug("Size: %i vs. %i",length,strlen(data));
691 if (rcpts && from) { 691 if (rcpts && from) {
692 return smtpSend(from,rcpts,data,strlen(data),smtp ); 692 return smtpSend(from,rcpts,data,strlen(data),smtp );
@@ -695,14 +695,17 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
695} 695}
696 696
697/* this is a special fun */ 697/* this is a special fun */
698void SMTPwrapper::flushOutbox(SMTPaccount*smtp) 698bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
699{ 699{
700 if (!smtp) return; 700 bool returnValue = true;
701 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 701
702 if (!smtp) return false;
703
704 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
702 MBOXwrapper*wrap = new MBOXwrapper(localfolders); 705 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
703 if (!wrap) { 706 if (!wrap) {
704 qDebug("memory error"); 707 qDebug("memory error");
705 return; 708 return false;
706 } 709 }
707 QList<RecMail> mailsToSend; 710 QList<RecMail> mailsToSend;
708 QList<RecMail> mailsToRemove; 711 QList<RecMail> mailsToRemove;
@@ -710,11 +713,11 @@ void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
710 wrap->listMessages(mbox,mailsToSend); 713 wrap->listMessages(mbox,mailsToSend);
711 if (mailsToSend.count()==0) { 714 if (mailsToSend.count()==0) {
712 delete wrap; 715 delete wrap;
713 return; 716 return false;
714 } 717 }
715 mailsToSend.setAutoDelete(false); 718 mailsToSend.setAutoDelete(false);
716 sendProgress = new progressMailSend(); 719 sendProgress = new progressMailSend();
717// sendProgress->showMaximized(); 720// sendProgress->showMaximized();
718 sendProgress->show(); 721 sendProgress->show();
719 sendProgress->setMaxMails(mailsToSend.count()); 722 sendProgress->setMaxMails(mailsToSend.count());
720 723
@@ -722,6 +725,8 @@ void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
722 if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { 725 if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) {
723 QMessageBox::critical(0,tr("Error sending mail"), 726 QMessageBox::critical(0,tr("Error sending mail"),
724 tr("Error sending queued mail - breaking")); 727 tr("Error sending queued mail - breaking"));
728
729 returnValue = false;
725 break; 730 break;
726 } 731 }
727 mailsToRemove.append(mailsToSend.at(0)); 732 mailsToRemove.append(mailsToSend.at(0));
@@ -734,4 +739,6 @@ void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
734 wrap->deleteMails(mbox,mailsToRemove); 739 wrap->deleteMails(mbox,mailsToRemove);
735 mailsToSend.setAutoDelete(true); 740 mailsToSend.setAutoDelete(true);
736 delete wrap; 741 delete wrap;
742 return returnValue;
743
737} 744}
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
@@ -28,7 +28,7 @@ public:
28 SMTPwrapper( Settings *s ); 28 SMTPwrapper( Settings *s );
29 virtual ~SMTPwrapper(){} 29 virtual ~SMTPwrapper(){}
30 void sendMail(const Mail& mail,bool later=false ); 30 void sendMail(const Mail& mail,bool later=false );
31 void flushOutbox(SMTPaccount*smtp); 31 bool flushOutbox(SMTPaccount*smtp);
32 32
33 static progressMailSend*sendProgress; 33 static progressMailSend*sendProgress;
34protected: 34protected:
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
@@ -68,8 +68,9 @@ void OpieMail::slotSendQueued()
68// } 68// }
69 if (smtp) { 69 if (smtp) {
70 SMTPwrapper * wrap = new SMTPwrapper(settings); 70 SMTPwrapper * wrap = new SMTPwrapper(settings);
71 wrap->flushOutbox(smtp); 71 if ( wrap->flushOutbox(smtp) ) {
72 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 72 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
73 }
73 } 74 }
74} 75}
75 76
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
@@ -218,7 +218,7 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
218 int err; 218 int err;
219 219
220 int pos = filename.findRev( '/' ); 220 int pos = filename.findRev( '/' );
221 221
222 if (filename.length()>0) { 222 if (filename.length()>0) {
223 QString tmp = filename.right( filename.length() - ( pos + 1 ) ); 223 QString tmp = filename.right( filename.length() - ( pos + 1 ) );
224 name = strdup( tmp.latin1() ); // just filename 224 name = strdup( tmp.latin1() ); // just filename
@@ -228,10 +228,10 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
228 228
229 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; 229 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT;
230 int mechanism = MAILMIME_MECHANISM_BASE64; 230 int mechanism = MAILMIME_MECHANISM_BASE64;
231 231
232 if ( mimetype.startsWith( "text/" ) ) { 232 if ( mimetype.startsWith( "text/" ) ) {
233 param = mailmime_parameter_new( strdup( "charset" ), 233 param = mailmime_parameter_new( strdup( "charset" ),
234 strdup( "iso-8859-1" ) ); 234 strdup( "iso-8859-1" ) );
235 disptype = MAILMIME_DISPOSITION_TYPE_INLINE; 235 disptype = MAILMIME_DISPOSITION_TYPE_INLINE;
236 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 236 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
237 } 237 }
@@ -250,7 +250,7 @@ mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimety
250 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); 250 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1()));
251 clist_append(content->ct_parameters,param); 251 clist_append(content->ct_parameters,param);
252 param = 0; 252 param = 0;
253 } 253 }
254 filePart = mailmime_new_empty( content, fields ); 254 filePart = mailmime_new_empty( content, fields );
255 } 255 }
256 if (filePart) { 256 if (filePart) {
@@ -548,13 +548,13 @@ void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
548 return; 548 return;
549 } 549 }
550 from = data = 0; 550 from = data = 0;
551 551
552 QString file = getTmpFile(); 552 QString file = getTmpFile();
553 writeToFile( file, mail ); 553 writeToFile( file, mail );
554 readFromFile( file, &data, &size ); 554 readFromFile( file, &data, &size );
555 QFile f( file ); 555 QFile f( file );
556 f.remove(); 556 f.remove();
557 557
558 if (later) { 558 if (later) {
559 storeMail(data,size,"Outgoing"); 559 storeMail(data,size,"Outgoing");
560 if (data) free( data ); 560 if (data) free( data );
@@ -572,13 +572,13 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou
572 uint16_t port; 572 uint16_t port;
573 mailsmtp *session; 573 mailsmtp *session;
574 int err,result; 574 int err,result;
575 575
576 result = 1; 576 result = 1;
577 server = user = pass = 0; 577 server = user = pass = 0;
578 server = strdup( smtp->getServer().latin1() ); 578 server = strdup( smtp->getServer().latin1() );
579 ssl = smtp->getSSL(); 579 ssl = smtp->getSSL();
580 port = smtp->getPort().toUInt(); 580 port = smtp->getPort().toUInt();
581 581
582 session = mailsmtp_new( 20, &progress ); 582 session = mailsmtp_new( 20, &progress );
583 if ( session == NULL ) goto free_mem; 583 if ( session == NULL ) goto free_mem;
584 584
@@ -644,15 +644,15 @@ free_mem:
644void SMTPwrapper::sendMail(const Mail&mail,bool later ) 644void SMTPwrapper::sendMail(const Mail&mail,bool later )
645{ 645{
646 mailmime * mimeMail; 646 mailmime * mimeMail;
647 647
648 SMTPaccount *smtp = getAccount(mail.getName()); 648 SMTPaccount *smtp = getAccount(mail.getName());
649 649
650 mimeMail = createMimeMail(mail ); 650 mimeMail = createMimeMail(mail );
651 if ( mimeMail == NULL ) { 651 if ( mimeMail == NULL ) {
652 qDebug( "sendMail: error creating mime mail" ); 652 qDebug( "sendMail: error creating mime mail" );
653 } else { 653 } else {
654 sendProgress = new progressMailSend(); 654 sendProgress = new progressMailSend();
655// sendProgress->showMaximized(); 655// sendProgress->showMaximized();
656 sendProgress->show(); 656 sendProgress->show();
657 sendProgress->setMaxMails(1); 657 sendProgress->setMaxMails(1);
658 smtpSend( mimeMail,later,smtp); 658 smtpSend( mimeMail,later,smtp);
@@ -676,17 +676,17 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
676 676
677 wrap->fetchRawBody(*which,&data,&length); 677 wrap->fetchRawBody(*which,&data,&length);
678 if (!data) return 0; 678 if (!data) return 0;
679 int err = mailimf_fields_parse( data, length, &curTok, &fields ); 679 int err = mailimf_fields_parse( data, length, &curTok, &fields );
680 if (err != MAILIMF_NO_ERROR) { 680 if (err != MAILIMF_NO_ERROR) {
681 free(data); 681 free(data);
682 delete wrap; 682 delete wrap;
683 return 0; 683 return 0;
684 } 684 }
685 685
686 rcpts = createRcptList( fields ); 686 rcpts = createRcptList( fields );
687 ffrom = getField(fields, MAILIMF_FIELD_FROM ); 687 ffrom = getField(fields, MAILIMF_FIELD_FROM );
688 from = getFrom(ffrom); 688 from = getFrom(ffrom);
689 689
690 qDebug("Size: %i vs. %i",length,strlen(data)); 690 qDebug("Size: %i vs. %i",length,strlen(data));
691 if (rcpts && from) { 691 if (rcpts && from) {
692 return smtpSend(from,rcpts,data,strlen(data),smtp ); 692 return smtpSend(from,rcpts,data,strlen(data),smtp );
@@ -695,14 +695,17 @@ int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
695} 695}
696 696
697/* this is a special fun */ 697/* this is a special fun */
698void SMTPwrapper::flushOutbox(SMTPaccount*smtp) 698bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
699{ 699{
700 if (!smtp) return; 700 bool returnValue = true;
701 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 701
702 if (!smtp) return false;
703
704 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
702 MBOXwrapper*wrap = new MBOXwrapper(localfolders); 705 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
703 if (!wrap) { 706 if (!wrap) {
704 qDebug("memory error"); 707 qDebug("memory error");
705 return; 708 return false;
706 } 709 }
707 QList<RecMail> mailsToSend; 710 QList<RecMail> mailsToSend;
708 QList<RecMail> mailsToRemove; 711 QList<RecMail> mailsToRemove;
@@ -710,11 +713,11 @@ void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
710 wrap->listMessages(mbox,mailsToSend); 713 wrap->listMessages(mbox,mailsToSend);
711 if (mailsToSend.count()==0) { 714 if (mailsToSend.count()==0) {
712 delete wrap; 715 delete wrap;
713 return; 716 return false;
714 } 717 }
715 mailsToSend.setAutoDelete(false); 718 mailsToSend.setAutoDelete(false);
716 sendProgress = new progressMailSend(); 719 sendProgress = new progressMailSend();
717// sendProgress->showMaximized(); 720// sendProgress->showMaximized();
718 sendProgress->show(); 721 sendProgress->show();
719 sendProgress->setMaxMails(mailsToSend.count()); 722 sendProgress->setMaxMails(mailsToSend.count());
720 723
@@ -722,6 +725,8 @@ void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
722 if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { 725 if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) {
723 QMessageBox::critical(0,tr("Error sending mail"), 726 QMessageBox::critical(0,tr("Error sending mail"),
724 tr("Error sending queued mail - breaking")); 727 tr("Error sending queued mail - breaking"));
728
729 returnValue = false;
725 break; 730 break;
726 } 731 }
727 mailsToRemove.append(mailsToSend.at(0)); 732 mailsToRemove.append(mailsToSend.at(0));
@@ -734,4 +739,6 @@ void SMTPwrapper::flushOutbox(SMTPaccount*smtp)
734 wrap->deleteMails(mbox,mailsToRemove); 739 wrap->deleteMails(mbox,mailsToRemove);
735 mailsToSend.setAutoDelete(true); 740 mailsToSend.setAutoDelete(true);
736 delete wrap; 741 delete wrap;
742 return returnValue;
743
737} 744}
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
@@ -28,7 +28,7 @@ public:
28 SMTPwrapper( Settings *s ); 28 SMTPwrapper( Settings *s );
29 virtual ~SMTPwrapper(){} 29 virtual ~SMTPwrapper(){}
30 void sendMail(const Mail& mail,bool later=false ); 30 void sendMail(const Mail& mail,bool later=false );
31 void flushOutbox(SMTPaccount*smtp); 31 bool flushOutbox(SMTPaccount*smtp);
32 32
33 static progressMailSend*sendProgress; 33 static progressMailSend*sendProgress;
34protected: 34protected: