summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/addresspicker.cpp2
-rw-r--r--noncore/net/mail/composemail.cpp50
-rw-r--r--noncore/net/mail/composemailui.ui268
-rw-r--r--noncore/net/mail/editaccounts.cpp23
-rw-r--r--noncore/net/mail/libmailwrapper/settings.cpp25
-rw-r--r--noncore/net/mail/libmailwrapper/settings.h20
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp54
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h3
-rw-r--r--noncore/net/mail/settings.cpp25
-rw-r--r--noncore/net/mail/settings.h20
-rw-r--r--noncore/net/mail/smtpconfigui.ui637
-rw-r--r--noncore/net/mail/smtpwrapper.cpp54
-rw-r--r--noncore/net/mail/smtpwrapper.h3
13 files changed, 482 insertions, 702 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
@@ -1,99 +1,99 @@
1#include <qpushbutton.h> 1#include <qpushbutton.h>
2#include <qmessagebox.h> 2#include <qmessagebox.h>
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <qlistbox.h> 4#include <qlistbox.h>
5#include <qfile.h> 5#include <qfile.h>
6 6
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8#include <opie/ocontactaccess.h> 8#include <opie/ocontactaccess.h>
9#include <opie/ocontact.h> 9#include <opie/ocontact.h>
10 10
11 11
12#include <stdlib.h> 12#include <stdlib.h>
13 13
14#include "composemail.h" 14#include "composemail.h"
15 15
16AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags ) 16AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags )
17 : AddressPickerUI( parent, name, modal, flags ) 17 : AddressPickerUI( parent, name, modal, flags )
18{ 18{
19 okButton->setIconSet( Resource::loadPixmap( "enter" ) ); 19 okButton->setIconSet( Resource::loadPixmap( "enter" ) );
20 cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); 20 cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) );
21 21
22 connect(okButton, SIGNAL(clicked()), SLOT(accept())); 22 connect(okButton, SIGNAL(clicked()), SLOT(accept()));
23 connect(cancelButton, SIGNAL(clicked()), SLOT(close())); 23 connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
24 OContactAccess::List::Iterator it; 24 OContactAccess::List::Iterator it;
25 25
26 QString lineEmail, lineName, contactLine; 26 QString lineEmail, lineName, contactLine;
27 /* what name has to set here???? */ 27 /* what name has to set here???? */
28 OContactAccess m_contactdb("addressbook"); 28 OContactAccess m_contactdb("addressbook");
29 QStringList mails; 29 QStringList mails;
30 QString pre,suf; 30 QString pre,suf;
31 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); 31 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
32 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 32 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
33 if ((*it).defaultEmail().length()!=0) { 33 if ((*it).defaultEmail().length()!=0) {
34 mails = (*it).emailList(); 34 mails = (*it).emailList();
35 if ((*it).fileAs().length()>0) { 35 if ((*it).fileAs().length()>0) {
36 pre = "\""+(*it).fileAs()+"\" <"; 36 pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <";
37 suf = ">"; 37 suf = ">";
38 } else { 38 } else {
39 pre = ""; 39 pre = "";
40 suf = ""; 40 suf = "";
41 } 41 }
42 QStringList::ConstIterator sit = mails.begin(); 42 QStringList::ConstIterator sit = mails.begin();
43 for (;sit!=mails.end();++sit) { 43 for (;sit!=mails.end();++sit) {
44 contactLine=pre+(*sit)+suf; 44 contactLine=pre+(*sit)+suf;
45 addressList->insertItem(contactLine); 45 addressList->insertItem(contactLine);
46 } 46 }
47 } 47 }
48 } 48 }
49 if ( addressList->count() <= 0 ) { 49 if ( addressList->count() <= 0 ) {
50#if 0 50#if 0
51 // makes this realy sense?? 51 // makes this realy sense??
52 addressList->insertItem( 52 addressList->insertItem(
53 tr( "There are no entries in the addressbook." ) ); 53 tr( "There are no entries in the addressbook." ) );
54#endif 54#endif
55 addressList->setEnabled( false ); 55 addressList->setEnabled( false );
56 okButton->setEnabled( false ); 56 okButton->setEnabled( false );
57 } else { 57 } else {
58// addressList->sort(); 58// addressList->sort();
59 } 59 }
60} 60}
61 61
62void AddressPicker::accept() 62void AddressPicker::accept()
63{ 63{
64 QListBoxItem *item = addressList->firstItem(); 64 QListBoxItem *item = addressList->firstItem();
65 QString names; 65 QString names;
66 66
67 while ( item ) { 67 while ( item ) {
68 if ( item->selected() ) 68 if ( item->selected() )
69 names += item->text() + ", "; 69 names += item->text() + ", ";
70 item = item->next(); 70 item = item->next();
71 } 71 }
72 names.replace( names.length() - 2, 2, "" ); 72 names.replace( names.length() - 2, 2, "" );
73 73
74 if ( names.isEmpty() ) { 74 if ( names.isEmpty() ) {
75 QMessageBox::information(this, tr("Error"), tr("<p>You have to select" 75 QMessageBox::information(this, tr("Error"), tr("<p>You have to select"
76 " at least one address entry.</p>"), tr("Ok")); 76 " at least one address entry.</p>"), tr("Ok"));
77 return; 77 return;
78 } 78 }
79 79
80 selectedNames = names; 80 selectedNames = names;
81 QDialog::accept(); 81 QDialog::accept();
82} 82}
83 83
84QString AddressPicker::getNames() 84QString AddressPicker::getNames()
85{ 85{
86 QString names = 0; 86 QString names = 0;
87 87
88 AddressPicker picker(0, 0, true); 88 AddressPicker picker(0, 0, true);
89 picker.showMaximized(); 89 picker.showMaximized();
90 picker.show(); 90 picker.show();
91 91
92 int ret = picker.exec(); 92 int ret = picker.exec();
93 if ( QDialog::Accepted == ret ) { 93 if ( QDialog::Accepted == ret ) {
94 return picker.selectedNames; 94 return picker.selectedNames;
95 } 95 }
96 96
97 return 0; 97 return 0;
98} 98}
99 99
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,215 +1,239 @@
1#include <qt.h> 1#include <qt.h>
2 2
3#include <opie/ofiledialog.h> 3#include <opie/ofiledialog.h>
4#include <qpe/resource.h> 4#include <qpe/resource.h>
5#include <qpe/config.h> 5#include <qpe/config.h>
6#include <qpe/global.h>
7#include <qpe/contact.h>
6 8
7#include "composemail.h" 9#include "composemail.h"
8#include "smtpwrapper.h" 10#include "smtpwrapper.h"
9 11
10ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 12ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
11 : ComposeMailUI( parent, name, modal, flags ) 13 : ComposeMailUI( parent, name, modal, flags )
12{ 14{
13 settings = s; 15 settings = s;
14 16
17 QString vfilename = Global::applicationFileName("addressbook",
18 "businesscard.vcf");
19 Contact c;
20 if (QFile::exists(vfilename)) {
21 c = Contact::readVCard( vfilename )[0];
22 }
23
24 QStringList mails = c.emailList();
25 QString defmail = c.defaultEmail();
26
27 if (defmail.length()!=0) {
28 fromBox->insertItem(defmail);
29 }
30 QStringList::ConstIterator sit = mails.begin();
31 for (;sit!=mails.end();++sit) {
32 if ( (*sit)==defmail)
33 continue;
34 fromBox->insertItem((*sit));
35 }
36 senderNameEdit->setText(c.firstName()+" "+c.lastName());
15 Config cfg( "mail" ); 37 Config cfg( "mail" );
16 cfg.setGroup( "Compose" ); 38 cfg.setGroup( "Compose" );
17 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); 39 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) );
18 40
19 attList->addColumn( tr( "Name" ) ); 41 attList->addColumn( tr( "Name" ) );
20 attList->addColumn( tr( "Size" ) ); 42 attList->addColumn( tr( "Size" ) );
21 43
22 QList<Account> accounts = settings->getAccounts(); 44 QList<Account> accounts = settings->getAccounts();
45
23 Account *it; 46 Account *it;
24 for ( it = accounts.first(); it; it = accounts.next() ) { 47 for ( it = accounts.first(); it; it = accounts.next() ) {
25 if ( it->getType().compare( "SMTP" ) == 0 ) { 48 if ( it->getType().compare( "SMTP" ) == 0 ) {
26 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 49 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
27 fromBox->insertItem( smtp->getMail() ); 50 smtpAccountBox->insertItem( smtp->getAccountName() );
28 smtpAccounts.append( smtp ); 51 smtpAccounts.append( smtp );
29 } 52 }
30 } 53 }
31 54
32 if ( smtpAccounts.count() > 0 ) { 55 if ( smtpAccounts.count() > 0 ) {
33 fillValues( fromBox->currentItem() ); 56 fillValues( smtpAccountBox->currentItem() );
34 } else { 57 } else {
35 QMessageBox::information( this, tr( "Problem" ), 58 QMessageBox::information( this, tr( "Problem" ),
36 tr( "<p>Please create an SMTP account first.</p>" ), 59 tr( "<p>Please create an SMTP account first.</p>" ),
37 tr( "Ok" ) ); 60 tr( "Ok" ) );
38 return; 61 return;
39 } 62 }
40 63
41 connect( fromBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); 64 connect( smtpAccountBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) );
42 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 65 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
43 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 66 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
44 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 67 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
45 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 68 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
46 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 69 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
47 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 70 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
48} 71}
49 72
50void ComposeMail::pickAddress( QLineEdit *line ) 73void ComposeMail::pickAddress( QLineEdit *line )
51{ 74{
52 QString names = AddressPicker::getNames(); 75 QString names = AddressPicker::getNames();
53 if ( line->text().isEmpty() ) { 76 if ( line->text().isEmpty() ) {
54 line->setText( names ); 77 line->setText( names );
55 } else if ( !names.isEmpty() ) { 78 } else if ( !names.isEmpty() ) {
56 line->setText( line->text() + ", " + names ); 79 line->setText( line->text() + ", " + names );
57 } 80 }
58} 81}
59 82
60 83
61void ComposeMail::setTo( const QString & to ) 84void ComposeMail::setTo( const QString & to )
62{ 85{
63/* QString toline; 86/* QString toline;
64 QStringList toEntry = to; 87 QStringList toEntry = to;
65 for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { 88 for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) {
66 toline += (*it); 89 toline += (*it);
67 } 90 }
68 toLine->setText( toline ); 91 toLine->setText( toline );
69*/ 92*/
70toLine->setText( to ); 93toLine->setText( to );
71} 94}
72 95
73void ComposeMail::setSubject( const QString & subject ) 96void ComposeMail::setSubject( const QString & subject )
74{ 97{
75 subjectLine->setText( subject ); 98 subjectLine->setText( subject );
76} 99}
77 100
78void ComposeMail::setInReplyTo( const QString & messageId ) 101void ComposeMail::setInReplyTo( const QString & messageId )
79{ 102{
80 103
81} 104}
82 105
83void ComposeMail::setMessage( const QString & text ) 106void ComposeMail::setMessage( const QString & text )
84{ 107{
85 message->setText( text ); 108 message->setText( text );
86} 109}
87 110
88 111
89void ComposeMail::pickAddressTo() 112void ComposeMail::pickAddressTo()
90{ 113{
91 pickAddress( toLine ); 114 pickAddress( toLine );
92} 115}
93 116
94void ComposeMail::pickAddressCC() 117void ComposeMail::pickAddressCC()
95{ 118{
96 pickAddress( ccLine ); 119 pickAddress( ccLine );
97} 120}
98 121
99void ComposeMail::pickAddressBCC() 122void ComposeMail::pickAddressBCC()
100{ 123{
101 pickAddress( bccLine ); 124 pickAddress( bccLine );
102} 125}
103 126
104void ComposeMail::pickAddressReply() 127void ComposeMail::pickAddressReply()
105{ 128{
106 pickAddress( replyLine ); 129 pickAddress( replyLine );
107} 130}
108 131
109void ComposeMail::fillValues( int current ) 132void ComposeMail::fillValues( int current )
110{ 133{
134#if 0
111 SMTPaccount *smtp = smtpAccounts.at( current ); 135 SMTPaccount *smtp = smtpAccounts.at( current );
112
113 ccLine->clear(); 136 ccLine->clear();
114 if ( smtp->getUseCC() ) { 137 if ( smtp->getUseCC() ) {
115 ccLine->setText( smtp->getCC() ); 138 ccLine->setText( smtp->getCC() );
116 } 139 }
117 bccLine->clear(); 140 bccLine->clear();
118 if ( smtp->getUseBCC() ) { 141 if ( smtp->getUseBCC() ) {
119 bccLine->setText( smtp->getBCC() ); 142 bccLine->setText( smtp->getBCC() );
120 } 143 }
121 replyLine->clear(); 144 replyLine->clear();
122 if ( smtp->getUseReply() ) { 145 if ( smtp->getUseReply() ) {
123 replyLine->setText( smtp->getReply() ); 146 replyLine->setText( smtp->getReply() );
124 } 147 }
125
126 sigMultiLine->setText( smtp->getSignature() ); 148 sigMultiLine->setText( smtp->getSignature() );
149#endif
127} 150}
128 151
129void ComposeMail::slotAdjustColumns() 152void ComposeMail::slotAdjustColumns()
130{ 153{
131 int currPage = tabWidget->currentPageIndex(); 154 int currPage = tabWidget->currentPageIndex();
132 155
133 tabWidget->showPage( attachTab ); 156 tabWidget->showPage( attachTab );
134 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 157 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
135 attList->setColumnWidth( 1, 80 ); 158 attList->setColumnWidth( 1, 80 );
136 159
137 tabWidget->setCurrentPage( currPage ); 160 tabWidget->setCurrentPage( currPage );
138} 161}
139 162
140void ComposeMail::addAttachment() 163void ComposeMail::addAttachment()
141{ 164{
142 DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); 165 DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" );
143 if ( !lnk.name().isEmpty() ) { 166 if ( !lnk.name().isEmpty() ) {
144 Attachment *att = new Attachment( lnk ); 167 Attachment *att = new Attachment( lnk );
145 (void) new AttachViewItem( attList, att ); 168 (void) new AttachViewItem( attList, att );
146 } 169 }
147} 170}
148 171
149void ComposeMail::removeAttachment() 172void ComposeMail::removeAttachment()
150{ 173{
151 if ( !attList->currentItem() ) { 174 if ( !attList->currentItem() ) {
152 QMessageBox::information( this, tr( "Error" ), 175 QMessageBox::information( this, tr( "Error" ),
153 tr( "<p>Please select a File.</p>" ), 176 tr( "<p>Please select a File.</p>" ),
154 tr( "Ok" ) ); 177 tr( "Ok" ) );
155 } else { 178 } else {
156 attList->takeItem( attList->currentItem() ); 179 attList->takeItem( attList->currentItem() );
157 } 180 }
158} 181}
159 182
160void ComposeMail::accept() 183void ComposeMail::accept()
161{ 184{
162 if ( checkBoxLater->isChecked() ) { 185 if ( checkBoxLater->isChecked() ) {
163 qDebug( "Send later" ); 186 qDebug( "Send later" );
164 } 187 }
165 188
166 189#if 0
167 qDebug( "Sending Mail with " + 190 qDebug( "Sending Mail with " +
168 smtpAccounts.at( fromBox->currentItem() )->getAccountName() ); 191 smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() );
192#endif
169 Mail *mail = new Mail(); 193 Mail *mail = new Mail();
170 SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() );
171 194
172 mail->setMail( smtp->getMail() ); 195 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
173 mail->setName( smtp->getName() ); 196 mail->setMail(fromBox->currentText());
174 197
175 if ( !toLine->text().isEmpty() ) { 198 if ( !toLine->text().isEmpty() ) {
176 mail->setTo( toLine->text() ); 199 mail->setTo( toLine->text() );
177 } else { 200 } else {
178 qDebug( "No Reciever spezified -> returning" ); 201 qDebug( "No Reciever spezified -> returning" );
179 return; 202 return;
180 } 203 }
181 204 mail->setName(senderNameEdit->text());
182 mail->setCC( ccLine->text() ); 205 mail->setCC( ccLine->text() );
183 mail->setBCC( bccLine->text() ); 206 mail->setBCC( bccLine->text() );
184 mail->setReply( replyLine->text() ); 207 mail->setReply( replyLine->text() );
185 mail->setSubject( subjectLine->text() ); 208 mail->setSubject( subjectLine->text() );
186 QString txt = message->text(); 209 QString txt = message->text();
187 if ( !sigMultiLine->text().isEmpty() ) { 210 if ( !sigMultiLine->text().isEmpty() ) {
188 txt.append( "\n--\n" ); 211 txt.append( "\n--\n" );
189 txt.append( sigMultiLine->text() ); 212 txt.append( sigMultiLine->text() );
190 } 213 }
214 qDebug(txt);
191 mail->setMessage( txt ); 215 mail->setMessage( txt );
192 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 216 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
193 while ( it != NULL ) { 217 while ( it != NULL ) {
194 mail->addAttachment( it->getAttachment() ); 218 mail->addAttachment( it->getAttachment() );
195 it = (AttachViewItem *) it->nextSibling(); 219 it = (AttachViewItem *) it->nextSibling();
196 } 220 }
197 221
198 SMTPwrapper wrapper( settings ); 222 SMTPwrapper wrapper( settings );
199 wrapper.sendMail( *mail,checkBoxLater->isChecked() ); 223 wrapper.sendMail( *mail,smtp,checkBoxLater->isChecked() );
200 224
201 QDialog::accept(); 225 QDialog::accept();
202} 226}
203 227
204AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 228AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
205 : QListViewItem( parent ) 229 : QListViewItem( parent )
206{ 230{
207 attachment = att; 231 attachment = att;
208 qDebug( att->getMimeType() ); 232 qDebug( att->getMimeType() );
209 setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? 233 setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ?
210 Resource::loadPixmap( "UnknownDocument-14" ) : 234 Resource::loadPixmap( "UnknownDocument-14" ) :
211 attachment->getDocLnk().pixmap() ); 235 attachment->getDocLnk().pixmap() );
212 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 236 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
213 setText( 1, QString::number( att->getSize() ) ); 237 setText( 1, QString::number( att->getSize() ) );
214} 238}
215 239
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,332 +1,474 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>ComposeMailUI</class> 2<class>ComposeMailUI</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>ComposeMailUI</cstring> 7 <cstring>ComposeMailUI</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>260</width> 14 <width>252</width>
15 <height>360</height> 15 <height>360</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Compose Message</string> 20 <string>Compose Message</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <vbox> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>3</number> 31 <number>1</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>3</number> 35 <number>1</number>
36 </property> 36 </property>
37 <widget> 37 <widget>
38 <class>QCheckBox</class> 38 <class>QLayoutWidget</class>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>name</name> 40 <name>name</name>
41 <cstring>checkBoxLater</cstring> 41 <cstring>Layout4</cstring>
42 </property> 42 </property>
43 <property stdset="1"> 43 <property>
44 <name>text</name> 44 <name>layoutSpacing</name>
45 <string>send later</string>
46 </property> 45 </property>
46 <grid>
47 <property stdset="1">
48 <name>margin</name>
49 <number>0</number>
50 </property>
51 <property stdset="1">
52 <name>spacing</name>
53 <number>3</number>
54 </property>
55 <widget row="0" column="0" >
56 <class>QCheckBox</class>
57 <property stdset="1">
58 <name>name</name>
59 <cstring>checkBoxLater</cstring>
60 </property>
61 <property stdset="1">
62 <name>text</name>
63 <string>send later</string>
64 </property>
65 </widget>
66 <widget row="0" column="1" >
67 <class>QLabel</class>
68 <property stdset="1">
69 <name>name</name>
70 <cstring>accountLabel</cstring>
71 </property>
72 <property stdset="1">
73 <name>text</name>
74 <string>use:</string>
75 </property>
76 </widget>
77 <widget row="0" column="2" >
78 <class>QComboBox</class>
79 <property stdset="1">
80 <name>name</name>
81 <cstring>smtpAccountBox</cstring>
82 </property>
83 <property stdset="1">
84 <name>sizePolicy</name>
85 <sizepolicy>
86 <hsizetype>3</hsizetype>
87 <vsizetype>0</vsizetype>
88 </sizepolicy>
89 </property>
90 </widget>
91 </grid>
47 </widget> 92 </widget>
48 <widget> 93 <widget>
49 <class>QTabWidget</class> 94 <class>QTabWidget</class>
50 <property stdset="1"> 95 <property stdset="1">
51 <name>name</name> 96 <name>name</name>
52 <cstring>tabWidget</cstring> 97 <cstring>tabWidget</cstring>
53 </property> 98 </property>
54 <property> 99 <property>
55 <name>layoutMargin</name> 100 <name>layoutMargin</name>
56 </property> 101 </property>
57 <property> 102 <property>
58 <name>layoutSpacing</name> 103 <name>layoutSpacing</name>
59 </property> 104 </property>
60 <widget> 105 <widget>
61 <class>QWidget</class> 106 <class>QWidget</class>
62 <property stdset="1"> 107 <property stdset="1">
63 <name>name</name> 108 <name>name</name>
64 <cstring>mailTab</cstring> 109 <cstring>mailTab</cstring>
65 </property> 110 </property>
66 <attribute> 111 <attribute>
67 <name>title</name> 112 <name>title</name>
68 <string>Mail</string> 113 <string>Mail</string>
69 </attribute> 114 </attribute>
70 <grid> 115 <vbox>
71 <property stdset="1"> 116 <property stdset="1">
72 <name>margin</name> 117 <name>margin</name>
73 <number>-1</number> 118 <number>1</number>
74 </property> 119 </property>
75 <property stdset="1"> 120 <property stdset="1">
76 <name>spacing</name> 121 <name>spacing</name>
77 <number>-1</number> 122 <number>1</number>
78 </property> 123 </property>
79 <widget row="2" column="1" > 124 <widget>
80 <class>QLineEdit</class> 125 <class>QLayoutWidget</class>
81 <property stdset="1"> 126 <property stdset="1">
82 <name>name</name> 127 <name>name</name>
83 <cstring>subjectLine</cstring> 128 <cstring>Layout10</cstring>
84 </property> 129 </property>
130 <property>
131 <name>layoutSpacing</name>
132 </property>
133 <grid>
134 <property stdset="1">
135 <name>margin</name>
136 <number>0</number>
137 </property>
138 <property stdset="1">
139 <name>spacing</name>
140 <number>1</number>
141 </property>
142 <widget row="0" column="1" >
143 <class>QLayoutWidget</class>
144 <property stdset="1">
145 <name>name</name>
146 <cstring>Layout9</cstring>
147 </property>
148 <property>
149 <name>layoutSpacing</name>
150 </property>
151 <grid>
152 <property stdset="1">
153 <name>margin</name>
154 <number>0</number>
155 </property>
156 <property stdset="1">
157 <name>spacing</name>
158 <number>3</number>
159 </property>
160 <widget row="0" column="1" >
161 <class>QComboBox</class>
162 <property stdset="1">
163 <name>name</name>
164 <cstring>fromBox</cstring>
165 </property>
166 <property stdset="1">
167 <name>sizePolicy</name>
168 <sizepolicy>
169 <hsizetype>3</hsizetype>
170 <vsizetype>0</vsizetype>
171 </sizepolicy>
172 </property>
173 <property stdset="1">
174 <name>editable</name>
175 <bool>true</bool>
176 </property>
177 <property stdset="1">
178 <name>duplicatesEnabled</name>
179 <bool>false</bool>
180 </property>
181 </widget>
182 <widget row="0" column="0" >
183 <class>QLineEdit</class>
184 <property stdset="1">
185 <name>name</name>
186 <cstring>senderNameEdit</cstring>
187 </property>
188 <property stdset="1">
189 <name>sizePolicy</name>
190 <sizepolicy>
191 <hsizetype>0</hsizetype>
192 <vsizetype>0</vsizetype>
193 </sizepolicy>
194 </property>
195 <property stdset="1">
196 <name>minimumSize</name>
197 <size>
198 <width>70</width>
199 <height>0</height>
200 </size>
201 </property>
202 <property stdset="1">
203 <name>maximumSize</name>
204 <size>
205 <width>70</width>
206 <height>32767</height>
207 </size>
208 </property>
209 </widget>
210 </grid>
211 </widget>
212 <widget row="2" column="1" >
213 <class>QLineEdit</class>
214 <property stdset="1">
215 <name>name</name>
216 <cstring>subjectLine</cstring>
217 </property>
218 <property stdset="1">
219 <name>sizePolicy</name>
220 <sizepolicy>
221 <hsizetype>3</hsizetype>
222 <vsizetype>0</vsizetype>
223 </sizepolicy>
224 </property>
225 </widget>
226 <widget row="1" column="1" >
227 <class>QLineEdit</class>
228 <property stdset="1">
229 <name>name</name>
230 <cstring>toLine</cstring>
231 </property>
232 <property stdset="1">
233 <name>sizePolicy</name>
234 <sizepolicy>
235 <hsizetype>3</hsizetype>
236 <vsizetype>0</vsizetype>
237 </sizepolicy>
238 </property>
239 </widget>
240 <widget row="2" column="0" >
241 <class>QLabel</class>
242 <property stdset="1">
243 <name>name</name>
244 <cstring>subjectLabel</cstring>
245 </property>
246 <property stdset="1">
247 <name>text</name>
248 <string>Subject</string>
249 </property>
250 </widget>
251 <widget row="0" column="0" >
252 <class>QLabel</class>
253 <property stdset="1">
254 <name>name</name>
255 <cstring>fromLabel</cstring>
256 </property>
257 <property stdset="1">
258 <name>text</name>
259 <string>From</string>
260 </property>
261 </widget>
262 <widget row="1" column="0" >
263 <class>QPushButton</class>
264 <property stdset="1">
265 <name>name</name>
266 <cstring>toButton</cstring>
267 </property>
268 <property stdset="1">
269 <name>text</name>
270 <string>To</string>
271 </property>
272 </widget>
273 </grid>
85 </widget> 274 </widget>
86 <widget row="3" column="0" rowspan="1" colspan="2" > 275 <widget>
87 <class>QMultiLineEdit</class> 276 <class>QMultiLineEdit</class>
88 <property stdset="1"> 277 <property stdset="1">
89 <name>name</name> 278 <name>name</name>
90 <cstring>message</cstring> 279 <cstring>message</cstring>
91 </property> 280 </property>
92 </widget> 281 </widget>
93 <widget row="2" column="0" > 282 </vbox>
94 <class>QLabel</class>
95 <property stdset="1">
96 <name>name</name>
97 <cstring>subjectLabel</cstring>
98 </property>
99 <property stdset="1">
100 <name>text</name>
101 <string>Subject</string>
102 </property>
103 </widget>
104 <widget row="0" column="0" >
105 <class>QLabel</class>
106 <property stdset="1">
107 <name>name</name>
108 <cstring>fromLabel</cstring>
109 </property>
110 <property stdset="1">
111 <name>text</name>
112 <string>From</string>
113 </property>
114 </widget>
115 <widget row="1" column="1" >
116 <class>QLineEdit</class>
117 <property stdset="1">
118 <name>name</name>
119 <cstring>toLine</cstring>
120 </property>
121 </widget>
122 <widget row="0" column="1" >
123 <class>QComboBox</class>
124 <property stdset="1">
125 <name>name</name>
126 <cstring>fromBox</cstring>
127 </property>
128 </widget>
129 <widget row="1" column="0" >
130 <class>QPushButton</class>
131 <property stdset="1">
132 <name>name</name>
133 <cstring>toButton</cstring>
134 </property>
135 <property stdset="1">
136 <name>text</name>
137 <string>To</string>
138 </property>
139 </widget>
140 </grid>
141 </widget> 283 </widget>
142 <widget> 284 <widget>
143 <class>QWidget</class> 285 <class>QWidget</class>
144 <property stdset="1"> 286 <property stdset="1">
145 <name>name</name> 287 <name>name</name>
146 <cstring>optionsTab</cstring> 288 <cstring>optionsTab</cstring>
147 </property> 289 </property>
148 <attribute> 290 <attribute>
149 <name>title</name> 291 <name>title</name>
150 <string>Options</string> 292 <string>Options</string>
151 </attribute> 293 </attribute>
152 <grid> 294 <grid>
153 <property stdset="1"> 295 <property stdset="1">
154 <name>margin</name> 296 <name>margin</name>
155 <number>4</number> 297 <number>4</number>
156 </property> 298 </property>
157 <property stdset="1"> 299 <property stdset="1">
158 <name>spacing</name> 300 <name>spacing</name>
159 <number>3</number> 301 <number>3</number>
160 </property> 302 </property>
161 <widget row="3" column="0" > 303 <widget row="3" column="0" >
162 <class>QPushButton</class> 304 <class>QPushButton</class>
163 <property stdset="1"> 305 <property stdset="1">
164 <name>name</name> 306 <name>name</name>
165 <cstring>replyButton</cstring> 307 <cstring>replyButton</cstring>
166 </property> 308 </property>
167 <property stdset="1"> 309 <property stdset="1">
168 <name>text</name> 310 <name>text</name>
169 <string>Reply-To</string> 311 <string>Reply-To</string>
170 </property> 312 </property>
171 </widget> 313 </widget>
172 <widget row="2" column="0" > 314 <widget row="2" column="0" >
173 <class>QPushButton</class> 315 <class>QPushButton</class>
174 <property stdset="1"> 316 <property stdset="1">
175 <name>name</name> 317 <name>name</name>
176 <cstring>bccButton</cstring> 318 <cstring>bccButton</cstring>
177 </property> 319 </property>
178 <property stdset="1"> 320 <property stdset="1">
179 <name>text</name> 321 <name>text</name>
180 <string>BCC</string> 322 <string>BCC</string>
181 </property> 323 </property>
182 </widget> 324 </widget>
183 <widget row="1" column="1" > 325 <widget row="1" column="1" >
184 <class>QLineEdit</class> 326 <class>QLineEdit</class>
185 <property stdset="1"> 327 <property stdset="1">
186 <name>name</name> 328 <name>name</name>
187 <cstring>ccLine</cstring> 329 <cstring>ccLine</cstring>
188 </property> 330 </property>
189 </widget> 331 </widget>
190 <widget row="2" column="1" > 332 <widget row="2" column="1" >
191 <class>QLineEdit</class> 333 <class>QLineEdit</class>
192 <property stdset="1"> 334 <property stdset="1">
193 <name>name</name> 335 <name>name</name>
194 <cstring>bccLine</cstring> 336 <cstring>bccLine</cstring>
195 </property> 337 </property>
196 </widget> 338 </widget>
197 <widget row="3" column="1" > 339 <widget row="3" column="1" >
198 <class>QLineEdit</class> 340 <class>QLineEdit</class>
199 <property stdset="1"> 341 <property stdset="1">
200 <name>name</name> 342 <name>name</name>
201 <cstring>replyLine</cstring> 343 <cstring>replyLine</cstring>
202 </property> 344 </property>
203 </widget> 345 </widget>
204 <widget row="6" column="0" rowspan="1" colspan="2" > 346 <widget row="6" column="0" rowspan="1" colspan="2" >
205 <class>QMultiLineEdit</class> 347 <class>QMultiLineEdit</class>
206 <property stdset="1"> 348 <property stdset="1">
207 <name>name</name> 349 <name>name</name>
208 <cstring>sigMultiLine</cstring> 350 <cstring>sigMultiLine</cstring>
209 </property> 351 </property>
210 </widget> 352 </widget>
211 <widget row="5" column="0" > 353 <widget row="5" column="0" >
212 <class>QLabel</class> 354 <class>QLabel</class>
213 <property stdset="1"> 355 <property stdset="1">
214 <name>name</name> 356 <name>name</name>
215 <cstring>sigLabel</cstring> 357 <cstring>sigLabel</cstring>
216 </property> 358 </property>
217 <property stdset="1"> 359 <property stdset="1">
218 <name>text</name> 360 <name>text</name>
219 <string>Signature</string> 361 <string>Signature</string>
220 </property> 362 </property>
221 </widget> 363 </widget>
222 <spacer row="4" column="0" > 364 <spacer row="4" column="0" >
223 <property> 365 <property>
224 <name>name</name> 366 <name>name</name>
225 <cstring>Spacer3</cstring> 367 <cstring>Spacer3</cstring>
226 </property> 368 </property>
227 <property stdset="1"> 369 <property stdset="1">
228 <name>orientation</name> 370 <name>orientation</name>
229 <enum>Vertical</enum> 371 <enum>Vertical</enum>
230 </property> 372 </property>
231 <property stdset="1"> 373 <property stdset="1">
232 <name>sizeType</name> 374 <name>sizeType</name>
233 <enum>Expanding</enum> 375 <enum>Expanding</enum>
234 </property> 376 </property>
235 <property> 377 <property>
236 <name>sizeHint</name> 378 <name>sizeHint</name>
237 <size> 379 <size>
238 <width>20</width> 380 <width>20</width>
239 <height>20</height> 381 <height>20</height>
240 </size> 382 </size>
241 </property> 383 </property>
242 </spacer> 384 </spacer>
243 <widget row="1" column="0" > 385 <widget row="1" column="0" >
244 <class>QPushButton</class> 386 <class>QPushButton</class>
245 <property stdset="1"> 387 <property stdset="1">
246 <name>name</name> 388 <name>name</name>
247 <cstring>ccButton</cstring> 389 <cstring>ccButton</cstring>
248 </property> 390 </property>
249 <property stdset="1"> 391 <property stdset="1">
250 <name>text</name> 392 <name>text</name>
251 <string>CC</string> 393 <string>CC</string>
252 </property> 394 </property>
253 </widget> 395 </widget>
254 </grid> 396 </grid>
255 </widget> 397 </widget>
256 <widget> 398 <widget>
257 <class>QWidget</class> 399 <class>QWidget</class>
258 <property stdset="1"> 400 <property stdset="1">
259 <name>name</name> 401 <name>name</name>
260 <cstring>attachTab</cstring> 402 <cstring>attachTab</cstring>
261 </property> 403 </property>
262 <attribute> 404 <attribute>
263 <name>title</name> 405 <name>title</name>
264 <string>Attachment</string> 406 <string>Attachment</string>
265 </attribute> 407 </attribute>
266 <grid> 408 <grid>
267 <property stdset="1"> 409 <property stdset="1">
268 <name>margin</name> 410 <name>margin</name>
269 <number>4</number> 411 <number>4</number>
270 </property> 412 </property>
271 <property stdset="1"> 413 <property stdset="1">
272 <name>spacing</name> 414 <name>spacing</name>
273 <number>3</number> 415 <number>3</number>
274 </property> 416 </property>
275 <widget row="0" column="0" rowspan="1" colspan="3" > 417 <widget row="0" column="0" rowspan="1" colspan="3" >
276 <class>QListView</class> 418 <class>QListView</class>
277 <property stdset="1"> 419 <property stdset="1">
278 <name>name</name> 420 <name>name</name>
279 <cstring>attList</cstring> 421 <cstring>attList</cstring>
280 </property> 422 </property>
281 <property stdset="1"> 423 <property stdset="1">
282 <name>selectionMode</name> 424 <name>selectionMode</name>
283 <enum>Single</enum> 425 <enum>Single</enum>
284 </property> 426 </property>
285 <property stdset="1"> 427 <property stdset="1">
286 <name>allColumnsShowFocus</name> 428 <name>allColumnsShowFocus</name>
287 <bool>true</bool> 429 <bool>true</bool>
288 </property> 430 </property>
289 <property stdset="1"> 431 <property stdset="1">
290 <name>showSortIndicator</name> 432 <name>showSortIndicator</name>
291 <bool>true</bool> 433 <bool>true</bool>
292 </property> 434 </property>
293 </widget> 435 </widget>
294 <widget row="1" column="2" > 436 <widget row="1" column="2" >
295 <class>QPushButton</class> 437 <class>QPushButton</class>
296 <property stdset="1"> 438 <property stdset="1">
297 <name>name</name> 439 <name>name</name>
298 <cstring>deleteButton</cstring> 440 <cstring>deleteButton</cstring>
299 </property> 441 </property>
300 <property stdset="1"> 442 <property stdset="1">
301 <name>text</name> 443 <name>text</name>
302 <string>Delete File</string> 444 <string>Delete File</string>
303 </property> 445 </property>
304 </widget> 446 </widget>
305 <widget row="1" column="0" > 447 <widget row="1" column="0" >
306 <class>QPushButton</class> 448 <class>QPushButton</class>
307 <property stdset="1"> 449 <property stdset="1">
308 <name>name</name> 450 <name>name</name>
309 <cstring>addButton</cstring> 451 <cstring>addButton</cstring>
310 </property> 452 </property>
311 <property stdset="1"> 453 <property stdset="1">
312 <name>text</name> 454 <name>text</name>
313 <string>Add File</string> 455 <string>Add File</string>
314 </property> 456 </property>
315 </widget> 457 </widget>
316 </grid> 458 </grid>
317 </widget> 459 </widget>
318 </widget> 460 </widget>
319 </vbox> 461 </vbox>
320</widget> 462</widget>
321<tabstops> 463<tabstops>
322 <tabstop>fromBox</tabstop> 464 <tabstop>fromBox</tabstop>
323 <tabstop>toButton</tabstop> 465 <tabstop>toButton</tabstop>
324 <tabstop>toLine</tabstop> 466 <tabstop>toLine</tabstop>
325 <tabstop>subjectLine</tabstop> 467 <tabstop>subjectLine</tabstop>
326 <tabstop>message</tabstop> 468 <tabstop>message</tabstop>
327 <tabstop>tabWidget</tabstop> 469 <tabstop>tabWidget</tabstop>
328 <tabstop>ccButton</tabstop> 470 <tabstop>ccButton</tabstop>
329 <tabstop>ccLine</tabstop> 471 <tabstop>ccLine</tabstop>
330 <tabstop>bccButton</tabstop> 472 <tabstop>bccButton</tabstop>
331 <tabstop>bccLine</tabstop> 473 <tabstop>bccLine</tabstop>
332 <tabstop>replyButton</tabstop> 474 <tabstop>replyButton</tabstop>
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
@@ -166,306 +166,283 @@ void EditAccounts::slotEditMail()
166 return; 166 return;
167 } 167 }
168 168
169 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 169 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
170 slotEditAccount( a ); 170 slotEditAccount( a );
171} 171}
172 172
173void EditAccounts::slotDeleteMail() 173void EditAccounts::slotDeleteMail()
174{ 174{
175 if ( !mailList->currentItem() ) { 175 if ( !mailList->currentItem() ) {
176 QMessageBox::information( this, tr( "Error" ), 176 QMessageBox::information( this, tr( "Error" ),
177 tr( "<p>Please select an account.</p>" ), 177 tr( "<p>Please select an account.</p>" ),
178 tr( "Ok" ) ); 178 tr( "Ok" ) );
179 return; 179 return;
180 } 180 }
181 181
182 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 182 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
183 slotDeleteAccount( a ); 183 slotDeleteAccount( a );
184} 184}
185 185
186void EditAccounts::slotNewNews() 186void EditAccounts::slotNewNews()
187{ 187{
188 qDebug( "New News Account" ); 188 qDebug( "New News Account" );
189 slotNewAccount( "NNTP" ); 189 slotNewAccount( "NNTP" );
190} 190}
191 191
192void EditAccounts::slotEditNews() 192void EditAccounts::slotEditNews()
193{ 193{
194 qDebug( "Edit News Account" ); 194 qDebug( "Edit News Account" );
195 if ( !newsList->currentItem() ) { 195 if ( !newsList->currentItem() ) {
196 QMessageBox::information( this, tr( "Error" ), 196 QMessageBox::information( this, tr( "Error" ),
197 tr( "<p>Please select an account.</p>" ), 197 tr( "<p>Please select an account.</p>" ),
198 tr( "Ok" ) ); 198 tr( "Ok" ) );
199 return; 199 return;
200 } 200 }
201 201
202 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 202 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
203 slotEditAccount( a ); 203 slotEditAccount( a );
204} 204}
205 205
206void EditAccounts::slotDeleteNews() 206void EditAccounts::slotDeleteNews()
207{ 207{
208 qDebug( "Delete News Account" ); 208 qDebug( "Delete News Account" );
209 if ( !newsList->currentItem() ) { 209 if ( !newsList->currentItem() ) {
210 QMessageBox::information( this, tr( "Error" ), 210 QMessageBox::information( this, tr( "Error" ),
211 tr( "<p>Please select an account.</p>" ), 211 tr( "<p>Please select an account.</p>" ),
212 tr( "Ok" ) ); 212 tr( "Ok" ) );
213 return; 213 return;
214 } 214 }
215 215
216 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 216 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
217 slotDeleteAccount( a ); 217 slotDeleteAccount( a );
218} 218}
219 219
220void EditAccounts::slotAdjustColumns() 220void EditAccounts::slotAdjustColumns()
221{ 221{
222 int currPage = configTab->currentPageIndex(); 222 int currPage = configTab->currentPageIndex();
223 223
224 configTab->showPage( mailTab ); 224 configTab->showPage( mailTab );
225 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); 225 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 );
226 mailList->setColumnWidth( 1, 50 ); 226 mailList->setColumnWidth( 1, 50 );
227 227
228 configTab->showPage( newsTab ); 228 configTab->showPage( newsTab );
229 newsList->setColumnWidth( 0, newsList->visibleWidth() ); 229 newsList->setColumnWidth( 0, newsList->visibleWidth() );
230 230
231 configTab->setCurrentPage( currPage ); 231 configTab->setCurrentPage( currPage );
232} 232}
233 233
234void EditAccounts::accept() 234void EditAccounts::accept()
235{ 235{
236 settings->saveAccounts(); 236 settings->saveAccounts();
237 237
238 QDialog::accept(); 238 QDialog::accept();
239} 239}
240 240
241/** 241/**
242 * SelectMailType 242 * SelectMailType
243 */ 243 */
244 244
245SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) 245SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags )
246 : SelectMailTypeUI( parent, name, modal, flags ) 246 : SelectMailTypeUI( parent, name, modal, flags )
247{ 247{
248 selected = selection; 248 selected = selection;
249 selected->replace( 0, selected->length(), typeBox->currentText() ); 249 selected->replace( 0, selected->length(), typeBox->currentText() );
250 connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) ); 250 connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) );
251} 251}
252 252
253void SelectMailType::slotSelection( const QString &sel ) 253void SelectMailType::slotSelection( const QString &sel )
254{ 254{
255 selected->replace( 0, selected->length(), sel ); 255 selected->replace( 0, selected->length(), sel );
256} 256}
257 257
258/** 258/**
259 * IMAPconfig 259 * IMAPconfig
260 */ 260 */
261 261
262IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 262IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
263 : IMAPconfigUI( parent, name, modal, flags ) 263 : IMAPconfigUI( parent, name, modal, flags )
264{ 264{
265 data = account; 265 data = account;
266 266
267 fillValues(); 267 fillValues();
268 268
269 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); 269 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) );
270} 270}
271 271
272void IMAPconfig::slotSSL( bool enabled ) 272void IMAPconfig::slotSSL( bool enabled )
273{ 273{
274 if ( enabled ) { 274 if ( enabled ) {
275 portLine->setText( IMAP_SSL_PORT ); 275 portLine->setText( IMAP_SSL_PORT );
276 } else { 276 } else {
277 portLine->setText( IMAP_PORT ); 277 portLine->setText( IMAP_PORT );
278 } 278 }
279} 279}
280 280
281void IMAPconfig::fillValues() 281void IMAPconfig::fillValues()
282{ 282{
283 accountLine->setText( data->getAccountName() ); 283 accountLine->setText( data->getAccountName() );
284 serverLine->setText( data->getServer() ); 284 serverLine->setText( data->getServer() );
285 portLine->setText( data->getPort() ); 285 portLine->setText( data->getPort() );
286 sslBox->setChecked( data->getSSL() ); 286 sslBox->setChecked( data->getSSL() );
287 userLine->setText( data->getUser() ); 287 userLine->setText( data->getUser() );
288 passLine->setText( data->getPassword() ); 288 passLine->setText( data->getPassword() );
289 prefixLine->setText(data->getPrefix()); 289 prefixLine->setText(data->getPrefix());
290} 290}
291 291
292void IMAPconfig::accept() 292void IMAPconfig::accept()
293{ 293{
294 data->setAccountName( accountLine->text() ); 294 data->setAccountName( accountLine->text() );
295 data->setServer( serverLine->text() ); 295 data->setServer( serverLine->text() );
296 data->setPort( portLine->text() ); 296 data->setPort( portLine->text() );
297 data->setSSL( sslBox->isChecked() ); 297 data->setSSL( sslBox->isChecked() );
298 data->setUser( userLine->text() ); 298 data->setUser( userLine->text() );
299 data->setPassword( passLine->text() ); 299 data->setPassword( passLine->text() );
300 data->setPrefix(prefixLine->text()); 300 data->setPrefix(prefixLine->text());
301 301
302 QDialog::accept(); 302 QDialog::accept();
303} 303}
304 304
305/** 305/**
306 * POP3config 306 * POP3config
307 */ 307 */
308 308
309POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 309POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
310 : POP3configUI( parent, name, modal, flags ) 310 : POP3configUI( parent, name, modal, flags )
311{ 311{
312 data = account; 312 data = account;
313 fillValues(); 313 fillValues();
314 314
315 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); 315 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) );
316} 316}
317 317
318void POP3config::slotSSL( bool enabled ) 318void POP3config::slotSSL( bool enabled )
319{ 319{
320 if ( enabled ) { 320 if ( enabled ) {
321 portLine->setText( POP3_SSL_PORT ); 321 portLine->setText( POP3_SSL_PORT );
322 } else { 322 } else {
323 portLine->setText( POP3_PORT ); 323 portLine->setText( POP3_PORT );
324 } 324 }
325} 325}
326 326
327void POP3config::fillValues() 327void POP3config::fillValues()
328{ 328{
329 accountLine->setText( data->getAccountName() ); 329 accountLine->setText( data->getAccountName() );
330 serverLine->setText( data->getServer() ); 330 serverLine->setText( data->getServer() );
331 portLine->setText( data->getPort() ); 331 portLine->setText( data->getPort() );
332 sslBox->setChecked( data->getSSL() ); 332 sslBox->setChecked( data->getSSL() );
333 userLine->setText( data->getUser() ); 333 userLine->setText( data->getUser() );
334 passLine->setText( data->getPassword() ); 334 passLine->setText( data->getPassword() );
335} 335}
336 336
337void POP3config::accept() 337void POP3config::accept()
338{ 338{
339 data->setAccountName( accountLine->text() ); 339 data->setAccountName( accountLine->text() );
340 data->setServer( serverLine->text() ); 340 data->setServer( serverLine->text() );
341 data->setPort( portLine->text() ); 341 data->setPort( portLine->text() );
342 data->setSSL( sslBox->isChecked() ); 342 data->setSSL( sslBox->isChecked() );
343 data->setUser( userLine->text() ); 343 data->setUser( userLine->text() );
344 data->setPassword( passLine->text() ); 344 data->setPassword( passLine->text() );
345 345
346 QDialog::accept(); 346 QDialog::accept();
347} 347}
348 348
349/** 349/**
350 * SMTPconfig 350 * SMTPconfig
351 */ 351 */
352 352
353SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 353SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
354 : SMTPconfigUI( parent, name, modal, flags ) 354 : SMTPconfigUI( parent, name, modal, flags )
355{ 355{
356 data = account; 356 data = account;
357 357
358 connect( ccBox, SIGNAL( toggled( bool ) ), ccLine, SLOT( setEnabled( bool ) ) );
359 connect( bccBox, SIGNAL( toggled( bool ) ), bccLine, SLOT( setEnabled( bool ) ) );
360 connect( replyBox, SIGNAL( toggled( bool ) ), replyLine, SLOT( setEnabled( bool ) ) );
361 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); 358 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) );
362 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); 359 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) );
363 360
364 fillValues(); 361 fillValues();
365 362
366 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); 363 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) );
367} 364}
368 365
369void SMTPconfig::slotSSL( bool enabled ) 366void SMTPconfig::slotSSL( bool enabled )
370{ 367{
371 if ( enabled ) { 368 if ( enabled ) {
372 portLine->setText( SMTP_SSL_PORT ); 369 portLine->setText( SMTP_SSL_PORT );
373 } else { 370 } else {
374 portLine->setText( SMTP_PORT ); 371 portLine->setText( SMTP_PORT );
375 } 372 }
376} 373}
377 374
378void SMTPconfig::fillValues() 375void SMTPconfig::fillValues()
379{ 376{
380 accountLine->setText( data->getAccountName() ); 377 accountLine->setText( data->getAccountName() );
381 serverLine->setText( data->getServer() ); 378 serverLine->setText( data->getServer() );
382 portLine->setText( data->getPort() ); 379 portLine->setText( data->getPort() );
383 sslBox->setChecked( data->getSSL() ); 380 sslBox->setChecked( data->getSSL() );
384 loginBox->setChecked( data->getLogin() ); 381 loginBox->setChecked( data->getLogin() );
385 userLine->setText( data->getUser() ); 382 userLine->setText( data->getUser() );
386 passLine->setText( data->getPassword() ); 383 passLine->setText( data->getPassword() );
387 nameLine->setText( data->getName() );
388 mailLine->setText( data->getMail() );
389 orgLine->setText( data->getOrg() );
390 ccBox->setChecked( data->getUseCC() );
391 ccLine->setText( data->getCC() );
392 bccBox->setChecked( data->getUseBCC() );
393 bccLine->setText( data->getBCC() );
394 replyBox->setChecked( data->getUseReply() );
395 replyLine->setText( data->getReply() );
396 sigMultiLine->setText( data->getSignature() );
397} 384}
398 385
399void SMTPconfig::accept() 386void SMTPconfig::accept()
400{ 387{
401 data->setAccountName( accountLine->text() ); 388 data->setAccountName( accountLine->text() );
402 data->setServer( serverLine->text() ); 389 data->setServer( serverLine->text() );
403 data->setPort( portLine->text() ); 390 data->setPort( portLine->text() );
404 data->setSSL( sslBox->isChecked() ); 391 data->setSSL( sslBox->isChecked() );
405 data->setLogin( loginBox->isChecked() ); 392 data->setLogin( loginBox->isChecked() );
406 data->setUser( userLine->text() ); 393 data->setUser( userLine->text() );
407 data->setPassword( passLine->text() ); 394 data->setPassword( passLine->text() );
408 data->setName( nameLine->text() );
409 data->setMail( mailLine->text() );
410 data->setOrg( orgLine->text() );
411 data->setCC( ccLine->text() );
412 data->setUseCC( ccBox->isChecked() );
413 data->setBCC( bccLine->text() );
414 data->setUseBCC( bccBox->isChecked() );
415 data->setReply( replyLine->text() );
416 data->setUseReply( replyBox->isChecked() );
417 data->setSignature( sigMultiLine->text() );
418 395
419 QDialog::accept(); 396 QDialog::accept();
420} 397}
421 398
422/** 399/**
423 * NNTPconfig 400 * NNTPconfig
424 */ 401 */
425 402
426NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 403NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
427 : NNTPconfigUI( parent, name, modal, flags ) 404 : NNTPconfigUI( parent, name, modal, flags )
428{ 405{
429 data = account; 406 data = account;
430 407
431 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); 408 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) );
432 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); 409 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) );
433 410
434 fillValues(); 411 fillValues();
435 412
436 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); 413 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) );
437} 414}
438 415
439void NNTPconfig::slotSSL( bool enabled ) 416void NNTPconfig::slotSSL( bool enabled )
440{ 417{
441 if ( enabled ) { 418 if ( enabled ) {
442 portLine->setText( NNTP_SSL_PORT ); 419 portLine->setText( NNTP_SSL_PORT );
443 } else { 420 } else {
444 portLine->setText( NNTP_PORT ); 421 portLine->setText( NNTP_PORT );
445 } 422 }
446} 423}
447 424
448void NNTPconfig::fillValues() 425void NNTPconfig::fillValues()
449{ 426{
450 accountLine->setText( data->getAccountName() ); 427 accountLine->setText( data->getAccountName() );
451 serverLine->setText( data->getServer() ); 428 serverLine->setText( data->getServer() );
452 portLine->setText( data->getPort() ); 429 portLine->setText( data->getPort() );
453 sslBox->setChecked( data->getSSL() ); 430 sslBox->setChecked( data->getSSL() );
454 loginBox->setChecked( data->getLogin() ); 431 loginBox->setChecked( data->getLogin() );
455 userLine->setText( data->getUser() ); 432 userLine->setText( data->getUser() );
456 passLine->setText( data->getPassword() ); 433 passLine->setText( data->getPassword() );
457} 434}
458 435
459void NNTPconfig::accept() 436void NNTPconfig::accept()
460{ 437{
461 data->setAccountName( accountLine->text() ); 438 data->setAccountName( accountLine->text() );
462 data->setServer( serverLine->text() ); 439 data->setServer( serverLine->text() );
463 data->setPort( portLine->text() ); 440 data->setPort( portLine->text() );
464 data->setSSL( sslBox->isChecked() ); 441 data->setSSL( sslBox->isChecked() );
465 data->setLogin( loginBox->isChecked() ); 442 data->setLogin( loginBox->isChecked() );
466 data->setUser( userLine->text() ); 443 data->setUser( userLine->text() );
467 data->setPassword( passLine->text() ); 444 data->setPassword( passLine->text() );
468 445
469 QDialog::accept(); 446 QDialog::accept();
470} 447}
471 448
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
@@ -84,345 +84,320 @@ void Settings::saveAccounts()
84} 84}
85 85
86void Settings::readAccounts() 86void Settings::readAccounts()
87{ 87{
88 checkDirectory(); 88 checkDirectory();
89 Account *it; 89 Account *it;
90 90
91 for ( it = accounts.first(); it; it = accounts.next() ) { 91 for ( it = accounts.first(); it; it = accounts.next() ) {
92 it->read(); 92 it->read();
93 } 93 }
94} 94}
95 95
96Account::Account() 96Account::Account()
97{ 97{
98 accountName = "changeMe"; 98 accountName = "changeMe";
99 type = "changeMe"; 99 type = "changeMe";
100 ssl = false; 100 ssl = false;
101} 101}
102 102
103void Account::remove() 103void Account::remove()
104{ 104{
105 QFile file( getFileName() ); 105 QFile file( getFileName() );
106 file.remove(); 106 file.remove();
107} 107}
108 108
109IMAPaccount::IMAPaccount() 109IMAPaccount::IMAPaccount()
110 : Account() 110 : Account()
111{ 111{
112 file = IMAPaccount::getUniqueFileName(); 112 file = IMAPaccount::getUniqueFileName();
113 accountName = "New IMAP Account"; 113 accountName = "New IMAP Account";
114 ssl = false; 114 ssl = false;
115 type = "IMAP"; 115 type = "IMAP";
116 port = IMAP_PORT; 116 port = IMAP_PORT;
117} 117}
118 118
119IMAPaccount::IMAPaccount( QString filename ) 119IMAPaccount::IMAPaccount( QString filename )
120 : Account() 120 : Account()
121{ 121{
122 file = filename; 122 file = filename;
123 accountName = "New IMAP Account"; 123 accountName = "New IMAP Account";
124 ssl = false; 124 ssl = false;
125 type = "IMAP"; 125 type = "IMAP";
126 port = IMAP_PORT; 126 port = IMAP_PORT;
127} 127}
128 128
129QString IMAPaccount::getUniqueFileName() 129QString IMAPaccount::getUniqueFileName()
130{ 130{
131 int num = 0; 131 int num = 0;
132 QString unique; 132 QString unique;
133 133
134 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 134 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
135 135
136 QStringList imap = dir.entryList( "imap-*" ); 136 QStringList imap = dir.entryList( "imap-*" );
137 do { 137 do {
138 unique.setNum( num++ ); 138 unique.setNum( num++ );
139 } while ( imap.contains( "imap-" + unique ) > 0 ); 139 } while ( imap.contains( "imap-" + unique ) > 0 );
140 140
141 return unique; 141 return unique;
142} 142}
143 143
144void IMAPaccount::read() 144void IMAPaccount::read()
145{ 145{
146 Config *conf = new Config( getFileName(), Config::File ); 146 Config *conf = new Config( getFileName(), Config::File );
147 conf->setGroup( "IMAP Account" ); 147 conf->setGroup( "IMAP Account" );
148 accountName = conf->readEntry( "Account","" ); 148 accountName = conf->readEntry( "Account","" );
149 if (accountName.isNull()) accountName = ""; 149 if (accountName.isNull()) accountName = "";
150 server = conf->readEntry( "Server","" ); 150 server = conf->readEntry( "Server","" );
151 if (server.isNull()) server=""; 151 if (server.isNull()) server="";
152 port = conf->readEntry( "Port","" ); 152 port = conf->readEntry( "Port","" );
153 if (port.isNull()) port="143"; 153 if (port.isNull()) port="143";
154 ssl = conf->readBoolEntry( "SSL",false ); 154 ssl = conf->readBoolEntry( "SSL",false );
155 user = conf->readEntry( "User","" ); 155 user = conf->readEntry( "User","" );
156 if (user.isNull()) user = ""; 156 if (user.isNull()) user = "";
157 password = conf->readEntryCrypt( "Password","" ); 157 password = conf->readEntryCrypt( "Password","" );
158 if (password.isNull()) password = ""; 158 if (password.isNull()) password = "";
159 prefix = conf->readEntry("MailPrefix",""); 159 prefix = conf->readEntry("MailPrefix","");
160 if (prefix.isNull()) prefix = ""; 160 if (prefix.isNull()) prefix = "";
161} 161}
162 162
163void IMAPaccount::save() 163void IMAPaccount::save()
164{ 164{
165 qDebug( "saving " + getFileName() ); 165 qDebug( "saving " + getFileName() );
166 Settings::checkDirectory(); 166 Settings::checkDirectory();
167 167
168 Config *conf = new Config( getFileName(), Config::File ); 168 Config *conf = new Config( getFileName(), Config::File );
169 conf->setGroup( "IMAP Account" ); 169 conf->setGroup( "IMAP Account" );
170 conf->writeEntry( "Account", accountName ); 170 conf->writeEntry( "Account", accountName );
171 conf->writeEntry( "Server", server ); 171 conf->writeEntry( "Server", server );
172 conf->writeEntry( "Port", port ); 172 conf->writeEntry( "Port", port );
173 conf->writeEntry( "SSL", ssl ); 173 conf->writeEntry( "SSL", ssl );
174 conf->writeEntry( "User", user ); 174 conf->writeEntry( "User", user );
175 conf->writeEntryCrypt( "Password", password ); 175 conf->writeEntryCrypt( "Password", password );
176 conf->writeEntry( "MailPrefix",prefix); 176 conf->writeEntry( "MailPrefix",prefix);
177 conf->write(); 177 conf->write();
178} 178}
179 179
180 180
181QString IMAPaccount::getFileName() 181QString IMAPaccount::getFileName()
182{ 182{
183 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; 183 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file;
184} 184}
185 185
186POP3account::POP3account() 186POP3account::POP3account()
187 : Account() 187 : Account()
188{ 188{
189 file = POP3account::getUniqueFileName(); 189 file = POP3account::getUniqueFileName();
190 accountName = "New POP3 Account"; 190 accountName = "New POP3 Account";
191 ssl = false; 191 ssl = false;
192 type = "POP3"; 192 type = "POP3";
193 port = POP3_PORT; 193 port = POP3_PORT;
194} 194}
195 195
196POP3account::POP3account( QString filename ) 196POP3account::POP3account( QString filename )
197 : Account() 197 : Account()
198{ 198{
199 file = filename; 199 file = filename;
200 accountName = "New POP3 Account"; 200 accountName = "New POP3 Account";
201 ssl = false; 201 ssl = false;
202 type = "POP3"; 202 type = "POP3";
203 port = POP3_PORT; 203 port = POP3_PORT;
204} 204}
205 205
206QString POP3account::getUniqueFileName() 206QString POP3account::getUniqueFileName()
207{ 207{
208 int num = 0; 208 int num = 0;
209 QString unique; 209 QString unique;
210 210
211 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 211 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
212 212
213 QStringList imap = dir.entryList( "pop3-*" ); 213 QStringList imap = dir.entryList( "pop3-*" );
214 do { 214 do {
215 unique.setNum( num++ ); 215 unique.setNum( num++ );
216 } while ( imap.contains( "pop3-" + unique ) > 0 ); 216 } while ( imap.contains( "pop3-" + unique ) > 0 );
217 217
218 return unique; 218 return unique;
219} 219}
220 220
221void POP3account::read() 221void POP3account::read()
222{ 222{
223 Config *conf = new Config( getFileName(), Config::File ); 223 Config *conf = new Config( getFileName(), Config::File );
224 conf->setGroup( "POP3 Account" ); 224 conf->setGroup( "POP3 Account" );
225 accountName = conf->readEntry( "Account" ); 225 accountName = conf->readEntry( "Account" );
226 server = conf->readEntry( "Server" ); 226 server = conf->readEntry( "Server" );
227 port = conf->readEntry( "Port" ); 227 port = conf->readEntry( "Port" );
228 ssl = conf->readBoolEntry( "SSL" ); 228 ssl = conf->readBoolEntry( "SSL" );
229 user = conf->readEntry( "User" ); 229 user = conf->readEntry( "User" );
230 password = conf->readEntryCrypt( "Password" ); 230 password = conf->readEntryCrypt( "Password" );
231} 231}
232 232
233void POP3account::save() 233void POP3account::save()
234{ 234{
235 qDebug( "saving " + getFileName() ); 235 qDebug( "saving " + getFileName() );
236 Settings::checkDirectory(); 236 Settings::checkDirectory();
237 237
238 Config *conf = new Config( getFileName(), Config::File ); 238 Config *conf = new Config( getFileName(), Config::File );
239 conf->setGroup( "POP3 Account" ); 239 conf->setGroup( "POP3 Account" );
240 conf->writeEntry( "Account", accountName ); 240 conf->writeEntry( "Account", accountName );
241 conf->writeEntry( "Server", server ); 241 conf->writeEntry( "Server", server );
242 conf->writeEntry( "Port", port ); 242 conf->writeEntry( "Port", port );
243 conf->writeEntry( "SSL", ssl ); 243 conf->writeEntry( "SSL", ssl );
244 conf->writeEntry( "User", user ); 244 conf->writeEntry( "User", user );
245 conf->writeEntryCrypt( "Password", password ); 245 conf->writeEntryCrypt( "Password", password );
246 conf->write(); 246 conf->write();
247} 247}
248 248
249 249
250QString POP3account::getFileName() 250QString POP3account::getFileName()
251{ 251{
252 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; 252 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file;
253} 253}
254 254
255SMTPaccount::SMTPaccount() 255SMTPaccount::SMTPaccount()
256 : Account() 256 : Account()
257{ 257{
258 file = SMTPaccount::getUniqueFileName(); 258 file = SMTPaccount::getUniqueFileName();
259 accountName = "New SMTP Account"; 259 accountName = "New SMTP Account";
260 ssl = false; 260 ssl = false;
261 login = false; 261 login = false;
262 useCC = false; 262 useCC = false;
263 useBCC = false; 263 useBCC = false;
264 useReply = false; 264 useReply = false;
265 type = "SMTP"; 265 type = "SMTP";
266 port = SMTP_PORT; 266 port = SMTP_PORT;
267} 267}
268 268
269SMTPaccount::SMTPaccount( QString filename ) 269SMTPaccount::SMTPaccount( QString filename )
270 : Account() 270 : Account()
271{ 271{
272 file = filename; 272 file = filename;
273 accountName = "New SMTP Account"; 273 accountName = "New SMTP Account";
274 ssl = false; 274 ssl = false;
275 login = false; 275 login = false;
276 useCC = false;
277 useBCC = false;
278 useReply = false;
279 type = "SMTP"; 276 type = "SMTP";
280 port = SMTP_PORT; 277 port = SMTP_PORT;
281} 278}
282 279
283QString SMTPaccount::getUniqueFileName() 280QString SMTPaccount::getUniqueFileName()
284{ 281{
285 int num = 0; 282 int num = 0;
286 QString unique; 283 QString unique;
287 284
288 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 285 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
289 286
290 QStringList imap = dir.entryList( "smtp-*" ); 287 QStringList imap = dir.entryList( "smtp-*" );
291 do { 288 do {
292 unique.setNum( num++ ); 289 unique.setNum( num++ );
293 } while ( imap.contains( "smtp-" + unique ) > 0 ); 290 } while ( imap.contains( "smtp-" + unique ) > 0 );
294 291
295 return unique; 292 return unique;
296} 293}
297 294
298void SMTPaccount::read() 295void SMTPaccount::read()
299{ 296{
300 Config *conf = new Config( getFileName(), Config::File ); 297 Config *conf = new Config( getFileName(), Config::File );
301 conf->setGroup( "SMTP Account" ); 298 conf->setGroup( "SMTP Account" );
302 accountName = conf->readEntry( "Account" ); 299 accountName = conf->readEntry( "Account" );
303 server = conf->readEntry( "Server" ); 300 server = conf->readEntry( "Server" );
304 port = conf->readEntry( "Port" ); 301 port = conf->readEntry( "Port" );
305 ssl = conf->readBoolEntry( "SSL" ); 302 ssl = conf->readBoolEntry( "SSL" );
306 login = conf->readBoolEntry( "Login" ); 303 login = conf->readBoolEntry( "Login" );
307 user = conf->readEntry( "User" ); 304 user = conf->readEntry( "User" );
308 password = conf->readEntryCrypt( "Password" ); 305 password = conf->readEntryCrypt( "Password" );
309 useCC = conf->readBoolEntry( "useCC" );
310 useBCC = conf->readBoolEntry( "useBCC" );
311 useReply = conf->readBoolEntry( "useReply" );
312 name = conf->readEntry( "Name" );
313 mail = conf->readEntry( "Mail" );
314 org = conf->readEntry( "Org" );
315 cc = conf->readEntry( "CC" );
316 bcc = conf->readEntry( "BCC" );
317 reply = conf->readEntry( "Reply" );
318 signature = conf->readEntry( "Signature" );
319 signature = signature.replace( QRegExp( "<br>" ), "\n" );
320} 306}
321 307
322void SMTPaccount::save() 308void SMTPaccount::save()
323{ 309{
324 qDebug( "saving " + getFileName() ); 310 qDebug( "saving " + getFileName() );
325 Settings::checkDirectory(); 311 Settings::checkDirectory();
326 312
327 Config *conf = new Config( getFileName(), Config::File ); 313 Config *conf = new Config( getFileName(), Config::File );
328 conf->setGroup( "SMTP Account" ); 314 conf->setGroup( "SMTP Account" );
329 conf->writeEntry( "Account", accountName ); 315 conf->writeEntry( "Account", accountName );
330 conf->writeEntry( "Server", server ); 316 conf->writeEntry( "Server", server );
331 conf->writeEntry( "Port", port ); 317 conf->writeEntry( "Port", port );
332 conf->writeEntry( "SSL", ssl ); 318 conf->writeEntry( "SSL", ssl );
333 conf->writeEntry( "Login", login ); 319 conf->writeEntry( "Login", login );
334 conf->writeEntry( "User", user ); 320 conf->writeEntry( "User", user );
335 conf->writeEntryCrypt( "Password", password ); 321 conf->writeEntryCrypt( "Password", password );
336 conf->writeEntry( "useCC", useCC );
337 conf->writeEntry( "useBCC", useBCC );
338 conf->writeEntry( "useReply", useReply );
339 conf->writeEntry( "Name", name );
340 conf->writeEntry( "Mail", mail );
341 conf->writeEntry( "Org", org );
342 conf->writeEntry( "CC", cc );
343 conf->writeEntry( "BCC", bcc );
344 conf->writeEntry( "Reply", reply );
345 conf->writeEntry( "Signature",
346 signature.replace( QRegExp( "\\n" ), "<br>" ) );
347 conf->write(); 322 conf->write();
348} 323}
349 324
350 325
351QString SMTPaccount::getFileName() 326QString SMTPaccount::getFileName()
352{ 327{
353 return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; 328 return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file;
354} 329}
355 330
356NNTPaccount::NNTPaccount() 331NNTPaccount::NNTPaccount()
357 : Account() 332 : Account()
358{ 333{
359 file = NNTPaccount::getUniqueFileName(); 334 file = NNTPaccount::getUniqueFileName();
360 accountName = "New NNTP Account"; 335 accountName = "New NNTP Account";
361 ssl = false; 336 ssl = false;
362 login = false; 337 login = false;
363 type = "NNTP"; 338 type = "NNTP";
364 port = NNTP_PORT; 339 port = NNTP_PORT;
365} 340}
366 341
367NNTPaccount::NNTPaccount( QString filename ) 342NNTPaccount::NNTPaccount( QString filename )
368 : Account() 343 : Account()
369{ 344{
370 file = filename; 345 file = filename;
371 accountName = "New NNTP Account"; 346 accountName = "New NNTP Account";
372 ssl = false; 347 ssl = false;
373 login = false; 348 login = false;
374 type = "NNTP"; 349 type = "NNTP";
375 port = NNTP_PORT; 350 port = NNTP_PORT;
376} 351}
377 352
378QString NNTPaccount::getUniqueFileName() 353QString NNTPaccount::getUniqueFileName()
379{ 354{
380 int num = 0; 355 int num = 0;
381 QString unique; 356 QString unique;
382 357
383 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 358 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
384 359
385 QStringList imap = dir.entryList( "nntp-*" ); 360 QStringList imap = dir.entryList( "nntp-*" );
386 do { 361 do {
387 unique.setNum( num++ ); 362 unique.setNum( num++ );
388 } while ( imap.contains( "nntp-" + unique ) > 0 ); 363 } while ( imap.contains( "nntp-" + unique ) > 0 );
389 364
390 return unique; 365 return unique;
391} 366}
392 367
393void NNTPaccount::read() 368void NNTPaccount::read()
394{ 369{
395 Config *conf = new Config( getFileName(), Config::File ); 370 Config *conf = new Config( getFileName(), Config::File );
396 conf->setGroup( "NNTP Account" ); 371 conf->setGroup( "NNTP Account" );
397 accountName = conf->readEntry( "Account" ); 372 accountName = conf->readEntry( "Account" );
398 server = conf->readEntry( "Server" ); 373 server = conf->readEntry( "Server" );
399 port = conf->readEntry( "Port" ); 374 port = conf->readEntry( "Port" );
400 ssl = conf->readBoolEntry( "SSL" ); 375 ssl = conf->readBoolEntry( "SSL" );
401 login = conf->readBoolEntry( "Login" ); 376 login = conf->readBoolEntry( "Login" );
402 user = conf->readEntry( "User" ); 377 user = conf->readEntry( "User" );
403 password = conf->readEntryCrypt( "Password" ); 378 password = conf->readEntryCrypt( "Password" );
404} 379}
405 380
406void NNTPaccount::save() 381void NNTPaccount::save()
407{ 382{
408 qDebug( "saving " + getFileName() ); 383 qDebug( "saving " + getFileName() );
409 Settings::checkDirectory(); 384 Settings::checkDirectory();
410 385
411 Config *conf = new Config( getFileName(), Config::File ); 386 Config *conf = new Config( getFileName(), Config::File );
412 conf->setGroup( "NNTP Account" ); 387 conf->setGroup( "NNTP Account" );
413 conf->writeEntry( "Account", accountName ); 388 conf->writeEntry( "Account", accountName );
414 conf->writeEntry( "Server", server ); 389 conf->writeEntry( "Server", server );
415 conf->writeEntry( "Port", port ); 390 conf->writeEntry( "Port", port );
416 conf->writeEntry( "SSL", ssl ); 391 conf->writeEntry( "SSL", ssl );
417 conf->writeEntry( "Login", login ); 392 conf->writeEntry( "Login", login );
418 conf->writeEntry( "User", user ); 393 conf->writeEntry( "User", user );
419 conf->writeEntryCrypt( "Password", password ); 394 conf->writeEntryCrypt( "Password", password );
420 conf->write(); 395 conf->write();
421} 396}
422 397
423 398
424QString NNTPaccount::getFileName() 399QString NNTPaccount::getFileName()
425{ 400{
426 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; 401 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file;
427} 402}
428 403
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
@@ -1,166 +1,146 @@
1#ifndef SETTINGS_H 1#ifndef SETTINGS_H
2#define SETTINGS_H 2#define SETTINGS_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7class Account 7class Account
8{ 8{
9 9
10public: 10public:
11 Account(); 11 Account();
12 virtual ~Account() {} 12 virtual ~Account() {}
13 13
14 void remove(); 14 void remove();
15 void setAccountName( QString name ) { accountName = name; } 15 void setAccountName( QString name ) { accountName = name; }
16 const QString&getAccountName()const{ return accountName; } 16 const QString&getAccountName()const{ return accountName; }
17 const QString&getType()const{ return type; } 17 const QString&getType()const{ return type; }
18 18
19 void setServer(const QString&str){ server = str; } 19 void setServer(const QString&str){ server = str; }
20 const QString&getServer()const{ return server; } 20 const QString&getServer()const{ return server; }
21 21
22 void setPort(const QString&str) { port = str; } 22 void setPort(const QString&str) { port = str; }
23 const QString&getPort()const{ return port; } 23 const QString&getPort()const{ return port; }
24 24
25 void setUser(const QString&str){ user = str; } 25 void setUser(const QString&str){ user = str; }
26 const QString&getUser()const{ return user; } 26 const QString&getUser()const{ return user; }
27 27
28 void setPassword(const QString&str) { password = str; } 28 void setPassword(const QString&str) { password = str; }
29 const QString&getPassword()const { return password; } 29 const QString&getPassword()const { return password; }
30 30
31 void setSSL( bool b ) { ssl = b; } 31 void setSSL( bool b ) { ssl = b; }
32 bool getSSL() { return ssl; } 32 bool getSSL() { return ssl; }
33 33
34 virtual QString getFileName() { return accountName; } 34 virtual QString getFileName() { return accountName; }
35 virtual void read() { qDebug( "base reading..." ); } 35 virtual void read() { qDebug( "base reading..." ); }
36 virtual void save() { qDebug( "base saving..." ); } 36 virtual void save() { qDebug( "base saving..." ); }
37 37
38protected: 38protected:
39 QString accountName, type, server, port, user, password; 39 QString accountName, type, server, port, user, password;
40 bool ssl; 40 bool ssl;
41 41
42}; 42};
43 43
44class IMAPaccount : public Account 44class IMAPaccount : public Account
45{ 45{
46 46
47public: 47public:
48 IMAPaccount(); 48 IMAPaccount();
49 IMAPaccount( QString filename ); 49 IMAPaccount( QString filename );
50 50
51 static QString getUniqueFileName(); 51 static QString getUniqueFileName();
52 52
53 virtual void read(); 53 virtual void read();
54 virtual void save(); 54 virtual void save();
55 virtual QString getFileName(); 55 virtual QString getFileName();
56 56
57 void setPrefix(const QString&str) {prefix=str;} 57 void setPrefix(const QString&str) {prefix=str;}
58 const QString&getPrefix()const{return prefix;} 58 const QString&getPrefix()const{return prefix;}
59 59
60private: 60private:
61 QString file,prefix; 61 QString file,prefix;
62 62
63}; 63};
64 64
65class POP3account : public Account 65class POP3account : public Account
66{ 66{
67 67
68public: 68public:
69 POP3account(); 69 POP3account();
70 POP3account( QString filename ); 70 POP3account( QString filename );
71 71
72 static QString getUniqueFileName(); 72 static QString getUniqueFileName();
73 73
74 virtual void read(); 74 virtual void read();
75 virtual void save(); 75 virtual void save();
76 virtual QString getFileName(); 76 virtual QString getFileName();
77 77
78private: 78private:
79 QString file; 79 QString file;
80 80
81}; 81};
82 82
83class SMTPaccount : public Account 83class SMTPaccount : public Account
84{ 84{
85 85
86public: 86public:
87 SMTPaccount(); 87 SMTPaccount();
88 SMTPaccount( QString filename ); 88 SMTPaccount( QString filename );
89 89
90 static QString getUniqueFileName(); 90 static QString getUniqueFileName();
91 91
92 virtual void read(); 92 virtual void read();
93 virtual void save(); 93 virtual void save();
94 virtual QString getFileName(); 94 virtual QString getFileName();
95 95
96 void setName( QString str ) { name = str; }
97 QString getName() { return name; }
98 void setMail( QString str ) { mail = str; }
99 QString getMail() { return mail; }
100 void setOrg( QString str ) { org = str; }
101 QString getOrg() { return org; }
102 void setUseCC( bool b ) { useCC = b; }
103 bool getUseCC() { return useCC; }
104 void setCC( QString str ) { cc = str; }
105 QString getCC() { return cc; }
106 void setUseBCC( bool b ) { useBCC = b; }
107 bool getUseBCC() { return useBCC; }
108 void setBCC( QString str ) { bcc = str; }
109 QString getBCC() { return bcc; }
110 void setUseReply( bool b ) { useReply = b; }
111 bool getUseReply() { return useReply; }
112 void setReply( QString str ) { reply = str; }
113 QString getReply() { return reply; }
114 void setSignature( QString str ) { signature = str; }
115 QString getSignature() { return signature; }
116 void setLogin( bool b ) { login = b; } 96 void setLogin( bool b ) { login = b; }
117 bool getLogin() { return login; } 97 bool getLogin() { return login; }
118 98
119private: 99private:
120 QString file, name, mail, org, cc, bcc, reply, signature; 100 QString file, name, mail, org, cc, bcc, reply, signature;
121 bool useCC, useBCC, useReply, login; 101 bool useCC, useBCC, useReply, login;
122 102
123}; 103};
124 104
125class NNTPaccount : public Account 105class NNTPaccount : public Account
126{ 106{
127 107
128public: 108public:
129 NNTPaccount(); 109 NNTPaccount();
130 NNTPaccount( QString filename ); 110 NNTPaccount( QString filename );
131 111
132 static QString getUniqueFileName(); 112 static QString getUniqueFileName();
133 113
134 virtual void read(); 114 virtual void read();
135 virtual void save(); 115 virtual void save();
136 virtual QString getFileName(); 116 virtual QString getFileName();
137 117
138 void setLogin( bool b ) { login = b; } 118 void setLogin( bool b ) { login = b; }
139 bool getLogin() { return login; } 119 bool getLogin() { return login; }
140 120
141private: 121private:
142 QString file; 122 QString file;
143 bool login; 123 bool login;
144 124
145}; 125};
146 126
147class Settings : public QObject 127class Settings : public QObject
148{ 128{
149 Q_OBJECT 129 Q_OBJECT
150 130
151public: 131public:
152 Settings(); 132 Settings();
153 QList<Account> getAccounts(); 133 QList<Account> getAccounts();
154 void addAccount(Account *account); 134 void addAccount(Account *account);
155 void delAccount(Account *account); 135 void delAccount(Account *account);
156 void saveAccounts(); 136 void saveAccounts();
157 void readAccounts(); 137 void readAccounts();
158 static void checkDirectory(); 138 static void checkDirectory();
159 139
160private: 140private:
161 void updateAccounts(); 141 void updateAccounts();
162 QList<Account> accounts; 142 QList<Account> accounts;
163 143
164}; 144};
165 145
166#endif 146#endif
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
@@ -1,726 +1,710 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <sys/stat.h> 2#include <sys/stat.h>
3#include <sys/types.h> 3#include <sys/types.h>
4#include <unistd.h> 4#include <unistd.h>
5#include <fcntl.h> 5#include <fcntl.h>
6#include <string.h> 6#include <string.h>
7#include <qdir.h> 7#include <qdir.h>
8#include <qt.h> 8#include <qt.h>
9 9
10#include <libetpan/libetpan.h> 10#include <libetpan/libetpan.h>
11 11
12#include "smtpwrapper.h" 12#include "smtpwrapper.h"
13#include "mailwrapper.h" 13#include "mailwrapper.h"
14#include "mboxwrapper.h" 14#include "mboxwrapper.h"
15#include "logindialog.h" 15#include "logindialog.h"
16#include "mailtypes.h" 16#include "mailtypes.h"
17#include "defines.h" 17#include "defines.h"
18#include "sendmailprogress.h" 18#include "sendmailprogress.h"
19 19
20progressMailSend*SMTPwrapper::sendProgress = 0; 20progressMailSend*SMTPwrapper::sendProgress = 0;
21 21
22SMTPwrapper::SMTPwrapper( Settings *s ) 22SMTPwrapper::SMTPwrapper( Settings *s )
23 : QObject() 23 : QObject()
24{ 24{
25 settings = s; 25 settings = s;
26} 26}
27 27
28QString SMTPwrapper::mailsmtpError( int errnum ) 28QString SMTPwrapper::mailsmtpError( int errnum )
29{ 29{
30 switch ( errnum ) { 30 switch ( errnum ) {
31 case MAILSMTP_NO_ERROR: 31 case MAILSMTP_NO_ERROR:
32 return tr( "No error" ); 32 return tr( "No error" );
33 case MAILSMTP_ERROR_UNEXPECTED_CODE: 33 case MAILSMTP_ERROR_UNEXPECTED_CODE:
34 return tr( "Unexpected error code" ); 34 return tr( "Unexpected error code" );
35 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 35 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
36 return tr( "Service not available" ); 36 return tr( "Service not available" );
37 case MAILSMTP_ERROR_STREAM: 37 case MAILSMTP_ERROR_STREAM:
38 return tr( "Stream error" ); 38 return tr( "Stream error" );
39 case MAILSMTP_ERROR_HOSTNAME: 39 case MAILSMTP_ERROR_HOSTNAME:
40 return tr( "gethostname() failed" ); 40 return tr( "gethostname() failed" );
41 case MAILSMTP_ERROR_NOT_IMPLEMENTED: 41 case MAILSMTP_ERROR_NOT_IMPLEMENTED:
42 return tr( "Not implemented" ); 42 return tr( "Not implemented" );
43 case MAILSMTP_ERROR_ACTION_NOT_TAKEN: 43 case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
44 return tr( "Error, action not taken" ); 44 return tr( "Error, action not taken" );
45 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: 45 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
46 return tr( "Data exceeds storage allocation" ); 46 return tr( "Data exceeds storage allocation" );
47 case MAILSMTP_ERROR_IN_PROCESSING: 47 case MAILSMTP_ERROR_IN_PROCESSING:
48 return tr( "Error in processing" ); 48 return tr( "Error in processing" );
49 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: 49 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
50 // return tr( "Insufficient system storage" ); 50 // return tr( "Insufficient system storage" );
51 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: 51 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
52 return tr( "Mailbox unavailable" ); 52 return tr( "Mailbox unavailable" );
53 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: 53 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
54 return tr( "Mailbox name not allowed" ); 54 return tr( "Mailbox name not allowed" );
55 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: 55 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
56 return tr( "Bad command sequence" ); 56 return tr( "Bad command sequence" );
57 case MAILSMTP_ERROR_USER_NOT_LOCAL: 57 case MAILSMTP_ERROR_USER_NOT_LOCAL:
58 return tr( "User not local" ); 58 return tr( "User not local" );
59 case MAILSMTP_ERROR_TRANSACTION_FAILED: 59 case MAILSMTP_ERROR_TRANSACTION_FAILED:
60 return tr( "Transaction failed" ); 60 return tr( "Transaction failed" );
61 case MAILSMTP_ERROR_MEMORY: 61 case MAILSMTP_ERROR_MEMORY:
62 return tr( "Memory error" ); 62 return tr( "Memory error" );
63 case MAILSMTP_ERROR_CONNECTION_REFUSED: 63 case MAILSMTP_ERROR_CONNECTION_REFUSED:
64 return tr( "Connection refused" ); 64 return tr( "Connection refused" );
65 default: 65 default:
66 return tr( "Unknown error code" ); 66 return tr( "Unknown error code" );
67 } 67 }
68} 68}
69 69
70mailimf_mailbox *SMTPwrapper::newMailbox(const QString&name, const QString&mail ) 70mailimf_mailbox *SMTPwrapper::newMailbox(const QString&name, const QString&mail )
71{ 71{
72 return mailimf_mailbox_new( strdup( name.latin1() ), 72 return mailimf_mailbox_new( strdup( name.latin1() ),
73 strdup( mail.latin1() ) ); 73 strdup( mail.latin1() ) );
74} 74}
75 75
76mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) 76mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr )
77{ 77{
78 mailimf_address_list *addresses; 78 mailimf_address_list *addresses;
79 79
80 if ( addr.isEmpty() ) return NULL; 80 if ( addr.isEmpty() ) return NULL;
81 81
82 addresses = mailimf_address_list_new_empty(); 82 addresses = mailimf_address_list_new_empty();
83 83
84 bool literal_open = false; 84 bool literal_open = false;
85 unsigned int startpos = 0; 85 unsigned int startpos = 0;
86 QStringList list; 86 QStringList list;
87 QString s; 87 QString s;
88 unsigned int i = 0; 88 unsigned int i = 0;
89 for (; i < addr.length();++i) { 89 for (; i < addr.length();++i) {
90 switch (addr[i]) { 90 switch (addr[i]) {
91 case '\"': 91 case '\"':
92 literal_open = !literal_open; 92 literal_open = !literal_open;
93 break; 93 break;
94 case ',': 94 case ',':
95 if (!literal_open) { 95 if (!literal_open) {
96 s = addr.mid(startpos,i-startpos); 96 s = addr.mid(startpos,i-startpos);
97 if (!s.isEmpty()) { 97 if (!s.isEmpty()) {
98 list.append(s); 98 list.append(s);
99 qDebug("Appended %s",s.latin1()); 99 qDebug("Appended %s",s.latin1());
100 } 100 }
101 // !!!! this is a MUST BE! 101 // !!!! this is a MUST BE!
102 startpos = ++i; 102 startpos = ++i;
103 } 103 }
104 break; 104 break;
105 default: 105 default:
106 break; 106 break;
107 } 107 }
108 } 108 }
109 s = addr.mid(startpos,i-startpos); 109 s = addr.mid(startpos,i-startpos);
110 if (!s.isEmpty()) { 110 if (!s.isEmpty()) {
111 list.append(s); 111 list.append(s);
112 qDebug("Appended %s",s.latin1()); 112 qDebug("Appended %s",s.latin1());
113 } 113 }
114 QStringList::Iterator it; 114 QStringList::Iterator it;
115 for ( it = list.begin(); it != list.end(); it++ ) { 115 for ( it = list.begin(); it != list.end(); it++ ) {
116 int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); 116 int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() );
117 if ( err != MAILIMF_NO_ERROR ) { 117 if ( err != MAILIMF_NO_ERROR ) {
118 qDebug( "Error parsing" ); 118 qDebug( "Error parsing" );
119 qDebug( *it ); 119 qDebug( *it );
120 } else { 120 } else {
121 qDebug( "Parse success! %s",(*it).latin1()); 121 qDebug( "Parse success! %s",(*it).latin1());
122 } 122 }
123 } 123 }
124 return addresses; 124 return addresses;
125} 125}
126 126
127mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) 127mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail )
128{ 128{
129 mailimf_fields *fields; 129 mailimf_fields *fields;
130 mailimf_field *xmailer; 130 mailimf_field *xmailer;
131 mailimf_mailbox *sender, *fromBox; 131 mailimf_mailbox *sender=0,*fromBox=0;
132 mailimf_mailbox_list *from; 132 mailimf_mailbox_list *from=0;
133 mailimf_address_list *to, *cc, *bcc, *reply; 133 mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0;
134 char *subject = strdup( mail.getSubject().latin1() ); 134 char *subject = strdup( mail.getSubject().latin1() );
135 int err; 135 int err;
136 136
137 sender = newMailbox( mail.getName(), mail.getMail() ); 137 sender = newMailbox( mail.getName(), mail.getMail() );
138 if ( sender == NULL ) goto err_free; 138 if ( sender == NULL ) goto err_free;
139 139
140 fromBox = newMailbox( mail.getName(), mail.getMail() ); 140 fromBox = newMailbox( mail.getName(), mail.getMail() );
141 if ( fromBox == NULL ) goto err_free_sender; 141 if ( fromBox == NULL ) goto err_free_sender;
142 142
143 from = mailimf_mailbox_list_new_empty(); 143 from = mailimf_mailbox_list_new_empty();
144 if ( from == NULL ) goto err_free_fromBox; 144 if ( from == NULL ) goto err_free_fromBox;
145 145
146 err = mailimf_mailbox_list_add( from, fromBox ); 146 err = mailimf_mailbox_list_add( from, fromBox );
147 if ( err != MAILIMF_NO_ERROR ) goto err_free_from; 147 if ( err != MAILIMF_NO_ERROR ) goto err_free_from;
148 148
149 to = parseAddresses( mail.getTo() ); 149 to = parseAddresses( mail.getTo() );
150 if ( to == NULL ) goto err_free_from; 150 if ( to == NULL ) goto err_free_from;
151 151
152 cc = parseAddresses( mail.getCC() ); 152 cc = parseAddresses( mail.getCC() );
153 bcc = parseAddresses( mail.getBCC() ); 153 bcc = parseAddresses( mail.getBCC() );
154 reply = parseAddresses( mail.getReply() ); 154 reply = parseAddresses( mail.getReply() );
155 155
156 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, 156 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc,
157 NULL, NULL, subject ); 157 NULL, NULL, subject );
158 if ( fields == NULL ) goto err_free_reply; 158 if ( fields == NULL ) goto err_free_reply;
159 159
160 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), 160 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ),
161 strdup( USER_AGENT ) ); 161 strdup( USER_AGENT ) );
162 if ( xmailer == NULL ) goto err_free_fields; 162 if ( xmailer == NULL ) goto err_free_fields;
163 163
164 err = mailimf_fields_add( fields, xmailer ); 164 err = mailimf_fields_add( fields, xmailer );
165 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; 165 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer;
166 166
167 return fields; // Success :) 167 return fields; // Success :)
168 168
169err_free_xmailer: 169err_free_xmailer:
170 mailimf_field_free( xmailer ); 170 if (xmailer) mailimf_field_free( xmailer );
171err_free_fields: 171err_free_fields:
172 mailimf_fields_free( fields ); 172 if (fields) mailimf_fields_free( fields );
173err_free_reply: 173err_free_reply:
174 mailimf_address_list_free( reply ); 174 if (reply) mailimf_address_list_free( reply );
175 mailimf_address_list_free( bcc ); 175 if (bcc) mailimf_address_list_free( bcc );
176 mailimf_address_list_free( cc ); 176 if (cc) mailimf_address_list_free( cc );
177 mailimf_address_list_free( to ); 177 if (to) mailimf_address_list_free( to );
178err_free_from: 178err_free_from:
179 mailimf_mailbox_list_free( from ); 179 if (from) mailimf_mailbox_list_free( from );
180err_free_fromBox: 180err_free_fromBox:
181 mailimf_mailbox_free( fromBox ); 181 mailimf_mailbox_free( fromBox );
182err_free_sender: 182err_free_sender:
183 mailimf_mailbox_free( sender ); 183 if (sender) mailimf_mailbox_free( sender );
184err_free: 184err_free:
185 free( subject ); 185 if (subject) free( subject );
186 qDebug( "createImfFields - error" ); 186 qDebug( "createImfFields - error" );
187 187
188 return NULL; // Error :( 188 return NULL; // Error :(
189} 189}
190 190
191mailmime *SMTPwrapper::buildTxtPart(const QString&str ) 191mailmime *SMTPwrapper::buildTxtPart(const QString&str )
192{ 192{
193 mailmime *txtPart; 193 mailmime *txtPart;
194 mailmime_fields *fields; 194 mailmime_fields *fields;
195 mailmime_content *content; 195 mailmime_content *content;
196 mailmime_parameter *param; 196 mailmime_parameter *param;
197 int err; 197 int err;
198 198
199 param = mailmime_parameter_new( strdup( "charset" ), 199 param = mailmime_parameter_new( strdup( "charset" ),
200 strdup( "iso-8859-1" ) ); 200 strdup( "iso-8859-1" ) );
201 if ( param == NULL ) goto err_free; 201 if ( param == NULL ) goto err_free;
202 202
203 content = mailmime_content_new_with_str( "text/plain" ); 203 content = mailmime_content_new_with_str( "text/plain" );
204 if ( content == NULL ) goto err_free_param; 204 if ( content == NULL ) goto err_free_param;
205 205
206 err = clist_append( content->ct_parameters, param ); 206 err = clist_append( content->ct_parameters, param );
207 if ( err != MAILIMF_NO_ERROR ) goto err_free_content; 207 if ( err != MAILIMF_NO_ERROR ) goto err_free_content;
208 208
209 fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_QUOTED_PRINTABLE); 209 fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT);
210 if ( fields == NULL ) goto err_free_content; 210 if ( fields == NULL ) goto err_free_content;
211 211
212 txtPart = mailmime_new_empty( content, fields ); 212 txtPart = mailmime_new_empty( content, fields );
213 if ( txtPart == NULL ) goto err_free_fields; 213 if ( txtPart == NULL ) goto err_free_fields;
214 214
215 err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); 215 err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() );
216 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 216 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
217 217
218 return txtPart; // Success :) 218 return txtPart; // Success :)
219 219
220err_free_txtPart: 220err_free_txtPart:
221 mailmime_free( txtPart ); 221 mailmime_free( txtPart );
222err_free_fields: 222err_free_fields:
223 mailmime_fields_free( fields ); 223 mailmime_fields_free( fields );
224err_free_content: 224err_free_content:
225 mailmime_content_free( content ); 225 mailmime_content_free( content );
226err_free_param: 226err_free_param:
227 mailmime_parameter_free( param ); 227 mailmime_parameter_free( param );
228err_free: 228err_free:
229 qDebug( "buildTxtPart - error" ); 229 qDebug( "buildTxtPart - error" );
230 230
231 return NULL; // Error :( 231 return NULL; // Error :(
232} 232}
233 233
234mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) 234mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent )
235{ 235{
236 mailmime * filePart = 0; 236 mailmime * filePart = 0;
237 mailmime_fields * fields = 0; 237 mailmime_fields * fields = 0;
238 mailmime_content * content = 0; 238 mailmime_content * content = 0;
239 mailmime_parameter * param = 0; 239 mailmime_parameter * param = 0;
240 char*name = 0; 240 char*name = 0;
241 char*file = 0; 241 char*file = 0;
242 int err; 242 int err;
243 243
244 int pos = filename.findRev( '/' ); 244 int pos = filename.findRev( '/' );
245 245
246 if (filename.length()>0) { 246 if (filename.length()>0) {
247 QString tmp = filename.right( filename.length() - ( pos + 1 ) ); 247 QString tmp = filename.right( filename.length() - ( pos + 1 ) );
248 name = strdup( tmp.latin1() ); // just filename 248 name = strdup( tmp.latin1() ); // just filename
249 file = strdup( filename.latin1() ); // full name with path 249 file = strdup( filename.latin1() ); // full name with path
250 } 250 }
251 251
252 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; 252 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT;
253 int mechanism = MAILMIME_MECHANISM_BASE64; 253 int mechanism = MAILMIME_MECHANISM_BASE64;
254 254
255 if ( mimetype.startsWith( "text/" ) ) { 255 if ( mimetype.startsWith( "text/" ) ) {
256 param = mailmime_parameter_new( strdup( "charset" ), 256 param = mailmime_parameter_new( strdup( "charset" ),
257 strdup( "iso-8859-1" ) ); 257 strdup( "iso-8859-1" ) );
258 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 258 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
259 } 259 }
260 260
261 fields = mailmime_fields_new_filename( 261 fields = mailmime_fields_new_filename(
262 disptype, name, 262 disptype, name,
263 mechanism ); 263 mechanism );
264 content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); 264 content = mailmime_content_new_with_str( (char*)mimetype.latin1() );
265 if (content!=0 && fields != 0) { 265 if (content!=0 && fields != 0) {
266 if (param) { 266 if (param) {
267 clist_append(content->ct_parameters,param); 267 clist_append(content->ct_parameters,param);
268 param = 0; 268 param = 0;
269 } 269 }
270 if (filename.length()>0) { 270 if (filename.length()>0) {
271 QFileInfo f(filename); 271 QFileInfo f(filename);
272 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); 272 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1()));
273 clist_append(content->ct_parameters,param); 273 clist_append(content->ct_parameters,param);
274 param = 0; 274 param = 0;
275 } 275 }
276 filePart = mailmime_new_empty( content, fields ); 276 filePart = mailmime_new_empty( content, fields );
277 } 277 }
278 if (filePart) { 278 if (filePart) {
279 if (filename.length()>0) { 279 if (filename.length()>0) {
280 err = mailmime_set_body_file( filePart, file ); 280 err = mailmime_set_body_file( filePart, file );
281 } else { 281 } else {
282 err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); 282 err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length());
283 } 283 }
284 if (err != MAILIMF_NO_ERROR) { 284 if (err != MAILIMF_NO_ERROR) {
285 qDebug("Error setting body with file %s",file); 285 qDebug("Error setting body with file %s",file);
286 mailmime_free( filePart ); 286 mailmime_free( filePart );
287 filePart = 0; 287 filePart = 0;
288 } 288 }
289 } 289 }
290 290
291 if (!filePart) { 291 if (!filePart) {
292 if ( param != NULL ) { 292 if ( param != NULL ) {
293 mailmime_parameter_free( param ); 293 mailmime_parameter_free( param );
294 } 294 }
295 if (content) { 295 if (content) {
296 mailmime_content_free( content ); 296 mailmime_content_free( content );
297 } 297 }
298 if (fields) { 298 if (fields) {
299 mailmime_fields_free( fields ); 299 mailmime_fields_free( fields );
300 } else { 300 } else {
301 if (name) { 301 if (name) {
302 free( name ); 302 free( name );
303 } 303 }
304 if (file) { 304 if (file) {
305 free( file ); 305 free( file );
306 } 306 }
307 } 307 }
308 } 308 }
309 return filePart; // Success :) 309 return filePart; // Success :)
310 310
311} 311}
312 312
313void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) 313void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files )
314{ 314{
315 const Attachment *it; 315 const Attachment *it;
316 unsigned int count = files.count(); 316 unsigned int count = files.count();
317 qDebug("List contains %i values",count); 317 qDebug("List contains %i values",count);
318 for ( unsigned int i = 0; i < count; ++i ) { 318 for ( unsigned int i = 0; i < count; ++i ) {
319 qDebug( "Adding file" ); 319 qDebug( "Adding file" );
320 mailmime *filePart; 320 mailmime *filePart;
321 int err; 321 int err;
322 it = ((QList<Attachment>)files).at(i); 322 it = ((QList<Attachment>)files).at(i);
323 323
324 filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); 324 filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" );
325 if ( filePart == NULL ) { 325 if ( filePart == NULL ) {
326 qDebug( "addFileParts: error adding file:" ); 326 qDebug( "addFileParts: error adding file:" );
327 qDebug( it->getFileName() ); 327 qDebug( it->getFileName() );
328 continue; 328 continue;
329 } 329 }
330 err = mailmime_smart_add_part( message, filePart ); 330 err = mailmime_smart_add_part( message, filePart );
331 if ( err != MAILIMF_NO_ERROR ) { 331 if ( err != MAILIMF_NO_ERROR ) {
332 mailmime_free( filePart ); 332 mailmime_free( filePart );
333 qDebug("error smart add"); 333 qDebug("error smart add");
334 } 334 }
335 } 335 }
336} 336}
337 337
338mailmime *SMTPwrapper::createMimeMail(const Mail &mail ) 338mailmime *SMTPwrapper::createMimeMail(const Mail &mail )
339{ 339{
340 mailmime *message, *txtPart; 340 mailmime *message, *txtPart;
341 mailimf_fields *fields; 341 mailimf_fields *fields;
342 int err; 342 int err;
343 343
344 fields = createImfFields( mail ); 344 fields = createImfFields( mail );
345 if ( fields == NULL ) goto err_free; 345 if ( fields == NULL ) goto err_free;
346 346
347 message = mailmime_new_message_data( NULL ); 347 message = mailmime_new_message_data( NULL );
348 if ( message == NULL ) goto err_free_fields; 348 if ( message == NULL ) goto err_free_fields;
349 349
350 mailmime_set_imf_fields( message, fields ); 350 mailmime_set_imf_fields( message, fields );
351 351
352 txtPart = buildTxtPart( mail.getMessage() ); 352 txtPart = buildTxtPart( mail.getMessage() );
353 353
354 if ( txtPart == NULL ) goto err_free_message; 354 if ( txtPart == NULL ) goto err_free_message;
355 355
356 err = mailmime_smart_add_part( message, txtPart ); 356 err = mailmime_smart_add_part( message, txtPart );
357 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 357 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
358 358
359 addFileParts( message, mail.getAttachments() ); 359 addFileParts( message, mail.getAttachments() );
360 360
361 return message; // Success :) 361 return message; // Success :)
362 362
363err_free_txtPart: 363err_free_txtPart:
364 mailmime_free( txtPart ); 364 mailmime_free( txtPart );
365err_free_message: 365err_free_message:
366 mailmime_free( message ); 366 mailmime_free( message );
367err_free_fields: 367err_free_fields:
368 mailimf_fields_free( fields ); 368 mailimf_fields_free( fields );
369err_free: 369err_free:
370 qDebug( "createMimeMail: error" ); 370 qDebug( "createMimeMail: error" );
371 371
372 return NULL; // Error :( 372 return NULL; // Error :(
373} 373}
374 374
375mailimf_field *SMTPwrapper::getField( mailimf_fields *fields, int type ) 375mailimf_field *SMTPwrapper::getField( mailimf_fields *fields, int type )
376{ 376{
377 mailimf_field *field; 377 mailimf_field *field;
378 clistiter *it; 378 clistiter *it;
379 379
380 it = clist_begin( fields->fld_list ); 380 it = clist_begin( fields->fld_list );
381 while ( it ) { 381 while ( it ) {
382 field = (mailimf_field *) it->data; 382 field = (mailimf_field *) it->data;
383 if ( field->fld_type == type ) { 383 if ( field->fld_type == type ) {
384 return field; 384 return field;
385 } 385 }
386 it = it->next; 386 it = it->next;
387 } 387 }
388 388
389 return NULL; 389 return NULL;
390} 390}
391 391
392void SMTPwrapper::addRcpts( clist *list, mailimf_address_list *addr_list ) 392void SMTPwrapper::addRcpts( clist *list, mailimf_address_list *addr_list )
393{ 393{
394 clistiter *it, *it2; 394 clistiter *it, *it2;
395 395
396 for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { 396 for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) {
397 mailimf_address *addr; 397 mailimf_address *addr;
398 addr = (mailimf_address *) it->data; 398 addr = (mailimf_address *) it->data;
399 399
400 if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { 400 if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) {
401 esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); 401 esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL );
402 } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { 402 } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) {
403 clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; 403 clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list;
404 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { 404 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) {
405 mailimf_mailbox *mbox; 405 mailimf_mailbox *mbox;
406 mbox = (mailimf_mailbox *) it2->data; 406 mbox = (mailimf_mailbox *) it2->data;
407 esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); 407 esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL );
408 } 408 }
409 } 409 }
410 } 410 }
411} 411}
412 412
413clist *SMTPwrapper::createRcptList( mailimf_fields *fields ) 413clist *SMTPwrapper::createRcptList( mailimf_fields *fields )
414{ 414{
415 clist *rcptList; 415 clist *rcptList;
416 mailimf_field *field; 416 mailimf_field *field;
417 417
418 rcptList = esmtp_address_list_new(); 418 rcptList = esmtp_address_list_new();
419 419
420 field = getField( fields, MAILIMF_FIELD_TO ); 420 field = getField( fields, MAILIMF_FIELD_TO );
421 if ( field && (field->fld_type == MAILIMF_FIELD_TO) 421 if ( field && (field->fld_type == MAILIMF_FIELD_TO)
422 && field->fld_data.fld_to->to_addr_list ) { 422 && field->fld_data.fld_to->to_addr_list ) {
423 addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); 423 addRcpts( rcptList, field->fld_data.fld_to->to_addr_list );
424 } 424 }
425 425
426 field = getField( fields, MAILIMF_FIELD_CC ); 426 field = getField( fields, MAILIMF_FIELD_CC );
427 if ( field && (field->fld_type == MAILIMF_FIELD_CC) 427 if ( field && (field->fld_type == MAILIMF_FIELD_CC)
428 && field->fld_data.fld_cc->cc_addr_list ) { 428 && field->fld_data.fld_cc->cc_addr_list ) {
429 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); 429 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list );
430 } 430 }
431 431
432 field = getField( fields, MAILIMF_FIELD_BCC ); 432 field = getField( fields, MAILIMF_FIELD_BCC );
433 if ( field && (field->fld_type == MAILIMF_FIELD_BCC) 433 if ( field && (field->fld_type == MAILIMF_FIELD_BCC)
434 && field->fld_data.fld_bcc->bcc_addr_list ) { 434 && field->fld_data.fld_bcc->bcc_addr_list ) {
435 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); 435 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list );
436 } 436 }
437 437
438 return rcptList; 438 return rcptList;
439} 439}
440 440
441char *SMTPwrapper::getFrom( mailimf_field *ffrom) 441char *SMTPwrapper::getFrom( mailimf_field *ffrom)
442{ 442{
443 char *from = NULL; 443 char *from = NULL;
444 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) 444 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM)
445 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { 445 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) {
446 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; 446 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list;
447 clistiter *it; 447 clistiter *it;
448 for ( it = clist_begin( cl ); it; it = it->next ) { 448 for ( it = clist_begin( cl ); it; it = it->next ) {
449 mailimf_mailbox *mb = (mailimf_mailbox *) it->data; 449 mailimf_mailbox *mb = (mailimf_mailbox *) it->data;
450 from = strdup( mb->mb_addr_spec ); 450 from = strdup( mb->mb_addr_spec );
451 } 451 }
452 } 452 }
453 453
454 return from; 454 return from;
455} 455}
456 456
457char *SMTPwrapper::getFrom( mailmime *mail ) 457char *SMTPwrapper::getFrom( mailmime *mail )
458{ 458{
459 /* no need to delete - its just a pointer to structure content */ 459 /* no need to delete - its just a pointer to structure content */
460 mailimf_field *ffrom = 0; 460 mailimf_field *ffrom = 0;
461 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); 461 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM );
462 return getFrom(ffrom); 462 return getFrom(ffrom);
463} 463}
464 464
465SMTPaccount *SMTPwrapper::getAccount(const QString&name )
466{
467 SMTPaccount *smtp;
468
469 QList<Account> list = settings->getAccounts();
470 Account *it;
471 for ( it = list.first(); it; it = list.next() ) {
472 if ( it->getType().compare( "SMTP" ) == 0 ) {
473 smtp = static_cast<SMTPaccount *>(it);
474 if ( smtp->getName()== name ) {
475 qDebug( "SMTPaccount found for" );
476 qDebug( name );
477 return smtp;
478 }
479 }
480 }
481
482 return NULL;
483}
484
485void SMTPwrapper::progress( size_t current, size_t maximum ) 465void SMTPwrapper::progress( size_t current, size_t maximum )
486{ 466{
487 if (SMTPwrapper::sendProgress) { 467 if (SMTPwrapper::sendProgress) {
488 SMTPwrapper::sendProgress->setSingleMail(current, maximum ); 468 SMTPwrapper::sendProgress->setSingleMail(current, maximum );
489 qApp->processEvents(); 469 qApp->processEvents();
490 } 470 }
491} 471}
492 472
493void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) 473void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box)
494{ 474{
495 if (!mail) return; 475 if (!mail) return;
496 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 476 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
497 MBOXwrapper*wrap = new MBOXwrapper(localfolders); 477 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
498 wrap->storeMessage(mail,length,box); 478 wrap->storeMessage(mail,length,box);
499 delete wrap; 479 delete wrap;
500} 480}
501 481
502void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) 482void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
503{ 483{
504 clist *rcpts = 0; 484 clist *rcpts = 0;
505 char *from, *data; 485 char *from, *data;
506 size_t size; 486 size_t size;
507 487
508 if ( smtp == NULL ) { 488 if ( smtp == NULL ) {
509 return; 489 return;
510 } 490 }
511 from = data = 0; 491 from = data = 0;
512 492
513 mailmessage * msg = 0; 493 mailmessage * msg = 0;
514 msg = mime_message_init(mail); 494 msg = mime_message_init(mail);
515 mime_message_set_tmpdir(msg,getenv( "HOME" )); 495 mime_message_set_tmpdir(msg,getenv( "HOME" ));
516 int r = mailmessage_fetch(msg,&data,&size); 496 int r = mailmessage_fetch(msg,&data,&size);
517 mime_message_detach_mime(msg); 497 mime_message_detach_mime(msg);
518 mailmessage_free(msg); 498 mailmessage_free(msg);
519 if (r != MAIL_NO_ERROR || !data) { 499 if (r != MAIL_NO_ERROR || !data) {
520 if (data) free(data); 500 if (data) free(data);
521 qDebug("Error fetching mime..."); 501 qDebug("Error fetching mime...");
522 return; 502 return;
523 } 503 }
524 QString tmp = data; 504 QString tmp = data;
525 tmp.replace(QRegExp("\r+",true,false),""); 505 tmp.replace(QRegExp("\r+",true,false),"");
526 msg = 0; 506 msg = 0;
527 if (later) { 507 if (later) {
528 storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); 508 storeMail((char*)tmp.data(),tmp.length(),"Outgoing");
529 if (data) free( data ); 509 if (data) free( data );
530 return; 510 return;
531 } 511 }
532 from = getFrom( mail ); 512 from = getFrom( mail );
533 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); 513 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
534 smtpSend(from,rcpts,data,size,smtp); 514 smtpSend(from,rcpts,data,size,smtp);
535 if (data) {free(data);} 515 if (data) {free(data);}
536 if (from) {free(from);} 516 if (from) {free(from);}
537 if (rcpts) smtp_address_list_free( rcpts ); 517 if (rcpts) smtp_address_list_free( rcpts );
538} 518}
539 519
540int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) 520int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp )
541{ 521{
542 char *server, *user, *pass; 522 char *server, *user, *pass;
543 bool ssl; 523 bool ssl;
544 uint16_t port; 524 uint16_t port;
545 mailsmtp *session; 525 mailsmtp *session;
546 int err,result; 526 int err,result;
547 527
548 result = 1; 528 result = 1;
549 server = user = pass = 0; 529 server = user = pass = 0;
550 server = strdup( smtp->getServer().latin1() ); 530 server = strdup( smtp->getServer().latin1() );
551 ssl = smtp->getSSL(); 531 ssl = smtp->getSSL();
552 port = smtp->getPort().toUInt(); 532 port = smtp->getPort().toUInt();
553 533
554 session = mailsmtp_new( 20, &progress ); 534 session = mailsmtp_new( 20, &progress );
555 if ( session == NULL ) goto free_mem; 535 if ( session == NULL ) goto free_mem;
556 536
557 qDebug( "Servername %s at port %i", server, port ); 537 qDebug( "Servername %s at port %i", server, port );
558 if ( ssl ) { 538 if ( ssl ) {
559 qDebug( "SSL session" ); 539 qDebug( "SSL session" );
560 err = mailsmtp_ssl_connect( session, server, port ); 540 err = mailsmtp_ssl_connect( session, server, port );
561 } else { 541 } else {
562 qDebug( "No SSL session" ); 542 qDebug( "No SSL session" );
563 err = mailsmtp_socket_connect( session, server, port ); 543 err = mailsmtp_socket_connect( session, server, port );
564 } 544 }
565 if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;} 545 if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;}
566 546
567 err = mailsmtp_init( session ); 547 err = mailsmtp_init( session );
568 if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} 548 if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;}
569 549
570 qDebug( "INIT OK" ); 550 qDebug( "INIT OK" );
571 551
572 if ( smtp->getLogin() ) { 552 if ( smtp->getLogin() ) {
573 if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { 553 if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) {
574 // get'em 554 // get'em
575 LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); 555 LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true );
576 login.show(); 556 login.show();
577 if ( QDialog::Accepted == login.exec() ) { 557 if ( QDialog::Accepted == login.exec() ) {
578 // ok 558 // ok
579 user = strdup( login.getUser().latin1() ); 559 user = strdup( login.getUser().latin1() );
580 pass = strdup( login.getPassword().latin1() ); 560 pass = strdup( login.getPassword().latin1() );
581 } else { 561 } else {
582 result = 0; goto free_con_session; 562 result = 0; goto free_con_session;
583 } 563 }
584 } else { 564 } else {
585 user = strdup( smtp->getUser().latin1() ); 565 user = strdup( smtp->getUser().latin1() );
586 pass = strdup( smtp->getPassword().latin1() ); 566 pass = strdup( smtp->getPassword().latin1() );
587 } 567 }
588 qDebug( "session->auth: %i", session->auth); 568 qDebug( "session->auth: %i", session->auth);
589 err = mailsmtp_auth( session, user, pass ); 569 err = mailsmtp_auth( session, user, pass );
590 if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); 570 if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok");
591 qDebug( "Done auth!" ); 571 qDebug( "Done auth!" );
592 } 572 }
593 573
594 err = mailsmtp_send( session, from, rcpts, data, size ); 574 err = mailsmtp_send( session, from, rcpts, data, size );
595 if ( err != MAILSMTP_NO_ERROR ) { 575 if ( err != MAILSMTP_NO_ERROR ) {
596 qDebug("Error sending mail: %s",mailsmtpError(err).latin1()); 576 qDebug("Error sending mail: %s",mailsmtpError(err).latin1());
597 result = 0; goto free_con_session; 577 result = 0; goto free_con_session;
598 } 578 }
599 579
600 qDebug( "Mail sent." ); 580 qDebug( "Mail sent." );
601 storeMail(data,size,"Sent"); 581 storeMail(data,size,"Sent");
602 582
603free_con_session: 583free_con_session:
604 mailsmtp_quit( session ); 584 mailsmtp_quit( session );
605free_mem_session: 585free_mem_session:
606 mailsmtp_free( session ); 586 mailsmtp_free( session );
607free_mem: 587free_mem:
608 if (server) free( server ); 588 if (server) free( server );
609 if ( smtp->getLogin() ) { 589 if ( smtp->getLogin() ) {
610 free( user ); 590 free( user );
611 free( pass ); 591 free( pass );
612 } 592 }
613 return result; 593 return result;
614} 594}
615 595
616void SMTPwrapper::sendMail(const Mail&mail,bool later ) 596void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later )
617{ 597{
618 mailmime * mimeMail; 598 mailmime * mimeMail;
619 599
620 SMTPaccount *smtp = getAccount(mail.getName()); 600 SMTPaccount *smtp = aSmtp;
621 601
602 if (!later && !smtp) {
603 qDebug("Didn't get any send method - giving up");
604 return;
605 }
622 mimeMail = createMimeMail(mail ); 606 mimeMail = createMimeMail(mail );
623 if ( mimeMail == NULL ) { 607 if ( mimeMail == NULL ) {
624 qDebug( "sendMail: error creating mime mail" ); 608 qDebug( "sendMail: error creating mime mail" );
625 } else { 609 } else {
626 sendProgress = new progressMailSend(); 610 sendProgress = new progressMailSend();
627 sendProgress->show(); 611 sendProgress->show();
628 sendProgress->setMaxMails(1); 612 sendProgress->setMaxMails(1);
629 smtpSend( mimeMail,later,smtp); 613 smtpSend( mimeMail,later,smtp);
630 qDebug("Clean up done"); 614 qDebug("Clean up done");
631 sendProgress->hide(); 615 sendProgress->hide();
632 delete sendProgress; 616 delete sendProgress;
633 sendProgress = 0; 617 sendProgress = 0;
634 mailmime_free( mimeMail ); 618 mailmime_free( mimeMail );
635 } 619 }
636} 620}
637 621
638int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) 622int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
639{ 623{
640 char*data = 0; 624 char*data = 0;
641 size_t length = 0; 625 size_t length = 0;
642 size_t curTok = 0; 626 size_t curTok = 0;
643 mailimf_fields *fields = 0; 627 mailimf_fields *fields = 0;
644 mailimf_field*ffrom = 0; 628 mailimf_field*ffrom = 0;
645 clist *rcpts = 0; 629 clist *rcpts = 0;
646 char*from = 0; 630 char*from = 0;
647 int res = 0; 631 int res = 0;
648 632
649 wrap->fetchRawBody(*which,&data,&length); 633 wrap->fetchRawBody(*which,&data,&length);
650 if (!data) return 0; 634 if (!data) return 0;
651 int err = mailimf_fields_parse( data, length, &curTok, &fields ); 635 int err = mailimf_fields_parse( data, length, &curTok, &fields );
652 if (err != MAILIMF_NO_ERROR) { 636 if (err != MAILIMF_NO_ERROR) {
653 free(data); 637 free(data);
654 delete wrap; 638 delete wrap;
655 return 0; 639 return 0;
656 } 640 }
657 641
658 rcpts = createRcptList( fields ); 642 rcpts = createRcptList( fields );
659 ffrom = getField(fields, MAILIMF_FIELD_FROM ); 643 ffrom = getField(fields, MAILIMF_FIELD_FROM );
660 from = getFrom(ffrom); 644 from = getFrom(ffrom);
661 645
662 qDebug("Size: %i vs. %i",length,strlen(data)); 646 qDebug("Size: %i vs. %i",length,strlen(data));
663 if (rcpts && from) { 647 if (rcpts && from) {
664 res = smtpSend(from,rcpts,data,length,smtp ); 648 res = smtpSend(from,rcpts,data,length,smtp );
665 } 649 }
666 if (fields) { 650 if (fields) {
667 mailimf_fields_free(fields); 651 mailimf_fields_free(fields);
668 fields = 0; 652 fields = 0;
669 } 653 }
670 if (data) { 654 if (data) {
671 free(data); 655 free(data);
672 } 656 }
673 if (from) { 657 if (from) {
674 free(from); 658 free(from);
675 } 659 }
676 if (rcpts) { 660 if (rcpts) {
677 smtp_address_list_free( rcpts ); 661 smtp_address_list_free( rcpts );
678 } 662 }
679 return res; 663 return res;
680} 664}
681 665
682/* this is a special fun */ 666/* this is a special fun */
683bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) 667bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
684{ 668{
685 bool returnValue = true; 669 bool returnValue = true;
686 670
687 if (!smtp) return false; 671 if (!smtp) return false;
688 672
689 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 673 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
690 MBOXwrapper*wrap = new MBOXwrapper(localfolders); 674 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
691 if (!wrap) { 675 if (!wrap) {
692 qDebug("memory error"); 676 qDebug("memory error");
693 return false; 677 return false;
694 } 678 }
695 QList<RecMail> mailsToSend; 679 QList<RecMail> mailsToSend;
696 QList<RecMail> mailsToRemove; 680 QList<RecMail> mailsToRemove;
697 QString mbox("Outgoing"); 681 QString mbox("Outgoing");
698 wrap->listMessages(mbox,mailsToSend); 682 wrap->listMessages(mbox,mailsToSend);
699 if (mailsToSend.count()==0) { 683 if (mailsToSend.count()==0) {
700 delete wrap; 684 delete wrap;
701 return false; 685 return false;
702 } 686 }
703 mailsToSend.setAutoDelete(false); 687 mailsToSend.setAutoDelete(false);
704 sendProgress = new progressMailSend(); 688 sendProgress = new progressMailSend();
705 sendProgress->show(); 689 sendProgress->show();
706 sendProgress->setMaxMails(mailsToSend.count()); 690 sendProgress->setMaxMails(mailsToSend.count());
707 691
708 while (mailsToSend.count()>0) { 692 while (mailsToSend.count()>0) {
709 if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { 693 if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) {
710 QMessageBox::critical(0,tr("Error sending mail"), 694 QMessageBox::critical(0,tr("Error sending mail"),
711 tr("Error sending queued mail - breaking")); 695 tr("Error sending queued mail - breaking"));
712 returnValue = false; 696 returnValue = false;
713 break; 697 break;
714 } 698 }
715 mailsToRemove.append(mailsToSend.at(0)); 699 mailsToRemove.append(mailsToSend.at(0));
716 mailsToSend.removeFirst(); 700 mailsToSend.removeFirst();
717 sendProgress->setCurrentMails(mailsToRemove.count()); 701 sendProgress->setCurrentMails(mailsToRemove.count());
718 } 702 }
719 sendProgress->hide(); 703 sendProgress->hide();
720 delete sendProgress; 704 delete sendProgress;
721 sendProgress = 0; 705 sendProgress = 0;
722 wrap->deleteMails(mbox,mailsToRemove); 706 wrap->deleteMails(mbox,mailsToRemove);
723 mailsToSend.setAutoDelete(true); 707 mailsToSend.setAutoDelete(true);
724 delete wrap; 708 delete wrap;
725 return returnValue; 709 return returnValue;
726} 710}
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
@@ -1,62 +1,61 @@
1#ifndef SMTPwrapper_H 1#ifndef SMTPwrapper_H
2#define SMTPwrapper_H 2#define SMTPwrapper_H
3 3
4#include <qpe/applnk.h> 4#include <qpe/applnk.h>
5 5
6#include <qbitarray.h> 6#include <qbitarray.h>
7#include <qdatetime.h> 7#include <qdatetime.h>
8#include <libetpan/clist.h> 8#include <libetpan/clist.h>
9 9
10#include "settings.h" 10#include "settings.h"
11 11
12class Mail; 12class Mail;
13class MBOXwrapper; 13class MBOXwrapper;
14class RecMail; 14class RecMail;
15class Attachment; 15class Attachment;
16struct mailimf_fields; 16struct mailimf_fields;
17struct mailimf_field; 17struct mailimf_field;
18struct mailimf_mailbox; 18struct mailimf_mailbox;
19struct mailmime; 19struct mailmime;
20struct mailimf_address_list; 20struct mailimf_address_list;
21class progressMailSend; 21class progressMailSend;
22 22
23class SMTPwrapper : public QObject 23class SMTPwrapper : public QObject
24{ 24{
25 Q_OBJECT 25 Q_OBJECT
26 26
27public: 27public:
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,SMTPaccount*smtp,bool later=false );
31 bool flushOutbox(SMTPaccount*smtp); 31 bool flushOutbox(SMTPaccount*smtp);
32 32
33 static progressMailSend*sendProgress; 33 static progressMailSend*sendProgress;
34protected: 34protected:
35 mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); 35 mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
36 mailimf_fields *createImfFields(const Mail &mail ); 36 mailimf_fields *createImfFields(const Mail &mail );
37 mailmime *createMimeMail(const Mail&mail ); 37 mailmime *createMimeMail(const Mail&mail );
38 38
39 mailimf_address_list *parseAddresses(const QString&addr ); 39 mailimf_address_list *parseAddresses(const QString&addr );
40 void addFileParts( mailmime *message,const QList<Attachment>&files ); 40 void addFileParts( mailmime *message,const QList<Attachment>&files );
41 mailmime *buildTxtPart(const QString&str ); 41 mailmime *buildTxtPart(const QString&str );
42 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); 42 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content);
43 void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); 43 void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp );
44 clist *createRcptList( mailimf_fields *fields ); 44 clist *createRcptList( mailimf_fields *fields );
45 SMTPaccount *getAccount(const QString&from );
46 45
47 static void storeMail(char*mail, size_t length, const QString&box); 46 static void storeMail(char*mail, size_t length, const QString&box);
48 static QString mailsmtpError( int err ); 47 static QString mailsmtpError( int err );
49 static void progress( size_t current, size_t maximum ); 48 static void progress( size_t current, size_t maximum );
50 static void addRcpts( clist *list, mailimf_address_list *addr_list ); 49 static void addRcpts( clist *list, mailimf_address_list *addr_list );
51 static char *getFrom( mailmime *mail ); 50 static char *getFrom( mailmime *mail );
52 static char *getFrom( mailimf_field *ffrom); 51 static char *getFrom( mailimf_field *ffrom);
53 static mailimf_field *getField( mailimf_fields *fields, int type ); 52 static mailimf_field *getField( mailimf_fields *fields, int type );
54 int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); 53 int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp );
55 54
56 void storeMail(mailmime*mail, const QString&box); 55 void storeMail(mailmime*mail, const QString&box);
57 Settings *settings; 56 Settings *settings;
58 57
59 int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); 58 int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which);
60}; 59};
61 60
62#endif 61#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
@@ -84,345 +84,320 @@ void Settings::saveAccounts()
84} 84}
85 85
86void Settings::readAccounts() 86void Settings::readAccounts()
87{ 87{
88 checkDirectory(); 88 checkDirectory();
89 Account *it; 89 Account *it;
90 90
91 for ( it = accounts.first(); it; it = accounts.next() ) { 91 for ( it = accounts.first(); it; it = accounts.next() ) {
92 it->read(); 92 it->read();
93 } 93 }
94} 94}
95 95
96Account::Account() 96Account::Account()
97{ 97{
98 accountName = "changeMe"; 98 accountName = "changeMe";
99 type = "changeMe"; 99 type = "changeMe";
100 ssl = false; 100 ssl = false;
101} 101}
102 102
103void Account::remove() 103void Account::remove()
104{ 104{
105 QFile file( getFileName() ); 105 QFile file( getFileName() );
106 file.remove(); 106 file.remove();
107} 107}
108 108
109IMAPaccount::IMAPaccount() 109IMAPaccount::IMAPaccount()
110 : Account() 110 : Account()
111{ 111{
112 file = IMAPaccount::getUniqueFileName(); 112 file = IMAPaccount::getUniqueFileName();
113 accountName = "New IMAP Account"; 113 accountName = "New IMAP Account";
114 ssl = false; 114 ssl = false;
115 type = "IMAP"; 115 type = "IMAP";
116 port = IMAP_PORT; 116 port = IMAP_PORT;
117} 117}
118 118
119IMAPaccount::IMAPaccount( QString filename ) 119IMAPaccount::IMAPaccount( QString filename )
120 : Account() 120 : Account()
121{ 121{
122 file = filename; 122 file = filename;
123 accountName = "New IMAP Account"; 123 accountName = "New IMAP Account";
124 ssl = false; 124 ssl = false;
125 type = "IMAP"; 125 type = "IMAP";
126 port = IMAP_PORT; 126 port = IMAP_PORT;
127} 127}
128 128
129QString IMAPaccount::getUniqueFileName() 129QString IMAPaccount::getUniqueFileName()
130{ 130{
131 int num = 0; 131 int num = 0;
132 QString unique; 132 QString unique;
133 133
134 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 134 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
135 135
136 QStringList imap = dir.entryList( "imap-*" ); 136 QStringList imap = dir.entryList( "imap-*" );
137 do { 137 do {
138 unique.setNum( num++ ); 138 unique.setNum( num++ );
139 } while ( imap.contains( "imap-" + unique ) > 0 ); 139 } while ( imap.contains( "imap-" + unique ) > 0 );
140 140
141 return unique; 141 return unique;
142} 142}
143 143
144void IMAPaccount::read() 144void IMAPaccount::read()
145{ 145{
146 Config *conf = new Config( getFileName(), Config::File ); 146 Config *conf = new Config( getFileName(), Config::File );
147 conf->setGroup( "IMAP Account" ); 147 conf->setGroup( "IMAP Account" );
148 accountName = conf->readEntry( "Account","" ); 148 accountName = conf->readEntry( "Account","" );
149 if (accountName.isNull()) accountName = ""; 149 if (accountName.isNull()) accountName = "";
150 server = conf->readEntry( "Server","" ); 150 server = conf->readEntry( "Server","" );
151 if (server.isNull()) server=""; 151 if (server.isNull()) server="";
152 port = conf->readEntry( "Port","" ); 152 port = conf->readEntry( "Port","" );
153 if (port.isNull()) port="143"; 153 if (port.isNull()) port="143";
154 ssl = conf->readBoolEntry( "SSL",false ); 154 ssl = conf->readBoolEntry( "SSL",false );
155 user = conf->readEntry( "User","" ); 155 user = conf->readEntry( "User","" );
156 if (user.isNull()) user = ""; 156 if (user.isNull()) user = "";
157 password = conf->readEntryCrypt( "Password","" ); 157 password = conf->readEntryCrypt( "Password","" );
158 if (password.isNull()) password = ""; 158 if (password.isNull()) password = "";
159 prefix = conf->readEntry("MailPrefix",""); 159 prefix = conf->readEntry("MailPrefix","");
160 if (prefix.isNull()) prefix = ""; 160 if (prefix.isNull()) prefix = "";
161} 161}
162 162
163void IMAPaccount::save() 163void IMAPaccount::save()
164{ 164{
165 qDebug( "saving " + getFileName() ); 165 qDebug( "saving " + getFileName() );
166 Settings::checkDirectory(); 166 Settings::checkDirectory();
167 167
168 Config *conf = new Config( getFileName(), Config::File ); 168 Config *conf = new Config( getFileName(), Config::File );
169 conf->setGroup( "IMAP Account" ); 169 conf->setGroup( "IMAP Account" );
170 conf->writeEntry( "Account", accountName ); 170 conf->writeEntry( "Account", accountName );
171 conf->writeEntry( "Server", server ); 171 conf->writeEntry( "Server", server );
172 conf->writeEntry( "Port", port ); 172 conf->writeEntry( "Port", port );
173 conf->writeEntry( "SSL", ssl ); 173 conf->writeEntry( "SSL", ssl );
174 conf->writeEntry( "User", user ); 174 conf->writeEntry( "User", user );
175 conf->writeEntryCrypt( "Password", password ); 175 conf->writeEntryCrypt( "Password", password );
176 conf->writeEntry( "MailPrefix",prefix); 176 conf->writeEntry( "MailPrefix",prefix);
177 conf->write(); 177 conf->write();
178} 178}
179 179
180 180
181QString IMAPaccount::getFileName() 181QString IMAPaccount::getFileName()
182{ 182{
183 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; 183 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file;
184} 184}
185 185
186POP3account::POP3account() 186POP3account::POP3account()
187 : Account() 187 : Account()
188{ 188{
189 file = POP3account::getUniqueFileName(); 189 file = POP3account::getUniqueFileName();
190 accountName = "New POP3 Account"; 190 accountName = "New POP3 Account";
191 ssl = false; 191 ssl = false;
192 type = "POP3"; 192 type = "POP3";
193 port = POP3_PORT; 193 port = POP3_PORT;
194} 194}
195 195
196POP3account::POP3account( QString filename ) 196POP3account::POP3account( QString filename )
197 : Account() 197 : Account()
198{ 198{
199 file = filename; 199 file = filename;
200 accountName = "New POP3 Account"; 200 accountName = "New POP3 Account";
201 ssl = false; 201 ssl = false;
202 type = "POP3"; 202 type = "POP3";
203 port = POP3_PORT; 203 port = POP3_PORT;
204} 204}
205 205
206QString POP3account::getUniqueFileName() 206QString POP3account::getUniqueFileName()
207{ 207{
208 int num = 0; 208 int num = 0;
209 QString unique; 209 QString unique;
210 210
211 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 211 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
212 212
213 QStringList imap = dir.entryList( "pop3-*" ); 213 QStringList imap = dir.entryList( "pop3-*" );
214 do { 214 do {
215 unique.setNum( num++ ); 215 unique.setNum( num++ );
216 } while ( imap.contains( "pop3-" + unique ) > 0 ); 216 } while ( imap.contains( "pop3-" + unique ) > 0 );
217 217
218 return unique; 218 return unique;
219} 219}
220 220
221void POP3account::read() 221void POP3account::read()
222{ 222{
223 Config *conf = new Config( getFileName(), Config::File ); 223 Config *conf = new Config( getFileName(), Config::File );
224 conf->setGroup( "POP3 Account" ); 224 conf->setGroup( "POP3 Account" );
225 accountName = conf->readEntry( "Account" ); 225 accountName = conf->readEntry( "Account" );
226 server = conf->readEntry( "Server" ); 226 server = conf->readEntry( "Server" );
227 port = conf->readEntry( "Port" ); 227 port = conf->readEntry( "Port" );
228 ssl = conf->readBoolEntry( "SSL" ); 228 ssl = conf->readBoolEntry( "SSL" );
229 user = conf->readEntry( "User" ); 229 user = conf->readEntry( "User" );
230 password = conf->readEntryCrypt( "Password" ); 230 password = conf->readEntryCrypt( "Password" );
231} 231}
232 232
233void POP3account::save() 233void POP3account::save()
234{ 234{
235 qDebug( "saving " + getFileName() ); 235 qDebug( "saving " + getFileName() );
236 Settings::checkDirectory(); 236 Settings::checkDirectory();
237 237
238 Config *conf = new Config( getFileName(), Config::File ); 238 Config *conf = new Config( getFileName(), Config::File );
239 conf->setGroup( "POP3 Account" ); 239 conf->setGroup( "POP3 Account" );
240 conf->writeEntry( "Account", accountName ); 240 conf->writeEntry( "Account", accountName );
241 conf->writeEntry( "Server", server ); 241 conf->writeEntry( "Server", server );
242 conf->writeEntry( "Port", port ); 242 conf->writeEntry( "Port", port );
243 conf->writeEntry( "SSL", ssl ); 243 conf->writeEntry( "SSL", ssl );
244 conf->writeEntry( "User", user ); 244 conf->writeEntry( "User", user );
245 conf->writeEntryCrypt( "Password", password ); 245 conf->writeEntryCrypt( "Password", password );
246 conf->write(); 246 conf->write();
247} 247}
248 248
249 249
250QString POP3account::getFileName() 250QString POP3account::getFileName()
251{ 251{
252 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; 252 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file;
253} 253}
254 254
255SMTPaccount::SMTPaccount() 255SMTPaccount::SMTPaccount()
256 : Account() 256 : Account()
257{ 257{
258 file = SMTPaccount::getUniqueFileName(); 258 file = SMTPaccount::getUniqueFileName();
259 accountName = "New SMTP Account"; 259 accountName = "New SMTP Account";
260 ssl = false; 260 ssl = false;
261 login = false; 261 login = false;
262 useCC = false; 262 useCC = false;
263 useBCC = false; 263 useBCC = false;
264 useReply = false; 264 useReply = false;
265 type = "SMTP"; 265 type = "SMTP";
266 port = SMTP_PORT; 266 port = SMTP_PORT;
267} 267}
268 268
269SMTPaccount::SMTPaccount( QString filename ) 269SMTPaccount::SMTPaccount( QString filename )
270 : Account() 270 : Account()
271{ 271{
272 file = filename; 272 file = filename;
273 accountName = "New SMTP Account"; 273 accountName = "New SMTP Account";
274 ssl = false; 274 ssl = false;
275 login = false; 275 login = false;
276 useCC = false;
277 useBCC = false;
278 useReply = false;
279 type = "SMTP"; 276 type = "SMTP";
280 port = SMTP_PORT; 277 port = SMTP_PORT;
281} 278}
282 279
283QString SMTPaccount::getUniqueFileName() 280QString SMTPaccount::getUniqueFileName()
284{ 281{
285 int num = 0; 282 int num = 0;
286 QString unique; 283 QString unique;
287 284
288 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 285 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
289 286
290 QStringList imap = dir.entryList( "smtp-*" ); 287 QStringList imap = dir.entryList( "smtp-*" );
291 do { 288 do {
292 unique.setNum( num++ ); 289 unique.setNum( num++ );
293 } while ( imap.contains( "smtp-" + unique ) > 0 ); 290 } while ( imap.contains( "smtp-" + unique ) > 0 );
294 291
295 return unique; 292 return unique;
296} 293}
297 294
298void SMTPaccount::read() 295void SMTPaccount::read()
299{ 296{
300 Config *conf = new Config( getFileName(), Config::File ); 297 Config *conf = new Config( getFileName(), Config::File );
301 conf->setGroup( "SMTP Account" ); 298 conf->setGroup( "SMTP Account" );
302 accountName = conf->readEntry( "Account" ); 299 accountName = conf->readEntry( "Account" );
303 server = conf->readEntry( "Server" ); 300 server = conf->readEntry( "Server" );
304 port = conf->readEntry( "Port" ); 301 port = conf->readEntry( "Port" );
305 ssl = conf->readBoolEntry( "SSL" ); 302 ssl = conf->readBoolEntry( "SSL" );
306 login = conf->readBoolEntry( "Login" ); 303 login = conf->readBoolEntry( "Login" );
307 user = conf->readEntry( "User" ); 304 user = conf->readEntry( "User" );
308 password = conf->readEntryCrypt( "Password" ); 305 password = conf->readEntryCrypt( "Password" );
309 useCC = conf->readBoolEntry( "useCC" );
310 useBCC = conf->readBoolEntry( "useBCC" );
311 useReply = conf->readBoolEntry( "useReply" );
312 name = conf->readEntry( "Name" );
313 mail = conf->readEntry( "Mail" );
314 org = conf->readEntry( "Org" );
315 cc = conf->readEntry( "CC" );
316 bcc = conf->readEntry( "BCC" );
317 reply = conf->readEntry( "Reply" );
318 signature = conf->readEntry( "Signature" );
319 signature = signature.replace( QRegExp( "<br>" ), "\n" );
320} 306}
321 307
322void SMTPaccount::save() 308void SMTPaccount::save()
323{ 309{
324 qDebug( "saving " + getFileName() ); 310 qDebug( "saving " + getFileName() );
325 Settings::checkDirectory(); 311 Settings::checkDirectory();
326 312
327 Config *conf = new Config( getFileName(), Config::File ); 313 Config *conf = new Config( getFileName(), Config::File );
328 conf->setGroup( "SMTP Account" ); 314 conf->setGroup( "SMTP Account" );
329 conf->writeEntry( "Account", accountName ); 315 conf->writeEntry( "Account", accountName );
330 conf->writeEntry( "Server", server ); 316 conf->writeEntry( "Server", server );
331 conf->writeEntry( "Port", port ); 317 conf->writeEntry( "Port", port );
332 conf->writeEntry( "SSL", ssl ); 318 conf->writeEntry( "SSL", ssl );
333 conf->writeEntry( "Login", login ); 319 conf->writeEntry( "Login", login );
334 conf->writeEntry( "User", user ); 320 conf->writeEntry( "User", user );
335 conf->writeEntryCrypt( "Password", password ); 321 conf->writeEntryCrypt( "Password", password );
336 conf->writeEntry( "useCC", useCC );
337 conf->writeEntry( "useBCC", useBCC );
338 conf->writeEntry( "useReply", useReply );
339 conf->writeEntry( "Name", name );
340 conf->writeEntry( "Mail", mail );
341 conf->writeEntry( "Org", org );
342 conf->writeEntry( "CC", cc );
343 conf->writeEntry( "BCC", bcc );
344 conf->writeEntry( "Reply", reply );
345 conf->writeEntry( "Signature",
346 signature.replace( QRegExp( "\\n" ), "<br>" ) );
347 conf->write(); 322 conf->write();
348} 323}
349 324
350 325
351QString SMTPaccount::getFileName() 326QString SMTPaccount::getFileName()
352{ 327{
353 return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; 328 return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file;
354} 329}
355 330
356NNTPaccount::NNTPaccount() 331NNTPaccount::NNTPaccount()
357 : Account() 332 : Account()
358{ 333{
359 file = NNTPaccount::getUniqueFileName(); 334 file = NNTPaccount::getUniqueFileName();
360 accountName = "New NNTP Account"; 335 accountName = "New NNTP Account";
361 ssl = false; 336 ssl = false;
362 login = false; 337 login = false;
363 type = "NNTP"; 338 type = "NNTP";
364 port = NNTP_PORT; 339 port = NNTP_PORT;
365} 340}
366 341
367NNTPaccount::NNTPaccount( QString filename ) 342NNTPaccount::NNTPaccount( QString filename )
368 : Account() 343 : Account()
369{ 344{
370 file = filename; 345 file = filename;
371 accountName = "New NNTP Account"; 346 accountName = "New NNTP Account";
372 ssl = false; 347 ssl = false;
373 login = false; 348 login = false;
374 type = "NNTP"; 349 type = "NNTP";
375 port = NNTP_PORT; 350 port = NNTP_PORT;
376} 351}
377 352
378QString NNTPaccount::getUniqueFileName() 353QString NNTPaccount::getUniqueFileName()
379{ 354{
380 int num = 0; 355 int num = 0;
381 QString unique; 356 QString unique;
382 357
383 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 358 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
384 359
385 QStringList imap = dir.entryList( "nntp-*" ); 360 QStringList imap = dir.entryList( "nntp-*" );
386 do { 361 do {
387 unique.setNum( num++ ); 362 unique.setNum( num++ );
388 } while ( imap.contains( "nntp-" + unique ) > 0 ); 363 } while ( imap.contains( "nntp-" + unique ) > 0 );
389 364
390 return unique; 365 return unique;
391} 366}
392 367
393void NNTPaccount::read() 368void NNTPaccount::read()
394{ 369{
395 Config *conf = new Config( getFileName(), Config::File ); 370 Config *conf = new Config( getFileName(), Config::File );
396 conf->setGroup( "NNTP Account" ); 371 conf->setGroup( "NNTP Account" );
397 accountName = conf->readEntry( "Account" ); 372 accountName = conf->readEntry( "Account" );
398 server = conf->readEntry( "Server" ); 373 server = conf->readEntry( "Server" );
399 port = conf->readEntry( "Port" ); 374 port = conf->readEntry( "Port" );
400 ssl = conf->readBoolEntry( "SSL" ); 375 ssl = conf->readBoolEntry( "SSL" );
401 login = conf->readBoolEntry( "Login" ); 376 login = conf->readBoolEntry( "Login" );
402 user = conf->readEntry( "User" ); 377 user = conf->readEntry( "User" );
403 password = conf->readEntryCrypt( "Password" ); 378 password = conf->readEntryCrypt( "Password" );
404} 379}
405 380
406void NNTPaccount::save() 381void NNTPaccount::save()
407{ 382{
408 qDebug( "saving " + getFileName() ); 383 qDebug( "saving " + getFileName() );
409 Settings::checkDirectory(); 384 Settings::checkDirectory();
410 385
411 Config *conf = new Config( getFileName(), Config::File ); 386 Config *conf = new Config( getFileName(), Config::File );
412 conf->setGroup( "NNTP Account" ); 387 conf->setGroup( "NNTP Account" );
413 conf->writeEntry( "Account", accountName ); 388 conf->writeEntry( "Account", accountName );
414 conf->writeEntry( "Server", server ); 389 conf->writeEntry( "Server", server );
415 conf->writeEntry( "Port", port ); 390 conf->writeEntry( "Port", port );
416 conf->writeEntry( "SSL", ssl ); 391 conf->writeEntry( "SSL", ssl );
417 conf->writeEntry( "Login", login ); 392 conf->writeEntry( "Login", login );
418 conf->writeEntry( "User", user ); 393 conf->writeEntry( "User", user );
419 conf->writeEntryCrypt( "Password", password ); 394 conf->writeEntryCrypt( "Password", password );
420 conf->write(); 395 conf->write();
421} 396}
422 397
423 398
424QString NNTPaccount::getFileName() 399QString NNTPaccount::getFileName()
425{ 400{
426 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; 401 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file;
427} 402}
428 403
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
@@ -1,166 +1,146 @@
1#ifndef SETTINGS_H 1#ifndef SETTINGS_H
2#define SETTINGS_H 2#define SETTINGS_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7class Account 7class Account
8{ 8{
9 9
10public: 10public:
11 Account(); 11 Account();
12 virtual ~Account() {} 12 virtual ~Account() {}
13 13
14 void remove(); 14 void remove();
15 void setAccountName( QString name ) { accountName = name; } 15 void setAccountName( QString name ) { accountName = name; }
16 const QString&getAccountName()const{ return accountName; } 16 const QString&getAccountName()const{ return accountName; }
17 const QString&getType()const{ return type; } 17 const QString&getType()const{ return type; }
18 18
19 void setServer(const QString&str){ server = str; } 19 void setServer(const QString&str){ server = str; }
20 const QString&getServer()const{ return server; } 20 const QString&getServer()const{ return server; }
21 21
22 void setPort(const QString&str) { port = str; } 22 void setPort(const QString&str) { port = str; }
23 const QString&getPort()const{ return port; } 23 const QString&getPort()const{ return port; }
24 24
25 void setUser(const QString&str){ user = str; } 25 void setUser(const QString&str){ user = str; }
26 const QString&getUser()const{ return user; } 26 const QString&getUser()const{ return user; }
27 27
28 void setPassword(const QString&str) { password = str; } 28 void setPassword(const QString&str) { password = str; }
29 const QString&getPassword()const { return password; } 29 const QString&getPassword()const { return password; }
30 30
31 void setSSL( bool b ) { ssl = b; } 31 void setSSL( bool b ) { ssl = b; }
32 bool getSSL() { return ssl; } 32 bool getSSL() { return ssl; }
33 33
34 virtual QString getFileName() { return accountName; } 34 virtual QString getFileName() { return accountName; }
35 virtual void read() { qDebug( "base reading..." ); } 35 virtual void read() { qDebug( "base reading..." ); }
36 virtual void save() { qDebug( "base saving..." ); } 36 virtual void save() { qDebug( "base saving..." ); }
37 37
38protected: 38protected:
39 QString accountName, type, server, port, user, password; 39 QString accountName, type, server, port, user, password;
40 bool ssl; 40 bool ssl;
41 41
42}; 42};
43 43
44class IMAPaccount : public Account 44class IMAPaccount : public Account
45{ 45{
46 46
47public: 47public:
48 IMAPaccount(); 48 IMAPaccount();
49 IMAPaccount( QString filename ); 49 IMAPaccount( QString filename );
50 50
51 static QString getUniqueFileName(); 51 static QString getUniqueFileName();
52 52
53 virtual void read(); 53 virtual void read();
54 virtual void save(); 54 virtual void save();
55 virtual QString getFileName(); 55 virtual QString getFileName();
56 56
57 void setPrefix(const QString&str) {prefix=str;} 57 void setPrefix(const QString&str) {prefix=str;}
58 const QString&getPrefix()const{return prefix;} 58 const QString&getPrefix()const{return prefix;}
59 59
60private: 60private:
61 QString file,prefix; 61 QString file,prefix;
62 62
63}; 63};
64 64
65class POP3account : public Account 65class POP3account : public Account
66{ 66{
67 67
68public: 68public:
69 POP3account(); 69 POP3account();
70 POP3account( QString filename ); 70 POP3account( QString filename );
71 71
72 static QString getUniqueFileName(); 72 static QString getUniqueFileName();
73 73
74 virtual void read(); 74 virtual void read();
75 virtual void save(); 75 virtual void save();
76 virtual QString getFileName(); 76 virtual QString getFileName();
77 77
78private: 78private:
79 QString file; 79 QString file;
80 80
81}; 81};
82 82
83class SMTPaccount : public Account 83class SMTPaccount : public Account
84{ 84{
85 85
86public: 86public:
87 SMTPaccount(); 87 SMTPaccount();
88 SMTPaccount( QString filename ); 88 SMTPaccount( QString filename );
89 89
90 static QString getUniqueFileName(); 90 static QString getUniqueFileName();
91 91
92 virtual void read(); 92 virtual void read();
93 virtual void save(); 93 virtual void save();
94 virtual QString getFileName(); 94 virtual QString getFileName();
95 95
96 void setName( QString str ) { name = str; }
97 QString getName() { return name; }
98 void setMail( QString str ) { mail = str; }
99 QString getMail() { return mail; }
100 void setOrg( QString str ) { org = str; }
101 QString getOrg() { return org; }
102 void setUseCC( bool b ) { useCC = b; }
103 bool getUseCC() { return useCC; }
104 void setCC( QString str ) { cc = str; }
105 QString getCC() { return cc; }
106 void setUseBCC( bool b ) { useBCC = b; }
107 bool getUseBCC() { return useBCC; }
108 void setBCC( QString str ) { bcc = str; }
109 QString getBCC() { return bcc; }
110 void setUseReply( bool b ) { useReply = b; }
111 bool getUseReply() { return useReply; }
112 void setReply( QString str ) { reply = str; }
113 QString getReply() { return reply; }
114 void setSignature( QString str ) { signature = str; }
115 QString getSignature() { return signature; }
116 void setLogin( bool b ) { login = b; } 96 void setLogin( bool b ) { login = b; }
117 bool getLogin() { return login; } 97 bool getLogin() { return login; }
118 98
119private: 99private:
120 QString file, name, mail, org, cc, bcc, reply, signature; 100 QString file, name, mail, org, cc, bcc, reply, signature;
121 bool useCC, useBCC, useReply, login; 101 bool useCC, useBCC, useReply, login;
122 102
123}; 103};
124 104
125class NNTPaccount : public Account 105class NNTPaccount : public Account
126{ 106{
127 107
128public: 108public:
129 NNTPaccount(); 109 NNTPaccount();
130 NNTPaccount( QString filename ); 110 NNTPaccount( QString filename );
131 111
132 static QString getUniqueFileName(); 112 static QString getUniqueFileName();
133 113
134 virtual void read(); 114 virtual void read();
135 virtual void save(); 115 virtual void save();
136 virtual QString getFileName(); 116 virtual QString getFileName();
137 117
138 void setLogin( bool b ) { login = b; } 118 void setLogin( bool b ) { login = b; }
139 bool getLogin() { return login; } 119 bool getLogin() { return login; }
140 120
141private: 121private:
142 QString file; 122 QString file;
143 bool login; 123 bool login;
144 124
145}; 125};
146 126
147class Settings : public QObject 127class Settings : public QObject
148{ 128{
149 Q_OBJECT 129 Q_OBJECT
150 130
151public: 131public:
152 Settings(); 132 Settings();
153 QList<Account> getAccounts(); 133 QList<Account> getAccounts();
154 void addAccount(Account *account); 134 void addAccount(Account *account);
155 void delAccount(Account *account); 135 void delAccount(Account *account);
156 void saveAccounts(); 136 void saveAccounts();
157 void readAccounts(); 137 void readAccounts();
158 static void checkDirectory(); 138 static void checkDirectory();
159 139
160private: 140private:
161 void updateAccounts(); 141 void updateAccounts();
162 QList<Account> accounts; 142 QList<Account> accounts;
163 143
164}; 144};
165 145
166#endif 146#endif
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 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>SMTPconfigUI</class> 2<class>SMTPconfigUI</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>SMTPconfigUI</cstring> 7 <cstring>SMTPconfigUI</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>253</width> 14 <width>241</width>
15 <height>342</height> 15 <height>321</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Configure SMTP</string> 20 <string>Configure SMTP</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <vbox> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>0</number> 31 <number>2</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>0</number> 35 <number>2</number>
36 </property> 36 </property>
37 <widget> 37 <widget>
38 <class>QTabWidget</class> 38 <class>QLayoutWidget</class>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>name</name> 40 <name>name</name>
41 <cstring>smtpTab</cstring> 41 <cstring>Layout4</cstring>
42 </property>
43 <property stdset="1">
44 <name>caption</name>
45 <string></string>
46 </property>
47 <property>
48 <name>layoutMargin</name>
49 </property> 42 </property>
50 <property> 43 <property>
51 <name>layoutSpacing</name> 44 <name>layoutSpacing</name>
52 </property> 45 </property>
53 <widget> 46 <grid>
54 <class>QWidget</class>
55 <property stdset="1"> 47 <property stdset="1">
56 <name>name</name> 48 <name>margin</name>
57 <cstring>serverTab</cstring> 49 <number>0</number>
58 </property> 50 </property>
59 <attribute> 51 <property stdset="1">
60 <name>title</name> 52 <name>spacing</name>
61 <string>Server</string> 53 <number>2</number>
62 </attribute> 54 </property>
63 <grid> 55 <widget row="0" column="0" rowspan="1" colspan="2" >
56 <class>QLabel</class>
64 <property stdset="1"> 57 <property stdset="1">
65 <name>margin</name> 58 <name>name</name>
66 <number>4</number> 59 <cstring>accountLabel</cstring>
67 </property> 60 </property>
68 <property stdset="1"> 61 <property stdset="1">
69 <name>spacing</name> 62 <name>text</name>
70 <number>3</number> 63 <string>Account</string>
64 </property>
65 </widget>
66 <widget row="8" column="2" >
67 <class>QLineEdit</class>
68 <property stdset="1">
69 <name>name</name>
70 <cstring>passLine</cstring>
71 </property>
72 <property stdset="1">
73 <name>enabled</name>
74 <bool>false</bool>
75 </property>
76 <property stdset="1">
77 <name>echoMode</name>
78 <enum>Password</enum>
79 </property>
80 </widget>
81 <widget row="4" column="0" rowspan="1" colspan="3" >
82 <class>QCheckBox</class>
83 <property stdset="1">
84 <name>name</name>
85 <cstring>sslBox</cstring>
86 </property>
87 <property stdset="1">
88 <name>text</name>
89 <string>Use SSL</string>
90 </property>
91 </widget>
92 <widget row="6" column="0" rowspan="1" colspan="3" >
93 <class>QCheckBox</class>
94 <property stdset="1">
95 <name>name</name>
96 <cstring>loginBox</cstring>
97 </property>
98 <property stdset="1">
99 <name>text</name>
100 <string>Use Login</string>
101 </property>
102 </widget>
103 <widget row="0" column="2" >
104 <class>QLineEdit</class>
105 <property stdset="1">
106 <name>name</name>
107 <cstring>accountLine</cstring>
108 </property>
109 <property>
110 <name>toolTip</name>
111 <string>Name of the Account</string>
112 </property>
113 </widget>
114 <widget row="2" column="1" rowspan="1" colspan="2" >
115 <class>QLineEdit</class>
116 <property stdset="1">
117 <name>name</name>
118 <cstring>serverLine</cstring>
119 </property>
120 <property>
121 <name>toolTip</name>
122 <string>Name of the SMTP Server</string>
123 </property>
124 </widget>
125 <widget row="7" column="2" >
126 <class>QLineEdit</class>
127 <property stdset="1">
128 <name>name</name>
129 <cstring>userLine</cstring>
130 </property>
131 <property stdset="1">
132 <name>enabled</name>
133 <bool>false</bool>
134 </property>
135 </widget>
136 <widget row="8" column="0" rowspan="1" colspan="2" >
137 <class>QLabel</class>
138 <property stdset="1">
139 <name>name</name>
140 <cstring>passLabel</cstring>
71 </property> 141 </property>
72 <widget row="3" column="0" >
73 <class>QLabel</class>
74 <property stdset="1">
75 <name>name</name>
76 <cstring>portLabel</cstring>
77 </property>
78 <property stdset="1">
79 <name>text</name>
80 <string>Port</string>
81 </property>
82 </widget>
83 <widget row="2" column="1" rowspan="1" colspan="2" >
84 <class>QLineEdit</class>
85 <property stdset="1">
86 <name>name</name>
87 <cstring>serverLine</cstring>
88 </property>
89 <property>
90 <name>toolTip</name>
91 <string>Name of the SMTP Server</string>
92 </property>
93 </widget>
94 <widget row="2" column="0" >
95 <class>QLabel</class>
96 <property stdset="1">
97 <name>name</name>
98 <cstring>serverLabel</cstring>
99 </property>
100 <property stdset="1">
101 <name>text</name>
102 <string>Server</string>
103 </property>
104 </widget>
105 <widget row="3" column="1" rowspan="1" colspan="2" >
106 <class>QLineEdit</class>
107 <property stdset="1">
108 <name>name</name>
109 <cstring>portLine</cstring>
110 </property>
111 <property>
112 <name>toolTip</name>
113 <string>Port of the SMTP Server</string>
114 </property>
115 </widget>
116 <widget row="0" column="0" >
117 <class>QLabel</class>
118 <property stdset="1">
119 <name>name</name>
120 <cstring>accountLabel</cstring>
121 </property>
122 <property stdset="1">
123 <name>text</name>
124 <string>Account</string>
125 </property>
126 </widget>
127 <widget row="0" column="1" rowspan="1" colspan="2" >
128 <class>QLineEdit</class>
129 <property stdset="1">
130 <name>name</name>
131 <cstring>accountLine</cstring>
132 </property>
133 <property>
134 <name>toolTip</name>
135 <string>Name of the Account</string>
136 </property>
137 </widget>
138 <widget row="1" column="0" rowspan="1" colspan="3" >
139 <class>Line</class>
140 <property stdset="1">
141 <name>name</name>
142 <cstring>line1</cstring>
143 </property>
144 <property stdset="1">
145 <name>orientation</name>
146 <enum>Horizontal</enum>
147 </property>
148 </widget>
149 <widget row="4" column="1" >
150 <class>QCheckBox</class>
151 <property stdset="1">
152 <name>name</name>
153 <cstring>sslBox</cstring>
154 </property>
155 <property stdset="1">
156 <name>text</name>
157 <string>Use SSL</string>
158 </property>
159 </widget>
160 <widget row="5" column="0" rowspan="1" colspan="3" >
161 <class>Line</class>
162 <property stdset="1">
163 <name>name</name>
164 <cstring>line2</cstring>
165 </property>
166 <property stdset="1">
167 <name>orientation</name>
168 <enum>Horizontal</enum>
169 </property>
170 </widget>
171 <widget row="8" column="1" rowspan="1" colspan="2" >
172 <class>QLineEdit</class>
173 <property stdset="1">
174 <name>name</name>
175 <cstring>passLine</cstring>
176 </property>
177 <property stdset="1">
178 <name>enabled</name>
179 <bool>false</bool>
180 </property>
181 <property stdset="1">
182 <name>echoMode</name>
183 <enum>Password</enum>
184 </property>
185 </widget>
186 <widget row="6" column="1" rowspan="1" colspan="2" >
187 <class>QCheckBox</class>
188 <property stdset="1">
189 <name>name</name>
190 <cstring>loginBox</cstring>
191 </property>
192 <property stdset="1">
193 <name>text</name>
194 <string>Use Login</string>
195 </property>
196 </widget>
197 <widget row="8" column="0" >
198 <class>QLabel</class>
199 <property stdset="1">
200 <name>name</name>
201 <cstring>passLabel</cstring>
202 </property>
203 <property stdset="1">
204 <name>text</name>
205 <string>Password</string>
206 </property>
207 </widget>
208 <widget row="7" column="0" >
209 <class>QLabel</class>
210 <property stdset="1">
211 <name>name</name>
212 <cstring>userLabel</cstring>
213 </property>
214 <property stdset="1">
215 <name>text</name>
216 <string>User</string>
217 </property>
218 </widget>
219 <widget row="7" column="1" rowspan="1" colspan="2" >
220 <class>QLineEdit</class>
221 <property stdset="1">
222 <name>name</name>
223 <cstring>userLine</cstring>
224 </property>
225 <property stdset="1">
226 <name>enabled</name>
227 <bool>false</bool>
228 </property>
229 </widget>
230 <spacer row="9" column="2" >
231 <property>
232 <name>name</name>
233 <cstring>spacer</cstring>
234 </property>
235 <property stdset="1">
236 <name>orientation</name>
237 <enum>Vertical</enum>
238 </property>
239 <property stdset="1">
240 <name>sizeType</name>
241 <enum>Expanding</enum>
242 </property>
243 <property>
244 <name>sizeHint</name>
245 <size>
246 <width>20</width>
247 <height>20</height>
248 </size>
249 </property>
250 </spacer>
251 </grid>
252 </widget>
253 <widget>
254 <class>QWidget</class>
255 <property stdset="1">
256 <name>name</name>
257 <cstring>identityTab</cstring>
258 </property>
259 <attribute>
260 <name>title</name>
261 <string>Identity</string>
262 </attribute>
263 <grid>
264 <property stdset="1"> 142 <property stdset="1">
265 <name>margin</name> 143 <name>text</name>
266 <number>4</number> 144 <string>Password</string>
267 </property> 145 </property>
146 </widget>
147 <widget row="3" column="0" >
148 <class>QLabel</class>
268 <property stdset="1"> 149 <property stdset="1">
269 <name>spacing</name> 150 <name>name</name>
270 <number>3</number> 151 <cstring>portLabel</cstring>
271 </property> 152 </property>
272 <widget row="9" column="0" rowspan="1" colspan="4" > 153 <property stdset="1">
273 <class>QMultiLineEdit</class> 154 <name>text</name>
274 <property stdset="1"> 155 <string>Port</string>
275 <name>name</name> 156 </property>
276 <cstring>sigMultiLine</cstring> 157 </widget>
277 </property> 158 <widget row="2" column="0" >
278 </widget> 159 <class>QLabel</class>
279 <spacer row="10" column="3" > 160 <property stdset="1">
280 <property> 161 <name>name</name>
281 <name>name</name> 162 <cstring>serverLabel</cstring>
282 <cstring>Spacer3</cstring> 163 </property>
283 </property> 164 <property stdset="1">
284 <property stdset="1"> 165 <name>text</name>
285 <name>orientation</name> 166 <string>Server</string>
286 <enum>Vertical</enum> 167 </property>
287 </property> 168 </widget>
288 <property stdset="1"> 169 <widget row="3" column="1" rowspan="1" colspan="2" >
289 <name>sizeType</name> 170 <class>QLineEdit</class>
290 <enum>Expanding</enum> 171 <property stdset="1">
291 </property> 172 <name>name</name>
292 <property> 173 <cstring>portLine</cstring>
293 <name>sizeHint</name> 174 </property>
294 <size> 175 <property>
295 <width>20</width> 176 <name>toolTip</name>
296 <height>20</height> 177 <string>Port of the SMTP Server</string>
297 </size> 178 </property>
298 </property> 179 </widget>
299 <property> 180 <widget row="1" column="0" rowspan="1" colspan="3" >
300 <name>toolTip</name> 181 <class>Line</class>
301 <string>Name of the Account</string> 182 <property stdset="1">
302 </property> 183 <name>name</name>
303 </spacer> 184 <cstring>line1</cstring>
304 <widget row="8" column="0" rowspan="1" colspan="3" > 185 </property>
305 <class>QLabel</class> 186 <property stdset="1">
306 <property stdset="1"> 187 <name>sizePolicy</name>
307 <name>name</name> 188 <sizepolicy>
308 <cstring>sigLabel</cstring> 189 <hsizetype>3</hsizetype>
309 </property> 190 <vsizetype>0</vsizetype>
310 <property stdset="1"> 191 </sizepolicy>
311 <name>text</name> 192 </property>
312 <string>Signature</string> 193 <property stdset="1">
313 </property> 194 <name>orientation</name>
314 </widget> 195 <enum>Horizontal</enum>
315 <widget row="6" column="2" rowspan="1" colspan="2" > 196 </property>
316 <class>QLineEdit</class> 197 </widget>
317 <property stdset="1"> 198 <widget row="7" column="0" rowspan="1" colspan="2" >
318 <name>name</name> 199 <class>QLabel</class>
319 <cstring>replyLine</cstring> 200 <property stdset="1">
320 </property> 201 <name>name</name>
321 <property stdset="1"> 202 <cstring>userLabel</cstring>
322 <name>enabled</name> 203 </property>
323 <bool>false</bool> 204 <property stdset="1">
324 </property> 205 <name>text</name>
325 </widget> 206 <string>User</string>
326 <widget row="5" column="2" rowspan="1" colspan="2" > 207 </property>
327 <class>QLineEdit</class> 208 </widget>
328 <property stdset="1"> 209 <widget row="5" column="0" rowspan="1" colspan="3" >
329 <name>name</name> 210 <class>Line</class>
330 <cstring>bccLine</cstring> 211 <property stdset="1">
331 </property> 212 <name>name</name>
332 <property stdset="1"> 213 <cstring>line2</cstring>
333 <name>enabled</name> 214 </property>
334 <bool>false</bool> 215 <property stdset="1">
335 </property> 216 <name>sizePolicy</name>
336 </widget> 217 <sizepolicy>
337 <widget row="4" column="2" rowspan="1" colspan="2" > 218 <hsizetype>3</hsizetype>
338 <class>QLineEdit</class> 219 <vsizetype>0</vsizetype>
339 <property stdset="1"> 220 </sizepolicy>
340 <name>name</name> 221 </property>
341 <cstring>ccLine</cstring> 222 <property stdset="1">
342 </property> 223 <name>orientation</name>
343 <property stdset="1"> 224 <enum>Horizontal</enum>
344 <name>enabled</name> 225 </property>
345 <bool>false</bool> 226 </widget>
346 </property> 227 </grid>
347 </widget>
348 <widget row="5" column="0" rowspan="1" colspan="2" >
349 <class>QCheckBox</class>
350 <property stdset="1">
351 <name>name</name>
352 <cstring>bccBox</cstring>
353 </property>
354 <property stdset="1">
355 <name>text</name>
356 <string>BCC</string>
357 </property>
358 </widget>
359 <widget row="6" column="0" rowspan="1" colspan="2" >
360 <class>QCheckBox</class>
361 <property stdset="1">
362 <name>name</name>
363 <cstring>replyBox</cstring>
364 </property>
365 <property stdset="1">
366 <name>text</name>
367 <string>Reply-To</string>
368 </property>
369 </widget>
370 <widget row="4" column="0" rowspan="1" colspan="2" >
371 <class>QCheckBox</class>
372 <property stdset="1">
373 <name>name</name>
374 <cstring>ccBox</cstring>
375 </property>
376 <property stdset="1">
377 <name>text</name>
378 <string>CC</string>
379 </property>
380 </widget>
381 <widget row="1" column="0" >
382 <class>QLabel</class>
383 <property stdset="1">
384 <name>name</name>
385 <cstring>mailLabel</cstring>
386 </property>
387 <property stdset="1">
388 <name>text</name>
389 <string>E-Mail</string>
390 </property>
391 </widget>
392 <widget row="0" column="1" rowspan="1" colspan="3" >
393 <class>QLineEdit</class>
394 <property stdset="1">
395 <name>name</name>
396 <cstring>nameLine</cstring>
397 </property>
398 <property>
399 <name>toolTip</name>
400 <string>Your Full Name</string>
401 </property>
402 </widget>
403 <widget row="0" column="0" >
404 <class>QLabel</class>
405 <property stdset="1">
406 <name>name</name>
407 <cstring>nameLabel</cstring>
408 </property>
409 <property stdset="1">
410 <name>text</name>
411 <string>Name</string>
412 </property>
413 </widget>
414 <widget row="2" column="0" >
415 <class>QLabel</class>
416 <property stdset="1">
417 <name>name</name>
418 <cstring>orgLabel</cstring>
419 </property>
420 <property stdset="1">
421 <name>text</name>
422 <string>Org.</string>
423 </property>
424 <property>
425 <name>layoutMargin</name>
426 </property>
427 <property>
428 <name>layoutSpacing</name>
429 </property>
430 </widget>
431 <widget row="2" column="1" rowspan="1" colspan="3" >
432 <class>QLineEdit</class>
433 <property stdset="1">
434 <name>name</name>
435 <cstring>orgLine</cstring>
436 </property>
437 <property>
438 <name>toolTip</name>
439 <string>Your Organisation</string>
440 </property>
441 </widget>
442 <widget row="1" column="1" rowspan="1" colspan="3" >
443 <class>QLineEdit</class>
444 <property stdset="1">
445 <name>name</name>
446 <cstring>mailLine</cstring>
447 </property>
448 <property>
449 <name>toolTip</name>
450 <string>Your E-Mail Adress</string>
451 </property>
452 </widget>
453 <widget row="3" column="0" rowspan="1" colspan="4" >
454 <class>Line</class>
455 <property stdset="1">
456 <name>name</name>
457 <cstring>line3</cstring>
458 </property>
459 <property stdset="1">
460 <name>orientation</name>
461 <enum>Horizontal</enum>
462 </property>
463 </widget>
464 <widget row="7" column="0" rowspan="1" colspan="4" >
465 <class>Line</class>
466 <property stdset="1">
467 <name>name</name>
468 <cstring>line4</cstring>
469 </property>
470 <property stdset="1">
471 <name>orientation</name>
472 <enum>Horizontal</enum>
473 </property>
474 </widget>
475 </grid>
476 </widget>
477 </widget> 228 </widget>
229 <spacer>
230 <property>
231 <name>name</name>
232 <cstring>spacer</cstring>
233 </property>
234 <property stdset="1">
235 <name>orientation</name>
236 <enum>Vertical</enum>
237 </property>
238 <property stdset="1">
239 <name>sizeType</name>
240 <enum>Expanding</enum>
241 </property>
242 <property>
243 <name>sizeHint</name>
244 <size>
245 <width>20</width>
246 <height>20</height>
247 </size>
248 </property>
249 </spacer>
478 </vbox> 250 </vbox>
479</widget> 251</widget>
480<tabstops> 252<tabstops>
481 <tabstop>accountLine</tabstop> 253 <tabstop>accountLine</tabstop>
482 <tabstop>serverLine</tabstop> 254 <tabstop>serverLine</tabstop>
483 <tabstop>portLine</tabstop> 255 <tabstop>portLine</tabstop>
484 <tabstop>sslBox</tabstop> 256 <tabstop>sslBox</tabstop>
485 <tabstop>loginBox</tabstop> 257 <tabstop>loginBox</tabstop>
486 <tabstop>userLine</tabstop> 258 <tabstop>userLine</tabstop>
487 <tabstop>passLine</tabstop> 259 <tabstop>passLine</tabstop>
488 <tabstop>smtpTab</tabstop>
489 <tabstop>nameLine</tabstop>
490 <tabstop>mailLine</tabstop>
491 <tabstop>orgLine</tabstop>
492 <tabstop>ccBox</tabstop>
493 <tabstop>ccLine</tabstop>
494 <tabstop>bccBox</tabstop>
495 <tabstop>bccLine</tabstop>
496 <tabstop>replyBox</tabstop>
497 <tabstop>replyLine</tabstop>
498 <tabstop>sigMultiLine</tabstop>
499</tabstops> 260</tabstops>
500</UI> 261</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
@@ -1,726 +1,710 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <sys/stat.h> 2#include <sys/stat.h>
3#include <sys/types.h> 3#include <sys/types.h>
4#include <unistd.h> 4#include <unistd.h>
5#include <fcntl.h> 5#include <fcntl.h>
6#include <string.h> 6#include <string.h>
7#include <qdir.h> 7#include <qdir.h>
8#include <qt.h> 8#include <qt.h>
9 9
10#include <libetpan/libetpan.h> 10#include <libetpan/libetpan.h>
11 11
12#include "smtpwrapper.h" 12#include "smtpwrapper.h"
13#include "mailwrapper.h" 13#include "mailwrapper.h"
14#include "mboxwrapper.h" 14#include "mboxwrapper.h"
15#include "logindialog.h" 15#include "logindialog.h"
16#include "mailtypes.h" 16#include "mailtypes.h"
17#include "defines.h" 17#include "defines.h"
18#include "sendmailprogress.h" 18#include "sendmailprogress.h"
19 19
20progressMailSend*SMTPwrapper::sendProgress = 0; 20progressMailSend*SMTPwrapper::sendProgress = 0;
21 21
22SMTPwrapper::SMTPwrapper( Settings *s ) 22SMTPwrapper::SMTPwrapper( Settings *s )
23 : QObject() 23 : QObject()
24{ 24{
25 settings = s; 25 settings = s;
26} 26}
27 27
28QString SMTPwrapper::mailsmtpError( int errnum ) 28QString SMTPwrapper::mailsmtpError( int errnum )
29{ 29{
30 switch ( errnum ) { 30 switch ( errnum ) {
31 case MAILSMTP_NO_ERROR: 31 case MAILSMTP_NO_ERROR:
32 return tr( "No error" ); 32 return tr( "No error" );
33 case MAILSMTP_ERROR_UNEXPECTED_CODE: 33 case MAILSMTP_ERROR_UNEXPECTED_CODE:
34 return tr( "Unexpected error code" ); 34 return tr( "Unexpected error code" );
35 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 35 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
36 return tr( "Service not available" ); 36 return tr( "Service not available" );
37 case MAILSMTP_ERROR_STREAM: 37 case MAILSMTP_ERROR_STREAM:
38 return tr( "Stream error" ); 38 return tr( "Stream error" );
39 case MAILSMTP_ERROR_HOSTNAME: 39 case MAILSMTP_ERROR_HOSTNAME:
40 return tr( "gethostname() failed" ); 40 return tr( "gethostname() failed" );
41 case MAILSMTP_ERROR_NOT_IMPLEMENTED: 41 case MAILSMTP_ERROR_NOT_IMPLEMENTED:
42 return tr( "Not implemented" ); 42 return tr( "Not implemented" );
43 case MAILSMTP_ERROR_ACTION_NOT_TAKEN: 43 case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
44 return tr( "Error, action not taken" ); 44 return tr( "Error, action not taken" );
45 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: 45 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
46 return tr( "Data exceeds storage allocation" ); 46 return tr( "Data exceeds storage allocation" );
47 case MAILSMTP_ERROR_IN_PROCESSING: 47 case MAILSMTP_ERROR_IN_PROCESSING:
48 return tr( "Error in processing" ); 48 return tr( "Error in processing" );
49 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: 49 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
50 // return tr( "Insufficient system storage" ); 50 // return tr( "Insufficient system storage" );
51 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: 51 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
52 return tr( "Mailbox unavailable" ); 52 return tr( "Mailbox unavailable" );
53 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: 53 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
54 return tr( "Mailbox name not allowed" ); 54 return tr( "Mailbox name not allowed" );
55 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: 55 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
56 return tr( "Bad command sequence" ); 56 return tr( "Bad command sequence" );
57 case MAILSMTP_ERROR_USER_NOT_LOCAL: 57 case MAILSMTP_ERROR_USER_NOT_LOCAL:
58 return tr( "User not local" ); 58 return tr( "User not local" );
59 case MAILSMTP_ERROR_TRANSACTION_FAILED: 59 case MAILSMTP_ERROR_TRANSACTION_FAILED:
60 return tr( "Transaction failed" ); 60 return tr( "Transaction failed" );
61 case MAILSMTP_ERROR_MEMORY: 61 case MAILSMTP_ERROR_MEMORY:
62 return tr( "Memory error" ); 62 return tr( "Memory error" );
63 case MAILSMTP_ERROR_CONNECTION_REFUSED: 63 case MAILSMTP_ERROR_CONNECTION_REFUSED:
64 return tr( "Connection refused" ); 64 return tr( "Connection refused" );
65 default: 65 default:
66 return tr( "Unknown error code" ); 66 return tr( "Unknown error code" );
67 } 67 }
68} 68}
69 69
70mailimf_mailbox *SMTPwrapper::newMailbox(const QString&name, const QString&mail ) 70mailimf_mailbox *SMTPwrapper::newMailbox(const QString&name, const QString&mail )
71{ 71{
72 return mailimf_mailbox_new( strdup( name.latin1() ), 72 return mailimf_mailbox_new( strdup( name.latin1() ),
73 strdup( mail.latin1() ) ); 73 strdup( mail.latin1() ) );
74} 74}
75 75
76mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) 76mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr )
77{ 77{
78 mailimf_address_list *addresses; 78 mailimf_address_list *addresses;
79 79
80 if ( addr.isEmpty() ) return NULL; 80 if ( addr.isEmpty() ) return NULL;
81 81
82 addresses = mailimf_address_list_new_empty(); 82 addresses = mailimf_address_list_new_empty();
83 83
84 bool literal_open = false; 84 bool literal_open = false;
85 unsigned int startpos = 0; 85 unsigned int startpos = 0;
86 QStringList list; 86 QStringList list;
87 QString s; 87 QString s;
88 unsigned int i = 0; 88 unsigned int i = 0;
89 for (; i < addr.length();++i) { 89 for (; i < addr.length();++i) {
90 switch (addr[i]) { 90 switch (addr[i]) {
91 case '\"': 91 case '\"':
92 literal_open = !literal_open; 92 literal_open = !literal_open;
93 break; 93 break;
94 case ',': 94 case ',':
95 if (!literal_open) { 95 if (!literal_open) {
96 s = addr.mid(startpos,i-startpos); 96 s = addr.mid(startpos,i-startpos);
97 if (!s.isEmpty()) { 97 if (!s.isEmpty()) {
98 list.append(s); 98 list.append(s);
99 qDebug("Appended %s",s.latin1()); 99 qDebug("Appended %s",s.latin1());
100 } 100 }
101 // !!!! this is a MUST BE! 101 // !!!! this is a MUST BE!
102 startpos = ++i; 102 startpos = ++i;
103 } 103 }
104 break; 104 break;
105 default: 105 default:
106 break; 106 break;
107 } 107 }
108 } 108 }
109 s = addr.mid(startpos,i-startpos); 109 s = addr.mid(startpos,i-startpos);
110 if (!s.isEmpty()) { 110 if (!s.isEmpty()) {
111 list.append(s); 111 list.append(s);
112 qDebug("Appended %s",s.latin1()); 112 qDebug("Appended %s",s.latin1());
113 } 113 }
114 QStringList::Iterator it; 114 QStringList::Iterator it;
115 for ( it = list.begin(); it != list.end(); it++ ) { 115 for ( it = list.begin(); it != list.end(); it++ ) {
116 int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); 116 int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() );
117 if ( err != MAILIMF_NO_ERROR ) { 117 if ( err != MAILIMF_NO_ERROR ) {
118 qDebug( "Error parsing" ); 118 qDebug( "Error parsing" );
119 qDebug( *it ); 119 qDebug( *it );
120 } else { 120 } else {
121 qDebug( "Parse success! %s",(*it).latin1()); 121 qDebug( "Parse success! %s",(*it).latin1());
122 } 122 }
123 } 123 }
124 return addresses; 124 return addresses;
125} 125}
126 126
127mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) 127mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail )
128{ 128{
129 mailimf_fields *fields; 129 mailimf_fields *fields;
130 mailimf_field *xmailer; 130 mailimf_field *xmailer;
131 mailimf_mailbox *sender, *fromBox; 131 mailimf_mailbox *sender=0,*fromBox=0;
132 mailimf_mailbox_list *from; 132 mailimf_mailbox_list *from=0;
133 mailimf_address_list *to, *cc, *bcc, *reply; 133 mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0;
134 char *subject = strdup( mail.getSubject().latin1() ); 134 char *subject = strdup( mail.getSubject().latin1() );
135 int err; 135 int err;
136 136
137 sender = newMailbox( mail.getName(), mail.getMail() ); 137 sender = newMailbox( mail.getName(), mail.getMail() );
138 if ( sender == NULL ) goto err_free; 138 if ( sender == NULL ) goto err_free;
139 139
140 fromBox = newMailbox( mail.getName(), mail.getMail() ); 140 fromBox = newMailbox( mail.getName(), mail.getMail() );
141 if ( fromBox == NULL ) goto err_free_sender; 141 if ( fromBox == NULL ) goto err_free_sender;
142 142
143 from = mailimf_mailbox_list_new_empty(); 143 from = mailimf_mailbox_list_new_empty();
144 if ( from == NULL ) goto err_free_fromBox; 144 if ( from == NULL ) goto err_free_fromBox;
145 145
146 err = mailimf_mailbox_list_add( from, fromBox ); 146 err = mailimf_mailbox_list_add( from, fromBox );
147 if ( err != MAILIMF_NO_ERROR ) goto err_free_from; 147 if ( err != MAILIMF_NO_ERROR ) goto err_free_from;
148 148
149 to = parseAddresses( mail.getTo() ); 149 to = parseAddresses( mail.getTo() );
150 if ( to == NULL ) goto err_free_from; 150 if ( to == NULL ) goto err_free_from;
151 151
152 cc = parseAddresses( mail.getCC() ); 152 cc = parseAddresses( mail.getCC() );
153 bcc = parseAddresses( mail.getBCC() ); 153 bcc = parseAddresses( mail.getBCC() );
154 reply = parseAddresses( mail.getReply() ); 154 reply = parseAddresses( mail.getReply() );
155 155
156 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, 156 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc,
157 NULL, NULL, subject ); 157 NULL, NULL, subject );
158 if ( fields == NULL ) goto err_free_reply; 158 if ( fields == NULL ) goto err_free_reply;
159 159
160 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), 160 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ),
161 strdup( USER_AGENT ) ); 161 strdup( USER_AGENT ) );
162 if ( xmailer == NULL ) goto err_free_fields; 162 if ( xmailer == NULL ) goto err_free_fields;
163 163
164 err = mailimf_fields_add( fields, xmailer ); 164 err = mailimf_fields_add( fields, xmailer );
165 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; 165 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer;
166 166
167 return fields; // Success :) 167 return fields; // Success :)
168 168
169err_free_xmailer: 169err_free_xmailer:
170 mailimf_field_free( xmailer ); 170 if (xmailer) mailimf_field_free( xmailer );
171err_free_fields: 171err_free_fields:
172 mailimf_fields_free( fields ); 172 if (fields) mailimf_fields_free( fields );
173err_free_reply: 173err_free_reply:
174 mailimf_address_list_free( reply ); 174 if (reply) mailimf_address_list_free( reply );
175 mailimf_address_list_free( bcc ); 175 if (bcc) mailimf_address_list_free( bcc );
176 mailimf_address_list_free( cc ); 176 if (cc) mailimf_address_list_free( cc );
177 mailimf_address_list_free( to ); 177 if (to) mailimf_address_list_free( to );
178err_free_from: 178err_free_from:
179 mailimf_mailbox_list_free( from ); 179 if (from) mailimf_mailbox_list_free( from );
180err_free_fromBox: 180err_free_fromBox:
181 mailimf_mailbox_free( fromBox ); 181 mailimf_mailbox_free( fromBox );
182err_free_sender: 182err_free_sender:
183 mailimf_mailbox_free( sender ); 183 if (sender) mailimf_mailbox_free( sender );
184err_free: 184err_free:
185 free( subject ); 185 if (subject) free( subject );
186 qDebug( "createImfFields - error" ); 186 qDebug( "createImfFields - error" );
187 187
188 return NULL; // Error :( 188 return NULL; // Error :(
189} 189}
190 190
191mailmime *SMTPwrapper::buildTxtPart(const QString&str ) 191mailmime *SMTPwrapper::buildTxtPart(const QString&str )
192{ 192{
193 mailmime *txtPart; 193 mailmime *txtPart;
194 mailmime_fields *fields; 194 mailmime_fields *fields;
195 mailmime_content *content; 195 mailmime_content *content;
196 mailmime_parameter *param; 196 mailmime_parameter *param;
197 int err; 197 int err;
198 198
199 param = mailmime_parameter_new( strdup( "charset" ), 199 param = mailmime_parameter_new( strdup( "charset" ),
200 strdup( "iso-8859-1" ) ); 200 strdup( "iso-8859-1" ) );
201 if ( param == NULL ) goto err_free; 201 if ( param == NULL ) goto err_free;
202 202
203 content = mailmime_content_new_with_str( "text/plain" ); 203 content = mailmime_content_new_with_str( "text/plain" );
204 if ( content == NULL ) goto err_free_param; 204 if ( content == NULL ) goto err_free_param;
205 205
206 err = clist_append( content->ct_parameters, param ); 206 err = clist_append( content->ct_parameters, param );
207 if ( err != MAILIMF_NO_ERROR ) goto err_free_content; 207 if ( err != MAILIMF_NO_ERROR ) goto err_free_content;
208 208
209 fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_QUOTED_PRINTABLE); 209 fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT);
210 if ( fields == NULL ) goto err_free_content; 210 if ( fields == NULL ) goto err_free_content;
211 211
212 txtPart = mailmime_new_empty( content, fields ); 212 txtPart = mailmime_new_empty( content, fields );
213 if ( txtPart == NULL ) goto err_free_fields; 213 if ( txtPart == NULL ) goto err_free_fields;
214 214
215 err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); 215 err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() );
216 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 216 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
217 217
218 return txtPart; // Success :) 218 return txtPart; // Success :)
219 219
220err_free_txtPart: 220err_free_txtPart:
221 mailmime_free( txtPart ); 221 mailmime_free( txtPart );
222err_free_fields: 222err_free_fields:
223 mailmime_fields_free( fields ); 223 mailmime_fields_free( fields );
224err_free_content: 224err_free_content:
225 mailmime_content_free( content ); 225 mailmime_content_free( content );
226err_free_param: 226err_free_param:
227 mailmime_parameter_free( param ); 227 mailmime_parameter_free( param );
228err_free: 228err_free:
229 qDebug( "buildTxtPart - error" ); 229 qDebug( "buildTxtPart - error" );
230 230
231 return NULL; // Error :( 231 return NULL; // Error :(
232} 232}
233 233
234mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) 234mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent )
235{ 235{
236 mailmime * filePart = 0; 236 mailmime * filePart = 0;
237 mailmime_fields * fields = 0; 237 mailmime_fields * fields = 0;
238 mailmime_content * content = 0; 238 mailmime_content * content = 0;
239 mailmime_parameter * param = 0; 239 mailmime_parameter * param = 0;
240 char*name = 0; 240 char*name = 0;
241 char*file = 0; 241 char*file = 0;
242 int err; 242 int err;
243 243
244 int pos = filename.findRev( '/' ); 244 int pos = filename.findRev( '/' );
245 245
246 if (filename.length()>0) { 246 if (filename.length()>0) {
247 QString tmp = filename.right( filename.length() - ( pos + 1 ) ); 247 QString tmp = filename.right( filename.length() - ( pos + 1 ) );
248 name = strdup( tmp.latin1() ); // just filename 248 name = strdup( tmp.latin1() ); // just filename
249 file = strdup( filename.latin1() ); // full name with path 249 file = strdup( filename.latin1() ); // full name with path
250 } 250 }
251 251
252 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; 252 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT;
253 int mechanism = MAILMIME_MECHANISM_BASE64; 253 int mechanism = MAILMIME_MECHANISM_BASE64;
254 254
255 if ( mimetype.startsWith( "text/" ) ) { 255 if ( mimetype.startsWith( "text/" ) ) {
256 param = mailmime_parameter_new( strdup( "charset" ), 256 param = mailmime_parameter_new( strdup( "charset" ),
257 strdup( "iso-8859-1" ) ); 257 strdup( "iso-8859-1" ) );
258 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 258 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
259 } 259 }
260 260
261 fields = mailmime_fields_new_filename( 261 fields = mailmime_fields_new_filename(
262 disptype, name, 262 disptype, name,
263 mechanism ); 263 mechanism );
264 content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); 264 content = mailmime_content_new_with_str( (char*)mimetype.latin1() );
265 if (content!=0 && fields != 0) { 265 if (content!=0 && fields != 0) {
266 if (param) { 266 if (param) {
267 clist_append(content->ct_parameters,param); 267 clist_append(content->ct_parameters,param);
268 param = 0; 268 param = 0;
269 } 269 }
270 if (filename.length()>0) { 270 if (filename.length()>0) {
271 QFileInfo f(filename); 271 QFileInfo f(filename);
272 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); 272 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1()));
273 clist_append(content->ct_parameters,param); 273 clist_append(content->ct_parameters,param);
274 param = 0; 274 param = 0;
275 } 275 }
276 filePart = mailmime_new_empty( content, fields ); 276 filePart = mailmime_new_empty( content, fields );
277 } 277 }
278 if (filePart) { 278 if (filePart) {
279 if (filename.length()>0) { 279 if (filename.length()>0) {
280 err = mailmime_set_body_file( filePart, file ); 280 err = mailmime_set_body_file( filePart, file );
281 } else { 281 } else {
282 err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); 282 err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length());
283 } 283 }
284 if (err != MAILIMF_NO_ERROR) { 284 if (err != MAILIMF_NO_ERROR) {
285 qDebug("Error setting body with file %s",file); 285 qDebug("Error setting body with file %s",file);
286 mailmime_free( filePart ); 286 mailmime_free( filePart );
287 filePart = 0; 287 filePart = 0;
288 } 288 }
289 } 289 }
290 290
291 if (!filePart) { 291 if (!filePart) {
292 if ( param != NULL ) { 292 if ( param != NULL ) {
293 mailmime_parameter_free( param ); 293 mailmime_parameter_free( param );
294 } 294 }
295 if (content) { 295 if (content) {
296 mailmime_content_free( content ); 296 mailmime_content_free( content );
297 } 297 }
298 if (fields) { 298 if (fields) {
299 mailmime_fields_free( fields ); 299 mailmime_fields_free( fields );
300 } else { 300 } else {
301 if (name) { 301 if (name) {
302 free( name ); 302 free( name );
303 } 303 }
304 if (file) { 304 if (file) {
305 free( file ); 305 free( file );
306 } 306 }
307 } 307 }
308 } 308 }
309 return filePart; // Success :) 309 return filePart; // Success :)
310 310
311} 311}
312 312
313void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) 313void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files )
314{ 314{
315 const Attachment *it; 315 const Attachment *it;
316 unsigned int count = files.count(); 316 unsigned int count = files.count();
317 qDebug("List contains %i values",count); 317 qDebug("List contains %i values",count);
318 for ( unsigned int i = 0; i < count; ++i ) { 318 for ( unsigned int i = 0; i < count; ++i ) {
319 qDebug( "Adding file" ); 319 qDebug( "Adding file" );
320 mailmime *filePart; 320 mailmime *filePart;
321 int err; 321 int err;
322 it = ((QList<Attachment>)files).at(i); 322 it = ((QList<Attachment>)files).at(i);
323 323
324 filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); 324 filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" );
325 if ( filePart == NULL ) { 325 if ( filePart == NULL ) {
326 qDebug( "addFileParts: error adding file:" ); 326 qDebug( "addFileParts: error adding file:" );
327 qDebug( it->getFileName() ); 327 qDebug( it->getFileName() );
328 continue; 328 continue;
329 } 329 }
330 err = mailmime_smart_add_part( message, filePart ); 330 err = mailmime_smart_add_part( message, filePart );
331 if ( err != MAILIMF_NO_ERROR ) { 331 if ( err != MAILIMF_NO_ERROR ) {
332 mailmime_free( filePart ); 332 mailmime_free( filePart );
333 qDebug("error smart add"); 333 qDebug("error smart add");
334 } 334 }
335 } 335 }
336} 336}
337 337
338mailmime *SMTPwrapper::createMimeMail(const Mail &mail ) 338mailmime *SMTPwrapper::createMimeMail(const Mail &mail )
339{ 339{
340 mailmime *message, *txtPart; 340 mailmime *message, *txtPart;
341 mailimf_fields *fields; 341 mailimf_fields *fields;
342 int err; 342 int err;
343 343
344 fields = createImfFields( mail ); 344 fields = createImfFields( mail );
345 if ( fields == NULL ) goto err_free; 345 if ( fields == NULL ) goto err_free;
346 346
347 message = mailmime_new_message_data( NULL ); 347 message = mailmime_new_message_data( NULL );
348 if ( message == NULL ) goto err_free_fields; 348 if ( message == NULL ) goto err_free_fields;
349 349
350 mailmime_set_imf_fields( message, fields ); 350 mailmime_set_imf_fields( message, fields );
351 351
352 txtPart = buildTxtPart( mail.getMessage() ); 352 txtPart = buildTxtPart( mail.getMessage() );
353 353
354 if ( txtPart == NULL ) goto err_free_message; 354 if ( txtPart == NULL ) goto err_free_message;
355 355
356 err = mailmime_smart_add_part( message, txtPart ); 356 err = mailmime_smart_add_part( message, txtPart );
357 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 357 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
358 358
359 addFileParts( message, mail.getAttachments() ); 359 addFileParts( message, mail.getAttachments() );
360 360
361 return message; // Success :) 361 return message; // Success :)
362 362
363err_free_txtPart: 363err_free_txtPart:
364 mailmime_free( txtPart ); 364 mailmime_free( txtPart );
365err_free_message: 365err_free_message:
366 mailmime_free( message ); 366 mailmime_free( message );
367err_free_fields: 367err_free_fields:
368 mailimf_fields_free( fields ); 368 mailimf_fields_free( fields );
369err_free: 369err_free:
370 qDebug( "createMimeMail: error" ); 370 qDebug( "createMimeMail: error" );
371 371
372 return NULL; // Error :( 372 return NULL; // Error :(
373} 373}
374 374
375mailimf_field *SMTPwrapper::getField( mailimf_fields *fields, int type ) 375mailimf_field *SMTPwrapper::getField( mailimf_fields *fields, int type )
376{ 376{
377 mailimf_field *field; 377 mailimf_field *field;
378 clistiter *it; 378 clistiter *it;
379 379
380 it = clist_begin( fields->fld_list ); 380 it = clist_begin( fields->fld_list );
381 while ( it ) { 381 while ( it ) {
382 field = (mailimf_field *) it->data; 382 field = (mailimf_field *) it->data;
383 if ( field->fld_type == type ) { 383 if ( field->fld_type == type ) {
384 return field; 384 return field;
385 } 385 }
386 it = it->next; 386 it = it->next;
387 } 387 }
388 388
389 return NULL; 389 return NULL;
390} 390}
391 391
392void SMTPwrapper::addRcpts( clist *list, mailimf_address_list *addr_list ) 392void SMTPwrapper::addRcpts( clist *list, mailimf_address_list *addr_list )
393{ 393{
394 clistiter *it, *it2; 394 clistiter *it, *it2;
395 395
396 for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { 396 for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) {
397 mailimf_address *addr; 397 mailimf_address *addr;
398 addr = (mailimf_address *) it->data; 398 addr = (mailimf_address *) it->data;
399 399
400 if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { 400 if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) {
401 esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); 401 esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL );
402 } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { 402 } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) {
403 clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; 403 clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list;
404 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { 404 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) {
405 mailimf_mailbox *mbox; 405 mailimf_mailbox *mbox;
406 mbox = (mailimf_mailbox *) it2->data; 406 mbox = (mailimf_mailbox *) it2->data;
407 esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); 407 esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL );
408 } 408 }
409 } 409 }
410 } 410 }
411} 411}
412 412
413clist *SMTPwrapper::createRcptList( mailimf_fields *fields ) 413clist *SMTPwrapper::createRcptList( mailimf_fields *fields )
414{ 414{
415 clist *rcptList; 415 clist *rcptList;
416 mailimf_field *field; 416 mailimf_field *field;
417 417
418 rcptList = esmtp_address_list_new(); 418 rcptList = esmtp_address_list_new();
419 419
420 field = getField( fields, MAILIMF_FIELD_TO ); 420 field = getField( fields, MAILIMF_FIELD_TO );
421 if ( field && (field->fld_type == MAILIMF_FIELD_TO) 421 if ( field && (field->fld_type == MAILIMF_FIELD_TO)
422 && field->fld_data.fld_to->to_addr_list ) { 422 && field->fld_data.fld_to->to_addr_list ) {
423 addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); 423 addRcpts( rcptList, field->fld_data.fld_to->to_addr_list );
424 } 424 }
425 425
426 field = getField( fields, MAILIMF_FIELD_CC ); 426 field = getField( fields, MAILIMF_FIELD_CC );
427 if ( field && (field->fld_type == MAILIMF_FIELD_CC) 427 if ( field && (field->fld_type == MAILIMF_FIELD_CC)
428 && field->fld_data.fld_cc->cc_addr_list ) { 428 && field->fld_data.fld_cc->cc_addr_list ) {
429 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); 429 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list );
430 } 430 }
431 431
432 field = getField( fields, MAILIMF_FIELD_BCC ); 432 field = getField( fields, MAILIMF_FIELD_BCC );
433 if ( field && (field->fld_type == MAILIMF_FIELD_BCC) 433 if ( field && (field->fld_type == MAILIMF_FIELD_BCC)
434 && field->fld_data.fld_bcc->bcc_addr_list ) { 434 && field->fld_data.fld_bcc->bcc_addr_list ) {
435 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); 435 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list );
436 } 436 }
437 437
438 return rcptList; 438 return rcptList;
439} 439}
440 440
441char *SMTPwrapper::getFrom( mailimf_field *ffrom) 441char *SMTPwrapper::getFrom( mailimf_field *ffrom)
442{ 442{
443 char *from = NULL; 443 char *from = NULL;
444 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) 444 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM)
445 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { 445 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) {
446 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; 446 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list;
447 clistiter *it; 447 clistiter *it;
448 for ( it = clist_begin( cl ); it; it = it->next ) { 448 for ( it = clist_begin( cl ); it; it = it->next ) {
449 mailimf_mailbox *mb = (mailimf_mailbox *) it->data; 449 mailimf_mailbox *mb = (mailimf_mailbox *) it->data;
450 from = strdup( mb->mb_addr_spec ); 450 from = strdup( mb->mb_addr_spec );
451 } 451 }
452 } 452 }
453 453
454 return from; 454 return from;
455} 455}
456 456
457char *SMTPwrapper::getFrom( mailmime *mail ) 457char *SMTPwrapper::getFrom( mailmime *mail )
458{ 458{
459 /* no need to delete - its just a pointer to structure content */ 459 /* no need to delete - its just a pointer to structure content */
460 mailimf_field *ffrom = 0; 460 mailimf_field *ffrom = 0;
461 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); 461 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM );
462 return getFrom(ffrom); 462 return getFrom(ffrom);
463} 463}
464 464
465SMTPaccount *SMTPwrapper::getAccount(const QString&name )
466{
467 SMTPaccount *smtp;
468
469 QList<Account> list = settings->getAccounts();
470 Account *it;
471 for ( it = list.first(); it; it = list.next() ) {
472 if ( it->getType().compare( "SMTP" ) == 0 ) {
473 smtp = static_cast<SMTPaccount *>(it);
474 if ( smtp->getName()== name ) {
475 qDebug( "SMTPaccount found for" );
476 qDebug( name );
477 return smtp;
478 }
479 }
480 }
481
482 return NULL;
483}
484
485void SMTPwrapper::progress( size_t current, size_t maximum ) 465void SMTPwrapper::progress( size_t current, size_t maximum )
486{ 466{
487 if (SMTPwrapper::sendProgress) { 467 if (SMTPwrapper::sendProgress) {
488 SMTPwrapper::sendProgress->setSingleMail(current, maximum ); 468 SMTPwrapper::sendProgress->setSingleMail(current, maximum );
489 qApp->processEvents(); 469 qApp->processEvents();
490 } 470 }
491} 471}
492 472
493void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box) 473void SMTPwrapper::storeMail(char*mail, size_t length, const QString&box)
494{ 474{
495 if (!mail) return; 475 if (!mail) return;
496 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 476 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
497 MBOXwrapper*wrap = new MBOXwrapper(localfolders); 477 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
498 wrap->storeMessage(mail,length,box); 478 wrap->storeMessage(mail,length,box);
499 delete wrap; 479 delete wrap;
500} 480}
501 481
502void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ) 482void SMTPwrapper::smtpSend( mailmime *mail,bool later, SMTPaccount *smtp )
503{ 483{
504 clist *rcpts = 0; 484 clist *rcpts = 0;
505 char *from, *data; 485 char *from, *data;
506 size_t size; 486 size_t size;
507 487
508 if ( smtp == NULL ) { 488 if ( smtp == NULL ) {
509 return; 489 return;
510 } 490 }
511 from = data = 0; 491 from = data = 0;
512 492
513 mailmessage * msg = 0; 493 mailmessage * msg = 0;
514 msg = mime_message_init(mail); 494 msg = mime_message_init(mail);
515 mime_message_set_tmpdir(msg,getenv( "HOME" )); 495 mime_message_set_tmpdir(msg,getenv( "HOME" ));
516 int r = mailmessage_fetch(msg,&data,&size); 496 int r = mailmessage_fetch(msg,&data,&size);
517 mime_message_detach_mime(msg); 497 mime_message_detach_mime(msg);
518 mailmessage_free(msg); 498 mailmessage_free(msg);
519 if (r != MAIL_NO_ERROR || !data) { 499 if (r != MAIL_NO_ERROR || !data) {
520 if (data) free(data); 500 if (data) free(data);
521 qDebug("Error fetching mime..."); 501 qDebug("Error fetching mime...");
522 return; 502 return;
523 } 503 }
524 QString tmp = data; 504 QString tmp = data;
525 tmp.replace(QRegExp("\r+",true,false),""); 505 tmp.replace(QRegExp("\r+",true,false),"");
526 msg = 0; 506 msg = 0;
527 if (later) { 507 if (later) {
528 storeMail((char*)tmp.data(),tmp.length(),"Outgoing"); 508 storeMail((char*)tmp.data(),tmp.length(),"Outgoing");
529 if (data) free( data ); 509 if (data) free( data );
530 return; 510 return;
531 } 511 }
532 from = getFrom( mail ); 512 from = getFrom( mail );
533 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); 513 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
534 smtpSend(from,rcpts,data,size,smtp); 514 smtpSend(from,rcpts,data,size,smtp);
535 if (data) {free(data);} 515 if (data) {free(data);}
536 if (from) {free(from);} 516 if (from) {free(from);}
537 if (rcpts) smtp_address_list_free( rcpts ); 517 if (rcpts) smtp_address_list_free( rcpts );
538} 518}
539 519
540int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ) 520int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp )
541{ 521{
542 char *server, *user, *pass; 522 char *server, *user, *pass;
543 bool ssl; 523 bool ssl;
544 uint16_t port; 524 uint16_t port;
545 mailsmtp *session; 525 mailsmtp *session;
546 int err,result; 526 int err,result;
547 527
548 result = 1; 528 result = 1;
549 server = user = pass = 0; 529 server = user = pass = 0;
550 server = strdup( smtp->getServer().latin1() ); 530 server = strdup( smtp->getServer().latin1() );
551 ssl = smtp->getSSL(); 531 ssl = smtp->getSSL();
552 port = smtp->getPort().toUInt(); 532 port = smtp->getPort().toUInt();
553 533
554 session = mailsmtp_new( 20, &progress ); 534 session = mailsmtp_new( 20, &progress );
555 if ( session == NULL ) goto free_mem; 535 if ( session == NULL ) goto free_mem;
556 536
557 qDebug( "Servername %s at port %i", server, port ); 537 qDebug( "Servername %s at port %i", server, port );
558 if ( ssl ) { 538 if ( ssl ) {
559 qDebug( "SSL session" ); 539 qDebug( "SSL session" );
560 err = mailsmtp_ssl_connect( session, server, port ); 540 err = mailsmtp_ssl_connect( session, server, port );
561 } else { 541 } else {
562 qDebug( "No SSL session" ); 542 qDebug( "No SSL session" );
563 err = mailsmtp_socket_connect( session, server, port ); 543 err = mailsmtp_socket_connect( session, server, port );
564 } 544 }
565 if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;} 545 if ( err != MAILSMTP_NO_ERROR ) {result = 0;goto free_mem_session;}
566 546
567 err = mailsmtp_init( session ); 547 err = mailsmtp_init( session );
568 if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;} 548 if ( err != MAILSMTP_NO_ERROR ) {result = 0; goto free_con_session;}
569 549
570 qDebug( "INIT OK" ); 550 qDebug( "INIT OK" );
571 551
572 if ( smtp->getLogin() ) { 552 if ( smtp->getLogin() ) {
573 if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { 553 if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) {
574 // get'em 554 // get'em
575 LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); 555 LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true );
576 login.show(); 556 login.show();
577 if ( QDialog::Accepted == login.exec() ) { 557 if ( QDialog::Accepted == login.exec() ) {
578 // ok 558 // ok
579 user = strdup( login.getUser().latin1() ); 559 user = strdup( login.getUser().latin1() );
580 pass = strdup( login.getPassword().latin1() ); 560 pass = strdup( login.getPassword().latin1() );
581 } else { 561 } else {
582 result = 0; goto free_con_session; 562 result = 0; goto free_con_session;
583 } 563 }
584 } else { 564 } else {
585 user = strdup( smtp->getUser().latin1() ); 565 user = strdup( smtp->getUser().latin1() );
586 pass = strdup( smtp->getPassword().latin1() ); 566 pass = strdup( smtp->getPassword().latin1() );
587 } 567 }
588 qDebug( "session->auth: %i", session->auth); 568 qDebug( "session->auth: %i", session->auth);
589 err = mailsmtp_auth( session, user, pass ); 569 err = mailsmtp_auth( session, user, pass );
590 if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); 570 if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok");
591 qDebug( "Done auth!" ); 571 qDebug( "Done auth!" );
592 } 572 }
593 573
594 err = mailsmtp_send( session, from, rcpts, data, size ); 574 err = mailsmtp_send( session, from, rcpts, data, size );
595 if ( err != MAILSMTP_NO_ERROR ) { 575 if ( err != MAILSMTP_NO_ERROR ) {
596 qDebug("Error sending mail: %s",mailsmtpError(err).latin1()); 576 qDebug("Error sending mail: %s",mailsmtpError(err).latin1());
597 result = 0; goto free_con_session; 577 result = 0; goto free_con_session;
598 } 578 }
599 579
600 qDebug( "Mail sent." ); 580 qDebug( "Mail sent." );
601 storeMail(data,size,"Sent"); 581 storeMail(data,size,"Sent");
602 582
603free_con_session: 583free_con_session:
604 mailsmtp_quit( session ); 584 mailsmtp_quit( session );
605free_mem_session: 585free_mem_session:
606 mailsmtp_free( session ); 586 mailsmtp_free( session );
607free_mem: 587free_mem:
608 if (server) free( server ); 588 if (server) free( server );
609 if ( smtp->getLogin() ) { 589 if ( smtp->getLogin() ) {
610 free( user ); 590 free( user );
611 free( pass ); 591 free( pass );
612 } 592 }
613 return result; 593 return result;
614} 594}
615 595
616void SMTPwrapper::sendMail(const Mail&mail,bool later ) 596void SMTPwrapper::sendMail(const Mail&mail,SMTPaccount*aSmtp,bool later )
617{ 597{
618 mailmime * mimeMail; 598 mailmime * mimeMail;
619 599
620 SMTPaccount *smtp = getAccount(mail.getName()); 600 SMTPaccount *smtp = aSmtp;
621 601
602 if (!later && !smtp) {
603 qDebug("Didn't get any send method - giving up");
604 return;
605 }
622 mimeMail = createMimeMail(mail ); 606 mimeMail = createMimeMail(mail );
623 if ( mimeMail == NULL ) { 607 if ( mimeMail == NULL ) {
624 qDebug( "sendMail: error creating mime mail" ); 608 qDebug( "sendMail: error creating mime mail" );
625 } else { 609 } else {
626 sendProgress = new progressMailSend(); 610 sendProgress = new progressMailSend();
627 sendProgress->show(); 611 sendProgress->show();
628 sendProgress->setMaxMails(1); 612 sendProgress->setMaxMails(1);
629 smtpSend( mimeMail,later,smtp); 613 smtpSend( mimeMail,later,smtp);
630 qDebug("Clean up done"); 614 qDebug("Clean up done");
631 sendProgress->hide(); 615 sendProgress->hide();
632 delete sendProgress; 616 delete sendProgress;
633 sendProgress = 0; 617 sendProgress = 0;
634 mailmime_free( mimeMail ); 618 mailmime_free( mimeMail );
635 } 619 }
636} 620}
637 621
638int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which) 622int SMTPwrapper::sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which)
639{ 623{
640 char*data = 0; 624 char*data = 0;
641 size_t length = 0; 625 size_t length = 0;
642 size_t curTok = 0; 626 size_t curTok = 0;
643 mailimf_fields *fields = 0; 627 mailimf_fields *fields = 0;
644 mailimf_field*ffrom = 0; 628 mailimf_field*ffrom = 0;
645 clist *rcpts = 0; 629 clist *rcpts = 0;
646 char*from = 0; 630 char*from = 0;
647 int res = 0; 631 int res = 0;
648 632
649 wrap->fetchRawBody(*which,&data,&length); 633 wrap->fetchRawBody(*which,&data,&length);
650 if (!data) return 0; 634 if (!data) return 0;
651 int err = mailimf_fields_parse( data, length, &curTok, &fields ); 635 int err = mailimf_fields_parse( data, length, &curTok, &fields );
652 if (err != MAILIMF_NO_ERROR) { 636 if (err != MAILIMF_NO_ERROR) {
653 free(data); 637 free(data);
654 delete wrap; 638 delete wrap;
655 return 0; 639 return 0;
656 } 640 }
657 641
658 rcpts = createRcptList( fields ); 642 rcpts = createRcptList( fields );
659 ffrom = getField(fields, MAILIMF_FIELD_FROM ); 643 ffrom = getField(fields, MAILIMF_FIELD_FROM );
660 from = getFrom(ffrom); 644 from = getFrom(ffrom);
661 645
662 qDebug("Size: %i vs. %i",length,strlen(data)); 646 qDebug("Size: %i vs. %i",length,strlen(data));
663 if (rcpts && from) { 647 if (rcpts && from) {
664 res = smtpSend(from,rcpts,data,length,smtp ); 648 res = smtpSend(from,rcpts,data,length,smtp );
665 } 649 }
666 if (fields) { 650 if (fields) {
667 mailimf_fields_free(fields); 651 mailimf_fields_free(fields);
668 fields = 0; 652 fields = 0;
669 } 653 }
670 if (data) { 654 if (data) {
671 free(data); 655 free(data);
672 } 656 }
673 if (from) { 657 if (from) {
674 free(from); 658 free(from);
675 } 659 }
676 if (rcpts) { 660 if (rcpts) {
677 smtp_address_list_free( rcpts ); 661 smtp_address_list_free( rcpts );
678 } 662 }
679 return res; 663 return res;
680} 664}
681 665
682/* this is a special fun */ 666/* this is a special fun */
683bool SMTPwrapper::flushOutbox(SMTPaccount*smtp) 667bool SMTPwrapper::flushOutbox(SMTPaccount*smtp)
684{ 668{
685 bool returnValue = true; 669 bool returnValue = true;
686 670
687 if (!smtp) return false; 671 if (!smtp) return false;
688 672
689 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/"); 673 QString localfolders = (QString) getenv( "HOME" ) + QString("/Applications/opiemail/localmail/");
690 MBOXwrapper*wrap = new MBOXwrapper(localfolders); 674 MBOXwrapper*wrap = new MBOXwrapper(localfolders);
691 if (!wrap) { 675 if (!wrap) {
692 qDebug("memory error"); 676 qDebug("memory error");
693 return false; 677 return false;
694 } 678 }
695 QList<RecMail> mailsToSend; 679 QList<RecMail> mailsToSend;
696 QList<RecMail> mailsToRemove; 680 QList<RecMail> mailsToRemove;
697 QString mbox("Outgoing"); 681 QString mbox("Outgoing");
698 wrap->listMessages(mbox,mailsToSend); 682 wrap->listMessages(mbox,mailsToSend);
699 if (mailsToSend.count()==0) { 683 if (mailsToSend.count()==0) {
700 delete wrap; 684 delete wrap;
701 return false; 685 return false;
702 } 686 }
703 mailsToSend.setAutoDelete(false); 687 mailsToSend.setAutoDelete(false);
704 sendProgress = new progressMailSend(); 688 sendProgress = new progressMailSend();
705 sendProgress->show(); 689 sendProgress->show();
706 sendProgress->setMaxMails(mailsToSend.count()); 690 sendProgress->setMaxMails(mailsToSend.count());
707 691
708 while (mailsToSend.count()>0) { 692 while (mailsToSend.count()>0) {
709 if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) { 693 if (sendQueuedMail(wrap,smtp,mailsToSend.at(0))==0) {
710 QMessageBox::critical(0,tr("Error sending mail"), 694 QMessageBox::critical(0,tr("Error sending mail"),
711 tr("Error sending queued mail - breaking")); 695 tr("Error sending queued mail - breaking"));
712 returnValue = false; 696 returnValue = false;
713 break; 697 break;
714 } 698 }
715 mailsToRemove.append(mailsToSend.at(0)); 699 mailsToRemove.append(mailsToSend.at(0));
716 mailsToSend.removeFirst(); 700 mailsToSend.removeFirst();
717 sendProgress->setCurrentMails(mailsToRemove.count()); 701 sendProgress->setCurrentMails(mailsToRemove.count());
718 } 702 }
719 sendProgress->hide(); 703 sendProgress->hide();
720 delete sendProgress; 704 delete sendProgress;
721 sendProgress = 0; 705 sendProgress = 0;
722 wrap->deleteMails(mbox,mailsToRemove); 706 wrap->deleteMails(mbox,mailsToRemove);
723 mailsToSend.setAutoDelete(true); 707 mailsToSend.setAutoDelete(true);
724 delete wrap; 708 delete wrap;
725 return returnValue; 709 return returnValue;
726} 710}
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
@@ -1,62 +1,61 @@
1#ifndef SMTPwrapper_H 1#ifndef SMTPwrapper_H
2#define SMTPwrapper_H 2#define SMTPwrapper_H
3 3
4#include <qpe/applnk.h> 4#include <qpe/applnk.h>
5 5
6#include <qbitarray.h> 6#include <qbitarray.h>
7#include <qdatetime.h> 7#include <qdatetime.h>
8#include <libetpan/clist.h> 8#include <libetpan/clist.h>
9 9
10#include "settings.h" 10#include "settings.h"
11 11
12class Mail; 12class Mail;
13class MBOXwrapper; 13class MBOXwrapper;
14class RecMail; 14class RecMail;
15class Attachment; 15class Attachment;
16struct mailimf_fields; 16struct mailimf_fields;
17struct mailimf_field; 17struct mailimf_field;
18struct mailimf_mailbox; 18struct mailimf_mailbox;
19struct mailmime; 19struct mailmime;
20struct mailimf_address_list; 20struct mailimf_address_list;
21class progressMailSend; 21class progressMailSend;
22 22
23class SMTPwrapper : public QObject 23class SMTPwrapper : public QObject
24{ 24{
25 Q_OBJECT 25 Q_OBJECT
26 26
27public: 27public:
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,SMTPaccount*smtp,bool later=false );
31 bool flushOutbox(SMTPaccount*smtp); 31 bool flushOutbox(SMTPaccount*smtp);
32 32
33 static progressMailSend*sendProgress; 33 static progressMailSend*sendProgress;
34protected: 34protected:
35 mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); 35 mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
36 mailimf_fields *createImfFields(const Mail &mail ); 36 mailimf_fields *createImfFields(const Mail &mail );
37 mailmime *createMimeMail(const Mail&mail ); 37 mailmime *createMimeMail(const Mail&mail );
38 38
39 mailimf_address_list *parseAddresses(const QString&addr ); 39 mailimf_address_list *parseAddresses(const QString&addr );
40 void addFileParts( mailmime *message,const QList<Attachment>&files ); 40 void addFileParts( mailmime *message,const QList<Attachment>&files );
41 mailmime *buildTxtPart(const QString&str ); 41 mailmime *buildTxtPart(const QString&str );
42 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); 42 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content);
43 void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp ); 43 void smtpSend( mailmime *mail,bool later, SMTPaccount *smtp );
44 clist *createRcptList( mailimf_fields *fields ); 44 clist *createRcptList( mailimf_fields *fields );
45 SMTPaccount *getAccount(const QString&from );
46 45
47 static void storeMail(char*mail, size_t length, const QString&box); 46 static void storeMail(char*mail, size_t length, const QString&box);
48 static QString mailsmtpError( int err ); 47 static QString mailsmtpError( int err );
49 static void progress( size_t current, size_t maximum ); 48 static void progress( size_t current, size_t maximum );
50 static void addRcpts( clist *list, mailimf_address_list *addr_list ); 49 static void addRcpts( clist *list, mailimf_address_list *addr_list );
51 static char *getFrom( mailmime *mail ); 50 static char *getFrom( mailmime *mail );
52 static char *getFrom( mailimf_field *ffrom); 51 static char *getFrom( mailimf_field *ffrom);
53 static mailimf_field *getField( mailimf_fields *fields, int type ); 52 static mailimf_field *getField( mailimf_fields *fields, int type );
54 int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp ); 53 int smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccount *smtp );
55 54
56 void storeMail(mailmime*mail, const QString&box); 55 void storeMail(mailmime*mail, const QString&box);
57 Settings *settings; 56 Settings *settings;
58 57
59 int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which); 58 int sendQueuedMail(MBOXwrapper*wrap,SMTPaccount*smtp,RecMail*which);
60}; 59};
61 60
62#endif 61#endif