fpicker/source/office/RemoteFilesDialog.cxx | 69 +++++++++++++++++++--------- 1 file changed, 49 insertions(+), 20 deletions(-)
New commits: commit 48ed3e1f7b3b4f225166dbea6944c63785c0905e Author: Szymon KÅos <[email protected]> Date: Mon Aug 10 14:15:59 2015 +0200 Show 'change password' only if is password is stored Change-Id: I04275d2e45ff32ed003a2487cd87500d550e9d73 diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx index c90175d..7b90ae0 100644 --- a/fpicker/source/office/RemoteFilesDialog.cxx +++ b/fpicker/source/office/RemoteFilesDialog.cxx @@ -578,7 +578,39 @@ void RemoteFilesDialog::AddFileExtension() void RemoteFilesDialog::EnableControls() { if( m_pServices_lb->GetEntryCount() > 0 ) + { m_pServices_lb->Enable( true ); + + if( m_pServices_lb->GetSelectEntryCount() ) + { + m_pAddMenu->EnableItem( "change_password", false ); + + try + { + Reference< XPasswordContainer2 > xMasterPasswd( + PasswordContainer::create( comphelper::getProcessComponentContext() ) ); + + if( xMasterPasswd->isPersistentStoringAllowed() ) + { + int nPos = GetSelectedServicePos(); + + if( nPos >= 0 ) + { + OUString sUrl( m_aServices[nPos]->GetUrl() ); + + UrlRecord aURLEntries = xMasterPasswd->find( sUrl, Reference< XInteractionHandler>() ); + + if( aURLEntries.UserList.getLength() ) + { + m_pAddMenu->EnableItem( "change_password" ); + } + } + } + } + catch( const Exception& ) + {} + } + } else m_pServices_lb->Enable( false ); @@ -745,7 +777,7 @@ IMPL_LINK_TYPED ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton, Reference< XPasswordContainer2 > xMasterPasswd( PasswordContainer::create( comphelper::getProcessComponentContext() ) ); - if( xMasterPasswd->isPersistentStoringAllowed() ) + if( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->authorizateWithMasterPassword( Reference< XInteractionHandler>() ) ) { int nPos = GetSelectedServicePos(); @@ -759,29 +791,26 @@ IMPL_LINK_TYPED ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton, UrlRecord aURLEntries = xMasterPasswd->find( sUrl, xInteractionHandler ); - if( aURLEntries.Url == sUrl ) + if( aURLEntries.Url == sUrl && aURLEntries.UserList.getLength() ) { - if( aURLEntries.UserList.getLength() ) - { - OUString sUserName = aURLEntries.UserList[0].UserName; + OUString sUserName = aURLEntries.UserList[0].UserName; - ::comphelper::SimplePasswordRequest* pPasswordRequest - = new ::comphelper::SimplePasswordRequest( PasswordRequestMode_PASSWORD_CREATE ); - Reference< XInteractionRequest > rRequest( pPasswordRequest ); + ::comphelper::SimplePasswordRequest* pPasswordRequest + = new ::comphelper::SimplePasswordRequest( PasswordRequestMode_PASSWORD_CREATE ); + Reference< XInteractionRequest > rRequest( pPasswordRequest ); - xInteractionHandler->handle( rRequest ); + xInteractionHandler->handle( rRequest ); - if ( pPasswordRequest->isPassword() ) - { - OUString aNewPass = pPasswordRequest->getPassword(); - Sequence< OUString > aPasswd( 1 ); - aPasswd[0] = aNewPass; - - Reference< XPasswordContainer2 > xPasswdContainer( - PasswordContainer::create(comphelper::getProcessComponentContext())); - xPasswdContainer->addPersistent( - sUrl, sUserName, aPasswd, xInteractionHandler ); - } + if ( pPasswordRequest->isPassword() ) + { + OUString aNewPass = pPasswordRequest->getPassword(); + Sequence< OUString > aPasswd( 1 ); + aPasswd[0] = aNewPass; + + Reference< XPasswordContainer2 > xPasswdContainer( + PasswordContainer::create( comphelper::getProcessComponentContext() ) ); + xPasswdContainer->addPersistent( + sUrl, sUserName, aPasswd, xInteractionHandler ); } } }
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
