-rw-r--r-- | noncore/net/mail/addresspicker.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/composemail.cpp | 48 | ||||
-rw-r--r-- | noncore/net/mail/composemailui.ui | 186 | ||||
-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 23 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 25 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.h | 20 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.cpp | 54 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/smtpwrapper.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/settings.cpp | 25 | ||||
-rw-r--r-- | noncore/net/mail/settings.h | 20 | ||||
-rw-r--r-- | noncore/net/mail/smtpconfigui.ui | 401 | ||||
-rw-r--r-- | noncore/net/mail/smtpwrapper.cpp | 54 | ||||
-rw-r--r-- | noncore/net/mail/smtpwrapper.h | 3 |
13 files changed, 322 insertions, 542 deletions
diff --git a/noncore/net/mail/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp index 581de62..7857870 100644 --- a/noncore/net/mail/addresspicker.cpp +++ b/noncore/net/mail/addresspicker.cpp @@ -12,49 +12,49 @@ #include <stdlib.h> #include "composemail.h" AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags ) : AddressPickerUI( parent, name, modal, flags ) { okButton->setIconSet( Resource::loadPixmap( "enter" ) ); cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); connect(okButton, SIGNAL(clicked()), SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), SLOT(close())); OContactAccess::List::Iterator it; QString lineEmail, lineName, contactLine; /* what name has to set here???? */ OContactAccess m_contactdb("addressbook"); QStringList mails; QString pre,suf; OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); for ( it = m_list.begin(); it != m_list.end(); ++it ) { if ((*it).defaultEmail().length()!=0) { mails = (*it).emailList(); if ((*it).fileAs().length()>0) { - pre = "\""+(*it).fileAs()+"\" <"; + pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <"; suf = ">"; } else { pre = ""; suf = ""; } QStringList::ConstIterator sit = mails.begin(); for (;sit!=mails.end();++sit) { contactLine=pre+(*sit)+suf; addressList->insertItem(contactLine); } } } if ( addressList->count() <= 0 ) { #if 0 // makes this realy sense?? addressList->insertItem( tr( "There are no entries in the addressbook." ) ); #endif addressList->setEnabled( false ); okButton->setEnabled( false ); } else { // addressList->sort(); } } diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index 73d1a43..13c7900 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp @@ -1,65 +1,88 @@ #include <qt.h> #include <opie/ofiledialog.h> #include <qpe/resource.h> #include <qpe/config.h> +#include <qpe/global.h> +#include <qpe/contact.h> #include "composemail.h" #include "smtpwrapper.h" ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) : ComposeMailUI( parent, name, modal, flags ) { settings = s; + QString vfilename = Global::applicationFileName("addressbook", + "businesscard.vcf"); + Contact c; + if (QFile::exists(vfilename)) { + c = Contact::readVCard( vfilename )[0]; + } + + QStringList mails = c.emailList(); + QString defmail = c.defaultEmail(); + + if (defmail.length()!=0) { + fromBox->insertItem(defmail); + } + QStringList::ConstIterator sit = mails.begin(); + for (;sit!=mails.end();++sit) { + if ( (*sit)==defmail) + continue; + fromBox->insertItem((*sit)); + } + senderNameEdit->setText(c.firstName()+" "+c.lastName()); Config cfg( "mail" ); cfg.setGroup( "Compose" ); checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); attList->addColumn( tr( "Name" ) ); attList->addColumn( tr( "Size" ) ); QList<Account> accounts = settings->getAccounts(); + Account *it; for ( it = accounts.first(); it; it = accounts.next() ) { if ( it->getType().compare( "SMTP" ) == 0 ) { SMTPaccount *smtp = static_cast<SMTPaccount *>(it); - fromBox->insertItem( smtp->getMail() ); + smtpAccountBox->insertItem( smtp->getAccountName() ); smtpAccounts.append( smtp ); } } if ( smtpAccounts.count() > 0 ) { - fillValues( fromBox->currentItem() ); + fillValues( smtpAccountBox->currentItem() ); } else { QMessageBox::information( this, tr( "Problem" ), tr( "<p>Please create an SMTP account first.</p>" ), tr( "Ok" ) ); return; } - connect( fromBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); + connect( smtpAccountBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); } void ComposeMail::pickAddress( QLineEdit *line ) { QString names = AddressPicker::getNames(); if ( line->text().isEmpty() ) { line->setText( names ); } else if ( !names.isEmpty() ) { line->setText( line->text() + ", " + names ); } } void ComposeMail::setTo( const QString & to ) { /* QString toline; QStringList toEntry = to; for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { @@ -87,129 +110,130 @@ void ComposeMail::setMessage( const QString & text ) void ComposeMail::pickAddressTo() { pickAddress( toLine ); } void ComposeMail::pickAddressCC() { pickAddress( ccLine ); } void ComposeMail::pickAddressBCC() { pickAddress( bccLine ); } void ComposeMail::pickAddressReply() { pickAddress( replyLine ); } void ComposeMail::fillValues( int current ) { +#if 0 SMTPaccount *smtp = smtpAccounts.at( current ); - ccLine->clear(); if ( smtp->getUseCC() ) { ccLine->setText( smtp->getCC() ); } bccLine->clear(); if ( smtp->getUseBCC() ) { bccLine->setText( smtp->getBCC() ); } replyLine->clear(); if ( smtp->getUseReply() ) { replyLine->setText( smtp->getReply() ); } - sigMultiLine->setText( smtp->getSignature() ); +#endif } void ComposeMail::slotAdjustColumns() { int currPage = tabWidget->currentPageIndex(); tabWidget->showPage( attachTab ); attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); attList->setColumnWidth( 1, 80 ); tabWidget->setCurrentPage( currPage ); } void ComposeMail::addAttachment() { DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); if ( !lnk.name().isEmpty() ) { Attachment *att = new Attachment( lnk ); (void) new AttachViewItem( attList, att ); } } 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( fromBox->currentItem() )->getAccountName() ); + smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); +#endif Mail *mail = new Mail(); - SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() ); - mail->setMail( smtp->getMail() ); - mail->setName( smtp->getName() ); + 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,checkBoxLater->isChecked() ); + wrapper.sendMail( *mail,smtp,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/composemailui.ui b/noncore/net/mail/composemailui.ui index 4d225e4..aebdf67 100644 --- a/noncore/net/mail/composemailui.ui +++ b/noncore/net/mail/composemailui.ui @@ -1,166 +1,308 @@ <!DOCTYPE UI><UI> <class>ComposeMailUI</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>ComposeMailUI</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>260</width> + <width>252</width> <height>360</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Compose Message</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> - <number>3</number> + <number>1</number> </property> <property stdset="1"> <name>spacing</name> - <number>3</number> + <number>1</number> </property> <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout4</cstring> + </property> + <property> + <name>layoutSpacing</name> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget row="0" column="0" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> <cstring>checkBoxLater</cstring> </property> <property stdset="1"> <name>text</name> <string>send later</string> </property> </widget> + <widget row="0" column="1" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>accountLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>use:</string> + </property> + </widget> + <widget row="0" column="2" > + <class>QComboBox</class> + <property stdset="1"> + <name>name</name> + <cstring>smtpAccountBox</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + </widget> + </grid> + </widget> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>tabWidget</cstring> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>mailTab</cstring> </property> <attribute> <name>title</name> <string>Mail</string> </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>1</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>1</number> + </property> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout10</cstring> + </property> + <property> + <name>layoutSpacing</name> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>1</number> + </property> + <widget row="0" column="1" > + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout9</cstring> + </property> + <property> + <name>layoutSpacing</name> + </property> <grid> <property stdset="1"> <name>margin</name> - <number>-1</number> + <number>0</number> </property> <property stdset="1"> <name>spacing</name> - <number>-1</number> + <number>3</number> </property> + <widget row="0" column="1" > + <class>QComboBox</class> + <property stdset="1"> + <name>name</name> + <cstring>fromBox</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>editable</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>duplicatesEnabled</name> + <bool>false</bool> + </property> + </widget> + <widget row="0" column="0" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>senderNameEdit</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>minimumSize</name> + <size> + <width>70</width> + <height>0</height> + </size> + </property> + <property stdset="1"> + <name>maximumSize</name> + <size> + <width>70</width> + <height>32767</height> + </size> + </property> + </widget> + </grid> + </widget> <widget row="2" column="1" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>subjectLine</cstring> </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> </widget> - <widget row="3" column="0" rowspan="1" colspan="2" > - <class>QMultiLineEdit</class> + <widget row="1" column="1" > + <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>message</cstring> + <cstring>toLine</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> </property> </widget> <widget row="2" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>subjectLabel</cstring> </property> <property stdset="1"> <name>text</name> <string>Subject</string> </property> </widget> <widget row="0" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>fromLabel</cstring> </property> <property stdset="1"> <name>text</name> <string>From</string> </property> </widget> - <widget row="1" column="1" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>toLine</cstring> - </property> - </widget> - <widget row="0" column="1" > - <class>QComboBox</class> - <property stdset="1"> - <name>name</name> - <cstring>fromBox</cstring> - </property> - </widget> <widget row="1" column="0" > <class>QPushButton</class> <property stdset="1"> <name>name</name> <cstring>toButton</cstring> </property> <property stdset="1"> <name>text</name> <string>To</string> </property> </widget> </grid> </widget> <widget> + <class>QMultiLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>message</cstring> + </property> + </widget> + </vbox> + </widget> + <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>optionsTab</cstring> </property> <attribute> <name>title</name> <string>Options</string> </attribute> <grid> <property stdset="1"> <name>margin</name> <number>4</number> </property> <property stdset="1"> <name>spacing</name> <number>3</number> </property> <widget row="3" column="0" > <class>QPushButton</class> <property stdset="1"> <name>name</name> <cstring>replyButton</cstring> </property> diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp index 1246037..de36e0d 100644 --- a/noncore/net/mail/editaccounts.cpp +++ b/noncore/net/mail/editaccounts.cpp @@ -334,108 +334,85 @@ void POP3config::fillValues() passLine->setText( data->getPassword() ); } void POP3config::accept() { data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); data->setSSL( sslBox->isChecked() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); QDialog::accept(); } /** * SMTPconfig */ SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) : SMTPconfigUI( parent, name, modal, flags ) { data = account; - connect( ccBox, SIGNAL( toggled( bool ) ), ccLine, SLOT( setEnabled( bool ) ) ); - connect( bccBox, SIGNAL( toggled( bool ) ), bccLine, SLOT( setEnabled( bool ) ) ); - connect( replyBox, SIGNAL( toggled( bool ) ), replyLine, SLOT( setEnabled( bool ) ) ); connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); fillValues(); connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); } void SMTPconfig::slotSSL( bool enabled ) { if ( enabled ) { portLine->setText( SMTP_SSL_PORT ); } else { portLine->setText( SMTP_PORT ); } } void SMTPconfig::fillValues() { accountLine->setText( data->getAccountName() ); serverLine->setText( data->getServer() ); portLine->setText( data->getPort() ); sslBox->setChecked( data->getSSL() ); loginBox->setChecked( data->getLogin() ); userLine->setText( data->getUser() ); passLine->setText( data->getPassword() ); - nameLine->setText( data->getName() ); - mailLine->setText( data->getMail() ); - orgLine->setText( data->getOrg() ); - ccBox->setChecked( data->getUseCC() ); - ccLine->setText( data->getCC() ); - bccBox->setChecked( data->getUseBCC() ); - bccLine->setText( data->getBCC() ); - replyBox->setChecked( data->getUseReply() ); - replyLine->setText( data->getReply() ); - sigMultiLine->setText( data->getSignature() ); } void SMTPconfig::accept() { data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); data->setSSL( sslBox->isChecked() ); data->setLogin( loginBox->isChecked() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); - data->setName( nameLine->text() ); - data->setMail( mailLine->text() ); - data->setOrg( orgLine->text() ); - data->setCC( ccLine->text() ); - data->setUseCC( ccBox->isChecked() ); - data->setBCC( bccLine->text() ); - data->setUseBCC( bccBox->isChecked() ); - data->setReply( replyLine->text() ); - data->setUseReply( replyBox->isChecked() ); - data->setSignature( sigMultiLine->text() ); QDialog::accept(); } /** * NNTPconfig */ NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) : NNTPconfigUI( parent, name, modal, flags ) { data = account; connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); fillValues(); connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); } void NNTPconfig::slotSSL( bool enabled ) { if ( enabled ) { diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index b580954..17aa1b0 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp @@ -252,119 +252,94 @@ QString POP3account::getFileName() return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; } SMTPaccount::SMTPaccount() : Account() { file = SMTPaccount::getUniqueFileName(); accountName = "New SMTP Account"; ssl = false; login = false; useCC = false; useBCC = false; useReply = false; type = "SMTP"; port = SMTP_PORT; } SMTPaccount::SMTPaccount( QString filename ) : Account() { file = filename; accountName = "New SMTP Account"; ssl = false; login = false; - useCC = false; - useBCC = false; - useReply = false; type = "SMTP"; port = SMTP_PORT; } QString SMTPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); QStringList imap = dir.entryList( "smtp-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "smtp-" + unique ) > 0 ); return unique; } void SMTPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "SMTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); - useCC = conf->readBoolEntry( "useCC" ); - useBCC = conf->readBoolEntry( "useBCC" ); - useReply = conf->readBoolEntry( "useReply" ); - name = conf->readEntry( "Name" ); - mail = conf->readEntry( "Mail" ); - org = conf->readEntry( "Org" ); - cc = conf->readEntry( "CC" ); - bcc = conf->readEntry( "BCC" ); - reply = conf->readEntry( "Reply" ); - signature = conf->readEntry( "Signature" ); - signature = signature.replace( QRegExp( "<br>" ), "\n" ); } void SMTPaccount::save() { qDebug( "saving " + getFileName() ); Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "SMTP Account" ); conf->writeEntry( "Account", accountName ); conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "Login", login ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); - conf->writeEntry( "useCC", useCC ); - conf->writeEntry( "useBCC", useBCC ); - conf->writeEntry( "useReply", useReply ); - conf->writeEntry( "Name", name ); - conf->writeEntry( "Mail", mail ); - conf->writeEntry( "Org", org ); - conf->writeEntry( "CC", cc ); - conf->writeEntry( "BCC", bcc ); - conf->writeEntry( "Reply", reply ); - conf->writeEntry( "Signature", - signature.replace( QRegExp( "\\n" ), "<br>" ) ); conf->write(); } QString SMTPaccount::getFileName() { return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; } NNTPaccount::NNTPaccount() : Account() { file = NNTPaccount::getUniqueFileName(); accountName = "New NNTP Account"; ssl = false; login = false; type = "NNTP"; port = NNTP_PORT; } NNTPaccount::NNTPaccount( QString filename ) : Account() { file = filename; diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h index 22184a5..caa5dfc 100644 --- a/noncore/net/mail/libmailwrapper/settings.h +++ b/noncore/net/mail/libmailwrapper/settings.h @@ -72,68 +72,48 @@ public: static QString getUniqueFileName(); virtual void read(); virtual void save(); virtual QString getFileName(); private: QString file; }; class SMTPaccount : public Account { public: SMTPaccount(); SMTPaccount( QString filename ); static QString getUniqueFileName(); virtual void read(); virtual void save(); virtual QString getFileName(); - void setName( QString str ) { name = str; } - QString getName() { return name; } - void setMail( QString str ) { mail = str; } - QString getMail() { return mail; } - void setOrg( QString str ) { org = str; } - QString getOrg() { return org; } - void setUseCC( bool b ) { useCC = b; } - bool getUseCC() { return useCC; } - void setCC( QString str ) { cc = str; } - QString getCC() { return cc; } - void setUseBCC( bool b ) { useBCC = b; } - bool getUseBCC() { return useBCC; } - void setBCC( QString str ) { bcc = str; } - QString getBCC() { return bcc; } - void setUseReply( bool b ) { useReply = b; } - bool getUseReply() { return useReply; } - void setReply( QString str ) { reply = str; } - QString getReply() { return reply; } - void setSignature( QString str ) { signature = str; } - QString getSignature() { return signature; } void setLogin( bool b ) { login = b; } bool getLogin() { return login; } private: QString file, name, mail, org, cc, bcc, reply, signature; bool useCC, useBCC, useReply, login; }; class NNTPaccount : public Account { public: NNTPaccount(); NNTPaccount( QString filename ); static QString getUniqueFileName(); virtual void read(); virtual void save(); virtual QString getFileName(); void setLogin( bool b ) { login = b; } bool getLogin() { return login; } diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index 521cd0a..30c0707 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp @@ -107,127 +107,127 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) } } s = addr.mid(startpos,i-startpos); if (!s.isEmpty()) { list.append(s); qDebug("Appended %s",s.latin1()); } QStringList::Iterator it; for ( it = list.begin(); it != list.end(); it++ ) { int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); if ( err != MAILIMF_NO_ERROR ) { qDebug( "Error parsing" ); qDebug( *it ); } else { qDebug( "Parse success! %s",(*it).latin1()); } } return addresses; } mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { mailimf_fields *fields; mailimf_field *xmailer; - mailimf_mailbox *sender, *fromBox; - mailimf_mailbox_list *from; - mailimf_address_list *to, *cc, *bcc, *reply; + mailimf_mailbox *sender=0,*fromBox=0; + mailimf_mailbox_list *from=0; + mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; char *subject = strdup( mail.getSubject().latin1() ); int err; sender = newMailbox( mail.getName(), mail.getMail() ); if ( sender == NULL ) goto err_free; fromBox = newMailbox( mail.getName(), mail.getMail() ); if ( fromBox == NULL ) goto err_free_sender; from = mailimf_mailbox_list_new_empty(); if ( from == NULL ) goto err_free_fromBox; err = mailimf_mailbox_list_add( from, fromBox ); if ( err != MAILIMF_NO_ERROR ) goto err_free_from; to = parseAddresses( mail.getTo() ); if ( to == NULL ) goto err_free_from; cc = parseAddresses( mail.getCC() ); bcc = parseAddresses( mail.getBCC() ); reply = parseAddresses( mail.getReply() ); fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, NULL, NULL, subject ); if ( fields == NULL ) goto err_free_reply; xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), strdup( USER_AGENT ) ); if ( xmailer == NULL ) goto err_free_fields; err = mailimf_fields_add( fields, xmailer ); if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; return fields; // Success :) err_free_xmailer: - mailimf_field_free( xmailer ); + if (xmailer) mailimf_field_free( xmailer ); err_free_fields: - mailimf_fields_free( fields ); + if (fields) mailimf_fields_free( fields ); err_free_reply: - mailimf_address_list_free( reply ); - mailimf_address_list_free( bcc ); - mailimf_address_list_free( cc ); - mailimf_address_list_free( to ); + if (reply) mailimf_address_list_free( reply ); + if (bcc) mailimf_address_list_free( bcc ); + if (cc) mailimf_address_list_free( cc ); + if (to) mailimf_address_list_free( to ); err_free_from: - mailimf_mailbox_list_free( from ); + if (from) mailimf_mailbox_list_free( from ); err_free_fromBox: mailimf_mailbox_free( fromBox ); err_free_sender: - mailimf_mailbox_free( sender ); + if (sender) mailimf_mailbox_free( sender ); err_free: - free( subject ); + if (subject) free( subject ); qDebug( "createImfFields - error" ); return NULL; // Error :( } mailmime *SMTPwrapper::buildTxtPart(const QString&str ) { mailmime *txtPart; mailmime_fields *fields; mailmime_content *content; mailmime_parameter *param; int err; param = mailmime_parameter_new( strdup( "charset" ), strdup( "iso-8859-1" ) ); if ( param == NULL ) goto err_free; content = mailmime_content_new_with_str( "text/plain" ); if ( content == NULL ) goto err_free_param; err = clist_append( content->ct_parameters, param ); if ( err != MAILIMF_NO_ERROR ) goto err_free_content; - fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_QUOTED_PRINTABLE); + fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); if ( fields == NULL ) goto err_free_content; txtPart = mailmime_new_empty( content, fields ); if ( txtPart == NULL ) goto err_free_fields; err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; return txtPart; // Success :) err_free_txtPart: mailmime_free( txtPart ); err_free_fields: mailmime_fields_free( fields ); err_free_content: mailmime_content_free( content ); err_free_param: mailmime_parameter_free( param ); err_free: qDebug( "buildTxtPart - error" ); return NULL; // Error :( } @@ -441,68 +441,48 @@ clist *SMTPwrapper::createRcptList( mailimf_fields *fields ) 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); } -SMTPaccount *SMTPwrapper::getAccount(const QString&name ) -{ - SMTPaccount *smtp; - - QList<Account> list = settings->getAccounts(); - Account *it; - for ( it = list.first(); it; it = list.next() ) { - if ( it->getType().compare( "SMTP" ) == 0 ) { - smtp = static_cast<SMTPaccount *>(it); - if ( smtp->getName()== name ) { - qDebug( "SMTPaccount found for" ); - qDebug( name ); - return smtp; - } - } - } - - return NULL; -} - void SMTPwrapper::progress( size_t current, size_t maximum ) { if (SMTPwrapper::sendProgress) { SMTPwrapper::sendProgress->setSingleMail(current, maximum ); qApp->processEvents(); } } void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) { if (!mail) return; QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); MBOXwrapper*wrap = new MBOXwrapper(localfolders); wrap->storeMessage(mail,length,box); delete wrap; } void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) { clist *rcpts = 0; char *from, *data; size_t size; if ( smtp == NULL ) { @@ -592,54 +572,58 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou } err = mailsmtp_send( session, from, rcpts, data, size ); if ( err != MAILSMTP_NO_ERROR ) { qDebug("Error sending mail: %s",mailsmtpError(err).latin1()); result = 0; goto free_con_session; } qDebug( "Mail sent." ); storeMail(data,size,"Sent"); free_con_session: mailsmtp_quit( session ); free_mem_session: mailsmtp_free( session ); free_mem: if (server) free( server ); if ( smtp->getLogin() ) { free( user ); free( pass ); } return result; } -void SMTPwrapper::sendMail(const Mail&mail,bool later ) +void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) { mailmime * mimeMail; - SMTPaccount *smtp = getAccount(mail.getName()); + 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); qDebug("Clean up done"); sendProgress->hide(); delete sendProgress; sendProgress = 0; mailmime_free( mimeMail ); } } int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) { char*data = 0; size_t length = 0; size_t curTok = 0; mailimf_fields *fields = 0; mailimf_field*ffrom = 0; clist *rcpts = 0; diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h index f734fa4..0535983 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.h +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h @@ -6,57 +6,56 @@ #include <qbitarray.h> #include <qdatetime.h> #include <libetpan/clist.h> #include "settings.h" class Mail; class MBOXwrapper; class RecMail; class Attachment; struct mailimf_fields; struct mailimf_field; struct mailimf_mailbox; struct mailmime; struct mailimf_address_list; class progressMailSend; class SMTPwrapper : public QObject { Q_OBJECT public: SMTPwrapper( Settings *s ); virtual ~SMTPwrapper(){} - void sendMail(const Mail& mail,bool later=false ); + void sendMail(const Mail& mail,SMTPaccount*smtp,bool later=false ); bool flushOutbox(SMTPaccount*smtp); static progressMailSend*sendProgress; protected: 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 ); clist *createRcptList( mailimf_fields *fields ); - SMTPaccount *getAccount(const QString&from ); static void storeMail(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 ); int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); void storeMail(mailmime*mail, const QString&box); Settings *settings; int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); }; #endif diff --git a/noncore/net/mail/settings.cpp b/noncore/net/mail/settings.cpp index b580954..17aa1b0 100644 --- a/noncore/net/mail/settings.cpp +++ b/noncore/net/mail/settings.cpp @@ -252,119 +252,94 @@ QString POP3account::getFileName() return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; } SMTPaccount::SMTPaccount() : Account() { file = SMTPaccount::getUniqueFileName(); accountName = "New SMTP Account"; ssl = false; login = false; useCC = false; useBCC = false; useReply = false; type = "SMTP"; port = SMTP_PORT; } SMTPaccount::SMTPaccount( QString filename ) : Account() { file = filename; accountName = "New SMTP Account"; ssl = false; login = false; - useCC = false; - useBCC = false; - useReply = false; type = "SMTP"; port = SMTP_PORT; } QString SMTPaccount::getUniqueFileName() { int num = 0; QString unique; QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); QStringList imap = dir.entryList( "smtp-*" ); do { unique.setNum( num++ ); } while ( imap.contains( "smtp-" + unique ) > 0 ); return unique; } void SMTPaccount::read() { Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "SMTP Account" ); accountName = conf->readEntry( "Account" ); server = conf->readEntry( "Server" ); port = conf->readEntry( "Port" ); ssl = conf->readBoolEntry( "SSL" ); login = conf->readBoolEntry( "Login" ); user = conf->readEntry( "User" ); password = conf->readEntryCrypt( "Password" ); - useCC = conf->readBoolEntry( "useCC" ); - useBCC = conf->readBoolEntry( "useBCC" ); - useReply = conf->readBoolEntry( "useReply" ); - name = conf->readEntry( "Name" ); - mail = conf->readEntry( "Mail" ); - org = conf->readEntry( "Org" ); - cc = conf->readEntry( "CC" ); - bcc = conf->readEntry( "BCC" ); - reply = conf->readEntry( "Reply" ); - signature = conf->readEntry( "Signature" ); - signature = signature.replace( QRegExp( "<br>" ), "\n" ); } void SMTPaccount::save() { qDebug( "saving " + getFileName() ); Settings::checkDirectory(); Config *conf = new Config( getFileName(), Config::File ); conf->setGroup( "SMTP Account" ); conf->writeEntry( "Account", accountName ); conf->writeEntry( "Server", server ); conf->writeEntry( "Port", port ); conf->writeEntry( "SSL", ssl ); conf->writeEntry( "Login", login ); conf->writeEntry( "User", user ); conf->writeEntryCrypt( "Password", password ); - conf->writeEntry( "useCC", useCC ); - conf->writeEntry( "useBCC", useBCC ); - conf->writeEntry( "useReply", useReply ); - conf->writeEntry( "Name", name ); - conf->writeEntry( "Mail", mail ); - conf->writeEntry( "Org", org ); - conf->writeEntry( "CC", cc ); - conf->writeEntry( "BCC", bcc ); - conf->writeEntry( "Reply", reply ); - conf->writeEntry( "Signature", - signature.replace( QRegExp( "\\n" ), "<br>" ) ); conf->write(); } QString SMTPaccount::getFileName() { return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; } NNTPaccount::NNTPaccount() : Account() { file = NNTPaccount::getUniqueFileName(); accountName = "New NNTP Account"; ssl = false; login = false; type = "NNTP"; port = NNTP_PORT; } NNTPaccount::NNTPaccount( QString filename ) : Account() { file = filename; diff --git a/noncore/net/mail/settings.h b/noncore/net/mail/settings.h index 22184a5..caa5dfc 100644 --- a/noncore/net/mail/settings.h +++ b/noncore/net/mail/settings.h @@ -72,68 +72,48 @@ public: static QString getUniqueFileName(); virtual void read(); virtual void save(); virtual QString getFileName(); private: QString file; }; class SMTPaccount : public Account { public: SMTPaccount(); SMTPaccount( QString filename ); static QString getUniqueFileName(); virtual void read(); virtual void save(); virtual QString getFileName(); - void setName( QString str ) { name = str; } - QString getName() { return name; } - void setMail( QString str ) { mail = str; } - QString getMail() { return mail; } - void setOrg( QString str ) { org = str; } - QString getOrg() { return org; } - void setUseCC( bool b ) { useCC = b; } - bool getUseCC() { return useCC; } - void setCC( QString str ) { cc = str; } - QString getCC() { return cc; } - void setUseBCC( bool b ) { useBCC = b; } - bool getUseBCC() { return useBCC; } - void setBCC( QString str ) { bcc = str; } - QString getBCC() { return bcc; } - void setUseReply( bool b ) { useReply = b; } - bool getUseReply() { return useReply; } - void setReply( QString str ) { reply = str; } - QString getReply() { return reply; } - void setSignature( QString str ) { signature = str; } - QString getSignature() { return signature; } void setLogin( bool b ) { login = b; } bool getLogin() { return login; } private: QString file, name, mail, org, cc, bcc, reply, signature; bool useCC, useBCC, useReply, login; }; class NNTPaccount : public Account { public: NNTPaccount(); NNTPaccount( QString filename ); static QString getUniqueFileName(); virtual void read(); virtual void save(); virtual QString getFileName(); void setLogin( bool b ) { login = b; } bool getLogin() { return login; } diff --git a/noncore/net/mail/smtpconfigui.ui b/noncore/net/mail/smtpconfigui.ui index 2cae8d6..f5ce8cb 100644 --- a/noncore/net/mail/smtpconfigui.ui +++ b/noncore/net/mail/smtpconfigui.ui @@ -1,500 +1,261 @@ <!DOCTYPE UI><UI> <class>SMTPconfigUI</class> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>SMTPconfigUI</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>253</width> - <height>342</height> + <width>241</width> + <height>321</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Configure SMTP</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> - <number>0</number> + <number>2</number> </property> <property stdset="1"> <name>spacing</name> - <number>0</number> + <number>2</number> </property> <widget> - <class>QTabWidget</class> + <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>smtpTab</cstring> - </property> - <property stdset="1"> - <name>caption</name> - <string></string> - </property> - <property> - <name>layoutMargin</name> + <cstring>Layout4</cstring> </property> <property> <name>layoutSpacing</name> </property> - <widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>serverTab</cstring> - </property> - <attribute> - <name>title</name> - <string>Server</string> - </attribute> <grid> <property stdset="1"> <name>margin</name> - <number>4</number> + <number>0</number> </property> <property stdset="1"> <name>spacing</name> - <number>3</number> + <number>2</number> </property> - <widget row="3" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>portLabel</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Port</string> - </property> - </widget> - <widget row="2" column="1" rowspan="1" colspan="2" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>serverLine</cstring> - </property> - <property> - <name>toolTip</name> - <string>Name of the SMTP Server</string> - </property> - </widget> - <widget row="2" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>serverLabel</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Server</string> - </property> - </widget> - <widget row="3" column="1" rowspan="1" colspan="2" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>portLine</cstring> - </property> - <property> - <name>toolTip</name> - <string>Port of the SMTP Server</string> - </property> - </widget> - <widget row="0" column="0" > + <widget row="0" column="0" rowspan="1" colspan="2" > <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>accountLabel</cstring> </property> <property stdset="1"> <name>text</name> <string>Account</string> </property> </widget> - <widget row="0" column="1" rowspan="1" colspan="2" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>accountLine</cstring> - </property> - <property> - <name>toolTip</name> - <string>Name of the Account</string> - </property> - </widget> - <widget row="1" column="0" rowspan="1" colspan="3" > - <class>Line</class> - <property stdset="1"> - <name>name</name> - <cstring>line1</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - </widget> - <widget row="4" column="1" > - <class>QCheckBox</class> - <property stdset="1"> - <name>name</name> - <cstring>sslBox</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Use SSL</string> - </property> - </widget> - <widget row="5" column="0" rowspan="1" colspan="3" > - <class>Line</class> - <property stdset="1"> - <name>name</name> - <cstring>line2</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - </widget> - <widget row="8" column="1" rowspan="1" colspan="2" > + <widget row="8" column="2" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>passLine</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> <property stdset="1"> <name>echoMode</name> <enum>Password</enum> </property> </widget> - <widget row="6" column="1" rowspan="1" colspan="2" > + <widget row="4" column="0" rowspan="1" colspan="3" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>loginBox</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Use Login</string> - </property> - </widget> - <widget row="8" column="0" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>passLabel</cstring> + <cstring>sslBox</cstring> </property> <property stdset="1"> <name>text</name> - <string>Password</string> + <string>Use SSL</string> </property> </widget> - <widget row="7" column="0" > - <class>QLabel</class> + <widget row="6" column="0" rowspan="1" colspan="3" > + <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>userLabel</cstring> + <cstring>loginBox</cstring> </property> <property stdset="1"> <name>text</name> - <string>User</string> + <string>Use Login</string> </property> </widget> - <widget row="7" column="1" rowspan="1" colspan="2" > + <widget row="0" column="2" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>userLine</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> - </property> - </widget> - <spacer row="9" column="2" > - <property> - <name>name</name> - <cstring>spacer</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Vertical</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </grid> - </widget> - <widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>identityTab</cstring> - </property> - <attribute> - <name>title</name> - <string>Identity</string> - </attribute> - <grid> - <property stdset="1"> - <name>margin</name> - <number>4</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>3</number> - </property> - <widget row="9" column="0" rowspan="1" colspan="4" > - <class>QMultiLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>sigMultiLine</cstring> - </property> - </widget> - <spacer row="10" column="3" > - <property> - <name>name</name> - <cstring>Spacer3</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Vertical</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> + <cstring>accountLine</cstring> </property> <property> <name>toolTip</name> <string>Name of the Account</string> </property> - </spacer> - <widget row="8" column="0" rowspan="1" colspan="3" > - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>sigLabel</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Signature</string> - </property> - </widget> - <widget row="6" column="2" rowspan="1" colspan="2" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>replyLine</cstring> - </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> - </property> </widget> - <widget row="5" column="2" rowspan="1" colspan="2" > + <widget row="2" column="1" rowspan="1" colspan="2" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>bccLine</cstring> + <cstring>serverLine</cstring> </property> - <property stdset="1"> - <name>enabled</name> - <bool>false</bool> + <property> + <name>toolTip</name> + <string>Name of the SMTP Server</string> </property> </widget> - <widget row="4" column="2" rowspan="1" colspan="2" > + <widget row="7" column="2" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>ccLine</cstring> + <cstring>userLine</cstring> </property> <property stdset="1"> <name>enabled</name> <bool>false</bool> </property> </widget> - <widget row="5" column="0" rowspan="1" colspan="2" > - <class>QCheckBox</class> - <property stdset="1"> - <name>name</name> - <cstring>bccBox</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>BCC</string> - </property> - </widget> - <widget row="6" column="0" rowspan="1" colspan="2" > - <class>QCheckBox</class> + <widget row="8" column="0" rowspan="1" colspan="2" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>replyBox</cstring> + <cstring>passLabel</cstring> </property> <property stdset="1"> <name>text</name> - <string>Reply-To</string> + <string>Password</string> </property> </widget> - <widget row="4" column="0" rowspan="1" colspan="2" > - <class>QCheckBox</class> + <widget row="3" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>ccBox</cstring> + <cstring>portLabel</cstring> </property> <property stdset="1"> <name>text</name> - <string>CC</string> + <string>Port</string> </property> </widget> - <widget row="1" column="0" > + <widget row="2" column="0" > <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>mailLabel</cstring> + <cstring>serverLabel</cstring> </property> <property stdset="1"> <name>text</name> - <string>E-Mail</string> + <string>Server</string> </property> </widget> - <widget row="0" column="1" rowspan="1" colspan="3" > + <widget row="3" column="1" rowspan="1" colspan="2" > <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>nameLine</cstring> + <cstring>portLine</cstring> </property> <property> <name>toolTip</name> - <string>Your Full Name</string> + <string>Port of the SMTP Server</string> </property> </widget> - <widget row="0" column="0" > - <class>QLabel</class> + <widget row="1" column="0" rowspan="1" colspan="3" > + <class>Line</class> <property stdset="1"> <name>name</name> - <cstring>nameLabel</cstring> + <cstring>line1</cstring> </property> <property stdset="1"> - <name>text</name> - <string>Name</string> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> </property> </widget> - <widget row="2" column="0" > + <widget row="7" column="0" rowspan="1" colspan="2" > <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>orgLabel</cstring> + <cstring>userLabel</cstring> </property> <property stdset="1"> <name>text</name> - <string>Org.</string> - </property> - <property> - <name>layoutMargin</name> - </property> - <property> - <name>layoutSpacing</name> - </property> - </widget> - <widget row="2" column="1" rowspan="1" colspan="3" > - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>orgLine</cstring> - </property> - <property> - <name>toolTip</name> - <string>Your Organisation</string> + <string>User</string> </property> </widget> - <widget row="1" column="1" rowspan="1" colspan="3" > - <class>QLineEdit</class> + <widget row="5" column="0" rowspan="1" colspan="3" > + <class>Line</class> <property stdset="1"> <name>name</name> - <cstring>mailLine</cstring> - </property> - <property> - <name>toolTip</name> - <string>Your E-Mail Adress</string> + <cstring>line2</cstring> </property> - </widget> - <widget row="3" column="0" rowspan="1" colspan="4" > - <class>Line</class> <property stdset="1"> - <name>name</name> - <cstring>line3</cstring> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> </widget> - <widget row="7" column="0" rowspan="1" colspan="4" > - <class>Line</class> - <property stdset="1"> + </grid> + </widget> + <spacer> + <property> <name>name</name> - <cstring>line4</cstring> + <cstring>spacer</cstring> </property> <property stdset="1"> <name>orientation</name> - <enum>Horizontal</enum> + <enum>Vertical</enum> </property> - </widget> - </grid> - </widget> - </widget> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> </vbox> </widget> <tabstops> <tabstop>accountLine</tabstop> <tabstop>serverLine</tabstop> <tabstop>portLine</tabstop> <tabstop>sslBox</tabstop> <tabstop>loginBox</tabstop> <tabstop>userLine</tabstop> <tabstop>passLine</tabstop> - <tabstop>smtpTab</tabstop> - <tabstop>nameLine</tabstop> - <tabstop>mailLine</tabstop> - <tabstop>orgLine</tabstop> - <tabstop>ccBox</tabstop> - <tabstop>ccLine</tabstop> - <tabstop>bccBox</tabstop> - <tabstop>bccLine</tabstop> - <tabstop>replyBox</tabstop> - <tabstop>replyLine</tabstop> - <tabstop>sigMultiLine</tabstop> </tabstops> </UI> diff --git a/noncore/net/mail/smtpwrapper.cpp b/noncore/net/mail/smtpwrapper.cpp index 521cd0a..30c0707 100644 --- a/noncore/net/mail/smtpwrapper.cpp +++ b/noncore/net/mail/smtpwrapper.cpp @@ -107,127 +107,127 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) } } s = addr.mid(startpos,i-startpos); if (!s.isEmpty()) { list.append(s); qDebug("Appended %s",s.latin1()); } QStringList::Iterator it; for ( it = list.begin(); it != list.end(); it++ ) { int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); if ( err != MAILIMF_NO_ERROR ) { qDebug( "Error parsing" ); qDebug( *it ); } else { qDebug( "Parse success! %s",(*it).latin1()); } } return addresses; } mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { mailimf_fields *fields; mailimf_field *xmailer; - mailimf_mailbox *sender, *fromBox; - mailimf_mailbox_list *from; - mailimf_address_list *to, *cc, *bcc, *reply; + mailimf_mailbox *sender=0,*fromBox=0; + mailimf_mailbox_list *from=0; + mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; char *subject = strdup( mail.getSubject().latin1() ); int err; sender = newMailbox( mail.getName(), mail.getMail() ); if ( sender == NULL ) goto err_free; fromBox = newMailbox( mail.getName(), mail.getMail() ); if ( fromBox == NULL ) goto err_free_sender; from = mailimf_mailbox_list_new_empty(); if ( from == NULL ) goto err_free_fromBox; err = mailimf_mailbox_list_add( from, fromBox ); if ( err != MAILIMF_NO_ERROR ) goto err_free_from; to = parseAddresses( mail.getTo() ); if ( to == NULL ) goto err_free_from; cc = parseAddresses( mail.getCC() ); bcc = parseAddresses( mail.getBCC() ); reply = parseAddresses( mail.getReply() ); fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, NULL, NULL, subject ); if ( fields == NULL ) goto err_free_reply; xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), strdup( USER_AGENT ) ); if ( xmailer == NULL ) goto err_free_fields; err = mailimf_fields_add( fields, xmailer ); if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; return fields; // Success :) err_free_xmailer: - mailimf_field_free( xmailer ); + if (xmailer) mailimf_field_free( xmailer ); err_free_fields: - mailimf_fields_free( fields ); + if (fields) mailimf_fields_free( fields ); err_free_reply: - mailimf_address_list_free( reply ); - mailimf_address_list_free( bcc ); - mailimf_address_list_free( cc ); - mailimf_address_list_free( to ); + if (reply) mailimf_address_list_free( reply ); + if (bcc) mailimf_address_list_free( bcc ); + if (cc) mailimf_address_list_free( cc ); + if (to) mailimf_address_list_free( to ); err_free_from: - mailimf_mailbox_list_free( from ); + if (from) mailimf_mailbox_list_free( from ); err_free_fromBox: mailimf_mailbox_free( fromBox ); err_free_sender: - mailimf_mailbox_free( sender ); + if (sender) mailimf_mailbox_free( sender ); err_free: - free( subject ); + if (subject) free( subject ); qDebug( "createImfFields - error" ); return NULL; // Error :( } mailmime *SMTPwrapper::buildTxtPart(const QString&str ) { mailmime *txtPart; mailmime_fields *fields; mailmime_content *content; mailmime_parameter *param; int err; param = mailmime_parameter_new( strdup( "charset" ), strdup( "iso-8859-1" ) ); if ( param == NULL ) goto err_free; content = mailmime_content_new_with_str( "text/plain" ); if ( content == NULL ) goto err_free_param; err = clist_append( content->ct_parameters, param ); if ( err != MAILIMF_NO_ERROR ) goto err_free_content; - fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_QUOTED_PRINTABLE); + fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); if ( fields == NULL ) goto err_free_content; txtPart = mailmime_new_empty( content, fields ); if ( txtPart == NULL ) goto err_free_fields; err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; return txtPart; // Success :) err_free_txtPart: mailmime_free( txtPart ); err_free_fields: mailmime_fields_free( fields ); err_free_content: mailmime_content_free( content ); err_free_param: mailmime_parameter_free( param ); err_free: qDebug( "buildTxtPart - error" ); return NULL; // Error :( } @@ -441,68 +441,48 @@ clist *SMTPwrapper::createRcptList( mailimf_fields *fields ) 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); } -SMTPaccount *SMTPwrapper::getAccount(const QString&name ) -{ - SMTPaccount *smtp; - - QList<Account> list = settings->getAccounts(); - Account *it; - for ( it = list.first(); it; it = list.next() ) { - if ( it->getType().compare( "SMTP" ) == 0 ) { - smtp = static_cast<SMTPaccount *>(it); - if ( smtp->getName()== name ) { - qDebug( "SMTPaccount found for" ); - qDebug( name ); - return smtp; - } - } - } - - return NULL; -} - void SMTPwrapper::progress( size_t current, size_t maximum ) { if (SMTPwrapper::sendProgress) { SMTPwrapper::sendProgress->setSingleMail(current, maximum ); qApp->processEvents(); } } void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) { if (!mail) return; QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); MBOXwrapper*wrap = new MBOXwrapper(localfolders); wrap->storeMessage(mail,length,box); delete wrap; } void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) { clist *rcpts = 0; char *from, *data; size_t size; if ( smtp == NULL ) { @@ -592,54 +572,58 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou } err = mailsmtp_send( session, from, rcpts, data, size ); if ( err != MAILSMTP_NO_ERROR ) { qDebug("Error sending mail: %s",mailsmtpError(err).latin1()); result = 0; goto free_con_session; } qDebug( "Mail sent." ); storeMail(data,size,"Sent"); free_con_session: mailsmtp_quit( session ); free_mem_session: mailsmtp_free( session ); free_mem: if (server) free( server ); if ( smtp->getLogin() ) { free( user ); free( pass ); } return result; } -void SMTPwrapper::sendMail(const Mail&mail,bool later ) +void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later ) { mailmime * mimeMail; - SMTPaccount *smtp = getAccount(mail.getName()); + 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); qDebug("Clean up done"); sendProgress->hide(); delete sendProgress; sendProgress = 0; mailmime_free( mimeMail ); } } int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) { char*data = 0; size_t length = 0; size_t curTok = 0; mailimf_fields *fields = 0; mailimf_field*ffrom = 0; clist *rcpts = 0; diff --git a/noncore/net/mail/smtpwrapper.h b/noncore/net/mail/smtpwrapper.h index f734fa4..0535983 100644 --- a/noncore/net/mail/smtpwrapper.h +++ b/noncore/net/mail/smtpwrapper.h @@ -6,57 +6,56 @@ #include <qbitarray.h> #include <qdatetime.h> #include <libetpan/clist.h> #include "settings.h" class Mail; class MBOXwrapper; class RecMail; class Attachment; struct mailimf_fields; struct mailimf_field; struct mailimf_mailbox; struct mailmime; struct mailimf_address_list; class progressMailSend; class SMTPwrapper : public QObject { Q_OBJECT public: SMTPwrapper( Settings *s ); virtual ~SMTPwrapper(){} - void sendMail(const Mail& mail,bool later=false ); + void sendMail(const Mail& mail,SMTPaccount*smtp,bool later=false ); bool flushOutbox(SMTPaccount*smtp); static progressMailSend*sendProgress; protected: 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 ); clist *createRcptList( mailimf_fields *fields ); - SMTPaccount *getAccount(const QString&from ); static void storeMail(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 ); int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); void storeMail(mailmime*mail, const QString&box); Settings *settings; int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); }; #endif |