summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/composemail.cpp7
-rw-r--r--noncore/net/mail/editaccounts.cpp1
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.cpp2
-rw-r--r--noncore/net/mail/mailwrapper.cpp2
-rw-r--r--noncore/net/mail/main.cpp1
-rw-r--r--noncore/net/mail/mainwindow.cpp1
6 files changed, 0 insertions, 14 deletions
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp
index a17ccb3..88dd780 100644
--- a/noncore/net/mail/composemail.cpp
+++ b/noncore/net/mail/composemail.cpp
@@ -1,180 +1,173 @@
1#include <qt.h> 1#include <qt.h>
2#include <qcombobox.h>
3#include <qmessagebox.h>
4#include <qlistview.h>
5#include <qtabwidget.h>
6#include <qmultilineedit.h>
7#include <qregexp.h>
8 2
9#include <opie/ofiledialog.h> 3#include <opie/ofiledialog.h>
10#include <qpe/resource.h> 4#include <qpe/resource.h>
11 5
12#include "composemail.h" 6#include "composemail.h"
13#include "mailwrapper.h"
14 7
15ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 8ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
16 : ComposeMailUI( parent, name, modal, flags ) 9 : ComposeMailUI( parent, name, modal, flags )
17{ 10{
18 settings = s; 11 settings = s;
19 12
20 attList->addColumn( tr( "Name" ) ); 13 attList->addColumn( tr( "Name" ) );
21 attList->addColumn( tr( "Size" ) ); 14 attList->addColumn( tr( "Size" ) );
22 15
23 QList<Account> accounts = settings->getAccounts(); 16 QList<Account> accounts = settings->getAccounts();
24 Account *it; 17 Account *it;
25 for ( it = accounts.first(); it; it = accounts.next() ) { 18 for ( it = accounts.first(); it; it = accounts.next() ) {
26 if ( it->getType().compare( "SMTP" ) == 0 ) { 19 if ( it->getType().compare( "SMTP" ) == 0 ) {
27 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 20 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
28 fromBox->insertItem( smtp->getMail() ); 21 fromBox->insertItem( smtp->getMail() );
29 smtpAccounts.append( smtp ); 22 smtpAccounts.append( smtp );
30 } 23 }
31 } 24 }
32 25
33 if ( smtpAccounts.count() > 0 ) { 26 if ( smtpAccounts.count() > 0 ) {
34 fillValues( fromBox->currentItem() ); 27 fillValues( fromBox->currentItem() );
35 } else { 28 } else {
36 QMessageBox::information( this, tr( "Problem" ), 29 QMessageBox::information( this, tr( "Problem" ),
37 tr( "<p>Please create an SMTP account first.</p>" ), 30 tr( "<p>Please create an SMTP account first.</p>" ),
38 tr( "Ok" ) ); 31 tr( "Ok" ) );
39 } 32 }
40 33
41 connect( fromBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) ); 34 connect( fromBox, SIGNAL( activated( int ) ), SLOT( fillValues( int ) ) );
42 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 35 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
43 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 36 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
44 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 37 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
45 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 38 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
46 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 39 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
47 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 40 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
48} 41}
49 42
50void ComposeMail::pickAddress( QLineEdit *line ) 43void ComposeMail::pickAddress( QLineEdit *line )
51{ 44{
52 QString names = AddressPicker::getNames(); 45 QString names = AddressPicker::getNames();
53 if ( line->text().isEmpty() ) { 46 if ( line->text().isEmpty() ) {
54 line->setText( names ); 47 line->setText( names );
55 } else if ( !names.isEmpty() ) { 48 } else if ( !names.isEmpty() ) {
56 line->setText( line->text() + ", " + names ); 49 line->setText( line->text() + ", " + names );
57 } 50 }
58} 51}
59 52
60void ComposeMail::pickAddressTo() 53void ComposeMail::pickAddressTo()
61{ 54{
62 pickAddress( toLine ); 55 pickAddress( toLine );
63} 56}
64 57
65void ComposeMail::pickAddressCC() 58void ComposeMail::pickAddressCC()
66{ 59{
67 pickAddress( ccLine ); 60 pickAddress( ccLine );
68} 61}
69 62
70void ComposeMail::pickAddressBCC() 63void ComposeMail::pickAddressBCC()
71{ 64{
72 pickAddress( bccLine ); 65 pickAddress( bccLine );
73} 66}
74 67
75void ComposeMail::pickAddressReply() 68void ComposeMail::pickAddressReply()
76{ 69{
77 pickAddress( replyLine ); 70 pickAddress( replyLine );
78} 71}
79 72
80void ComposeMail::fillValues( int current ) 73void ComposeMail::fillValues( int current )
81{ 74{
82 SMTPaccount *smtp = smtpAccounts.at( current ); 75 SMTPaccount *smtp = smtpAccounts.at( current );
83 76
84 ccLine->clear(); 77 ccLine->clear();
85 if ( smtp->getUseCC() ) { 78 if ( smtp->getUseCC() ) {
86 ccLine->setText( smtp->getCC() ); 79 ccLine->setText( smtp->getCC() );
87 } 80 }
88 bccLine->clear(); 81 bccLine->clear();
89 if ( smtp->getUseBCC() ) { 82 if ( smtp->getUseBCC() ) {
90 bccLine->setText( smtp->getBCC() ); 83 bccLine->setText( smtp->getBCC() );
91 } 84 }
92 replyLine->clear(); 85 replyLine->clear();
93 if ( smtp->getUseReply() ) { 86 if ( smtp->getUseReply() ) {
94 replyLine->setText( smtp->getReply() ); 87 replyLine->setText( smtp->getReply() );
95 } 88 }
96 89
97 sigMultiLine->setText( smtp->getSignature() ); 90 sigMultiLine->setText( smtp->getSignature() );
98} 91}
99 92
100void ComposeMail::slotAdjustColumns() 93void ComposeMail::slotAdjustColumns()
101{ 94{
102 int currPage = tabWidget->currentPageIndex(); 95 int currPage = tabWidget->currentPageIndex();
103 96
104 tabWidget->showPage( attachTab ); 97 tabWidget->showPage( attachTab );
105 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 98 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
106 attList->setColumnWidth( 1, 80 ); 99 attList->setColumnWidth( 1, 80 );
107 100
108 tabWidget->setCurrentPage( currPage ); 101 tabWidget->setCurrentPage( currPage );
109} 102}
110 103
111void ComposeMail::addAttachment() 104void ComposeMail::addAttachment()
112{ 105{
113 DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" ); 106 DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" );
114 if ( !lnk.name().isEmpty() ) { 107 if ( !lnk.name().isEmpty() ) {
115 Attachment *att = new Attachment( lnk ); 108 Attachment *att = new Attachment( lnk );
116 (void) new AttachViewItem( attList, att ); 109 (void) new AttachViewItem( attList, att );
117 } 110 }
118} 111}
119 112
120void ComposeMail::removeAttachment() 113void ComposeMail::removeAttachment()
121{ 114{
122 if ( !attList->currentItem() ) { 115 if ( !attList->currentItem() ) {
123 QMessageBox::information( this, tr( "Error" ), 116 QMessageBox::information( this, tr( "Error" ),
124 tr( "<p>Please select a File.</p>" ), 117 tr( "<p>Please select a File.</p>" ),
125 tr( "Ok" ) ); 118 tr( "Ok" ) );
126 } else { 119 } else {
127 attList->takeItem( attList->currentItem() ); 120 attList->takeItem( attList->currentItem() );
128 } 121 }
129} 122}
130 123
131void ComposeMail::accept() 124void ComposeMail::accept()
132{ 125{
133 qDebug( "Sending Mail with " + 126 qDebug( "Sending Mail with " +
134 smtpAccounts.at( fromBox->currentItem() )->getAccountName() ); 127 smtpAccounts.at( fromBox->currentItem() )->getAccountName() );
135 Mail *mail = new Mail(); 128 Mail *mail = new Mail();
136 SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() ); 129 SMTPaccount *smtp = smtpAccounts.at( fromBox->currentItem() );
137 mail->setMail( smtp->getMail() ); 130 mail->setMail( smtp->getMail() );
138 mail->setName( smtp->getName() ); 131 mail->setName( smtp->getName() );
139 132
140 if ( !toLine->text().isEmpty() ) { 133 if ( !toLine->text().isEmpty() ) {
141 mail->setTo( toLine->text() ); 134 mail->setTo( toLine->text() );
142 } else { 135 } else {
143 qDebug( "No Reciever spezified -> returning" ); 136 qDebug( "No Reciever spezified -> returning" );
144 return; 137 return;
145 } 138 }
146 139
147 mail->setCC( ccLine->text() ); 140 mail->setCC( ccLine->text() );
148 mail->setBCC( bccLine->text() ); 141 mail->setBCC( bccLine->text() );
149 mail->setReply( replyLine->text() ); 142 mail->setReply( replyLine->text() );
150 mail->setSubject( subjectLine->text() ); 143 mail->setSubject( subjectLine->text() );
151 QString txt = message->text(); 144 QString txt = message->text();
152 if ( !sigMultiLine->text().isEmpty() ) { 145 if ( !sigMultiLine->text().isEmpty() ) {
153 txt.append( "\n--\n" ); 146 txt.append( "\n--\n" );
154 txt.append( sigMultiLine->text() ); 147 txt.append( sigMultiLine->text() );
155 } 148 }
156 mail->setMessage( txt ); 149 mail->setMessage( txt );
157 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 150 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
158 while ( it != NULL ) { 151 while ( it != NULL ) {
159 mail->addAttachment( it->getAttachment() ); 152 mail->addAttachment( it->getAttachment() );
160 it = (AttachViewItem *) it->itemBelow(); 153 it = (AttachViewItem *) it->itemBelow();
161 } 154 }
162 155
163 MailWrapper wrapper( settings ); 156 MailWrapper wrapper( settings );
164 wrapper.sendMail( *mail ); 157 wrapper.sendMail( *mail );
165 158
166 QDialog::accept(); 159 QDialog::accept();
167} 160}
168 161
169AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 162AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
170 : QListViewItem( parent ) 163 : QListViewItem( parent )
171{ 164{
172 attachment = att; 165 attachment = att;
173 qDebug( att->getMimeType() ); 166 qDebug( att->getMimeType() );
174 setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? 167 setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ?
175 Resource::loadPixmap( "UnknownDocument-14" ) : 168 Resource::loadPixmap( "UnknownDocument-14" ) :
176 attachment->getDocLnk().pixmap() ); 169 attachment->getDocLnk().pixmap() );
177 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 170 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
178 setText( 1, QString::number( att->getSize() ) ); 171 setText( 1, QString::number( att->getSize() ) );
179} 172}
180 173
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp
index 7e2dd24..1c80adb 100644
--- a/noncore/net/mail/editaccounts.cpp
+++ b/noncore/net/mail/editaccounts.cpp
@@ -1,471 +1,470 @@
1#include <qt.h> 1#include <qt.h>
2#include <qtabwidget.h>
3 2
4#include "defines.h" 3#include "defines.h"
5#include "editaccounts.h" 4#include "editaccounts.h"
6 5
7AccountListItem::AccountListItem( QListView *parent, Account *a) 6AccountListItem::AccountListItem( QListView *parent, Account *a)
8 : QListViewItem( parent ) 7 : QListViewItem( parent )
9{ 8{
10 account = a; 9 account = a;
11 setText( 0, account->getAccountName() ); 10 setText( 0, account->getAccountName() );
12 setText( 1, account->getType() ); 11 setText( 1, account->getType() );
13} 12}
14 13
15EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 14EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
16 : EditAccountsUI( parent, name, modal, flags ) 15 : EditAccountsUI( parent, name, modal, flags )
17{ 16{
18 qDebug( "New Account Configuration Widget" ); 17 qDebug( "New Account Configuration Widget" );
19 settings = s; 18 settings = s;
20 19
21 mailList->addColumn( tr( "Account" ) ); 20 mailList->addColumn( tr( "Account" ) );
22 mailList->addColumn( tr( "Type" ) ); 21 mailList->addColumn( tr( "Type" ) );
23 22
24 newsList->addColumn( tr( "Account" ) ); 23 newsList->addColumn( tr( "Account" ) );
25 24
26 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); 25 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) );
27 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); 26 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) );
28 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); 27 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) );
29 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); 28 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) );
30 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); 29 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) );
31 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); 30 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) );
32 31
33 slotFillLists(); 32 slotFillLists();
34} 33}
35 34
36void EditAccounts::slotFillLists() 35void EditAccounts::slotFillLists()
37{ 36{
38 mailList->clear(); 37 mailList->clear();
39 newsList->clear(); 38 newsList->clear();
40 39
41 QList<Account> accounts = settings->getAccounts(); 40 QList<Account> accounts = settings->getAccounts();
42 Account *it; 41 Account *it;
43 for ( it = accounts.first(); it; it = accounts.next() ) { 42 for ( it = accounts.first(); it; it = accounts.next() ) {
44 if ( it->getType().compare( "NNTP" ) == 0 ) { 43 if ( it->getType().compare( "NNTP" ) == 0 ) {
45 (void) new AccountListItem( newsList, it ); 44 (void) new AccountListItem( newsList, it );
46 } else { 45 } else {
47 (void) new AccountListItem( mailList, it ); 46 (void) new AccountListItem( mailList, it );
48 } 47 }
49 } 48 }
50} 49}
51 50
52void EditAccounts::slotNewMail() 51void EditAccounts::slotNewMail()
53{ 52{
54 qDebug( "New Mail Account" ); 53 qDebug( "New Mail Account" );
55 QString *selection = new QString(); 54 QString *selection = new QString();
56 SelectMailType selType( selection, this, 0, true ); 55 SelectMailType selType( selection, this, 0, true );
57 selType.show(); 56 selType.show();
58 if ( QDialog::Accepted == selType.exec() ) { 57 if ( QDialog::Accepted == selType.exec() ) {
59 slotNewAccount( *selection ); 58 slotNewAccount( *selection );
60 } 59 }
61} 60}
62 61
63void EditAccounts::slotNewAccount( const QString &type ) 62void EditAccounts::slotNewAccount( const QString &type )
64{ 63{
65 if ( type.compare( "IMAP" ) == 0 ) { 64 if ( type.compare( "IMAP" ) == 0 ) {
66 qDebug( "-> config IMAP" ); 65 qDebug( "-> config IMAP" );
67 IMAPaccount *account = new IMAPaccount(); 66 IMAPaccount *account = new IMAPaccount();
68 IMAPconfig imap( account, this, 0, true ); 67 IMAPconfig imap( account, this, 0, true );
69 imap.showMaximized(); 68 imap.showMaximized();
70 if ( QDialog::Accepted == imap.exec() ) { 69 if ( QDialog::Accepted == imap.exec() ) {
71 settings->addAccount( account ); 70 settings->addAccount( account );
72 account->save(); 71 account->save();
73 slotFillLists(); 72 slotFillLists();
74 } else { 73 } else {
75 account->remove(); 74 account->remove();
76 } 75 }
77 } else if ( type.compare( "POP3" ) == 0 ) { 76 } else if ( type.compare( "POP3" ) == 0 ) {
78 qDebug( "-> config POP3" ); 77 qDebug( "-> config POP3" );
79 POP3account *account = new POP3account(); 78 POP3account *account = new POP3account();
80 POP3config pop3( account, this, 0, true ); 79 POP3config pop3( account, this, 0, true );
81 pop3.showMaximized(); 80 pop3.showMaximized();
82 if ( QDialog::Accepted == pop3.exec() ) { 81 if ( QDialog::Accepted == pop3.exec() ) {
83 settings->addAccount( account ); 82 settings->addAccount( account );
84 account->save(); 83 account->save();
85 slotFillLists(); 84 slotFillLists();
86 } else { 85 } else {
87 account->remove(); 86 account->remove();
88 } 87 }
89 } else if ( type.compare( "SMTP" ) == 0 ) { 88 } else if ( type.compare( "SMTP" ) == 0 ) {
90 qDebug( "-> config SMTP" ); 89 qDebug( "-> config SMTP" );
91 SMTPaccount *account = new SMTPaccount(); 90 SMTPaccount *account = new SMTPaccount();
92 SMTPconfig smtp( account, this, 0, true ); 91 SMTPconfig smtp( account, this, 0, true );
93 smtp.showMaximized(); 92 smtp.showMaximized();
94 if ( QDialog::Accepted == smtp.exec() ) { 93 if ( QDialog::Accepted == smtp.exec() ) {
95 settings->addAccount( account ); 94 settings->addAccount( account );
96 account->save(); 95 account->save();
97 slotFillLists(); 96 slotFillLists();
98 } else { 97 } else {
99 account->remove(); 98 account->remove();
100 } 99 }
101 } else if ( type.compare( "NNTP" ) == 0 ) { 100 } else if ( type.compare( "NNTP" ) == 0 ) {
102 qDebug( "-> config NNTP" ); 101 qDebug( "-> config NNTP" );
103 NNTPaccount *account = new NNTPaccount(); 102 NNTPaccount *account = new NNTPaccount();
104 NNTPconfig nntp( account, this, 0, true ); 103 NNTPconfig nntp( account, this, 0, true );
105 nntp.showMaximized(); 104 nntp.showMaximized();
106 if ( QDialog::Accepted == nntp.exec() ) { 105 if ( QDialog::Accepted == nntp.exec() ) {
107 settings->addAccount( account ); 106 settings->addAccount( account );
108 account->save(); 107 account->save();
109 slotFillLists(); 108 slotFillLists();
110 } else { 109 } else {
111 account->remove(); 110 account->remove();
112 } 111 }
113 } 112 }
114} 113}
115 114
116void EditAccounts::slotEditAccount( Account *account ) 115void EditAccounts::slotEditAccount( Account *account )
117{ 116{
118 if ( account->getType().compare( "IMAP" ) == 0 ) { 117 if ( account->getType().compare( "IMAP" ) == 0 ) {
119 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); 118 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account);
120 IMAPconfig imap( imapAcc, this, 0, true ); 119 IMAPconfig imap( imapAcc, this, 0, true );
121 imap.showMaximized(); 120 imap.showMaximized();
122 if ( QDialog::Accepted == imap.exec() ) { 121 if ( QDialog::Accepted == imap.exec() ) {
123 slotFillLists(); 122 slotFillLists();
124 } 123 }
125 } else if ( account->getType().compare( "POP3" ) == 0 ) { 124 } else if ( account->getType().compare( "POP3" ) == 0 ) {
126 POP3account *pop3Acc = static_cast<POP3account *>(account); 125 POP3account *pop3Acc = static_cast<POP3account *>(account);
127 POP3config pop3( pop3Acc, this, 0, true ); 126 POP3config pop3( pop3Acc, this, 0, true );
128 pop3.showMaximized(); 127 pop3.showMaximized();
129 if ( QDialog::Accepted == pop3.exec() ) { 128 if ( QDialog::Accepted == pop3.exec() ) {
130 slotFillLists(); 129 slotFillLists();
131 } 130 }
132 } else if ( account->getType().compare( "SMTP" ) == 0 ) { 131 } else if ( account->getType().compare( "SMTP" ) == 0 ) {
133 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); 132 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account);
134 SMTPconfig smtp( smtpAcc, this, 0, true ); 133 SMTPconfig smtp( smtpAcc, this, 0, true );
135 smtp.showMaximized(); 134 smtp.showMaximized();
136 if ( QDialog::Accepted == smtp.exec() ) { 135 if ( QDialog::Accepted == smtp.exec() ) {
137 slotFillLists(); 136 slotFillLists();
138 } 137 }
139 } else if ( account->getType().compare( "NNTP" ) == 0 ) { 138 } else if ( account->getType().compare( "NNTP" ) == 0 ) {
140 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); 139 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account);
141 NNTPconfig nntp( nntpAcc, this, 0, true ); 140 NNTPconfig nntp( nntpAcc, this, 0, true );
142 nntp.showMaximized(); 141 nntp.showMaximized();
143 if ( QDialog::Accepted == nntp.exec() ) { 142 if ( QDialog::Accepted == nntp.exec() ) {
144 slotFillLists(); 143 slotFillLists();
145 } 144 }
146 } 145 }
147} 146}
148 147
149void EditAccounts::slotDeleteAccount( Account *account ) 148void EditAccounts::slotDeleteAccount( Account *account )
150{ 149{
151 if ( QMessageBox::information( this, tr( "Question" ), 150 if ( QMessageBox::information( this, tr( "Question" ),
152 tr( "<p>Do you really want to delete the selected Account?</p>" ), 151 tr( "<p>Do you really want to delete the selected Account?</p>" ),
153 tr( "Yes" ), tr( "No" ) ) == 0 ) { 152 tr( "Yes" ), tr( "No" ) ) == 0 ) {
154 settings->delAccount( account ); 153 settings->delAccount( account );
155 slotFillLists(); 154 slotFillLists();
156 } 155 }
157} 156}
158 157
159void EditAccounts::slotEditMail() 158void EditAccounts::slotEditMail()
160{ 159{
161 qDebug( "Edit Mail Account" ); 160 qDebug( "Edit Mail Account" );
162 if ( !mailList->currentItem() ) { 161 if ( !mailList->currentItem() ) {
163 QMessageBox::information( this, tr( "Error" ), 162 QMessageBox::information( this, tr( "Error" ),
164 tr( "<p>Please select an account.</p>" ), 163 tr( "<p>Please select an account.</p>" ),
165 tr( "Ok" ) ); 164 tr( "Ok" ) );
166 return; 165 return;
167 } 166 }
168 167
169 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 168 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
170 slotEditAccount( a ); 169 slotEditAccount( a );
171} 170}
172 171
173void EditAccounts::slotDeleteMail() 172void EditAccounts::slotDeleteMail()
174{ 173{
175 if ( !mailList->currentItem() ) { 174 if ( !mailList->currentItem() ) {
176 QMessageBox::information( this, tr( "Error" ), 175 QMessageBox::information( this, tr( "Error" ),
177 tr( "<p>Please select an account.</p>" ), 176 tr( "<p>Please select an account.</p>" ),
178 tr( "Ok" ) ); 177 tr( "Ok" ) );
179 return; 178 return;
180 } 179 }
181 180
182 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 181 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
183 slotDeleteAccount( a ); 182 slotDeleteAccount( a );
184} 183}
185 184
186void EditAccounts::slotNewNews() 185void EditAccounts::slotNewNews()
187{ 186{
188 qDebug( "New News Account" ); 187 qDebug( "New News Account" );
189 slotNewAccount( "NNTP" ); 188 slotNewAccount( "NNTP" );
190} 189}
191 190
192void EditAccounts::slotEditNews() 191void EditAccounts::slotEditNews()
193{ 192{
194 qDebug( "Edit News Account" ); 193 qDebug( "Edit News Account" );
195 if ( !newsList->currentItem() ) { 194 if ( !newsList->currentItem() ) {
196 QMessageBox::information( this, tr( "Error" ), 195 QMessageBox::information( this, tr( "Error" ),
197 tr( "<p>Please select an account.</p>" ), 196 tr( "<p>Please select an account.</p>" ),
198 tr( "Ok" ) ); 197 tr( "Ok" ) );
199 return; 198 return;
200 } 199 }
201 200
202 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 201 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
203 slotEditAccount( a ); 202 slotEditAccount( a );
204} 203}
205 204
206void EditAccounts::slotDeleteNews() 205void EditAccounts::slotDeleteNews()
207{ 206{
208 qDebug( "Delete News Account" ); 207 qDebug( "Delete News Account" );
209 if ( !newsList->currentItem() ) { 208 if ( !newsList->currentItem() ) {
210 QMessageBox::information( this, tr( "Error" ), 209 QMessageBox::information( this, tr( "Error" ),
211 tr( "<p>Please select an account.</p>" ), 210 tr( "<p>Please select an account.</p>" ),
212 tr( "Ok" ) ); 211 tr( "Ok" ) );
213 return; 212 return;
214 } 213 }
215 214
216 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 215 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
217 slotDeleteAccount( a ); 216 slotDeleteAccount( a );
218} 217}
219 218
220void EditAccounts::slotAdjustColumns() 219void EditAccounts::slotAdjustColumns()
221{ 220{
222 int currPage = configTab->currentPageIndex(); 221 int currPage = configTab->currentPageIndex();
223 222
224 configTab->showPage( mailTab ); 223 configTab->showPage( mailTab );
225 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); 224 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 );
226 mailList->setColumnWidth( 1, 50 ); 225 mailList->setColumnWidth( 1, 50 );
227 226
228 configTab->showPage( newsTab ); 227 configTab->showPage( newsTab );
229 newsList->setColumnWidth( 0, newsList->visibleWidth() ); 228 newsList->setColumnWidth( 0, newsList->visibleWidth() );
230 229
231 configTab->setCurrentPage( currPage ); 230 configTab->setCurrentPage( currPage );
232} 231}
233 232
234void EditAccounts::accept() 233void EditAccounts::accept()
235{ 234{
236 settings->saveAccounts(); 235 settings->saveAccounts();
237 236
238 QDialog::accept(); 237 QDialog::accept();
239} 238}
240 239
241/** 240/**
242 * SelectMailType 241 * SelectMailType
243 */ 242 */
244 243
245SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) 244SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags )
246 : SelectMailTypeUI( parent, name, modal, flags ) 245 : SelectMailTypeUI( parent, name, modal, flags )
247{ 246{
248 selected = selection; 247 selected = selection;
249 selected->replace( 0, selected->length(), typeBox->currentText() ); 248 selected->replace( 0, selected->length(), typeBox->currentText() );
250 connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) ); 249 connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) );
251} 250}
252 251
253void SelectMailType::slotSelection( const QString &sel ) 252void SelectMailType::slotSelection( const QString &sel )
254{ 253{
255 selected->replace( 0, selected->length(), sel ); 254 selected->replace( 0, selected->length(), sel );
256} 255}
257 256
258/** 257/**
259 * IMAPconfig 258 * IMAPconfig
260 */ 259 */
261 260
262IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 261IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
263 : IMAPconfigUI( parent, name, modal, flags ) 262 : IMAPconfigUI( parent, name, modal, flags )
264{ 263{
265 data = account; 264 data = account;
266 265
267 fillValues(); 266 fillValues();
268 267
269 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); 268 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) );
270} 269}
271 270
272void IMAPconfig::slotSSL( bool enabled ) 271void IMAPconfig::slotSSL( bool enabled )
273{ 272{
274 if ( enabled ) { 273 if ( enabled ) {
275 portLine->setText( IMAP_SSL_PORT ); 274 portLine->setText( IMAP_SSL_PORT );
276 } else { 275 } else {
277 portLine->setText( IMAP_PORT ); 276 portLine->setText( IMAP_PORT );
278 } 277 }
279} 278}
280 279
281void IMAPconfig::fillValues() 280void IMAPconfig::fillValues()
282{ 281{
283 accountLine->setText( data->getAccountName() ); 282 accountLine->setText( data->getAccountName() );
284 serverLine->setText( data->getServer() ); 283 serverLine->setText( data->getServer() );
285 portLine->setText( data->getPort() ); 284 portLine->setText( data->getPort() );
286 sslBox->setChecked( data->getSSL() ); 285 sslBox->setChecked( data->getSSL() );
287 userLine->setText( data->getUser() ); 286 userLine->setText( data->getUser() );
288 passLine->setText( data->getPassword() ); 287 passLine->setText( data->getPassword() );
289 prefixLine->setText(data->getPrefix()); 288 prefixLine->setText(data->getPrefix());
290} 289}
291 290
292void IMAPconfig::accept() 291void IMAPconfig::accept()
293{ 292{
294 data->setAccountName( accountLine->text() ); 293 data->setAccountName( accountLine->text() );
295 data->setServer( serverLine->text() ); 294 data->setServer( serverLine->text() );
296 data->setPort( portLine->text() ); 295 data->setPort( portLine->text() );
297 data->setSSL( sslBox->isChecked() ); 296 data->setSSL( sslBox->isChecked() );
298 data->setUser( userLine->text() ); 297 data->setUser( userLine->text() );
299 data->setPassword( passLine->text() ); 298 data->setPassword( passLine->text() );
300 data->setPrefix(prefixLine->text()); 299 data->setPrefix(prefixLine->text());
301 300
302 QDialog::accept(); 301 QDialog::accept();
303} 302}
304 303
305/** 304/**
306 * POP3config 305 * POP3config
307 */ 306 */
308 307
309POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 308POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
310 : POP3configUI( parent, name, modal, flags ) 309 : POP3configUI( parent, name, modal, flags )
311{ 310{
312 data = account; 311 data = account;
313 fillValues(); 312 fillValues();
314 313
315 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); 314 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) );
316} 315}
317 316
318void POP3config::slotSSL( bool enabled ) 317void POP3config::slotSSL( bool enabled )
319{ 318{
320 if ( enabled ) { 319 if ( enabled ) {
321 portLine->setText( POP3_SSL_PORT ); 320 portLine->setText( POP3_SSL_PORT );
322 } else { 321 } else {
323 portLine->setText( POP3_PORT ); 322 portLine->setText( POP3_PORT );
324 } 323 }
325} 324}
326 325
327void POP3config::fillValues() 326void POP3config::fillValues()
328{ 327{
329 accountLine->setText( data->getAccountName() ); 328 accountLine->setText( data->getAccountName() );
330 serverLine->setText( data->getServer() ); 329 serverLine->setText( data->getServer() );
331 portLine->setText( data->getPort() ); 330 portLine->setText( data->getPort() );
332 sslBox->setChecked( data->getSSL() ); 331 sslBox->setChecked( data->getSSL() );
333 userLine->setText( data->getUser() ); 332 userLine->setText( data->getUser() );
334 passLine->setText( data->getPassword() ); 333 passLine->setText( data->getPassword() );
335} 334}
336 335
337void POP3config::accept() 336void POP3config::accept()
338{ 337{
339 data->setAccountName( accountLine->text() ); 338 data->setAccountName( accountLine->text() );
340 data->setServer( serverLine->text() ); 339 data->setServer( serverLine->text() );
341 data->setPort( portLine->text() ); 340 data->setPort( portLine->text() );
342 data->setSSL( sslBox->isChecked() ); 341 data->setSSL( sslBox->isChecked() );
343 data->setUser( userLine->text() ); 342 data->setUser( userLine->text() );
344 data->setPassword( passLine->text() ); 343 data->setPassword( passLine->text() );
345 344
346 QDialog::accept(); 345 QDialog::accept();
347} 346}
348 347
349/** 348/**
350 * SMTPconfig 349 * SMTPconfig
351 */ 350 */
352 351
353SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 352SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
354 : SMTPconfigUI( parent, name, modal, flags ) 353 : SMTPconfigUI( parent, name, modal, flags )
355{ 354{
356 data = account; 355 data = account;
357 356
358 connect( ccBox, SIGNAL( toggled( bool ) ), ccLine, SLOT( setEnabled( bool ) ) ); 357 connect( ccBox, SIGNAL( toggled( bool ) ), ccLine, SLOT( setEnabled( bool ) ) );
359 connect( bccBox, SIGNAL( toggled( bool ) ), bccLine, SLOT( setEnabled( bool ) ) ); 358 connect( bccBox, SIGNAL( toggled( bool ) ), bccLine, SLOT( setEnabled( bool ) ) );
360 connect( replyBox, SIGNAL( toggled( bool ) ), replyLine, SLOT( setEnabled( bool ) ) ); 359 connect( replyBox, SIGNAL( toggled( bool ) ), replyLine, SLOT( setEnabled( bool ) ) );
361 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); 360 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) );
362 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); 361 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) );
363 362
364 fillValues(); 363 fillValues();
365 364
366 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); 365 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) );
367} 366}
368 367
369void SMTPconfig::slotSSL( bool enabled ) 368void SMTPconfig::slotSSL( bool enabled )
370{ 369{
371 if ( enabled ) { 370 if ( enabled ) {
372 portLine->setText( SMTP_SSL_PORT ); 371 portLine->setText( SMTP_SSL_PORT );
373 } else { 372 } else {
374 portLine->setText( SMTP_PORT ); 373 portLine->setText( SMTP_PORT );
375 } 374 }
376} 375}
377 376
378void SMTPconfig::fillValues() 377void SMTPconfig::fillValues()
379{ 378{
380 accountLine->setText( data->getAccountName() ); 379 accountLine->setText( data->getAccountName() );
381 serverLine->setText( data->getServer() ); 380 serverLine->setText( data->getServer() );
382 portLine->setText( data->getPort() ); 381 portLine->setText( data->getPort() );
383 sslBox->setChecked( data->getSSL() ); 382 sslBox->setChecked( data->getSSL() );
384 loginBox->setChecked( data->getLogin() ); 383 loginBox->setChecked( data->getLogin() );
385 userLine->setText( data->getUser() ); 384 userLine->setText( data->getUser() );
386 passLine->setText( data->getPassword() ); 385 passLine->setText( data->getPassword() );
387 nameLine->setText( data->getName() ); 386 nameLine->setText( data->getName() );
388 mailLine->setText( data->getMail() ); 387 mailLine->setText( data->getMail() );
389 orgLine->setText( data->getOrg() ); 388 orgLine->setText( data->getOrg() );
390 ccBox->setChecked( data->getUseCC() ); 389 ccBox->setChecked( data->getUseCC() );
391 ccLine->setText( data->getCC() ); 390 ccLine->setText( data->getCC() );
392 bccBox->setChecked( data->getUseBCC() ); 391 bccBox->setChecked( data->getUseBCC() );
393 bccLine->setText( data->getBCC() ); 392 bccLine->setText( data->getBCC() );
394 replyBox->setChecked( data->getUseReply() ); 393 replyBox->setChecked( data->getUseReply() );
395 replyLine->setText( data->getReply() ); 394 replyLine->setText( data->getReply() );
396 sigMultiLine->setText( data->getSignature() ); 395 sigMultiLine->setText( data->getSignature() );
397} 396}
398 397
399void SMTPconfig::accept() 398void SMTPconfig::accept()
400{ 399{
401 data->setAccountName( accountLine->text() ); 400 data->setAccountName( accountLine->text() );
402 data->setServer( serverLine->text() ); 401 data->setServer( serverLine->text() );
403 data->setPort( portLine->text() ); 402 data->setPort( portLine->text() );
404 data->setSSL( sslBox->isChecked() ); 403 data->setSSL( sslBox->isChecked() );
405 data->setLogin( loginBox->isChecked() ); 404 data->setLogin( loginBox->isChecked() );
406 data->setUser( userLine->text() ); 405 data->setUser( userLine->text() );
407 data->setPassword( passLine->text() ); 406 data->setPassword( passLine->text() );
408 data->setName( nameLine->text() ); 407 data->setName( nameLine->text() );
409 data->setMail( mailLine->text() ); 408 data->setMail( mailLine->text() );
410 data->setOrg( orgLine->text() ); 409 data->setOrg( orgLine->text() );
411 data->setCC( ccLine->text() ); 410 data->setCC( ccLine->text() );
412 data->setUseCC( ccBox->isChecked() ); 411 data->setUseCC( ccBox->isChecked() );
413 data->setBCC( bccLine->text() ); 412 data->setBCC( bccLine->text() );
414 data->setUseBCC( bccBox->isChecked() ); 413 data->setUseBCC( bccBox->isChecked() );
415 data->setReply( replyLine->text() ); 414 data->setReply( replyLine->text() );
416 data->setUseReply( replyBox->isChecked() ); 415 data->setUseReply( replyBox->isChecked() );
417 data->setSignature( sigMultiLine->text() ); 416 data->setSignature( sigMultiLine->text() );
418 417
419 QDialog::accept(); 418 QDialog::accept();
420} 419}
421 420
422/** 421/**
423 * NNTPconfig 422 * NNTPconfig
424 */ 423 */
425 424
426NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 425NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
427 : NNTPconfigUI( parent, name, modal, flags ) 426 : NNTPconfigUI( parent, name, modal, flags )
428{ 427{
429 data = account; 428 data = account;
430 429
431 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); 430 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) );
432 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); 431 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) );
433 432
434 fillValues(); 433 fillValues();
435 434
436 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); 435 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) );
437} 436}
438 437
439void NNTPconfig::slotSSL( bool enabled ) 438void NNTPconfig::slotSSL( bool enabled )
440{ 439{
441 if ( enabled ) { 440 if ( enabled ) {
442 portLine->setText( NNTP_SSL_PORT ); 441 portLine->setText( NNTP_SSL_PORT );
443 } else { 442 } else {
444 portLine->setText( NNTP_PORT ); 443 portLine->setText( NNTP_PORT );
445 } 444 }
446} 445}
447 446
448void NNTPconfig::fillValues() 447void NNTPconfig::fillValues()
449{ 448{
450 accountLine->setText( data->getAccountName() ); 449 accountLine->setText( data->getAccountName() );
451 serverLine->setText( data->getServer() ); 450 serverLine->setText( data->getServer() );
452 portLine->setText( data->getPort() ); 451 portLine->setText( data->getPort() );
453 sslBox->setChecked( data->getSSL() ); 452 sslBox->setChecked( data->getSSL() );
454 loginBox->setChecked( data->getLogin() ); 453 loginBox->setChecked( data->getLogin() );
455 userLine->setText( data->getUser() ); 454 userLine->setText( data->getUser() );
456 passLine->setText( data->getPassword() ); 455 passLine->setText( data->getPassword() );
457} 456}
458 457
459void NNTPconfig::accept() 458void NNTPconfig::accept()
460{ 459{
461 data->setAccountName( accountLine->text() ); 460 data->setAccountName( accountLine->text() );
462 data->setServer( serverLine->text() ); 461 data->setServer( serverLine->text() );
463 data->setPort( portLine->text() ); 462 data->setPort( portLine->text() );
464 data->setSSL( sslBox->isChecked() ); 463 data->setSSL( sslBox->isChecked() );
465 data->setLogin( loginBox->isChecked() ); 464 data->setLogin( loginBox->isChecked() );
466 data->setUser( userLine->text() ); 465 data->setUser( userLine->text() );
467 data->setPassword( passLine->text() ); 466 data->setPassword( passLine->text() );
468 467
469 QDialog::accept(); 468 QDialog::accept();
470} 469}
471 470
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
index 13a3fd9..ea9e7b2 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
@@ -1,521 +1,519 @@
1#include <qfileinfo.h>
2#include <stdlib.h> 1#include <stdlib.h>
3#include <sys/stat.h> 2#include <sys/stat.h>
4#include <sys/types.h> 3#include <sys/types.h>
5#include <unistd.h> 4#include <unistd.h>
6#include <fcntl.h> 5#include <fcntl.h>
7#include <string.h> 6#include <string.h>
8#include <qdir.h> 7#include <qdir.h>
9#include <qtextstream.h>
10 8
11#include "mailwrapper.h" 9#include "mailwrapper.h"
12#include "logindialog.h" 10#include "logindialog.h"
13//#include "mail.h" 11//#include "mail.h"
14#include "defines.h" 12#include "defines.h"
15 13
16Attachment::Attachment( DocLnk lnk ) 14Attachment::Attachment( DocLnk lnk )
17{ 15{
18 doc = lnk; 16 doc = lnk;
19 size = QFileInfo( doc.file() ).size(); 17 size = QFileInfo( doc.file() ).size();
20} 18}
21 19
22Folder::Folder(const QString&tmp_name ) 20Folder::Folder(const QString&tmp_name )
23{ 21{
24 name = tmp_name; 22 name = tmp_name;
25 nameDisplay = name; 23 nameDisplay = name;
26 24
27 for ( int pos = nameDisplay.find( '&' ); pos != -1; 25 for ( int pos = nameDisplay.find( '&' ); pos != -1;
28 pos = nameDisplay.find( '&' ) ) { 26 pos = nameDisplay.find( '&' ) ) {
29 int end = nameDisplay.find( '-' ); 27 int end = nameDisplay.find( '-' );
30 if ( end == -1 || end <= pos ) break; 28 if ( end == -1 || end <= pos ) break;
31 QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); 29 QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 );
32 // TODO: do real base64 decoding here ! 30 // TODO: do real base64 decoding here !
33 if ( str64.compare( "APw" ) == 0 ) { 31 if ( str64.compare( "APw" ) == 0 ) {
34 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); 32 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" );
35 } else if ( str64.compare( "APY" ) == 0 ) { 33 } else if ( str64.compare( "APY" ) == 0 ) {
36 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); 34 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" );
37 } 35 }
38 } 36 }
39 37
40 qDebug( "folder " + name + " - displayed as " + nameDisplay ); 38 qDebug( "folder " + name + " - displayed as " + nameDisplay );
41} 39}
42 40
43MailWrapper::MailWrapper( Settings *s ) 41MailWrapper::MailWrapper( Settings *s )
44 : QObject() 42 : QObject()
45{ 43{
46 settings = s; 44 settings = s;
47} 45}
48 46
49QString MailWrapper::mailsmtpError( int errnum ) 47QString MailWrapper::mailsmtpError( int errnum )
50{ 48{
51 switch ( errnum ) { 49 switch ( errnum ) {
52 case MAILSMTP_NO_ERROR: 50 case MAILSMTP_NO_ERROR:
53 return tr( "No error" ); 51 return tr( "No error" );
54 case MAILSMTP_ERROR_UNEXPECTED_CODE: 52 case MAILSMTP_ERROR_UNEXPECTED_CODE:
55 return tr( "Unexpected error code" ); 53 return tr( "Unexpected error code" );
56 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 54 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
57 return tr( "Service not available" ); 55 return tr( "Service not available" );
58 case MAILSMTP_ERROR_STREAM: 56 case MAILSMTP_ERROR_STREAM:
59 return tr( "Stream error" ); 57 return tr( "Stream error" );
60 case MAILSMTP_ERROR_HOSTNAME: 58 case MAILSMTP_ERROR_HOSTNAME:
61 return tr( "gethostname() failed" ); 59 return tr( "gethostname() failed" );
62 case MAILSMTP_ERROR_NOT_IMPLEMENTED: 60 case MAILSMTP_ERROR_NOT_IMPLEMENTED:
63 return tr( "Not implemented" ); 61 return tr( "Not implemented" );
64 case MAILSMTP_ERROR_ACTION_NOT_TAKEN: 62 case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
65 return tr( "Error, action not taken" ); 63 return tr( "Error, action not taken" );
66 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: 64 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
67 return tr( "Data exceeds storage allocation" ); 65 return tr( "Data exceeds storage allocation" );
68 case MAILSMTP_ERROR_IN_PROCESSING: 66 case MAILSMTP_ERROR_IN_PROCESSING:
69 return tr( "Error in processing" ); 67 return tr( "Error in processing" );
70 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: 68 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
71 // return tr( "Insufficient system storage" ); 69 // return tr( "Insufficient system storage" );
72 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: 70 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
73 return tr( "Mailbox unavailable" ); 71 return tr( "Mailbox unavailable" );
74 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: 72 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
75 return tr( "Mailbox name not allowed" ); 73 return tr( "Mailbox name not allowed" );
76 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: 74 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
77 return tr( "Bad command sequence" ); 75 return tr( "Bad command sequence" );
78 case MAILSMTP_ERROR_USER_NOT_LOCAL: 76 case MAILSMTP_ERROR_USER_NOT_LOCAL:
79 return tr( "User not local" ); 77 return tr( "User not local" );
80 case MAILSMTP_ERROR_TRANSACTION_FAILED: 78 case MAILSMTP_ERROR_TRANSACTION_FAILED:
81 return tr( "Transaction failed" ); 79 return tr( "Transaction failed" );
82 case MAILSMTP_ERROR_MEMORY: 80 case MAILSMTP_ERROR_MEMORY:
83 return tr( "Memory error" ); 81 return tr( "Memory error" );
84 case MAILSMTP_ERROR_CONNECTION_REFUSED: 82 case MAILSMTP_ERROR_CONNECTION_REFUSED:
85 return tr( "Connection refused" ); 83 return tr( "Connection refused" );
86 default: 84 default:
87 return tr( "Unknown error code" ); 85 return tr( "Unknown error code" );
88 } 86 }
89} 87}
90 88
91mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail ) 89mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail )
92{ 90{
93 return mailimf_mailbox_new( strdup( name.latin1() ), 91 return mailimf_mailbox_new( strdup( name.latin1() ),
94 strdup( mail.latin1() ) ); 92 strdup( mail.latin1() ) );
95} 93}
96 94
97mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) 95mailimf_address_list *MailWrapper::parseAddresses(const QString&addr )
98{ 96{
99 mailimf_address_list *addresses; 97 mailimf_address_list *addresses;
100 98
101 if ( addr.isEmpty() ) return NULL; 99 if ( addr.isEmpty() ) return NULL;
102 100
103 addresses = mailimf_address_list_new_empty(); 101 addresses = mailimf_address_list_new_empty();
104 102
105 QStringList list = QStringList::split( ',', addr ); 103 QStringList list = QStringList::split( ',', addr );
106 QStringList::Iterator it; 104 QStringList::Iterator it;
107 for ( it = list.begin(); it != list.end(); it++ ) { 105 for ( it = list.begin(); it != list.end(); it++ ) {
108 char *str = strdup( (*it).latin1() ); 106 char *str = strdup( (*it).latin1() );
109 int err = mailimf_address_list_add_parse( addresses, str ); 107 int err = mailimf_address_list_add_parse( addresses, str );
110 if ( err != MAILIMF_NO_ERROR ) { 108 if ( err != MAILIMF_NO_ERROR ) {
111 qDebug( "Error parsing" ); 109 qDebug( "Error parsing" );
112 qDebug( *it ); 110 qDebug( *it );
113 free( str ); 111 free( str );
114 } else { 112 } else {
115 qDebug( "Parse success! :)" ); 113 qDebug( "Parse success! :)" );
116 } 114 }
117 } 115 }
118 116
119 return addresses; 117 return addresses;
120} 118}
121 119
122mailimf_fields *MailWrapper::createImfFields( Mail *mail ) 120mailimf_fields *MailWrapper::createImfFields( Mail *mail )
123{ 121{
124 mailimf_fields *fields; 122 mailimf_fields *fields;
125 mailimf_field *xmailer; 123 mailimf_field *xmailer;
126 mailimf_mailbox *sender, *fromBox; 124 mailimf_mailbox *sender, *fromBox;
127 mailimf_mailbox_list *from; 125 mailimf_mailbox_list *from;
128 mailimf_address_list *to, *cc, *bcc, *reply; 126 mailimf_address_list *to, *cc, *bcc, *reply;
129 char *subject = strdup( mail->getSubject().latin1() ); 127 char *subject = strdup( mail->getSubject().latin1() );
130 int err; 128 int err;
131 129
132 sender = newMailbox( mail->getName(), mail->getMail() ); 130 sender = newMailbox( mail->getName(), mail->getMail() );
133 if ( sender == NULL ) goto err_free; 131 if ( sender == NULL ) goto err_free;
134 132
135 fromBox = newMailbox( mail->getName(), mail->getMail() ); 133 fromBox = newMailbox( mail->getName(), mail->getMail() );
136 if ( fromBox == NULL ) goto err_free_sender; 134 if ( fromBox == NULL ) goto err_free_sender;
137 135
138 from = mailimf_mailbox_list_new_empty(); 136 from = mailimf_mailbox_list_new_empty();
139 if ( from == NULL ) goto err_free_fromBox; 137 if ( from == NULL ) goto err_free_fromBox;
140 138
141 err = mailimf_mailbox_list_add( from, fromBox ); 139 err = mailimf_mailbox_list_add( from, fromBox );
142 if ( err != MAILIMF_NO_ERROR ) goto err_free_from; 140 if ( err != MAILIMF_NO_ERROR ) goto err_free_from;
143 141
144 to = parseAddresses( mail->getTo() ); 142 to = parseAddresses( mail->getTo() );
145 if ( to == NULL ) goto err_free_from; 143 if ( to == NULL ) goto err_free_from;
146 144
147 cc = parseAddresses( mail->getCC() ); 145 cc = parseAddresses( mail->getCC() );
148 bcc = parseAddresses( mail->getBCC() ); 146 bcc = parseAddresses( mail->getBCC() );
149 reply = parseAddresses( mail->getReply() ); 147 reply = parseAddresses( mail->getReply() );
150 148
151 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, 149 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc,
152 NULL, NULL, subject ); 150 NULL, NULL, subject );
153 if ( fields == NULL ) goto err_free_reply; 151 if ( fields == NULL ) goto err_free_reply;
154 152
155 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), 153 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ),
156 strdup( USER_AGENT ) ); 154 strdup( USER_AGENT ) );
157 if ( xmailer == NULL ) goto err_free_fields; 155 if ( xmailer == NULL ) goto err_free_fields;
158 156
159 err = mailimf_fields_add( fields, xmailer ); 157 err = mailimf_fields_add( fields, xmailer );
160 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; 158 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer;
161 159
162 return fields; // Success :) 160 return fields; // Success :)
163 161
164err_free_xmailer: 162err_free_xmailer:
165 mailimf_field_free( xmailer ); 163 mailimf_field_free( xmailer );
166err_free_fields: 164err_free_fields:
167 mailimf_fields_free( fields ); 165 mailimf_fields_free( fields );
168err_free_reply: 166err_free_reply:
169 mailimf_address_list_free( reply ); 167 mailimf_address_list_free( reply );
170 mailimf_address_list_free( bcc ); 168 mailimf_address_list_free( bcc );
171 mailimf_address_list_free( cc ); 169 mailimf_address_list_free( cc );
172 mailimf_address_list_free( to ); 170 mailimf_address_list_free( to );
173err_free_from: 171err_free_from:
174 mailimf_mailbox_list_free( from ); 172 mailimf_mailbox_list_free( from );
175err_free_fromBox: 173err_free_fromBox:
176 mailimf_mailbox_free( fromBox ); 174 mailimf_mailbox_free( fromBox );
177err_free_sender: 175err_free_sender:
178 mailimf_mailbox_free( sender ); 176 mailimf_mailbox_free( sender );
179err_free: 177err_free:
180 free( subject ); 178 free( subject );
181 qDebug( "createImfFields - error" ); 179 qDebug( "createImfFields - error" );
182 180
183 return NULL; // Error :( 181 return NULL; // Error :(
184} 182}
185 183
186mailmime *MailWrapper::buildTxtPart( QString str ) 184mailmime *MailWrapper::buildTxtPart( QString str )
187{ 185{
188 mailmime *txtPart; 186 mailmime *txtPart;
189 mailmime_fields *fields; 187 mailmime_fields *fields;
190 mailmime_content *content; 188 mailmime_content *content;
191 mailmime_parameter *param; 189 mailmime_parameter *param;
192 char *txt = strdup( str.latin1() ); 190 char *txt = strdup( str.latin1() );
193 int err; 191 int err;
194 192
195 param = mailmime_parameter_new( strdup( "charset" ), 193 param = mailmime_parameter_new( strdup( "charset" ),
196 strdup( "iso-8859-1" ) ); 194 strdup( "iso-8859-1" ) );
197 if ( param == NULL ) goto err_free; 195 if ( param == NULL ) goto err_free;
198 196
199 content = mailmime_content_new_with_str( "text/plain" ); 197 content = mailmime_content_new_with_str( "text/plain" );
200 if ( content == NULL ) goto err_free_param; 198 if ( content == NULL ) goto err_free_param;
201 199
202 err = clist_append( content->parameters, param ); 200 err = clist_append( content->parameters, param );
203 if ( err != MAILIMF_NO_ERROR ) goto err_free_content; 201 if ( err != MAILIMF_NO_ERROR ) goto err_free_content;
204 202
205 fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); 203 fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT );
206 if ( fields == NULL ) goto err_free_content; 204 if ( fields == NULL ) goto err_free_content;
207 205
208 txtPart = mailmime_new_empty( content, fields ); 206 txtPart = mailmime_new_empty( content, fields );
209 if ( txtPart == NULL ) goto err_free_fields; 207 if ( txtPart == NULL ) goto err_free_fields;
210 208
211 err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); 209 err = mailmime_set_body_text( txtPart, txt, strlen( txt ) );
212 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 210 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
213 211
214 return txtPart; // Success :) 212 return txtPart; // Success :)
215 213
216err_free_txtPart: 214err_free_txtPart:
217 mailmime_free( txtPart ); 215 mailmime_free( txtPart );
218err_free_fields: 216err_free_fields:
219 mailmime_fields_free( fields ); 217 mailmime_fields_free( fields );
220err_free_content: 218err_free_content:
221 mailmime_content_free( content ); 219 mailmime_content_free( content );
222err_free_param: 220err_free_param:
223 mailmime_parameter_free( param ); 221 mailmime_parameter_free( param );
224err_free: 222err_free:
225 free( txt ); 223 free( txt );
226 qDebug( "buildTxtPart - error" ); 224 qDebug( "buildTxtPart - error" );
227 225
228 return NULL; // Error :( 226 return NULL; // Error :(
229} 227}
230 228
231mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) 229mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype )
232{ 230{
233 mailmime * filePart; 231 mailmime * filePart;
234 mailmime_fields * fields; 232 mailmime_fields * fields;
235 mailmime_content * content; 233 mailmime_content * content;
236 mailmime_parameter * param = NULL; 234 mailmime_parameter * param = NULL;
237 int err; 235 int err;
238 236
239 int pos = filename.findRev( '/' ); 237 int pos = filename.findRev( '/' );
240 QString tmp = filename.right( filename.length() - ( pos + 1 ) ); 238 QString tmp = filename.right( filename.length() - ( pos + 1 ) );
241 char *name = strdup( tmp.latin1() ); // just filename 239 char *name = strdup( tmp.latin1() ); // just filename
242 char *file = strdup( filename.latin1() ); // full name with path 240 char *file = strdup( filename.latin1() ); // full name with path
243 char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain 241 char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain
244 242
245 fields = mailmime_fields_new_filename( 243 fields = mailmime_fields_new_filename(
246 MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, 244 MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name,
247 MAILMIME_MECHANISM_BASE64 ); 245 MAILMIME_MECHANISM_BASE64 );
248 if ( fields == NULL ) goto err_free; 246 if ( fields == NULL ) goto err_free;
249 247
250 content = mailmime_content_new_with_str( mime ); 248 content = mailmime_content_new_with_str( mime );
251 if ( content == NULL ) goto err_free_fields; 249 if ( content == NULL ) goto err_free_fields;
252 250
253 if ( mimetype.compare( "text/plain" ) == 0 ) { 251 if ( mimetype.compare( "text/plain" ) == 0 ) {
254 param = mailmime_parameter_new( strdup( "charset" ), 252 param = mailmime_parameter_new( strdup( "charset" ),
255 strdup( "iso-8859-1" ) ); 253 strdup( "iso-8859-1" ) );
256 if ( param == NULL ) goto err_free_content; 254 if ( param == NULL ) goto err_free_content;
257 255
258 err = clist_append( content->parameters, param ); 256 err = clist_append( content->parameters, param );
259 if ( err != MAILIMF_NO_ERROR ) goto err_free_param; 257 if ( err != MAILIMF_NO_ERROR ) goto err_free_param;
260 } 258 }
261 259
262 filePart = mailmime_new_empty( content, fields ); 260 filePart = mailmime_new_empty( content, fields );
263 if ( filePart == NULL ) goto err_free_param; 261 if ( filePart == NULL ) goto err_free_param;
264 262
265 err = mailmime_set_body_file( filePart, file ); 263 err = mailmime_set_body_file( filePart, file );
266 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; 264 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart;
267 265
268 return filePart; // Success :) 266 return filePart; // Success :)
269 267
270err_free_filePart: 268err_free_filePart:
271 mailmime_free( filePart ); 269 mailmime_free( filePart );
272err_free_param: 270err_free_param:
273 if ( param != NULL ) mailmime_parameter_free( param ); 271 if ( param != NULL ) mailmime_parameter_free( param );
274err_free_content: 272err_free_content:
275 mailmime_content_free( content ); 273 mailmime_content_free( content );
276err_free_fields: 274err_free_fields:
277 mailmime_fields_free( fields ); 275 mailmime_fields_free( fields );
278err_free: 276err_free:
279 free( name ); 277 free( name );
280 free( mime ); 278 free( mime );
281 free( file ); 279 free( file );
282 qDebug( "buildFilePart - error" ); 280 qDebug( "buildFilePart - error" );
283 281
284 return NULL; // Error :( 282 return NULL; // Error :(
285} 283}
286 284
287void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files ) 285void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files )
288{ 286{
289 Attachment *it; 287 Attachment *it;
290 for ( it = files.first(); it; it = files.next() ) { 288 for ( it = files.first(); it; it = files.next() ) {
291 qDebug( "Adding file" ); 289 qDebug( "Adding file" );
292 mailmime *filePart; 290 mailmime *filePart;
293 int err; 291 int err;
294 292
295 filePart = buildFilePart( it->getFileName(), it->getMimeType() ); 293 filePart = buildFilePart( it->getFileName(), it->getMimeType() );
296 if ( filePart == NULL ) goto err_free; 294 if ( filePart == NULL ) goto err_free;
297 295
298 err = mailmime_smart_add_part( message, filePart ); 296 err = mailmime_smart_add_part( message, filePart );
299 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; 297 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart;
300 298
301 continue; // Success :) 299 continue; // Success :)
302 300
303 err_free_filePart: 301 err_free_filePart:
304 mailmime_free( filePart ); 302 mailmime_free( filePart );
305 err_free: 303 err_free:
306 qDebug( "addFileParts: error adding file:" ); 304 qDebug( "addFileParts: error adding file:" );
307 qDebug( it->getFileName() ); 305 qDebug( it->getFileName() );
308 } 306 }
309} 307}
310 308
311mailmime *MailWrapper::createMimeMail( Mail *mail ) 309mailmime *MailWrapper::createMimeMail( Mail *mail )
312{ 310{
313 mailmime *message, *txtPart; 311 mailmime *message, *txtPart;
314 mailimf_fields *fields; 312 mailimf_fields *fields;
315 int err; 313 int err;
316 314
317 fields = createImfFields( mail ); 315 fields = createImfFields( mail );
318 if ( fields == NULL ) goto err_free; 316 if ( fields == NULL ) goto err_free;
319 317
320 message = mailmime_new_message_data( NULL ); 318 message = mailmime_new_message_data( NULL );
321 if ( message == NULL ) goto err_free_fields; 319 if ( message == NULL ) goto err_free_fields;
322 320
323 mailmime_set_imf_fields( message, fields ); 321 mailmime_set_imf_fields( message, fields );
324 322
325 txtPart = buildTxtPart( mail->getMessage() ); 323 txtPart = buildTxtPart( mail->getMessage() );
326 if ( txtPart == NULL ) goto err_free_message; 324 if ( txtPart == NULL ) goto err_free_message;
327 325
328 err = mailmime_smart_add_part( message, txtPart ); 326 err = mailmime_smart_add_part( message, txtPart );
329 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 327 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
330 328
331 addFileParts( message, mail->getAttachments() ); 329 addFileParts( message, mail->getAttachments() );
332 330
333 return message; // Success :) 331 return message; // Success :)
334 332
335err_free_txtPart: 333err_free_txtPart:
336 mailmime_free( txtPart ); 334 mailmime_free( txtPart );
337err_free_message: 335err_free_message:
338 mailmime_free( message ); 336 mailmime_free( message );
339err_free_fields: 337err_free_fields:
340 mailimf_fields_free( fields ); 338 mailimf_fields_free( fields );
341err_free: 339err_free:
342 qDebug( "createMimeMail: error" ); 340 qDebug( "createMimeMail: error" );
343 341
344 return NULL; // Error :( 342 return NULL; // Error :(
345} 343}
346 344
347mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type ) 345mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type )
348{ 346{
349 mailimf_field *field; 347 mailimf_field *field;
350 clistiter *it; 348 clistiter *it;
351 349
352 it = clist_begin( fields->list ); 350 it = clist_begin( fields->list );
353 while ( it ) { 351 while ( it ) {
354 field = (mailimf_field *) it->data; 352 field = (mailimf_field *) it->data;
355 if ( field->type == type ) { 353 if ( field->type == type ) {
356 return field; 354 return field;
357 } 355 }
358 it = it->next; 356 it = it->next;
359 } 357 }
360 358
361 return NULL; 359 return NULL;
362} 360}
363 361
364static void addRcpts( clist *list, mailimf_address_list *addr_list ) 362static void addRcpts( clist *list, mailimf_address_list *addr_list )
365{ 363{
366 clistiter *it, *it2; 364 clistiter *it, *it2;
367 365
368 for ( it = clist_begin( addr_list->list ); it; it = it->next ) { 366 for ( it = clist_begin( addr_list->list ); it; it = it->next ) {
369 mailimf_address *addr; 367 mailimf_address *addr;
370 addr = (mailimf_address *) it->data; 368 addr = (mailimf_address *) it->data;
371 369
372 if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) { 370 if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) {
373 esmtp_address_list_add( list, addr->mailbox->addr_spec, 0, NULL ); 371 esmtp_address_list_add( list, addr->mailbox->addr_spec, 0, NULL );
374 } else if ( addr->type == MAILIMF_ADDRESS_GROUP ) { 372 } else if ( addr->type == MAILIMF_ADDRESS_GROUP ) {
375 clist *l = addr->group->mb_list->list; 373 clist *l = addr->group->mb_list->list;
376 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { 374 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) {
377 mailimf_mailbox *mbox; 375 mailimf_mailbox *mbox;
378 mbox = (mailimf_mailbox *) it2->data; 376 mbox = (mailimf_mailbox *) it2->data;
379 esmtp_address_list_add( list, mbox->addr_spec, 0, NULL ); 377 esmtp_address_list_add( list, mbox->addr_spec, 0, NULL );
380 } 378 }
381 } 379 }
382 } 380 }
383} 381}
384 382
385clist *MailWrapper::createRcptList( mailimf_fields *fields ) 383clist *MailWrapper::createRcptList( mailimf_fields *fields )
386{ 384{
387 clist *rcptList; 385 clist *rcptList;
388 mailimf_field *field; 386 mailimf_field *field;
389 387
390 rcptList = esmtp_address_list_new(); 388 rcptList = esmtp_address_list_new();
391 389
392 field = getField( fields, MAILIMF_FIELD_TO ); 390 field = getField( fields, MAILIMF_FIELD_TO );
393 if ( field && (field->type == MAILIMF_FIELD_TO) 391 if ( field && (field->type == MAILIMF_FIELD_TO)
394 && field->field.to->addr_list ) { 392 && field->field.to->addr_list ) {
395 addRcpts( rcptList, field->field.to->addr_list ); 393 addRcpts( rcptList, field->field.to->addr_list );
396 } 394 }
397 395
398 field = getField( fields, MAILIMF_FIELD_CC ); 396 field = getField( fields, MAILIMF_FIELD_CC );
399 if ( field && (field->type == MAILIMF_FIELD_CC) 397 if ( field && (field->type == MAILIMF_FIELD_CC)
400 && field->field.cc->addr_list ) { 398 && field->field.cc->addr_list ) {
401 addRcpts( rcptList, field->field.cc->addr_list ); 399 addRcpts( rcptList, field->field.cc->addr_list );
402 } 400 }
403 401
404 field = getField( fields, MAILIMF_FIELD_BCC ); 402 field = getField( fields, MAILIMF_FIELD_BCC );
405 if ( field && (field->type == MAILIMF_FIELD_BCC) 403 if ( field && (field->type == MAILIMF_FIELD_BCC)
406 && field->field.bcc->addr_list ) { 404 && field->field.bcc->addr_list ) {
407 addRcpts( rcptList, field->field.bcc->addr_list ); 405 addRcpts( rcptList, field->field.bcc->addr_list );
408 } 406 }
409 407
410 return rcptList; 408 return rcptList;
411} 409}
412 410
413char *MailWrapper::getFrom( mailmime *mail ) 411char *MailWrapper::getFrom( mailmime *mail )
414{ 412{
415 char *from = NULL; 413 char *from = NULL;
416 414
417 mailimf_field *ffrom; 415 mailimf_field *ffrom;
418 ffrom = getField( mail->fields, MAILIMF_FIELD_FROM ); 416 ffrom = getField( mail->fields, MAILIMF_FIELD_FROM );
419 if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) 417 if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM)
420 && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) { 418 && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) {
421 clist *cl = ffrom->field.from->mb_list->list; 419 clist *cl = ffrom->field.from->mb_list->list;
422 clistiter *it; 420 clistiter *it;
423 for ( it = clist_begin( cl ); it; it = it->next ) { 421 for ( it = clist_begin( cl ); it; it = it->next ) {
424 mailimf_mailbox *mb = (mailimf_mailbox *) it->data; 422 mailimf_mailbox *mb = (mailimf_mailbox *) it->data;
425 from = strdup( mb->addr_spec ); 423 from = strdup( mb->addr_spec );
426 } 424 }
427 } 425 }
428 426
429 return from; 427 return from;
430} 428}
431 429
432SMTPaccount *MailWrapper::getAccount( QString from ) 430SMTPaccount *MailWrapper::getAccount( QString from )
433{ 431{
434 SMTPaccount *smtp; 432 SMTPaccount *smtp;
435 433
436 QList<Account> list = settings->getAccounts(); 434 QList<Account> list = settings->getAccounts();
437 Account *it; 435 Account *it;
438 for ( it = list.first(); it; it = list.next() ) { 436 for ( it = list.first(); it; it = list.next() ) {
439 if ( it->getType().compare( "SMTP" ) == 0 ) { 437 if ( it->getType().compare( "SMTP" ) == 0 ) {
440 smtp = static_cast<SMTPaccount *>(it); 438 smtp = static_cast<SMTPaccount *>(it);
441 if ( smtp->getMail().compare( from ) == 0 ) { 439 if ( smtp->getMail().compare( from ) == 0 ) {
442 qDebug( "SMTPaccount found for" ); 440 qDebug( "SMTPaccount found for" );
443 qDebug( from ); 441 qDebug( from );
444 return smtp; 442 return smtp;
445 } 443 }
446 } 444 }
447 } 445 }
448 446
449 return NULL; 447 return NULL;
450} 448}
451 449
452QString MailWrapper::getTmpFile() { 450QString MailWrapper::getTmpFile() {
453 int num = 0; 451 int num = 0;
454 QString unique; 452 QString unique;
455 453
456 QDir dir( "/tmp" ); 454 QDir dir( "/tmp" );
457 QStringList::Iterator it; 455 QStringList::Iterator it;
458 456
459 QStringList list = dir.entryList( "opiemail-tmp-*" ); 457 QStringList list = dir.entryList( "opiemail-tmp-*" );
460 do { 458 do {
461 unique.setNum( num++ ); 459 unique.setNum( num++ );
462 } while ( list.contains( "opiemail-tmp-" + unique ) > 0 ); 460 } while ( list.contains( "opiemail-tmp-" + unique ) > 0 );
463 461
464 return "/tmp/opiemail-tmp-" + unique; 462 return "/tmp/opiemail-tmp-" + unique;
465} 463}
466 464
467void MailWrapper::writeToFile( QString file, mailmime *mail ) 465void MailWrapper::writeToFile( QString file, mailmime *mail )
468{ 466{
469 FILE *f; 467 FILE *f;
470 int err, col = 0; 468 int err, col = 0;
471 469
472 f = fopen( file.latin1(), "w" ); 470 f = fopen( file.latin1(), "w" );
473 if ( f == NULL ) { 471 if ( f == NULL ) {
474 qDebug( "writeToFile: error opening file" ); 472 qDebug( "writeToFile: error opening file" );
475 return; 473 return;
476 } 474 }
477 475
478 err = mailmime_write( f, &col, mail ); 476 err = mailmime_write( f, &col, mail );
479 if ( err != MAILIMF_NO_ERROR ) { 477 if ( err != MAILIMF_NO_ERROR ) {
480 fclose( f ); 478 fclose( f );
481 qDebug( "writeToFile: error writing mailmime" ); 479 qDebug( "writeToFile: error writing mailmime" );
482 return; 480 return;
483 } 481 }
484 482
485 fclose( f ); 483 fclose( f );
486} 484}
487 485
488void MailWrapper::readFromFile( QString file, char **data, size_t *size ) 486void MailWrapper::readFromFile( QString file, char **data, size_t *size )
489{ 487{
490 char *buf; 488 char *buf;
491 struct stat st; 489 struct stat st;
492 int fd, count = 0, total = 0; 490 int fd, count = 0, total = 0;
493 491
494 fd = open( file.latin1(), O_RDONLY, 0 ); 492 fd = open( file.latin1(), O_RDONLY, 0 );
495 if ( fd == -1 ) return; 493 if ( fd == -1 ) return;
496 494
497 if ( fstat( fd, &st ) != 0 ) goto err_close; 495 if ( fstat( fd, &st ) != 0 ) goto err_close;
498 if ( !st.st_size ) goto err_close; 496 if ( !st.st_size ) goto err_close;
499 497
500 buf = (char *) malloc( st.st_size ); 498 buf = (char *) malloc( st.st_size );
501 if ( !buf ) goto err_close; 499 if ( !buf ) goto err_close;
502 500
503 while ( ( total < st.st_size ) && ( count >= 0 ) ) { 501 while ( ( total < st.st_size ) && ( count >= 0 ) ) {
504 count = read( fd, buf + total, st.st_size - total ); 502 count = read( fd, buf + total, st.st_size - total );
505 total += count; 503 total += count;
506 } 504 }
507 if ( count < 0 ) goto err_free; 505 if ( count < 0 ) goto err_free;
508 506
509 *data = buf; 507 *data = buf;
510 *size = st.st_size; 508 *size = st.st_size;
511 509
512 close( fd ); 510 close( fd );
513 511
514 return; // Success :) 512 return; // Success :)
515 513
516err_free: 514err_free:
517 free( buf ); 515 free( buf );
518err_close: 516err_close:
519 close( fd ); 517 close( fd );
520} 518}
521 519
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp
index 13a3fd9..ea9e7b2 100644
--- a/noncore/net/mail/mailwrapper.cpp
+++ b/noncore/net/mail/mailwrapper.cpp
@@ -1,521 +1,519 @@
1#include <qfileinfo.h>
2#include <stdlib.h> 1#include <stdlib.h>
3#include <sys/stat.h> 2#include <sys/stat.h>
4#include <sys/types.h> 3#include <sys/types.h>
5#include <unistd.h> 4#include <unistd.h>
6#include <fcntl.h> 5#include <fcntl.h>
7#include <string.h> 6#include <string.h>
8#include <qdir.h> 7#include <qdir.h>
9#include <qtextstream.h>
10 8
11#include "mailwrapper.h" 9#include "mailwrapper.h"
12#include "logindialog.h" 10#include "logindialog.h"
13//#include "mail.h" 11//#include "mail.h"
14#include "defines.h" 12#include "defines.h"
15 13
16Attachment::Attachment( DocLnk lnk ) 14Attachment::Attachment( DocLnk lnk )
17{ 15{
18 doc = lnk; 16 doc = lnk;
19 size = QFileInfo( doc.file() ).size(); 17 size = QFileInfo( doc.file() ).size();
20} 18}
21 19
22Folder::Folder(const QString&tmp_name ) 20Folder::Folder(const QString&tmp_name )
23{ 21{
24 name = tmp_name; 22 name = tmp_name;
25 nameDisplay = name; 23 nameDisplay = name;
26 24
27 for ( int pos = nameDisplay.find( '&' ); pos != -1; 25 for ( int pos = nameDisplay.find( '&' ); pos != -1;
28 pos = nameDisplay.find( '&' ) ) { 26 pos = nameDisplay.find( '&' ) ) {
29 int end = nameDisplay.find( '-' ); 27 int end = nameDisplay.find( '-' );
30 if ( end == -1 || end <= pos ) break; 28 if ( end == -1 || end <= pos ) break;
31 QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 ); 29 QString str64 = nameDisplay.mid( pos + 1, end - pos - 1 );
32 // TODO: do real base64 decoding here ! 30 // TODO: do real base64 decoding here !
33 if ( str64.compare( "APw" ) == 0 ) { 31 if ( str64.compare( "APw" ) == 0 ) {
34 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" ); 32 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "ue" );
35 } else if ( str64.compare( "APY" ) == 0 ) { 33 } else if ( str64.compare( "APY" ) == 0 ) {
36 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" ); 34 nameDisplay = nameDisplay.replace( pos, end - pos + 1, "oe" );
37 } 35 }
38 } 36 }
39 37
40 qDebug( "folder " + name + " - displayed as " + nameDisplay ); 38 qDebug( "folder " + name + " - displayed as " + nameDisplay );
41} 39}
42 40
43MailWrapper::MailWrapper( Settings *s ) 41MailWrapper::MailWrapper( Settings *s )
44 : QObject() 42 : QObject()
45{ 43{
46 settings = s; 44 settings = s;
47} 45}
48 46
49QString MailWrapper::mailsmtpError( int errnum ) 47QString MailWrapper::mailsmtpError( int errnum )
50{ 48{
51 switch ( errnum ) { 49 switch ( errnum ) {
52 case MAILSMTP_NO_ERROR: 50 case MAILSMTP_NO_ERROR:
53 return tr( "No error" ); 51 return tr( "No error" );
54 case MAILSMTP_ERROR_UNEXPECTED_CODE: 52 case MAILSMTP_ERROR_UNEXPECTED_CODE:
55 return tr( "Unexpected error code" ); 53 return tr( "Unexpected error code" );
56 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 54 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
57 return tr( "Service not available" ); 55 return tr( "Service not available" );
58 case MAILSMTP_ERROR_STREAM: 56 case MAILSMTP_ERROR_STREAM:
59 return tr( "Stream error" ); 57 return tr( "Stream error" );
60 case MAILSMTP_ERROR_HOSTNAME: 58 case MAILSMTP_ERROR_HOSTNAME:
61 return tr( "gethostname() failed" ); 59 return tr( "gethostname() failed" );
62 case MAILSMTP_ERROR_NOT_IMPLEMENTED: 60 case MAILSMTP_ERROR_NOT_IMPLEMENTED:
63 return tr( "Not implemented" ); 61 return tr( "Not implemented" );
64 case MAILSMTP_ERROR_ACTION_NOT_TAKEN: 62 case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
65 return tr( "Error, action not taken" ); 63 return tr( "Error, action not taken" );
66 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: 64 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
67 return tr( "Data exceeds storage allocation" ); 65 return tr( "Data exceeds storage allocation" );
68 case MAILSMTP_ERROR_IN_PROCESSING: 66 case MAILSMTP_ERROR_IN_PROCESSING:
69 return tr( "Error in processing" ); 67 return tr( "Error in processing" );
70 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: 68 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
71 // return tr( "Insufficient system storage" ); 69 // return tr( "Insufficient system storage" );
72 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: 70 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
73 return tr( "Mailbox unavailable" ); 71 return tr( "Mailbox unavailable" );
74 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: 72 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
75 return tr( "Mailbox name not allowed" ); 73 return tr( "Mailbox name not allowed" );
76 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: 74 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
77 return tr( "Bad command sequence" ); 75 return tr( "Bad command sequence" );
78 case MAILSMTP_ERROR_USER_NOT_LOCAL: 76 case MAILSMTP_ERROR_USER_NOT_LOCAL:
79 return tr( "User not local" ); 77 return tr( "User not local" );
80 case MAILSMTP_ERROR_TRANSACTION_FAILED: 78 case MAILSMTP_ERROR_TRANSACTION_FAILED:
81 return tr( "Transaction failed" ); 79 return tr( "Transaction failed" );
82 case MAILSMTP_ERROR_MEMORY: 80 case MAILSMTP_ERROR_MEMORY:
83 return tr( "Memory error" ); 81 return tr( "Memory error" );
84 case MAILSMTP_ERROR_CONNECTION_REFUSED: 82 case MAILSMTP_ERROR_CONNECTION_REFUSED:
85 return tr( "Connection refused" ); 83 return tr( "Connection refused" );
86 default: 84 default:
87 return tr( "Unknown error code" ); 85 return tr( "Unknown error code" );
88 } 86 }
89} 87}
90 88
91mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail ) 89mailimf_mailbox *MailWrapper::newMailbox(const QString&name, const QString&mail )
92{ 90{
93 return mailimf_mailbox_new( strdup( name.latin1() ), 91 return mailimf_mailbox_new( strdup( name.latin1() ),
94 strdup( mail.latin1() ) ); 92 strdup( mail.latin1() ) );
95} 93}
96 94
97mailimf_address_list *MailWrapper::parseAddresses(const QString&addr ) 95mailimf_address_list *MailWrapper::parseAddresses(const QString&addr )
98{ 96{
99 mailimf_address_list *addresses; 97 mailimf_address_list *addresses;
100 98
101 if ( addr.isEmpty() ) return NULL; 99 if ( addr.isEmpty() ) return NULL;
102 100
103 addresses = mailimf_address_list_new_empty(); 101 addresses = mailimf_address_list_new_empty();
104 102
105 QStringList list = QStringList::split( ',', addr ); 103 QStringList list = QStringList::split( ',', addr );
106 QStringList::Iterator it; 104 QStringList::Iterator it;
107 for ( it = list.begin(); it != list.end(); it++ ) { 105 for ( it = list.begin(); it != list.end(); it++ ) {
108 char *str = strdup( (*it).latin1() ); 106 char *str = strdup( (*it).latin1() );
109 int err = mailimf_address_list_add_parse( addresses, str ); 107 int err = mailimf_address_list_add_parse( addresses, str );
110 if ( err != MAILIMF_NO_ERROR ) { 108 if ( err != MAILIMF_NO_ERROR ) {
111 qDebug( "Error parsing" ); 109 qDebug( "Error parsing" );
112 qDebug( *it ); 110 qDebug( *it );
113 free( str ); 111 free( str );
114 } else { 112 } else {
115 qDebug( "Parse success! :)" ); 113 qDebug( "Parse success! :)" );
116 } 114 }
117 } 115 }
118 116
119 return addresses; 117 return addresses;
120} 118}
121 119
122mailimf_fields *MailWrapper::createImfFields( Mail *mail ) 120mailimf_fields *MailWrapper::createImfFields( Mail *mail )
123{ 121{
124 mailimf_fields *fields; 122 mailimf_fields *fields;
125 mailimf_field *xmailer; 123 mailimf_field *xmailer;
126 mailimf_mailbox *sender, *fromBox; 124 mailimf_mailbox *sender, *fromBox;
127 mailimf_mailbox_list *from; 125 mailimf_mailbox_list *from;
128 mailimf_address_list *to, *cc, *bcc, *reply; 126 mailimf_address_list *to, *cc, *bcc, *reply;
129 char *subject = strdup( mail->getSubject().latin1() ); 127 char *subject = strdup( mail->getSubject().latin1() );
130 int err; 128 int err;
131 129
132 sender = newMailbox( mail->getName(), mail->getMail() ); 130 sender = newMailbox( mail->getName(), mail->getMail() );
133 if ( sender == NULL ) goto err_free; 131 if ( sender == NULL ) goto err_free;
134 132
135 fromBox = newMailbox( mail->getName(), mail->getMail() ); 133 fromBox = newMailbox( mail->getName(), mail->getMail() );
136 if ( fromBox == NULL ) goto err_free_sender; 134 if ( fromBox == NULL ) goto err_free_sender;
137 135
138 from = mailimf_mailbox_list_new_empty(); 136 from = mailimf_mailbox_list_new_empty();
139 if ( from == NULL ) goto err_free_fromBox; 137 if ( from == NULL ) goto err_free_fromBox;
140 138
141 err = mailimf_mailbox_list_add( from, fromBox ); 139 err = mailimf_mailbox_list_add( from, fromBox );
142 if ( err != MAILIMF_NO_ERROR ) goto err_free_from; 140 if ( err != MAILIMF_NO_ERROR ) goto err_free_from;
143 141
144 to = parseAddresses( mail->getTo() ); 142 to = parseAddresses( mail->getTo() );
145 if ( to == NULL ) goto err_free_from; 143 if ( to == NULL ) goto err_free_from;
146 144
147 cc = parseAddresses( mail->getCC() ); 145 cc = parseAddresses( mail->getCC() );
148 bcc = parseAddresses( mail->getBCC() ); 146 bcc = parseAddresses( mail->getBCC() );
149 reply = parseAddresses( mail->getReply() ); 147 reply = parseAddresses( mail->getReply() );
150 148
151 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, 149 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc,
152 NULL, NULL, subject ); 150 NULL, NULL, subject );
153 if ( fields == NULL ) goto err_free_reply; 151 if ( fields == NULL ) goto err_free_reply;
154 152
155 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), 153 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ),
156 strdup( USER_AGENT ) ); 154 strdup( USER_AGENT ) );
157 if ( xmailer == NULL ) goto err_free_fields; 155 if ( xmailer == NULL ) goto err_free_fields;
158 156
159 err = mailimf_fields_add( fields, xmailer ); 157 err = mailimf_fields_add( fields, xmailer );
160 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; 158 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer;
161 159
162 return fields; // Success :) 160 return fields; // Success :)
163 161
164err_free_xmailer: 162err_free_xmailer:
165 mailimf_field_free( xmailer ); 163 mailimf_field_free( xmailer );
166err_free_fields: 164err_free_fields:
167 mailimf_fields_free( fields ); 165 mailimf_fields_free( fields );
168err_free_reply: 166err_free_reply:
169 mailimf_address_list_free( reply ); 167 mailimf_address_list_free( reply );
170 mailimf_address_list_free( bcc ); 168 mailimf_address_list_free( bcc );
171 mailimf_address_list_free( cc ); 169 mailimf_address_list_free( cc );
172 mailimf_address_list_free( to ); 170 mailimf_address_list_free( to );
173err_free_from: 171err_free_from:
174 mailimf_mailbox_list_free( from ); 172 mailimf_mailbox_list_free( from );
175err_free_fromBox: 173err_free_fromBox:
176 mailimf_mailbox_free( fromBox ); 174 mailimf_mailbox_free( fromBox );
177err_free_sender: 175err_free_sender:
178 mailimf_mailbox_free( sender ); 176 mailimf_mailbox_free( sender );
179err_free: 177err_free:
180 free( subject ); 178 free( subject );
181 qDebug( "createImfFields - error" ); 179 qDebug( "createImfFields - error" );
182 180
183 return NULL; // Error :( 181 return NULL; // Error :(
184} 182}
185 183
186mailmime *MailWrapper::buildTxtPart( QString str ) 184mailmime *MailWrapper::buildTxtPart( QString str )
187{ 185{
188 mailmime *txtPart; 186 mailmime *txtPart;
189 mailmime_fields *fields; 187 mailmime_fields *fields;
190 mailmime_content *content; 188 mailmime_content *content;
191 mailmime_parameter *param; 189 mailmime_parameter *param;
192 char *txt = strdup( str.latin1() ); 190 char *txt = strdup( str.latin1() );
193 int err; 191 int err;
194 192
195 param = mailmime_parameter_new( strdup( "charset" ), 193 param = mailmime_parameter_new( strdup( "charset" ),
196 strdup( "iso-8859-1" ) ); 194 strdup( "iso-8859-1" ) );
197 if ( param == NULL ) goto err_free; 195 if ( param == NULL ) goto err_free;
198 196
199 content = mailmime_content_new_with_str( "text/plain" ); 197 content = mailmime_content_new_with_str( "text/plain" );
200 if ( content == NULL ) goto err_free_param; 198 if ( content == NULL ) goto err_free_param;
201 199
202 err = clist_append( content->parameters, param ); 200 err = clist_append( content->parameters, param );
203 if ( err != MAILIMF_NO_ERROR ) goto err_free_content; 201 if ( err != MAILIMF_NO_ERROR ) goto err_free_content;
204 202
205 fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); 203 fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT );
206 if ( fields == NULL ) goto err_free_content; 204 if ( fields == NULL ) goto err_free_content;
207 205
208 txtPart = mailmime_new_empty( content, fields ); 206 txtPart = mailmime_new_empty( content, fields );
209 if ( txtPart == NULL ) goto err_free_fields; 207 if ( txtPart == NULL ) goto err_free_fields;
210 208
211 err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); 209 err = mailmime_set_body_text( txtPart, txt, strlen( txt ) );
212 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 210 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
213 211
214 return txtPart; // Success :) 212 return txtPart; // Success :)
215 213
216err_free_txtPart: 214err_free_txtPart:
217 mailmime_free( txtPart ); 215 mailmime_free( txtPart );
218err_free_fields: 216err_free_fields:
219 mailmime_fields_free( fields ); 217 mailmime_fields_free( fields );
220err_free_content: 218err_free_content:
221 mailmime_content_free( content ); 219 mailmime_content_free( content );
222err_free_param: 220err_free_param:
223 mailmime_parameter_free( param ); 221 mailmime_parameter_free( param );
224err_free: 222err_free:
225 free( txt ); 223 free( txt );
226 qDebug( "buildTxtPart - error" ); 224 qDebug( "buildTxtPart - error" );
227 225
228 return NULL; // Error :( 226 return NULL; // Error :(
229} 227}
230 228
231mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) 229mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype )
232{ 230{
233 mailmime * filePart; 231 mailmime * filePart;
234 mailmime_fields * fields; 232 mailmime_fields * fields;
235 mailmime_content * content; 233 mailmime_content * content;
236 mailmime_parameter * param = NULL; 234 mailmime_parameter * param = NULL;
237 int err; 235 int err;
238 236
239 int pos = filename.findRev( '/' ); 237 int pos = filename.findRev( '/' );
240 QString tmp = filename.right( filename.length() - ( pos + 1 ) ); 238 QString tmp = filename.right( filename.length() - ( pos + 1 ) );
241 char *name = strdup( tmp.latin1() ); // just filename 239 char *name = strdup( tmp.latin1() ); // just filename
242 char *file = strdup( filename.latin1() ); // full name with path 240 char *file = strdup( filename.latin1() ); // full name with path
243 char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain 241 char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain
244 242
245 fields = mailmime_fields_new_filename( 243 fields = mailmime_fields_new_filename(
246 MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, 244 MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name,
247 MAILMIME_MECHANISM_BASE64 ); 245 MAILMIME_MECHANISM_BASE64 );
248 if ( fields == NULL ) goto err_free; 246 if ( fields == NULL ) goto err_free;
249 247
250 content = mailmime_content_new_with_str( mime ); 248 content = mailmime_content_new_with_str( mime );
251 if ( content == NULL ) goto err_free_fields; 249 if ( content == NULL ) goto err_free_fields;
252 250
253 if ( mimetype.compare( "text/plain" ) == 0 ) { 251 if ( mimetype.compare( "text/plain" ) == 0 ) {
254 param = mailmime_parameter_new( strdup( "charset" ), 252 param = mailmime_parameter_new( strdup( "charset" ),
255 strdup( "iso-8859-1" ) ); 253 strdup( "iso-8859-1" ) );
256 if ( param == NULL ) goto err_free_content; 254 if ( param == NULL ) goto err_free_content;
257 255
258 err = clist_append( content->parameters, param ); 256 err = clist_append( content->parameters, param );
259 if ( err != MAILIMF_NO_ERROR ) goto err_free_param; 257 if ( err != MAILIMF_NO_ERROR ) goto err_free_param;
260 } 258 }
261 259
262 filePart = mailmime_new_empty( content, fields ); 260 filePart = mailmime_new_empty( content, fields );
263 if ( filePart == NULL ) goto err_free_param; 261 if ( filePart == NULL ) goto err_free_param;
264 262
265 err = mailmime_set_body_file( filePart, file ); 263 err = mailmime_set_body_file( filePart, file );
266 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; 264 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart;
267 265
268 return filePart; // Success :) 266 return filePart; // Success :)
269 267
270err_free_filePart: 268err_free_filePart:
271 mailmime_free( filePart ); 269 mailmime_free( filePart );
272err_free_param: 270err_free_param:
273 if ( param != NULL ) mailmime_parameter_free( param ); 271 if ( param != NULL ) mailmime_parameter_free( param );
274err_free_content: 272err_free_content:
275 mailmime_content_free( content ); 273 mailmime_content_free( content );
276err_free_fields: 274err_free_fields:
277 mailmime_fields_free( fields ); 275 mailmime_fields_free( fields );
278err_free: 276err_free:
279 free( name ); 277 free( name );
280 free( mime ); 278 free( mime );
281 free( file ); 279 free( file );
282 qDebug( "buildFilePart - error" ); 280 qDebug( "buildFilePart - error" );
283 281
284 return NULL; // Error :( 282 return NULL; // Error :(
285} 283}
286 284
287void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files ) 285void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files )
288{ 286{
289 Attachment *it; 287 Attachment *it;
290 for ( it = files.first(); it; it = files.next() ) { 288 for ( it = files.first(); it; it = files.next() ) {
291 qDebug( "Adding file" ); 289 qDebug( "Adding file" );
292 mailmime *filePart; 290 mailmime *filePart;
293 int err; 291 int err;
294 292
295 filePart = buildFilePart( it->getFileName(), it->getMimeType() ); 293 filePart = buildFilePart( it->getFileName(), it->getMimeType() );
296 if ( filePart == NULL ) goto err_free; 294 if ( filePart == NULL ) goto err_free;
297 295
298 err = mailmime_smart_add_part( message, filePart ); 296 err = mailmime_smart_add_part( message, filePart );
299 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; 297 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart;
300 298
301 continue; // Success :) 299 continue; // Success :)
302 300
303 err_free_filePart: 301 err_free_filePart:
304 mailmime_free( filePart ); 302 mailmime_free( filePart );
305 err_free: 303 err_free:
306 qDebug( "addFileParts: error adding file:" ); 304 qDebug( "addFileParts: error adding file:" );
307 qDebug( it->getFileName() ); 305 qDebug( it->getFileName() );
308 } 306 }
309} 307}
310 308
311mailmime *MailWrapper::createMimeMail( Mail *mail ) 309mailmime *MailWrapper::createMimeMail( Mail *mail )
312{ 310{
313 mailmime *message, *txtPart; 311 mailmime *message, *txtPart;
314 mailimf_fields *fields; 312 mailimf_fields *fields;
315 int err; 313 int err;
316 314
317 fields = createImfFields( mail ); 315 fields = createImfFields( mail );
318 if ( fields == NULL ) goto err_free; 316 if ( fields == NULL ) goto err_free;
319 317
320 message = mailmime_new_message_data( NULL ); 318 message = mailmime_new_message_data( NULL );
321 if ( message == NULL ) goto err_free_fields; 319 if ( message == NULL ) goto err_free_fields;
322 320
323 mailmime_set_imf_fields( message, fields ); 321 mailmime_set_imf_fields( message, fields );
324 322
325 txtPart = buildTxtPart( mail->getMessage() ); 323 txtPart = buildTxtPart( mail->getMessage() );
326 if ( txtPart == NULL ) goto err_free_message; 324 if ( txtPart == NULL ) goto err_free_message;
327 325
328 err = mailmime_smart_add_part( message, txtPart ); 326 err = mailmime_smart_add_part( message, txtPart );
329 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 327 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
330 328
331 addFileParts( message, mail->getAttachments() ); 329 addFileParts( message, mail->getAttachments() );
332 330
333 return message; // Success :) 331 return message; // Success :)
334 332
335err_free_txtPart: 333err_free_txtPart:
336 mailmime_free( txtPart ); 334 mailmime_free( txtPart );
337err_free_message: 335err_free_message:
338 mailmime_free( message ); 336 mailmime_free( message );
339err_free_fields: 337err_free_fields:
340 mailimf_fields_free( fields ); 338 mailimf_fields_free( fields );
341err_free: 339err_free:
342 qDebug( "createMimeMail: error" ); 340 qDebug( "createMimeMail: error" );
343 341
344 return NULL; // Error :( 342 return NULL; // Error :(
345} 343}
346 344
347mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type ) 345mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type )
348{ 346{
349 mailimf_field *field; 347 mailimf_field *field;
350 clistiter *it; 348 clistiter *it;
351 349
352 it = clist_begin( fields->list ); 350 it = clist_begin( fields->list );
353 while ( it ) { 351 while ( it ) {
354 field = (mailimf_field *) it->data; 352 field = (mailimf_field *) it->data;
355 if ( field->type == type ) { 353 if ( field->type == type ) {
356 return field; 354 return field;
357 } 355 }
358 it = it->next; 356 it = it->next;
359 } 357 }
360 358
361 return NULL; 359 return NULL;
362} 360}
363 361
364static void addRcpts( clist *list, mailimf_address_list *addr_list ) 362static void addRcpts( clist *list, mailimf_address_list *addr_list )
365{ 363{
366 clistiter *it, *it2; 364 clistiter *it, *it2;
367 365
368 for ( it = clist_begin( addr_list->list ); it; it = it->next ) { 366 for ( it = clist_begin( addr_list->list ); it; it = it->next ) {
369 mailimf_address *addr; 367 mailimf_address *addr;
370 addr = (mailimf_address *) it->data; 368 addr = (mailimf_address *) it->data;
371 369
372 if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) { 370 if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) {
373 esmtp_address_list_add( list, addr->mailbox->addr_spec, 0, NULL ); 371 esmtp_address_list_add( list, addr->mailbox->addr_spec, 0, NULL );
374 } else if ( addr->type == MAILIMF_ADDRESS_GROUP ) { 372 } else if ( addr->type == MAILIMF_ADDRESS_GROUP ) {
375 clist *l = addr->group->mb_list->list; 373 clist *l = addr->group->mb_list->list;
376 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { 374 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) {
377 mailimf_mailbox *mbox; 375 mailimf_mailbox *mbox;
378 mbox = (mailimf_mailbox *) it2->data; 376 mbox = (mailimf_mailbox *) it2->data;
379 esmtp_address_list_add( list, mbox->addr_spec, 0, NULL ); 377 esmtp_address_list_add( list, mbox->addr_spec, 0, NULL );
380 } 378 }
381 } 379 }
382 } 380 }
383} 381}
384 382
385clist *MailWrapper::createRcptList( mailimf_fields *fields ) 383clist *MailWrapper::createRcptList( mailimf_fields *fields )
386{ 384{
387 clist *rcptList; 385 clist *rcptList;
388 mailimf_field *field; 386 mailimf_field *field;
389 387
390 rcptList = esmtp_address_list_new(); 388 rcptList = esmtp_address_list_new();
391 389
392 field = getField( fields, MAILIMF_FIELD_TO ); 390 field = getField( fields, MAILIMF_FIELD_TO );
393 if ( field && (field->type == MAILIMF_FIELD_TO) 391 if ( field && (field->type == MAILIMF_FIELD_TO)
394 && field->field.to->addr_list ) { 392 && field->field.to->addr_list ) {
395 addRcpts( rcptList, field->field.to->addr_list ); 393 addRcpts( rcptList, field->field.to->addr_list );
396 } 394 }
397 395
398 field = getField( fields, MAILIMF_FIELD_CC ); 396 field = getField( fields, MAILIMF_FIELD_CC );
399 if ( field && (field->type == MAILIMF_FIELD_CC) 397 if ( field && (field->type == MAILIMF_FIELD_CC)
400 && field->field.cc->addr_list ) { 398 && field->field.cc->addr_list ) {
401 addRcpts( rcptList, field->field.cc->addr_list ); 399 addRcpts( rcptList, field->field.cc->addr_list );
402 } 400 }
403 401
404 field = getField( fields, MAILIMF_FIELD_BCC ); 402 field = getField( fields, MAILIMF_FIELD_BCC );
405 if ( field && (field->type == MAILIMF_FIELD_BCC) 403 if ( field && (field->type == MAILIMF_FIELD_BCC)
406 && field->field.bcc->addr_list ) { 404 && field->field.bcc->addr_list ) {
407 addRcpts( rcptList, field->field.bcc->addr_list ); 405 addRcpts( rcptList, field->field.bcc->addr_list );
408 } 406 }
409 407
410 return rcptList; 408 return rcptList;
411} 409}
412 410
413char *MailWrapper::getFrom( mailmime *mail ) 411char *MailWrapper::getFrom( mailmime *mail )
414{ 412{
415 char *from = NULL; 413 char *from = NULL;
416 414
417 mailimf_field *ffrom; 415 mailimf_field *ffrom;
418 ffrom = getField( mail->fields, MAILIMF_FIELD_FROM ); 416 ffrom = getField( mail->fields, MAILIMF_FIELD_FROM );
419 if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) 417 if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM)
420 && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) { 418 && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) {
421 clist *cl = ffrom->field.from->mb_list->list; 419 clist *cl = ffrom->field.from->mb_list->list;
422 clistiter *it; 420 clistiter *it;
423 for ( it = clist_begin( cl ); it; it = it->next ) { 421 for ( it = clist_begin( cl ); it; it = it->next ) {
424 mailimf_mailbox *mb = (mailimf_mailbox *) it->data; 422 mailimf_mailbox *mb = (mailimf_mailbox *) it->data;
425 from = strdup( mb->addr_spec ); 423 from = strdup( mb->addr_spec );
426 } 424 }
427 } 425 }
428 426
429 return from; 427 return from;
430} 428}
431 429
432SMTPaccount *MailWrapper::getAccount( QString from ) 430SMTPaccount *MailWrapper::getAccount( QString from )
433{ 431{
434 SMTPaccount *smtp; 432 SMTPaccount *smtp;
435 433
436 QList<Account> list = settings->getAccounts(); 434 QList<Account> list = settings->getAccounts();
437 Account *it; 435 Account *it;
438 for ( it = list.first(); it; it = list.next() ) { 436 for ( it = list.first(); it; it = list.next() ) {
439 if ( it->getType().compare( "SMTP" ) == 0 ) { 437 if ( it->getType().compare( "SMTP" ) == 0 ) {
440 smtp = static_cast<SMTPaccount *>(it); 438 smtp = static_cast<SMTPaccount *>(it);
441 if ( smtp->getMail().compare( from ) == 0 ) { 439 if ( smtp->getMail().compare( from ) == 0 ) {
442 qDebug( "SMTPaccount found for" ); 440 qDebug( "SMTPaccount found for" );
443 qDebug( from ); 441 qDebug( from );
444 return smtp; 442 return smtp;
445 } 443 }
446 } 444 }
447 } 445 }
448 446
449 return NULL; 447 return NULL;
450} 448}
451 449
452QString MailWrapper::getTmpFile() { 450QString MailWrapper::getTmpFile() {
453 int num = 0; 451 int num = 0;
454 QString unique; 452 QString unique;
455 453
456 QDir dir( "/tmp" ); 454 QDir dir( "/tmp" );
457 QStringList::Iterator it; 455 QStringList::Iterator it;
458 456
459 QStringList list = dir.entryList( "opiemail-tmp-*" ); 457 QStringList list = dir.entryList( "opiemail-tmp-*" );
460 do { 458 do {
461 unique.setNum( num++ ); 459 unique.setNum( num++ );
462 } while ( list.contains( "opiemail-tmp-" + unique ) > 0 ); 460 } while ( list.contains( "opiemail-tmp-" + unique ) > 0 );
463 461
464 return "/tmp/opiemail-tmp-" + unique; 462 return "/tmp/opiemail-tmp-" + unique;
465} 463}
466 464
467void MailWrapper::writeToFile( QString file, mailmime *mail ) 465void MailWrapper::writeToFile( QString file, mailmime *mail )
468{ 466{
469 FILE *f; 467 FILE *f;
470 int err, col = 0; 468 int err, col = 0;
471 469
472 f = fopen( file.latin1(), "w" ); 470 f = fopen( file.latin1(), "w" );
473 if ( f == NULL ) { 471 if ( f == NULL ) {
474 qDebug( "writeToFile: error opening file" ); 472 qDebug( "writeToFile: error opening file" );
475 return; 473 return;
476 } 474 }
477 475
478 err = mailmime_write( f, &col, mail ); 476 err = mailmime_write( f, &col, mail );
479 if ( err != MAILIMF_NO_ERROR ) { 477 if ( err != MAILIMF_NO_ERROR ) {
480 fclose( f ); 478 fclose( f );
481 qDebug( "writeToFile: error writing mailmime" ); 479 qDebug( "writeToFile: error writing mailmime" );
482 return; 480 return;
483 } 481 }
484 482
485 fclose( f ); 483 fclose( f );
486} 484}
487 485
488void MailWrapper::readFromFile( QString file, char **data, size_t *size ) 486void MailWrapper::readFromFile( QString file, char **data, size_t *size )
489{ 487{
490 char *buf; 488 char *buf;
491 struct stat st; 489 struct stat st;
492 int fd, count = 0, total = 0; 490 int fd, count = 0, total = 0;
493 491
494 fd = open( file.latin1(), O_RDONLY, 0 ); 492 fd = open( file.latin1(), O_RDONLY, 0 );
495 if ( fd == -1 ) return; 493 if ( fd == -1 ) return;
496 494
497 if ( fstat( fd, &st ) != 0 ) goto err_close; 495 if ( fstat( fd, &st ) != 0 ) goto err_close;
498 if ( !st.st_size ) goto err_close; 496 if ( !st.st_size ) goto err_close;
499 497
500 buf = (char *) malloc( st.st_size ); 498 buf = (char *) malloc( st.st_size );
501 if ( !buf ) goto err_close; 499 if ( !buf ) goto err_close;
502 500
503 while ( ( total < st.st_size ) && ( count >= 0 ) ) { 501 while ( ( total < st.st_size ) && ( count >= 0 ) ) {
504 count = read( fd, buf + total, st.st_size - total ); 502 count = read( fd, buf + total, st.st_size - total );
505 total += count; 503 total += count;
506 } 504 }
507 if ( count < 0 ) goto err_free; 505 if ( count < 0 ) goto err_free;
508 506
509 *data = buf; 507 *data = buf;
510 *size = st.st_size; 508 *size = st.st_size;
511 509
512 close( fd ); 510 close( fd );
513 511
514 return; // Success :) 512 return; // Success :)
515 513
516err_free: 514err_free:
517 free( buf ); 515 free( buf );
518err_close: 516err_close:
519 close( fd ); 517 close( fd );
520} 518}
521 519
diff --git a/noncore/net/mail/main.cpp b/noncore/net/mail/main.cpp
index f97bea1..3bfcb4a 100644
--- a/noncore/net/mail/main.cpp
+++ b/noncore/net/mail/main.cpp
@@ -1,6 +1,5 @@
1#include <qpe/qpeapplication.h>
2#include <opie/oapplicationfactory.h> 1#include <opie/oapplicationfactory.h>
3 2
4#include "opiemail.h" 3#include "opiemail.h"
5 4
6OPIE_EXPORT_APP( OApplicationFactory<OpieMail> ) 5OPIE_EXPORT_APP( OApplicationFactory<OpieMail> )
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index 28111d0..6f054cc 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,150 +1,149 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qvbox.h> 2#include <qvbox.h>
3#include <qheader.h> 3#include <qheader.h>
4#include <qtimer.h> 4#include <qtimer.h>
5 5
6#include <qpe/resource.h>
7 6
8#include "defines.h" 7#include "defines.h"
9#include "mainwindow.h" 8#include "mainwindow.h"
10 9
11MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 10MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
12 : QMainWindow( parent, name, flags ) 11 : QMainWindow( parent, name, flags )
13{ 12{
14 setCaption( tr( "Opie-Mail" ) ); 13 setCaption( tr( "Opie-Mail" ) );
15 setToolBarsMovable( false ); 14 setToolBarsMovable( false );
16 15
17 toolBar = new QToolBar( this ); 16 toolBar = new QToolBar( this );
18 menuBar = new QMenuBar( toolBar ); 17 menuBar = new QMenuBar( toolBar );
19 mailMenu = new QPopupMenu( menuBar ); 18 mailMenu = new QPopupMenu( menuBar );
20 menuBar->insertItem( tr( "Mail" ), mailMenu ); 19 menuBar->insertItem( tr( "Mail" ), mailMenu );
21 settingsMenu = new QPopupMenu( menuBar ); 20 settingsMenu = new QPopupMenu( menuBar );
22 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 21 menuBar->insertItem( tr( "Settings" ), settingsMenu );
23 22
24 addToolBar( toolBar ); 23 addToolBar( toolBar );
25 toolBar->setHorizontalStretchable( true ); 24 toolBar->setHorizontalStretchable( true );
26 25
27 QLabel *spacer = new QLabel( toolBar ); 26 QLabel *spacer = new QLabel( toolBar );
28 spacer->setBackgroundMode( QWidget::PaletteButton ); 27 spacer->setBackgroundMode( QWidget::PaletteButton );
29 toolBar->setStretchableWidget( spacer ); 28 toolBar->setStretchableWidget( spacer );
30 29
31 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 30 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
32 0, 0, this ); 31 0, 0, this );
33 composeMail->addTo( toolBar ); 32 composeMail->addTo( toolBar );
34 composeMail->addTo( mailMenu ); 33 composeMail->addTo( mailMenu );
35 34
36 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 35 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
37 0, 0, this ); 36 0, 0, this );
38 sendQueued->addTo( toolBar ); 37 sendQueued->addTo( toolBar );
39 sendQueued->addTo( mailMenu ); 38 sendQueued->addTo( mailMenu );
40 39
41 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 40 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
42 0, 0, this ); 41 0, 0, this );
43 syncFolders->addTo( toolBar ); 42 syncFolders->addTo( toolBar );
44 syncFolders->addTo( mailMenu ); 43 syncFolders->addTo( mailMenu );
45 44
46 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 45 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
47 0, 0, this, 0, true ); 46 0, 0, this, 0, true );
48 showFolders->addTo( toolBar ); 47 showFolders->addTo( toolBar );
49 showFolders->addTo( mailMenu ); 48 showFolders->addTo( mailMenu );
50 connect(showFolders, SIGNAL( toggled( bool ) ), 49 connect(showFolders, SIGNAL( toggled( bool ) ),
51 SLOT( slotShowFolders( bool ) ) ); 50 SLOT( slotShowFolders( bool ) ) );
52 51
53 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, 52 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS,
54 0, 0, this ); 53 0, 0, this );
55 searchMails->addTo( toolBar ); 54 searchMails->addTo( toolBar );
56 searchMails->addTo( mailMenu ); 55 searchMails->addTo( mailMenu );
57 56
58 57
59 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 58 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS,
60 0, 0, this ); 59 0, 0, this );
61 editSettings->addTo( settingsMenu ); 60 editSettings->addTo( settingsMenu );
62 61
63 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 62 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS,
64 0, 0, this ); 63 0, 0, this );
65 editAccounts->addTo( settingsMenu ); 64 editAccounts->addTo( settingsMenu );
66 65
67 QVBox *view = new QVBox( this ); 66 QVBox *view = new QVBox( this );
68 setCentralWidget( view ); 67 setCentralWidget( view );
69 68
70 folderView = new AccountView( view ); 69 folderView = new AccountView( view );
71 folderView->header()->hide(); 70 folderView->header()->hide();
72 folderView->setMinimumHeight( 90 ); 71 folderView->setMinimumHeight( 90 );
73 folderView->setMaximumHeight( 90 ); 72 folderView->setMaximumHeight( 90 );
74 folderView->addColumn( tr( "Mailbox" ) ); 73 folderView->addColumn( tr( "Mailbox" ) );
75 folderView->hide(); 74 folderView->hide();
76 75
77 mailView = new QListView( view ); 76 mailView = new QListView( view );
78 mailView->setMinimumHeight( 50 ); 77 mailView->setMinimumHeight( 50 );
79 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 78 mailView->addColumn( tr( "Subject" ),QListView::Manual );
80 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 79 mailView->addColumn( tr( "Sender" ),QListView::Manual );
81 mailView->addColumn( tr( "Date" )); 80 mailView->addColumn( tr( "Date" ));
82 mailView->setAllColumnsShowFocus(true); 81 mailView->setAllColumnsShowFocus(true);
83 mailView->setSorting(-1); 82 mailView->setSorting(-1);
84 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, 83 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this,
85 SLOT( displayMail( QListViewItem * ) ) ); 84 SLOT( displayMail( QListViewItem * ) ) );
86 85
87 connect(folderView,SIGNAL(refreshMailview(Maillist*)),this,SLOT(refreshMailView(Maillist*))); 86 connect(folderView,SIGNAL(refreshMailview(Maillist*)),this,SLOT(refreshMailView(Maillist*)));
88 87
89 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 88 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
90} 89}
91 90
92void MainWindow::slotAdjustColumns() 91void MainWindow::slotAdjustColumns()
93{ 92{
94 bool hidden = folderView->isHidden(); 93 bool hidden = folderView->isHidden();
95 if ( hidden ) folderView->show(); 94 if ( hidden ) folderView->show();
96 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 95 folderView->setColumnWidth( 0, folderView->visibleWidth() );
97 if ( hidden ) folderView->hide(); 96 if ( hidden ) folderView->hide();
98 97
99 mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 ); 98 mailView->setColumnWidth( 0, mailView->visibleWidth() - 130 );
100 mailView->setColumnWidth( 1, 80 ); 99 mailView->setColumnWidth( 1, 80 );
101 mailView->setColumnWidth( 2, 50 ); 100 mailView->setColumnWidth( 2, 50 );
102} 101}
103 102
104void MainWindow::slotShowFolders( bool show ) 103void MainWindow::slotShowFolders( bool show )
105{ 104{
106 qDebug( "Show Folders" ); 105 qDebug( "Show Folders" );
107 if ( show && folderView->isHidden() ) { 106 if ( show && folderView->isHidden() ) {
108 qDebug( "-> showing" ); 107 qDebug( "-> showing" );
109 folderView->show(); 108 folderView->show();
110 } else if ( !show && !folderView->isHidden() ) { 109 } else if ( !show && !folderView->isHidden() ) {
111 qDebug( "-> hiding" ); 110 qDebug( "-> hiding" );
112 folderView->hide(); 111 folderView->hide();
113 } 112 }
114} 113}
115 114
116void MainWindow::refreshMailView(Maillist*list) 115void MainWindow::refreshMailView(Maillist*list)
117{ 116{
118 MailListViewItem*item = 0; 117 MailListViewItem*item = 0;
119 mailView->clear(); 118 mailView->clear();
120#if 0 119#if 0
121 QFont f = mailView->getFont(); 120 QFont f = mailView->getFont();
122 QFont bf = f; 121 QFont bf = f;
123#endif 122#endif
124 for (unsigned int i = 0; i < list->count();++i) { 123 for (unsigned int i = 0; i < list->count();++i) {
125 item = new MailListViewItem(mailView,item); 124 item = new MailListViewItem(mailView,item);
126 item->storeData(*(list->at(i))); 125 item->storeData(*(list->at(i)));
127 item->showEntry(); 126 item->showEntry();
128#if 0 127#if 0
129 if (!list->at(i)->getFlags().testBit(FLAG_SEEN)) { 128 if (!list->at(i)->getFlags().testBit(FLAG_SEEN)) {
130 item->setFont(bf); 129 item->setFont(bf);
131 } 130 }
132#endif 131#endif
133 } 132 }
134} 133}
135void MainWindow::displayMail(QListViewItem*item) 134void MainWindow::displayMail(QListViewItem*item)
136{ 135{
137 if (!item) return; 136 if (!item) return;
138 qDebug("View mail"); 137 qDebug("View mail");
139 RecMail mail = ((MailListViewItem*)item)->data(); 138 RecMail mail = ((MailListViewItem*)item)->data();
140 QString body = folderView->fetchBody(mail); 139 QString body = folderView->fetchBody(mail);
141 140
142 qDebug(body); 141 qDebug(body);
143} 142}
144 143
145void MailListViewItem::showEntry() 144void MailListViewItem::showEntry()
146{ 145{
147 setText(0,mail_data.getSubject()); 146 setText(0,mail_data.getSubject());
148 setText(1,mail_data.getFrom()); 147 setText(1,mail_data.getFrom());
149 setText(2,mail_data.getDate()); 148 setText(2,mail_data.getDate());
150} 149}