diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2015-08-26 13:48:59 +0200 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2015-08-29 12:33:20 +0200 |
commit | 51c3a6421ecdb3443121c26e3bdeb21b07bd1fd8 (patch) | |
tree | cd68488980d4da4f0fc9f4c8099c0534dd9a1e86 /svtools/source/dialogs | |
parent | c879fa8e5fd7779ca242fe368cbdd70084df049b (diff) |
remember password for all types of service
Change-Id: I8620332ac5228eee1d7c16d0b0ff7920031be331
Diffstat (limited to 'svtools/source/dialogs')
-rw-r--r-- | svtools/source/dialogs/PlaceEditDialog.cxx | 32 | ||||
-rw-r--r-- | svtools/source/dialogs/ServerDetailsControls.cxx | 36 |
2 files changed, 42 insertions, 26 deletions
diff --git a/svtools/source/dialogs/PlaceEditDialog.cxx b/svtools/source/dialogs/PlaceEditDialog.cxx index b244494fbfda..68e5741be0bf 100644 --- a/svtools/source/dialogs/PlaceEditDialog.cxx +++ b/svtools/source/dialogs/PlaceEditDialog.cxx @@ -23,7 +23,7 @@ PlaceEditDialog::PlaceEditDialog(vcl::Window* pParent) , m_xCurrentDetails() , m_nCurrentType( 0 ) , bLabelChanged( false ) - , m_bShowPassword( false ) + , m_bShowPassword( true ) { get( m_pEDServerName, "name" ); get( m_pLBServerType, "type" ); @@ -36,11 +36,6 @@ PlaceEditDialog::PlaceEditDialog(vcl::Window* pParent) get( m_pEDPassword, "password" ); get( m_pFTPasswordLabel, "passwordLabel" ); - m_pEDPassword->Hide(); - m_pFTPasswordLabel->Hide(); - m_pCBPassword->Hide(); - m_pCBPassword->SetToggleHdl( LINK( this, PlaceEditDialog, ToggledPassHdl ) ); - m_pBTOk->SetClickHdl( LINK( this, PlaceEditDialog, OKHdl) ); m_pBTOk->Enable( false ); @@ -52,6 +47,7 @@ PlaceEditDialog::PlaceEditDialog(vcl::Window* pParent) m_pLBServerType->SetSelectHdl( LINK( this, PlaceEditDialog, SelectTypeHdl ) ); m_pEDUsername->SetModifyHdl( LINK( this, PlaceEditDialog, EditUsernameHdl ) ); + m_pEDPassword->SetModifyHdl( LINK( this, PlaceEditDialog, EditUsernameHdl ) ); InitDetails( ); } @@ -76,7 +72,6 @@ PlaceEditDialog::PlaceEditDialog(vcl::Window* pParent, const std::shared_ptr<Pla m_pEDPassword->Hide(); m_pFTPasswordLabel->Hide(); m_pCBPassword->Hide(); - m_pCBPassword->SetToggleHdl( LINK( this, PlaceEditDialog, ToggledPassHdl ) ); m_pBTOk->SetClickHdl( LINK( this, PlaceEditDialog, OKHdl) ); m_pBTDelete->SetClickHdl ( LINK( this, PlaceEditDialog, DelHdl) ); @@ -149,19 +144,6 @@ std::shared_ptr<Place> PlaceEditDialog::GetPlace() return std::make_shared<Place>(m_pEDServerName->GetText(), GetServerUrl(), true); } -IMPL_LINK( PlaceEditDialog, ToggledPassHdl, CheckBox*, pCheckBox ) -{ - bool bChecked = pCheckBox->IsEnabled() && pCheckBox->IsChecked(); - - m_pEDPassword->Enable( bChecked ); - m_pFTPasswordLabel->Enable( bChecked ); - - if ( !bChecked ) - m_pEDPassword->SetText( "" ); - - return 0; -} - void PlaceEditDialog::InitDetails( ) { // Create CMIS controls for each server type @@ -322,6 +304,7 @@ IMPL_LINK_NOARG( PlaceEditDialog, EditUsernameHdl ) it != m_aDetailsContainers.end( ); ++it ) { ( *it )->setUsername( OUString( m_pEDUsername->GetText() ) ); + ( *it )->setPassword( m_pEDPassword->GetText() ); } EditHdl(NULL); @@ -350,12 +333,9 @@ IMPL_LINK_NOARG( PlaceEditDialog, SelectTypeHdl ) m_xCurrentDetails->show(); - bool bShowPass = m_xCurrentDetails->hasPassEntry(); - m_pCBPassword->Show( bShowPass ); - m_pEDPassword->Show( bShowPass ); - m_pFTPasswordLabel->Show( bShowPass ); - - ToggledPassHdl( m_pCBPassword ); + m_pCBPassword->Show( m_bShowPassword ); + m_pEDPassword->Show( m_bShowPassword ); + m_pFTPasswordLabel->Show( m_bShowPassword ); SetSizePixel(GetOptimalSize()); diff --git a/svtools/source/dialogs/ServerDetailsControls.cxx b/svtools/source/dialogs/ServerDetailsControls.cxx index 96da5918c740..5b5f0832ce88 100644 --- a/svtools/source/dialogs/ServerDetailsControls.cxx +++ b/svtools/source/dialogs/ServerDetailsControls.cxx @@ -382,6 +382,11 @@ void CmisDetailsContainer::setUsername( const OUString& rUsername ) m_sUsername = rUsername; } +void CmisDetailsContainer::setPassword( const OUString& rPass ) +{ + m_sPassword = rPass; +} + void CmisDetailsContainer::selectRepository( ) { // Get the repo ID and call the Change listener @@ -395,6 +400,10 @@ void CmisDetailsContainer::selectRepository( ) IMPL_LINK_NOARG_TYPED( CmisDetailsContainer, RefreshReposHdl, Button*, void ) { + Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + Reference< XPasswordContainer2 > xMasterPasswd = PasswordContainer::create( xContext ); + + OUString sBindingUrl = m_pEDHost->GetText().trim( ); OUString sEncodedUsername = ""; @@ -424,6 +433,25 @@ IMPL_LINK_NOARG_TYPED( CmisDetailsContainer, RefreshReposHdl, Button*, void ) sUrl = "vnd.libreoffice.cmis://" + sEncodedUsername + sEncodedBinding; } + // temporary remember the password + try + { + if( xMasterPasswd->isPersistentStoringAllowed() && !sUrl.isEmpty() && !m_sUsername.isEmpty() && !m_sPassword.isEmpty() ) + { + Reference< XInteractionHandler > xInteractionHandler( + InteractionHandler::createWithParent( xContext, 0 ), + UNO_QUERY ); + + Sequence< OUString > aPasswd( 1 ); + aPasswd[0] = m_sPassword; + + xMasterPasswd->add( + sUrl, m_sUsername, aPasswd, xInteractionHandler ); + } + } + catch( const Exception& ) + {} + // Get the Content ::ucbhelper::Content aCnt( sUrl, m_xCmdEnv, comphelper::getProcessComponentContext() ); Sequence< OUString > aProps( 1 ); @@ -456,6 +484,14 @@ IMPL_LINK_NOARG_TYPED( CmisDetailsContainer, RefreshReposHdl, Button*, void ) m_pLBRepository->SelectEntryPos( 0 ); selectRepository( ); } + + // remove temporary password + try + { + xMasterPasswd->remove( sUrl, m_sUsername ); + } + catch( const Exception& ) + {} } IMPL_LINK_NOARG( CmisDetailsContainer, SelectRepoHdl ) |