xref: /aoo41x/main/uui/source/services.cxx (revision 859212d1)
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 #include <com/sun/star/registry/XRegistryKey.hpp>
25 #include <cppu/macros.hxx>
26 #include <cppuhelper/factory.hxx>
27 #include <rtl/ustring.hxx>
28 #include <sal/types.h>
29 #include <uno/environment.h>
30 
31 #include "interactionhandler.hxx"
32 #include "requeststringresolver.hxx"
33 #include "passwordcontainer.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::registry;
39 
40 //============================================================================
41 //
42 //  component_getImplementationEnvironment
43 //
44 //============================================================================
45 
46 extern "C" void SAL_CALL
component_getImplementationEnvironment(sal_Char const ** pEnvTypeName,uno_Environment **)47 component_getImplementationEnvironment(sal_Char const ** pEnvTypeName,
48                        uno_Environment **)
49 {
50     *pEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
51 }
52 
53 //============================================================================
54 //
55 //  component_getFactory
56 //
57 //============================================================================
58 
component_getFactory(sal_Char const * pImplName,void * pServiceManager,void *)59 extern "C" void * SAL_CALL component_getFactory(sal_Char const * pImplName,
60                         void * pServiceManager,
61                         void *)
62 {
63     if (!pImplName)
64         return 0;
65 
66     void * pRet = 0;
67 
68     Reference< XMultiServiceFactory > xSMgr(
69         reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
70     Reference< XSingleServiceFactory > xFactory;
71 
72     //////////////////////////////////////////////////////////////////////
73     // UUI Interaction Handler.
74     //////////////////////////////////////////////////////////////////////
75 
76     if ( rtl_str_compare(pImplName,
77                          UUIInteractionHandler::m_aImplementationName)
78          == 0)
79     {
80         xFactory =
81             cppu::createSingleFactory(
82                 static_cast< XMultiServiceFactory * >(pServiceManager),
83                 OUString::createFromAscii(
84                     UUIInteractionHandler::m_aImplementationName),
85                 &UUIInteractionHandler::createInstance,
86                 UUIInteractionHandler::getSupportedServiceNames_static());
87     }
88 
89     //////////////////////////////////////////////////////////////////////
90     // UUI Interaction Request String Resolver.
91     //////////////////////////////////////////////////////////////////////
92 
93     else if ( rtl_str_compare(pImplName,
94                   UUIInteractionRequestStringResolver::m_aImplementationName)
95           == 0)
96     {
97         xFactory =
98             cppu::createSingleFactory(
99                 static_cast< XMultiServiceFactory * >(pServiceManager),
100                 OUString::createFromAscii(
101                     UUIInteractionRequestStringResolver::m_aImplementationName),
102                 &UUIInteractionRequestStringResolver::createInstance,
103                 UUIInteractionRequestStringResolver::getSupportedServiceNames_static());
104     }
105 
106     //////////////////////////////////////////////////////////////////////
107     // UUI Password Container Interaction Handler.
108     //////////////////////////////////////////////////////////////////////
109 
110     else if ( uui::PasswordContainerInteractionHandler::getImplementationName_Static().
111                 compareToAscii( pImplName ) == 0 )
112     {
113         xFactory =
114             uui::PasswordContainerInteractionHandler::createServiceFactory( xSMgr );
115     }
116 
117     //////////////////////////////////////////////////////////////////////
118 
119     if ( xFactory.is() )
120     {
121         xFactory->acquire();
122         pRet = xFactory.get();
123     }
124 
125     return pRet;
126 }
127