|
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 "../../Core/UCCS_ServiceValues.h" |
|
30 #include "../../Core/UCCS_ErrorCodes.h" |
|
31 #include "CTestServiceStub.h" |
|
32 #include "CCTestservice.h" |
|
33 |
|
34 |
|
35 /******************************************************************************* |
|
36 * |
|
37 * Definitions |
|
38 * |
|
39 ******************************************************************************/ |
|
40 |
|
41 /******************************************************************************* |
|
42 * |
|
43 * Macro Functions |
|
44 * |
|
45 ******************************************************************************/ |
|
46 |
|
47 /******************************************************************************* |
|
48 * |
|
49 * Constructor / Destructor |
|
50 * |
|
51 ******************************************************************************/ |
|
52 CTestServiceStub::CTestServiceStub() |
|
53 { |
|
54 iClientTest = new CCTestservice(); |
|
55 assert( iClientTest != NULL ); |
|
56 } |
|
57 |
|
58 |
|
59 CTestServiceStub::~CTestServiceStub() |
|
60 { |
|
61 delete iClientTest; |
|
62 } |
|
63 |
|
64 |
|
65 /******************************************************************************* |
|
66 * |
|
67 * Startup / Shutdown |
|
68 * |
|
69 ******************************************************************************/ |
|
70 int CTestServiceStub::StartUccsService( char *aHostName, int *aErrorInfo, int *aUnused ) |
|
71 { |
|
72 int client_stub_error; |
|
73 *aErrorInfo = *aUnused = 0; |
|
74 |
|
75 // connect the stub to the remote service |
|
76 client_stub_error = iClientTest->Connect( aHostName ); |
|
77 |
|
78 // return the result |
|
79 return client_stub_error; |
|
80 } |
|
81 |
|
82 |
|
83 int CTestServiceStub::StopUccsService( int *aErrorInfo, int *aUnused ) |
|
84 { |
|
85 int client_stub_error; |
|
86 *aErrorInfo = *aUnused = 0; |
|
87 |
|
88 // disconnect the stub from the remote service |
|
89 client_stub_error = iClientTest->Disconnect(); |
|
90 |
|
91 // return the result |
|
92 return client_stub_error; |
|
93 } |
|
94 |
|
95 |
|
96 /******************************************************************************* |
|
97 * |
|
98 * IssueCommand |
|
99 * |
|
100 ******************************************************************************/ |
|
101 CDataRecord* CTestServiceStub::IssueCommand( CDataRecord* aRequest ) |
|
102 { |
|
103 int i, client_result, method_id = -1; |
|
104 CDataRecord *request_reply; |
|
105 |
|
106 TStartupInfo sarg_startupinfo; |
|
107 int sarg_integer, rv_integer; |
|
108 TResult rv_result; |
|
109 TComponentList rv_component_list; |
|
110 |
|
111 // check params |
|
112 assert( aRequest != NULL ); |
|
113 |
|
114 // create a standard reply |
|
115 request_reply = CreateBaseReply( aRequest ); |
|
116 assert( request_reply != NULL ); |
|
117 |
|
118 // get and check the method_id |
|
119 request_reply->GetFieldAsInt( "METHODID", &method_id ); |
|
120 if( method_id == -1 ) { |
|
121 UpdateCompletionCode( request_reply, ERR_INVALID_METHOD ); |
|
122 return request_reply; |
|
123 } |
|
124 |
|
125 // now dispatch and call the appropriate method |
|
126 switch( method_id ) { |
|
127 |
|
128 // ss_startuprpcservice |
|
129 case 1: |
|
130 |
|
131 // extract the parameters |
|
132 sarg_startupinfo.iEmpty = 0; |
|
133 |
|
134 // make the call and update the return value |
|
135 client_result = iClientTest->ss_startuprpcservice( sarg_startupinfo, &rv_integer ); |
|
136 UpdateCompletionCode( request_reply, client_result ); |
|
137 if( client_result != ERR_NONE ) { |
|
138 break; |
|
139 } |
|
140 |
|
141 // set the return values |
|
142 request_reply->NewField( "RESULT", rv_integer ); |
|
143 break; |
|
144 |
|
145 // sc_shutdownrpcservice |
|
146 case 2: |
|
147 |
|
148 // extract the parameters |
|
149 GETINTEGERARGUMENT( "FORCE", &sarg_integer, 1, 1, aRequest, request_reply ); |
|
150 |
|
151 // make the call and update the return value |
|
152 client_result = iClientTest->sc_shutdownrpcservice( sarg_integer, &rv_integer ); |
|
153 UpdateCompletionCode( request_reply, client_result ); |
|
154 if( client_result != ERR_NONE ) { |
|
155 break; |
|
156 } |
|
157 |
|
158 // set the return values |
|
159 request_reply->NewField( "RESULT", rv_integer ); |
|
160 break; |
|
161 |
|
162 // list_devices |
|
163 case 3: |
|
164 |
|
165 // make the call and update the return value |
|
166 client_result = iClientTest->list_devices( &rv_component_list ); |
|
167 UpdateCompletionCode( request_reply, client_result ); |
|
168 if( client_result != ERR_NONE ) { |
|
169 break; |
|
170 } |
|
171 |
|
172 // set the return values |
|
173 request_reply->NewField( "DEVICECOUNT", rv_component_list.TComponentList_len ); |
|
174 for( i = 0; i < rv_component_list.TComponentList_len; i++ ) { |
|
175 AddIteratedIntegerFieldName( "DEVICEID", i, (rv_component_list.TComponentList_val)[i], request_reply ); |
|
176 } |
|
177 break; |
|
178 |
|
179 |
|
180 // st_discard |
|
181 case 10: |
|
182 |
|
183 // extract the parameters |
|
184 sarg_integer = 10; |
|
185 |
|
186 // make the call and update the return value |
|
187 client_result = iClientTest->st_discard( sarg_integer, &rv_result ); |
|
188 UpdateCompletionCode( request_reply, client_result ); |
|
189 if( client_result != ERR_NONE ) { |
|
190 break; |
|
191 } |
|
192 |
|
193 // set the return values |
|
194 request_reply->NewField( "RESULT", rv_result.iStandardResult ); |
|
195 request_reply->NewField( "RESULT_EXTENDED_CODE", rv_result.iExtendedCode ); |
|
196 request_reply->NewField( "RESULT_SYSTEM_ERROR", rv_result.iSystemError ); |
|
197 break; |
|
198 |
|
199 |
|
200 // st_block |
|
201 case 11: |
|
202 |
|
203 // extract the parameters |
|
204 sarg_integer = 11; |
|
205 |
|
206 // make the call and update the return value |
|
207 client_result = iClientTest->st_block( sarg_integer, &rv_result ); |
|
208 UpdateCompletionCode( request_reply, client_result ); |
|
209 if( client_result != ERR_NONE ) { |
|
210 break; |
|
211 } |
|
212 |
|
213 // set the return values |
|
214 request_reply->NewField( "RESULT", rv_result.iStandardResult ); |
|
215 request_reply->NewField( "RESULT_EXTENDED_CODE", rv_result.iExtendedCode ); |
|
216 request_reply->NewField( "RESULT_SYSTEM_ERROR", rv_result.iSystemError ); |
|
217 break; |
|
218 |
|
219 |
|
220 // st_wait |
|
221 case 12: |
|
222 |
|
223 // extract the parameters |
|
224 sarg_integer = 12; |
|
225 |
|
226 // make the call and update the return value |
|
227 client_result = iClientTest->st_wait( sarg_integer, &rv_result ); |
|
228 UpdateCompletionCode( request_reply, client_result ); |
|
229 if( client_result != ERR_NONE ) { |
|
230 break; |
|
231 } |
|
232 |
|
233 // set the return values |
|
234 request_reply->NewField( "RESULT", rv_result.iStandardResult ); |
|
235 request_reply->NewField( "RESULT_EXTENDED_CODE", rv_result.iExtendedCode ); |
|
236 request_reply->NewField( "RESULT_SYSTEM_ERROR", rv_result.iSystemError ); |
|
237 break; |
|
238 |
|
239 |
|
240 // Any other method id results in an invalid method id result |
|
241 default: |
|
242 UpdateCompletionCode( request_reply, ERR_INVALID_METHOD ); |
|
243 break; |
|
244 } |
|
245 |
|
246 // everything should be handled above |
|
247 return request_reply; |
|
248 } |
|
249 |
|
250 |
|
251 /******************************************************************************* |
|
252 * |
|
253 * GetStatus() |
|
254 * |
|
255 ******************************************************************************/ |
|
256 int CTestServiceStub::GetStatus() |
|
257 { |
|
258 assert( !"GetStatus() - is not implemented" ); |
|
259 return -1; |
|
260 } |
|
261 |
|
262 |
|
263 /******************************************************************************* |
|
264 * |
|
265 * GetLastRPCError() |
|
266 * |
|
267 ******************************************************************************/ |
|
268 char *CTestServiceStub::GetLastRPCError( int *aIntError ) |
|
269 { |
|
270 return iClientTest->GetLastRPCError( aIntError ); |
|
271 } |