[Libreoffice-commits] core.git: Branch 'feature/gsoc15-open-remote-files-dialog' - fpicker/source include/svtools

Szymon Kłos eszkadev at gmail.com
Tue Aug 11 03:23:10 PDT 2015


 fpicker/source/office/RemoteFilesDialog.cxx |   32 +++++++++++++++++++++++++---
 fpicker/source/office/RemoteFilesDialog.hxx |    2 +
 include/svtools/PlaceEditDialog.hxx         |    1 
 3 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit a1981e60691c61b726ab4791503e0d716e0ef66a
Author: Szymon Kłos <eszkadev at gmail.com>
Date:   Tue Aug 11 11:26:24 2015 +0200

    store password for service if filled
    
    Change-Id: I99ce30516a3d8859c060c8e85f8f8ea5e5217d61

diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx
index 6cf9994..98ef36f 100644
--- a/fpicker/source/office/RemoteFilesDialog.cxx
+++ b/fpicker/source/office/RemoteFilesDialog.cxx
@@ -650,6 +650,27 @@ void RemoteFilesDialog::DisableControls()
     m_pCancel_btn->Enable( true );
 }
 
+void RemoteFilesDialog::SavePassword( const OUString& rURL, const OUString& rUser, const OUString& rPassword )
+{
+    try
+    {
+        if( m_xMasterPasswd->isPersistentStoringAllowed() && m_xMasterPasswd->authorizateWithMasterPassword( Reference< XInteractionHandler>() ) )
+        {
+            Reference< XInteractionHandler > xInteractionHandler(
+                InteractionHandler::createWithParent( m_xContext, 0 ),
+                UNO_QUERY );
+
+            Sequence< OUString > aPasswd( 1 );
+            aPasswd[0] = rPassword;
+
+            m_xMasterPasswd->addPersistent(
+                rURL, rUser, aPasswd, xInteractionHandler );
+        }
+    }
+    catch( const Exception& )
+    {}
+}
+
 IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl )
 {
     ScopedVclPtrInstance< PlaceEditDialog > aDlg( this );
@@ -663,6 +684,13 @@ IMPL_LINK_NOARG ( RemoteFilesDialog, AddServiceHdl )
             ServicePtr newService = aDlg->GetPlace();
             m_aServices.push_back( newService );
 
+            OUString sPassword = aDlg->GetPassword();
+            OUString sUser = aDlg->GetUser();
+            if( !sUser.isEmpty() && !sPassword.isEmpty() )
+            {
+                SavePassword( newService->GetUrl(), sUser, sPassword );
+            }
+
             OUString sPrefix = lcl_GetServiceType( newService );
 
             if(!sPrefix.isEmpty())
@@ -803,9 +831,7 @@ IMPL_LINK_TYPED ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton,
                             Sequence< OUString > aPasswd( 1 );
                             aPasswd[0] = aNewPass;
 
-                            Reference< XPasswordContainer2 > xPasswdContainer(
-                                PasswordContainer::create( m_xContext ) );
-                            xPasswdContainer->addPersistent(
+                            m_xMasterPasswd->addPersistent(
                                 sUrl, sUserName, aPasswd, xInteractionHandler );
                         }
                     }
diff --git a/fpicker/source/office/RemoteFilesDialog.hxx b/fpicker/source/office/RemoteFilesDialog.hxx
index f35d64c..4fe1188 100644
--- a/fpicker/source/office/RemoteFilesDialog.hxx
+++ b/fpicker/source/office/RemoteFilesDialog.hxx
@@ -178,6 +178,8 @@ private:
     void EnableControls();
     void DisableControls();
 
+    void SavePassword( const OUString& rURL, const OUString& rUser, const OUString& rPassword );
+
     DECL_LINK ( AddServiceHdl, void * );
     DECL_LINK ( SelectServiceHdl, void * );
     DECL_LINK_TYPED ( EditServiceMenuHdl, MenuButton *, void );
diff --git a/include/svtools/PlaceEditDialog.hxx b/include/svtools/PlaceEditDialog.hxx
index cfcfe67..79ec348 100644
--- a/include/svtools/PlaceEditDialog.hxx
+++ b/include/svtools/PlaceEditDialog.hxx
@@ -70,6 +70,7 @@ public :
      OUString GetServerName() { return m_pEDServerName->GetText(); }
      OUString GetServerUrl();
      OUString GetPassword() { return m_pEDPassword->GetText(); };
+     OUString GetUser() { return m_pEDUsername->GetText(); };
 
      void ShowPasswordControl( bool bShow = true ) { m_pEDPassword->Show( bShow ); m_pFTPasswordLabel->Show( bShow ); }
 


More information about the Libreoffice-commits mailing list