From 836d3f493757d14b8cc8b449a766780ee4eb1bd0 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Tue, 24 Aug 2010 13:49:08 +0200 Subject: #i107134# - add support for https proxy server. --- ucbhelper/source/client/proxydecider.cxx | 239 ++++++++++++++++--------------- 1 file changed, 122 insertions(+), 117 deletions(-) (limited to 'ucbhelper') diff --git a/ucbhelper/source/client/proxydecider.cxx b/ucbhelper/source/client/proxydecider.cxx index 8505472e1b1f..d6fc260f558b 100644 --- a/ucbhelper/source/client/proxydecider.cxx +++ b/ucbhelper/source/client/proxydecider.cxx @@ -51,13 +51,15 @@ using namespace com::sun::star; using namespace ucbhelper; -#define CONFIG_ROOT_KEY "org.openoffice.Inet/Settings" -#define PROXY_TYPE_KEY "ooInetProxyType" -#define NO_PROXY_LIST_KEY "ooInetNoProxy" -#define HTTP_PROXY_NAME_KEY "ooInetHTTPProxyName" -#define HTTP_PROXY_PORT_KEY "ooInetHTTPProxyPort" -#define FTP_PROXY_NAME_KEY "ooInetFTPProxyName" -#define FTP_PROXY_PORT_KEY "ooInetFTPProxyPort" +#define CONFIG_ROOT_KEY "org.openoffice.Inet/Settings" +#define PROXY_TYPE_KEY "ooInetProxyType" +#define NO_PROXY_LIST_KEY "ooInetNoProxy" +#define HTTP_PROXY_NAME_KEY "ooInetHTTPProxyName" +#define HTTP_PROXY_PORT_KEY "ooInetHTTPProxyPort" +#define HTTPS_PROXY_NAME_KEY "ooInetHTTPSProxyName" +#define HTTPS_PROXY_PORT_KEY "ooInetHTTPSProxyPort" +#define FTP_PROXY_NAME_KEY "ooInetFTPProxyName" +#define FTP_PROXY_PORT_KEY "ooInetFTPProxyPort" //========================================================================= namespace ucbhelper @@ -132,6 +134,7 @@ class InternetProxyDecider_Impl : { mutable osl::Mutex m_aMutex; InternetProxyServer m_aHttpProxy; + InternetProxyServer m_aHttpsProxy; InternetProxyServer m_aFtpProxy; const InternetProxyServer m_aEmptyProxy; sal_Int32 m_nProxyType; @@ -245,6 +248,63 @@ bool WildCard::Matches( const rtl::OUString& rString ) const return ( *pStr == '\0' ) && ( *pWild == '\0' ); } +//========================================================================= +bool getConfigStringValue( + const uno::Reference< container::XNameAccess > & xNameAccess, + const char * key, + rtl::OUString & value ) +{ + try + { + if ( !( xNameAccess->getByName( rtl::OUString::createFromAscii( key ) ) + >>= value ) ) + { + OSL_ENSURE( sal_False, + "InternetProxyDecider - " + "Error getting config item value!" ); + return false; + } + } + catch ( lang::WrappedTargetException const & ) + { + return false; + } + catch ( container::NoSuchElementException const & ) + { + return false; + } + return true; +} + +//========================================================================= +bool getConfigInt32Value( + const uno::Reference< container::XNameAccess > & xNameAccess, + const char * key, + sal_Int32 & value ) +{ + try + { + uno::Any aValue = xNameAccess->getByName( + rtl::OUString::createFromAscii( key ) ); + if ( aValue.hasValue() && !( aValue >>= value ) ) + { + OSL_ENSURE( sal_False, + "InternetProxyDecider - " + "Error getting config item value!" ); + return false; + } + } + catch ( lang::WrappedTargetException const & ) + { + return false; + } + catch ( container::NoSuchElementException const & ) + { + return false; + } + return true; +} + //========================================================================= //========================================================================= // @@ -291,127 +351,43 @@ InternetProxyDecider_Impl::InternetProxyDecider_Impl( if ( xNameAccess.is() ) { - try - { - if ( !( xNameAccess->getByName( - rtl::OUString::createFromAscii( - PROXY_TYPE_KEY ) ) >>= m_nProxyType ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } + // *** Proxy type *** + getConfigInt32Value( + xNameAccess, PROXY_TYPE_KEY, m_nProxyType ); + // *** No proxy list *** rtl::OUString aNoProxyList; - try - { - if ( !( xNameAccess->getByName( - rtl::OUString::createFromAscii( - NO_PROXY_LIST_KEY ) ) >>= aNoProxyList ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } - + getConfigStringValue( + xNameAccess, NO_PROXY_LIST_KEY, aNoProxyList ); setNoProxyList( aNoProxyList ); - try - { - if ( !( xNameAccess->getByName( - rtl::OUString::createFromAscii( - HTTP_PROXY_NAME_KEY ) ) - >>= m_aHttpProxy.aName ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } + // *** HTTP *** + getConfigStringValue( + xNameAccess, HTTP_PROXY_NAME_KEY, m_aHttpProxy.aName ); m_aHttpProxy.nPort = -1; - try - { - uno::Any aValue = xNameAccess->getByName( - rtl::OUString::createFromAscii( - HTTP_PROXY_PORT_KEY ) ); - if ( aValue.hasValue() && - !( aValue >>= m_aHttpProxy.nPort ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } - + getConfigInt32Value( + xNameAccess, HTTP_PROXY_PORT_KEY, m_aHttpProxy.nPort ); if ( m_aHttpProxy.nPort == -1 ) m_aHttpProxy.nPort = 80; // standard HTTP port. - try - { - if ( !( xNameAccess->getByName( - rtl::OUString::createFromAscii( - FTP_PROXY_NAME_KEY ) ) - >>= m_aFtpProxy.aName ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } + // *** HTTPS *** + getConfigStringValue( + xNameAccess, HTTPS_PROXY_NAME_KEY, m_aHttpsProxy.aName ); + + m_aHttpsProxy.nPort = -1; + getConfigInt32Value( + xNameAccess, HTTPS_PROXY_PORT_KEY, m_aHttpsProxy.nPort ); + if ( m_aHttpsProxy.nPort == -1 ) + m_aHttpsProxy.nPort = 443; // standard HTTPS port. + + // *** FTP *** + getConfigStringValue( + xNameAccess, FTP_PROXY_NAME_KEY, m_aFtpProxy.aName ); m_aFtpProxy.nPort = -1; - try - { - uno::Any aValue = xNameAccess->getByName( - rtl::OUString::createFromAscii( - FTP_PROXY_PORT_KEY ) ); - if ( aValue.hasValue() && - !( aValue >>= m_aFtpProxy.nPort ) ) - { - OSL_ENSURE( sal_False, - "InternetProxyDecider - " - "Error getting config item value!" ); - } - } - catch ( lang::WrappedTargetException const & ) - { - } - catch ( container::NoSuchElementException const & ) - { - } + getConfigInt32Value( + xNameAccess, FTP_PROXY_PORT_KEY, m_aFtpProxy.nPort ); } // Register as listener for config changes. @@ -588,6 +564,12 @@ const InternetProxyServer & InternetProxyDecider_Impl::getProxy( if ( m_aFtpProxy.aName.getLength() > 0 && m_aFtpProxy.nPort >= 0 ) return m_aFtpProxy; } + else if ( rProtocol.toAsciiLowerCase() + .equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "https" ) ) ) + { + if ( m_aHttpsProxy.aName.getLength() ) + return m_aHttpsProxy; + } else if ( m_aHttpProxy.aName.getLength() ) { // All other protocols use the HTTP proxy. @@ -661,6 +643,29 @@ void SAL_CALL InternetProxyDecider_Impl::changesOccurred( if ( m_aHttpProxy.nPort == -1 ) m_aHttpProxy.nPort = 80; // standard HTTP port. } + else if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( + HTTPS_PROXY_NAME_KEY ) ) ) + { + if ( !( rElem.Element >>= m_aHttpsProxy.aName ) ) + { + OSL_ENSURE( sal_False, + "InternetProxyDecider - changesOccurred - " + "Error getting config item value!" ); + } + } + else if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( + HTTPS_PROXY_PORT_KEY ) ) ) + { + if ( !( rElem.Element >>= m_aHttpsProxy.nPort ) ) + { + OSL_ENSURE( sal_False, + "InternetProxyDecider - changesOccurred - " + "Error getting config item value!" ); + } + + if ( m_aHttpsProxy.nPort == -1 ) + m_aHttpsProxy.nPort = 443; // standard HTTPS port. + } else if ( aKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( FTP_PROXY_NAME_KEY ) ) ) { -- cgit v1.2.3 From 62580204bb6ed8c8812d85fd465fe38e8e79e00e Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Wed, 1 Sep 2010 15:23:16 +0200 Subject: Fixed typos in documantation. --- ucbhelper/inc/ucbhelper/simplenameclashresolverequest.hxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ucbhelper') diff --git a/ucbhelper/inc/ucbhelper/simplenameclashresolverequest.hxx b/ucbhelper/inc/ucbhelper/simplenameclashresolverequest.hxx index 7f3da27ece7c..8ab8ead7cffb 100644 --- a/ucbhelper/inc/ucbhelper/simplenameclashresolverequest.hxx +++ b/ucbhelper/inc/ucbhelper/simplenameclashresolverequest.hxx @@ -37,7 +37,7 @@ namespace ucbhelper { /** * This class implements a simple name clash resolve interaction request. * Instances can be passed directly to XInteractionHandler::handle(...). Each - * instance contains an NameClashResolveRequest and two interaction + * instance contains a NameClashResolveRequest and two interaction * continuations: "Abort" and "SupplyName". Another continuation * ("ReplaceExistingData") may be supplied optionally. * @@ -56,11 +56,11 @@ public: * * @param rTargetFolderURL contains the URL of the folder that contains * the clashing resource. - * @param rClashingName contains the clashing name, + * @param rClashingName contains the clashing name. * @param rProposedNewName contains a proposal for the new name or is * empty. - * @param bSupportsOverwriteData indictes whether an - * InteractioneplaceExistingData continuation shall be supplied + * @param bSupportsOverwriteData indicates whether an + * InteractionReplaceExistingData continuation shall be supplied * with the interaction request. */ SimpleNameClashResolveRequest( const rtl::OUString & rTargetFolderURL, -- cgit v1.2.3