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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_extensions.hxx"
26 #include <string.h>
27 
28 #include <usr/reflserv.hxx>  // for EXTERN_SERVICE_CALLTYPE
29 
30 #include <usr/factoryhlp.hxx>
31 #include "testfactreg.hxx"
32 
33 
34 using namespace vos;
35 using namespace usr;
36 
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #endif
41 
exService_writeRegEntry(const UNO_INTERFACE (XRegistryKey)* xUnoKey)42 BOOL EXTERN_SERVICE_CALLTYPE exService_writeRegEntry(
43         const UNO_INTERFACE(XRegistryKey)* xUnoKey)
44 
45 {
46 	XRegistryKeyRef   xKey;
47 	uno2smart(xKey, *xUnoKey);
48 
49 	UString str = UString( L"/" ) + OPipeTest_getImplementationName() + UString( L"/UNO/SERVICES" );
50 	XRegistryKeyRef xNewKey = xKey->createKey( str );
51 	xNewKey->createKey( OPipeTest_getServiceName() );
52 
53 	str = UString( L"/" ) + ODataStreamTest_getImplementationName(1) + UString( L"/UNO/SERVICES" );
54 	xNewKey = xKey->createKey( str );
55 	xNewKey->createKey( ODataStreamTest_getServiceName(1) );
56 
57 	str = UString( L"/" ) + ODataStreamTest_getImplementationName(2) + UString( L"/UNO/SERVICES" );
58 	xNewKey = xKey->createKey( str );
59 	xNewKey->createKey( ODataStreamTest_getServiceName(2) );
60 
61 	str = UString( L"/" ) + OObjectStreamTest_getImplementationName(1) + UString( L"/UNO/SERVICES" );
62 	xNewKey = xKey->createKey( str );
63 	xNewKey->createKey( OObjectStreamTest_getServiceName(1) );
64 
65 	str = UString( L"/" ) + OObjectStreamTest_getImplementationName(2) + UString( L"/UNO/SERVICES" );
66 	xNewKey = xKey->createKey( str );
67 	xNewKey->createKey( OObjectStreamTest_getServiceName(2) );
68 
69 	str = UString( L"/" ) + OMarkableOutputStreamTest_getImplementationName() + UString( L"/UNO/SERVICES" );
70 	xNewKey = xKey->createKey( str );
71 	xNewKey->createKey( OMarkableOutputStreamTest_getServiceName() );
72 
73 	str = UString( L"/" ) + OMarkableInputStreamTest_getImplementationName() + UString( L"/UNO/SERVICES" );
74 	xNewKey = xKey->createKey( str );
75 	xNewKey->createKey( OMarkableInputStreamTest_getServiceName() );
76 
77 	str = UString( L"/" ) + OMyPersistObject_getImplementationName() + UString( L"/UNO/SERVICES" );
78 	xNewKey = xKey->createKey( str );
79 	xNewKey->createKey( OMyPersistObject_getServiceName() );
80 
81 	return TRUE;
82 }
83 
84 
UNO_INTERFACE(XInterface)85 UNO_INTERFACE(XInterface) EXTERN_SERVICE_CALLTYPE exService_getFactory
86 (
87 	const wchar_t* implementationName,
88 	const UNO_INTERFACE(XMultiServiceFactory)* xUnoFact,
89 	const UNO_INTERFACE(XRegistryKey)*
90 )
91 {
92 	UNO_INTERFACE(XInterface) xUnoRet = {0, 0};
93 
94 	XInterfaceRef 			xRet;
95 	XMultiServiceFactoryRef xSMgr;
96 	UString					aImplementationName(implementationName);
97 
98 	uno2smart(xSMgr, *xUnoFact);
99 
100 	if (aImplementationName == OPipeTest_getImplementationName() )
101 	{
102 		xRet = createSingleFactory( xSMgr, implementationName,
103 									OPipeTest_CreateInstance,
104 									OPipeTest_getSupportedServiceNames() );
105 	}
106 	else if( aImplementationName == ODataStreamTest_getImplementationName(1) ) {
107 		xRet = createSingleFactory( xSMgr , implementationName,
108 									ODataStreamTest_CreateInstance,
109 									ODataStreamTest_getSupportedServiceNames(1) );
110 	}
111 	else if( aImplementationName == ODataStreamTest_getImplementationName(2) ) {
112 		xRet = createSingleFactory( xSMgr , implementationName,
113 									ODataStreamTest_CreateInstance,
114 									ODataStreamTest_getSupportedServiceNames(2) );
115 	}
116 	else if( aImplementationName == OObjectStreamTest_getImplementationName(1) ) {
117 		xRet = createSingleFactory( xSMgr , implementationName,
118 									OObjectStreamTest_CreateInstance,
119 									OObjectStreamTest_getSupportedServiceNames(1) );
120 	}
121 	else if( aImplementationName == OObjectStreamTest_getImplementationName(2) ) {
122 		xRet = createSingleFactory( xSMgr , implementationName,
123 									OObjectStreamTest_CreateInstance,
124 									OObjectStreamTest_getSupportedServiceNames(2) );
125 	}
126 	else if( aImplementationName == OMarkableOutputStreamTest_getImplementationName() ) {
127 		xRet = createSingleFactory( xSMgr , implementationName,
128 									OMarkableOutputStreamTest_CreateInstance,
129 									OMarkableOutputStreamTest_getSupportedServiceNames() );
130 	}
131 	else if( aImplementationName == OMarkableInputStreamTest_getImplementationName() ) {
132 		xRet = createSingleFactory( xSMgr , implementationName,
133 									OMarkableInputStreamTest_CreateInstance,
134 									OMarkableInputStreamTest_getSupportedServiceNames() );
135 	}
136 	else if( aImplementationName == OMyPersistObject_getImplementationName() ) {
137 		xRet = createSingleFactory( xSMgr , implementationName,
138 									OMyPersistObject_CreateInstance,
139 									OMyPersistObject_getSupportedServiceNames() );
140 	}
141 	if (xRet.is())
142 	{
143 		smart2uno(xRet, xUnoRet);
144 	}
145 
146 	return xUnoRet;
147 }
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
createSeq(char * p)153 Sequence<BYTE> createSeq( char * p )
154 {
155 	Sequence<BYTE> seq( strlen( p )+1 );
156 	strcpy( (char * ) seq.getArray() , p );
157 	return seq;
158 }
159 
createIntSeq(INT32 i)160 Sequence<BYTE> createIntSeq( INT32 i )
161 {
162 	char pcCount[20];
163 	sprintf( pcCount , "%d" , i );
164 	return createSeq( pcCount );
165 }
166 
167