|
1 /* |
|
2 * Copyright (c) 2006-2007 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: RCCHClient implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cchclient.h" |
|
21 #include "cchlogger.h" |
|
22 #include "cchclientserver.h" |
|
23 #include "cchclientserverinternal.h" |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 // None |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 // None |
|
30 |
|
31 // CONSTANTS |
|
32 // None |
|
33 |
|
34 // MACROS |
|
35 // None |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 // None |
|
39 |
|
40 // MODULE DATA STRUCTURES |
|
41 // None |
|
42 |
|
43 // LOCAL FUNCTION PROTOTYPES |
|
44 // None |
|
45 |
|
46 // FORWARD DECLARATIONS |
|
47 // None |
|
48 |
|
49 // ============================= LOCAL FUNCTIONS ============================= |
|
50 |
|
51 // ============================ MEMBER FUNCTIONS ============================= |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // RCCHClient::RCCHClient |
|
55 // C++ default constructor can NOT contain any code, that might leave. |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C RCCHClient::RCCHClient() |
|
59 { |
|
60 // No implementation required |
|
61 iService = NULL; |
|
62 } |
|
63 |
|
64 EXPORT_C RCCHClient::~RCCHClient() |
|
65 { |
|
66 delete iService; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // RCCHClient::Open |
|
71 // Open subsession |
|
72 // (other items were commented in a header). |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C TInt RCCHClient::Open( const RCCHServer& aRCCHServer ) |
|
76 { |
|
77 CCHLOGSTRING( "RCCHClient::Open" ); |
|
78 return RSubSessionBase::CreateSubSession( |
|
79 aRCCHServer, ECCHOpenSubSession ); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // RCCHClient::Close |
|
84 // Close subsession |
|
85 // (other items were commented in a header). |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C void RCCHClient::Close() |
|
89 { |
|
90 CCHLOGSTRING( "RCCHClient::Close" ); |
|
91 RSubSessionBase::CloseSubSession( ECCHCloseSubSession ); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // RCCHClient::RegisterToServer |
|
96 // Send register message to server. |
|
97 // (other items were commented in a header). |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C void RCCHClient::RegisterToServer( TRequestStatus& aReqStatus ) const |
|
101 { |
|
102 const TIpcArgs args( TIpcArgs::ENothing ); |
|
103 SendReceive( ECCHServerRegister, args, aReqStatus ); |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // RCCHClient::RegisterToServerCancel |
|
108 // Cancel register server request |
|
109 // (other items were commented in a header). |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 EXPORT_C void RCCHClient::RegisterToServerCancel( ) const |
|
113 { |
|
114 const TIpcArgs args( TIpcArgs::ENothing ); |
|
115 SendReceive( ECCHServerRegisterCancel, args ); |
|
116 } |
|
117 |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // RCCHClient::SubscribeToEvents |
|
121 // Subscribe to specific service events. |
|
122 // (other items were commented in a header). |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 EXPORT_C void RCCHClient::SubscribeToEvents( |
|
126 const TServiceSelection& aServiceSelection, |
|
127 TPckgBuf<TServiceStatus>& aServiceStatus, |
|
128 TRequestStatus& aReqStatus ) const |
|
129 { |
|
130 const TIpcArgs args( |
|
131 aServiceSelection.iServiceId, aServiceSelection.iType, |
|
132 &aServiceStatus ); |
|
133 SendReceive( ECCHSubscribeToEvents, args, aReqStatus ); |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // RCCHClient::SubscribeToEvents |
|
138 // (other items were commented in a header). |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 EXPORT_C void RCCHClient::SubscribeToEventsCancel() const |
|
142 { |
|
143 const TIpcArgs args( TIpcArgs::ENothing ); |
|
144 SendReceive( ECCHSubscribeToEventsCancel, args ); |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // RCCHClient::GetServicesL |
|
149 // Client queries for all services and sub-services. |
|
150 // (other items were commented in a header). |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 EXPORT_C void RCCHClient::GetServicesL( |
|
154 CArrayFixFlat<TCCHService>& aServices, |
|
155 TRequestStatus& aReqStatus ) |
|
156 { |
|
157 TUint32 count( 0 ); |
|
158 TPckgBuf<TUint32> countPckg( count ); |
|
159 User::LeaveIfError( |
|
160 SendReceive( ECCHServiceCount, TIpcArgs( |
|
161 &countPckg, ECCHUnknown ) ) ); |
|
162 |
|
163 for ( TInt i( 0 ); i < countPckg(); i++ ) |
|
164 { |
|
165 TCCHService service; |
|
166 aServices.AppendL( service ); |
|
167 } |
|
168 |
|
169 if ( countPckg() ) |
|
170 { |
|
171 TUint32 length = countPckg() * sizeof( TCCHService ); |
|
172 |
|
173 if ( !iService ) |
|
174 { |
|
175 iService = new (ELeave) TPtr8( reinterpret_cast<TText8*>( |
|
176 &aServices[ 0 ] ), length, length ); |
|
177 } |
|
178 else |
|
179 { |
|
180 iService->Set( reinterpret_cast<TText8*>( |
|
181 &aServices[ 0 ] ), length, length ); |
|
182 } |
|
183 |
|
184 const TIpcArgs args( KErrNotFound, ECCHUnknown, iService ); |
|
185 SendReceive( ECCHGetServices, args, aReqStatus ); |
|
186 } |
|
187 else |
|
188 { |
|
189 const TIpcArgs args( TIpcArgs::ENothing ); |
|
190 SendReceive( ECCHGetServices, args, aReqStatus ); |
|
191 } |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // RCCHClient::GetServicesL |
|
196 // Get services which contains this type of sub-services |
|
197 // (other items were commented in a header). |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 EXPORT_C void RCCHClient::GetServicesL( |
|
201 const TServiceSelection& aServiceSelection, |
|
202 CArrayFixFlat<TCCHService>& aServices, |
|
203 TRequestStatus& aReqStatus ) |
|
204 { |
|
205 TUint32 count( 0 ); |
|
206 TPckgBuf<TUint32> countPckg( count ); |
|
207 |
|
208 // If some Service has selected Service count must be one, |
|
209 // otherwise we have to ask how many Services is enough |
|
210 if ( aServiceSelection.iServiceId != 0 ) |
|
211 { |
|
212 countPckg = 1; |
|
213 } |
|
214 else |
|
215 { |
|
216 User::LeaveIfError( |
|
217 SendReceive( ECCHServiceCount, TIpcArgs( &countPckg, |
|
218 aServiceSelection.iType ) ) ); |
|
219 } |
|
220 |
|
221 for ( TInt i( 0 ); i < countPckg(); i++ ) |
|
222 { |
|
223 TCCHService service; |
|
224 aServices.AppendL( service ); |
|
225 } |
|
226 |
|
227 if ( countPckg() ) |
|
228 { |
|
229 TUint32 length = countPckg() * sizeof( TCCHService ); |
|
230 |
|
231 if ( !iService ) |
|
232 { |
|
233 iService = new (ELeave) TPtr8( reinterpret_cast<TText8*>( |
|
234 &aServices[ 0 ] ), length, length ); |
|
235 } |
|
236 else |
|
237 { |
|
238 iService->Set( reinterpret_cast<TText8*>( |
|
239 &aServices[ 0 ] ), length, length ); |
|
240 } |
|
241 |
|
242 const TIpcArgs args( aServiceSelection.iServiceId, |
|
243 aServiceSelection.iType, |
|
244 iService ); |
|
245 SendReceive( ECCHGetServices, args, aReqStatus ); |
|
246 } |
|
247 else |
|
248 { |
|
249 const TIpcArgs args( TIpcArgs::ENothing ); |
|
250 SendReceive( ECCHGetServices, args, aReqStatus ); |
|
251 } |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // RCCHClient::GetServicesCancel |
|
256 // Cancel get services request |
|
257 // (other items were commented in a header). |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 EXPORT_C void RCCHClient::GetServicesCancel() const |
|
261 { |
|
262 const TIpcArgs args( TIpcArgs::ENothing ); |
|
263 SendReceive( ECCHGetServicesCancel, args ); |
|
264 } |
|
265 |
|
266 // --------------------------------------------------------------------------- |
|
267 // RCCHClient::GetServiceState |
|
268 // (other items were commented in a header). |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 EXPORT_C TInt RCCHClient::GetServiceState( |
|
272 const TServiceSelection& aServiceSelection, |
|
273 TCCHSubserviceState& aState ) const |
|
274 { |
|
275 TPckgBuf<TCCHSubserviceState> statePckg( aState ); |
|
276 const TIpcArgs args( |
|
277 aServiceSelection.iServiceId, aServiceSelection.iType, &statePckg ); |
|
278 TInt error = SendReceive( ECCHGetServiceState, args ); |
|
279 aState = statePckg(); |
|
280 return error; |
|
281 } |
|
282 |
|
283 // --------------------------------------------------------------------------- |
|
284 // RCCHClient::EnableService |
|
285 // Enable services. All sub-services under the service are enabled. |
|
286 // (other items were commented in a header). |
|
287 // --------------------------------------------------------------------------- |
|
288 // |
|
289 EXPORT_C void RCCHClient::EnableService( |
|
290 const TServiceSelection& aServiceSelection, |
|
291 TRequestStatus& aReqStatus, |
|
292 TBool aConnectivityCheck ) const |
|
293 { |
|
294 const TIpcArgs args( |
|
295 aServiceSelection.iServiceId, aServiceSelection.iType, |
|
296 aConnectivityCheck ); |
|
297 SendReceive( ECCHEnableService, args, aReqStatus ); |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------------------------- |
|
301 // RCCHClient::EnableServiceCancel |
|
302 // Cancels enable services request. |
|
303 // (other items were commented in a header). |
|
304 // --------------------------------------------------------------------------- |
|
305 // |
|
306 EXPORT_C void RCCHClient::EnableServiceCancel() const |
|
307 { |
|
308 const TIpcArgs args( TIpcArgs::ENothing ); |
|
309 SendReceive( ECCHEnableServiceCancel, args ); |
|
310 } |
|
311 |
|
312 // --------------------------------------------------------------------------- |
|
313 // RCCHClient::DisableService |
|
314 // (other items were commented in a header). |
|
315 // --------------------------------------------------------------------------- |
|
316 // |
|
317 EXPORT_C void RCCHClient::DisableService( |
|
318 const TServiceSelection& aServiceSelection, |
|
319 TRequestStatus& aReqStatus ) const |
|
320 { |
|
321 const TIpcArgs args( |
|
322 aServiceSelection.iServiceId, aServiceSelection.iType ); |
|
323 SendReceive( ECCHDisableService, args, aReqStatus ); |
|
324 } |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // RCCHClient::DisableServiceCancel |
|
328 // (other items were commented in a header). |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 EXPORT_C void RCCHClient::DisableServiceCancel() const |
|
332 { |
|
333 const TIpcArgs args( TIpcArgs::ENothing ); |
|
334 SendReceive( ECCHDisableServiceCancel, args ); |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // RCCHClient::GetServiceInfo |
|
339 // Get service specifics information about service and protocol |
|
340 // (other items were commented in a header). |
|
341 // --------------------------------------------------------------------------- |
|
342 // |
|
343 EXPORT_C TInt RCCHClient::GetServiceInfo( |
|
344 const TServiceSelection& aServiceSelection, |
|
345 TDes& aBuffer ) const |
|
346 { |
|
347 TPckgBuf<TServiceConnectionInfo> serviceConnInfoPckg; |
|
348 serviceConnInfoPckg().SetServiceId( aServiceSelection.iServiceId ); |
|
349 serviceConnInfoPckg().SetType( aServiceSelection.iType ); |
|
350 serviceConnInfoPckg().SetParameter( aServiceSelection.iParameter ); |
|
351 |
|
352 // only service id, type and parameter values are used from |
|
353 // TServiceConnectionInfo |
|
354 const TIpcArgs args( &serviceConnInfoPckg, &aBuffer ); |
|
355 return SendReceive( ECCHGetServiceInfo, args ); |
|
356 } |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // RCCHClient::SetConnectionInfo |
|
360 // (other items were commented in a header). |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 EXPORT_C void RCCHClient::SetConnectionInfo( |
|
364 const TPckgBuf<TServiceConnectionInfo>& aServiceConnInfo, |
|
365 TRequestStatus& aReqStatus ) |
|
366 { |
|
367 const TIpcArgs args( &aServiceConnInfo ); |
|
368 SendReceive( ECCHSetConnectionInfo, args, aReqStatus ); |
|
369 } |
|
370 |
|
371 // ----------------------------------------------------------------------------- |
|
372 // RCCHClient::SetConnectionInfoCancel |
|
373 // (other items were commented in a header). |
|
374 // ----------------------------------------------------------------------------- |
|
375 // |
|
376 EXPORT_C void RCCHClient::SetConnectionInfoCancel() const |
|
377 { |
|
378 const TIpcArgs args( TIpcArgs::ENothing ); |
|
379 SendReceive( ECCHSetConnectionInfoCancel, args ); |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // RCCHClient::GetConnectionInfo |
|
384 // (other items were commented in a header). |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 |
|
388 EXPORT_C void RCCHClient::GetConnectionInfo( |
|
389 const TServiceSelection& aServiceSelection, |
|
390 TPckgBuf<TServiceConnectionInfo>& aServiceConnInfo, |
|
391 TRequestStatus& aReqStatus ) const |
|
392 { |
|
393 aServiceConnInfo().SetServiceId( aServiceSelection.iServiceId ); |
|
394 aServiceConnInfo().SetType( aServiceSelection.iType ); |
|
395 aServiceConnInfo().SetParameter( aServiceSelection.iParameter ); |
|
396 // only service id, type and parameter values are used from |
|
397 // TServiceConnectionInfo |
|
398 const TIpcArgs args( &aServiceConnInfo ); |
|
399 SendReceive( ECCHGetConnectionInfo, args, aReqStatus ); |
|
400 } |
|
401 |
|
402 // ----------------------------------------------------------------------------- |
|
403 // RCCHClient::GetConnectionInfoCancel |
|
404 // (other items were commented in a header). |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 |
|
408 EXPORT_C void RCCHClient::GetConnectionInfoCancel() const |
|
409 { |
|
410 const TIpcArgs args( TIpcArgs::ENothing ); |
|
411 SendReceive( ECCHGetConnectionInfoCancel, args ); |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------------------------- |
|
415 // RCCHClient::ReserveService |
|
416 // Reserves the service for exclusive use |
|
417 // (other items were commented in a header). |
|
418 // --------------------------------------------------------------------------- |
|
419 // |
|
420 EXPORT_C TInt RCCHClient::ReserveService( |
|
421 const TServiceSelection& aServiceSelection ) |
|
422 { |
|
423 const TIpcArgs args( |
|
424 aServiceSelection.iServiceId, aServiceSelection.iType ); |
|
425 return SendReceive( ECCHReserveService, args ); |
|
426 } |
|
427 |
|
428 // --------------------------------------------------------------------------- |
|
429 // RCCHClient::FreeService |
|
430 // Frees the exclusive service reservation |
|
431 // (other items were commented in a header). |
|
432 // --------------------------------------------------------------------------- |
|
433 // |
|
434 EXPORT_C TInt RCCHClient::FreeService( |
|
435 const TServiceSelection& aServiceSelection ) |
|
436 { |
|
437 const TIpcArgs args( |
|
438 aServiceSelection.iServiceId, aServiceSelection.iType ); |
|
439 return SendReceive( ECCHFreeService, args ); |
|
440 } |
|
441 |
|
442 // --------------------------------------------------------------------------- |
|
443 // RCCHClient::IsReserved |
|
444 // Returns true if the service is reserved for exclusive use |
|
445 // (other items were commented in a header). |
|
446 // --------------------------------------------------------------------------- |
|
447 // |
|
448 EXPORT_C TBool RCCHClient::IsReserved( |
|
449 const TServiceSelection& aServiceSelection ) const |
|
450 { |
|
451 TPckgBuf<TBool> reserved; |
|
452 const TIpcArgs args( |
|
453 aServiceSelection.iServiceId, aServiceSelection.iType,&reserved ); |
|
454 SendReceive( ECCHIsReserved, args ); |
|
455 return reserved(); |
|
456 } |
|
457 |
|
458 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
459 |
|
460 // End of File |