summaryrefslogtreecommitdiff
path: root/noncore/net/mail/editaccounts.cpp
Unidiff
Diffstat (limited to 'noncore/net/mail/editaccounts.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/editaccounts.cpp153
1 files changed, 104 insertions, 49 deletions
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp
index 1cb202e..60bffa5 100644
--- a/noncore/net/mail/editaccounts.cpp
+++ b/noncore/net/mail/editaccounts.cpp
@@ -1,8 +1,13 @@
1#include <qt.h>
2 1
3#include "defines.h" 2#include "defines.h"
4#include "editaccounts.h" 3#include "editaccounts.h"
5 4
5/* OPIE */
6#include <qpe/qpeapplication.h>
7
8/* QT */
9#include <qt.h>
10
6AccountListItem::AccountListItem( QListView *parent, Account *a) 11AccountListItem::AccountListItem( QListView *parent, Account *a)
7 : QListViewItem( parent ) 12 : QListViewItem( parent )
8{ 13{
@@ -39,10 +44,14 @@ void EditAccounts::slotFillLists()
39 44
40 QList<Account> accounts = settings->getAccounts(); 45 QList<Account> accounts = settings->getAccounts();
41 Account *it; 46 Account *it;
42 for ( it = accounts.first(); it; it = accounts.next() ) { 47 for ( it = accounts.first(); it; it = accounts.next() )
43 if ( it->getType().compare( "NNTP" ) == 0 ) { 48 {
49 if ( it->getType().compare( "NNTP" ) == 0 )
50 {
44 (void) new AccountListItem( newsList, it ); 51 (void) new AccountListItem( newsList, it );
45 } else { 52 }
53 else
54 {
46 (void) new AccountListItem( mailList, it ); 55 (void) new AccountListItem( mailList, it );
47 } 56 }
48 } 57 }
@@ -54,60 +63,76 @@ void EditAccounts::slotNewMail()
54 QString *selection = new QString(); 63 QString *selection = new QString();
55 SelectMailType selType( selection, this, 0, true ); 64 SelectMailType selType( selection, this, 0, true );
56 selType.show(); 65 selType.show();
57 if ( QDialog::Accepted == selType.exec() ) { 66 if ( QDialog::Accepted == selType.exec() )
67 {
58 slotNewAccount( *selection ); 68 slotNewAccount( *selection );
59 } 69 }
60} 70}
61 71
62void EditAccounts::slotNewAccount( const QString &type ) 72void EditAccounts::slotNewAccount( const QString &type )
63{ 73{
64 if ( type.compare( "IMAP" ) == 0 ) { 74 if ( type.compare( "IMAP" ) == 0 )
75 {
65 qDebug( "-> config IMAP" ); 76 qDebug( "-> config IMAP" );
66 IMAPaccount *account = new IMAPaccount(); 77 IMAPaccount *account = new IMAPaccount();
67 IMAPconfig imap( account, this, 0, true ); 78 IMAPconfig imap( account, this, 0, true );
68 imap.showMaximized(); 79 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
69 if ( QDialog::Accepted == imap.exec() ) { 80 {
70 settings->addAccount( account ); 81 settings->addAccount( account );
71 account->save(); 82 account->save();
72 slotFillLists(); 83 slotFillLists();
73 } else { 84 }
85 else
86 {
74 account->remove(); 87 account->remove();
75 } 88 }
76 } else if ( type.compare( "POP3" ) == 0 ) { 89 }
90 else if ( type.compare( "POP3" ) == 0 )
91 {
77 qDebug( "-> config POP3" ); 92 qDebug( "-> config POP3" );
78 POP3account *account = new POP3account(); 93 POP3account *account = new POP3account();
79 POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); 94 POP3config pop3( account, this, 0, true, WStyle_ContextHelp );
80 pop3.showMaximized(); 95 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
81 if ( QDialog::Accepted == pop3.exec() ) { 96 {
82 settings->addAccount( account ); 97 settings->addAccount( account );
83 account->save(); 98 account->save();
84 slotFillLists(); 99 slotFillLists();
85 } else { 100 }
101 else
102 {
86 account->remove(); 103 account->remove();
87 } 104 }
88 } else if ( type.compare( "SMTP" ) == 0 ) { 105 }
106 else if ( type.compare( "SMTP" ) == 0 )
107 {
89 qDebug( "-> config SMTP" ); 108 qDebug( "-> config SMTP" );
90 SMTPaccount *account = new SMTPaccount(); 109 SMTPaccount *account = new SMTPaccount();
91 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); 110 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp );
92 smtp.showMaximized(); 111 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
93 if ( QDialog::Accepted == smtp.exec() ) { 112 {
94 settings->addAccount( account ); 113 settings->addAccount( account );
95 account->save(); 114 account->save();
96 slotFillLists(); 115 slotFillLists();
97 116
98 } else { 117 }
118 else
119 {
99 account->remove(); 120 account->remove();
100 } 121 }
101 } else if ( type.compare( "NNTP" ) == 0 ) { 122 }
123 else if ( type.compare( "NNTP" ) == 0 )
124 {
102 qDebug( "-> config NNTP" ); 125 qDebug( "-> config NNTP" );
103 NNTPaccount *account = new NNTPaccount(); 126 NNTPaccount *account = new NNTPaccount();
104 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); 127 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp );
105 nntp.showMaximized(); 128 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
106 if ( QDialog::Accepted == nntp.exec() ) { 129 {
107 settings->addAccount( account ); 130 settings->addAccount( account );
108 account->save(); 131 account->save();
109 slotFillLists(); 132 slotFillLists();
110 } else { 133 }
134 else
135 {
111 account->remove(); 136 account->remove();
112 } 137 }
113 } 138 }
@@ -115,32 +140,39 @@ void EditAccounts::slotNewAccount( const QString &type )
115 140
116void EditAccounts::slotEditAccount( Account *account ) 141void EditAccounts::slotEditAccount( Account *account )
117{ 142{
118 if ( account->getType().compare( "IMAP" ) == 0 ) { 143 if ( account->getType().compare( "IMAP" ) == 0 )
144 {
119 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); 145 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account);
120 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); 146 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp );
121 imap.showMaximized(); 147 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
122 if ( QDialog::Accepted == imap.exec() ) { 148 {
123 slotFillLists(); 149 slotFillLists();
124 } 150 }
125 } else if ( account->getType().compare( "POP3" ) == 0 ) { 151 }
152 else if ( account->getType().compare( "POP3" ) == 0 )
153 {
126 POP3account *pop3Acc = static_cast<POP3account *>(account); 154 POP3account *pop3Acc = static_cast<POP3account *>(account);
127 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); 155 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp );
128 pop3.showMaximized(); 156 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
129 if ( QDialog::Accepted == pop3.exec() ) { 157 {
130 slotFillLists(); 158 slotFillLists();
131 } 159 }
132 } else if ( account->getType().compare( "SMTP" ) == 0 ) { 160 }
161 else if ( account->getType().compare( "SMTP" ) == 0 )
162 {
133 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); 163 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account);
134 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); 164 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp );
135 smtp.showMaximized(); 165 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
136 if ( QDialog::Accepted == smtp.exec() ) { 166 {
137 slotFillLists(); 167 slotFillLists();
138 } 168 }
139 } else if ( account->getType().compare( "NNTP" ) == 0 ) { 169 }
170 else if ( account->getType().compare( "NNTP" ) == 0 )
171 {
140 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); 172 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account);
141 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); 173 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp );
142 nntp.showMaximized(); 174 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
143 if ( QDialog::Accepted == nntp.exec() ) { 175 {
144 slotFillLists(); 176 slotFillLists();
145 } 177 }
146 } 178 }
@@ -150,7 +182,8 @@ void EditAccounts::slotDeleteAccount( Account *account )
150{ 182{
151 if ( QMessageBox::information( this, tr( "Question" ), 183 if ( QMessageBox::information( this, tr( "Question" ),
152 tr( "<p>Do you really want to delete the selected Account?</p>" ), 184 tr( "<p>Do you really want to delete the selected Account?</p>" ),
153 tr( "Yes" ), tr( "No" ) ) == 0 ) { 185 tr( "Yes" ), tr( "No" ) ) == 0 )
186 {
154 settings->delAccount( account ); 187 settings->delAccount( account );
155 slotFillLists(); 188 slotFillLists();
156 } 189 }
@@ -159,7 +192,8 @@ void EditAccounts::slotDeleteAccount( Account *account )
159void EditAccounts::slotEditMail() 192void EditAccounts::slotEditMail()
160{ 193{
161 qDebug( "Edit Mail Account" ); 194 qDebug( "Edit Mail Account" );
162 if ( !mailList->currentItem() ) { 195 if ( !mailList->currentItem() )
196 {
163 QMessageBox::information( this, tr( "Error" ), 197 QMessageBox::information( this, tr( "Error" ),
164 tr( "<p>Please select an account.</p>" ), 198 tr( "<p>Please select an account.</p>" ),
165 tr( "Ok" ) ); 199 tr( "Ok" ) );
@@ -172,7 +206,8 @@ void EditAccounts::slotEditMail()
172 206
173void EditAccounts::slotDeleteMail() 207void EditAccounts::slotDeleteMail()
174{ 208{
175 if ( !mailList->currentItem() ) { 209 if ( !mailList->currentItem() )
210 {
176 QMessageBox::information( this, tr( "Error" ), 211 QMessageBox::information( this, tr( "Error" ),
177 tr( "<p>Please select an account.</p>" ), 212 tr( "<p>Please select an account.</p>" ),
178 tr( "Ok" ) ); 213 tr( "Ok" ) );
@@ -192,7 +227,8 @@ void EditAccounts::slotNewNews()
192void EditAccounts::slotEditNews() 227void EditAccounts::slotEditNews()
193{ 228{
194 qDebug( "Edit News Account" ); 229 qDebug( "Edit News Account" );
195 if ( !newsList->currentItem() ) { 230 if ( !newsList->currentItem() )
231 {
196 QMessageBox::information( this, tr( "Error" ), 232 QMessageBox::information( this, tr( "Error" ),
197 tr( "<p>Please select an account.</p>" ), 233 tr( "<p>Please select an account.</p>" ),
198 tr( "Ok" ) ); 234 tr( "Ok" ) );
@@ -206,7 +242,8 @@ void EditAccounts::slotEditNews()
206void EditAccounts::slotDeleteNews() 242void EditAccounts::slotDeleteNews()
207{ 243{
208 qDebug( "Delete News Account" ); 244 qDebug( "Delete News Account" );
209 if ( !newsList->currentItem() ) { 245 if ( !newsList->currentItem() )
246 {
210 QMessageBox::information( this, tr( "Error" ), 247 QMessageBox::information( this, tr( "Error" ),
211 tr( "<p>Please select an account.</p>" ), 248 tr( "<p>Please select an account.</p>" ),
212 tr( "Ok" ) ); 249 tr( "Ok" ) );
@@ -277,12 +314,17 @@ IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name,
277 314
278void IMAPconfig::slotConnectionToggle( int index ) 315void IMAPconfig::slotConnectionToggle( int index )
279{ 316{
280 if ( index == 2 ) { 317 if ( index == 2 )
318 {
281 portLine->setText( IMAP_SSL_PORT ); 319 portLine->setText( IMAP_SSL_PORT );
282 } else if ( index == 3 ) { 320 }
321 else if ( index == 3 )
322 {
283 portLine->setText( IMAP_PORT ); 323 portLine->setText( IMAP_PORT );
284 CommandEdit->show(); 324 CommandEdit->show();
285 } else { 325 }
326 else
327 {
286 portLine->setText( IMAP_PORT ); 328 portLine->setText( IMAP_PORT );
287 } 329 }
288} 330}
@@ -333,12 +375,17 @@ POP3config::POP3config( POP3account *account, QWidget *parent, const char *name,
333void POP3config::slotConnectionToggle( int index ) 375void POP3config::slotConnectionToggle( int index )
334{ 376{
335 // 2 is ssl connection 377 // 2 is ssl connection
336 if ( index == 2 ) { 378 if ( index == 2 )
379 {
337 portLine->setText( POP3_SSL_PORT ); 380 portLine->setText( POP3_SSL_PORT );
338 } else if ( index == 3 ) { 381 }
382 else if ( index == 3 )
383 {
339 portLine->setText( POP3_PORT ); 384 portLine->setText( POP3_PORT );
340 CommandEdit->show(); 385 CommandEdit->show();
341 } else { 386 }
387 else
388 {
342 portLine->setText( POP3_PORT ); 389 portLine->setText( POP3_PORT );
343 } 390 }
344} 391}
@@ -391,12 +438,17 @@ SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name,
391void SMTPconfig::slotConnectionToggle( int index ) 438void SMTPconfig::slotConnectionToggle( int index )
392{ 439{
393 // 2 is ssl connection 440 // 2 is ssl connection
394 if ( index == 2 ) { 441 if ( index == 2 )
442 {
395 portLine->setText( SMTP_SSL_PORT ); 443 portLine->setText( SMTP_SSL_PORT );
396 } else if ( index == 3 ) { 444 }
445 else if ( index == 3 )
446 {
397 portLine->setText( SMTP_PORT ); 447 portLine->setText( SMTP_PORT );
398 CommandEdit->show(); 448 CommandEdit->show();
399 } else { 449 }
450 else
451 {
400 portLine->setText( SMTP_PORT ); 452 portLine->setText( SMTP_PORT );
401 } 453 }
402} 454}
@@ -444,9 +496,12 @@ NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name,
444 496
445void NNTPconfig::slotSSL( bool enabled ) 497void NNTPconfig::slotSSL( bool enabled )
446{ 498{
447 if ( enabled ) { 499 if ( enabled )
500 {
448 portLine->setText( NNTP_SSL_PORT ); 501 portLine->setText( NNTP_SSL_PORT );
449 } else { 502 }
503 else
504 {
450 portLine->setText( NNTP_PORT ); 505 portLine->setText( NNTP_PORT );
451 } 506 }
452} 507}