1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2a97ec55SAndrew Rist  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2a97ec55SAndrew Rist  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19*2a97ec55SAndrew Rist  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir #include <string.h>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <usr/reflserv.hxx>  // for EXTERN_SERVICE_CALLTYPE
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <usr/factoryhlp.hxx>
31cdf0e10cSrcweir #include "testfactreg.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 
34cdf0e10cSrcweir using namespace vos;
35cdf0e10cSrcweir using namespace usr;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #ifdef __cplusplus
38cdf0e10cSrcweir extern "C"
39cdf0e10cSrcweir {
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir 
exService_writeRegEntry(const UNO_INTERFACE (XRegistryKey)* xUnoKey)42cdf0e10cSrcweir BOOL EXTERN_SERVICE_CALLTYPE exService_writeRegEntry(
43cdf0e10cSrcweir         const UNO_INTERFACE(XRegistryKey)* xUnoKey)
44cdf0e10cSrcweir 
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	XRegistryKeyRef   xKey;
47cdf0e10cSrcweir 	uno2smart(xKey, *xUnoKey);
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	UString str = UString( L"/" ) + OPipeTest_getImplementationName() + UString( L"/UNO/SERVICES" );
50cdf0e10cSrcweir 	XRegistryKeyRef xNewKey = xKey->createKey( str );
51cdf0e10cSrcweir 	xNewKey->createKey( OPipeTest_getServiceName() );
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	str = UString( L"/" ) + ODataStreamTest_getImplementationName(1) + UString( L"/UNO/SERVICES" );
54cdf0e10cSrcweir 	xNewKey = xKey->createKey( str );
55cdf0e10cSrcweir 	xNewKey->createKey( ODataStreamTest_getServiceName(1) );
56cdf0e10cSrcweir 
57cdf0e10cSrcweir 	str = UString( L"/" ) + ODataStreamTest_getImplementationName(2) + UString( L"/UNO/SERVICES" );
58cdf0e10cSrcweir 	xNewKey = xKey->createKey( str );
59cdf0e10cSrcweir 	xNewKey->createKey( ODataStreamTest_getServiceName(2) );
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	str = UString( L"/" ) + OObjectStreamTest_getImplementationName(1) + UString( L"/UNO/SERVICES" );
62cdf0e10cSrcweir 	xNewKey = xKey->createKey( str );
63cdf0e10cSrcweir 	xNewKey->createKey( OObjectStreamTest_getServiceName(1) );
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	str = UString( L"/" ) + OObjectStreamTest_getImplementationName(2) + UString( L"/UNO/SERVICES" );
66cdf0e10cSrcweir 	xNewKey = xKey->createKey( str );
67cdf0e10cSrcweir 	xNewKey->createKey( OObjectStreamTest_getServiceName(2) );
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	str = UString( L"/" ) + OMarkableOutputStreamTest_getImplementationName() + UString( L"/UNO/SERVICES" );
70cdf0e10cSrcweir 	xNewKey = xKey->createKey( str );
71cdf0e10cSrcweir 	xNewKey->createKey( OMarkableOutputStreamTest_getServiceName() );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	str = UString( L"/" ) + OMarkableInputStreamTest_getImplementationName() + UString( L"/UNO/SERVICES" );
74cdf0e10cSrcweir 	xNewKey = xKey->createKey( str );
75cdf0e10cSrcweir 	xNewKey->createKey( OMarkableInputStreamTest_getServiceName() );
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	str = UString( L"/" ) + OMyPersistObject_getImplementationName() + UString( L"/UNO/SERVICES" );
78cdf0e10cSrcweir 	xNewKey = xKey->createKey( str );
79cdf0e10cSrcweir 	xNewKey->createKey( OMyPersistObject_getServiceName() );
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	return TRUE;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
UNO_INTERFACE(XInterface)85cdf0e10cSrcweir UNO_INTERFACE(XInterface) EXTERN_SERVICE_CALLTYPE exService_getFactory
86cdf0e10cSrcweir (
87cdf0e10cSrcweir 	const wchar_t* implementationName,
88cdf0e10cSrcweir 	const UNO_INTERFACE(XMultiServiceFactory)* xUnoFact,
89cdf0e10cSrcweir 	const UNO_INTERFACE(XRegistryKey)*
90cdf0e10cSrcweir )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	UNO_INTERFACE(XInterface) xUnoRet = {0, 0};
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	XInterfaceRef 			xRet;
95cdf0e10cSrcweir 	XMultiServiceFactoryRef xSMgr;
96cdf0e10cSrcweir 	UString					aImplementationName(implementationName);
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	uno2smart(xSMgr, *xUnoFact);
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	if (aImplementationName == OPipeTest_getImplementationName() )
101cdf0e10cSrcweir 	{
102cdf0e10cSrcweir 		xRet = createSingleFactory( xSMgr, implementationName,
103cdf0e10cSrcweir 									OPipeTest_CreateInstance,
104cdf0e10cSrcweir 									OPipeTest_getSupportedServiceNames() );
105cdf0e10cSrcweir 	}
106cdf0e10cSrcweir 	else if( aImplementationName == ODataStreamTest_getImplementationName(1) ) {
107cdf0e10cSrcweir 		xRet = createSingleFactory( xSMgr , implementationName,
108cdf0e10cSrcweir 									ODataStreamTest_CreateInstance,
109cdf0e10cSrcweir 									ODataStreamTest_getSupportedServiceNames(1) );
110cdf0e10cSrcweir 	}
111cdf0e10cSrcweir 	else if( aImplementationName == ODataStreamTest_getImplementationName(2) ) {
112cdf0e10cSrcweir 		xRet = createSingleFactory( xSMgr , implementationName,
113cdf0e10cSrcweir 									ODataStreamTest_CreateInstance,
114cdf0e10cSrcweir 									ODataStreamTest_getSupportedServiceNames(2) );
115cdf0e10cSrcweir 	}
116cdf0e10cSrcweir 	else if( aImplementationName == OObjectStreamTest_getImplementationName(1) ) {
117cdf0e10cSrcweir 		xRet = createSingleFactory( xSMgr , implementationName,
118cdf0e10cSrcweir 									OObjectStreamTest_CreateInstance,
119cdf0e10cSrcweir 									OObjectStreamTest_getSupportedServiceNames(1) );
120cdf0e10cSrcweir 	}
121cdf0e10cSrcweir 	else if( aImplementationName == OObjectStreamTest_getImplementationName(2) ) {
122cdf0e10cSrcweir 		xRet = createSingleFactory( xSMgr , implementationName,
123cdf0e10cSrcweir 									OObjectStreamTest_CreateInstance,
124cdf0e10cSrcweir 									OObjectStreamTest_getSupportedServiceNames(2) );
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 	else if( aImplementationName == OMarkableOutputStreamTest_getImplementationName() ) {
127cdf0e10cSrcweir 		xRet = createSingleFactory( xSMgr , implementationName,
128cdf0e10cSrcweir 									OMarkableOutputStreamTest_CreateInstance,
129cdf0e10cSrcweir 									OMarkableOutputStreamTest_getSupportedServiceNames() );
130cdf0e10cSrcweir 	}
131cdf0e10cSrcweir 	else if( aImplementationName == OMarkableInputStreamTest_getImplementationName() ) {
132cdf0e10cSrcweir 		xRet = createSingleFactory( xSMgr , implementationName,
133cdf0e10cSrcweir 									OMarkableInputStreamTest_CreateInstance,
134cdf0e10cSrcweir 									OMarkableInputStreamTest_getSupportedServiceNames() );
135cdf0e10cSrcweir 	}
136cdf0e10cSrcweir 	else if( aImplementationName == OMyPersistObject_getImplementationName() ) {
137cdf0e10cSrcweir 		xRet = createSingleFactory( xSMgr , implementationName,
138cdf0e10cSrcweir 									OMyPersistObject_CreateInstance,
139cdf0e10cSrcweir 									OMyPersistObject_getSupportedServiceNames() );
140cdf0e10cSrcweir 	}
141cdf0e10cSrcweir 	if (xRet.is())
142cdf0e10cSrcweir 	{
143cdf0e10cSrcweir 		smart2uno(xRet, xUnoRet);
144cdf0e10cSrcweir 	}
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	return xUnoRet;
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir #ifdef __cplusplus
150cdf0e10cSrcweir }
151cdf0e10cSrcweir #endif
152cdf0e10cSrcweir 
createSeq(char * p)153cdf0e10cSrcweir Sequence<BYTE> createSeq( char * p )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir 	Sequence<BYTE> seq( strlen( p )+1 );
156cdf0e10cSrcweir 	strcpy( (char * ) seq.getArray() , p );
157cdf0e10cSrcweir 	return seq;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
createIntSeq(INT32 i)160cdf0e10cSrcweir Sequence<BYTE> createIntSeq( INT32 i )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir 	char pcCount[20];
163cdf0e10cSrcweir 	sprintf( pcCount , "%d" , i );
164cdf0e10cSrcweir 	return createSeq( pcCount );
165cdf0e10cSrcweir }
166cdf0e10cSrcweir 
167