|
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 * Fri Dec 05 11:06:04 2003 |
|
18 * System Includes |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #include <assert.h> |
|
26 |
|
27 |
|
28 /**************************************************************************************** |
|
29 * |
|
30 * Local Includes |
|
31 * |
|
32 ***************************************************************************************/ |
|
33 #include "CSvcPppcontroller.h" |
|
34 #include "CSPppcontroller.h" |
|
35 #include "CComponentManager.h" |
|
36 |
|
37 |
|
38 /**************************************************************************************** |
|
39 * |
|
40 * Static Variables |
|
41 * |
|
42 ***************************************************************************************/ |
|
43 static CComponentManager<CSPppcontroller> *iComponentManager; |
|
44 |
|
45 |
|
46 /**************************************************************************************** |
|
47 * |
|
48 * PUBLIC FUNCTION: ss_startuprpcservice |
|
49 * |
|
50 ***************************************************************************************/ |
|
51 int *ss_startuprpcservice_4( 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<CSPppcontroller>( INFO_MAXIMUM_OBJECTS ); |
|
63 if( iComponentManager == NULL ) { |
|
64 rv = ERR_FAILED_TO_CREATE_COMPONENT_MANAGER; |
|
65 return &rv; |
|
66 } |
|
67 |
|
68 // call the custom service manager |
|
69 rv = CSvcPppcontroller::StartRPCService( iComponentManager, aArgs ); |
|
70 if( rv != ERR_NONE ) { |
|
71 delete iComponentManager; |
|
72 iComponentManager = NULL; |
|
73 return &rv; |
|
74 } |
|
75 |
|
76 // success |
|
77 rv = ERR_NONE; |
|
78 return &rv; |
|
79 } |
|
80 |
|
81 |
|
82 /**************************************************************************************** |
|
83 * |
|
84 * PUBLIC FUNCTION: sc_shutdownrpcservice |
|
85 * |
|
86 ***************************************************************************************/ |
|
87 int *sc_shutdownrpcservice_4( int *aArgs, CLIENT *aDutout ) |
|
88 { |
|
89 static int rv; |
|
90 int instance_count; |
|
91 int err; |
|
92 |
|
93 // check that the service is started |
|
94 if( iComponentManager == NULL ) { |
|
95 rv = ERR_SERVICE_NOT_RUNNING; |
|
96 return &rv; |
|
97 } |
|
98 |
|
99 // if there are active sessions and the force flag isn't set then return an error |
|
100 instance_count = iComponentManager->GetInstanceCount(); |
|
101 if( (instance_count > 0) && (*aArgs == 0) ) { |
|
102 rv = ERR_ACTIVE_USER_SESSIONS; |
|
103 return &rv; |
|
104 }; |
|
105 |
|
106 // if the force flag IS set then reset all active connections |
|
107 instance_count = iComponentManager->GetInstanceCount(); |
|
108 if( instance_count > 0 ) { |
|
109 err = iComponentManager->DeleteAllInstances(); |
|
110 if( err != 0 ) { |
|
111 rv = ERR_FAILED_TO_REMOVE_ACTIVE_SESSIONS; |
|
112 return &rv; |
|
113 } |
|
114 } |
|
115 |
|
116 // call the custom service manager |
|
117 rv = CSvcPppcontroller::StopRPCService(); |
|
118 if( rv != ERR_NONE ) { |
|
119 return &rv; |
|
120 } |
|
121 |
|
122 // delete the component manager |
|
123 delete iComponentManager; |
|
124 iComponentManager = NULL; |
|
125 |
|
126 // success |
|
127 rv = ERR_NONE; |
|
128 return &rv; |
|
129 } |
|
130 |
|
131 |
|
132 /**************************************************************************************** |
|
133 * |
|
134 * PUBLIC FUNCTION: list_devices |
|
135 * |
|
136 ***************************************************************************************/ |
|
137 TComponentList *list_devices_4( void *aArgs, CLIENT *aDutout ) |
|
138 { |
|
139 static TComponentList rv; |
|
140 int i, valid_count, component_instance_count; |
|
141 |
|
142 //free any allocated memory |
|
143 if( rv.TComponentList_val != NULL ) { |
|
144 free( rv.TComponentList_val ); |
|
145 rv.TComponentList_val = NULL; |
|
146 rv.TComponentList_len = 0; |
|
147 } |
|
148 |
|
149 // check that the service is started |
|
150 if( iComponentManager == NULL ) { |
|
151 CSvcPppcontroller::SetError( LIST_DEVICES, (void*)&rv, ERR_SERVICE_NOT_RUNNING ); |
|
152 return &rv; |
|
153 } |
|
154 |
|
155 // set the return value to generic error |
|
156 CSvcPppcontroller::SetError( LIST_DEVICES, (void*)&rv, ERR_FAILED_TO_RETRIEVE_KEY ); |
|
157 |
|
158 // get the number of active component instances |
|
159 component_instance_count = iComponentManager->GetInstanceCount(); |
|
160 |
|
161 // if there are one or more instances then allocate the memory |
|
162 if( component_instance_count > 0 ) { |
|
163 rv.TComponentList_val = (int*)malloc( sizeof(int) * component_instance_count ); |
|
164 assert( rv.TComponentList_val != NULL ); |
|
165 rv.TComponentList_len = component_instance_count; |
|
166 } |
|
167 |
|
168 // store all the currently active IDs in the list |
|
169 for( i = 0, valid_count = 0; i < INFO_MAXIMUM_OBJECTS; i++ ) { |
|
170 if( iComponentManager->IsValidKey(i) != 0 ) { |
|
171 assert( valid_count < component_instance_count ); |
|
172 (rv.TComponentList_val)[valid_count++] = i; |
|
173 } |
|
174 } |
|
175 |
|
176 // ok return everything |
|
177 return &rv; |
|
178 } |
|
179 |
|
180 |
|
181 /**************************************************************************************** |
|
182 * |
|
183 * PUBLIC FUNCTION: cstr_startpppsession |
|
184 * |
|
185 ***************************************************************************************/ |
|
186 TResult *cstr_startpppsession_4( TPppSessionConfig *aArgs, CLIENT *aDutout ) |
|
187 { |
|
188 static TResult rv; |
|
189 int result; |
|
190 int internal_err; |
|
191 int instance_key; |
|
192 CSPppcontroller *session; |
|
193 |
|
194 // check that the service is started |
|
195 if( iComponentManager == NULL ) { |
|
196 CSvcPppcontroller::SetError( CSTR_STARTPPPSESSION, (void*)&rv, ERR_SERVICE_NOT_RUNNING ); |
|
197 return &rv; |
|
198 } |
|
199 |
|
200 // create a new component instance |
|
201 instance_key = iComponentManager->CreateInstance(); |
|
202 if( instance_key < 0 ) { |
|
203 CSvcPppcontroller::SetError( CSTR_STARTPPPSESSION, (void*)&rv, instance_key ); |
|
204 return &rv; |
|
205 } |
|
206 |
|
207 // get the instance |
|
208 session = iComponentManager->GetInstance( instance_key ); |
|
209 assert( session != NULL ); |
|
210 |
|
211 // call the corresponding method on the instance |
|
212 rv = session->cstr_startpppsession( *aArgs ); |
|
213 result = CSvcPppcontroller::GetError( CSTR_STARTPPPSESSION, (void*)&rv ); |
|
214 |
|
215 // if the method fails then we cleanup the instance -- otherwise we set the instance key |
|
216 // as the return value |
|
217 if( result != ERR_NONE ) { |
|
218 internal_err = iComponentManager->DeleteInstance( instance_key ); |
|
219 assert( internal_err == 0 ); |
|
220 } else { |
|
221 CSvcPppcontroller::SetError( CSTR_STARTPPPSESSION, (void*)&rv, instance_key ); |
|
222 } |
|
223 |
|
224 // done |
|
225 return &rv; |
|
226 } |
|
227 |
|
228 |
|
229 /**************************************************************************************** |
|
230 * |
|
231 * PUBLIC FUNCTION: dstr_removepppsession |
|
232 * |
|
233 ***************************************************************************************/ |
|
234 TResult *dstr_removepppsession_4( int *aArgs, CLIENT *aDutout ) |
|
235 { |
|
236 static TResult rv; |
|
237 int result; |
|
238 int internal_err; |
|
239 int instance_key; |
|
240 int should_delete = 1; |
|
241 CSPppcontroller *session; |
|
242 |
|
243 // check that the service is started |
|
244 if( iComponentManager == NULL ) { |
|
245 CSvcPppcontroller::SetError( DSTR_REMOVEPPPSESSION, (void*)&rv, ERR_SERVICE_NOT_RUNNING ); |
|
246 return &rv; |
|
247 } |
|
248 |
|
249 // get the key for the instance from the args |
|
250 instance_key = CSvcPppcontroller::GetInstanceKeyFromArgs( DSTR_REMOVEPPPSESSION, (void*)aArgs ); |
|
251 if( instance_key < 0 ) { |
|
252 CSvcPppcontroller::SetError( DSTR_REMOVEPPPSESSION, (void*)&rv, instance_key ); |
|
253 return &rv; |
|
254 } |
|
255 // make sure the key is valid |
|
256 if( iComponentManager->IsValidKey(instance_key) == 0 ) { |
|
257 CSvcPppcontroller::SetError( DSTR_REMOVEPPPSESSION, (void*)&rv, ERR_INSTANCE_DOES_NOT_EXIST ); |
|
258 return &rv; |
|
259 } |
|
260 |
|
261 // get the instance |
|
262 session = iComponentManager->GetInstance( instance_key ); |
|
263 assert( session != NULL ); |
|
264 |
|
265 // call the corresponding method on the instance |
|
266 rv = session->dstr_removepppsession( *aArgs, &should_delete ); |
|
267 |
|
268 result = CSvcPppcontroller::GetError( DSTR_REMOVEPPPSESSION, (void*)&rv ); |
|
269 |
|
270 // it is illegal for the method to succeed but not delete the instance |
|
271 assert( (result != ERR_NONE) || (should_delete == 1) ); |
|
272 |
|
273 // delete the instance if requested |
|
274 if( should_delete != 0 ) { |
|
275 internal_err = iComponentManager->DeleteInstance( instance_key ); |
|
276 assert( internal_err == ERR_NONE ); |
|
277 } |
|
278 |
|
279 // done |
|
280 return &rv; |
|
281 } |
|
282 |
|
283 |
|
284 /**************************************************************************************** |
|
285 * |
|
286 * PUBLIC FUNCTION: killsession |
|
287 * |
|
288 ***************************************************************************************/ |
|
289 TResult *killsession_4( int *aArgs, CLIENT *aDutout ) |
|
290 { |
|
291 static TResult rv; |
|
292 int instance_key; |
|
293 CSPppcontroller *session; |
|
294 |
|
295 // check that the service is started |
|
296 if( iComponentManager == NULL ) { |
|
297 CSvcPppcontroller::SetError( KILLSESSION, (void*)&rv, ERR_SERVICE_NOT_RUNNING ); |
|
298 return &rv; |
|
299 } |
|
300 |
|
301 // set the return value to generic error |
|
302 CSvcPppcontroller::SetError( KILLSESSION, (void*)&rv, ERR_FAILED_TO_RETRIEVE_KEY ); |
|
303 |
|
304 // get the key for the instance from the args |
|
305 instance_key = CSvcPppcontroller::GetInstanceKeyFromArgs( KILLSESSION, (void*)aArgs ); |
|
306 if( instance_key < 0 ) { |
|
307 return &rv; |
|
308 } |
|
309 |
|
310 // make sure the key is valid |
|
311 if( iComponentManager->IsValidKey(instance_key) == 0 ) { |
|
312 CSvcPppcontroller::SetError( KILLSESSION, (void*)&rv, ERR_INSTANCE_DOES_NOT_EXIST ); |
|
313 return &rv; |
|
314 } |
|
315 |
|
316 // get the instance |
|
317 session = iComponentManager->GetInstance( instance_key ); |
|
318 assert( session != NULL ); |
|
319 |
|
320 // call the corresponding method on the instance |
|
321 rv = session->killsession( *aArgs ); |
|
322 return &rv; |
|
323 } |
|
324 |
|
325 |
|
326 /**************************************************************************************** |
|
327 * |
|
328 * PUBLIC FUNCTION: stopsession |
|
329 * |
|
330 ***************************************************************************************/ |
|
331 TResult *stopsession_4( int *aArgs, CLIENT *aDutout ) |
|
332 { |
|
333 static TResult rv; |
|
334 int instance_key; |
|
335 CSPppcontroller *session; |
|
336 |
|
337 // check that the service is started |
|
338 if( iComponentManager == NULL ) { |
|
339 CSvcPppcontroller::SetError( STOPSESSION, (void*)&rv, ERR_SERVICE_NOT_RUNNING ); |
|
340 return &rv; |
|
341 } |
|
342 |
|
343 // set the return value to generic error |
|
344 CSvcPppcontroller::SetError( STOPSESSION, (void*)&rv, ERR_FAILED_TO_RETRIEVE_KEY ); |
|
345 |
|
346 // get the key for the instance from the args |
|
347 instance_key = CSvcPppcontroller::GetInstanceKeyFromArgs( STOPSESSION, (void*)aArgs ); |
|
348 if( instance_key < 0 ) { |
|
349 return &rv; |
|
350 } |
|
351 |
|
352 // make sure the key is valid |
|
353 if( iComponentManager->IsValidKey(instance_key) == 0 ) { |
|
354 CSvcPppcontroller::SetError( STOPSESSION, (void*)&rv, ERR_INSTANCE_DOES_NOT_EXIST ); |
|
355 return &rv; |
|
356 } |
|
357 |
|
358 // get the instance |
|
359 session = iComponentManager->GetInstance( instance_key ); |
|
360 assert( session != NULL ); |
|
361 |
|
362 // call the corresponding method on the instance |
|
363 rv = session->stopsession( *aArgs ); |
|
364 return &rv; |
|
365 } |
|
366 |
|
367 |
|
368 /**************************************************************************************** |
|
369 * |
|
370 * PUBLIC FUNCTION: getsessioninfo |
|
371 * |
|
372 ***************************************************************************************/ |
|
373 TPppSessionDesc *getsessioninfo_4( int *aArgs, CLIENT *aDutout ) |
|
374 { |
|
375 static TPppSessionDesc rv; |
|
376 int instance_key; |
|
377 CSPppcontroller *session; |
|
378 |
|
379 // check that the service is started |
|
380 if( iComponentManager == NULL ) { |
|
381 CSvcPppcontroller::SetError( GETSESSIONINFO, (void*)&rv, ERR_SERVICE_NOT_RUNNING ); |
|
382 return &rv; |
|
383 } |
|
384 |
|
385 // set the return value to generic error |
|
386 CSvcPppcontroller::SetError( GETSESSIONINFO, (void*)&rv, ERR_FAILED_TO_RETRIEVE_KEY ); |
|
387 |
|
388 // get the key for the instance from the args |
|
389 instance_key = CSvcPppcontroller::GetInstanceKeyFromArgs( GETSESSIONINFO, (void*)aArgs ); |
|
390 if( instance_key < 0 ) { |
|
391 return &rv; |
|
392 } |
|
393 |
|
394 // make sure the key is valid |
|
395 if( iComponentManager->IsValidKey(instance_key) == 0 ) { |
|
396 CSvcPppcontroller::SetError( GETSESSIONINFO, (void*)&rv, ERR_INSTANCE_DOES_NOT_EXIST ); |
|
397 return &rv; |
|
398 } |
|
399 |
|
400 // get the instance |
|
401 session = iComponentManager->GetInstance( instance_key ); |
|
402 assert( session != NULL ); |
|
403 |
|
404 // call the corresponding method on the instance |
|
405 rv = session->getsessioninfo( *aArgs ); |
|
406 return &rv; |
|
407 } |
|
408 |
|
409 |
|
410 /**************************************************************************************** |
|
411 * |
|
412 * PUBLIC FUNCTION: getppplog |
|
413 * |
|
414 ***************************************************************************************/ |
|
415 TVarData *getppplog_4( int *aArgs, CLIENT *aDutout ) |
|
416 { |
|
417 static TVarData rv; |
|
418 int instance_key; |
|
419 CSPppcontroller *session; |
|
420 |
|
421 // check that the service is started |
|
422 if( iComponentManager == NULL ) { |
|
423 CSvcPppcontroller::SetError( GETPPPLOG, (void*)&rv, ERR_SERVICE_NOT_RUNNING ); |
|
424 return &rv; |
|
425 } |
|
426 |
|
427 // set the return value to generic error |
|
428 CSvcPppcontroller::SetError( GETPPPLOG, (void*)&rv, ERR_FAILED_TO_RETRIEVE_KEY ); |
|
429 |
|
430 // get the key for the instance from the args |
|
431 instance_key = CSvcPppcontroller::GetInstanceKeyFromArgs( GETPPPLOG, (void*)aArgs ); |
|
432 if( instance_key < 0 ) { |
|
433 return &rv; |
|
434 } |
|
435 |
|
436 // make sure the key is valid |
|
437 if( iComponentManager->IsValidKey(instance_key) == 0 ) { |
|
438 CSvcPppcontroller::SetError( GETPPPLOG, (void*)&rv, ERR_INSTANCE_DOES_NOT_EXIST ); |
|
439 return &rv; |
|
440 } |
|
441 |
|
442 // get the instance |
|
443 session = iComponentManager->GetInstance( instance_key ); |
|
444 assert( session != NULL ); |
|
445 |
|
446 // call the corresponding method on the instance |
|
447 rv = session->getppplog( *aArgs ); |
|
448 return &rv; |
|
449 } |