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_extensions.hxx"
26 
27 #include "corecontroller.hxx"
28 #include "invite_job.hxx"
29 #include "onlogrotate_job.hxx"
30 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
31 #include <cppuhelper/factory.hxx>
32 #include <osl/mutex.hxx>
33 #include <osl/thread.h>
34 #include <rtl/ustrbuf.hxx>
35 #include <rtl/ustring.hxx>
36 
37 
38 using namespace ::com::sun::star::lang;
39 using namespace ::com::sun::star::registry;
40 using namespace ::com::sun::star::uno;
41 using namespace ::oooimprovement;
42 using ::rtl::OUString;
43 using ::rtl::OUStringBuffer;
44 
45 
46 namespace
47 {
writeInfo(const Reference<XRegistryKey> & reg_key,const OUString & implementation_name,const OUString & service_name)48     void writeInfo(const Reference<XRegistryKey>& reg_key,
49         const OUString& implementation_name,
50         const OUString& service_name)
51     {
52         OUStringBuffer buf(256);
53         buf.append(implementation_name);
54         buf.appendAscii("/UNO/SERVICES/");
55         buf.append(service_name);
56         reg_key->createKey(buf.makeStringAndClear());
57     }
58 }
59 
60 extern "C"
61 {
component_getImplementationEnvironment(const sal_Char ** env_type_name,uno_Environment **)62     void SAL_CALL component_getImplementationEnvironment(const sal_Char** env_type_name, uno_Environment**)
63     { *env_type_name = CPPU_CURRENT_LANGUAGE_BINDING_NAME; }
64 
component_getFactory(const sal_Char * pImplName,void * pServiceManager,void *)65     void* SAL_CALL component_getFactory(const sal_Char* pImplName, void* pServiceManager, void*)
66     {
67         if ( !pServiceManager || !pImplName ) return 0;
68 
69         Reference<XSingleServiceFactory> factory;
70         Reference<XMultiServiceFactory>  sm(reinterpret_cast<XMultiServiceFactory*>(pServiceManager), UNO_QUERY);
71         OUString impl_name = OUString::createFromAscii(pImplName);
72         Sequence<OUString> names(1);
73         names[0] = impl_name;
74 
75         if (impl_name.equals(CoreController::getImplementationName_static()))
76             factory = ::cppu::createSingleFactory(sm, impl_name, CoreController::Create, names);
77         if (impl_name.equals(OnLogRotateJob::getImplementationName_static()))
78             factory = ::cppu::createSingleFactory(sm, impl_name, OnLogRotateJob::Create, names);
79         if (impl_name.equals(InviteJob::getImplementationName_static()))
80             factory = ::cppu::createSingleFactory(sm, impl_name, InviteJob::Create, names);
81         if (!factory.is()) return 0;
82         factory->acquire();
83         return factory.get();
84     }
85 }
86