officecfg/registry/data/org/openoffice/Office/Common.xcu |    2 
 ucb/source/ucp/cmis/cmis_content.cxx                     |   12 +++++
 ucb/source/ucp/cmis/cmis_oauth2_providers.hxx            |   32 +++++++++++++++
 ucb/source/ucp/cmis/cmis_url.cxx                         |   26 +++++++-----
 4 files changed, 60 insertions(+), 12 deletions(-)

New commits:
commit a3e5c43ff690da09390634dd7c54c9ff193a95cc
Author: Cao Cuong Ngo <cao.cuong....@gmail.com>
Date:   Sun Jul 14 23:59:51 2013 +0200

    CMIS: connect LO to Google Drive
    
    Change-Id: I2c1b1d3e2bfd50ceb8647e62d37512ee3a0b9dae

diff --git a/officecfg/registry/data/org/openoffice/Office/Common.xcu 
b/officecfg/registry/data/org/openoffice/Office/Common.xcu
index fb84a88..ef0e765 100644
--- a/officecfg/registry/data/org/openoffice/Office/Common.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Common.xcu
@@ -583,6 +583,7 @@
         <it>https://&lt;host&gt;/cmis/atom</it>
         
<it>http://ec2-184-72-233-127.compute-1.amazonaws.com/ot-cmis/services/RepositoryService?wsdl</it>
         <it>http://&lt;host&gt;/_vti_bin/CMISSoapwsdl.aspx</it>
+        <it>https://www.googleapis.com/drive/v2</it>
       </value>
     </prop>
     <prop oor:name="CmisServersNames">
@@ -595,6 +596,7 @@
         <it>OpenDataSpace</it>
         <it>OpenText ELS 10.2.0</it>
         <it>SharePoint 2010</it>
+        <it>Google Drive</it>
       </value>
     </prop>
   </node>
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx 
b/ucb/source/ucp/cmis/cmis_content.cxx
index 9d4beeb..e4a206c 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -49,6 +49,7 @@
 #include "cmis_content.hxx"
 #include "cmis_provider.hxx"
 #include "cmis_resultset.hxx"
+#include "cmis_oauth2_providers.hxx"
 
 #define OUSTR_TO_STDSTR(s) string( OUStringToOString( s, RTL_TEXTENCODING_UTF8 
).getStr() )
 #define STD_TO_OUSTR( str ) OUString( str.c_str(), str.length( ), 
RTL_TEXTENCODING_UTF8 )
@@ -316,9 +317,16 @@ namespace cmis
             if ( authProvider.authenticationQuery( rUsername, rPassword ) )
             {
                 // Initiate a CMIS session and register it as we found nothing
+                libcmis::OAuth2DataPtr oauth2Data = NULL;
+                if ( m_aURL.getBindingUrl( ) == GDRIVE_BASE_URL )
+                    oauth2Data.reset( new libcmis::OAuth2Data(
+                        GDRIVE_AUTH_URL, GDRIVE_TOKEN_URL,
+                        GDRIVE_SCOPE, GDRIVE_REDIRECT_URI,
+                        GDRIVE_CLIENT_ID, GDRIVE_CLIENT_SECRET ) );
+
                 m_pSession = libcmis::SessionFactory::createSession(
                         OUSTR_TO_STDSTR( m_aURL.getBindingUrl( ) ),
-                        rUsername, rPassword, OUSTR_TO_STDSTR( 
m_aURL.getRepositoryId( ) ) );
+                        rUsername, rPassword, OUSTR_TO_STDSTR( 
m_aURL.getRepositoryId( ) ), oauth2Data );
                 if ( m_pSession == NULL )
                     ucbhelper::cancelCommandExecution(
                                         ucb::IOErrorCode_INVALID_DEVICE,
@@ -1773,6 +1781,8 @@ namespace cmis
                     if ( sPath[sPath.getLength( ) - 1] != '/' )
                         sPath += "/";
                     sPath += STD_TO_OUSTR( ( *it )->getName( ) );
+                    OUString sId = STD_TO_OUSTR( ( *it )->getId( ) );
+                    aUrl.setObjectId( sId );
                     aUrl.setObjectPath( sPath );
                     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_oauth2_providers.hxx 
b/ucb/source/ucp/cmis/cmis_oauth2_providers.hxx
new file mode 100644
index 0000000..bd3df5b
--- /dev/null
+++ b/ucb/source/ucp/cmis/cmis_oauth2_providers.hxx
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ */
+
+#ifndef CMIS_OAUTH2_PROVIDER2_HXX
+#define CMIS_OAUTH2_PROVIDERS_HXX
+
+
+namespace cmis
+{
+
+#define GDRIVE_BASE_URL "https://www.googleapis.com/drive/v2";
+#define GDRIVE_CLIENT_ID "457862564325.apps.googleusercontent.com"
+#define GDRIVE_CLIENT_SECRET "GYWrDtzyZQZ0_g5YoBCC6F0I"
+#define GDRIVE_AUTH_URL "https://accounts.google.com/o/oauth2/auth";
+#define GDRIVE_TOKEN_URL "https://accounts.google.com/o/oauth2/token";
+#define GDRIVE_REDIRECT_URI "urn:ietf:wg:oauth:2.0:oob"
+#define GDRIVE_SCOPE "https://www.googleapis.com/auth/drive";
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/cmis/cmis_url.cxx b/ucb/source/ucp/cmis/cmis_url.cxx
index 79c7a9e..5d82e18 100644
--- a/ucb/source/ucp/cmis/cmis_url.cxx
+++ b/ucb/source/ucp/cmis/cmis_url.cxx
@@ -15,6 +15,7 @@
 #include <rtl/uri.hxx>
 
 #include "cmis_url.hxx"
+#include "cmis_oauth2_providers.hxx"
 
 using namespace std;
 
@@ -34,7 +35,11 @@ namespace cmis
         m_sPass = aUrl.GetPass( INetURLObject::DECODE_WITH_CHARSET );
 
         // Store the path to the object
-        m_sPath = aUrl.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );
+        // Google Drive doesn't support getObjectByPath
+        if ( m_sBindingUrl == GDRIVE_BASE_URL )
+            m_sPath = OUString( );
+        else
+            m_sPath = aUrl.GetURLPath( INetURLObject::DECODE_WITH_CHARSET );
         m_sId = aUrl.GetMark( INetURLObject::DECODE_WITH_CHARSET );
 
         if ( !m_sId.isEmpty( ) )
@@ -64,12 +69,10 @@ namespace cmis
     void URL::setObjectPath( OUString sPath )
     {
         m_sPath = sPath;
-        m_sId = OUString( );
     }
 
     void URL::setObjectId( OUString sId )
     {
-        m_sPath = OUString( );
         m_sId = sId;
     }
 
@@ -83,7 +86,15 @@ namespace cmis
                 RTL_TEXTENCODING_UTF8 );
         sUrl = "vnd.libreoffice.cmis://" + sEncodedBinding;
 
-        if ( !m_sPath.isEmpty( ) )
+        // Prefer get object by ID
+        if ( !m_sId.isEmpty( ) )
+        {
+            sUrl += "#" + rtl::Uri::encode( m_sId,
+                rtl_UriCharClassRelSegment,
+                rtl_UriEncodeKeepEscapes,
+                RTL_TEXTENCODING_UTF8 );
+        }
+        else if ( !m_sPath.isEmpty( ) )
         {
             sal_Int32 nPos = -1;
             OUString sEncodedPath;
@@ -107,13 +118,6 @@ namespace cmis
             while ( nPos != -1 );
             sUrl += sEncodedPath;
         }
-        else if ( !m_sId.isEmpty( ) )
-        {
-            sUrl += "#" + rtl::Uri::encode( m_sId,
-                rtl_UriCharClassRelSegment,
-                rtl_UriEncodeKeepEscapes,
-                RTL_TEXTENCODING_UTF8 );
-        }
 
         return sUrl;
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to