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