1*2a97ec55SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2a97ec55SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2a97ec55SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2a97ec55SAndrew Rist * distributed with this work for additional information 6*2a97ec55SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2a97ec55SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2a97ec55SAndrew Rist * "License"); you may not use this file except in compliance 9*2a97ec55SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2a97ec55SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2a97ec55SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2a97ec55SAndrew Rist * software distributed under the License is distributed on an 15*2a97ec55SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2a97ec55SAndrew Rist * KIND, either express or implied. See the License for the 17*2a97ec55SAndrew Rist * specific language governing permissions and limitations 18*2a97ec55SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2a97ec55SAndrew Rist *************************************************************/ 21*2a97ec55SAndrew Rist 22*2a97ec55SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_extensions.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "updatecheckconfig.hxx" 29cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 30cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp> 31cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 32cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <osl/security.hxx> 35cdf0e10cSrcweir #include <osl/time.h> 36cdf0e10cSrcweir #include <osl/file.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #ifdef WNT 39cdf0e10cSrcweir #ifdef _MSC_VER 40cdf0e10cSrcweir #pragma warning(push,1) // disable warnings within system headers 41cdf0e10cSrcweir #pragma warning(disable: 4917) 42cdf0e10cSrcweir #endif 43cdf0e10cSrcweir #include <shlobj.h> 44cdf0e10cSrcweir #ifdef _MSC_VER 45cdf0e10cSrcweir #pragma warning(pop) 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir 49cdf0e10cSrcweir namespace container = com::sun::star::container ; 50cdf0e10cSrcweir namespace beans = com::sun::star::beans ; 51cdf0e10cSrcweir namespace lang = com::sun::star::lang ; 52cdf0e10cSrcweir namespace util = com::sun::star::util ; 53cdf0e10cSrcweir namespace uno = com::sun::star::uno ; 54cdf0e10cSrcweir 55cdf0e10cSrcweir #define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 56cdf0e10cSrcweir 57cdf0e10cSrcweir #define LAST_CHECK "LastCheck" 58cdf0e10cSrcweir #define VERSION_FOUND "UpdateVersionFound" 59cdf0e10cSrcweir #define UPDATE_VERSION "UpdateVersion" 60cdf0e10cSrcweir #define UPDATE_BUILDID "UpdateBuildId" 61cdf0e10cSrcweir #define UPDATE_DESCRIPTION "UpdateDescription" 62cdf0e10cSrcweir #define DOWNLOAD_URL "DownloadURL" 63cdf0e10cSrcweir #define IS_DIRECT_DOWNLOAD "IsDirectDownload" 64cdf0e10cSrcweir #define OLD_VERSION "UpdateFoundFor" 65cdf0e10cSrcweir #define AUTOCHECK_ENABLED "AutoCheckEnabled" 66cdf0e10cSrcweir #define AUTODOWNLOAD_ENABLED "AutoDownloadEnabled" 67cdf0e10cSrcweir #define CHECK_INTERVAL "CheckInterval" 68cdf0e10cSrcweir #define LOCAL_FILE "LocalFile" 69cdf0e10cSrcweir #define DOWNLOAD_SIZE "DownloadSize" 70cdf0e10cSrcweir #define DOWNLOAD_PAUSED "DownloadPaused" 71cdf0e10cSrcweir #define DOWNLOAD_DESTINATION "DownloadDestination" 72cdf0e10cSrcweir #define RELEASE_NOTE "ReleaseNote" 73cdf0e10cSrcweir #define EXTENSION_PREFIX "Extension_" 74cdf0e10cSrcweir 75cdf0e10cSrcweir #define PROPERTY_VERSION UNISTRING("Version") 76cdf0e10cSrcweir 77cdf0e10cSrcweir static const sal_Char * const aUpdateEntryProperties[] = { 78cdf0e10cSrcweir UPDATE_VERSION, 79cdf0e10cSrcweir UPDATE_BUILDID, 80cdf0e10cSrcweir UPDATE_DESCRIPTION, 81cdf0e10cSrcweir DOWNLOAD_URL, 82cdf0e10cSrcweir IS_DIRECT_DOWNLOAD, 83cdf0e10cSrcweir RELEASE_NOTE"1", 84cdf0e10cSrcweir RELEASE_NOTE"2", 85cdf0e10cSrcweir RELEASE_NOTE"3", 86cdf0e10cSrcweir RELEASE_NOTE"4", 87cdf0e10cSrcweir RELEASE_NOTE"5", 88cdf0e10cSrcweir OLD_VERSION 89cdf0e10cSrcweir }; 90cdf0e10cSrcweir 91cdf0e10cSrcweir static const sal_uInt32 nUpdateEntryProperties = sizeof(aUpdateEntryProperties) / sizeof(sal_Char *); 92cdf0e10cSrcweir 93cdf0e10cSrcweir //------------------------------------------------------------------------------ 94cdf0e10cSrcweir 95cdf0e10cSrcweir NamedValueByNameAccess::~NamedValueByNameAccess() 96cdf0e10cSrcweir { 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir //------------------------------------------------------------------------------ 100cdf0e10cSrcweir 101cdf0e10cSrcweir ::com::sun::star::uno::Any 102cdf0e10cSrcweir NamedValueByNameAccess::getValue(const sal_Char * pName) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir const sal_Int32 nLen = m_rValues.getLength(); 105cdf0e10cSrcweir for( sal_Int32 n=0; n < nLen; ++n ) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir if( m_rValues[n].Name.equalsAscii( pName ) ) 108cdf0e10cSrcweir return m_rValues[n].Value; 109cdf0e10cSrcweir } 110cdf0e10cSrcweir return ::com::sun::star::uno::Any(); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir 114cdf0e10cSrcweir //------------------------------------------------------------------------------ 115cdf0e10cSrcweir 116cdf0e10cSrcweir bool 117cdf0e10cSrcweir UpdateCheckROModel::isAutoCheckEnabled() const 118cdf0e10cSrcweir { 119cdf0e10cSrcweir return sal_True == m_aNameAccess.getValue(AUTOCHECK_ENABLED).get< sal_Bool >(); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir //------------------------------------------------------------------------------ 123cdf0e10cSrcweir 124cdf0e10cSrcweir bool 125cdf0e10cSrcweir UpdateCheckROModel::isDownloadPaused() const 126cdf0e10cSrcweir { 127cdf0e10cSrcweir return sal_True == m_aNameAccess.getValue(DOWNLOAD_PAUSED).get< sal_Bool >(); 128cdf0e10cSrcweir } 129cdf0e10cSrcweir 130cdf0e10cSrcweir //------------------------------------------------------------------------------ 131cdf0e10cSrcweir 132cdf0e10cSrcweir rtl::OUString 133cdf0e10cSrcweir UpdateCheckROModel::getStringValue(const sal_Char * pStr) const 134cdf0e10cSrcweir { 135cdf0e10cSrcweir uno::Any aAny( m_aNameAccess.getValue(pStr) ); 136cdf0e10cSrcweir rtl::OUString aRet; 137cdf0e10cSrcweir 138cdf0e10cSrcweir aAny >>= aRet; 139cdf0e10cSrcweir 140cdf0e10cSrcweir return aRet; 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir //------------------------------------------------------------------------------ 144cdf0e10cSrcweir 145cdf0e10cSrcweir rtl::OUString UpdateCheckROModel::getLocalFileName() const 146cdf0e10cSrcweir { 147cdf0e10cSrcweir return getStringValue(LOCAL_FILE); 148cdf0e10cSrcweir }; 149cdf0e10cSrcweir 150cdf0e10cSrcweir //------------------------------------------------------------------------------ 151cdf0e10cSrcweir 152cdf0e10cSrcweir sal_Int64 UpdateCheckROModel::getDownloadSize() const 153cdf0e10cSrcweir { 154cdf0e10cSrcweir uno::Any aAny( m_aNameAccess.getValue(DOWNLOAD_SIZE) ); 155cdf0e10cSrcweir sal_Int64 nRet = -1; 156cdf0e10cSrcweir 157cdf0e10cSrcweir aAny >>= nRet; 158cdf0e10cSrcweir return nRet; 159cdf0e10cSrcweir }; 160cdf0e10cSrcweir 161cdf0e10cSrcweir //------------------------------------------------------------------------------ 162cdf0e10cSrcweir 163cdf0e10cSrcweir rtl::OUString 164cdf0e10cSrcweir UpdateCheckROModel::getUpdateEntryVersion() const 165cdf0e10cSrcweir { 166cdf0e10cSrcweir return getStringValue(OLD_VERSION); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir //------------------------------------------------------------------------------ 170cdf0e10cSrcweir 171cdf0e10cSrcweir void 172cdf0e10cSrcweir UpdateCheckROModel::getUpdateEntry(UpdateInfo& rInfo) const 173cdf0e10cSrcweir { 174cdf0e10cSrcweir rInfo.BuildId = getStringValue(UPDATE_BUILDID); 175cdf0e10cSrcweir rInfo.Version = getStringValue(UPDATE_VERSION); 176cdf0e10cSrcweir rInfo.Description = getStringValue(UPDATE_DESCRIPTION); 177cdf0e10cSrcweir 178cdf0e10cSrcweir sal_Bool isDirectDownload = sal_False; 179cdf0e10cSrcweir m_aNameAccess.getValue(IS_DIRECT_DOWNLOAD) >>= isDirectDownload; 180cdf0e10cSrcweir 181cdf0e10cSrcweir rInfo.Sources.push_back( DownloadSource( isDirectDownload, getStringValue(DOWNLOAD_URL) ) ); 182cdf0e10cSrcweir 183cdf0e10cSrcweir rtl::OString aStr(RELEASE_NOTE); 184cdf0e10cSrcweir for(sal_Int32 n=1; n < 6; ++n ) 185cdf0e10cSrcweir { 186cdf0e10cSrcweir rtl::OUString aUStr = getStringValue(aStr + rtl::OString::valueOf(n)); 187cdf0e10cSrcweir if( aUStr.getLength() > 0 ) 188cdf0e10cSrcweir rInfo.ReleaseNotes.push_back(ReleaseNote((sal_Int8) n, aUStr)); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir 193cdf0e10cSrcweir //------------------------------------------------------------------------------ 194cdf0e10cSrcweir 195cdf0e10cSrcweir rtl::OUString UpdateCheckConfig::getDesktopDirectory() 196cdf0e10cSrcweir { 197cdf0e10cSrcweir rtl::OUString aRet; 198cdf0e10cSrcweir 199cdf0e10cSrcweir #ifdef WNT 200cdf0e10cSrcweir WCHAR szPath[MAX_PATH]; 201cdf0e10cSrcweir 202cdf0e10cSrcweir if( ! FAILED( SHGetSpecialFolderPathW( NULL, szPath, CSIDL_DESKTOPDIRECTORY, true ) ) ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir aRet = rtl::OUString( reinterpret_cast< sal_Unicode * >(szPath) ); 205cdf0e10cSrcweir osl::FileBase::getFileURLFromSystemPath( aRet, aRet ); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir #else 208cdf0e10cSrcweir // This should become a desktop specific setting in some system backend .. 209cdf0e10cSrcweir rtl::OUString aHomeDir; 210cdf0e10cSrcweir osl::Security().getHomeDir( aHomeDir ); 211cdf0e10cSrcweir aRet = aHomeDir + rtl::OUString::createFromAscii("/Desktop"); 212cdf0e10cSrcweir 213cdf0e10cSrcweir // Set path to home directory when there is no /Desktop directory 214cdf0e10cSrcweir osl::Directory aDocumentsDir( aRet ); 215cdf0e10cSrcweir if( osl::FileBase::E_None != aDocumentsDir.open() ) 216cdf0e10cSrcweir aRet = aHomeDir; 217cdf0e10cSrcweir #endif 218cdf0e10cSrcweir 219cdf0e10cSrcweir return aRet; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir //------------------------------------------------------------------------------ 223cdf0e10cSrcweir 224cdf0e10cSrcweir rtl::OUString UpdateCheckConfig::getAllUsersDirectory() 225cdf0e10cSrcweir { 226cdf0e10cSrcweir rtl::OUString aRet; 227cdf0e10cSrcweir 228cdf0e10cSrcweir #ifdef WNT 229cdf0e10cSrcweir WCHAR szPath[MAX_PATH]; 230cdf0e10cSrcweir 231cdf0e10cSrcweir if( ! FAILED( SHGetSpecialFolderPathW( NULL, szPath, CSIDL_COMMON_DOCUMENTS, true ) ) ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir aRet = rtl::OUString( reinterpret_cast< sal_Unicode * >(szPath) ); 234cdf0e10cSrcweir osl::FileBase::RC rc; 235cdf0e10cSrcweir rc = osl::FileBase::getFileURLFromSystemPath( aRet, aRet ); 236cdf0e10cSrcweir } 237cdf0e10cSrcweir #else 238cdf0e10cSrcweir osl::FileBase::getTempDirURL(aRet); 239cdf0e10cSrcweir #endif 240cdf0e10cSrcweir 241cdf0e10cSrcweir return aRet; 242cdf0e10cSrcweir } 243cdf0e10cSrcweir 244cdf0e10cSrcweir //------------------------------------------------------------------------------ 245cdf0e10cSrcweir UpdateCheckConfig::UpdateCheckConfig( const uno::Reference<container::XNameContainer>& xContainer, 246cdf0e10cSrcweir const uno::Reference<container::XNameContainer>& xAvailableUpdates, 247cdf0e10cSrcweir const uno::Reference<container::XNameContainer>& xIgnoredUpdates, 248cdf0e10cSrcweir const ::rtl::Reference< UpdateCheckConfigListener >& rListener ) : 249cdf0e10cSrcweir m_xContainer( xContainer ), 250cdf0e10cSrcweir m_xAvailableUpdates( xAvailableUpdates ), 251cdf0e10cSrcweir m_xIgnoredUpdates( xIgnoredUpdates ), 252cdf0e10cSrcweir m_rListener( rListener ) 253cdf0e10cSrcweir {} 254cdf0e10cSrcweir 255cdf0e10cSrcweir //------------------------------------------------------------------------------ 256cdf0e10cSrcweir UpdateCheckConfig::~UpdateCheckConfig() 257cdf0e10cSrcweir {} 258cdf0e10cSrcweir 259cdf0e10cSrcweir //------------------------------------------------------------------------------ 260cdf0e10cSrcweir 261cdf0e10cSrcweir ::rtl::Reference< UpdateCheckConfig > 262cdf0e10cSrcweir UpdateCheckConfig::get( 263cdf0e10cSrcweir const uno::Reference<uno::XComponentContext>& xContext, 264cdf0e10cSrcweir const ::rtl::Reference< UpdateCheckConfigListener >& rListener) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir if( !xContext.is() ) 267cdf0e10cSrcweir throw uno::RuntimeException( 268cdf0e10cSrcweir UNISTRING( "UpdateCheckConfig: empty component context" ), 269cdf0e10cSrcweir uno::Reference< uno::XInterface >() ); 270cdf0e10cSrcweir 271cdf0e10cSrcweir uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager()); 272cdf0e10cSrcweir 273cdf0e10cSrcweir if( !xServiceManager.is() ) 274cdf0e10cSrcweir throw uno::RuntimeException( 275cdf0e10cSrcweir UNISTRING( "UpdateCheckConfig: unable to obtain service manager from component context" ), 276cdf0e10cSrcweir uno::Reference< uno::XInterface >() ); 277cdf0e10cSrcweir 278cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xConfigProvider( 279cdf0e10cSrcweir xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" ), xContext ), 280cdf0e10cSrcweir uno::UNO_QUERY_THROW); 281cdf0e10cSrcweir 282cdf0e10cSrcweir beans::PropertyValue aProperty; 283cdf0e10cSrcweir aProperty.Name = UNISTRING( "nodepath" ); 284cdf0e10cSrcweir aProperty.Value = uno::makeAny( UNISTRING("org.openoffice.Office.Jobs/Jobs/UpdateCheck/Arguments") ); 285cdf0e10cSrcweir 286cdf0e10cSrcweir uno::Sequence< uno::Any > aArgumentList( 1 ); 287cdf0e10cSrcweir aArgumentList[0] = uno::makeAny( aProperty ); 288cdf0e10cSrcweir 289cdf0e10cSrcweir uno::Reference< container::XNameContainer > xContainer( 290cdf0e10cSrcweir xConfigProvider->createInstanceWithArguments( 291cdf0e10cSrcweir UNISTRING("com.sun.star.configuration.ConfigurationUpdateAccess"), aArgumentList ), 292cdf0e10cSrcweir uno::UNO_QUERY_THROW ); 293cdf0e10cSrcweir 294cdf0e10cSrcweir aProperty.Value = uno::makeAny( UNISTRING("/org.openoffice.Office.ExtensionManager/ExtensionUpdateData/IgnoredUpdates") ); 295cdf0e10cSrcweir aArgumentList[0] = uno::makeAny( aProperty ); 296cdf0e10cSrcweir uno::Reference< container::XNameContainer > xIgnoredExt( xConfigProvider->createInstanceWithArguments( UNISTRING("com.sun.star.configuration.ConfigurationUpdateAccess"), aArgumentList ), uno::UNO_QUERY_THROW ); 297cdf0e10cSrcweir 298cdf0e10cSrcweir aProperty.Value = uno::makeAny( UNISTRING("/org.openoffice.Office.ExtensionManager/ExtensionUpdateData/AvailableUpdates") ); 299cdf0e10cSrcweir aArgumentList[0] = uno::makeAny( aProperty ); 300cdf0e10cSrcweir uno::Reference< container::XNameContainer > xUpdateAvail( xConfigProvider->createInstanceWithArguments( UNISTRING("com.sun.star.configuration.ConfigurationUpdateAccess"), aArgumentList ), uno::UNO_QUERY_THROW ); 301cdf0e10cSrcweir 302cdf0e10cSrcweir return new UpdateCheckConfig( xContainer, xUpdateAvail, xIgnoredExt, rListener ); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir //------------------------------------------------------------------------------ 306cdf0e10cSrcweir 307cdf0e10cSrcweir bool 308cdf0e10cSrcweir UpdateCheckConfig::isAutoCheckEnabled() const 309cdf0e10cSrcweir { 310cdf0e10cSrcweir sal_Bool nValue = sal_False; 311cdf0e10cSrcweir const_cast < UpdateCheckConfig *> (this)->getByName( UNISTRING( AUTOCHECK_ENABLED ) ) >>= nValue; 312cdf0e10cSrcweir return nValue; 313cdf0e10cSrcweir } 314cdf0e10cSrcweir 315cdf0e10cSrcweir //------------------------------------------------------------------------------ 316cdf0e10cSrcweir 317cdf0e10cSrcweir bool 318cdf0e10cSrcweir UpdateCheckConfig::isAutoDownloadEnabled() const 319cdf0e10cSrcweir { 320cdf0e10cSrcweir sal_Bool nValue = sal_False; 321cdf0e10cSrcweir const_cast < UpdateCheckConfig *> (this)->getByName( UNISTRING( AUTODOWNLOAD_ENABLED ) ) >>= nValue; 322cdf0e10cSrcweir return nValue; 323cdf0e10cSrcweir } 324cdf0e10cSrcweir 325cdf0e10cSrcweir //------------------------------------------------------------------------------ 326cdf0e10cSrcweir 327cdf0e10cSrcweir rtl::OUString 328cdf0e10cSrcweir UpdateCheckConfig::getUpdateEntryVersion() const 329cdf0e10cSrcweir { 330cdf0e10cSrcweir rtl::OUString aValue; 331cdf0e10cSrcweir 332cdf0e10cSrcweir // getByName is defined as non const in XNameAccess 333cdf0e10cSrcweir const_cast < UpdateCheckConfig *> (this)->getByName( UNISTRING( OLD_VERSION ) ) >>= aValue; 334cdf0e10cSrcweir 335cdf0e10cSrcweir return aValue; 336cdf0e10cSrcweir } 337cdf0e10cSrcweir 338cdf0e10cSrcweir //------------------------------------------------------------------------------ 339cdf0e10cSrcweir 340cdf0e10cSrcweir sal_Int64 341cdf0e10cSrcweir UpdateCheckConfig::getLastChecked() const 342cdf0e10cSrcweir { 343cdf0e10cSrcweir sal_Int64 nValue = 0; 344cdf0e10cSrcweir 345cdf0e10cSrcweir // getByName is defined as non const in XNameAccess 346cdf0e10cSrcweir const_cast < UpdateCheckConfig *> (this)->getByName( UNISTRING( LAST_CHECK ) ) >>= nValue; 347cdf0e10cSrcweir 348cdf0e10cSrcweir return nValue; 349cdf0e10cSrcweir } 350cdf0e10cSrcweir 351cdf0e10cSrcweir //------------------------------------------------------------------------------ 352cdf0e10cSrcweir 353cdf0e10cSrcweir sal_Int64 354cdf0e10cSrcweir UpdateCheckConfig::getCheckInterval() const 355cdf0e10cSrcweir { 356cdf0e10cSrcweir sal_Int64 nValue = 0; 357cdf0e10cSrcweir 358cdf0e10cSrcweir // getByName is defined as non const in XNameAccess 359cdf0e10cSrcweir const_cast < UpdateCheckConfig *> (this)->getByName( UNISTRING( CHECK_INTERVAL ) ) >>= nValue; 360cdf0e10cSrcweir 361cdf0e10cSrcweir return nValue; 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir //------------------------------------------------------------------------------ 365cdf0e10cSrcweir 366cdf0e10cSrcweir rtl::OUString 367cdf0e10cSrcweir UpdateCheckConfig::getLocalFileName() const 368cdf0e10cSrcweir { 369cdf0e10cSrcweir rtl::OUString aName = UNISTRING(LOCAL_FILE); 370cdf0e10cSrcweir rtl::OUString aRet; 371cdf0e10cSrcweir 372cdf0e10cSrcweir if( m_xContainer->hasByName(aName) ) 373cdf0e10cSrcweir m_xContainer->getByName(aName) >>= aRet; 374cdf0e10cSrcweir 375cdf0e10cSrcweir return aRet; 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir //------------------------------------------------------------------------------ 379cdf0e10cSrcweir 380cdf0e10cSrcweir rtl::OUString 381cdf0e10cSrcweir UpdateCheckConfig::getDownloadDestination() const 382cdf0e10cSrcweir { 383cdf0e10cSrcweir rtl::OUString aName = UNISTRING(DOWNLOAD_DESTINATION); 384cdf0e10cSrcweir rtl::OUString aRet; 385cdf0e10cSrcweir 386cdf0e10cSrcweir const_cast <UpdateCheckConfig *> (this)->getByName(aName) >>= aRet; 387cdf0e10cSrcweir 388cdf0e10cSrcweir return aRet; 389cdf0e10cSrcweir } 390cdf0e10cSrcweir 391cdf0e10cSrcweir //------------------------------------------------------------------------------ 392cdf0e10cSrcweir 393cdf0e10cSrcweir void 394cdf0e10cSrcweir UpdateCheckConfig::storeLocalFileName(const rtl::OUString& rLocalFileName, sal_Int64 nFileSize) 395cdf0e10cSrcweir { 396cdf0e10cSrcweir const sal_uInt8 nItems = 2; 397cdf0e10cSrcweir const rtl::OUString aNameList[nItems] = { UNISTRING(LOCAL_FILE), UNISTRING(DOWNLOAD_SIZE) }; 398cdf0e10cSrcweir const uno::Any aValueList[nItems] = { uno::makeAny(rLocalFileName), uno::makeAny(nFileSize) }; 399cdf0e10cSrcweir 400cdf0e10cSrcweir for( sal_uInt8 i=0; i < nItems; ++i ) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir if( m_xContainer->hasByName(aNameList[i]) ) 403cdf0e10cSrcweir m_xContainer->replaceByName(aNameList[i], aValueList[i]); 404cdf0e10cSrcweir else 405cdf0e10cSrcweir m_xContainer->insertByName(aNameList[i], aValueList[i]); 406cdf0e10cSrcweir } 407cdf0e10cSrcweir 408cdf0e10cSrcweir commitChanges(); 409cdf0e10cSrcweir } 410cdf0e10cSrcweir 411cdf0e10cSrcweir //------------------------------------------------------------------------------ 412cdf0e10cSrcweir 413cdf0e10cSrcweir void 414cdf0e10cSrcweir UpdateCheckConfig::clearLocalFileName() 415cdf0e10cSrcweir { 416cdf0e10cSrcweir const sal_uInt8 nItems = 2; 417cdf0e10cSrcweir const rtl::OUString aNameList[nItems] = { UNISTRING(LOCAL_FILE), UNISTRING(DOWNLOAD_SIZE) }; 418cdf0e10cSrcweir 419cdf0e10cSrcweir for( sal_uInt8 i=0; i < nItems; ++i ) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir if( m_xContainer->hasByName(aNameList[i]) ) 422cdf0e10cSrcweir m_xContainer->removeByName(aNameList[i]); 423cdf0e10cSrcweir } 424cdf0e10cSrcweir 425cdf0e10cSrcweir commitChanges(); 426cdf0e10cSrcweir } 427cdf0e10cSrcweir 428cdf0e10cSrcweir //------------------------------------------------------------------------------ 429cdf0e10cSrcweir 430cdf0e10cSrcweir void 431cdf0e10cSrcweir UpdateCheckConfig::storeDownloadPaused(bool paused) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir replaceByName(UNISTRING(DOWNLOAD_PAUSED) , uno::makeAny(paused)); 434cdf0e10cSrcweir commitChanges(); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir //------------------------------------------------------------------------------ 438cdf0e10cSrcweir 439cdf0e10cSrcweir void 440cdf0e10cSrcweir UpdateCheckConfig::updateLastChecked() 441cdf0e10cSrcweir { 442cdf0e10cSrcweir TimeValue systime; 443cdf0e10cSrcweir osl_getSystemTime(&systime); 444cdf0e10cSrcweir 445cdf0e10cSrcweir sal_Int64 lastCheck = systime.Seconds; 446cdf0e10cSrcweir 447cdf0e10cSrcweir replaceByName(UNISTRING(LAST_CHECK), uno::makeAny(lastCheck)); 448cdf0e10cSrcweir } 449cdf0e10cSrcweir 450cdf0e10cSrcweir //------------------------------------------------------------------------------ 451cdf0e10cSrcweir 452cdf0e10cSrcweir void 453cdf0e10cSrcweir UpdateCheckConfig::storeUpdateFound( const UpdateInfo& rInfo, const rtl::OUString& aCurrentBuild) 454cdf0e10cSrcweir 455cdf0e10cSrcweir { 456cdf0e10cSrcweir bool autoDownloadEnabled = isAutoDownloadEnabled(); 457cdf0e10cSrcweir 458cdf0e10cSrcweir uno::Any aValues[nUpdateEntryProperties] = 459cdf0e10cSrcweir { 460cdf0e10cSrcweir uno::makeAny(rInfo.Version), 461cdf0e10cSrcweir uno::makeAny(rInfo.BuildId), 462cdf0e10cSrcweir uno::makeAny(rInfo.Description), 463cdf0e10cSrcweir uno::makeAny(rInfo.Sources[0].URL), 464cdf0e10cSrcweir uno::makeAny(rInfo.Sources[0].IsDirect ? sal_True : sal_False), 465cdf0e10cSrcweir uno::makeAny(getReleaseNote(rInfo, 1, autoDownloadEnabled) ), 466cdf0e10cSrcweir uno::makeAny(getReleaseNote(rInfo, 2, autoDownloadEnabled) ), 467cdf0e10cSrcweir uno::makeAny(getReleaseNote(rInfo, 3, autoDownloadEnabled) ), 468cdf0e10cSrcweir uno::makeAny(getReleaseNote(rInfo, 4, autoDownloadEnabled) ), 469cdf0e10cSrcweir uno::makeAny(getReleaseNote(rInfo, 5, autoDownloadEnabled) ), 470cdf0e10cSrcweir uno::makeAny(aCurrentBuild) 471cdf0e10cSrcweir }; 472cdf0e10cSrcweir 473cdf0e10cSrcweir rtl::OUString aName; 474cdf0e10cSrcweir for( sal_uInt32 n=0; n < nUpdateEntryProperties; ++n ) 475cdf0e10cSrcweir { 476cdf0e10cSrcweir aName = rtl::OUString::createFromAscii(aUpdateEntryProperties[n]); 477cdf0e10cSrcweir 478cdf0e10cSrcweir if( m_xContainer->hasByName(aName) ) 479cdf0e10cSrcweir m_xContainer->replaceByName(aName, aValues[n]); 480cdf0e10cSrcweir else 481cdf0e10cSrcweir m_xContainer->insertByName(aName,aValues[n]); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir 484cdf0e10cSrcweir commitChanges(); 485cdf0e10cSrcweir } 486cdf0e10cSrcweir 487cdf0e10cSrcweir //------------------------------------------------------------------------------ 488cdf0e10cSrcweir 489cdf0e10cSrcweir void 490cdf0e10cSrcweir UpdateCheckConfig::clearUpdateFound() 491cdf0e10cSrcweir { 492cdf0e10cSrcweir rtl::OUString aName; 493cdf0e10cSrcweir 494cdf0e10cSrcweir for( sal_uInt32 n=0; n < nUpdateEntryProperties; ++n ) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir aName = rtl::OUString::createFromAscii(aUpdateEntryProperties[n]); 497cdf0e10cSrcweir 498cdf0e10cSrcweir try { 499cdf0e10cSrcweir if( m_xContainer->hasByName(aName) ) 500cdf0e10cSrcweir m_xContainer->removeByName(aName); 501cdf0e10cSrcweir } catch(const lang::WrappedTargetException& ) { 502cdf0e10cSrcweir // Can not remove value, probably in share layer 503cdf0e10cSrcweir OSL_ASSERT(false); 504cdf0e10cSrcweir m_xContainer->replaceByName(aName, uno::makeAny(rtl::OUString())); 505cdf0e10cSrcweir } 506cdf0e10cSrcweir } 507cdf0e10cSrcweir 508cdf0e10cSrcweir /* As we have removed UpdateVersionFound from the shared configuration 509cdf0e10cSrcweir * existing entries in the user layer do not have a oor operation and 510cdf0e10cSrcweir * thus are completly ignored (which also means they can not be removed). 511cdf0e10cSrcweir */ 512cdf0e10cSrcweir 513cdf0e10cSrcweir commitChanges(); 514cdf0e10cSrcweir } 515cdf0e10cSrcweir 516cdf0e10cSrcweir //------------------------------------------------------------------------------ 517cdf0e10cSrcweir 518cdf0e10cSrcweir uno::Sequence< rtl::OUString > 519cdf0e10cSrcweir UpdateCheckConfig::getServiceNames() 520cdf0e10cSrcweir { 521cdf0e10cSrcweir uno::Sequence< rtl::OUString > aServiceList(1); 522cdf0e10cSrcweir aServiceList[0] = UNISTRING( "com.sun.star.setup.UpdateCheckConfig"); 523cdf0e10cSrcweir return aServiceList; 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir //------------------------------------------------------------------------------ 527cdf0e10cSrcweir 528cdf0e10cSrcweir rtl::OUString 529cdf0e10cSrcweir UpdateCheckConfig::getImplName() 530cdf0e10cSrcweir { 531cdf0e10cSrcweir return UNISTRING( "vnd.sun.UpdateCheckConfig"); 532cdf0e10cSrcweir } 533cdf0e10cSrcweir 534cdf0e10cSrcweir //------------------------------------------------------------------------------ 535cdf0e10cSrcweir 536cdf0e10cSrcweir uno::Type SAL_CALL 537cdf0e10cSrcweir UpdateCheckConfig::getElementType() throw (uno::RuntimeException) 538cdf0e10cSrcweir { 539cdf0e10cSrcweir return m_xContainer->getElementType(); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir 542cdf0e10cSrcweir //------------------------------------------------------------------------------ 543cdf0e10cSrcweir 544cdf0e10cSrcweir sal_Bool SAL_CALL 545cdf0e10cSrcweir UpdateCheckConfig::hasElements() throw (uno::RuntimeException) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir return m_xContainer->hasElements(); 548cdf0e10cSrcweir } 549cdf0e10cSrcweir 550cdf0e10cSrcweir //------------------------------------------------------------------------------ 551cdf0e10cSrcweir 552cdf0e10cSrcweir uno::Any SAL_CALL 553cdf0e10cSrcweir UpdateCheckConfig::getByName( const ::rtl::OUString& aName ) 554cdf0e10cSrcweir throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) 555cdf0e10cSrcweir { 556cdf0e10cSrcweir uno::Any aValue = m_xContainer->getByName( aName ); 557cdf0e10cSrcweir 558cdf0e10cSrcweir // Provide dynamic default value 559cdf0e10cSrcweir if( aName.equalsAscii(DOWNLOAD_DESTINATION) ) 560cdf0e10cSrcweir { 561cdf0e10cSrcweir rtl::OUString aStr; 562cdf0e10cSrcweir aValue >>= aStr; 563cdf0e10cSrcweir 564cdf0e10cSrcweir if( aStr.getLength() == 0 ) 565cdf0e10cSrcweir aValue = uno::makeAny(getDesktopDirectory()); 566cdf0e10cSrcweir } 567cdf0e10cSrcweir 568cdf0e10cSrcweir return aValue; 569cdf0e10cSrcweir } 570cdf0e10cSrcweir 571cdf0e10cSrcweir //------------------------------------------------------------------------------ 572cdf0e10cSrcweir 573cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL 574cdf0e10cSrcweir UpdateCheckConfig::getElementNames( ) throw (uno::RuntimeException) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir return m_xContainer->getElementNames(); 577cdf0e10cSrcweir } 578cdf0e10cSrcweir 579cdf0e10cSrcweir //------------------------------------------------------------------------------ 580cdf0e10cSrcweir 581cdf0e10cSrcweir sal_Bool SAL_CALL 582cdf0e10cSrcweir UpdateCheckConfig::hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException) 583cdf0e10cSrcweir { 584cdf0e10cSrcweir return m_xContainer->hasByName( aName ); 585cdf0e10cSrcweir } 586cdf0e10cSrcweir 587cdf0e10cSrcweir //------------------------------------------------------------------------------ 588cdf0e10cSrcweir 589cdf0e10cSrcweir void SAL_CALL 590cdf0e10cSrcweir UpdateCheckConfig::replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement ) 591cdf0e10cSrcweir throw (lang::IllegalArgumentException, container::NoSuchElementException, 592cdf0e10cSrcweir lang::WrappedTargetException, uno::RuntimeException) 593cdf0e10cSrcweir { 594cdf0e10cSrcweir return m_xContainer->replaceByName( aName, aElement ); 595cdf0e10cSrcweir } 596cdf0e10cSrcweir 597cdf0e10cSrcweir //------------------------------------------------------------------------------ 598cdf0e10cSrcweir // XChangesBatch 599cdf0e10cSrcweir 600cdf0e10cSrcweir void SAL_CALL 601cdf0e10cSrcweir UpdateCheckConfig::commitChanges() 602cdf0e10cSrcweir throw (lang::WrappedTargetException, uno::RuntimeException) 603cdf0e10cSrcweir { 604cdf0e10cSrcweir uno::Reference< util::XChangesBatch > xChangesBatch(m_xContainer, uno::UNO_QUERY); 605cdf0e10cSrcweir if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() ) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir util::ChangesSet aChangesSet = xChangesBatch->getPendingChanges(); 608cdf0e10cSrcweir xChangesBatch->commitChanges(); 609cdf0e10cSrcweir 610cdf0e10cSrcweir if( m_rListener.is() ) 611cdf0e10cSrcweir { 612cdf0e10cSrcweir const sal_Int32 nChanges = aChangesSet.getLength(); 613cdf0e10cSrcweir rtl::OUString aString; 614cdf0e10cSrcweir 615cdf0e10cSrcweir for( sal_Int32 i=0; i<nChanges; ++i ) 616cdf0e10cSrcweir { 617cdf0e10cSrcweir aChangesSet[i].Accessor >>= aString; 618cdf0e10cSrcweir 619cdf0e10cSrcweir // FIXME: use non IgnoreAsciiCase version as soon as it becomes available 620cdf0e10cSrcweir if( aString.endsWithIgnoreAsciiCaseAsciiL(AUTOCHECK_ENABLED "']", sizeof(AUTOCHECK_ENABLED)+1) ) 621cdf0e10cSrcweir { 622cdf0e10cSrcweir sal_Bool bEnabled = sal_False; 623cdf0e10cSrcweir aChangesSet[i].Element >>= bEnabled; 624cdf0e10cSrcweir m_rListener->autoCheckStatusChanged(sal_True == bEnabled); 625cdf0e10cSrcweir } 626cdf0e10cSrcweir // FIXME: use non IgnoreAsciiCase version as soon as it becomes available 627cdf0e10cSrcweir else if( aString.endsWithIgnoreAsciiCaseAsciiL(CHECK_INTERVAL "']", sizeof(CHECK_INTERVAL)+1) ) 628cdf0e10cSrcweir { 629cdf0e10cSrcweir m_rListener->autoCheckIntervalChanged(); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir } 632cdf0e10cSrcweir } 633cdf0e10cSrcweir } 634cdf0e10cSrcweir 635cdf0e10cSrcweir xChangesBatch = uno::Reference< util::XChangesBatch > ( m_xAvailableUpdates, uno::UNO_QUERY ); 636cdf0e10cSrcweir if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() ) 637cdf0e10cSrcweir { 638cdf0e10cSrcweir util::ChangesSet aChangesSet = xChangesBatch->getPendingChanges(); 639cdf0e10cSrcweir xChangesBatch->commitChanges(); 640cdf0e10cSrcweir } 641cdf0e10cSrcweir xChangesBatch = uno::Reference< util::XChangesBatch > ( m_xIgnoredUpdates, uno::UNO_QUERY ); 642cdf0e10cSrcweir if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() ) 643cdf0e10cSrcweir { 644cdf0e10cSrcweir util::ChangesSet aChangesSet = xChangesBatch->getPendingChanges(); 645cdf0e10cSrcweir xChangesBatch->commitChanges(); 646cdf0e10cSrcweir } 647cdf0e10cSrcweir } 648cdf0e10cSrcweir 649cdf0e10cSrcweir //------------------------------------------------------------------------------ 650cdf0e10cSrcweir 651cdf0e10cSrcweir sal_Bool SAL_CALL 652cdf0e10cSrcweir UpdateCheckConfig::hasPendingChanges( ) throw (uno::RuntimeException) 653cdf0e10cSrcweir { 654cdf0e10cSrcweir uno::Reference< util::XChangesBatch > xChangesBatch(m_xContainer, uno::UNO_QUERY); 655cdf0e10cSrcweir if( xChangesBatch.is() ) 656cdf0e10cSrcweir return xChangesBatch->hasPendingChanges(); 657cdf0e10cSrcweir 658cdf0e10cSrcweir return sal_False; 659cdf0e10cSrcweir } 660cdf0e10cSrcweir 661cdf0e10cSrcweir //------------------------------------------------------------------------------ 662cdf0e10cSrcweir 663cdf0e10cSrcweir uno::Sequence< util::ElementChange > SAL_CALL 664cdf0e10cSrcweir UpdateCheckConfig::getPendingChanges( ) throw (uno::RuntimeException) 665cdf0e10cSrcweir { 666cdf0e10cSrcweir uno::Reference< util::XChangesBatch > xChangesBatch(m_xContainer, uno::UNO_QUERY); 667cdf0e10cSrcweir if( xChangesBatch.is() ) 668cdf0e10cSrcweir return xChangesBatch->getPendingChanges(); 669cdf0e10cSrcweir 670cdf0e10cSrcweir return uno::Sequence< util::ElementChange >(); 671cdf0e10cSrcweir } 672cdf0e10cSrcweir 673cdf0e10cSrcweir //------------------------------------------------------------------------------ 674cdf0e10cSrcweir bool UpdateCheckConfig::storeExtensionVersion( const rtl::OUString& rExtensionName, 675cdf0e10cSrcweir const rtl::OUString& rVersion ) 676cdf0e10cSrcweir { 677cdf0e10cSrcweir bool bNotify = true; 678cdf0e10cSrcweir 679cdf0e10cSrcweir if ( m_xAvailableUpdates->hasByName( rExtensionName ) ) 680cdf0e10cSrcweir uno::Reference< beans::XPropertySet >( m_xAvailableUpdates->getByName( rExtensionName ), uno::UNO_QUERY_THROW )->setPropertyValue( PROPERTY_VERSION, uno::Any( rVersion ) ); 681cdf0e10cSrcweir else 682cdf0e10cSrcweir { 683cdf0e10cSrcweir uno::Reference< beans::XPropertySet > elem( uno::Reference< lang::XSingleServiceFactory >( m_xAvailableUpdates, uno::UNO_QUERY_THROW )->createInstance(), uno::UNO_QUERY_THROW ); 684cdf0e10cSrcweir elem->setPropertyValue( PROPERTY_VERSION, uno::Any( rVersion ) ); 685cdf0e10cSrcweir m_xAvailableUpdates->insertByName( rExtensionName, uno::Any( elem ) ); 686cdf0e10cSrcweir } 687cdf0e10cSrcweir 688cdf0e10cSrcweir if ( m_xIgnoredUpdates->hasByName( rExtensionName ) ) 689cdf0e10cSrcweir { 690cdf0e10cSrcweir ::rtl::OUString aIgnoredVersion; 691cdf0e10cSrcweir uno::Any aValue( uno::Reference< beans::XPropertySet >( m_xIgnoredUpdates->getByName( rExtensionName ), uno::UNO_QUERY_THROW )->getPropertyValue( PROPERTY_VERSION ) ); 692cdf0e10cSrcweir aValue >>= aIgnoredVersion; 693cdf0e10cSrcweir if ( aIgnoredVersion.getLength() == 0 ) // no version means ignore all updates 694cdf0e10cSrcweir bNotify = false; 695cdf0e10cSrcweir else if ( aIgnoredVersion == rVersion ) // the user wanted to ignore this update 696cdf0e10cSrcweir bNotify = false; 697cdf0e10cSrcweir } 698cdf0e10cSrcweir 699cdf0e10cSrcweir commitChanges(); 700cdf0e10cSrcweir 701cdf0e10cSrcweir return bNotify; 702cdf0e10cSrcweir } 703cdf0e10cSrcweir 704cdf0e10cSrcweir //------------------------------------------------------------------------------ 705cdf0e10cSrcweir bool UpdateCheckConfig::checkExtensionVersion( const rtl::OUString& rExtensionName, 706cdf0e10cSrcweir const rtl::OUString& rVersion ) 707cdf0e10cSrcweir { 708cdf0e10cSrcweir if ( m_xAvailableUpdates->hasByName( rExtensionName ) ) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir ::rtl::OUString aStoredVersion; 711cdf0e10cSrcweir uno::Any aValue( uno::Reference< beans::XPropertySet >( m_xAvailableUpdates->getByName( rExtensionName ), uno::UNO_QUERY_THROW )->getPropertyValue( PROPERTY_VERSION ) ); 712cdf0e10cSrcweir aValue >>= aStoredVersion; 713cdf0e10cSrcweir 714cdf0e10cSrcweir if ( m_xIgnoredUpdates->hasByName( rExtensionName ) ) 715cdf0e10cSrcweir { 716cdf0e10cSrcweir ::rtl::OUString aIgnoredVersion; 717cdf0e10cSrcweir uno::Any aValue2( uno::Reference< beans::XPropertySet >( m_xIgnoredUpdates->getByName( rExtensionName ), uno::UNO_QUERY_THROW )->getPropertyValue( PROPERTY_VERSION ) ); 718cdf0e10cSrcweir aValue2 >>= aIgnoredVersion; 719cdf0e10cSrcweir if ( aIgnoredVersion.getLength() == 0 ) // no version means ignore all updates 720cdf0e10cSrcweir return false; 721cdf0e10cSrcweir else if ( aIgnoredVersion == aStoredVersion ) // the user wanted to ignore this update 722cdf0e10cSrcweir return false; 723cdf0e10cSrcweir // TODO: else delete ignored entry? 724cdf0e10cSrcweir } 725cdf0e10cSrcweir if ( isVersionGreater( rVersion, aStoredVersion ) ) 726cdf0e10cSrcweir return true; 727cdf0e10cSrcweir else 728cdf0e10cSrcweir { 729cdf0e10cSrcweir m_xAvailableUpdates->removeByName( rExtensionName ); 730cdf0e10cSrcweir commitChanges(); 731cdf0e10cSrcweir } 732cdf0e10cSrcweir } 733cdf0e10cSrcweir 734cdf0e10cSrcweir return false; 735cdf0e10cSrcweir } 736cdf0e10cSrcweir 737cdf0e10cSrcweir //------------------------------------------------------------------------------ 738cdf0e10cSrcweir rtl::OUString UpdateCheckConfig::getSubVersion( const rtl::OUString& rVersion, 739cdf0e10cSrcweir sal_Int32 *nIndex ) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir while ( *nIndex < rVersion.getLength() && rVersion[*nIndex] == '0') 742cdf0e10cSrcweir { 743cdf0e10cSrcweir ++*nIndex; 744cdf0e10cSrcweir } 745cdf0e10cSrcweir 746cdf0e10cSrcweir return rVersion.getToken( 0, '.', *nIndex ); 747cdf0e10cSrcweir } 748cdf0e10cSrcweir 749cdf0e10cSrcweir //------------------------------------------------------------------------------ 750cdf0e10cSrcweir // checks if the second version string is greater than the first one 751cdf0e10cSrcweir 752cdf0e10cSrcweir bool UpdateCheckConfig::isVersionGreater( const rtl::OUString& rVersion1, 753cdf0e10cSrcweir const rtl::OUString& rVersion2 ) 754cdf0e10cSrcweir { 755cdf0e10cSrcweir for ( sal_Int32 i1 = 0, i2 = 0; i1 >= 0 || i2 >= 0; ) 756cdf0e10cSrcweir { 757cdf0e10cSrcweir ::rtl::OUString sSub1( getSubVersion( rVersion1, &i1 ) ); 758cdf0e10cSrcweir ::rtl::OUString sSub2( getSubVersion( rVersion2, &i2 ) ); 759cdf0e10cSrcweir 760cdf0e10cSrcweir if ( sSub1.getLength() < sSub2.getLength() ) { 761cdf0e10cSrcweir return true; 762cdf0e10cSrcweir } else if ( sSub1.getLength() > sSub2.getLength() ) { 763cdf0e10cSrcweir return false; 764cdf0e10cSrcweir } else if ( sSub1 < sSub2 ) { 765cdf0e10cSrcweir return true; 766cdf0e10cSrcweir } else if ( sSub1 > sSub2 ) { 767cdf0e10cSrcweir return false; 768cdf0e10cSrcweir } 769cdf0e10cSrcweir } 770cdf0e10cSrcweir return false; 771cdf0e10cSrcweir } 772cdf0e10cSrcweir 773cdf0e10cSrcweir //------------------------------------------------------------------------------ 774cdf0e10cSrcweir //------------------------------------------------------------------------------ 775cdf0e10cSrcweir //------------------------------------------------------------------------------ 776cdf0e10cSrcweir 777cdf0e10cSrcweir rtl::OUString SAL_CALL 778cdf0e10cSrcweir UpdateCheckConfig::getImplementationName() throw (uno::RuntimeException) 779cdf0e10cSrcweir { 780cdf0e10cSrcweir return getImplName(); 781cdf0e10cSrcweir } 782cdf0e10cSrcweir 783cdf0e10cSrcweir //------------------------------------------------------------------------------ 784cdf0e10cSrcweir 785cdf0e10cSrcweir sal_Bool SAL_CALL 786cdf0e10cSrcweir UpdateCheckConfig::supportsService(rtl::OUString const & serviceName) 787cdf0e10cSrcweir throw (uno::RuntimeException) 788cdf0e10cSrcweir { 789cdf0e10cSrcweir uno::Sequence< rtl::OUString > aServiceNameList = getServiceNames(); 790cdf0e10cSrcweir 791cdf0e10cSrcweir for( sal_Int32 n=0; n < aServiceNameList.getLength(); n++ ) 792cdf0e10cSrcweir if( aServiceNameList[n].equals(serviceName) ) 793cdf0e10cSrcweir return sal_True; 794cdf0e10cSrcweir 795cdf0e10cSrcweir return sal_False; 796cdf0e10cSrcweir } 797cdf0e10cSrcweir 798cdf0e10cSrcweir //------------------------------------------------------------------------------ 799cdf0e10cSrcweir 800cdf0e10cSrcweir uno::Sequence< rtl::OUString > SAL_CALL 801cdf0e10cSrcweir UpdateCheckConfig::getSupportedServiceNames() throw (uno::RuntimeException) 802cdf0e10cSrcweir { 803cdf0e10cSrcweir return getServiceNames(); 804cdf0e10cSrcweir } 805cdf0e10cSrcweir 806cdf0e10cSrcweir 807