xref: /trunk/main/uui/source/services.cxx (revision ab743807)
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" SAL_DLLPUBLIC_EXPORT 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 
59 extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL
component_getFactory(sal_Char const * pImplName,void * pServiceManager,void *)60 component_getFactory(sal_Char const * pImplName,
61                         void * pServiceManager,
62                         void *)
63 {
64     if (!pImplName)
65         return 0;
66 
67     void * pRet = 0;
68 
69     Reference< XMultiServiceFactory > xSMgr(
70         reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
71     Reference< XSingleServiceFactory > xFactory;
72 
73     //////////////////////////////////////////////////////////////////////
74     // UUI Interaction Handler.
75     //////////////////////////////////////////////////////////////////////
76 
77     if ( rtl_str_compare(pImplName,
78                          UUIInteractionHandler::m_aImplementationName)
79          == 0)
80     {
81         xFactory =
82             cppu::createSingleFactory(
83                 static_cast< XMultiServiceFactory * >(pServiceManager),
84                 OUString::createFromAscii(
85                     UUIInteractionHandler::m_aImplementationName),
86                 &UUIInteractionHandler::createInstance,
87                 UUIInteractionHandler::getSupportedServiceNames_static());
88     }
89 
90     //////////////////////////////////////////////////////////////////////
91     // UUI Interaction Request String Resolver.
92     //////////////////////////////////////////////////////////////////////
93 
94     else if ( rtl_str_compare(pImplName,
95                   UUIInteractionRequestStringResolver::m_aImplementationName)
96           == 0)
97     {
98         xFactory =
99             cppu::createSingleFactory(
100                 static_cast< XMultiServiceFactory * >(pServiceManager),
101                 OUString::createFromAscii(
102                     UUIInteractionRequestStringResolver::m_aImplementationName),
103                 &UUIInteractionRequestStringResolver::createInstance,
104                 UUIInteractionRequestStringResolver::getSupportedServiceNames_static());
105     }
106 
107     //////////////////////////////////////////////////////////////////////
108     // UUI Password Container Interaction Handler.
109     //////////////////////////////////////////////////////////////////////
110 
111     else if ( uui::PasswordContainerInteractionHandler::getImplementationName_Static().
112                 compareToAscii( pImplName ) == 0 )
113     {
114         xFactory =
115             uui::PasswordContainerInteractionHandler::createServiceFactory( xSMgr );
116     }
117 
118     //////////////////////////////////////////////////////////////////////
119 
120     if ( xFactory.is() )
121     {
122         xFactory->acquire();
123         pRet = xFactory.get();
124     }
125 
126     return pRet;
127 }
128