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