diff options
author | Szymon Kłos <eszkadev@gmail.com> | 2015-08-10 14:15:59 +0200 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2015-08-14 08:45:43 +0200 |
commit | bd277973b2e3e467b665e30c0ba56ad372d3d233 (patch) | |
tree | 257abdc5224a8b0b0c516561eae8a7bbaee10dc0 /fpicker | |
parent | 0ab1f6a024651d09b619c2864cee1ecc0c7968db (diff) |
Show 'change password' only if is password is stored
Change-Id: I04275d2e45ff32ed003a2487cd87500d550e9d73
Diffstat (limited to 'fpicker')
-rw-r--r-- | fpicker/source/office/RemoteFilesDialog.cxx | 69 |
1 files changed, 49 insertions, 20 deletions
diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx index c90175d10855..7b90ae07b8ae 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 ); } } } |