|
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 * System Includes |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include <assert.h> |
|
23 |
|
24 /******************************************************************************* |
|
25 * |
|
26 * Local Includes |
|
27 * |
|
28 ******************************************************************************/ |
|
29 #include "strncpynt.h" |
|
30 #include "../../Core/UCCS_ServiceValues.h" |
|
31 #include "../../Core/UCCS_ErrorCodes.h" |
|
32 #include "CPppControllerStub.h" |
|
33 #include "CCPppcontroller.h" |
|
34 |
|
35 |
|
36 /******************************************************************************* |
|
37 * |
|
38 * Definitions |
|
39 * |
|
40 ******************************************************************************/ |
|
41 |
|
42 /******************************************************************************* |
|
43 * |
|
44 * Macro Functions |
|
45 * |
|
46 ******************************************************************************/ |
|
47 |
|
48 /******************************************************************************* |
|
49 * |
|
50 * Constructor / Destructor |
|
51 * |
|
52 ******************************************************************************/ |
|
53 CPppControllerServiceStub::CPppControllerServiceStub() |
|
54 { |
|
55 iClientPppController = new CCPppcontroller(); |
|
56 assert( iClientPppController != NULL ); |
|
57 } |
|
58 |
|
59 |
|
60 CPppControllerServiceStub::~CPppControllerServiceStub() |
|
61 { |
|
62 delete iClientPppController; |
|
63 } |
|
64 |
|
65 |
|
66 /******************************************************************************* |
|
67 * |
|
68 * Startup / Shutdown |
|
69 * |
|
70 ******************************************************************************/ |
|
71 int CPppControllerServiceStub::StartUccsService( char *aHostName, int *aErrorCode, int *aUnused ) |
|
72 { |
|
73 int client_stub_error; |
|
74 |
|
75 // check params |
|
76 assert( aHostName != NULL ); |
|
77 assert( aErrorCode != NULL ); |
|
78 *aErrorCode = 0; |
|
79 |
|
80 // connect to the remote service |
|
81 client_stub_error = iClientPppController->Connect( aHostName ); |
|
82 |
|
83 // return the result |
|
84 return client_stub_error; |
|
85 |
|
86 } |
|
87 |
|
88 |
|
89 int CPppControllerServiceStub::StopUccsService( int *aErrorCode, int *aUnused ) |
|
90 { |
|
91 int client_stub_error; |
|
92 |
|
93 // check params |
|
94 assert( aErrorCode != NULL ); |
|
95 *aErrorCode = 0; |
|
96 |
|
97 // shutdown the stub -- force it to close |
|
98 client_stub_error = iClientPppController->Disconnect(); |
|
99 |
|
100 // done |
|
101 return client_stub_error; |
|
102 } |
|
103 |
|
104 |
|
105 /******************************************************************************* |
|
106 * |
|
107 * IssueCommand |
|
108 * |
|
109 ******************************************************************************/ |
|
110 CDataRecord* CPppControllerServiceStub::IssueCommand( CDataRecord* aRequest ) |
|
111 { |
|
112 int i, err, client_stub_error, method_id = -1; |
|
113 char *tmp_string; |
|
114 CDataRecord *request_reply; |
|
115 |
|
116 int rv_integer, sarg_integer; |
|
117 TComponentList rv_component_list; |
|
118 TResult rv_result; |
|
119 TVarData rv_var_data; |
|
120 TPppSessionDesc rv_session_desc; |
|
121 TPppSessionConfig sarg_session_config; |
|
122 TStartupInfo sarg_startup_info; |
|
123 |
|
124 // check params |
|
125 assert( aRequest != NULL ); |
|
126 |
|
127 // create a standard reply |
|
128 request_reply = CreateBaseReply( aRequest ); |
|
129 assert( request_reply != NULL ); |
|
130 |
|
131 // get and check the method_id |
|
132 err = request_reply->GetFieldAsInt( "METHODID", &method_id ); |
|
133 if( method_id == -1 ) { |
|
134 UpdateCompletionCode( request_reply, ERR_INVALID_METHOD ); |
|
135 return request_reply; |
|
136 } |
|
137 |
|
138 // now dispatch and call the appropriate method |
|
139 switch( method_id ) { |
|
140 |
|
141 // ss_startuprpcservice |
|
142 case 1: |
|
143 |
|
144 // setup the args |
|
145 sarg_startup_info.iEmpty = 0; |
|
146 |
|
147 // make the call and update the return value |
|
148 client_stub_error = iClientPppController->ss_startuprpcservice( sarg_startup_info, &rv_integer ); |
|
149 UpdateCompletionCode( request_reply, client_stub_error ); |
|
150 if( client_stub_error != ERR_NONE ) { |
|
151 break; |
|
152 } |
|
153 |
|
154 // set any return information |
|
155 request_reply->NewField( "RESULT", rv_integer ); |
|
156 break; |
|
157 |
|
158 // sc_shutdownrpcservice |
|
159 case 2: |
|
160 |
|
161 // extract the parameters |
|
162 GETINTEGERARGUMENT( "FORCE", &sarg_integer, 1, 1, aRequest, request_reply ); |
|
163 |
|
164 // make the call and update the return value |
|
165 client_stub_error = iClientPppController->sc_shutdownrpcservice( sarg_integer, &rv_integer ); |
|
166 UpdateCompletionCode( request_reply, client_stub_error ); |
|
167 if( client_stub_error != ERR_NONE ) { |
|
168 break; |
|
169 } |
|
170 |
|
171 // set the return values |
|
172 request_reply->NewField( "RESULT", rv_integer ); |
|
173 break; |
|
174 |
|
175 // list_devices |
|
176 case 30: |
|
177 |
|
178 // make the call and update the return value |
|
179 client_stub_error = iClientPppController->list_devices( &rv_component_list ); |
|
180 UpdateCompletionCode( request_reply, client_stub_error ); |
|
181 if( client_stub_error != ERR_NONE ) { |
|
182 break; |
|
183 } |
|
184 |
|
185 // set the return values |
|
186 request_reply->NewField( "DEVICECOUNT", rv_component_list.TComponentList_len ); |
|
187 for( i = 0; i < rv_component_list.TComponentList_len; i++ ) { |
|
188 AddIteratedIntegerFieldName( "DEVICEID", i, (rv_component_list.TComponentList_val)[i], request_reply ); |
|
189 } |
|
190 break; |
|
191 |
|
192 // cstr_startpppsession |
|
193 case 31: |
|
194 |
|
195 // extract the parameters |
|
196 GETSTRINGARGUMENT( "MADDR", &tmp_string, 1, 0, aRequest, request_reply ); |
|
197 STRNCPY_NULL_TERMINATE( sarg_session_config.iMobsterAddress, tmp_string, MAXADDRLEN ); |
|
198 GETSTRINGARGUMENT( "MPORT", &tmp_string, 2, 0, aRequest, request_reply ); |
|
199 STRNCPY_NULL_TERMINATE( sarg_session_config.iMobsterPort, tmp_string, MAXPORTLEN ); |
|
200 GETINTEGERARGUMENT( "MTID", &(sarg_session_config.iMTID), 3, 0, aRequest, request_reply ); |
|
201 GETSTRINGARGUMENT( "CONFIG", &tmp_string, 4, 0, aRequest, request_reply ); |
|
202 STRNCPY_NULL_TERMINATE( sarg_session_config.iSessionConfiguration, tmp_string, MAXCONFIGURATIONLENGTH ); |
|
203 |
|
204 // make the call and update the return value |
|
205 client_stub_error = iClientPppController->cstr_startpppsession( sarg_session_config, &rv_result ); |
|
206 UpdateCompletionCode( request_reply, client_stub_error ); |
|
207 if( client_stub_error != ERR_NONE ) { |
|
208 break; |
|
209 } |
|
210 |
|
211 // set the result values |
|
212 request_reply->NewField( "RESULT", rv_result.iStandardResult ); |
|
213 request_reply->NewField( "RESULT_DETAIL", rv_result.iExtendedCode ); |
|
214 request_reply->NewField( "RESULT_SYSTEM_ERROR", rv_result.iSystemError ); |
|
215 break; |
|
216 |
|
217 |
|
218 // dstr_removepppsession |
|
219 case 32: |
|
220 |
|
221 // extract the parameters |
|
222 GETINTEGERARGUMENT( "SID", &sarg_integer, 1, 0, aRequest, request_reply ); |
|
223 |
|
224 // make the call and update the return value |
|
225 client_stub_error = iClientPppController->dstr_removepppsession( sarg_integer, &rv_result ); |
|
226 UpdateCompletionCode( request_reply, client_stub_error ); |
|
227 if( client_stub_error != ERR_NONE ) { |
|
228 break; |
|
229 } |
|
230 |
|
231 // set the result values |
|
232 request_reply->NewField( "RESULT", rv_result.iStandardResult ); |
|
233 request_reply->NewField( "RESULT_DETAIL", rv_result.iExtendedCode ); |
|
234 request_reply->NewField( "RESULT_SYSTEM_ERROR", rv_result.iSystemError ); |
|
235 break; |
|
236 |
|
237 |
|
238 // killsession |
|
239 case 5: |
|
240 |
|
241 // extract the parameters |
|
242 GETINTEGERARGUMENT( "SID", &sarg_integer, 1, 0, aRequest, request_reply ); |
|
243 |
|
244 // make the call and update the return value |
|
245 client_stub_error = iClientPppController->killsession( sarg_integer, &rv_result ); |
|
246 UpdateCompletionCode( request_reply, client_stub_error ); |
|
247 if( client_stub_error != ERR_NONE ) { |
|
248 break; |
|
249 } |
|
250 |
|
251 // set the result values |
|
252 request_reply->NewField( "RESULT", rv_result.iStandardResult ); |
|
253 request_reply->NewField( "RESULT_DETAIL", rv_result.iExtendedCode ); |
|
254 request_reply->NewField( "RESULT_SYSTEM_ERROR", rv_result.iSystemError ); |
|
255 break; |
|
256 |
|
257 |
|
258 // stopsession |
|
259 case 6: |
|
260 |
|
261 // extract the parameters |
|
262 GETINTEGERARGUMENT( "SID", &sarg_integer, 1, 0, aRequest, request_reply ); |
|
263 |
|
264 // make the call and update the return value |
|
265 client_stub_error = iClientPppController->stopsession( sarg_integer, &rv_result ); |
|
266 UpdateCompletionCode( request_reply, client_stub_error ); |
|
267 if( client_stub_error != ERR_NONE ) { |
|
268 break; |
|
269 } |
|
270 |
|
271 // set the result values |
|
272 request_reply->NewField( "RESULT", rv_result.iStandardResult ); |
|
273 request_reply->NewField( "RESULT_DETAIL", rv_result.iExtendedCode ); |
|
274 request_reply->NewField( "RESULT_SYSTEM_ERROR", rv_result.iSystemError ); |
|
275 break; |
|
276 |
|
277 |
|
278 // getsessioninfo |
|
279 case 7: |
|
280 |
|
281 // extract the parameters |
|
282 GETINTEGERARGUMENT( "SID", &sarg_integer, 1, 0, aRequest, request_reply ); |
|
283 |
|
284 // make the call and update the return value |
|
285 client_stub_error = iClientPppController->getsessioninfo( sarg_integer, &rv_session_desc ); |
|
286 UpdateCompletionCode( request_reply, client_stub_error ); |
|
287 if( client_stub_error != ERR_NONE ) { |
|
288 break; |
|
289 } |
|
290 |
|
291 // set the result values |
|
292 request_reply->NewField( "RESULT", rv_session_desc.iErrorCode ); |
|
293 request_reply->NewField( "RESULT_DETAIL", rv_session_desc.iErrorDetail ); |
|
294 request_reply->NewField( "SESSION_MADDR", rv_session_desc.iConfig.iMobsterAddress ); |
|
295 request_reply->NewField( "SESSION_MPORT", rv_session_desc.iConfig.iMobsterPort ); |
|
296 request_reply->NewField( "SESSION_MTID", rv_session_desc.iConfig.iMTID ); |
|
297 request_reply->NewField( "SESSION_CONFIG", rv_session_desc.iConfig.iSessionConfiguration ); |
|
298 request_reply->NewField( "SESSION_STATUS", rv_session_desc.iSessionStatus ); |
|
299 request_reply->NewField( "SESSION_INTERFACE_NAME", rv_session_desc.iInterfaceName ); |
|
300 request_reply->NewField( "SESSION_LOCAL_IP_ADDRESS", IntToAddress(rv_session_desc.iLocalIPAddress) ); |
|
301 request_reply->NewField( "SESSION_REMOTE_IP_ADDRESS", IntToAddress(rv_session_desc.iRemoteIPAddress) ); |
|
302 request_reply->NewField( "SESSION_PROCESS_STATUS", rv_session_desc.iProcessStatus ); |
|
303 request_reply->NewField( "SESSION_PROCESS_EXIT_REASON", rv_session_desc.iProcessExitReason ); |
|
304 request_reply->NewField( "SESSION_PROCESS_EXIT_CODE", rv_session_desc.iProcessExitCode ); |
|
305 break; |
|
306 |
|
307 |
|
308 // getppplog |
|
309 case 8: |
|
310 |
|
311 // extract the parameters |
|
312 GETINTEGERARGUMENT( "SID", &sarg_integer, 1, 0, aRequest, request_reply ); |
|
313 |
|
314 // make the call and update the return value |
|
315 client_stub_error = iClientPppController->getppplog( sarg_integer, &rv_var_data ); |
|
316 UpdateCompletionCode( request_reply, client_stub_error ); |
|
317 if( client_stub_error != ERR_NONE ) { |
|
318 break; |
|
319 } |
|
320 |
|
321 // set the result values |
|
322 request_reply->NewField( "LOG", rv_var_data.TVarData_val ); |
|
323 request_reply->NewField( "LOG_LENGTH", (rv_var_data.TVarData_len - 1)); |
|
324 |
|
325 // free the memory (if any was allocated) |
|
326 if( rv_var_data.TVarData_len > 0 ) { |
|
327 XdrFree( &(rv_var_data.TVarData_val), (int*)&(rv_var_data.TVarData_len) ); |
|
328 } |
|
329 break; |
|
330 |
|
331 |
|
332 // Any other method id results in an invalid method id result |
|
333 default: |
|
334 UpdateCompletionCode( request_reply, ERR_INVALID_METHOD ); |
|
335 break; |
|
336 } |
|
337 |
|
338 // everything should be handled above |
|
339 return request_reply; |
|
340 } |
|
341 |
|
342 |
|
343 /******************************************************************************* |
|
344 * |
|
345 * GetLastRPCError() |
|
346 * |
|
347 ******************************************************************************/ |
|
348 char *CPppControllerServiceStub::GetLastRPCError( int *aIntError ) |
|
349 { |
|
350 return iClientPppController->GetLastRPCError( aIntError ); |
|
351 } |
|
352 |
|
353 |
|
354 /******************************************************************************* |
|
355 * |
|
356 * GetStatus() |
|
357 * |
|
358 ******************************************************************************/ |
|
359 int CPppControllerServiceStub::GetStatus() |
|
360 { |
|
361 assert( !"GetStatus() - is not implemented" ); |
|
362 return -1; |
|
363 } |
|
364 |