1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_desktop.hxx"
26
27 #include "firststart.hxx"
28 #include "../migration/wizard.hxx"
29 #include <comphelper/sequenceashashmap.hxx>
30
31 using namespace rtl;
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::lang;
34 using namespace ::com::sun::star::beans;
35
36 namespace desktop{
37
38
39 const char* FirstStart::interfaces[] =
40 {
41 "com.sun.star.task.XJob",
42 NULL,
43 };
44 const char* FirstStart::implementationName = "com.sun.star.comp.desktop.FirstStart";
45 const char* FirstStart::serviceName = "com.sun.star.task.Job";
46
GetImplementationName()47 OUString FirstStart::GetImplementationName()
48 {
49 return OUString( RTL_CONSTASCII_USTRINGPARAM( implementationName));
50 }
51
GetSupportedServiceNames()52 Sequence< OUString > FirstStart::GetSupportedServiceNames()
53 {
54 sal_Int32 nSize = (sizeof( interfaces ) / sizeof( const char *)) - 1;
55 Sequence< OUString > aResult( nSize );
56
57 for( sal_Int32 i = 0; i < nSize; i++ )
58 aResult[i] = OUString::createFromAscii( interfaces[i] );
59 return aResult;
60 }
61
CreateInstance(const Reference<XMultiServiceFactory> & rSMgr)62 Reference< XInterface > SAL_CALL FirstStart::CreateInstance(
63 const Reference< XMultiServiceFactory >& rSMgr )
64 {
65 static osl::Mutex aMutex;
66 osl::MutexGuard guard( aMutex );
67 return (XComponent*) ( new FirstStart( rSMgr ) );
68 }
69
FirstStart(const Reference<XMultiServiceFactory> & xFactory)70 FirstStart::FirstStart( const Reference< XMultiServiceFactory >& xFactory ) :
71 m_aListeners( m_aMutex ),
72 m_xServiceManager( xFactory )
73 {
74 }
75
~FirstStart()76 FirstStart::~FirstStart()
77 {
78 }
79
80 // XComponent
dispose()81 void SAL_CALL FirstStart::dispose()
82 {
83 EventObject aObject;
84 aObject.Source = (XComponent*)this;
85 m_aListeners.disposeAndClear( aObject );
86 }
87
addEventListener(const Reference<XEventListener> & aListener)88 void SAL_CALL FirstStart::addEventListener( const Reference< XEventListener > & aListener)
89 {
90 m_aListeners.addInterface( aListener );
91 }
92
removeEventListener(const Reference<XEventListener> & aListener)93 void SAL_CALL FirstStart::removeEventListener( const Reference< XEventListener > & aListener )
94 {
95 m_aListeners.removeInterface( aListener );
96 }
97
98 // XServiceInfo
getImplementationName()99 ::rtl::OUString SAL_CALL FirstStart::getImplementationName()
100 {
101 return FirstStart::GetImplementationName();
102 }
103
supportsService(const::rtl::OUString & rServiceName)104 sal_Bool SAL_CALL FirstStart::supportsService( const ::rtl::OUString& rServiceName )
105 {
106 sal_Int32 nSize = sizeof( interfaces ) / sizeof( const char *);
107
108 for( sal_Int32 i = 0; i < nSize; i++ )
109 if ( rServiceName.equalsAscii( interfaces[i] ))
110 return sal_True;
111 return sal_False;
112 }
113
getSupportedServiceNames()114 Sequence< ::rtl::OUString > SAL_CALL FirstStart::getSupportedServiceNames()
115 {
116 return FirstStart::GetSupportedServiceNames();
117 }
118
119 // XJob
execute(const Sequence<NamedValue> & args)120 Any SAL_CALL FirstStart::execute(const Sequence<NamedValue>& args)
121 {
122 static const ::rtl::OUString ARG_LICENSENEEDED( RTL_CONSTASCII_USTRINGPARAM( "LicenseNeedsAcceptance" ) );
123 static const ::rtl::OUString ARG_LICENSEPATH( RTL_CONSTASCII_USTRINGPARAM( "LicensePath" ) );
124
125 ::comphelper::SequenceAsHashMap lArgs(args);
126
127 sal_Bool bLicenseNeeded = lArgs.getUnpackedValueOrDefault( ARG_LICENSENEEDED, (sal_Bool)sal_True );
128 rtl::OUString aLicensePath = lArgs.getUnpackedValueOrDefault( ARG_LICENSEPATH, rtl::OUString() );
129
130 FirstStartWizard fsw( NULL, bLicenseNeeded && ( aLicensePath.getLength() > 0 ), aLicensePath );
131 return makeAny( (sal_Bool)fsw.Execute() );
132 }
133
134 // XJobExecutor
trigger(const OUString &)135 void SAL_CALL FirstStart::trigger(const OUString&)
136 {
137 // trigger wizard with override, so it gets started regardless of
138 // configuration
139 Sequence<NamedValue> seq(1);
140 seq[0] = NamedValue(
141 OUString::createFromAscii("Override"),
142 makeAny(sal_True));
143 execute(seq);
144 }
145
146
147 } // namespace desktop
148