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 // MARKER(update_precomp.py): autogen include statement, do not remove 28*cdf0e10cSrcweir #include "precompiled_desktop.hxx" 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include "osl/file.hxx" 31*cdf0e10cSrcweir #include "osl/mutex.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <rtl/bootstrap.hxx> 34*cdf0e10cSrcweir #include <rtl/ustring.hxx> 35*cdf0e10cSrcweir #include <rtl/logfile.hxx> 36*cdf0e10cSrcweir #include "cppuhelper/compbase3.hxx" 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include "vcl/wrkwin.hxx" 39*cdf0e10cSrcweir #include "vcl/timer.hxx" 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <unotools/configmgr.hxx> 42*cdf0e10cSrcweir #include "toolkit/helper/vclunohelper.hxx" 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 45*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 46*cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx> 47*cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandEnvironment.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 50*cdf0e10cSrcweir #include "com/sun/star/deployment/XPackage.hpp" 51*cdf0e10cSrcweir #include "com/sun/star/deployment/ExtensionManager.hpp" 52*cdf0e10cSrcweir #include "com/sun/star/deployment/LicenseException.hpp" 53*cdf0e10cSrcweir #include "com/sun/star/deployment/ui/LicenseDialog.hpp" 54*cdf0e10cSrcweir #include <com/sun/star/task/XJob.hpp> 55*cdf0e10cSrcweir #include <com/sun/star/task/XJobExecutor.hpp> 56*cdf0e10cSrcweir #include <com/sun/star/task/XInteractionApprove.hpp> 57*cdf0e10cSrcweir #include <com/sun/star/task/XInteractionAbort.hpp> 58*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 59*cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp" 60*cdf0e10cSrcweir #include <com/sun/star/util/XChangesBatch.hpp> 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir #include "app.hxx" 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #include "../deployment/inc/dp_misc.h" 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir using rtl::OUString; 67*cdf0e10cSrcweir using namespace desktop; 68*cdf0e10cSrcweir using namespace com::sun::star; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir #define UNISTRING(s) OUString(RTL_CONSTASCII_USTRINGPARAM(s)) 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir namespace 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir //For use with XExtensionManager.synchronize 75*cdf0e10cSrcweir class SilentCommandEnv 76*cdf0e10cSrcweir : public ::cppu::WeakImplHelper3< ucb::XCommandEnvironment, 77*cdf0e10cSrcweir task::XInteractionHandler, 78*cdf0e10cSrcweir ucb::XProgressHandler > 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir Desktop *mpDesktop; 81*cdf0e10cSrcweir sal_Int32 mnLevel; 82*cdf0e10cSrcweir sal_Int32 mnProgress; 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir public: 85*cdf0e10cSrcweir SilentCommandEnv( Desktop* pDesktop ); 86*cdf0e10cSrcweir virtual ~SilentCommandEnv(); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir // XCommandEnvironment 89*cdf0e10cSrcweir virtual uno::Reference<task::XInteractionHandler > SAL_CALL 90*cdf0e10cSrcweir getInteractionHandler() throw (uno::RuntimeException); 91*cdf0e10cSrcweir virtual uno::Reference<ucb::XProgressHandler > 92*cdf0e10cSrcweir SAL_CALL getProgressHandler() throw (uno::RuntimeException); 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir // XInteractionHandler 95*cdf0e10cSrcweir virtual void SAL_CALL handle( 96*cdf0e10cSrcweir uno::Reference<task::XInteractionRequest > const & xRequest ) 97*cdf0e10cSrcweir throw (uno::RuntimeException); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir // XProgressHandler 100*cdf0e10cSrcweir virtual void SAL_CALL push( uno::Any const & Status ) 101*cdf0e10cSrcweir throw (uno::RuntimeException); 102*cdf0e10cSrcweir virtual void SAL_CALL update( uno::Any const & Status ) 103*cdf0e10cSrcweir throw (uno::RuntimeException); 104*cdf0e10cSrcweir virtual void SAL_CALL pop() throw (uno::RuntimeException); 105*cdf0e10cSrcweir }; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir //----------------------------------------------------------------------------- 108*cdf0e10cSrcweir SilentCommandEnv::SilentCommandEnv( Desktop* pDesktop ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir mpDesktop = pDesktop; 111*cdf0e10cSrcweir mnLevel = 0; 112*cdf0e10cSrcweir mnProgress = 25; 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir //----------------------------------------------------------------------------- 116*cdf0e10cSrcweir SilentCommandEnv::~SilentCommandEnv() 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir mpDesktop->SetSplashScreenText( OUString() ); 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir //----------------------------------------------------------------------------- 122*cdf0e10cSrcweir Reference<task::XInteractionHandler> SilentCommandEnv::getInteractionHandler() 123*cdf0e10cSrcweir throw (uno::RuntimeException) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir return this; 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir //----------------------------------------------------------------------------- 129*cdf0e10cSrcweir Reference<ucb::XProgressHandler> SilentCommandEnv::getProgressHandler() 130*cdf0e10cSrcweir throw (uno::RuntimeException) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir return this; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir //----------------------------------------------------------------------------- 136*cdf0e10cSrcweir // XInteractionHandler 137*cdf0e10cSrcweir void SilentCommandEnv::handle( Reference< task::XInteractionRequest> const & xRequest ) 138*cdf0e10cSrcweir throw (uno::RuntimeException) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir deployment::LicenseException licExc; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir uno::Any request( xRequest->getRequest() ); 143*cdf0e10cSrcweir bool bApprove = true; 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir if ( request >>= licExc ) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir uno::Reference< uno::XComponentContext > xContext = comphelper_getProcessComponentContext(); 148*cdf0e10cSrcweir uno::Reference< ui::dialogs::XExecutableDialog > xDialog( 149*cdf0e10cSrcweir deployment::ui::LicenseDialog::create( 150*cdf0e10cSrcweir xContext, VCLUnoHelper::GetInterface( NULL ), 151*cdf0e10cSrcweir licExc.ExtensionName, licExc.Text ) ); 152*cdf0e10cSrcweir sal_Int16 res = xDialog->execute(); 153*cdf0e10cSrcweir if ( res == ui::dialogs::ExecutableDialogResults::CANCEL ) 154*cdf0e10cSrcweir bApprove = false; 155*cdf0e10cSrcweir else if ( res == ui::dialogs::ExecutableDialogResults::OK ) 156*cdf0e10cSrcweir bApprove = true; 157*cdf0e10cSrcweir else 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir OSL_ASSERT(0); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir // We approve everything here 164*cdf0e10cSrcweir uno::Sequence< Reference< task::XInteractionContinuation > > conts( xRequest->getContinuations() ); 165*cdf0e10cSrcweir Reference< task::XInteractionContinuation > const * pConts = conts.getConstArray(); 166*cdf0e10cSrcweir sal_Int32 len = conts.getLength(); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir for ( sal_Int32 pos = 0; pos < len; ++pos ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir if ( bApprove ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir uno::Reference< task::XInteractionApprove > xInteractionApprove( pConts[ pos ], uno::UNO_QUERY ); 173*cdf0e10cSrcweir if ( xInteractionApprove.is() ) 174*cdf0e10cSrcweir xInteractionApprove->select(); 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir else 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir uno::Reference< task::XInteractionAbort > xInteractionAbort( pConts[ pos ], uno::UNO_QUERY ); 179*cdf0e10cSrcweir if ( xInteractionAbort.is() ) 180*cdf0e10cSrcweir xInteractionAbort->select(); 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir //----------------------------------------------------------------------------- 186*cdf0e10cSrcweir // XProgressHandler 187*cdf0e10cSrcweir void SilentCommandEnv::push( uno::Any const & rStatus ) 188*cdf0e10cSrcweir throw (uno::RuntimeException) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir OUString sText; 191*cdf0e10cSrcweir mnLevel += 1; 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir if ( rStatus.hasValue() && ( rStatus >>= sText) ) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir if ( mnLevel <= 3 ) 196*cdf0e10cSrcweir mpDesktop->SetSplashScreenText( sText ); 197*cdf0e10cSrcweir else 198*cdf0e10cSrcweir mpDesktop->SetSplashScreenProgress( ++mnProgress ); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir //----------------------------------------------------------------------------- 203*cdf0e10cSrcweir void SilentCommandEnv::update( uno::Any const & rStatus ) 204*cdf0e10cSrcweir throw (uno::RuntimeException) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir OUString sText; 207*cdf0e10cSrcweir if ( rStatus.hasValue() && ( rStatus >>= sText) ) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir mpDesktop->SetSplashScreenText( sText ); 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir //----------------------------------------------------------------------------- 214*cdf0e10cSrcweir void SilentCommandEnv::pop() throw (uno::RuntimeException) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir mnLevel -= 1; 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir } // end namespace 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir //----------------------------------------------------------------------------- 222*cdf0e10cSrcweir //----------------------------------------------------------------------------- 223*cdf0e10cSrcweir //----------------------------------------------------------------------------- 224*cdf0e10cSrcweir static const OUString sConfigSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); 225*cdf0e10cSrcweir static const OUString sAccessSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ); 226*cdf0e10cSrcweir //------------------------------------------------------------------------------ 227*cdf0e10cSrcweir static sal_Int16 impl_showExtensionDialog( uno::Reference< uno::XComponentContext > &xContext ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir rtl::OUString sServiceName = UNISTRING("com.sun.star.deployment.ui.UpdateRequiredDialog"); 230*cdf0e10cSrcweir uno::Reference< uno::XInterface > xService; 231*cdf0e10cSrcweir sal_Int16 nRet = 0; 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir uno::Reference< lang::XMultiComponentFactory > xServiceManager( xContext->getServiceManager() ); 234*cdf0e10cSrcweir if( !xServiceManager.is() ) 235*cdf0e10cSrcweir throw uno::RuntimeException( 236*cdf0e10cSrcweir UNISTRING( "impl_showExtensionDialog(): unable to obtain service manager from component context" ), uno::Reference< uno::XInterface > () ); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir xService = xServiceManager->createInstanceWithContext( sServiceName, xContext ); 239*cdf0e10cSrcweir uno::Reference< ui::dialogs::XExecutableDialog > xExecuteable( xService, uno::UNO_QUERY ); 240*cdf0e10cSrcweir if ( xExecuteable.is() ) 241*cdf0e10cSrcweir nRet = xExecuteable->execute(); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir return nRet; 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir //------------------------------------------------------------------------------ 247*cdf0e10cSrcweir // Check dependencies of all packages 248*cdf0e10cSrcweir //------------------------------------------------------------------------------ 249*cdf0e10cSrcweir static bool impl_checkDependencies( const uno::Reference< uno::XComponentContext > &xContext ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir uno::Sequence< uno::Sequence< uno::Reference< deployment::XPackage > > > xAllPackages; 252*cdf0e10cSrcweir uno::Reference< deployment::XExtensionManager > xExtensionManager = deployment::ExtensionManager::get( xContext ); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir if ( !xExtensionManager.is() ) 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir OSL_ENSURE( 0, "Could not get the Extension Manager!" ); 257*cdf0e10cSrcweir return true; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir try { 261*cdf0e10cSrcweir xAllPackages = xExtensionManager->getAllExtensions( uno::Reference< task::XAbortChannel >(), 262*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment >() ); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir catch ( deployment::DeploymentException & ) { return true; } 265*cdf0e10cSrcweir catch ( ucb::CommandFailedException & ) { return true; } 266*cdf0e10cSrcweir catch ( ucb::CommandAbortedException & ) { return true; } 267*cdf0e10cSrcweir catch ( lang::IllegalArgumentException & e ) { 268*cdf0e10cSrcweir throw uno::RuntimeException( e.Message, e.Context ); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir sal_Int32 nMax = 2; 272*cdf0e10cSrcweir #ifdef DEBUG 273*cdf0e10cSrcweir nMax = 3; 274*cdf0e10cSrcweir #endif 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir for ( sal_Int32 j = 0; (j<nMax) && (j < xPackageList.getLength()); ++j ) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; 283*cdf0e10cSrcweir if ( xPackage.is() ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir bool bRegistered = false; 286*cdf0e10cSrcweir try { 287*cdf0e10cSrcweir beans::Optional< beans::Ambiguous< sal_Bool > > option( xPackage->isRegistered( uno::Reference< task::XAbortChannel >(), 288*cdf0e10cSrcweir uno::Reference< ucb::XCommandEnvironment >() ) ); 289*cdf0e10cSrcweir if ( option.IsPresent ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir ::beans::Ambiguous< sal_Bool > const & reg = option.Value; 292*cdf0e10cSrcweir if ( reg.IsAmbiguous ) 293*cdf0e10cSrcweir bRegistered = false; 294*cdf0e10cSrcweir else 295*cdf0e10cSrcweir bRegistered = reg.Value ? true : false; 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir else 298*cdf0e10cSrcweir bRegistered = false; 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir catch ( uno::RuntimeException & ) { throw; } 301*cdf0e10cSrcweir catch ( uno::Exception & exc) { 302*cdf0e10cSrcweir (void) exc; 303*cdf0e10cSrcweir OSL_ENSURE( 0, ::rtl::OUStringToOString( exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir if ( bRegistered ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir bool bDependenciesValid = false; 309*cdf0e10cSrcweir try { 310*cdf0e10cSrcweir bDependenciesValid = xPackage->checkDependencies( uno::Reference< ucb::XCommandEnvironment >() ); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir catch ( deployment::DeploymentException & ) {} 313*cdf0e10cSrcweir if ( ! bDependenciesValid ) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir return false; 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir return true; 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir //------------------------------------------------------------------------------ 325*cdf0e10cSrcweir // resets the 'check needed' flag (needed, if aborted) 326*cdf0e10cSrcweir //------------------------------------------------------------------------------ 327*cdf0e10cSrcweir static void impl_setNeedsCompatCheck() 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir try { 330*cdf0e10cSrcweir Reference < XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); 331*cdf0e10cSrcweir // get configuration provider 332*cdf0e10cSrcweir Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory >( 333*cdf0e10cSrcweir xFactory->createInstance(sConfigSrvc), UNO_QUERY_THROW); 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir Sequence< Any > theArgs(1); 336*cdf0e10cSrcweir beans::NamedValue v( OUString::createFromAscii("NodePath"), 337*cdf0e10cSrcweir makeAny( OUString::createFromAscii("org.openoffice.Setup/Office") ) ); 338*cdf0e10cSrcweir theArgs[0] <<= v; 339*cdf0e10cSrcweir Reference< beans::XPropertySet > pset = Reference< beans::XPropertySet >( 340*cdf0e10cSrcweir theConfigProvider->createInstanceWithArguments( sAccessSrvc, theArgs ), UNO_QUERY_THROW ); 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir Any value = makeAny( OUString::createFromAscii("never") ); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir pset->setPropertyValue( OUString::createFromAscii("LastCompatibilityCheckID"), value ); 345*cdf0e10cSrcweir Reference< util::XChangesBatch >( pset, UNO_QUERY_THROW )->commitChanges(); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir catch (const Exception&) {} 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir //------------------------------------------------------------------------------ 351*cdf0e10cSrcweir static bool impl_check() 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir uno::Reference< uno::XComponentContext > xContext = comphelper_getProcessComponentContext(); 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir bool bDependenciesValid = impl_checkDependencies( xContext ); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir short nRet = 0; 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir if ( !bDependenciesValid ) 360*cdf0e10cSrcweir nRet = impl_showExtensionDialog( xContext ); 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir if ( nRet == -1 ) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir impl_setNeedsCompatCheck(); 365*cdf0e10cSrcweir return true; 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir else 368*cdf0e10cSrcweir return false; 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir //------------------------------------------------------------------------------ 372*cdf0e10cSrcweir // to check if we need checking the dependencies of the extensions again, we compare 373*cdf0e10cSrcweir // the build id of the office with the one of the last check 374*cdf0e10cSrcweir //------------------------------------------------------------------------------ 375*cdf0e10cSrcweir static bool impl_needsCompatCheck() 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir bool bNeedsCheck = false; 378*cdf0e10cSrcweir rtl::OUString aLastCheckBuildID; 379*cdf0e10cSrcweir rtl::OUString aCurrentBuildID( UNISTRING( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":buildid}" ) ); 380*cdf0e10cSrcweir rtl::Bootstrap::expandMacros( aCurrentBuildID ); 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir try { 383*cdf0e10cSrcweir Reference < XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); 384*cdf0e10cSrcweir // get configuration provider 385*cdf0e10cSrcweir Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory >( 386*cdf0e10cSrcweir xFactory->createInstance(sConfigSrvc), UNO_QUERY_THROW); 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir Sequence< Any > theArgs(1); 389*cdf0e10cSrcweir beans::NamedValue v( OUString::createFromAscii("NodePath"), 390*cdf0e10cSrcweir makeAny( OUString::createFromAscii("org.openoffice.Setup/Office") ) ); 391*cdf0e10cSrcweir theArgs[0] <<= v; 392*cdf0e10cSrcweir Reference< beans::XPropertySet > pset = Reference< beans::XPropertySet >( 393*cdf0e10cSrcweir theConfigProvider->createInstanceWithArguments( sAccessSrvc, theArgs ), UNO_QUERY_THROW ); 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir Any result = pset->getPropertyValue( OUString::createFromAscii("LastCompatibilityCheckID") ); 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir result >>= aLastCheckBuildID; 398*cdf0e10cSrcweir if ( aLastCheckBuildID != aCurrentBuildID ) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir bNeedsCheck = true; 401*cdf0e10cSrcweir result <<= aCurrentBuildID; 402*cdf0e10cSrcweir pset->setPropertyValue( OUString::createFromAscii("LastCompatibilityCheckID"), result ); 403*cdf0e10cSrcweir Reference< util::XChangesBatch >( pset, UNO_QUERY_THROW )->commitChanges(); 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir #ifdef DEBUG 406*cdf0e10cSrcweir bNeedsCheck = true; 407*cdf0e10cSrcweir #endif 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir catch (const Exception&) {} 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir return bNeedsCheck; 412*cdf0e10cSrcweir } 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir //------------------------------------------------------------------------------ 415*cdf0e10cSrcweir // Do we need to check the dependencies of the extensions? 416*cdf0e10cSrcweir // When there are unresolved issues, we can't continue with startup 417*cdf0e10cSrcweir sal_Bool Desktop::CheckExtensionDependencies() 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir sal_Bool bAbort = false; 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir if ( impl_needsCompatCheck() ) 422*cdf0e10cSrcweir bAbort = impl_check(); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir return bAbort; 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir void Desktop::SynchronizeExtensionRepositories() 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog,"desktop (jl) ::Desktop::SynchronizeExtensionRepositories"); 430*cdf0e10cSrcweir dp_misc::syncRepositories( new SilentCommandEnv( this ) ); 431*cdf0e10cSrcweir } 432