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

Szymon Kłos eszkadev at gmail.com
Wed Jul 29 01:20:37 PDT 2015


 ucb/source/ucp/cmis/cmis_content.cxx  |   10 ++++++++--
 ucb/source/ucp/cmis/cmis_provider.cxx |   13 +++++++++----
 ucb/source/ucp/cmis/cmis_provider.hxx |    6 +++---
 ucb/source/ucp/cmis/cmis_url.cxx      |    9 ++++++++-
 ucb/source/ucp/cmis/cmis_url.hxx      |    1 +
 5 files changed, 29 insertions(+), 10 deletions(-)

New commits:
commit 92e41683dbe657921e99310f1ec4c29aaef2828d
Author: Szymon Kłos <eszkadev at gmail.com>
Date:   Wed Jul 29 10:18:20 2015 +0200

    CMIS: remember new session for each user
    
    Change-Id: I7d0a72e48b8f9056e8761cae8939e2b8f6dbdd24

diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index bc77db1..c0b72b6 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -339,7 +339,7 @@ namespace cmis
         // Look for a cached session, key is binding url + repo id
         OUString sSessionId = m_aURL.getBindingUrl( ) + m_aURL.getRepositoryId( );
         if ( NULL == m_pSession )
-            m_pSession = m_pProvider->getSession( sSessionId );
+            m_pSession = m_pProvider->getSession( sSessionId, m_aURL.getUsername( ) );
 
         if ( NULL == m_pSession )
         {
@@ -411,7 +411,7 @@ namespace cmis
                 }
                 else
                 {
-                    m_pProvider->registerSession(sSessionId, m_pSession);
+                    m_pProvider->registerSession(sSessionId, m_aURL.getUsername( ), m_pSession);
                 }
             }
             else
@@ -2019,14 +2019,20 @@ namespace cmis
                 {
                     // TODO Cache the objects
 
+                    INetURLObject aURL( m_sURL );
+                    OUString sUser = aURL.GetUser( INetURLObject::NO_DECODE );
+
                     URL aUrl( m_sURL );
                     OUString sPath( m_sObjectPath );
                     if ( !sPath.endsWith("/") )
                         sPath += "/";
                     sPath += STD_TO_OUSTR( ( *it )->getName( ) );
                     OUString sId = STD_TO_OUSTR( ( *it )->getId( ) );
+
                     aUrl.setObjectId( sId );
                     aUrl.setObjectPath( sPath );
+                    aUrl.setUsername( sUser );
+
                     uno::Reference< ucb::XContentIdentifier > xId = new ucbhelper::ContentIdentifier( aUrl.asString( ) );
                     uno::Reference< ucb::XContent > xContent = new Content( m_xContext, m_pProvider, xId, *it );
 
diff --git a/ucb/source/ucp/cmis/cmis_provider.cxx b/ucb/source/ucp/cmis/cmis_provider.cxx
index a41b52c..c9819b5 100644
--- a/ucb/source/ucp/cmis/cmis_provider.cxx
+++ b/ucb/source/ucp/cmis/cmis_provider.cxx
@@ -59,10 +59,11 @@ ContentProvider::queryContent(
     return xContent;
 }
 
-libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl )
+libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl, const OUString& sUsername )
 {
     libcmis::Session* pSession = NULL;
-    std::map< OUString, libcmis::Session* >::iterator it = m_aSessionCache.find( sBindingUrl );
+    std::map< std::pair< OUString, OUString >, libcmis::Session* >::iterator it
+            = m_aSessionCache.find( std::pair< OUString, OUString >( sBindingUrl, sUsername ) );
     if ( it != m_aSessionCache.end( ) )
     {
         pSession = it->second;
@@ -70,9 +71,13 @@ libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl )
     return pSession;
 }
 
-void ContentProvider::registerSession( const OUString& sBindingUrl, libcmis::Session* pSession )
+void ContentProvider::registerSession( const OUString& sBindingUrl, const OUString& sUsername, libcmis::Session* pSession )
 {
-    m_aSessionCache.insert( std::pair< OUString, libcmis::Session* >( sBindingUrl, pSession ) );
+    m_aSessionCache.insert( std::pair< std::pair< OUString, OUString >, libcmis::Session* >
+                            (
+                                std::pair< OUString, OUString >( sBindingUrl, sUsername ),
+                                pSession
+                            ) );
 }
 
 ContentProvider::ContentProvider(
diff --git a/ucb/source/ucp/cmis/cmis_provider.hxx b/ucb/source/ucp/cmis/cmis_provider.hxx
index efbd439..1dcad0a 100644
--- a/ucb/source/ucp/cmis/cmis_provider.hxx
+++ b/ucb/source/ucp/cmis/cmis_provider.hxx
@@ -20,7 +20,7 @@ namespace cmis
 class ContentProvider : public ::ucbhelper::ContentProviderImplHelper
 {
 private:
-    std::map< OUString, libcmis::Session* > m_aSessionCache;
+    std::map< std::pair< OUString, OUString >, libcmis::Session* > m_aSessionCache;
 
 public:
     explicit ContentProvider( const ::com::sun::star::uno::Reference<
@@ -64,8 +64,8 @@ public:
         throw( ::com::sun::star::ucb::IllegalIdentifierException,
                ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
 
-    libcmis::Session* getSession( const OUString& sBindingUrl );
-    void registerSession( const OUString& sBindingUrl, libcmis::Session* pSession );
+    libcmis::Session* getSession( const OUString& sBindingUrl, const OUString& sUsername );
+    void registerSession( const OUString& sBindingUrl, const OUString& sUsername, libcmis::Session* pSession );
 };
 
 }
diff --git a/ucb/source/ucp/cmis/cmis_url.cxx b/ucb/source/ucp/cmis/cmis_url.cxx
index ff0763c..533ebf2 100644
--- a/ucb/source/ucp/cmis/cmis_url.cxx
+++ b/ucb/source/ucp/cmis/cmis_url.cxx
@@ -53,6 +53,11 @@ namespace cmis
         m_sId = sId;
     }
 
+    void URL::setUsername( const OUString& sUser )
+    {
+        m_sUser = sUser;
+    }
+
     OUString URL::asString( )
     {
         OUString sUrl;
@@ -61,7 +66,9 @@ namespace cmis
                 rtl_UriCharClassRelSegment,
                 rtl_UriEncodeKeepEscapes,
                 RTL_TEXTENCODING_UTF8 );
-        sUrl = "vnd.libreoffice.cmis://" + sEncodedBinding;
+        sUrl = "vnd.libreoffice.cmis://" +
+                ( m_sUser.isEmpty() ? OUString( ) : (m_sUser + "@") ) +
+                sEncodedBinding;
 
         if ( !m_sPath.isEmpty( ) )
         {
diff --git a/ucb/source/ucp/cmis/cmis_url.hxx b/ucb/source/ucp/cmis/cmis_url.hxx
index 14a32c00..c09b509 100644
--- a/ucb/source/ucp/cmis/cmis_url.hxx
+++ b/ucb/source/ucp/cmis/cmis_url.hxx
@@ -38,6 +38,7 @@ namespace cmis
             const OUString& getPassword() const { return m_sPass; }
             void setObjectPath( const OUString& sPath );
             void setObjectId( const OUString& sId );
+            void setUsername( const OUString& sUser );
 
             OUString asString( );
     };


More information about the Libreoffice-commits mailing list