summaryrefslogtreecommitdiffabout
path: root/kmicromail/editaccounts.cpp
Unidiff
Diffstat (limited to 'kmicromail/editaccounts.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/editaccounts.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp
index f1075c0..49049f6 100644
--- a/kmicromail/editaccounts.cpp
+++ b/kmicromail/editaccounts.cpp
@@ -141,553 +141,557 @@ void EditAccounts::slotNewAccount( const QString &type )
141 else if ( type.compare( i18n("SMTP") ) == 0 ) 141 else if ( type.compare( i18n("SMTP") ) == 0 )
142 { 142 {
143 SMTPaccount *account = new SMTPaccount(); 143 SMTPaccount *account = new SMTPaccount();
144 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); 144 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp );
145 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) 145 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) )
146 { 146 {
147 settings->addAccount( account ); 147 settings->addAccount( account );
148 account->save(); 148 account->save();
149 slotFillLists(); 149 slotFillLists();
150 150
151 } 151 }
152 else 152 else
153 { 153 {
154 account->remove(); 154 account->remove();
155 } 155 }
156 } 156 }
157 else if ( type.compare( i18n("NNTP") ) == 0 ) 157 else if ( type.compare( i18n("NNTP") ) == 0 )
158 { 158 {
159 NNTPaccount *account = new NNTPaccount(); 159 NNTPaccount *account = new NNTPaccount();
160 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); 160 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp );
161 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) 161 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) )
162 { 162 {
163 settings->addAccount( account ); 163 settings->addAccount( account );
164 account->save(); 164 account->save();
165 slotFillLists(); 165 slotFillLists();
166 } 166 }
167 else 167 else
168 { 168 {
169 account->remove(); 169 account->remove();
170 } 170 }
171 } 171 }
172} 172}
173 173
174void EditAccounts::slotEditAccount( Account *account ) 174void EditAccounts::slotEditAccount( Account *account )
175{ 175{
176 if ( account->getType() == MAILLIB::A_IMAP ) 176 if ( account->getType() == MAILLIB::A_IMAP )
177 { 177 {
178 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); 178 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account);
179 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); 179 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp );
180 if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) 180 if ( QDialog::Accepted == KApplication::execDialog( &imap ) )
181 { 181 {
182 slotFillLists(); 182 slotFillLists();
183 } 183 }
184 } 184 }
185 else if ( account->getType()==MAILLIB::A_POP3 ) 185 else if ( account->getType()==MAILLIB::A_POP3 )
186 { 186 {
187 POP3account *pop3Acc = static_cast<POP3account *>(account); 187 POP3account *pop3Acc = static_cast<POP3account *>(account);
188 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); 188 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp );
189 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) 189 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) )
190 { 190 {
191 slotFillLists(); 191 slotFillLists();
192 } 192 }
193 } 193 }
194 else if ( account->getType()==MAILLIB::A_SMTP ) 194 else if ( account->getType()==MAILLIB::A_SMTP )
195 { 195 {
196 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); 196 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account);
197 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); 197 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp );
198 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) 198 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) )
199 { 199 {
200 slotFillLists(); 200 slotFillLists();
201 } 201 }
202 } 202 }
203 else if ( account->getType()==MAILLIB::A_NNTP) 203 else if ( account->getType()==MAILLIB::A_NNTP)
204 { 204 {
205 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); 205 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account);
206 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); 206 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp );
207 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) 207 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) )
208 { 208 {
209 slotFillLists(); 209 slotFillLists();
210 } 210 }
211 } 211 }
212} 212}
213 213
214void EditAccounts::slotDeleteAccount( Account *account ) 214void EditAccounts::slotDeleteAccount( Account *account )
215{ 215{
216 if ( QMessageBox::information( this, i18n( "Question" ), 216 if ( QMessageBox::information( this, i18n( "Question" ),
217 i18n( "<p>Do you really want to delete the selected Account?</p>" ), 217 i18n( "<p>Do you really want to delete the selected Account?</p>" ),
218 i18n( "Yes" ), i18n( "No" ) ) == 0 ) 218 i18n( "Yes" ), i18n( "No" ) ) == 0 )
219 { 219 {
220 settings->delAccount( account ); 220 settings->delAccount( account );
221 slotFillLists(); 221 slotFillLists();
222 } 222 }
223} 223}
224 224
225void EditAccounts::slotEditMail() 225void EditAccounts::slotEditMail()
226{ 226{
227 if ( !mailList->currentItem() ) 227 if ( !mailList->currentItem() )
228 { 228 {
229 QMessageBox::information( this, i18n( "Error" ), 229 QMessageBox::information( this, i18n( "Error" ),
230 i18n( "<p>Please select an account.</p>" ), 230 i18n( "<p>Please select an account.</p>" ),
231 i18n( "Ok" ) ); 231 i18n( "Ok" ) );
232 return; 232 return;
233 } 233 }
234 234
235 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 235 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
236 slotEditAccount( a ); 236 slotEditAccount( a );
237} 237}
238 238
239void EditAccounts::slotDeleteMail() 239void EditAccounts::slotDeleteMail()
240{ 240{
241 if ( !mailList->currentItem() ) 241 if ( !mailList->currentItem() )
242 { 242 {
243 QMessageBox::information( this, i18n( "Error" ), 243 QMessageBox::information( this, i18n( "Error" ),
244 i18n( "<p>Please select an account.</p>" ), 244 i18n( "<p>Please select an account.</p>" ),
245 i18n( "Ok" ) ); 245 i18n( "Ok" ) );
246 return; 246 return;
247 } 247 }
248 248
249 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 249 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
250 slotDeleteAccount( a ); 250 slotDeleteAccount( a );
251} 251}
252 252
253void EditAccounts::slotNewNews() 253void EditAccounts::slotNewNews()
254{ 254{
255 slotNewAccount( "NNTP" ); 255 slotNewAccount( "NNTP" );
256} 256}
257 257
258void EditAccounts::slotEditNews() 258void EditAccounts::slotEditNews()
259{ 259{
260 if ( !newsList->currentItem() ) 260 if ( !newsList->currentItem() )
261 { 261 {
262 QMessageBox::information( this, i18n( "Error" ), 262 QMessageBox::information( this, i18n( "Error" ),
263 i18n( "<p>Please select an account.</p>" ), 263 i18n( "<p>Please select an account.</p>" ),
264 i18n( "Ok" ) ); 264 i18n( "Ok" ) );
265 return; 265 return;
266 } 266 }
267 267
268 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 268 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
269 slotEditAccount( a ); 269 slotEditAccount( a );
270} 270}
271 271
272void EditAccounts::slotDeleteNews() 272void EditAccounts::slotDeleteNews()
273{ 273{
274 if ( !newsList->currentItem() ) 274 if ( !newsList->currentItem() )
275 { 275 {
276 QMessageBox::information( this, i18n( "Error" ), 276 QMessageBox::information( this, i18n( "Error" ),
277 i18n( "<p>Please select an account.</p>" ), 277 i18n( "<p>Please select an account.</p>" ),
278 i18n( "Ok" ) ); 278 i18n( "Ok" ) );
279 return; 279 return;
280 } 280 }
281 281
282 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 282 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
283 slotDeleteAccount( a ); 283 slotDeleteAccount( a );
284} 284}
285 285
286void EditAccounts::slotAdjustColumns() 286void EditAccounts::slotAdjustColumns()
287{ 287{
288 int currPage = configTab->currentPageIndex(); 288 int currPage = configTab->currentPageIndex();
289 289
290 configTab->showPage( mailTab ); 290 configTab->showPage( mailTab );
291 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); 291 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 );
292 mailList->setColumnWidth( 1, 50 ); 292 mailList->setColumnWidth( 1, 50 );
293 293
294 configTab->showPage( newsTab ); 294 configTab->showPage( newsTab );
295 newsList->setColumnWidth( 0, newsList->visibleWidth() ); 295 newsList->setColumnWidth( 0, newsList->visibleWidth() );
296 296
297 configTab->setCurrentPage( currPage ); 297 configTab->setCurrentPage( currPage );
298} 298}
299 299
300void EditAccounts::accept() 300void EditAccounts::accept()
301{ 301{
302 settings->saveAccounts(); 302 settings->saveAccounts();
303 303
304 QDialog::accept(); 304 QDialog::accept();
305} 305}
306 306
307/** 307/**
308 * SelectMailType 308 * SelectMailType
309 */ 309 */
310 310
311SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) 311SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags )
312 : SelectMailTypeUI( parent, name, modal, flags ) 312 : SelectMailTypeUI( parent, name, modal, flags )
313{ 313{
314 selected = selection; 314 selected = selection;
315 selected->replace( 0, selected->length(), typeBox->currentText() ); 315 selected->replace( 0, selected->length(), typeBox->currentText() );
316 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); 316 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) );
317} 317}
318 318
319void SelectMailType::slotSelection( const QString &sel ) 319void SelectMailType::slotSelection( const QString &sel )
320{ 320{
321 selected->replace( 0, selected->length(), sel ); 321 selected->replace( 0, selected->length(), sel );
322} 322}
323 323
324/** 324/**
325 * IMAPconfig 325 * IMAPconfig
326 */ 326 */
327 327
328IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 328IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
329 : IMAPconfigUI( parent, name, modal, flags ) 329 : IMAPconfigUI( parent, name, modal, flags )
330{ 330{
331 data = account; 331 data = account;
332 332
333 fillValues(); 333 //fillValues();
334 334
335 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 335 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
336 ComboBox1->insertItem( "Only if available", 0 ); 336 ComboBox1->insertItem( "Only if available", 0 );
337 ComboBox1->insertItem( "Always, Negotiated", 1 ); 337 ComboBox1->insertItem( "Always, Negotiated", 1 );
338 ComboBox1->insertItem( "Connect on secure port", 2 ); 338 ComboBox1->insertItem( "Connect on secure port", 2 );
339 ComboBox1->insertItem( "Run command instead", 3 ); 339 ComboBox1->insertItem( "Run command instead", 3 );
340 CommandEdit->hide(); 340 CommandEdit->hide();
341 ComboBox1->setCurrentItem( data->ConnectionType() ); 341 fillValues();
342 // ComboBox1->setCurrentItem( data->ConnectionType() );
342} 343}
343 344
344void IMAPconfig::slotConnectionToggle( int index ) 345void IMAPconfig::slotConnectionToggle( int index )
345{ 346{
346 if ( index == 2 ) 347 if ( index == 2 )
347 { 348 {
348 portLine->setText( IMAP_SSL_PORT ); 349 portLine->setText( IMAP_SSL_PORT );
349 } 350 }
350 else if ( index == 3 ) 351 else if ( index == 3 )
351 { 352 {
352 portLine->setText( IMAP_PORT ); 353 portLine->setText( IMAP_PORT );
353 CommandEdit->show(); 354 CommandEdit->show();
354 } 355 }
355 else 356 else
356 { 357 {
357 portLine->setText( IMAP_PORT ); 358 portLine->setText( IMAP_PORT );
358 } 359 }
359} 360}
360 361
361void IMAPconfig::fillValues() 362void IMAPconfig::fillValues()
362{ 363{
363 accountLine->setText( data->getAccountName() ); 364 accountLine->setText( data->getAccountName() );
364 serverLine->setText( data->getServer() ); 365 serverLine->setText( data->getServer() );
365 portLine->setText( data->getPort() ); 366 portLine->setText( data->getPort() );
366 ComboBox1->setCurrentItem( data->ConnectionType() ); 367 ComboBox1->setCurrentItem( data->ConnectionType() );
367 userLine->setText( data->getUser() ); 368 userLine->setText( data->getUser() );
368 passLine->setText( data->getPassword() ); 369 passLine->setText( data->getPassword() );
369 prefixLine->setText(data->getPrefix()); 370 prefixLine->setText(data->getPrefix());
370 localFolder->setText( data->getLocalFolder() ); 371 localFolder->setText( data->getLocalFolder() );
371 int max = data->getMaxMailSize() ; 372 int max = data->getMaxMailSize() ;
372 if ( max ) { 373 if ( max ) {
373 CheckBoxDown->setChecked( true ); 374 CheckBoxDown->setChecked( true );
374 SpinBoxDown->setValue ( max ); 375 SpinBoxDown->setValue ( max );
375 } else { 376 } else {
376 CheckBoxDown->setChecked( false ); 377 CheckBoxDown->setChecked( false );
377 SpinBoxDown->setValue ( 5 ); 378 SpinBoxDown->setValue ( 5 );
378 } 379 }
379 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); 380 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() );
380} 381}
381 382
382void IMAPconfig::accept() 383void IMAPconfig::accept()
383{ 384{
384 if ( localFolder->text().contains("/") ||localFolder->text().contains("\\") ) { 385 if ( localFolder->text().contains("/") ||localFolder->text().contains("\\") ) {
385 QMessageBox::information( this, i18n( "Error" ), 386 QMessageBox::information( this, i18n( "Error" ),
386 i18n( "No paths allowed in\nlocal folder settings.\nPlease specify a folder\nname or leave empty\nto create local folder\nwith account name\nautomatically." ), 387 i18n( "No paths allowed in\nlocal folder settings.\nPlease specify a folder\nname or leave empty\nto create local folder\nwith account name\nautomatically." ),
387 i18n( "Ok" ) ); 388 i18n( "Ok" ) );
388 return; 389 return;
389 } 390 }
390 data->setAccountName( accountLine->text() ); 391 data->setAccountName( accountLine->text() );
391 data->setServer( serverLine->text() ); 392 data->setServer( serverLine->text() );
392 data->setPort( portLine->text() ); 393 data->setPort( portLine->text() );
393 data->setConnectionType( ComboBox1->currentItem() ); 394 data->setConnectionType( ComboBox1->currentItem() );
394 data->setUser( userLine->text() ); 395 data->setUser( userLine->text() );
395 data->setPassword( passLine->text() ); 396 data->setPassword( passLine->text() );
396 data->setPrefix(prefixLine->text()); 397 data->setPrefix(prefixLine->text());
397 data->setLocalFolder( localFolder->text() ); 398 data->setLocalFolder( localFolder->text() );
398 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; 399 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ;
399 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); 400 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() );
400 401
401 QDialog::accept(); 402 QDialog::accept();
402} 403}
403 404
404/** 405/**
405 * POP3config 406 * POP3config
406 */ 407 */
407 408
408POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 409POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
409 : POP3configUI( parent, name, modal, flags ) 410 : POP3configUI( parent, name, modal, flags )
410{ 411{
411 data = account; 412 data = account;
412 fillValues(); 413 //fillValues();
413 414
414 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 415 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
415 ComboBox1->insertItem( "Only if available", 0 ); 416 ComboBox1->insertItem( "Only if available", 0 );
416 ComboBox1->insertItem( "Always, Negotiated", 1 ); 417 ComboBox1->insertItem( "Always, Negotiated", 1 );
417 ComboBox1->insertItem( "Connect on secure port", 2 ); 418 ComboBox1->insertItem( "Connect on secure port", 2 );
418 ComboBox1->insertItem( "Run command instead", 3 ); 419 ComboBox1->insertItem( "Run command instead", 3 );
419 CommandEdit->hide(); 420 CommandEdit->hide();
420 ComboBox1->setCurrentItem( data->ConnectionType() ); 421 fillValues();
422 //ComboBox1->setCurrentItem( data->ConnectionType() );
421} 423}
422 424
423void POP3config::slotConnectionToggle( int index ) 425void POP3config::slotConnectionToggle( int index )
424{ 426{
425 // 2 is ssl connection 427 // 2 is ssl connection
426 if ( index == 2 ) 428 if ( index == 2 )
427 { 429 {
428 portLine->setText( POP3_SSL_PORT ); 430 portLine->setText( POP3_SSL_PORT );
429 } 431 }
430 else if ( index == 3 ) 432 else if ( index == 3 )
431 { 433 {
432 portLine->setText( POP3_PORT ); 434 portLine->setText( POP3_PORT );
433 CommandEdit->show(); 435 CommandEdit->show();
434 } 436 }
435 else 437 else
436 { 438 {
437 portLine->setText( POP3_PORT ); 439 portLine->setText( POP3_PORT );
438 } 440 }
439} 441}
440 442
441void POP3config::fillValues() 443void POP3config::fillValues()
442{ 444{
443 accountLine->setText( data->getAccountName() ); 445 accountLine->setText( data->getAccountName() );
444 serverLine->setText( data->getServer() ); 446 serverLine->setText( data->getServer() );
445 portLine->setText( data->getPort() ); 447 portLine->setText( data->getPort() );
446 ComboBox1->setCurrentItem( data->ConnectionType() ); 448 ComboBox1->setCurrentItem( data->ConnectionType() );
447 userLine->setText( data->getUser() ); 449 userLine->setText( data->getUser() );
448 passLine->setText( data->getPassword() ); 450 passLine->setText( data->getPassword() );
449 localFolder->setText( data->getLocalFolder() ); 451 localFolder->setText( data->getLocalFolder() );
450 int max = data->getMaxMailSize() ; 452 int max = data->getMaxMailSize() ;
451 if ( max ) { 453 if ( max ) {
452 CheckBoxDown->setChecked( true ); 454 CheckBoxDown->setChecked( true );
453 SpinBoxDown->setValue ( max ); 455 SpinBoxDown->setValue ( max );
454 } else { 456 } else {
455 CheckBoxDown->setChecked( false ); 457 CheckBoxDown->setChecked( false );
456 SpinBoxDown->setValue ( 5 ); 458 SpinBoxDown->setValue ( 5 );
457 } 459 }
458 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() ); 460 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() );
459} 461}
460 462
461void POP3config::accept() 463void POP3config::accept()
462{ 464{
463 if ( localFolder->text().contains("/") ||localFolder->text().contains("\\") ) { 465 if ( localFolder->text().contains("/") ||localFolder->text().contains("\\") ) {
464 QMessageBox::information( this, i18n( "Error" ), 466 QMessageBox::information( this, i18n( "Error" ),
465 i18n( "No paths allowed in\nlocal folder settings.\nPlease specify a folder\nname or leave empty\nto create local folder\nwith account name\nautomatically." ), 467 i18n( "No paths allowed in\nlocal folder settings.\nPlease specify a folder\nname or leave empty\nto create local folder\nwith account name\nautomatically." ),
466 i18n( "Ok" ) ); 468 i18n( "Ok" ) );
467 return; 469 return;
468 } 470 }
469 data->setAccountName( accountLine->text() ); 471 data->setAccountName( accountLine->text() );
470 data->setServer( serverLine->text() ); 472 data->setServer( serverLine->text() );
471 data->setPort( portLine->text() ); 473 data->setPort( portLine->text() );
472 data->setConnectionType( ComboBox1->currentItem() ); 474 data->setConnectionType( ComboBox1->currentItem() );
473 data->setUser( userLine->text() ); 475 data->setUser( userLine->text() );
474 data->setPassword( passLine->text() ); 476 data->setPassword( passLine->text() );
475 data->setLocalFolder( localFolder->text() ); 477 data->setLocalFolder( localFolder->text() );
476 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; 478 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ;
477 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() ); 479 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() );
478 480
479 QDialog::accept(); 481 QDialog::accept();
480} 482}
481 483
482/** 484/**
483 * SMTPconfig 485 * SMTPconfig
484 */ 486 */
485 487
486SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 488SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
487 : SMTPconfigUI( parent, name, modal, flags ) 489 : SMTPconfigUI( parent, name, modal, flags )
488{ 490{
489 data = account; 491 data = account;
490 492
491 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 493 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
492 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 494 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
493 495
494 fillValues(); 496 // fillValues();
495 QIconSet icon; 497 QIconSet icon;
496 //icon = SmallIcon("fileexport"); 498 //icon = SmallIcon("fileexport");
497 icon = SmallIcon("fileopen"); 499 icon = SmallIcon("fileopen");
498 SignaturButton->setText(""); 500 SignaturButton->setText("");
499 SignaturButton->setIconSet (icon ) ; 501 SignaturButton->setIconSet (icon ) ;
500 SignaturButton->setMaximumSize ( SignaturButton->sizeHint().height()+4,SignaturButton->sizeHint().height()) ; 502 SignaturButton->setMaximumSize ( SignaturButton->sizeHint().height()+4,SignaturButton->sizeHint().height()) ;
501 connect( SignaturButton, SIGNAL( clicked() ), this, SLOT( chooseSig() ) ); 503 connect( SignaturButton, SIGNAL( clicked() ), this, SLOT( chooseSig() ) );
502 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 504 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
503 ComboBox1->insertItem( "Only if available", 0 ); 505 ComboBox1->insertItem( "No secure connection, no TLS", 0 );
504 ComboBox1->insertItem( "Always, Negotiated", 1 ); 506 ComboBox1->insertItem( "Only if available, try TLS", 1 );
505 ComboBox1->insertItem( "Connect on secure port", 2 ); 507 ComboBox1->insertItem( "Always, use TLS", 2 );
506 ComboBox1->insertItem( "Run command instead", 3 ); 508 ComboBox1->insertItem( "Connect on secure port (SSL)", 3 );
509 ComboBox1->insertItem( "Run command instead", 4 );
507 CommandEdit->hide(); 510 CommandEdit->hide();
508 ComboBox1->setCurrentItem( data->ConnectionType() ); 511 fillValues();
512 //ComboBox1->setCurrentItem( data->ConnectionType() );
509} 513}
510void SMTPconfig::chooseSig() 514void SMTPconfig::chooseSig()
511{ 515{
512 QString lnk = KFileDialog::getOpenFileName( "", "Choose Signatur File", this ); 516 QString lnk = KFileDialog::getOpenFileName( "", "Choose Signatur File", this );
513 if ( !lnk.isEmpty() ) { 517 if ( !lnk.isEmpty() ) {
514 SignaturEdit->setText( lnk ); 518 SignaturEdit->setText( lnk );
515 } 519 }
516} 520}
517void SMTPconfig::slotConnectionToggle( int index ) 521void SMTPconfig::slotConnectionToggle( int index )
518{ 522{
519 // 2 is ssl connection 523 // 2 is ssl connection
520 if ( index == 2 ) 524 if ( index == 2 )
521 { 525 {
522 portLine->setText( SMTP_SSL_PORT ); 526 portLine->setText( SMTP_SSL_PORT );
523 } 527 }
524 else if ( index == 3 ) 528 else if ( index == 3 )
525 { 529 {
526 portLine->setText( SMTP_PORT ); 530 portLine->setText( SMTP_PORT );
527 CommandEdit->show(); 531 CommandEdit->show();
528 } 532 }
529 else 533 else
530 { 534 {
531 portLine->setText( SMTP_PORT ); 535 portLine->setText( SMTP_PORT );
532 } 536 }
533} 537}
534 538
535void SMTPconfig::fillValues() 539void SMTPconfig::fillValues()
536{ 540{
537 accountLine->setText( data->getAccountName() ); 541 accountLine->setText( data->getAccountName() );
538 serverLine->setText( data->getServer() ); 542 serverLine->setText( data->getServer() );
539 portLine->setText( data->getPort() ); 543 portLine->setText( data->getPort() );
540 ComboBox1->setCurrentItem( data->ConnectionType() ); 544 ComboBox1->setCurrentItem( data->ConnectionType() );
541 loginBox->setChecked( data->getLogin() ); 545 loginBox->setChecked( data->getLogin() );
542 userLine->setText( data->getUser() ); 546 userLine->setText( data->getUser() );
543 passLine->setText( data->getPassword() ); 547 passLine->setText( data->getPassword() );
544 SignaturEdit->setText( data->getSigFile() ); 548 SignaturEdit->setText( data->getSigFile() );
545} 549}
546 550
547void SMTPconfig::accept() 551void SMTPconfig::accept()
548{ 552{
549 data->setAccountName( accountLine->text() ); 553 data->setAccountName( accountLine->text() );
550 data->setServer( serverLine->text() ); 554 data->setServer( serverLine->text() );
551 data->setPort( portLine->text() ); 555 data->setPort( portLine->text() );
552 data->setConnectionType( ComboBox1->currentItem() ); 556 data->setConnectionType( ComboBox1->currentItem() );
553 data->setLogin( loginBox->isChecked() ); 557 data->setLogin( loginBox->isChecked() );
554 data->setUser( userLine->text() ); 558 data->setUser( userLine->text() );
555 data->setPassword( passLine->text() ); 559 data->setPassword( passLine->text() );
556 data->setSigFile( SignaturEdit->text() ); 560 data->setSigFile( SignaturEdit->text() );
557 561
558 QDialog::accept(); 562 QDialog::accept();
559} 563}
560 564
561/** 565/**
562 * NNTPconfig 566 * NNTPconfig
563 */ 567 */
564 568
565NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 569NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
566 : NNTPconfigUI( parent, name, modal, flags ) 570 : NNTPconfigUI( parent, name, modal, flags )
567{ 571{
568 data = account; 572 data = account;
569 573
570 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 574 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
571 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 575 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
572 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); 576 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) );
573 connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) ); 577 connect( ShowSubcribed, SIGNAL( clicked() ), this, SLOT( slotShowSub() ) );
574 connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) ); 578 connect( FilterButton, SIGNAL( clicked() ), this, SLOT( slotShowFilter() ) );
575 fillValues(); 579 fillValues();
576 580
577 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); 581 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) );
578} 582}
579 583
580void NNTPconfig::slotShowSub() 584void NNTPconfig::slotShowSub()
581{ 585{
582 save(); 586 save();
583 data->save(); 587 data->save();
584 ListViewGroups->clear(); 588 ListViewGroups->clear();
585 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { 589 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
586 QCheckListItem *item; 590 QCheckListItem *item;
587 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 591 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
588 item->setOn( true ); 592 item->setOn( true );
589 } 593 }
590 topLevelWidget()->setCaption( i18n("%1 groups subscribed").arg( subscribedGroups.count())); 594 topLevelWidget()->setCaption( i18n("%1 groups subscribed").arg( subscribedGroups.count()));
591} 595}
592void NNTPconfig::slotShowFilter() 596void NNTPconfig::slotShowFilter()
593{ 597{
594 save(); 598 save();
595 data->save(); 599 data->save();
596 ListViewGroups->clear(); 600 ListViewGroups->clear();
597 int count = 0; 601 int count = 0;
598 for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { 602 for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) {
599 QCheckListItem *item; 603 QCheckListItem *item;
600 if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) { 604 if ( GroupFilter->text().isEmpty() || (*it).find( GroupFilter->text() ) >= 0 ) {
601 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 605 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
602 ++count; 606 ++count;
603 if ( subscribedGroups.contains( (*it) ) >= 1 ) { 607 if ( subscribedGroups.contains( (*it) ) >= 1 ) {
604 item->setOn( true ); 608 item->setOn( true );
605 } 609 }
606 } 610 }
607 } 611 }
608 topLevelWidget()->setCaption( i18n("Filter found %1 groups").arg( count)); 612 topLevelWidget()->setCaption( i18n("Filter found %1 groups").arg( count));
609} 613}
610void NNTPconfig::slotGetNG() { 614void NNTPconfig::slotGetNG() {
611 save(); 615 save();
612 data->save(); 616 data->save();
613 topLevelWidget()->setCaption( i18n("Fetching group list...")); 617 topLevelWidget()->setCaption( i18n("Fetching group list..."));
614 qApp->processEvents(); 618 qApp->processEvents();
615 NNTPwrapper* tmp = new NNTPwrapper( data ); 619 NNTPwrapper* tmp = new NNTPwrapper( data );
616 allGroups = tmp->listAllNewsgroups(); 620 allGroups = tmp->listAllNewsgroups();
617 topLevelWidget()->setCaption( i18n("Downloaded %1 group names").arg( allGroups.count())); 621 topLevelWidget()->setCaption( i18n("Downloaded %1 group names").arg( allGroups.count()));
618 622
619 ListViewGroups->clear(); 623 ListViewGroups->clear();
620 624
621 for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) { 625 for ( QStringList::Iterator it = allGroups.begin(); it != allGroups.end(); ++it ) {
622 QCheckListItem *item; 626 QCheckListItem *item;
623 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 627 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
624 if ( subscribedGroups.contains( (*it) ) >= 1 ) { 628 if ( subscribedGroups.contains( (*it) ) >= 1 ) {
625 item->setOn( true ); 629 item->setOn( true );
626 630
627 } 631 }
628 } 632 }
629 delete tmp; 633 delete tmp;
630} 634}
631 635
632void NNTPconfig::slotSSL( bool enabled ) 636void NNTPconfig::slotSSL( bool enabled )
633{ 637{
634 if ( enabled ) 638 if ( enabled )
635 { 639 {
636 portLine->setText( NNTP_SSL_PORT ); 640 portLine->setText( NNTP_SSL_PORT );
637 } 641 }
638 else 642 else
639 { 643 {
640 portLine->setText( NNTP_PORT ); 644 portLine->setText( NNTP_PORT );
641 } 645 }
642} 646}
643 647
644void NNTPconfig::fillValues() 648void NNTPconfig::fillValues()
645{ 649{
646 accountLine->setText( data->getAccountName() ); 650 accountLine->setText( data->getAccountName() );
647 serverLine->setText( data->getServer() ); 651 serverLine->setText( data->getServer() );
648 portLine->setText( data->getPort() ); 652 portLine->setText( data->getPort() );
649 sslBox->setChecked( data->getSSL() ); 653 sslBox->setChecked( data->getSSL() );
650 loginBox->setChecked( data->getLogin() ); 654 loginBox->setChecked( data->getLogin() );
651 userLine->setText( data->getUser() ); 655 userLine->setText( data->getUser() );
652 passLine->setText( data->getPassword() ); 656 passLine->setText( data->getPassword() );
653 subscribedGroups = data->getGroups(); 657 subscribedGroups = data->getGroups();
654 /* don't forget that - you will overwrite values if user clicks cancel! */ 658 /* don't forget that - you will overwrite values if user clicks cancel! */
655 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { 659 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
656 QCheckListItem *item; 660 QCheckListItem *item;
657 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 661 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
658 item->setOn( true ); 662 item->setOn( true );
659 } 663 }
660} 664}
661 665
662void NNTPconfig::save() 666void NNTPconfig::save()
663{ 667{
664 data->setAccountName( accountLine->text() ); 668 data->setAccountName( accountLine->text() );
665 data->setServer( serverLine->text() ); 669 data->setServer( serverLine->text() );
666 data->setPort( portLine->text() ); 670 data->setPort( portLine->text() );
667 data->setSSL( sslBox->isChecked() ); 671 data->setSSL( sslBox->isChecked() );
668 data->setLogin( loginBox->isChecked() ); 672 data->setLogin( loginBox->isChecked() );
669 data->setUser( userLine->text() ); 673 data->setUser( userLine->text() );
670 data->setPassword( passLine->text() ); 674 data->setPassword( passLine->text() );
671 675
672 QListViewItemIterator list_it( ListViewGroups ); 676 QListViewItemIterator list_it( ListViewGroups );
673 677
674 for ( ; list_it.current(); ++list_it ) { 678 for ( ; list_it.current(); ++list_it ) {
675 679
676 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { 680 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) {
677 if ( subscribedGroups.contains( list_it.current()->text(0) ) < 1 ) 681 if ( subscribedGroups.contains( list_it.current()->text(0) ) < 1 )
678 subscribedGroups.append( list_it.current()->text(0) ); 682 subscribedGroups.append( list_it.current()->text(0) );
679 } else { 683 } else {
680 if ( subscribedGroups.contains( list_it.current()->text(0) ) >= 1 ) 684 if ( subscribedGroups.contains( list_it.current()->text(0) ) >= 1 )
681 subscribedGroups.remove( list_it.current()->text(0) ); 685 subscribedGroups.remove( list_it.current()->text(0) );
682 } 686 }
683 687
684 } 688 }
685 data->setGroups( subscribedGroups ); 689 data->setGroups( subscribedGroups );
686} 690}
687 691
688void NNTPconfig::accept() 692void NNTPconfig::accept()
689{ 693{
690 save(); 694 save();
691 QDialog::accept(); 695 QDialog::accept();
692} 696}
693 697