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
@@ -20,33 +20,33 @@ AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFl
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(
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,57 +1,80 @@
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 }
@@ -95,48 +118,48 @@ void 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, "/" );
@@ -150,66 +173,67 @@ void 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,156 +1,298 @@
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>
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
@@ -342,92 +342,69 @@ void POP3config::accept()
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
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
@@ -260,103 +260,78 @@ SMTPaccount::SMTPaccount()
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;
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
@@ -80,52 +80,32 @@ private:
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
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
@@ -115,35 +115,35 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr )
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() );
@@ -154,72 +154,72 @@ mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail )
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 );
@@ -449,52 +449,32 @@ char *SMTPwrapper::getFrom( mailimf_field *ffrom)
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}
@@ -600,38 +580,42 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou
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
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
@@ -14,48 +14,47 @@ class 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
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
@@ -260,103 +260,78 @@ SMTPaccount::SMTPaccount()
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;
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
@@ -80,52 +80,32 @@ private:
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
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
@@ -115,35 +115,35 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr )
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() );
@@ -154,72 +154,72 @@ mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail )
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 );
@@ -449,52 +449,32 @@ char *SMTPwrapper::getFrom( mailimf_field *ffrom)
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}
@@ -600,38 +580,42 @@ int SMTPwrapper::smtpSend(char*from,clist*rcpts,char*data,size_t size, SMTPaccou
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
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
@@ -14,48 +14,47 @@ class 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