1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: registerservices.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmlsecurity.hxx"
34 #include <tools/debug.hxx>
35 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
37 #include <cppuhelper/factory.hxx>
40 #include <documentdigitalsignatures.hxx>
41 #include <certificatecontainer.hxx>
43 using namespace ::com::sun::star
;
47 void SAL_CALL
component_getImplementationEnvironment( const sal_Char
** ppEnvTypeName
, uno_Environment
** )
49 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
52 sal_Bool SAL_CALL
component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey
)
59 // SERVICE DocumentDigitalSignatures
61 uno::Reference
< registry::XRegistryKey
> xNewKey(
62 reinterpret_cast< registry::XRegistryKey
* >( pRegistryKey
)->createKey( DocumentDigitalSignatures::GetImplementationName() ) );
64 xNewKey
= xNewKey
->createKey( rtl::OUString::createFromAscii( "/UNO/SERVICES" ) );
66 const uno::Sequence
< rtl::OUString
>& rSNL
= DocumentDigitalSignatures::GetSupportedServiceNames();
67 const rtl::OUString
* pArray
= rSNL
.getConstArray();
68 for ( nPos
= rSNL
.getLength(); nPos
--; )
69 xNewKey
->createKey( pArray
[nPos
] );
71 // SERVICE CertificateContainer
73 uno::Reference
< registry::XRegistryKey
> xNewKeyCertificateContainer(
74 reinterpret_cast< registry::XRegistryKey
* >( pRegistryKey
)->createKey( CertificateContainer::impl_getStaticImplementationName() ) );
75 xNewKeyCertificateContainer
= xNewKeyCertificateContainer
->createKey( rtl::OUString::createFromAscii( "/UNO/SERVICES" ) );
77 const uno::Sequence
< rtl::OUString
>& rSNLCertificateContainer
= CertificateContainer::impl_getStaticSupportedServiceNames();
78 const rtl::OUString
* pArrayCertificateContainer
= rSNLCertificateContainer
.getConstArray();
79 for ( nPos
= rSNLCertificateContainer
.getLength(); nPos
--; )
80 xNewKeyCertificateContainer
->createKey( pArrayCertificateContainer
[nPos
] );
82 //-----------------------------
86 catch (registry::InvalidRegistryException
&)
88 DBG_ERROR( "InvalidRegistryException!" );
94 void* SAL_CALL
component_getFactory( const sal_Char
* pImplName
, void * pServiceManager
, void * /*pRegistryKey*/ )
97 uno::Reference
< XInterface
> xFactory
;
100 rtl::OUString implName
= rtl::OUString::createFromAscii( pImplName
);
102 if ( pServiceManager
&& implName
.equals( DocumentDigitalSignatures::GetImplementationName() ) )
104 // DocumentDigitalSignatures
105 xFactory
= cppu::createSingleComponentFactory(
106 DocumentDigitalSignatures_CreateInstance
,
107 rtl::OUString::createFromAscii( pImplName
),
108 DocumentDigitalSignatures::GetSupportedServiceNames() );
110 else if ( pServiceManager
&& implName
.equals( CertificateContainer::impl_getStaticImplementationName() ))
112 // CertificateContainer
113 xFactory
= cppu::createOneInstanceFactory(
114 reinterpret_cast< lang::XMultiServiceFactory
* >( pServiceManager
),
115 rtl::OUString::createFromAscii( pImplName
),
116 CertificateContainer::impl_createInstance
,
117 CertificateContainer::impl_getStaticSupportedServiceNames() );
123 pRet
= xFactory
.get();