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
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_desktop.hxx"
26cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
27cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp>
28cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp>
29cdf0e10cSrcweir #include <uno/environment.h>
30cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
31cdf0e10cSrcweir #include <unotools/configmgr.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include "splash.hxx"
34cdf0e10cSrcweir #include "firststart.hxx"
35cdf0e10cSrcweir
36cdf0e10cSrcweir
37cdf0e10cSrcweir using namespace rtl;
38cdf0e10cSrcweir using namespace ::com::sun::star::uno;
39cdf0e10cSrcweir using namespace ::com::sun::star::lang;
40cdf0e10cSrcweir using namespace ::com::sun::star::beans;
41cdf0e10cSrcweir using namespace ::com::sun::star::registry;
42cdf0e10cSrcweir using namespace ::desktop;
43cdf0e10cSrcweir
44cdf0e10cSrcweir static const char* pServices[] =
45cdf0e10cSrcweir {
46cdf0e10cSrcweir SplashScreen::serviceName,
47cdf0e10cSrcweir FirstStart::serviceName,
48cdf0e10cSrcweir NULL
49cdf0e10cSrcweir };
50cdf0e10cSrcweir
51cdf0e10cSrcweir static const char* pImplementations[] =
52cdf0e10cSrcweir {
53cdf0e10cSrcweir SplashScreen::implementationName,
54cdf0e10cSrcweir FirstStart::implementationName,
55cdf0e10cSrcweir NULL
56cdf0e10cSrcweir };
57cdf0e10cSrcweir
58cdf0e10cSrcweir typedef Reference<XInterface>(* fProvider)(const Reference<XMultiServiceFactory>&);
59cdf0e10cSrcweir
60cdf0e10cSrcweir static const fProvider pInstanceProviders[] =
61cdf0e10cSrcweir {
62cdf0e10cSrcweir SplashScreen::getInstance,
63cdf0e10cSrcweir FirstStart::CreateInstance,
64cdf0e10cSrcweir NULL
65cdf0e10cSrcweir };
66cdf0e10cSrcweir
67cdf0e10cSrcweir
68cdf0e10cSrcweir static const char** pSupportedServices[] =
69cdf0e10cSrcweir {
70cdf0e10cSrcweir SplashScreen::interfaces,
71cdf0e10cSrcweir FirstStart::interfaces,
72cdf0e10cSrcweir NULL
73cdf0e10cSrcweir };
74cdf0e10cSrcweir
75cdf0e10cSrcweir static Sequence<OUString>
getSupportedServiceNames(int p)76cdf0e10cSrcweir getSupportedServiceNames(int p) {
77cdf0e10cSrcweir const char **names = pSupportedServices[p];
78cdf0e10cSrcweir Sequence<OUString> aSeq;
79cdf0e10cSrcweir for(int i = 0; names[i] != NULL; i++) {
80cdf0e10cSrcweir aSeq.realloc(i+1);
81cdf0e10cSrcweir aSeq[i] = OUString::createFromAscii(names[i]);
82cdf0e10cSrcweir }
83cdf0e10cSrcweir return aSeq;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir
86cdf0e10cSrcweir extern "C"
87cdf0e10cSrcweir {
88cdf0e10cSrcweir void SAL_CALL
component_getImplementationEnvironment(const sal_Char ** ppEnvironmentTypeName,uno_Environment **)89cdf0e10cSrcweir component_getImplementationEnvironment(
90cdf0e10cSrcweir const sal_Char** ppEnvironmentTypeName,
91cdf0e10cSrcweir uno_Environment**)
92cdf0e10cSrcweir {
93cdf0e10cSrcweir *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir
96cdf0e10cSrcweir void* SAL_CALL
component_getFactory(const sal_Char * pImplementationName,void * pServiceManager,void *)97cdf0e10cSrcweir component_getFactory(
98cdf0e10cSrcweir const sal_Char* pImplementationName,
99cdf0e10cSrcweir void* pServiceManager,
100cdf0e10cSrcweir void*)
101cdf0e10cSrcweir {
102cdf0e10cSrcweir // Set default return value for this operation - if it failed.
103cdf0e10cSrcweir if ( pImplementationName && pServiceManager )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir Reference< XSingleServiceFactory > xFactory;
106cdf0e10cSrcweir Reference< XMultiServiceFactory > xServiceManager(
107cdf0e10cSrcweir reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
108cdf0e10cSrcweir
109cdf0e10cSrcweir // search implementation
110cdf0e10cSrcweir for (int i = 0; (pImplementations[i]!=NULL); i++) {
111cdf0e10cSrcweir if ( strcmp(pImplementations[i], pImplementationName ) == 0 ) {
112cdf0e10cSrcweir // found implementation
113cdf0e10cSrcweir xFactory = Reference<XSingleServiceFactory>(cppu::createSingleFactory(
114cdf0e10cSrcweir xServiceManager, OUString::createFromAscii(pImplementationName),
115cdf0e10cSrcweir pInstanceProviders[i], getSupportedServiceNames(i)));
116cdf0e10cSrcweir if ( xFactory.is() ) {
117cdf0e10cSrcweir // Factory is valid - service was found.
118cdf0e10cSrcweir xFactory->acquire();
119cdf0e10cSrcweir return xFactory.get();
120cdf0e10cSrcweir }
121cdf0e10cSrcweir }
122cdf0e10cSrcweir } // for()
123cdf0e10cSrcweir }
124cdf0e10cSrcweir // Return with result of this operation.
125cdf0e10cSrcweir return NULL;
126cdf0e10cSrcweir }
127cdf0e10cSrcweir } // extern "C"
128