xref: /AOO41X/main/desktop/source/splash/firststart.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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_desktop.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "firststart.hxx"
32*cdf0e10cSrcweir #include "../migration/wizard.hxx"
33*cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir using namespace rtl;
36*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
37*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
38*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir namespace desktop{
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir const char* FirstStart::interfaces[] =
44*cdf0e10cSrcweir {
45*cdf0e10cSrcweir     "com.sun.star.task.XJob",
46*cdf0e10cSrcweir     NULL,
47*cdf0e10cSrcweir };
48*cdf0e10cSrcweir const char* FirstStart::implementationName = "com.sun.star.comp.desktop.FirstStart";
49*cdf0e10cSrcweir const char* FirstStart::serviceName = "com.sun.star.task.Job";
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir OUString FirstStart::GetImplementationName()
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( implementationName));
54*cdf0e10cSrcweir }
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir Sequence< OUString > FirstStart::GetSupportedServiceNames()
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir 	sal_Int32 nSize = (sizeof( interfaces ) / sizeof( const char *)) - 1;
59*cdf0e10cSrcweir 	Sequence< OUString > aResult( nSize );
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir 	for( sal_Int32 i = 0; i < nSize; i++ )
62*cdf0e10cSrcweir 		aResult[i] = OUString::createFromAscii( interfaces[i] );
63*cdf0e10cSrcweir 	return aResult;
64*cdf0e10cSrcweir }
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir Reference< XInterface >  SAL_CALL FirstStart::CreateInstance(
67*cdf0e10cSrcweir     const Reference< XMultiServiceFactory >& rSMgr )
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir 	    static osl::Mutex aMutex;
70*cdf0e10cSrcweir 		osl::MutexGuard guard( aMutex );
71*cdf0e10cSrcweir 		return (XComponent*) ( new FirstStart( rSMgr ) );
72*cdf0e10cSrcweir }
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir FirstStart::FirstStart( const Reference< XMultiServiceFactory >& xFactory ) :
75*cdf0e10cSrcweir 	m_aListeners( m_aMutex ),
76*cdf0e10cSrcweir 	m_xServiceManager( xFactory )
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir }
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir FirstStart::~FirstStart()
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir }
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir // XComponent
85*cdf0e10cSrcweir void SAL_CALL FirstStart::dispose() throw ( RuntimeException )
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir     EventObject aObject;
88*cdf0e10cSrcweir     aObject.Source = (XComponent*)this;
89*cdf0e10cSrcweir     m_aListeners.disposeAndClear( aObject );
90*cdf0e10cSrcweir }
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir void SAL_CALL FirstStart::addEventListener( const Reference< XEventListener > & aListener) throw ( RuntimeException )
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir     m_aListeners.addInterface( aListener );
95*cdf0e10cSrcweir }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir void SAL_CALL FirstStart::removeEventListener( const Reference< XEventListener > & aListener ) throw ( RuntimeException )
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir     m_aListeners.removeInterface( aListener );
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir // XServiceInfo
103*cdf0e10cSrcweir ::rtl::OUString SAL_CALL FirstStart::getImplementationName()
104*cdf0e10cSrcweir throw ( RuntimeException )
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir 	return FirstStart::GetImplementationName();
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir sal_Bool SAL_CALL FirstStart::supportsService( const ::rtl::OUString& rServiceName )
110*cdf0e10cSrcweir throw ( RuntimeException )
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir 	sal_Int32 nSize = sizeof( interfaces ) / sizeof( const char *);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 	for( sal_Int32 i = 0; i < nSize; i++ )
115*cdf0e10cSrcweir 		if ( rServiceName.equalsAscii( interfaces[i] ))
116*cdf0e10cSrcweir 			return sal_True;
117*cdf0e10cSrcweir 	return sal_False;
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL FirstStart::getSupportedServiceNames()
121*cdf0e10cSrcweir throw ( RuntimeException )
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir 	return FirstStart::GetSupportedServiceNames();
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir // XJob
127*cdf0e10cSrcweir Any SAL_CALL FirstStart::execute(const Sequence<NamedValue>& args)
128*cdf0e10cSrcweir throw ( RuntimeException )
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir     static const ::rtl::OUString ARG_LICENSENEEDED( RTL_CONSTASCII_USTRINGPARAM( "LicenseNeedsAcceptance" ) );
131*cdf0e10cSrcweir     static const ::rtl::OUString ARG_LICENSEPATH(   RTL_CONSTASCII_USTRINGPARAM( "LicensePath" ) );
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     ::comphelper::SequenceAsHashMap lArgs(args);
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     sal_Bool bLicenseNeeded    = lArgs.getUnpackedValueOrDefault( ARG_LICENSENEEDED, (sal_Bool)sal_True );
136*cdf0e10cSrcweir     rtl::OUString aLicensePath = lArgs.getUnpackedValueOrDefault( ARG_LICENSEPATH, rtl::OUString() );
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir     FirstStartWizard fsw( NULL, bLicenseNeeded && ( aLicensePath.getLength() > 0 ), aLicensePath );
139*cdf0e10cSrcweir     return makeAny( (sal_Bool)fsw.Execute() );
140*cdf0e10cSrcweir }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir // XJobExecutor
143*cdf0e10cSrcweir void SAL_CALL FirstStart::trigger(const OUString&)
144*cdf0e10cSrcweir throw ( RuntimeException )
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir     // trigger wizard with override, so it gets started regardless of
147*cdf0e10cSrcweir     // configuration
148*cdf0e10cSrcweir     Sequence<NamedValue> seq(1);
149*cdf0e10cSrcweir     seq[0] = NamedValue(
150*cdf0e10cSrcweir         OUString::createFromAscii("Override"),
151*cdf0e10cSrcweir         makeAny(sal_True));
152*cdf0e10cSrcweir     execute(seq);
153*cdf0e10cSrcweir }
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir } // namespace desktop
157