webdavprovider.cxx (c1c10f68) webdavprovider.cxx (6601ee31)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 18 unchanged lines hidden (view full) ---

27/**************************************************************************
28 TODO
29 **************************************************************************
30
31 *************************************************************************/
32#include <ucbhelper/contentidentifier.hxx>
33#include "webdavprovider.hxx"
34#include "webdavcontent.hxx"
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 18 unchanged lines hidden (view full) ---

27/**************************************************************************
28 TODO
29 **************************************************************************
30
31 *************************************************************************/
32#include <ucbhelper/contentidentifier.hxx>
33#include "webdavprovider.hxx"
34#include "webdavcontent.hxx"
35#include "webdavuseragent.hxx"
35
36#include <osl/mutex.hxx>
36
37#include <osl/mutex.hxx>
38#include <rtl/ustrbuf.hxx>
39#include <comphelper/processfactory.hxx>
40#include <com/sun/star/beans/NamedValue.hpp>
41#include <com/sun/star/container/XNameAccess.hpp>
37
38using namespace com::sun::star;
39using namespace http_dav_ucp;
40
42
43using namespace com::sun::star;
44using namespace http_dav_ucp;
45
46
47rtl::OUString &WebDAVUserAgent::operator()() const
48{
49 rtl::OUStringBuffer aBuffer;
50 aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "$ooName/$ooSetupVersion" ));
51#if OSL_DEBUG_LEVEL > 0
52#ifdef APR_VERSION
53 aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " apr/" APR_VERSION ));
54#endif
55
56#ifdef APR_UTIL_VERSION
57 aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " apr-util/" APR_UTIL_VERSION ));
58#endif
59
60#ifdef SERF_VERSION
61 aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " serf/" SERF_VERSION ));
62#endif
63#endif
64 static rtl::OUString aUserAgent( aBuffer.makeStringAndClear() );
65 return aUserAgent;
66}
67
41//=========================================================================
42//=========================================================================
43//
44// ContentProvider Implementation.
45//
46//=========================================================================
47//=========================================================================
48
49ContentProvider::ContentProvider(
50 const uno::Reference< lang::XMultiServiceFactory >& rSMgr )
51: ::ucbhelper::ContentProviderImplHelper( rSMgr ),
52 m_xDAVSessionFactory( new DAVSessionFactory() ),
53 m_pProps( 0 )
54{
68//=========================================================================
69//=========================================================================
70//
71// ContentProvider Implementation.
72//
73//=========================================================================
74//=========================================================================
75
76ContentProvider::ContentProvider(
77 const uno::Reference< lang::XMultiServiceFactory >& rSMgr )
78: ::ucbhelper::ContentProviderImplHelper( rSMgr ),
79 m_xDAVSessionFactory( new DAVSessionFactory() ),
80 m_pProps( 0 )
81{
82 static bool bInit = false;
83 if ( bInit )
84 return;
85 bInit = true;
86 try
87 {
88 uno::Reference< uno::XComponentContext > xContext(
89 ::comphelper::getProcessComponentContext() );
90 uno::Reference< lang::XMultiServiceFactory > xConfigProvider(
91 xContext->getServiceManager()->createInstanceWithContext(
92 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
93 "com.sun.star.configuration.ConfigurationProvider")), xContext),
94 uno::UNO_QUERY_THROW );
95
96 beans::NamedValue aNodePath;
97 aNodePath.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) );
98 aNodePath.Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Product"));
99
100 uno::Sequence< uno::Any > aArgs( 1 );
101 aArgs[0] <<= aNodePath;
102
103 uno::Reference< container::XNameAccess > xConfigAccess(
104 xConfigProvider->createInstanceWithArguments(
105 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
106 "com.sun.star.configuration.ConfigurationAccess")), aArgs),
107 uno::UNO_QUERY_THROW );
108
109 rtl::OUString aVal;
110 xConfigAccess->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooName"))) >>= aVal;
111
112 rtl::OUString &aUserAgent = WebDAVUserAgent::get();
113 sal_Int32 nIndex = aUserAgent.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "$ooName" ) );
114 if ( !aVal.getLength() || nIndex == -1 )
115 return;
116 aUserAgent = aUserAgent.replaceAt( nIndex, RTL_CONSTASCII_LENGTH( "$ooName" ), aVal );
117
118 xConfigAccess->getByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooSetupVersion"))) >>= aVal;
119 nIndex = aUserAgent.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "$ooSetupVersion" ) );
120 if ( !aVal.getLength() || nIndex == -1 )
121 return;
122 aUserAgent = aUserAgent.replaceAt( nIndex, RTL_CONSTASCII_LENGTH( "$ooSetupVersion" ), aVal );
123
124 }
125 catch ( const uno::Exception &e )
126 {
127 OSL_TRACE( "ContentProvider -caught exception! %s",
128 rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
129 (void) e;
130 }
55}
56
57//=========================================================================
58// virtual
59ContentProvider::~ContentProvider()
60{
61 delete m_pProps;
62}

--- 164 unchanged lines hidden ---
131}
132
133//=========================================================================
134// virtual
135ContentProvider::~ContentProvider()
136{
137 delete m_pProps;
138}

--- 164 unchanged lines hidden ---