[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Re: Kmail crashes by modifying a pop Account without a name
From:       Espen Sand <espen.sand () neo ! no>
Date:       2000-10-30 8:05:41
[Download RAW message or body]

On Sun, 29 Oct 2000, George Staikos wrote:
> On Friday 27 October 2000 11:22, Johannes Pohl wrote:
> > Kmail crashes if you want to modify an Pop Account where the name field was
> > left blank.
> 
>   Confirmed - it's crashing in QMap::clear().  I'm thinking it would be a 
> good idea to require a name >= 1 character for this too.

hi,

I think the code below should not be used until the crash reason is removed.
We should  make the core more robust first instead of just hiding the problem I
think. The general problem is that it is quite difficult to hide a problem 100%.

Anyway here is the fix when saving pop account data. I only have a kde-20 branch
at the moment (f* up my head branch) and I can't commit it because of the new
message strings I added. Add it to the head version if you like but I think 
(as I said above) it is not the best to do in the long run. What should we do
if one want to modify an accout that contains an empty name (because someone
has manually edited the kmailrc file) ? ....

(ps: the saveSettings() must be modified in "accountdialog.h"  as well. It did
not return bool before this fix)

void AccountDialog::slotOk()
{
  if( saveSettings() )
  {
    accept();
  }
}


bool AccountDialog::saveSettings()
{
  QString accountType = mAccount->type();
  if( accountType == "local" )
  {
    //
    // The system can not handle empty name strings (espen 2000-10-30)
    //
    QString name = mLocal.nameEdit->text().stripWhiteSpace();
    if( name.isEmpty() )
    {
      QString msg = i18n("You must specify an account name");
      KMessageBox::information( topLevelWidget(), msg, i18n("Save Account") );
      return false;
    }

    mAccount->setName( name );
    ((KMAcctLocal*)mAccount)->setLocation( mLocal.locationEdit->text() );
    mAccount->setCheckInterval( mLocal.intervalCheck->isChecked() ? 
			     mLocal.intervalSpin->value() : 0 );
    mAccount->setCheckExclude( mLocal.excludeCheck->isChecked() );
 
    mAccount->setPrecommand( mLocal.precommand->text() );

    KMFolder *folder 
      = kernel->folderMgr()->find( mLocal.folderCombo->currentText() );
    mAccount->setFolder( folder );

  }
  else if( accountType == "pop" )
  {
    //
    // The system can not handle empty name strings (espen 2000-10-30)
    //
    QString name = mPop.nameEdit->text().stripWhiteSpace();
    if( name.isEmpty() )
    {
      QString msg = i18n("You must specify an account name");
      KMessageBox::information( topLevelWidget(), msg, i18n("Save Account") );
      return false;
    }

    mAccount->setName( name );
    mAccount->setCheckInterval( mPop.intervalCheck->isChecked() ? 
			     mPop.intervalSpin->value() : 0 );
    mAccount->setCheckExclude( mPop.excludeCheck->isChecked() );

    KMFolder *folder 
      = kernel->folderMgr()->find( mPop.folderCombo->currentText() );
    mAccount->setFolder( folder );
    
    KMAcctExpPop &epa = *(KMAcctExpPop*)mAccount;
    epa.setHost( mPop.hostEdit->text() );
    epa.setPort( mPop.portEdit->text().toInt() );
    epa.setLogin( mPop.loginEdit->text() );
    epa.setPasswd( mPop.passwordEdit->text(), true );
    epa.setUseSSL( mPop.useSSLCheck->isChecked() );
    epa.setStorePasswd( mPop.storePasswordCheck->isChecked() );
    epa.setPasswd( mPop.passwordEdit->text(), epa.storePasswd() );
    epa.setLeaveOnServer( !mPop.deleteMailCheck->isChecked() );
    epa.setRetrieveAll( mPop.retriveAllCheck->isChecked() ); 
    epa.setPrecommand( mPop.precommand->text() );

  }
  kernel->acctMgr()->writeConfig(TRUE);
  return true;
}



-- 
Espen Sand

_______________________________________________
Kmail Developers mailing list
Kmail@master.kde.org
http://master.kde.org/mailman/listinfo/kmail

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic