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

Szymon Kłos eszkadev at gmail.com
Mon Aug 10 04:51:05 PDT 2015


 fpicker/source/office/RemoteFilesDialog.cxx |   52 ++++++++++++++++++++++++++++
 fpicker/source/office/RemoteFilesDialog.hxx |    5 ++
 fpicker/uiconfig/ui/remotefilesdialog.ui    |    8 ++++
 3 files changed, 65 insertions(+)

New commits:
commit fcc8fd178d7f001ff75d602d98a365ab0851af16
Author: Szymon Kłos <eszkadev at gmail.com>
Date:   Mon Aug 10 13:49:18 2015 +0200

    added change password entry in the split button menu
    
    Change-Id: I68e76e346ec6d704c27fe6f4031453dd44dbc983

diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx
index a85c40d..c90175d 100644
--- a/fpicker/source/office/RemoteFilesDialog.cxx
+++ b/fpicker/source/office/RemoteFilesDialog.cxx
@@ -738,6 +738,58 @@ IMPL_LINK_TYPED ( RemoteFilesDialog, EditServiceMenuHdl, MenuButton *, pButton,
             }
         }
     }
+    else if( sIdent == "change_password" )
+    {
+        try
+        {
+            Reference< XPasswordContainer2 > xMasterPasswd(
+                PasswordContainer::create( comphelper::getProcessComponentContext() ) );
+
+            if( xMasterPasswd->isPersistentStoringAllowed() )
+            {
+                int nPos = GetSelectedServicePos();
+
+                if( nPos >= 0 )
+                {
+                    OUString sUrl( m_aServices[nPos]->GetUrl() );
+
+                    Reference< XInteractionHandler > xInteractionHandler(
+                        InteractionHandler::createWithParent( comphelper::getProcessComponentContext(), 0 ),
+                        UNO_QUERY );
+
+                    UrlRecord aURLEntries = xMasterPasswd->find( sUrl, xInteractionHandler );
+
+                    if( aURLEntries.Url == sUrl )
+                    {
+                        if( aURLEntries.UserList.getLength() )
+                        {
+                            OUString sUserName = aURLEntries.UserList[0].UserName;
+
+                            ::comphelper::SimplePasswordRequest* pPasswordRequest
+                                = new ::comphelper::SimplePasswordRequest( PasswordRequestMode_PASSWORD_CREATE );
+                            Reference< XInteractionRequest > rRequest( pPasswordRequest );
+
+                            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 );
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        catch( const Exception& )
+        {}
+    }
 
     EnableControls();
 }
diff --git a/fpicker/source/office/RemoteFilesDialog.hxx b/fpicker/source/office/RemoteFilesDialog.hxx
index a63bef3..740262a 100644
--- a/fpicker/source/office/RemoteFilesDialog.hxx
+++ b/fpicker/source/office/RemoteFilesDialog.hxx
@@ -10,6 +10,8 @@
 #ifndef INCLUDED_SVTOOLS_REMOTEFILESDIALOG_HXX
 #define INCLUDED_SVTOOLS_REMOTEFILESDIALOG_HXX
 
+#include <comphelper/docpasswordrequest.hxx>
+
 #include <svtools/foldertree.hxx>
 #include <svtools/place.hxx>
 #include <svtools/PlaceEditDialog.hxx>
@@ -32,6 +34,8 @@
 #include <officecfg/Office/Common.hxx>
 #include <com/sun/star/beans/StringPair.hpp>
 #include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/task/PasswordContainer.hpp>
+#include <com/sun/star/task/XPasswordContainer2.hpp>
 
 #include <vector>
 
@@ -42,6 +46,7 @@
 #include "iodlg.hrc"
 
 using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::task;
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::ui::dialogs;
 
diff --git a/fpicker/uiconfig/ui/remotefilesdialog.ui b/fpicker/uiconfig/ui/remotefilesdialog.ui
index 7c0c923..e0699a5 100644
--- a/fpicker/uiconfig/ui/remotefilesdialog.ui
+++ b/fpicker/uiconfig/ui/remotefilesdialog.ui
@@ -285,5 +285,13 @@
         <property name="use_underline">True</property>
       </object>
     </child>
+    <child>
+      <object class="GtkMenuItem" id="change_password">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">_Change password</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
   </object>
 </interface>


More information about the Libreoffice-commits mailing list