0
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* THIS FILE IS AUTOGENERATED. Do not modify the contents of this file directly
|
|
16 |
* as changes will be lost
|
|
17 |
* Tue Nov 16 15:19:57 2004
|
|
18 |
* System Includes
|
|
19 |
*
|
|
20 |
*/
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
#include <assert.h>
|
|
25 |
|
|
26 |
|
|
27 |
/****************************************************************************************
|
|
28 |
*
|
|
29 |
* Local Includes
|
|
30 |
*
|
|
31 |
***************************************************************************************/
|
|
32 |
#include "CSvcGenericstub.h"
|
|
33 |
#include "CSGenericstub.h"
|
|
34 |
#include "CComponentManager.h"
|
|
35 |
|
|
36 |
|
|
37 |
/****************************************************************************************
|
|
38 |
*
|
|
39 |
* Static Variables
|
|
40 |
*
|
|
41 |
***************************************************************************************/
|
|
42 |
static CComponentManager<CSGenericstub> *iComponentManager;
|
|
43 |
static CSGenericstub *iGenericStub;
|
|
44 |
|
|
45 |
|
|
46 |
/****************************************************************************************
|
|
47 |
*
|
|
48 |
* PUBLIC FUNCTION: ss_startuprpcservice
|
|
49 |
*
|
|
50 |
***************************************************************************************/
|
|
51 |
int *ss_startuprpcservice_1( TStartupInfo *aArgs, CLIENT * /*aDutout*/ )
|
|
52 |
{
|
|
53 |
static int rv;
|
|
54 |
|
|
55 |
// if the service is already started then return an error
|
|
56 |
if( iComponentManager != NULL ) {
|
|
57 |
rv = ERR_SERVICE_ALREADY_STARTED;
|
|
58 |
return &rv;
|
|
59 |
}
|
|
60 |
|
|
61 |
// create the component manager
|
|
62 |
iComponentManager = new CComponentManager<CSGenericstub>( INFO_MAXIMUM_OBJECTS );
|
|
63 |
if( iComponentManager == NULL ) {
|
|
64 |
rv = ERR_FAILED_TO_CREATE_COMPONENT_MANAGER;
|
|
65 |
return &rv;
|
|
66 |
}
|
|
67 |
|
|
68 |
iGenericStub = new CSGenericstub();
|
|
69 |
if( iGenericStub != NULL )
|
|
70 |
{
|
|
71 |
if( !iGenericStub->Setup() )
|
|
72 |
{
|
|
73 |
rv = ERR_FAILED_TO_CONNECT;
|
|
74 |
return &rv;
|
|
75 |
}
|
|
76 |
}
|
|
77 |
else
|
|
78 |
{
|
|
79 |
rv = ERR_FAILED_TO_CONNECT;
|
|
80 |
return &rv;
|
|
81 |
}
|
|
82 |
|
|
83 |
// call the custom service manager
|
|
84 |
rv = CSvcGenericstub::StartRPCService( iComponentManager, aArgs );
|
|
85 |
if( rv != ERR_NONE ) {
|
|
86 |
delete iComponentManager;
|
|
87 |
iComponentManager = NULL;
|
|
88 |
return &rv;
|
|
89 |
}
|
|
90 |
|
|
91 |
// success
|
|
92 |
rv = ERR_NONE;
|
|
93 |
return &rv;
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
/****************************************************************************************
|
|
98 |
*
|
|
99 |
* PUBLIC FUNCTION: sc_shutdownrpcservice
|
|
100 |
*
|
|
101 |
***************************************************************************************/
|
|
102 |
int *sc_shutdownrpcservice_1( int *aArgs, CLIENT * /*aDutout*/ )
|
|
103 |
{
|
|
104 |
static int rv;
|
|
105 |
int instance_count;
|
|
106 |
int err;
|
|
107 |
|
|
108 |
// check that the service is started
|
|
109 |
if( iComponentManager == NULL ) {
|
|
110 |
rv = ERR_SERVICE_NOT_RUNNING;
|
|
111 |
return &rv;
|
|
112 |
}
|
|
113 |
|
|
114 |
// if there are active sessions and the force flag isn't set then return an error
|
|
115 |
instance_count = iComponentManager->GetInstanceCount();
|
|
116 |
if( (instance_count > 0) && (*aArgs == 0) ) {
|
|
117 |
rv = ERR_ACTIVE_USER_SESSIONS;
|
|
118 |
return &rv;
|
|
119 |
};
|
|
120 |
|
|
121 |
// if the force flag IS set then reset all active connections
|
|
122 |
instance_count = iComponentManager->GetInstanceCount();
|
|
123 |
if( instance_count > 0 ) {
|
|
124 |
err = iComponentManager->DeleteAllInstances();
|
|
125 |
if( err != 0 ) {
|
|
126 |
rv = ERR_FAILED_TO_REMOVE_ACTIVE_SESSIONS;
|
|
127 |
return &rv;
|
|
128 |
}
|
|
129 |
}
|
|
130 |
|
|
131 |
// call the custom service manager
|
|
132 |
rv = CSvcGenericstub::StopRPCService();
|
|
133 |
if( rv != ERR_NONE ) {
|
|
134 |
return &rv;
|
|
135 |
}
|
|
136 |
|
|
137 |
// delete the component manager
|
|
138 |
delete iComponentManager;
|
|
139 |
iComponentManager = NULL;
|
|
140 |
|
|
141 |
delete iGenericStub;
|
|
142 |
iGenericStub = NULL;
|
|
143 |
|
|
144 |
// success
|
|
145 |
rv = ERR_NONE;
|
|
146 |
return &rv;
|
|
147 |
}
|
|
148 |
|
|
149 |
|
|
150 |
/****************************************************************************************
|
|
151 |
*
|
|
152 |
* PUBLIC FUNCTION: list_connections
|
|
153 |
*
|
|
154 |
***************************************************************************************/
|
|
155 |
TComponentList *list_connections_1( void * /*aArgs*/, CLIENT * /*aDutout*/ )
|
|
156 |
{
|
|
157 |
static TComponentList rv;
|
|
158 |
int i, valid_count, component_instance_count;
|
|
159 |
|
|
160 |
//free any allocated memory
|
|
161 |
if( rv.TComponentList_val != NULL ) {
|
|
162 |
free( rv.TComponentList_val );
|
|
163 |
rv.TComponentList_val = NULL;
|
|
164 |
rv.TComponentList_len = 0;
|
|
165 |
}
|
|
166 |
|
|
167 |
// check that the service is started
|
|
168 |
if( iComponentManager == NULL ) {
|
|
169 |
CSvcGenericstub::SetError( LIST_CONNECTIONS, (void*)&rv, ERR_SERVICE_NOT_RUNNING );
|
|
170 |
return &rv;
|
|
171 |
}
|
|
172 |
|
|
173 |
// set the return value to generic error
|
|
174 |
CSvcGenericstub::SetError( LIST_CONNECTIONS, (void*)&rv, ERR_FAILED_TO_RETRIEVE_KEY );
|
|
175 |
|
|
176 |
// get the number of active component instances
|
|
177 |
component_instance_count = iComponentManager->GetInstanceCount();
|
|
178 |
|
|
179 |
// if there are one or more instances then allocate the memory
|
|
180 |
if( component_instance_count > 0 ) {
|
|
181 |
rv.TComponentList_val = (int*)malloc( sizeof(int) * component_instance_count );
|
|
182 |
assert( rv.TComponentList_val != NULL );
|
|
183 |
rv.TComponentList_len = component_instance_count;
|
|
184 |
}
|
|
185 |
|
|
186 |
// store all the currently active IDs in the list
|
|
187 |
for( i = 0, valid_count = 0; i < INFO_MAXIMUM_OBJECTS; i++ ) {
|
|
188 |
if( iComponentManager->IsValidKey(i) != 0 ) {
|
|
189 |
assert( valid_count < component_instance_count );
|
|
190 |
(rv.TComponentList_val)[valid_count++] = i;
|
|
191 |
}
|
|
192 |
}
|
|
193 |
|
|
194 |
// ok return everything
|
|
195 |
return &rv;
|
|
196 |
}
|
|
197 |
|
|
198 |
|
|
199 |
/****************************************************************************************
|
|
200 |
*
|
|
201 |
* PUBLIC FUNCTION: cstr_startprocess
|
|
202 |
*
|
|
203 |
***************************************************************************************/
|
|
204 |
int *cstr_startprocess_1( char **aArgs, CLIENT * /*aDutout*/ )
|
|
205 |
{
|
|
206 |
static int rv;
|
|
207 |
int result;
|
|
208 |
int internal_err;
|
|
209 |
int instance_key;
|
|
210 |
CSGenericstub *session;
|
|
211 |
|
|
212 |
// check that the service is started
|
|
213 |
if( iComponentManager == NULL ) {
|
|
214 |
rv = ERR_SERVICE_NOT_RUNNING;
|
|
215 |
return &rv;
|
|
216 |
}
|
|
217 |
|
|
218 |
// create a new component instance
|
|
219 |
instance_key = iComponentManager->CreateInstance();
|
|
220 |
if( instance_key < 0 ) {
|
|
221 |
rv = instance_key;
|
|
222 |
return &rv;
|
|
223 |
}
|
|
224 |
|
|
225 |
// get the instance
|
|
226 |
session = iComponentManager->GetInstance( instance_key );
|
|
227 |
assert( session != NULL );
|
|
228 |
|
|
229 |
// call the corresponding method on the instance
|
|
230 |
rv = session->cstr_startprocess( *aArgs );
|
|
231 |
result = rv;
|
|
232 |
|
|
233 |
// if the method fails then we cleanup the instance -- otherwise we set the instance key
|
|
234 |
// as the return value
|
|
235 |
if( result != ERR_NONE ) {
|
|
236 |
internal_err = iComponentManager->DeleteInstance( instance_key );
|
|
237 |
assert( internal_err == 0 );
|
|
238 |
} else {
|
|
239 |
rv = instance_key;
|
|
240 |
}
|
|
241 |
|
|
242 |
// done
|
|
243 |
return &rv;
|
|
244 |
}
|
|
245 |
|
|
246 |
|
|
247 |
/****************************************************************************************
|
|
248 |
*
|
|
249 |
* PUBLIC FUNCTION: dstr_removeprocess
|
|
250 |
*
|
|
251 |
***************************************************************************************/
|
|
252 |
int *dstr_removeprocess_1( int *aArgs, CLIENT * /*aDutout*/ )
|
|
253 |
{
|
|
254 |
static int rv;
|
|
255 |
int result;
|
|
256 |
int internal_err;
|
|
257 |
int instance_key;
|
|
258 |
int should_delete = 1;
|
|
259 |
CSGenericstub *session;
|
|
260 |
|
|
261 |
// check that the service is started
|
|
262 |
if( iComponentManager == NULL ) {
|
|
263 |
rv = ERR_SERVICE_NOT_RUNNING;
|
|
264 |
return &rv;
|
|
265 |
}
|
|
266 |
|
|
267 |
// get the key for the instance from the args
|
|
268 |
instance_key = CSvcGenericstub::GetInstanceKeyFromArgs( DSTR_REMOVEPROCESS, (void*)aArgs );
|
|
269 |
if( instance_key < 0 ) {
|
|
270 |
rv = instance_key;
|
|
271 |
return &rv;
|
|
272 |
}
|
|
273 |
// make sure the key is valid
|
|
274 |
if( iComponentManager->IsValidKey(instance_key) == 0 ) {
|
|
275 |
rv = ERR_INSTANCE_DOES_NOT_EXIST;
|
|
276 |
return &rv;
|
|
277 |
}
|
|
278 |
|
|
279 |
// get the instance
|
|
280 |
session = iComponentManager->GetInstance( instance_key );
|
|
281 |
assert( session != NULL );
|
|
282 |
|
|
283 |
// call the corresponding method on the instance
|
|
284 |
rv = session->dstr_removeprocess( *aArgs, &should_delete );
|
|
285 |
|
|
286 |
result = rv;
|
|
287 |
|
|
288 |
// it is illegal for the method to succeed but not delete the instance
|
|
289 |
assert( (result != ERR_NONE) || (should_delete == 1) );
|
|
290 |
|
|
291 |
// delete the instance if requested
|
|
292 |
if( should_delete != 0 ) {
|
|
293 |
internal_err = iComponentManager->DeleteInstance( instance_key );
|
|
294 |
assert( internal_err == ERR_NONE );
|
|
295 |
}
|
|
296 |
|
|
297 |
// done
|
|
298 |
return &rv;
|
|
299 |
}
|
|
300 |
|
|
301 |
|
|
302 |
/****************************************************************************************
|
|
303 |
*
|
|
304 |
* PUBLIC FUNCTION: run_command
|
|
305 |
*
|
|
306 |
***************************************************************************************/
|
|
307 |
int *run_command_1( TCall *aArgs, CLIENT *aDutout )
|
|
308 |
{
|
|
309 |
static int rv;
|
|
310 |
// check that the service is started
|
|
311 |
if( iComponentManager == NULL ) {
|
|
312 |
rv = ERR_SERVICE_NOT_RUNNING;
|
|
313 |
return &rv;
|
|
314 |
}
|
|
315 |
// call the corresponding method on the instance
|
|
316 |
rv = iGenericStub->run_command(*aArgs);
|
|
317 |
return &rv;
|
|
318 |
}
|