1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_desktop.hxx" 30 31 #include "firststart.hxx" 32 #include "../migration/wizard.hxx" 33 #include <comphelper/sequenceashashmap.hxx> 34 35 using namespace rtl; 36 using namespace ::com::sun::star::uno; 37 using namespace ::com::sun::star::lang; 38 using namespace ::com::sun::star::beans; 39 40 namespace desktop{ 41 42 43 const char* FirstStart::interfaces[] = 44 { 45 "com.sun.star.task.XJob", 46 NULL, 47 }; 48 const char* FirstStart::implementationName = "com.sun.star.comp.desktop.FirstStart"; 49 const char* FirstStart::serviceName = "com.sun.star.task.Job"; 50 51 OUString FirstStart::GetImplementationName() 52 { 53 return OUString( RTL_CONSTASCII_USTRINGPARAM( implementationName)); 54 } 55 56 Sequence< OUString > FirstStart::GetSupportedServiceNames() 57 { 58 sal_Int32 nSize = (sizeof( interfaces ) / sizeof( const char *)) - 1; 59 Sequence< OUString > aResult( nSize ); 60 61 for( sal_Int32 i = 0; i < nSize; i++ ) 62 aResult[i] = OUString::createFromAscii( interfaces[i] ); 63 return aResult; 64 } 65 66 Reference< XInterface > SAL_CALL FirstStart::CreateInstance( 67 const Reference< XMultiServiceFactory >& rSMgr ) 68 { 69 static osl::Mutex aMutex; 70 osl::MutexGuard guard( aMutex ); 71 return (XComponent*) ( new FirstStart( rSMgr ) ); 72 } 73 74 FirstStart::FirstStart( const Reference< XMultiServiceFactory >& xFactory ) : 75 m_aListeners( m_aMutex ), 76 m_xServiceManager( xFactory ) 77 { 78 } 79 80 FirstStart::~FirstStart() 81 { 82 } 83 84 // XComponent 85 void SAL_CALL FirstStart::dispose() throw ( RuntimeException ) 86 { 87 EventObject aObject; 88 aObject.Source = (XComponent*)this; 89 m_aListeners.disposeAndClear( aObject ); 90 } 91 92 void SAL_CALL FirstStart::addEventListener( const Reference< XEventListener > & aListener) throw ( RuntimeException ) 93 { 94 m_aListeners.addInterface( aListener ); 95 } 96 97 void SAL_CALL FirstStart::removeEventListener( const Reference< XEventListener > & aListener ) throw ( RuntimeException ) 98 { 99 m_aListeners.removeInterface( aListener ); 100 } 101 102 // XServiceInfo 103 ::rtl::OUString SAL_CALL FirstStart::getImplementationName() 104 throw ( RuntimeException ) 105 { 106 return FirstStart::GetImplementationName(); 107 } 108 109 sal_Bool SAL_CALL FirstStart::supportsService( const ::rtl::OUString& rServiceName ) 110 throw ( RuntimeException ) 111 { 112 sal_Int32 nSize = sizeof( interfaces ) / sizeof( const char *); 113 114 for( sal_Int32 i = 0; i < nSize; i++ ) 115 if ( rServiceName.equalsAscii( interfaces[i] )) 116 return sal_True; 117 return sal_False; 118 } 119 120 Sequence< ::rtl::OUString > SAL_CALL FirstStart::getSupportedServiceNames() 121 throw ( RuntimeException ) 122 { 123 return FirstStart::GetSupportedServiceNames(); 124 } 125 126 // XJob 127 Any SAL_CALL FirstStart::execute(const Sequence<NamedValue>& args) 128 throw ( RuntimeException ) 129 { 130 static const ::rtl::OUString ARG_LICENSENEEDED( RTL_CONSTASCII_USTRINGPARAM( "LicenseNeedsAcceptance" ) ); 131 static const ::rtl::OUString ARG_LICENSEPATH( RTL_CONSTASCII_USTRINGPARAM( "LicensePath" ) ); 132 133 ::comphelper::SequenceAsHashMap lArgs(args); 134 135 sal_Bool bLicenseNeeded = lArgs.getUnpackedValueOrDefault( ARG_LICENSENEEDED, (sal_Bool)sal_True ); 136 rtl::OUString aLicensePath = lArgs.getUnpackedValueOrDefault( ARG_LICENSEPATH, rtl::OUString() ); 137 138 FirstStartWizard fsw( NULL, bLicenseNeeded && ( aLicensePath.getLength() > 0 ), aLicensePath ); 139 return makeAny( (sal_Bool)fsw.Execute() ); 140 } 141 142 // XJobExecutor 143 void SAL_CALL FirstStart::trigger(const OUString&) 144 throw ( RuntimeException ) 145 { 146 // trigger wizard with override, so it gets started regardless of 147 // configuration 148 Sequence<NamedValue> seq(1); 149 seq[0] = NamedValue( 150 OUString::createFromAscii("Override"), 151 makeAny(sal_True)); 152 execute(seq); 153 } 154 155 156 } // namespace desktop 157