[Libreoffice-commits] core.git: Branch 'feature/gsoc15-open-remote-files-dialog' - fpicker/source include/svtools svtools/source svtools/uiconfig
Szymon Kłos
eszkadev at gmail.com
Wed Aug 26 04:51:26 PDT 2015
fpicker/source/office/RemoteFilesDialog.cxx | 19 ++++++++----
fpicker/source/office/RemoteFilesDialog.hxx | 3 +
include/svtools/PlaceEditDialog.hxx | 2 -
include/svtools/ServerDetailsControls.hxx | 8 +++--
svtools/source/dialogs/PlaceEditDialog.cxx | 32 +++-----------------
svtools/source/dialogs/ServerDetailsControls.cxx | 36 +++++++++++++++++++++++
svtools/uiconfig/ui/placeedit.ui | 6 +--
7 files changed, 67 insertions(+), 39 deletions(-)
New commits:
commit d56cd3ae41b095185f05e3081379f4de2cbe0bfb
Author: Szymon Kłos <eszkadev at gmail.com>
Date: Wed Aug 26 13:48:59 2015 +0200
remember password for all types of service
Change-Id: I8620332ac5228eee1d7c16d0b0ff7920031be331
diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx
index dfc14e1..54c986a 100644
--- a/fpicker/source/office/RemoteFilesDialog.cxx
+++ b/fpicker/source/office/RemoteFilesDialog.cxx
@@ -687,11 +687,16 @@ void RemoteFilesDialog::DisableControls()
m_pCancel_btn->Enable( true );
}
-void RemoteFilesDialog::SavePassword( const OUString& rURL, const OUString& rUser, const OUString& rPassword )
+void RemoteFilesDialog::SavePassword( const OUString& rURL, const OUString& rUser
+ , const OUString& rPassword, bool bPersistent )
{
+ if( rURL.isEmpty() || rUser.isEmpty() || rPassword.isEmpty() )
+ return;
+
try
{
- if( m_xMasterPasswd->isPersistentStoringAllowed() && m_xMasterPasswd->authorizateWithMasterPassword( Reference< XInteractionHandler>() ) )
+ if( m_xMasterPasswd->isPersistentStoringAllowed() &&
+ ( !bPersistent || m_xMasterPasswd->authorizateWithMasterPassword( Reference< XInteractionHandler>() ) ) )
{
Reference< XInteractionHandler > xInteractionHandler(
InteractionHandler::createWithParent( m_xContext, 0 ),
@@ -700,8 +705,11 @@ void RemoteFilesDialog::SavePassword( const OUString& rURL, const OUString& rUse
Sequence< OUString > aPasswd( 1 );
aPasswd[0] = rPassword;
- m_xMasterPasswd->addPersistent(
- rURL, rUser, aPasswd, xInteractionHandler );
+ if( bPersistent )
+ m_xMasterPasswd->addPersistent(
+ rURL, rUser, aPasswd, xInteractionHandler );
+ else
+ m_xMasterPasswd->add( rURL, rUser, aPasswd, xInteractionHandler );
}
}
catch( const Exception& )
@@ -725,7 +733,8 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl )
OUString sUser = aDlg->GetUser();
if( !sUser.isEmpty() && !sPassword.isEmpty() )
{
- SavePassword( newService->GetUrl(), sUser, sPassword );
+ bool bPersistent = aDlg->IsRememberChecked();
+ SavePassword( newService->GetUrl(), sUser, sPassword, bPersistent );
}
OUString sPrefix = lcl_GetServiceType( newService );
diff --git a/fpicker/source/office/RemoteFilesDialog.hxx b/fpicker/source/office/RemoteFilesDialog.hxx
index d00191b..98c0d53 100644
--- a/fpicker/source/office/RemoteFilesDialog.hxx
+++ b/fpicker/source/office/RemoteFilesDialog.hxx
@@ -182,7 +182,8 @@ private:
void EnableControls();
void DisableControls();
- void SavePassword( const OUString& rURL, const OUString& rUser, const OUString& rPassword );
+ void SavePassword( const OUString& rURL, const OUString& rUser
+ , const OUString& rPassword, bool bPersistent );
DECL_LINK ( AddServiceHdl, void * );
DECL_LINK ( SelectServiceHdl, void * );
diff --git a/include/svtools/PlaceEditDialog.hxx b/include/svtools/PlaceEditDialog.hxx
index c15735e..1b7126a 100644
--- a/include/svtools/PlaceEditDialog.hxx
+++ b/include/svtools/PlaceEditDialog.hxx
@@ -73,6 +73,7 @@ public :
OUString GetServerUrl();
OUString GetPassword() { return m_pEDPassword->GetText(); };
OUString GetUser() { return m_pEDUsername->GetText(); };
+ bool IsRememberChecked() { return m_pCBPassword->IsChecked(); }
void ShowPasswordControl( bool bShow = true ) { m_bShowPassword = bShow; }
@@ -87,7 +88,6 @@ private:
DECL_LINK ( SelectTypeHdl, void * );
DECL_LINK ( EditLabelHdl, void * );
DECL_LINK ( EditUsernameHdl, void * );
- DECL_LINK ( ToggledPassHdl, CheckBox * pCheckBox );
};
diff --git a/include/svtools/ServerDetailsControls.hxx b/include/svtools/ServerDetailsControls.hxx
index 691f528..aa57f11 100644
--- a/include/svtools/ServerDetailsControls.hxx
+++ b/include/svtools/ServerDetailsControls.hxx
@@ -12,6 +12,8 @@
#include <map>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <com/sun/star/task/PasswordContainer.hpp>
+#include <com/sun/star/task/XPasswordContainer2.hpp>
#include <tools/urlobj.hxx>
#include <vcl/builder.hxx>
@@ -53,11 +55,10 @@ class DetailsContainer
virtual bool setUrl( const INetURLObject& rUrl );
virtual void setUsername( const OUString& /*rUsername*/ ) { };
+ virtual void setPassword( const OUString& ) { };
virtual void setActive( bool bActive = true );
- virtual bool hasPassEntry() { return true; }
-
protected:
void notifyChange( );
DECL_LINK ( ValueChangeHdl, void * );
@@ -124,6 +125,7 @@ class CmisDetailsContainer : public DetailsContainer
{
private:
OUString m_sUsername;
+ OUString m_sPassword;
com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xCmdEnv;
std::vector< OUString > m_aRepoIds;
OUString m_sRepoId;
@@ -142,7 +144,7 @@ class CmisDetailsContainer : public DetailsContainer
virtual INetURLObject getUrl( ) SAL_OVERRIDE;
virtual bool setUrl( const INetURLObject& rUrl ) SAL_OVERRIDE;
virtual void setUsername( const OUString& rUsername ) SAL_OVERRIDE;
- virtual bool hasPassEntry() SAL_OVERRIDE { return false; }
+ virtual void setPassword( const OUString& rPass ) SAL_OVERRIDE;
private:
void selectRepository( );
diff --git a/svtools/source/dialogs/PlaceEditDialog.cxx b/svtools/source/dialogs/PlaceEditDialog.cxx
index 77526de..0f9f99e 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
@@ -320,6 +302,7 @@ IMPL_LINK_NOARG( PlaceEditDialog, EditUsernameHdl )
it != m_aDetailsContainers.end( ); ++it )
{
( *it )->setUsername( OUString( m_pEDUsername->GetText() ) );
+ ( *it )->setPassword( m_pEDPassword->GetText() );
}
EditHdl(NULL);
@@ -348,12 +331,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 ad4750e..2fb20df 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( CmisDetailsContainer, RefreshReposHdl )
{
+ 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( CmisDetailsContainer, RefreshReposHdl )
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 );
@@ -457,6 +485,14 @@ IMPL_LINK_NOARG( CmisDetailsContainer, RefreshReposHdl )
selectRepository( );
}
+ // remove temporary password
+ try
+ {
+ xMasterPasswd->remove( sUrl, m_sUsername );
+ }
+ catch( const Exception& )
+ {}
+
return 0;
}
diff --git a/svtools/uiconfig/ui/placeedit.ui b/svtools/uiconfig/ui/placeedit.ui
index 8f4e0e5..e3c0d3c 100644
--- a/svtools/uiconfig/ui/placeedit.ui
+++ b/svtools/uiconfig/ui/placeedit.ui
@@ -416,7 +416,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -428,7 +428,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">4</property>
</packing>
</child>
<child>
@@ -442,7 +442,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
</packing>
</child>
<child>
More information about the Libreoffice-commits
mailing list