diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-07-02 08:30:29 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-07-02 08:30:29 +0000 |
commit | c85996d2208aa530a7d58149e3a702e93a731beb (patch) | |
tree | c102be591d12c3c7cddcf22db953f7cf4f04d3ec /extensions/source/update | |
parent | d04420d72c2bb3311b11dadd178d785f8418a027 (diff) |
INTEGRATION: CWS sb90 (1.10.12); FILE MERGED
2008/06/27 14:40:57 sb 1.10.12.3: #157787# corrected order of product version and edition name
2008/06/26 11:28:03 sb 1.10.12.2: #157787# to allow for cross-platform edition data, consistently name the ini-file edition.ini (not editionrc)
2008/06/26 08:50:31 sb 1.10.12.1: #157787# expand new <PRODUCT> in versionrc UpdateUserAgent
Diffstat (limited to 'extensions/source/update')
-rw-r--r-- | extensions/source/update/feed/updatefeed.cxx | 82 |
1 files changed, 63 insertions, 19 deletions
diff --git a/extensions/source/update/feed/updatefeed.cxx b/extensions/source/update/feed/updatefeed.cxx index 4c2da9378960..f4d23d4228a5 100644 --- a/extensions/source/update/feed/updatefeed.cxx +++ b/extensions/source/update/feed/updatefeed.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: updatefeed.cxx,v $ - * $Revision: 1.10 $ + * $Revision: 1.11 $ * * This file is part of OpenOffice.org. * @@ -70,6 +70,7 @@ #include <rtl/ref.hxx> #include <rtl/memory.h> #include <rtl/bootstrap.hxx> +#include <rtl/ustrbuf.hxx> #include <osl/process.h> #include <osl/conditn.hxx> @@ -364,7 +365,7 @@ public: protected: virtual ~UpdateInformationProvider(); - static uno::Any getUILanguage(uno::Reference<uno::XComponentContext> const & xContext); + static uno::Any getConfigurationItem(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, rtl::OUString const & node, rtl::OUString const & item); private: uno::Reference< io::XInputStream > load(const rtl::OUString& rURL); @@ -506,15 +507,70 @@ UpdateInformationProvider::UpdateInformationProvider( rtl::OUString aPath; if( rtl::Bootstrap::get( UNISTRING("BRAND_BASE_DIR"), aPath ) ) { + uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager()); + if( !xServiceManager.is() ) + throw uno::RuntimeException( + UNISTRING("unable to obtain service manager from component context"), + uno::Reference< uno::XInterface >()); + + uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider( + xServiceManager->createInstanceWithContext( + UNISTRING("com.sun.star.configuration.ConfigurationProvider"), + xContext ), + uno::UNO_QUERY_THROW); + aPath += UNISTRING( "/program/" SAL_CONFIGFILE( "version" ) ); rtl::Bootstrap aVersionFile(aPath); + rtl::OUStringBuffer buf; + rtl::OUString name; + getConfigurationItem( + xConfigurationProvider, + UNISTRING("org.openoffice.Setup/Product"), + UNISTRING("ooName")) >>= name; + buf.append(name); + buf.append(sal_Unicode(' ')); + rtl::OUString version; + getConfigurationItem( + xConfigurationProvider, + UNISTRING("org.openoffice.Setup/Product"), + UNISTRING("ooSetupVersion")) >>= version; + buf.append(version); + rtl::OUString edition( + UNISTRING( + "${${BRAND_BASE_DIR}/program/edition/edition.ini:" + "EDITIONNAME}")); + rtl::Bootstrap::expandMacros(edition); + if (edition.getLength() != 0) { + buf.append(sal_Unicode(' ')); + buf.append(edition); + } + rtl::OUString extension; + getConfigurationItem( + xConfigurationProvider, + UNISTRING("org.openoffice.Setup/Product"), + UNISTRING("ooSetupExtension")) >>= extension; + if (extension.getLength() != 0) { + buf.append(sal_Unicode(' ')); + buf.append(extension); + } + rtl::OUString product(buf.makeStringAndClear()); rtl::OUString aUserAgent; aVersionFile.getFrom(UNISTRING("UpdateUserAgent"), aUserAgent, rtl::OUString()); + for (sal_Int32 i = 0;;) { + i = aUserAgent.indexOfAsciiL( + RTL_CONSTASCII_STRINGPARAM("<PRODUCT>"), i); + if (i == -1) { + break; + } + aUserAgent = aUserAgent.replaceAt( + i, RTL_CONSTASCII_LENGTH("<PRODUCT>"), product); + i += product.getLength(); + } m_aRequestHeaderList[0].Name = UNISTRING("Accept-Language"); - m_aRequestHeaderList[0].Value = getUILanguage( xContext ); + m_aRequestHeaderList[0].Value = getConfigurationItem( xConfigurationProvider, UNISTRING("org.openoffice.Setup/L10N"), UNISTRING("ooLocale") ); m_aRequestHeaderList[1].Name = UNISTRING("Accept-Encoding"); m_aRequestHeaderList[1].Value = uno::makeAny( UNISTRING("gzip,deflate") ); @@ -565,34 +621,22 @@ UpdateInformationProvider::~UpdateInformationProvider() //------------------------------------------------------------------------------ uno::Any -UpdateInformationProvider::getUILanguage(uno::Reference<uno::XComponentContext> const & xContext) +UpdateInformationProvider::getConfigurationItem(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, rtl::OUString const & node, rtl::OUString const & item) { - uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager()); - if( !xServiceManager.is() ) - throw uno::RuntimeException( - UNISTRING("unable to obtain service manager from component context"), - uno::Reference< uno::XInterface >()); - - uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider( - xServiceManager->createInstanceWithContext( - UNISTRING("com.sun.star.configuration.ConfigurationProvider"), - xContext ), - uno::UNO_QUERY_THROW); - beans::PropertyValue aProperty; aProperty.Name = UNISTRING("nodepath"); - aProperty.Value = uno::makeAny(UNISTRING("org.openoffice.Setup/L10N")); + aProperty.Value = uno::makeAny(node); uno::Sequence< uno::Any > aArgumentList( 1 ); aArgumentList[0] = uno::makeAny( aProperty ); uno::Reference< container::XNameAccess > xNameAccess( - xConfigurationProvider->createInstanceWithArguments( + configurationProvider->createInstanceWithArguments( UNISTRING("com.sun.star.configuration.ConfigurationAccess"), aArgumentList ), uno::UNO_QUERY_THROW); - return xNameAccess->getByName(UNISTRING("ooLocale")); + return xNameAccess->getByName(item); } //------------------------------------------------------------------------------ |