Logo Search packages:      
Sourcecode: kmess version File versions  Download package

void AccountPage::saveSettings ( Account account  ) 

Save the settings in the account object.

Definition at line 294 of file accountpage.cpp.

References Account::getFriendlyName(), Account::getPassword(), Account::getSavePassword(), Account::isGuestAccount(), Account::isVerified(), Account::setGuestAccount(), Account::setInitialStatus(), Account::setLoginInformation(), Account::setOriginalPicturePath(), Account::setPicturePath(), Account::setSavePassword(), Account::setShowPicture(), Account::setStatusOptions(), Account::setUseAutologin(), STATUS_AWAY, STATUS_BE_RIGHT_BACK, STATUS_BUSY, STATUS_INVISIBLE, STATUS_ON_THE_PHONE, and STATUS_OUT_TO_LUNCH.

{
  QString password;
  QString pictureName;
  Status  initialStatus;
  QString newFriendlyName;
  QDir    pictureFolder;
  bool    showPicture;

  // Read settings
  showPicture = ! noPictureCheckbox_->isChecked();

  // Update the picture if we have one. This is done before changing the handle, so the new picture is saved at the old account dir
  // and can be moved to the new one easily
  if( hasTempPicture_ )
  {
    if( ! showPicture )
    {
      // The temporary file is no longer needed.
      QFile::remove( tempPictureFile_ );
      hasTempPicture_ = false;

      // Leaving variable 'pictureName' empty, which means no image is selected
    }
    else
    {
      // Retrieve the picture's hash
      QString msnObjectHash( KMessShared::generateFileHash( tempPictureFile_ ).toBase64() );
      const QString safeMsnObjectHash( msnObjectHash.replace( QRegExp("[^a-zA-Z0-9+=]"), "_" ) );

      // Save the new display picture with its hash as name, to ensure correct caching
      pictureName = msnObjectHash + ".png";
      pictureFolder = QDir( pictureDir_ );

      // Do not overwrite identical pictures
      if( ! pictureFolder.exists( pictureName ) )
      {
        if( pictureFolder.rename( tempPictureFile_, pictureName ) )
        {
          // The temp picture has now its final name, nothing is left to be removed
          hasTempPicture_ = false;
        }
        else
        {
          kWarning() << "The display picture file could not be renamed from" << tempPictureFile_ << "to" << pictureName << ".";
        }
      }
    }

    // Set the new picture
    account->setPicturePath( pictureDir_ + pictureName );
  }

  // Save path to the display picture original
  account->setOriginalPicturePath( originalPicturePath_ );

  // When the account is a guest account, see if the user wanted to "upgrade" it.

  if( account->isGuestAccount() )
  {
    if( rememberCheckbox_->isChecked() )
    {
      account->setGuestAccount(false);
    }
  }

  // If the account is not verified, don't change the nickname.
  if( ! account->isVerified() )
  {
    newFriendlyName = account->getFriendlyName( STRING_ORIGINAL );
  }
  else
  {
    newFriendlyName = friendlyNameEdit_->text();
  }

  // Update the settings
  account->setLoginInformation( handleEdit_->text(), newFriendlyName, passwordEdit_->text() );
  // Switch option "remember password" to true only if also the password is not empty
  account->setSavePassword( rememberPasswordCheckBox_->isChecked() && ! account->getPassword().isEmpty() );
  // Switch option "autologin" to true only if the option "save password" is true
  account->setUseAutologin( autologinCheckBox_->isChecked() && account->getSavePassword() );
  account->setShowPicture( showPicture );

  // Update the initial status
  switch( initialStatus_->currentIndex() )
  {
    case 1:  initialStatus = STATUS_AWAY;          break;
    case 2:  initialStatus = STATUS_BE_RIGHT_BACK; break;
    case 3:  initialStatus = STATUS_BUSY;          break;
    case 6:  initialStatus = STATUS_INVISIBLE;     break;
    case 5:  initialStatus = STATUS_ON_THE_PHONE;  break;
    case 4:  initialStatus = STATUS_OUT_TO_LUNCH;  break;
    case 0:
    default: initialStatus = STATUS_ONLINE;        break;
  }
  account->setInitialStatus( initialStatus );

  account->setStatusOptions( useIdleTimerCheckBox_->isChecked(), idleTimeSpinBox_->value(),
                             hideNotificationsWhenBusyCheckBox_->isChecked() );
}


Generated by  Doxygen 1.6.0   Back to index