Kaydet (Commit) bd277973 authored tarafından Szymon Kłos's avatar Szymon Kłos

Show 'change password' only if is password is stored

Change-Id: I04275d2e45ff32ed003a2487cd87500d550e9d73
üst 0ab1f6a0
...@@ -578,7 +578,39 @@ void RemoteFilesDialog::AddFileExtension() ...@@ -578,7 +578,39 @@ void RemoteFilesDialog::AddFileExtension()
void RemoteFilesDialog::EnableControls() void RemoteFilesDialog::EnableControls()
{ {
if( m_pServices_lb->GetEntryCount() > 0 ) if( m_pServices_lb->GetEntryCount() > 0 )
{
m_pServices_lb->Enable( true ); 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 else
m_pServices_lb->Enable( false ); m_pServices_lb->Enable( false );
...@@ -745,7 +777,7 @@ IMPL_LINK_TYPED ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton, ...@@ -745,7 +777,7 @@ IMPL_LINK_TYPED ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton,
Reference< XPasswordContainer2 > xMasterPasswd( Reference< XPasswordContainer2 > xMasterPasswd(
PasswordContainer::create( comphelper::getProcessComponentContext() ) ); PasswordContainer::create( comphelper::getProcessComponentContext() ) );
if( xMasterPasswd->isPersistentStoringAllowed() ) if( xMasterPasswd->isPersistentStoringAllowed() && xMasterPasswd->authorizateWithMasterPassword( Reference< XInteractionHandler>() ) )
{ {
int nPos = GetSelectedServicePos(); int nPos = GetSelectedServicePos();
...@@ -759,29 +791,26 @@ IMPL_LINK_TYPED ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton, ...@@ -759,29 +791,26 @@ IMPL_LINK_TYPED ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton,
UrlRecord aURLEntries = xMasterPasswd->find( sUrl, xInteractionHandler ); 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 ::comphelper::SimplePasswordRequest* pPasswordRequest
= new ::comphelper::SimplePasswordRequest( PasswordRequestMode_PASSWORD_CREATE ); = new ::comphelper::SimplePasswordRequest( PasswordRequestMode_PASSWORD_CREATE );
Reference< XInteractionRequest > rRequest( pPasswordRequest ); Reference< XInteractionRequest > rRequest( pPasswordRequest );
xInteractionHandler->handle( rRequest ); xInteractionHandler->handle( rRequest );
if ( pPasswordRequest->isPassword() ) if ( pPasswordRequest->isPassword() )
{ {
OUString aNewPass = pPasswordRequest->getPassword(); OUString aNewPass = pPasswordRequest->getPassword();
Sequence< OUString > aPasswd( 1 ); Sequence< OUString > aPasswd( 1 );
aPasswd[0] = aNewPass; aPasswd[0] = aNewPass;
Reference< XPasswordContainer2 > xPasswdContainer( Reference< XPasswordContainer2 > xPasswdContainer(
PasswordContainer::create(comphelper::getProcessComponentContext())); PasswordContainer::create( comphelper::getProcessComponentContext() ) );
xPasswdContainer->addPersistent( xPasswdContainer->addPersistent(
sUrl, sUserName, aPasswd, xInteractionHandler ); sUrl, sUserName, aPasswd, xInteractionHandler );
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment