summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-22 02:37:35 (UTC)
committer alwin <alwin>2003-12-22 02:37:35 (UTC)
commit9e7aafdb7c76d29fee742d53131a73dd60aded2b (patch) (unidiff)
treee98f9fe1233455f458738acbfd29bac78dd03342
parent7c016e1a75970cb7c28d70398ad20c708cdb452b (diff)
downloadopie-9e7aafdb7c76d29fee742d53131a73dd60aded2b.zip
opie-9e7aafdb7c76d29fee742d53131a73dd60aded2b.tar.gz
opie-9e7aafdb7c76d29fee742d53131a73dd60aded2b.tar.bz2
- storing mails send in outgoing (if queued) or sent (if sent) folder
TODO: flush queue, cleanup SMTP code, select smtp-account if more than one when flush the outgoing queue
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/composemail.cpp3
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp26
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h2
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp61
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h6
-rw-r--r--noncore/net/mail/mboxwrapper.cpp26
-rw-r--r--noncore/net/mail/mboxwrapper.h2
-rw-r--r--noncore/net/mail/smtpwrapper.cpp61
-rw-r--r--noncore/net/mail/smtpwrapper.h6
9 files changed, 162 insertions, 31 deletions
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp
index f680f5c..f532815 100644
--- a/noncore/net/mail/composemail.cpp
+++ b/noncore/net/mail/composemail.cpp
@@ -170,2 +170,3 @@ void ComposeMail::accept()
170 SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() ); 170 SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() );
171
171 mail->setMail( smtp->getMail() ); 172 mail->setMail( smtp->getMail() );
@@ -197,3 +198,3 @@ void ComposeMail::accept()
197 SMTPwrapper wrapper( settings ); 198 SMTPwrapper wrapper( settings );
198 wrapper.sendMail( *mail ); 199 wrapper.sendMail( *mail,checkBoxLater->isChecked() );
199 200
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 7581715..8117cef 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -3,4 +3,4 @@
3#include "mailwrapper.h" 3#include "mailwrapper.h"
4#include "libetpan/libetpan.h" 4#include <libetpan/libetpan.h>
5#include "libetpan/mailstorage.h" 5#include <libetpan/mailstorage.h>
6#include <qdir.h> 6#include <qdir.h>
@@ -69,3 +69,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
69 if (r == MAIL_ERROR_NOT_IMPLEMENTED) { 69 if (r == MAIL_ERROR_NOT_IMPLEMENTED) {
70 qDebug("flag fetching not implemented");
71 mFlags.setBit(FLAG_SEEN); 70 mFlags.setBit(FLAG_SEEN);
@@ -199 +198,22 @@ void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
199} 198}
199
200void MBOXwrapper::createFolder(const QString&)
201{
202}
203
204void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
205{
206 QString p = MBOXPath+"/";
207 p+=folder;
208 mailmbox_folder*f = 0;
209 int r = mailmbox_init(p.latin1(),0,1,0,&f);
210 if (r != MAIL_NO_ERROR) {
211 qDebug("Error init folder");
212 return;
213 }
214 r = mailmbox_append_message(f,msg,length);
215 if (r != MAIL_NO_ERROR) {
216 qDebug("Error writing message folder");
217 }
218 mailmbox_done(f);
219}
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index 779dbc8..1bbaf79 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -21,2 +21,4 @@ public:
21 virtual void answeredMail(const RecMail&mail); 21 virtual void answeredMail(const RecMail&mail);
22 virtual void createFolder(const QString&aFolder);
23 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
22 24
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index 162b1b9..a6a46ba 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -8,3 +8,4 @@
8 8
9#include <libetpan/mailmime.h> 9#include <libetpan/libetpan.h>
10#if 0
10#include <libetpan/mailimf.h> 11#include <libetpan/mailimf.h>
@@ -13,2 +14,3 @@
13#include <libetpan/maildriver.h> 14#include <libetpan/maildriver.h>
15#endif
14 16
@@ -16,2 +18,3 @@
16#include "mailwrapper.h" 18#include "mailwrapper.h"
19#include "mboxwrapper.h"
17#include "logindialog.h" 20#include "logindialog.h"
@@ -467,2 +470,19 @@ void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size )
467{ 470{
471
472 QFile msg_cache(file);
473 QString msg = "";
474 msg_cache.open(IO_ReadOnly);
475 char*message = new char[4096];
476 memset(message,0,4096);
477 while (msg_cache.readBlock(message,4095)>0) {
478 msg+=message;
479 memset(message,0,4096);
480 }
481 delete message;
482 *data = (char*)malloc(msg.length()+1*sizeof(char));
483 memset(*data,0,msg.length()+1);
484 memcpy(*data,msg.ascii(),msg.length());
485 *size=msg.length();
486
487#if 0
468 char *buf; 488 char *buf;
@@ -497,2 +517,3 @@ err_close:
497 close( fd ); 517 close( fd );
518#endif
498} 519}
@@ -504,3 +525,12 @@ void SMTPwrapper::progress( size_t current, size_t maximum )
504 525
505void SMTPwrapper::smtpSend( mailmime *mail ) 526void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box)
527{
528 if (!mail) return;
529 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
530 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
531 wrap->storeMessage(mail,length,box);
532 delete wrap;
533}
534
535void SMTPwrapper::smtpSend( mailmime *mail,bool later )
506{ 536{
@@ -521,5 +551,2 @@ void SMTPwrapper::smtpSend( mailmime *mail )
521 } 551 }
522 server = strdup( smtp->getServer().latin1() );
523 ssl = smtp->getSSL();
524 port = smtp->getPort().toUInt();
525 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); 552 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
@@ -528,2 +555,3 @@ void SMTPwrapper::smtpSend( mailmime *mail )
528 writeToFile( file, mail ); 555 writeToFile( file, mail );
556
529 readFromFile( file, &data, &size ); 557 readFromFile( file, &data, &size );
@@ -531,3 +559,15 @@ void SMTPwrapper::smtpSend( mailmime *mail )
531 f.remove(); 559 f.remove();
560
561 storeMail(data,size,(later?"Outgoing":"Sent"));
532 562
563 if (later) {
564 smtp_address_list_free( rcpts );
565 if (data) free( data );
566 if (from) free(from);
567 return;
568 }
569 server = strdup( smtp->getServer().latin1() );
570 ssl = smtp->getSSL();
571 port = smtp->getPort().toUInt();
572
533 session = mailsmtp_new( 20, &progress ); 573 session = mailsmtp_new( 20, &progress );
@@ -583,4 +623,5 @@ free_mem:
583 smtp_address_list_free( rcpts ); 623 smtp_address_list_free( rcpts );
584 free( data ); 624 if (data) free( data );
585 free( server ); 625 if (from) free(from);
626 if (server) free( server );
586 if ( smtp->getLogin() ) { 627 if ( smtp->getLogin() ) {
@@ -592,5 +633,5 @@ free_mem:
592 633
593void SMTPwrapper::sendMail(const Mail&mail ) 634void SMTPwrapper::sendMail(const Mail&mail,bool later )
594{ 635{
595 mailmime *mimeMail; 636 mailmime * mimeMail;
596 637
@@ -600,3 +641,3 @@ void SMTPwrapper::sendMail(const Mail&mail )
600 } else { 641 } else {
601 smtpSend( mimeMail ); 642 smtpSend( mimeMail,later );
602 mailmime_free( mimeMail ); 643 mailmime_free( mimeMail );
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h
index 8fdb07d..41e9a8c 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h
@@ -26,3 +26,3 @@ public:
26 virtual ~SMTPwrapper(){} 26 virtual ~SMTPwrapper(){}
27 void sendMail(const Mail& mail ); 27 void sendMail(const Mail& mail,bool later=false );
28 28
@@ -37,3 +37,3 @@ protected:
37 mailmime *buildFilePart(const QString&filename,const QString&mimetype ); 37 mailmime *buildFilePart(const QString&filename,const QString&mimetype );
38 void smtpSend( mailmime *mail ); 38 void smtpSend( mailmime *mail,bool later );
39 mailimf_field *getField( mailimf_fields *fields, int type ); 39 mailimf_field *getField( mailimf_fields *fields, int type );
@@ -44,2 +44,3 @@ protected:
44 void readFromFile(const QString&file, char **data, size_t *size ); 44 void readFromFile(const QString&file, char **data, size_t *size );
45 void storeMail(char*mail, size_t length, const QString&box);
45 46
@@ -49,2 +50,3 @@ protected:
49 static void addRcpts( clist *list, mailimf_address_list *addr_list ); 50 static void addRcpts( clist *list, mailimf_address_list *addr_list );
51 void storeMail(mailmime*mail, const QString&box);
50 Settings *settings; 52 Settings *settings;
diff --git a/noncore/net/mail/mboxwrapper.cpp b/noncore/net/mail/mboxwrapper.cpp
index 7581715..8117cef 100644
--- a/noncore/net/mail/mboxwrapper.cpp
+++ b/noncore/net/mail/mboxwrapper.cpp
@@ -3,4 +3,4 @@
3#include "mailwrapper.h" 3#include "mailwrapper.h"
4#include "libetpan/libetpan.h" 4#include <libetpan/libetpan.h>
5#include "libetpan/mailstorage.h" 5#include <libetpan/mailstorage.h>
6#include <qdir.h> 6#include <qdir.h>
@@ -69,3 +69,2 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target )
69 if (r == MAIL_ERROR_NOT_IMPLEMENTED) { 69 if (r == MAIL_ERROR_NOT_IMPLEMENTED) {
70 qDebug("flag fetching not implemented");
71 mFlags.setBit(FLAG_SEEN); 70 mFlags.setBit(FLAG_SEEN);
@@ -199 +198,22 @@ void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
199} 198}
199
200void MBOXwrapper::createFolder(const QString&)
201{
202}
203
204void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
205{
206 QString p = MBOXPath+"/";
207 p+=folder;
208 mailmbox_folder*f = 0;
209 int r = mailmbox_init(p.latin1(),0,1,0,&f);
210 if (r != MAIL_NO_ERROR) {
211 qDebug("Error init folder");
212 return;
213 }
214 r = mailmbox_append_message(f,msg,length);
215 if (r != MAIL_NO_ERROR) {
216 qDebug("Error writing message folder");
217 }
218 mailmbox_done(f);
219}
diff --git a/noncore/net/mail/mboxwrapper.h b/noncore/net/mail/mboxwrapper.h
index 779dbc8..1bbaf79 100644
--- a/noncore/net/mail/mboxwrapper.h
+++ b/noncore/net/mail/mboxwrapper.h
@@ -21,2 +21,4 @@ public:
21 virtual void answeredMail(const RecMail&mail); 21 virtual void answeredMail(const RecMail&mail);
22 virtual void createFolder(const QString&aFolder);
23 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
22 24
diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp
index 162b1b9..a6a46ba 100644
--- a/noncore/net/mail/smtpwrapper.cpp
+++ b/noncore/net/mail/smtpwrapper.cpp
@@ -8,3 +8,4 @@
8 8
9#include <libetpan/mailmime.h> 9#include <libetpan/libetpan.h>
10#if 0
10#include <libetpan/mailimf.h> 11#include <libetpan/mailimf.h>
@@ -13,2 +14,3 @@
13#include <libetpan/maildriver.h> 14#include <libetpan/maildriver.h>
15#endif
14 16
@@ -16,2 +18,3 @@
16#include "mailwrapper.h" 18#include "mailwrapper.h"
19#include "mboxwrapper.h"
17#include "logindialog.h" 20#include "logindialog.h"
@@ -467,2 +470,19 @@ void SMTPwrapper::readFromFile(const QString&file, char **data, size_t *size )
467{ 470{
471
472 QFile msg_cache(file);
473 QString msg = "";
474 msg_cache.open(IO_ReadOnly);
475 char*message = new char[4096];
476 memset(message,0,4096);
477 while (msg_cache.readBlock(message,4095)>0) {
478 msg+=message;
479 memset(message,0,4096);
480 }
481 delete message;
482 *data = (char*)malloc(msg.length()+1*sizeof(char));
483 memset(*data,0,msg.length()+1);
484 memcpy(*data,msg.ascii(),msg.length());
485 *size=msg.length();
486
487#if 0
468 char *buf; 488 char *buf;
@@ -497,2 +517,3 @@ err_close:
497 close( fd ); 517 close( fd );
518#endif
498} 519}
@@ -504,3 +525,12 @@ void SMTPwrapper::progress( size_t current, size_t maximum )
504 525
505void SMTPwrapper::smtpSend( mailmime *mail ) 526void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box)
527{
528 if (!mail) return;
529 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
530 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
531 wrap->storeMessage(mail,length,box);
532 delete wrap;
533}
534
535void SMTPwrapper::smtpSend( mailmime *mail,bool later )
506{ 536{
@@ -521,5 +551,2 @@ void SMTPwrapper::smtpSend( mailmime *mail )
521 } 551 }
522 server = strdup( smtp->getServer().latin1() );
523 ssl = smtp->getSSL();
524 port = smtp->getPort().toUInt();
525 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); 552 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
@@ -528,2 +555,3 @@ void SMTPwrapper::smtpSend( mailmime *mail )
528 writeToFile( file, mail ); 555 writeToFile( file, mail );
556
529 readFromFile( file, &data, &size ); 557 readFromFile( file, &data, &size );
@@ -531,3 +559,15 @@ void SMTPwrapper::smtpSend( mailmime *mail )
531 f.remove(); 559 f.remove();
560
561 storeMail(data,size,(later?"Outgoing":"Sent"));
532 562
563 if (later) {
564 smtp_address_list_free( rcpts );
565 if (data) free( data );
566 if (from) free(from);
567 return;
568 }
569 server = strdup( smtp->getServer().latin1() );
570 ssl = smtp->getSSL();
571 port = smtp->getPort().toUInt();
572
533 session = mailsmtp_new( 20, &progress ); 573 session = mailsmtp_new( 20, &progress );
@@ -583,4 +623,5 @@ free_mem:
583 smtp_address_list_free( rcpts ); 623 smtp_address_list_free( rcpts );
584 free( data ); 624 if (data) free( data );
585 free( server ); 625 if (from) free(from);
626 if (server) free( server );
586 if ( smtp->getLogin() ) { 627 if ( smtp->getLogin() ) {
@@ -592,5 +633,5 @@ free_mem:
592 633
593void SMTPwrapper::sendMail(const Mail&mail ) 634void SMTPwrapper::sendMail(const Mail&mail,bool later )
594{ 635{
595 mailmime *mimeMail; 636 mailmime * mimeMail;
596 637
@@ -600,3 +641,3 @@ void SMTPwrapper::sendMail(const Mail&mail )
600 } else { 641 } else {
601 smtpSend( mimeMail ); 642 smtpSend( mimeMail,later );
602 mailmime_free( mimeMail ); 643 mailmime_free( mimeMail );
diff --git a/noncore/net/mail/smtpwrapper.h b/noncore/net/mail/smtpwrapper.h
index 8fdb07d..41e9a8c 100644
--- a/noncore/net/mail/smtpwrapper.h
+++ b/noncore/net/mail/smtpwrapper.h
@@ -26,3 +26,3 @@ public:
26 virtual ~SMTPwrapper(){} 26 virtual ~SMTPwrapper(){}
27 void sendMail(const Mail& mail ); 27 void sendMail(const Mail& mail,bool later=false );
28 28
@@ -37,3 +37,3 @@ protected:
37 mailmime *buildFilePart(const QString&filename,const QString&mimetype ); 37 mailmime *buildFilePart(const QString&filename,const QString&mimetype );
38 void smtpSend( mailmime *mail ); 38 void smtpSend( mailmime *mail,bool later );
39 mailimf_field *getField( mailimf_fields *fields, int type ); 39 mailimf_field *getField( mailimf_fields *fields, int type );
@@ -44,2 +44,3 @@ protected:
44 void readFromFile(const QString&file, char **data, size_t *size ); 44 void readFromFile(const QString&file, char **data, size_t *size );
45 void storeMail(char*mail, size_t length, const QString&box);
45 46
@@ -49,2 +50,3 @@ protected:
49 static void addRcpts( clist *list, mailimf_address_list *addr_list ); 50 static void addRcpts( clist *list, mailimf_address_list *addr_list );
51 void storeMail(mailmime*mail, const QString&box);
50 Settings *settings; 52 Settings *settings;