external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch
 |  142 ++++++++++
 external/libcmis/UnpackedTarball_libcmis.mk                                    
  |    1 
 2 files changed, 143 insertions(+)

New commits:
commit 5610476a61fb9e75e87d98a30c5ba4e7ac353545
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Mon Nov 6 14:43:12 2023 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Sat Nov 11 18:08:22 2023 +0100

    libcmis: HttpSession: add a callback that can be used to configure libcurl
    
    Change-Id: I6c2a3d1976f2256b21a3a306db7fbf04ca444c32
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159000
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 061e48e607291c2992c81d3073a8c41387c56996)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158907
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git 
a/external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch
 
b/external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch
new file mode 100644
index 000000000000..b47ee4d195b2
--- /dev/null
+++ 
b/external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch
@@ -0,0 +1,142 @@
+From 94012ca5b669e71ea35508159f63576364736dc2 Mon Sep 17 00:00:00 2001
+From: Michael Stahl <michael.st...@allotropia.de>
+Date: Mon, 6 Nov 2023 14:18:59 +0100
+Subject: [PATCH 2/2] HttpSession: add a callback that can be used to configure
+ libcurl
+
+---
+ inc/libcmis/session-factory.hxx | 7 +++++++
+ src/libcmis/http-session.cxx    | 8 +++++++-
+ src/libcmis/http-session.hxx    | 8 +++++++-
+ src/libcmis/session-factory.cxx | 9 ++++++++-
+ 4 files changed, 29 insertions(+), 3 deletions(-)
+
+diff --git a/inc/libcmis/session-factory.hxx b/inc/libcmis/session-factory.hxx
+index 45abd8b..227ac4d 100644
+--- a/inc/libcmis/session-factory.hxx
++++ b/inc/libcmis/session-factory.hxx
+@@ -38,6 +38,9 @@
+ #include "libcmis/repository.hxx"
+ #include "libcmis/session.hxx"
+ 
++// needed for a callback type
++typedef void CURL;
++
+ namespace libcmis
+ {
+     /** This callback provides the OAuth2 code or NULL.
+@@ -80,6 +83,8 @@ namespace libcmis
+     };
+     typedef boost::shared_ptr< CertValidationHandler > 
CertValidationHandlerPtr;
+ 
++    typedef void(*CurlInitProtocolsFunction)(CURL *);
++
+     class LIBCMIS_API SessionFactory
+     {
+         private:
+@@ -109,6 +114,8 @@ namespace libcmis
+             static void setCertificateValidationHandler( 
CertValidationHandlerPtr handler ) { s_certValidationHandler = handler; }
+             static CertValidationHandlerPtr getCertificateValidationHandler( 
) { return s_certValidationHandler; }
+ 
++            static void 
setCurlInitProtocolsFunction(CurlInitProtocolsFunction);
++
+             static void setProxySettings( std::string proxy,
+                     std::string noProxy,
+                     std::string proxyUser,
+diff --git a/src/libcmis/http-session.cxx b/src/libcmis/http-session.cxx
+index 9703427..8787c50 100644
+--- a/src/libcmis/http-session.cxx
++++ b/src/libcmis/http-session.cxx
+@@ -133,8 +133,10 @@ namespace
+ }
+ 
+ HttpSession::HttpSession( string username, string password, bool noSslCheck,
+-                          libcmis::OAuth2DataPtr oauth2, bool verbose ) :
++                          libcmis::OAuth2DataPtr oauth2, bool verbose,
++                          libcmis::CurlInitProtocolsFunction initProtocols) :
+     m_curlHandle( NULL ),
++    m_CurlInitProtocolsFunction(initProtocols),
+     m_no100Continue( false ),
+     m_oauth2Handler( NULL ),
+     m_username( username ),
+@@ -903,6 +905,10 @@ void HttpSession::initProtocols( )
+     curl_easy_setopt(m_curlHandle, CURLOPT_PROTOCOLS, protocols);
+     curl_easy_setopt(m_curlHandle, CURLOPT_REDIR_PROTOCOLS, protocols);
+ #endif
++    if (m_CurlInitProtocolsFunction)
++    {
++        (*m_CurlInitProtocolsFunction)(m_curlHandle);
++    }
+ }
+ 
+ const char* CurlException::what( ) const noexcept
+diff --git a/src/libcmis/http-session.hxx b/src/libcmis/http-session.hxx
+index 6c9ed1b..34223b2 100644
+--- a/src/libcmis/http-session.hxx
++++ b/src/libcmis/http-session.hxx
+@@ -43,6 +43,10 @@
+ 
+ class OAuth2Handler;
+ 
++namespace libcmis {
++    typedef void(*CurlInitProtocolsFunction)(CURL *);
++}
++
+ class CurlException : public std::exception
+ {
+     private:
+@@ -93,6 +97,7 @@ class HttpSession
+ {
+     protected:
+         CURL* m_curlHandle;
++        libcmis::CurlInitProtocolsFunction m_CurlInitProtocolsFunction = 
nullptr;
+     private:
+         bool  m_no100Continue;
+     protected:
+@@ -111,7 +116,8 @@ class HttpSession
+         HttpSession( std::string username, std::string password,
+                      bool noSslCheck = false,
+                      libcmis::OAuth2DataPtr oauth2 = libcmis::OAuth2DataPtr(),
+-                     bool verbose = false );
++                     bool verbose = false,
++                     libcmis::CurlInitProtocolsFunction = nullptr);
+ 
+         HttpSession( const HttpSession& copy );
+         virtual ~HttpSession( );
+diff --git a/src/libcmis/session-factory.cxx b/src/libcmis/session-factory.cxx
+index 1222473..47dc1c8 100644
+--- a/src/libcmis/session-factory.cxx
++++ b/src/libcmis/session-factory.cxx
+@@ -38,6 +38,7 @@ using namespace std;
+ 
+ namespace libcmis
+ {
++    CurlInitProtocolsFunction g_CurlInitProtocolsFunction = 0;
+     AuthProviderPtr SessionFactory::s_authProvider;
+     OAuth2AuthCodeProvider SessionFactory::s_oauth2AuthCodeProvider;
+ 
+@@ -48,6 +49,11 @@ namespace libcmis
+ 
+     CertValidationHandlerPtr SessionFactory::s_certValidationHandler;
+ 
++    void 
SessionFactory::setCurlInitProtocolsFunction(CurlInitProtocolsFunction const 
initProtocols)
++    {
++        g_CurlInitProtocolsFunction = initProtocols;
++    }
++
+     void SessionFactory::setProxySettings( string proxy, string noProxy,
+             string proxyUser, string proxyPass )
+     {
+@@ -81,7 +87,8 @@ namespace libcmis
+                 libcmis::HttpResponsePtr response;
+                 boost::shared_ptr< HttpSession> httpSession(
+                         new HttpSession( username, password,
+-                                         noSslCheck, oauth2, verbose ) );
++                                         noSslCheck, oauth2, verbose,
++                                         g_CurlInitProtocolsFunction) );
+ 
+                 try
+                 {
+-- 
+2.41.0
+
diff --git a/external/libcmis/UnpackedTarball_libcmis.mk 
b/external/libcmis/UnpackedTarball_libcmis.mk
index d7ecc207f10d..1ef846aa2b4b 100644
--- a/external/libcmis/UnpackedTarball_libcmis.mk
+++ b/external/libcmis/UnpackedTarball_libcmis.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libcmis,1))
 
 $(eval $(call gb_UnpackedTarball_add_patches,libcmis,\
        external/libcmis/0001-fix-regression-in-HttpSession-initProtocols.patch 
\
+       
external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch
 \
 ))
 
 # vim: set noet sw=4 ts=4:

Reply via email to