summaryrefslogtreecommitdiffabout
path: root/kmicromail/editaccounts.cpp
Unidiff
Diffstat (limited to 'kmicromail/editaccounts.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/editaccounts.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp
index d272c3b..e7d2750 100644
--- a/kmicromail/editaccounts.cpp
+++ b/kmicromail/editaccounts.cpp
@@ -1,210 +1,211 @@
1 1
2#include "defines.h" 2#include "defines.h"
3#include "editaccounts.h" 3#include "editaccounts.h"
4#include "kapplication.h" 4#include "kapplication.h"
5/* OPIE */ 5/* OPIE */
6#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
7 7
8/* QT */ 8/* QT */
9#include <qstringlist.h> 9#include <qstringlist.h>
10 10
11#include <qcombobox.h> 11#include <qcombobox.h>
12#include <qcheckbox.h> 12#include <qcheckbox.h>
13#include <qmessagebox.h> 13#include <qmessagebox.h>
14#include <qpushbutton.h> 14#include <qpushbutton.h>
15#include <qlineedit.h> 15#include <qlineedit.h>
16#include <qlabel.h> 16#include <qlabel.h>
17#include <qtabwidget.h> 17#include <qtabwidget.h>
18#include <qlistview.h> 18#include <qlistview.h>
19#include <qspinbox.h>
19 20
20#include <libmailwrapper/nntpwrapper.h> 21#include <libmailwrapper/nntpwrapper.h>
21 22
22using namespace Opie::Core; 23using namespace Opie::Core;
23 24
24AccountListItem::AccountListItem( QListView *parent, Account *a) 25AccountListItem::AccountListItem( QListView *parent, Account *a)
25 : QListViewItem( parent ) 26 : QListViewItem( parent )
26{ 27{
27 account = a; 28 account = a;
28 setText( 0, account->getAccountName() ); 29 setText( 0, account->getAccountName() );
29 QString ttext = ""; 30 QString ttext = "";
30 switch (account->getType()) { 31 switch (account->getType()) {
31 case MAILLIB::A_NNTP: 32 case MAILLIB::A_NNTP:
32 ttext="NNTP"; 33 ttext="NNTP";
33 break; 34 break;
34 case MAILLIB::A_POP3: 35 case MAILLIB::A_POP3:
35 ttext = "POP3"; 36 ttext = "POP3";
36 break; 37 break;
37 case MAILLIB::A_IMAP: 38 case MAILLIB::A_IMAP:
38 ttext = "IMAP"; 39 ttext = "IMAP";
39 break; 40 break;
40 case MAILLIB::A_SMTP: 41 case MAILLIB::A_SMTP:
41 ttext = "SMTP"; 42 ttext = "SMTP";
42 break; 43 break;
43 default: 44 default:
44 ttext = "UNKNOWN"; 45 ttext = "UNKNOWN";
45 break; 46 break;
46 } 47 }
47 setText( 1, ttext); 48 setText( 1, ttext);
48} 49}
49 50
50EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 51EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
51 : EditAccountsUI( parent, name, modal, flags ) 52 : EditAccountsUI( parent, name, modal, flags )
52{ 53{
53 settings = s; 54 settings = s;
54 55
55 mailList->addColumn( tr( "Account" ) ); 56 mailList->addColumn( tr( "Account" ) );
56 mailList->addColumn( tr( "Type" ) ); 57 mailList->addColumn( tr( "Type" ) );
57 58
58 newsList->addColumn( tr( "Account" ) ); 59 newsList->addColumn( tr( "Account" ) );
59 60
60 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); 61 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) );
61 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); 62 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) );
62 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); 63 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) );
63 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); 64 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) );
64 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); 65 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) );
65 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); 66 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) );
66 67
67 slotFillLists(); 68 slotFillLists();
68} 69}
69 70
70void EditAccounts::slotFillLists() 71void EditAccounts::slotFillLists()
71{ 72{
72 mailList->clear(); 73 mailList->clear();
73 newsList->clear(); 74 newsList->clear();
74 75
75 QList<Account> accounts = settings->getAccounts(); 76 QList<Account> accounts = settings->getAccounts();
76 Account *it; 77 Account *it;
77 for ( it = accounts.first(); it; it = accounts.next() ) 78 for ( it = accounts.first(); it; it = accounts.next() )
78 { 79 {
79 if ( it->getType()==MAILLIB::A_NNTP ) 80 if ( it->getType()==MAILLIB::A_NNTP )
80 { 81 {
81 (void) new AccountListItem( newsList, it ); 82 (void) new AccountListItem( newsList, it );
82 } 83 }
83 else 84 else
84 { 85 {
85 (void) new AccountListItem( mailList, it ); 86 (void) new AccountListItem( mailList, it );
86 } 87 }
87 } 88 }
88} 89}
89 90
90void EditAccounts::slotNewMail() 91void EditAccounts::slotNewMail()
91{ 92{
92 QString *selection = new QString(); 93 QString *selection = new QString();
93 SelectMailType selType( selection, this, 0, true ); 94 SelectMailType selType( selection, this, 0, true );
94 selType.show(); 95 selType.show();
95 if ( QDialog::Accepted == selType.exec() ) 96 if ( QDialog::Accepted == selType.exec() )
96 { 97 {
97 slotNewAccount( *selection ); 98 slotNewAccount( *selection );
98 } 99 }
99} 100}
100 101
101void EditAccounts::slotNewAccount( const QString &type ) 102void EditAccounts::slotNewAccount( const QString &type )
102{ 103{
103 if ( type.compare( "IMAP" ) == 0 ) 104 if ( type.compare( "IMAP" ) == 0 )
104 { 105 {
105 IMAPaccount *account = new IMAPaccount(); 106 IMAPaccount *account = new IMAPaccount();
106 IMAPconfig imap( account, this, 0, true ); 107 IMAPconfig imap( account, this, 0, true );
107 imap.showMaximized(); 108 imap.showMaximized();
108 if ( QDialog::Accepted == imap.exec() ) 109 if ( QDialog::Accepted == imap.exec() )
109 { 110 {
110 settings->addAccount( account ); 111 settings->addAccount( account );
111 account->save(); 112 account->save();
112 slotFillLists(); 113 slotFillLists();
113 } 114 }
114 else 115 else
115 { 116 {
116 account->remove(); 117 account->remove();
117 } 118 }
118 } 119 }
119 else if ( type.compare( "POP3" ) == 0 ) 120 else if ( type.compare( "POP3" ) == 0 )
120 { 121 {
121 POP3account *account = new POP3account(); 122 POP3account *account = new POP3account();
122 POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); 123 POP3config pop3( account, this, 0, true, WStyle_ContextHelp );
123 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) 124 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) )
124 { 125 {
125 settings->addAccount( account ); 126 settings->addAccount( account );
126 account->save(); 127 account->save();
127 slotFillLists(); 128 slotFillLists();
128 } 129 }
129 else 130 else
130 { 131 {
131 account->remove(); 132 account->remove();
132 } 133 }
133 } 134 }
134 else if ( type.compare( "SMTP" ) == 0 ) 135 else if ( type.compare( "SMTP" ) == 0 )
135 { 136 {
136 SMTPaccount *account = new SMTPaccount(); 137 SMTPaccount *account = new SMTPaccount();
137 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); 138 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp );
138 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) 139 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) )
139 { 140 {
140 settings->addAccount( account ); 141 settings->addAccount( account );
141 account->save(); 142 account->save();
142 slotFillLists(); 143 slotFillLists();
143 144
144 } 145 }
145 else 146 else
146 { 147 {
147 account->remove(); 148 account->remove();
148 } 149 }
149 } 150 }
150 else if ( type.compare( "NNTP" ) == 0 ) 151 else if ( type.compare( "NNTP" ) == 0 )
151 { 152 {
152 NNTPaccount *account = new NNTPaccount(); 153 NNTPaccount *account = new NNTPaccount();
153 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); 154 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp );
154 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) 155 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) )
155 { 156 {
156 settings->addAccount( account ); 157 settings->addAccount( account );
157 account->save(); 158 account->save();
158 slotFillLists(); 159 slotFillLists();
159 } 160 }
160 else 161 else
161 { 162 {
162 account->remove(); 163 account->remove();
163 } 164 }
164 } 165 }
165} 166}
166 167
167void EditAccounts::slotEditAccount( Account *account ) 168void EditAccounts::slotEditAccount( Account *account )
168{ 169{
169 if ( account->getType() == MAILLIB::A_IMAP ) 170 if ( account->getType() == MAILLIB::A_IMAP )
170 { 171 {
171 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); 172 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account);
172 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); 173 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp );
173 if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) 174 if ( QDialog::Accepted == KApplication::execDialog( &imap ) )
174 { 175 {
175 slotFillLists(); 176 slotFillLists();
176 } 177 }
177 } 178 }
178 else if ( account->getType()==MAILLIB::A_POP3 ) 179 else if ( account->getType()==MAILLIB::A_POP3 )
179 { 180 {
180 POP3account *pop3Acc = static_cast<POP3account *>(account); 181 POP3account *pop3Acc = static_cast<POP3account *>(account);
181 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); 182 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp );
182 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) 183 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) )
183 { 184 {
184 slotFillLists(); 185 slotFillLists();
185 } 186 }
186 } 187 }
187 else if ( account->getType()==MAILLIB::A_SMTP ) 188 else if ( account->getType()==MAILLIB::A_SMTP )
188 { 189 {
189 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); 190 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account);
190 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); 191 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp );
191 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) 192 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) )
192 { 193 {
193 slotFillLists(); 194 slotFillLists();
194 } 195 }
195 } 196 }
196 else if ( account->getType()==MAILLIB::A_NNTP) 197 else if ( account->getType()==MAILLIB::A_NNTP)
197 { 198 {
198 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); 199 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account);
199 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); 200 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp );
200 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) 201 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) )
201 { 202 {
202 slotFillLists(); 203 slotFillLists();
203 } 204 }
204 } 205 }
205} 206}
206 207
207void EditAccounts::slotDeleteAccount( Account *account ) 208void EditAccounts::slotDeleteAccount( Account *account )
208{ 209{
209 if ( QMessageBox::information( this, tr( "Question" ), 210 if ( QMessageBox::information( this, tr( "Question" ),
210 tr( "<p>Do you really want to delete the selected Account?</p>" ), 211 tr( "<p>Do you really want to delete the selected Account?</p>" ),
@@ -231,364 +232,375 @@ void EditAccounts::slotEditMail()
231 232
232void EditAccounts::slotDeleteMail() 233void EditAccounts::slotDeleteMail()
233{ 234{
234 if ( !mailList->currentItem() ) 235 if ( !mailList->currentItem() )
235 { 236 {
236 QMessageBox::information( this, tr( "Error" ), 237 QMessageBox::information( this, tr( "Error" ),
237 tr( "<p>Please select an account.</p>" ), 238 tr( "<p>Please select an account.</p>" ),
238 tr( "Ok" ) ); 239 tr( "Ok" ) );
239 return; 240 return;
240 } 241 }
241 242
242 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 243 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
243 slotDeleteAccount( a ); 244 slotDeleteAccount( a );
244} 245}
245 246
246void EditAccounts::slotNewNews() 247void EditAccounts::slotNewNews()
247{ 248{
248 slotNewAccount( "NNTP" ); 249 slotNewAccount( "NNTP" );
249} 250}
250 251
251void EditAccounts::slotEditNews() 252void EditAccounts::slotEditNews()
252{ 253{
253 if ( !newsList->currentItem() ) 254 if ( !newsList->currentItem() )
254 { 255 {
255 QMessageBox::information( this, tr( "Error" ), 256 QMessageBox::information( this, tr( "Error" ),
256 tr( "<p>Please select an account.</p>" ), 257 tr( "<p>Please select an account.</p>" ),
257 tr( "Ok" ) ); 258 tr( "Ok" ) );
258 return; 259 return;
259 } 260 }
260 261
261 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 262 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
262 slotEditAccount( a ); 263 slotEditAccount( a );
263} 264}
264 265
265void EditAccounts::slotDeleteNews() 266void EditAccounts::slotDeleteNews()
266{ 267{
267 if ( !newsList->currentItem() ) 268 if ( !newsList->currentItem() )
268 { 269 {
269 QMessageBox::information( this, tr( "Error" ), 270 QMessageBox::information( this, tr( "Error" ),
270 tr( "<p>Please select an account.</p>" ), 271 tr( "<p>Please select an account.</p>" ),
271 tr( "Ok" ) ); 272 tr( "Ok" ) );
272 return; 273 return;
273 } 274 }
274 275
275 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 276 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
276 slotDeleteAccount( a ); 277 slotDeleteAccount( a );
277} 278}
278 279
279void EditAccounts::slotAdjustColumns() 280void EditAccounts::slotAdjustColumns()
280{ 281{
281 int currPage = configTab->currentPageIndex(); 282 int currPage = configTab->currentPageIndex();
282 283
283 configTab->showPage( mailTab ); 284 configTab->showPage( mailTab );
284 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); 285 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 );
285 mailList->setColumnWidth( 1, 50 ); 286 mailList->setColumnWidth( 1, 50 );
286 287
287 configTab->showPage( newsTab ); 288 configTab->showPage( newsTab );
288 newsList->setColumnWidth( 0, newsList->visibleWidth() ); 289 newsList->setColumnWidth( 0, newsList->visibleWidth() );
289 290
290 configTab->setCurrentPage( currPage ); 291 configTab->setCurrentPage( currPage );
291} 292}
292 293
293void EditAccounts::accept() 294void EditAccounts::accept()
294{ 295{
295 settings->saveAccounts(); 296 settings->saveAccounts();
296 297
297 QDialog::accept(); 298 QDialog::accept();
298} 299}
299 300
300/** 301/**
301 * SelectMailType 302 * SelectMailType
302 */ 303 */
303 304
304SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) 305SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags )
305 : SelectMailTypeUI( parent, name, modal, flags ) 306 : SelectMailTypeUI( parent, name, modal, flags )
306{ 307{
307 selected = selection; 308 selected = selection;
308 selected->replace( 0, selected->length(), typeBox->currentText() ); 309 selected->replace( 0, selected->length(), typeBox->currentText() );
309 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); 310 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) );
310} 311}
311 312
312void SelectMailType::slotSelection( const QString &sel ) 313void SelectMailType::slotSelection( const QString &sel )
313{ 314{
314 selected->replace( 0, selected->length(), sel ); 315 selected->replace( 0, selected->length(), sel );
315} 316}
316 317
317/** 318/**
318 * IMAPconfig 319 * IMAPconfig
319 */ 320 */
320 321
321IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 322IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
322 : IMAPconfigUI( parent, name, modal, flags ) 323 : IMAPconfigUI( parent, name, modal, flags )
323{ 324{
324 data = account; 325 data = account;
325 326
326 fillValues(); 327 fillValues();
327 328
328 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 329 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
329 ComboBox1->insertItem( "Only if available", 0 ); 330 ComboBox1->insertItem( "Only if available", 0 );
330 ComboBox1->insertItem( "Always, Negotiated", 1 ); 331 ComboBox1->insertItem( "Always, Negotiated", 1 );
331 ComboBox1->insertItem( "Connect on secure port", 2 ); 332 ComboBox1->insertItem( "Connect on secure port", 2 );
332 ComboBox1->insertItem( "Run command instead", 3 ); 333 ComboBox1->insertItem( "Run command instead", 3 );
333 CommandEdit->hide(); 334 CommandEdit->hide();
334 ComboBox1->setCurrentItem( data->ConnectionType() ); 335 ComboBox1->setCurrentItem( data->ConnectionType() );
335} 336}
336 337
337void IMAPconfig::slotConnectionToggle( int index ) 338void IMAPconfig::slotConnectionToggle( int index )
338{ 339{
339 if ( index == 2 ) 340 if ( index == 2 )
340 { 341 {
341 portLine->setText( IMAP_SSL_PORT ); 342 portLine->setText( IMAP_SSL_PORT );
342 } 343 }
343 else if ( index == 3 ) 344 else if ( index == 3 )
344 { 345 {
345 portLine->setText( IMAP_PORT ); 346 portLine->setText( IMAP_PORT );
346 CommandEdit->show(); 347 CommandEdit->show();
347 } 348 }
348 else 349 else
349 { 350 {
350 portLine->setText( IMAP_PORT ); 351 portLine->setText( IMAP_PORT );
351 } 352 }
352} 353}
353 354
354void IMAPconfig::fillValues() 355void IMAPconfig::fillValues()
355{ 356{
356 accountLine->setText( data->getAccountName() ); 357 accountLine->setText( data->getAccountName() );
357 serverLine->setText( data->getServer() ); 358 serverLine->setText( data->getServer() );
358 portLine->setText( data->getPort() ); 359 portLine->setText( data->getPort() );
359 ComboBox1->setCurrentItem( data->ConnectionType() ); 360 ComboBox1->setCurrentItem( data->ConnectionType() );
360 userLine->setText( data->getUser() ); 361 userLine->setText( data->getUser() );
361 passLine->setText( data->getPassword() ); 362 passLine->setText( data->getPassword() );
362 prefixLine->setText(data->getPrefix()); 363 prefixLine->setText(data->getPrefix());
363} 364}
364 365
365void IMAPconfig::accept() 366void IMAPconfig::accept()
366{ 367{
367 data->setAccountName( accountLine->text() ); 368 data->setAccountName( accountLine->text() );
368 data->setServer( serverLine->text() ); 369 data->setServer( serverLine->text() );
369 data->setPort( portLine->text() ); 370 data->setPort( portLine->text() );
370 data->setConnectionType( ComboBox1->currentItem() ); 371 data->setConnectionType( ComboBox1->currentItem() );
371 data->setUser( userLine->text() ); 372 data->setUser( userLine->text() );
372 data->setPassword( passLine->text() ); 373 data->setPassword( passLine->text() );
373 data->setPrefix(prefixLine->text()); 374 data->setPrefix(prefixLine->text());
374 375
375 QDialog::accept(); 376 QDialog::accept();
376} 377}
377 378
378/** 379/**
379 * POP3config 380 * POP3config
380 */ 381 */
381 382
382POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 383POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
383 : POP3configUI( parent, name, modal, flags ) 384 : POP3configUI( parent, name, modal, flags )
384{ 385{
385 data = account; 386 data = account;
386 fillValues(); 387 fillValues();
387 388
388 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 389 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
389 ComboBox1->insertItem( "Only if available", 0 ); 390 ComboBox1->insertItem( "Only if available", 0 );
390 ComboBox1->insertItem( "Always, Negotiated", 1 ); 391 ComboBox1->insertItem( "Always, Negotiated", 1 );
391 ComboBox1->insertItem( "Connect on secure port", 2 ); 392 ComboBox1->insertItem( "Connect on secure port", 2 );
392 ComboBox1->insertItem( "Run command instead", 3 ); 393 ComboBox1->insertItem( "Run command instead", 3 );
393 CommandEdit->hide(); 394 CommandEdit->hide();
394 ComboBox1->setCurrentItem( data->ConnectionType() ); 395 ComboBox1->setCurrentItem( data->ConnectionType() );
395} 396}
396 397
397void POP3config::slotConnectionToggle( int index ) 398void POP3config::slotConnectionToggle( int index )
398{ 399{
399 // 2 is ssl connection 400 // 2 is ssl connection
400 if ( index == 2 ) 401 if ( index == 2 )
401 { 402 {
402 portLine->setText( POP3_SSL_PORT ); 403 portLine->setText( POP3_SSL_PORT );
403 } 404 }
404 else if ( index == 3 ) 405 else if ( index == 3 )
405 { 406 {
406 portLine->setText( POP3_PORT ); 407 portLine->setText( POP3_PORT );
407 CommandEdit->show(); 408 CommandEdit->show();
408 } 409 }
409 else 410 else
410 { 411 {
411 portLine->setText( POP3_PORT ); 412 portLine->setText( POP3_PORT );
412 } 413 }
413} 414}
414 415
415void POP3config::fillValues() 416void POP3config::fillValues()
416{ 417{
417 accountLine->setText( data->getAccountName() ); 418 accountLine->setText( data->getAccountName() );
418 serverLine->setText( data->getServer() ); 419 serverLine->setText( data->getServer() );
419 portLine->setText( data->getPort() ); 420 portLine->setText( data->getPort() );
420 ComboBox1->setCurrentItem( data->ConnectionType() ); 421 ComboBox1->setCurrentItem( data->ConnectionType() );
421 userLine->setText( data->getUser() ); 422 userLine->setText( data->getUser() );
422 passLine->setText( data->getPassword() ); 423 passLine->setText( data->getPassword() );
424 localFolder->setText( data->getLocalFolder() );
425 int max = data->getMaxMailSize() ;
426 if ( max ) {
427 CheckBoxDown->setChecked( true );
428 SpinBoxDown->setValue ( max );
429 } else {
430 CheckBoxDown->setChecked( false );
431 SpinBoxDown->setValue ( 5 );
432 }
423} 433}
424 434
425void POP3config::accept() 435void POP3config::accept()
426{ 436{
427 data->setAccountName( accountLine->text() ); 437 data->setAccountName( accountLine->text() );
428 data->setServer( serverLine->text() ); 438 data->setServer( serverLine->text() );
429 data->setPort( portLine->text() ); 439 data->setPort( portLine->text() );
430 data->setConnectionType( ComboBox1->currentItem() ); 440 data->setConnectionType( ComboBox1->currentItem() );
431 data->setUser( userLine->text() ); 441 data->setUser( userLine->text() );
432 data->setPassword( passLine->text() ); 442 data->setPassword( passLine->text() );
443 data->setLocalFolder( localFolder->text() );
444 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ;
433 445
434 QDialog::accept(); 446 QDialog::accept();
435} 447}
436 448
437/** 449/**
438 * SMTPconfig 450 * SMTPconfig
439 */ 451 */
440 452
441SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 453SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
442 : SMTPconfigUI( parent, name, modal, flags ) 454 : SMTPconfigUI( parent, name, modal, flags )
443{ 455{
444 data = account; 456 data = account;
445 457
446 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 458 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
447 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 459 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
448 460
449 fillValues(); 461 fillValues();
450 462
451 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 463 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
452 ComboBox1->insertItem( "Only if available", 0 ); 464 ComboBox1->insertItem( "Only if available", 0 );
453 ComboBox1->insertItem( "Always, Negotiated", 1 ); 465 ComboBox1->insertItem( "Always, Negotiated", 1 );
454 ComboBox1->insertItem( "Connect on secure port", 2 ); 466 ComboBox1->insertItem( "Connect on secure port", 2 );
455 ComboBox1->insertItem( "Run command instead", 3 ); 467 ComboBox1->insertItem( "Run command instead", 3 );
456 CommandEdit->hide(); 468 CommandEdit->hide();
457 ComboBox1->setCurrentItem( data->ConnectionType() ); 469 ComboBox1->setCurrentItem( data->ConnectionType() );
458} 470}
459 471
460void SMTPconfig::slotConnectionToggle( int index ) 472void SMTPconfig::slotConnectionToggle( int index )
461{ 473{
462 // 2 is ssl connection 474 // 2 is ssl connection
463 if ( index == 2 ) 475 if ( index == 2 )
464 { 476 {
465 portLine->setText( SMTP_SSL_PORT ); 477 portLine->setText( SMTP_SSL_PORT );
466 } 478 }
467 else if ( index == 3 ) 479 else if ( index == 3 )
468 { 480 {
469 portLine->setText( SMTP_PORT ); 481 portLine->setText( SMTP_PORT );
470 CommandEdit->show(); 482 CommandEdit->show();
471 } 483 }
472 else 484 else
473 { 485 {
474 portLine->setText( SMTP_PORT ); 486 portLine->setText( SMTP_PORT );
475 } 487 }
476} 488}
477 489
478void SMTPconfig::fillValues() 490void SMTPconfig::fillValues()
479{ 491{
480 accountLine->setText( data->getAccountName() ); 492 accountLine->setText( data->getAccountName() );
481 serverLine->setText( data->getServer() ); 493 serverLine->setText( data->getServer() );
482 portLine->setText( data->getPort() ); 494 portLine->setText( data->getPort() );
483 ComboBox1->setCurrentItem( data->ConnectionType() ); 495 ComboBox1->setCurrentItem( data->ConnectionType() );
484 loginBox->setChecked( data->getLogin() ); 496 loginBox->setChecked( data->getLogin() );
485 userLine->setText( data->getUser() ); 497 userLine->setText( data->getUser() );
486 passLine->setText( data->getPassword() ); 498 passLine->setText( data->getPassword() );
487} 499}
488 500
489void SMTPconfig::accept() 501void SMTPconfig::accept()
490{ 502{
491 data->setAccountName( accountLine->text() ); 503 data->setAccountName( accountLine->text() );
492 data->setServer( serverLine->text() ); 504 data->setServer( serverLine->text() );
493 data->setPort( portLine->text() ); 505 data->setPort( portLine->text() );
494 data->setConnectionType( ComboBox1->currentItem() ); 506 data->setConnectionType( ComboBox1->currentItem() );
495 data->setLogin( loginBox->isChecked() ); 507 data->setLogin( loginBox->isChecked() );
496 data->setUser( userLine->text() ); 508 data->setUser( userLine->text() );
497 data->setPassword( passLine->text() ); 509 data->setPassword( passLine->text() );
498 510
499 QDialog::accept(); 511 QDialog::accept();
500} 512}
501 513
502/** 514/**
503 * NNTPconfig 515 * NNTPconfig
504 */ 516 */
505 517
506NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 518NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
507 : NNTPconfigUI( parent, name, modal, flags ) 519 : NNTPconfigUI( parent, name, modal, flags )
508{ 520{
509 data = account; 521 data = account;
510 522
511 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 523 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
512 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 524 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
513 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); 525 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) );
514 fillValues(); 526 fillValues();
515 527
516 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); 528 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) );
517} 529}
518 530
519void NNTPconfig::slotGetNG() { 531void NNTPconfig::slotGetNG() {
520 save(); 532 save();
521 data->save(); 533 data->save();
522 NNTPwrapper* tmp = new NNTPwrapper( data ); 534 NNTPwrapper* tmp = new NNTPwrapper( data );
523 QStringList list = tmp->listAllNewsgroups(); 535 QStringList list = tmp->listAllNewsgroups();
524 536
525 ListViewGroups->clear(); 537 ListViewGroups->clear();
526 538
527 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 539 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
528 QCheckListItem *item; 540 QCheckListItem *item;
529 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 541 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
530 if ( subscribedGroups.contains( (*it) ) >= 1 ) { 542 if ( subscribedGroups.contains( (*it) ) >= 1 ) {
531 item->setOn( true ); 543 item->setOn( true );
532 } 544 }
533 } 545 }
534} 546}
535 547
536void NNTPconfig::slotSSL( bool enabled ) 548void NNTPconfig::slotSSL( bool enabled )
537{ 549{
538 if ( enabled ) 550 if ( enabled )
539 { 551 {
540 portLine->setText( NNTP_SSL_PORT ); 552 portLine->setText( NNTP_SSL_PORT );
541 } 553 }
542 else 554 else
543 { 555 {
544 portLine->setText( NNTP_PORT ); 556 portLine->setText( NNTP_PORT );
545 } 557 }
546} 558}
547 559
548void NNTPconfig::fillValues() 560void NNTPconfig::fillValues()
549{ 561{
550 accountLine->setText( data->getAccountName() ); 562 accountLine->setText( data->getAccountName() );
551 serverLine->setText( data->getServer() ); 563 serverLine->setText( data->getServer() );
552 portLine->setText( data->getPort() ); 564 portLine->setText( data->getPort() );
553 sslBox->setChecked( data->getSSL() ); 565 sslBox->setChecked( data->getSSL() );
554 loginBox->setChecked( data->getLogin() ); 566 loginBox->setChecked( data->getLogin() );
555 userLine->setText( data->getUser() ); 567 userLine->setText( data->getUser() );
556 passLine->setText( data->getPassword() ); 568 passLine->setText( data->getPassword() );
557 subscribedGroups = data->getGroups(); 569 subscribedGroups = data->getGroups();
558 /* don't forget that - you will overwrite values if user clicks cancel! */ 570 /* don't forget that - you will overwrite values if user clicks cancel! */
559 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { 571 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
560 QCheckListItem *item; 572 QCheckListItem *item;
561 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 573 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
562 item->setOn( true ); 574 item->setOn( true );
563 } 575 }
564} 576}
565 577
566void NNTPconfig::save() 578void NNTPconfig::save()
567{ 579{
568 data->setAccountName( accountLine->text() ); 580 data->setAccountName( accountLine->text() );
569 data->setServer( serverLine->text() ); 581 data->setServer( serverLine->text() );
570 data->setPort( portLine->text() ); 582 data->setPort( portLine->text() );
571 data->setSSL( sslBox->isChecked() ); 583 data->setSSL( sslBox->isChecked() );
572 data->setLogin( loginBox->isChecked() ); 584 data->setLogin( loginBox->isChecked() );
573 data->setUser( userLine->text() ); 585 data->setUser( userLine->text() );
574 data->setPassword( passLine->text() ); 586 data->setPassword( passLine->text() );
575 587
576 QListViewItemIterator list_it( ListViewGroups ); 588 QListViewItemIterator list_it( ListViewGroups );
577 589
578 QStringList groupList; 590 QStringList groupList;
579 for ( ; list_it.current(); ++list_it ) { 591 for ( ; list_it.current(); ++list_it ) {
580 592
581 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { 593 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) {
582 groupList.append( list_it.current()->text(0) ); 594 groupList.append( list_it.current()->text(0) );
583 } 595 }
584 596
585 } 597 }
586 data->setGroups( groupList ); 598 data->setGroups( groupList );
587} 599}
588 600
589void NNTPconfig::accept() 601void NNTPconfig::accept()
590{ 602{
591 save(); 603 save();
592 QDialog::accept(); 604 QDialog::accept();
593} 605}
594 606