merged tag ooo/OOO330_m14
[LibreOffice.git] / xmlsecurity / source / component / registerservices.cxx
blob653b1038ba710b0d7f2a399e75d728c904174c75
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmlsecurity.hxx"
31 #include <tools/debug.hxx>
32 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
34 #include <cppuhelper/factory.hxx>
37 #include <documentdigitalsignatures.hxx>
38 #include <certificatecontainer.hxx>
40 using namespace ::com::sun::star;
42 extern "C"
44 void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** )
46 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
49 sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
51 if (pRegistryKey)
53 try
55 sal_Int32 nPos = 0;
56 // SERVICE DocumentDigitalSignatures
57 nPos = 0;
58 uno::Reference< registry::XRegistryKey > xNewKey(
59 reinterpret_cast< registry::XRegistryKey* >( pRegistryKey )->createKey( DocumentDigitalSignatures::GetImplementationName() ) );
61 xNewKey = xNewKey->createKey( rtl::OUString::createFromAscii( "/UNO/SERVICES" ) );
63 const uno::Sequence< rtl::OUString >& rSNL = DocumentDigitalSignatures::GetSupportedServiceNames();
64 const rtl::OUString* pArray = rSNL.getConstArray();
65 for ( nPos = rSNL.getLength(); nPos--; )
66 xNewKey->createKey( pArray[nPos] );
68 // SERVICE CertificateContainer
69 nPos = 0;
70 uno::Reference< registry::XRegistryKey > xNewKeyCertificateContainer(
71 reinterpret_cast< registry::XRegistryKey* >( pRegistryKey )->createKey( CertificateContainer::impl_getStaticImplementationName() ) );
72 xNewKeyCertificateContainer = xNewKeyCertificateContainer->createKey( rtl::OUString::createFromAscii( "/UNO/SERVICES" ) );
74 const uno::Sequence< rtl::OUString >& rSNLCertificateContainer = CertificateContainer::impl_getStaticSupportedServiceNames();
75 const rtl::OUString* pArrayCertificateContainer = rSNLCertificateContainer.getConstArray();
76 for ( nPos = rSNLCertificateContainer.getLength(); nPos--; )
77 xNewKeyCertificateContainer->createKey( pArrayCertificateContainer[nPos] );
79 //-----------------------------
81 return sal_True;
83 catch (registry::InvalidRegistryException &)
85 DBG_ERROR( "InvalidRegistryException!" );
88 return sal_False;
91 void* SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
93 void* pRet = 0;
94 uno::Reference< XInterface > xFactory;
96 //Decryptor
97 rtl::OUString implName = rtl::OUString::createFromAscii( pImplName );
99 if ( pServiceManager && implName.equals( DocumentDigitalSignatures::GetImplementationName() ) )
101 // DocumentDigitalSignatures
102 xFactory = cppu::createSingleComponentFactory(
103 DocumentDigitalSignatures_CreateInstance,
104 rtl::OUString::createFromAscii( pImplName ),
105 DocumentDigitalSignatures::GetSupportedServiceNames() );
107 else if ( pServiceManager && implName.equals( CertificateContainer::impl_getStaticImplementationName() ))
109 // CertificateContainer
110 xFactory = cppu::createOneInstanceFactory(
111 reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
112 rtl::OUString::createFromAscii( pImplName ),
113 CertificateContainer::impl_createInstance,
114 CertificateContainer::impl_getStaticSupportedServiceNames() );
117 if (xFactory.is())
119 xFactory->acquire();
120 pRet = xFactory.get();
122 return pRet;
125 } // extern "C"