summaryrefslogtreecommitdiff
path: root/ucb/source/ucp/webdav/webdavprovider.cxx
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2013-03-24 12:22:15 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-23 22:48:18 +0100
commitae57695241d41022f4559601addbedea36b88f37 (patch)
treee52769d398cdb3d8154642b5e0a077c6fc36d963 /ucb/source/ucp/webdav/webdavprovider.cxx
parent5aaa9a0ade0fb5edbeed40ad9bfaef3139094631 (diff)
Resolves: #i121947# Default User-Agent
(cherry picked from commit 339d75d9c99462d63234845031f24a42e7ffdd27) Conflicts: ucb/source/ucp/webdav/DAVResourceAccess.cxx ucb/source/ucp/webdav/makefile.mk Change-Id: Ie74275cfa9953fdc4fa0801224909efbcecab3a9
Diffstat (limited to 'ucb/source/ucp/webdav/webdavprovider.cxx')
-rw-r--r--ucb/source/ucp/webdav/webdavprovider.cxx76
1 files changed, 76 insertions, 0 deletions
diff --git a/ucb/source/ucp/webdav/webdavprovider.cxx b/ucb/source/ucp/webdav/webdavprovider.cxx
index ad93bf9924f0..b782b048f941 100644
--- a/ucb/source/ucp/webdav/webdavprovider.cxx
+++ b/ucb/source/ucp/webdav/webdavprovider.cxx
@@ -20,12 +20,39 @@
#include <ucbhelper/contentidentifier.hxx>
#include "webdavprovider.hxx"
#include "webdavcontent.hxx"
+#include "webdavuseragent.hxx"
#include <osl/mutex.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
using namespace com::sun::star;
using namespace http_dav_ucp;
+
+OUString &WebDAVUserAgent::operator()() const
+{
+ OUStringBuffer aBuffer;
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "$ooName/$ooSetupVersion" ));
+#if OSL_DEBUG_LEVEL > 0
+#ifdef APR_VERSION
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " apr/" APR_VERSION ));
+#endif
+
+#ifdef APR_UTIL_VERSION
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " apr-util/" APR_UTIL_VERSION ));
+#endif
+
+#ifdef SERF_VERSION
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " serf/" SERF_VERSION ));
+#endif
+#endif
+ static OUString aUserAgent( aBuffer.makeStringAndClear() );
+ return aUserAgent;
+}
+
//=========================================================================
//=========================================================================
//
@@ -40,6 +67,55 @@ ContentProvider::ContentProvider(
m_xDAVSessionFactory( new DAVSessionFactory() ),
m_pProps( 0 )
{
+ static bool bInit = false;
+ if ( bInit )
+ return;
+ bInit = true;
+ try
+ {
+ uno::Reference< uno::XComponentContext > xContext(
+ ::comphelper::getProcessComponentContext() );
+ uno::Reference< lang::XMultiServiceFactory > xConfigProvider(
+ xContext->getServiceManager()->createInstanceWithContext(
+ OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationProvider")), xContext),
+ uno::UNO_QUERY_THROW );
+
+ beans::NamedValue aNodePath;
+ aNodePath.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
+ aNodePath.Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Product"));
+
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[0] <<= aNodePath;
+
+ uno::Reference< container::XNameAccess > xConfigAccess(
+ xConfigProvider->createInstanceWithArguments(
+ OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.configuration.ConfigurationAccess")), aArgs),
+ uno::UNO_QUERY_THROW );
+
+ OUString aVal;
+ xConfigAccess->getByName(OUString(RTL_CONSTASCII_USTRINGPARAM("ooName"))) >>= aVal;
+
+ OUString &aUserAgent = WebDAVUserAgent::get();
+ sal_Int32 nIndex = aUserAgent.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "$ooName" ) );
+ if ( !aVal.getLength() || nIndex == -1 )
+ return;
+ aUserAgent = aUserAgent.replaceAt( nIndex, RTL_CONSTASCII_LENGTH( "$ooName" ), aVal );
+
+ xConfigAccess->getByName(OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupVersion"))) >>= aVal;
+ nIndex = aUserAgent.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "$ooSetupVersion" ) );
+ if ( !aVal.getLength() || nIndex == -1 )
+ return;
+ aUserAgent = aUserAgent.replaceAt( nIndex, RTL_CONSTASCII_LENGTH( "$ooSetupVersion" ), aVal );
+
+ }
+ catch ( const uno::Exception &e )
+ {
+ OSL_TRACE( "ContentProvider -caught exception! %s",
+ OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+ (void) e;
+ }
}
//=========================================================================