|
1 /* |
|
2 * Copyright (c) 2002-2008 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: Server-side sub-session of Accessory Connection Base |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "AccSrvSubConnectionBase.h" |
|
22 #include "AccPolGenericIDAccessor.h" |
|
23 #include "acc_debug.h" |
|
24 #include "AccSrvASYProxyHandler.h" |
|
25 #include "AccPolAccessoryPolicy.h" |
|
26 #include <s32mem.h> |
|
27 #include <accpolobjectcon.h> |
|
28 |
|
29 // EXTERNAL DATA STRUCTURES |
|
30 |
|
31 // EXTERNAL FUNCTION PROTOTYPES |
|
32 |
|
33 // CONSTANTS |
|
34 |
|
35 // MACROS |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 |
|
39 // MODULE DATA STRUCTURES |
|
40 |
|
41 // LOCAL FUNCTION PROTOTYPES |
|
42 |
|
43 // FORWARD DECLARATIONS |
|
44 |
|
45 // ============================= LOCAL FUNCTIONS =============================== |
|
46 |
|
47 // ============================ MEMBER FUNCTIONS =============================== |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CAccSrvSubConnectionBase::CAccSrvSubConnectionBase |
|
51 // C++ default constructor can NOT contain any code, that |
|
52 // might leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CAccSrvSubConnectionBase::CAccSrvSubConnectionBase( |
|
56 CASYProxyAPI* aProxy, |
|
57 CAccSrvConnectionController* aConnectionController, |
|
58 CAccSrvServerModel* aServerModel ) |
|
59 : CAccSrvSubBase( aProxy, aConnectionController, aServerModel ) |
|
60 { |
|
61 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::CAccSrvSubConnectionBase()" ); |
|
62 |
|
63 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::CAccSrvSubConnectionBase - return void" ); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CAccSrvSubConnectionBase::ConstructL |
|
68 // Symbian 2nd phase constructor can leave. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CAccSrvSubConnectionBase::ConstructL() |
|
72 { |
|
73 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::ConstructL" ); |
|
74 |
|
75 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::ConstructL - return void" ); |
|
76 } |
|
77 |
|
78 // Destructor |
|
79 CAccSrvSubConnectionBase::~CAccSrvSubConnectionBase() |
|
80 { |
|
81 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::~CAccSrvSubConnectionBase()" ); |
|
82 |
|
83 // Complete possible outstanding request |
|
84 if ( !iMessage.IsNull() ) |
|
85 { |
|
86 iMessage.Complete( KErrCancel ); |
|
87 } |
|
88 |
|
89 if( iDataBuf ) |
|
90 { |
|
91 delete iDataBuf; |
|
92 iDataBuf = NULL; |
|
93 } |
|
94 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::~CAccSrvSubConnectionBase - return void" ); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CAccSrvSubConnectionBase::GetSubblockNameArrayL |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CAccSrvSubConnectionBase::GetSubblockNameArrayL( const RMessage2& aMessage ) |
|
102 { |
|
103 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetSubblockNameArrayL()" ); |
|
104 |
|
105 TInt err( KErrNone ); |
|
106 TAccPolGenericID genericID; |
|
107 TAccSrvGenericIDPckg genericIDPckg( genericID ); |
|
108 RBufWriteStream wStrm; |
|
109 TInt bufSize( aMessage.Int1() ); |
|
110 CBufFlat* buf = CBufFlat::NewL( bufSize ); |
|
111 CleanupStack::PushL( buf ); |
|
112 |
|
113 //Read client parameters |
|
114 aMessage.ReadL( KAccServParamPosFirst, genericIDPckg ); |
|
115 |
|
116 // Externalize |
|
117 (void) wStrm.Open(*buf); |
|
118 CleanupClosePushL( wStrm ); |
|
119 iServerModel->CapabilityStorage().ExternalizeCapabilityNameListL( genericID, wStrm); |
|
120 wStrm.CommitL(); |
|
121 |
|
122 if ( buf->Size() > bufSize ) |
|
123 { |
|
124 wStrm.Truncate( *buf ); |
|
125 //A new attempt is made from client side with a bigger buffer. |
|
126 //Write only a new buffer size to client for new memory allocation |
|
127 COM_TRACE_2( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetSubblockNameArrayL - size=%d reserved size=%d", buf->Size(), bufSize ); |
|
128 TInt newBufSize( buf->Size() ); |
|
129 buf->Reset(); |
|
130 buf->ResizeL( bufSize ); |
|
131 wStrm.WriteInt32L( newBufSize ); |
|
132 wStrm.CommitL(); |
|
133 err = KErrEof; |
|
134 } |
|
135 |
|
136 TPtr8 ptr( buf->Ptr( 0 ) ); |
|
137 aMessage.Write( KAccServParamPosThird, ptr ); |
|
138 |
|
139 CleanupStack::PopAndDestroy( &wStrm ); |
|
140 CleanupStack::PopAndDestroy( buf ); |
|
141 |
|
142 User::LeaveIfError( err ); |
|
143 |
|
144 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetSubblockNameArrayL - return void" ); |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CAccSrvSubConnectionBase::GetValueTBoolL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 void CAccSrvSubConnectionBase::GetValueTBoolL( const RMessage2& aMessage ) |
|
152 { |
|
153 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetValueTBoolL()" ); |
|
154 |
|
155 TAccPolGenericID genericID; |
|
156 TAccSrvGenericIDPckg genericIDPckg( genericID ); |
|
157 TAccPolNameRecord nameRecord; |
|
158 TAccSrvNameRecordPckg nameRecordPckg( nameRecord ); |
|
159 TAccValueTypeTBool getValue; |
|
160 TAccSrvValueTypeTBoolPckg getValuePckg( getValue ); |
|
161 TASYCommandParamRecord asyCommandParamRecord; |
|
162 TInt32 value( 0 ); |
|
163 TAccValueTypeTBool boolValue = { EFalse }; |
|
164 |
|
165 //Read client parameters |
|
166 aMessage.ReadL( KAccServParamPosFirst, genericIDPckg ); |
|
167 aMessage.ReadL( KAccServParamPosSecond, nameRecordPckg ); |
|
168 aMessage.ReadL( KAccServParamPosThird, getValuePckg ); |
|
169 |
|
170 //Precondition |
|
171 iServerModel->IsConnectedOrDetectedL( genericID );//Leaves with KErrArgument if the accessory is not connected or detected |
|
172 |
|
173 //Copy client parameters to format in which they are sent to ASY |
|
174 asyCommandParamRecord.iNameRecord = nameRecordPckg(); |
|
175 asyCommandParamRecord.iCmdValue = getValue.iValue; |
|
176 asyCommandParamRecord.iGenericID = genericID; |
|
177 |
|
178 //get capability |
|
179 TUint32 name; |
|
180 asyCommandParamRecord.iNameRecord.GetName( name ); |
|
181 |
|
182 CCapValue * capValue = iServerModel->CapabilityStorage().GetCapability( genericID, name ); |
|
183 |
|
184 if ( !capValue ) |
|
185 { |
|
186 User::Leave( KErrArgument ); |
|
187 } |
|
188 |
|
189 User::LeaveIfError( capValue->ValueInt( value ) ); |
|
190 |
|
191 switch ( capValue->Location() ) |
|
192 { |
|
193 case EAPVPolicy: |
|
194 { |
|
195 iMessage = aMessage;//copy message for later completion |
|
196 |
|
197 if ( KErrUnknown == value ) |
|
198 { |
|
199 //Value initialization is needed, forward Get-request to ASY |
|
200 iConnectionController->ASYProxyHandler().HandleASYCommsL( |
|
201 ECmdGetValueBool, |
|
202 asyCommandParamRecord ); |
|
203 //Store this sub-session to queue so that it will be informed when ASY has served request |
|
204 iConnectionController->NotificationQueue().RegisterControlMessage( |
|
205 EGetValue, |
|
206 this ); |
|
207 } |
|
208 else |
|
209 { |
|
210 //Value exist in Accessory Policy DB, request can be completed |
|
211 boolValue.iValue = value; |
|
212 HandleValueMessageL( EGetValue, |
|
213 boolValue, |
|
214 KErrNone, |
|
215 0 ); |
|
216 } |
|
217 } |
|
218 break; |
|
219 |
|
220 case EAPVAccessory: |
|
221 { |
|
222 iMessage = aMessage;//copy message for later completion |
|
223 |
|
224 if ( KErrUnknown == value ) |
|
225 { |
|
226 //Forward request to ASY Proxy Handler |
|
227 iConnectionController->ASYProxyHandler().HandleASYCommsL( |
|
228 ECmdGetValueBool, |
|
229 asyCommandParamRecord ); |
|
230 |
|
231 //Store session to queue so that it will be informed when ASY has |
|
232 //served request |
|
233 iConnectionController->NotificationQueue().RegisterControlMessage( |
|
234 EGetValue, |
|
235 this ); |
|
236 } |
|
237 else |
|
238 { |
|
239 //Value exist in Accessory Policy DB, request can be completed |
|
240 boolValue.iValue = value; |
|
241 HandleValueMessageL( EGetValue, |
|
242 boolValue, |
|
243 KErrNone, |
|
244 0 ); |
|
245 } |
|
246 } |
|
247 break; |
|
248 |
|
249 default: |
|
250 { |
|
251 //Capability given as a parameter doesn't contain a value |
|
252 User::Leave( KErrArgument ); |
|
253 } |
|
254 break; |
|
255 } |
|
256 |
|
257 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetValueTBoolL - return void" ); |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CAccSrvSubConnectionBase::GetValueTIntL |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 void CAccSrvSubConnectionBase::GetValueTIntL( const RMessage2& aMessage ) |
|
265 { |
|
266 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetValueTIntL()" ); |
|
267 |
|
268 TAccPolGenericID genericID; |
|
269 TAccSrvGenericIDPckg genericIDPckg( genericID ); |
|
270 TAccPolNameRecord nameRecord; |
|
271 TAccSrvNameRecordPckg nameRecordPckg( nameRecord ); |
|
272 TAccValueTypeTInt getValue; |
|
273 TAccSrvValueTypeTIntPckg getValuePckg( getValue ); |
|
274 TASYCommandParamRecord asyCommandParamRecord; |
|
275 TInt32 value( 0 ); |
|
276 TAccValueTypeTInt tintValue = { 0 }; |
|
277 |
|
278 // Read client parameters |
|
279 aMessage.ReadL( KAccServParamPosFirst, genericIDPckg ); |
|
280 aMessage.ReadL( KAccServParamPosSecond, nameRecordPckg ); |
|
281 aMessage.ReadL( KAccServParamPosThird, getValuePckg ); |
|
282 |
|
283 //Precondition |
|
284 iServerModel->IsConnectedOrDetectedL( genericID );//Leaves with KErrArgument if the accessory is not connected or detected |
|
285 |
|
286 //Copy client parameters to format in which they are sent to ASY |
|
287 asyCommandParamRecord.iNameRecord = nameRecordPckg(); |
|
288 asyCommandParamRecord.iCmdValue = getValue.iValue; |
|
289 asyCommandParamRecord.iGenericID = genericID; |
|
290 |
|
291 |
|
292 //get capability |
|
293 TUint32 name; |
|
294 asyCommandParamRecord.iNameRecord.GetName( name ); |
|
295 |
|
296 CCapValue * capValue = iServerModel->CapabilityStorage().GetCapability( genericID, name ); |
|
297 |
|
298 if ( !capValue ) |
|
299 { |
|
300 User::Leave( KErrArgument ); |
|
301 } |
|
302 |
|
303 User::LeaveIfError( capValue->ValueInt( value ) ); |
|
304 |
|
305 switch ( capValue->Location() ) |
|
306 { |
|
307 case EAPVPolicy: |
|
308 { |
|
309 iMessage = aMessage;//copy message for later completion |
|
310 |
|
311 if ( KErrUnknown == value ) |
|
312 { |
|
313 //Value initialization is needed, forward Get-request to ASY |
|
314 iConnectionController->ASYProxyHandler().HandleASYCommsL( |
|
315 ECmdGetValueTInt, |
|
316 asyCommandParamRecord ); |
|
317 //Store session to queue so that it will be informed when ASY has |
|
318 //served request |
|
319 iConnectionController->NotificationQueue().RegisterControlMessage( |
|
320 EGetValue, |
|
321 this ); |
|
322 } |
|
323 else |
|
324 { |
|
325 //Value has been initialized, request can be completed |
|
326 tintValue.iValue = value; |
|
327 HandleValueMessageL( EGetValue, |
|
328 tintValue, |
|
329 KErrNone, |
|
330 0 ); |
|
331 } |
|
332 } |
|
333 break; |
|
334 |
|
335 case EAPVAccessory: |
|
336 { |
|
337 iMessage = aMessage;//copy message for later completion |
|
338 |
|
339 if ( KErrUnknown == value ) |
|
340 { |
|
341 //Forward request to ASY Proxy Handler |
|
342 iConnectionController->ASYProxyHandler().HandleASYCommsL( |
|
343 ECmdGetValueTInt, |
|
344 asyCommandParamRecord ); |
|
345 //Store session to queue so that it will be informed when ASY has |
|
346 //served request |
|
347 iConnectionController->NotificationQueue().RegisterControlMessage( |
|
348 EGetValue, |
|
349 this ); |
|
350 } |
|
351 else |
|
352 { |
|
353 //Value exist in Accessory Policy DB, request can be completed |
|
354 tintValue.iValue = value; |
|
355 HandleValueMessageL( EGetValue, |
|
356 tintValue, |
|
357 KErrNone, |
|
358 0 ); |
|
359 } |
|
360 } |
|
361 break; |
|
362 |
|
363 default: |
|
364 { |
|
365 //Capability given as a parameter doesn't contain a value |
|
366 User::Leave( KErrArgument ); |
|
367 } |
|
368 break; |
|
369 } |
|
370 |
|
371 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetValueTIntL - return void" ); |
|
372 } |
|
373 |
|
374 // ----------------------------------------------------------------------------- |
|
375 // CAccSrvSubConnectionBase::GetValueTDes8L |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 void CAccSrvSubConnectionBase::GetValueTDes8L( const RMessage2& aMessage ) |
|
379 { |
|
380 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetValueTDes8L()" ); |
|
381 |
|
382 TAccSrvGIDNameRecord GIDNameRecord; |
|
383 TAccSrvGIDNameRecordPckg GIDNameRecordPckg( GIDNameRecord ); |
|
384 TBuf8<KSBMaxNameLength> valueBuf; //Just For testing |
|
385 TASYCommandParamRecord asyCommandParamRecord; |
|
386 |
|
387 // Read client parameters |
|
388 aMessage.ReadL( KAccServParamPosFirst, GIDNameRecordPckg ); |
|
389 aMessage.ReadL( KAccServParamPosSecond, valueBuf ); //Just For testing |
|
390 |
|
391 //Precondition |
|
392 iServerModel->IsConnectedOrDetectedL( GIDNameRecord.iGenericID );//Leaves with KErrArgument if the accessory is not connected or detected |
|
393 |
|
394 //Copy client parameters to format in which they are sent to ASY |
|
395 asyCommandParamRecord.iNameRecord = GIDNameRecord.iNameRecord; |
|
396 asyCommandParamRecord.iCmdValue = 0; |
|
397 asyCommandParamRecord.iGenericID = GIDNameRecord.iGenericID; |
|
398 |
|
399 //get capability |
|
400 TUint32 name; |
|
401 asyCommandParamRecord.iNameRecord.GetName( name); |
|
402 |
|
403 CCapValue * capValue = iServerModel->CapabilityStorage().GetCapability( |
|
404 GIDNameRecord.iGenericID, |
|
405 name ); |
|
406 if ( !capValue ) |
|
407 { |
|
408 User::Leave( KErrArgument ); |
|
409 } |
|
410 |
|
411 switch ( capValue->Location() ) |
|
412 { |
|
413 case EAPVPolicy: |
|
414 { |
|
415 TPtrC8 ptrc8value; |
|
416 User::LeaveIfError( capValue->ValueDesc( ptrc8value ) ); |
|
417 |
|
418 |
|
419 //Value is located in Accessory Policy DB, request can be completed |
|
420 iMessage = aMessage; |
|
421 HandleValueMessageL( EGetValue, |
|
422 ptrc8value, |
|
423 KErrNone, //ErrorCode, |
|
424 0 ); //TrId, not used at the moment |
|
425 } |
|
426 break; |
|
427 |
|
428 case EAPVAccessory: |
|
429 { |
|
430 //Forward request to ASY Proxy Handler |
|
431 iConnectionController->ASYProxyHandler().HandleASYCommsL( |
|
432 ECmdGetValueTDes8, |
|
433 asyCommandParamRecord ); |
|
434 |
|
435 //Store session to queue so that it will be informed when ASY has |
|
436 //served request |
|
437 iConnectionController->NotificationQueue().RegisterControlMessage( |
|
438 EGetValue, |
|
439 this ); |
|
440 |
|
441 //Copy client message for completion after ASY has served request |
|
442 iMessage = aMessage; |
|
443 } |
|
444 break; |
|
445 |
|
446 default: |
|
447 { |
|
448 //Capability given as a parameter doesn't contain a value |
|
449 User::Leave( KErrArgument ); |
|
450 } |
|
451 break; |
|
452 } |
|
453 |
|
454 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetValueTDes8L - return void" ); |
|
455 } |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // CAccSrvSubConnectionBase::GetValueObjectBaseL |
|
459 // ----------------------------------------------------------------------------- |
|
460 // |
|
461 void CAccSrvSubConnectionBase::GetValueObjectBaseL( const RMessage2& aMessage ) |
|
462 { |
|
463 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetValueObjectBaseL()" ); |
|
464 RBufReadStream rStrm; |
|
465 TAccPolGenericID genericID; |
|
466 TAccSrvGenericIDPckg genericIDPckg( genericID ); |
|
467 TAccPolNameRecord nameRecord; |
|
468 TAccSrvNameRecordPckg nameRecordPckg( nameRecord ); |
|
469 TASYCommandParamRecord asyCommandParamRecord; |
|
470 |
|
471 CBufFlat *buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); |
|
472 CleanupStack::PushL( buf ); |
|
473 buf->ResizeL( aMessage.GetDesMaxLength( KAccServParamPosThird ) ); |
|
474 |
|
475 TPtr8 ptrBuf( buf->Ptr( 0 ) ); |
|
476 |
|
477 // Read client parameters |
|
478 aMessage.ReadL( KAccServParamPosFirst, genericIDPckg ); |
|
479 aMessage.ReadL( KAccServParamPosSecond, nameRecordPckg ); |
|
480 aMessage.ReadL( KAccServParamPosThird, ptrBuf ); |
|
481 |
|
482 //Precondition |
|
483 iServerModel->IsConnectedOrDetectedL( genericID );//Leaves with KErrArgument if the accessory is not connected or detected |
|
484 |
|
485 //Copy client parameters to format in which they are sent to ASY |
|
486 asyCommandParamRecord.iNameRecord = nameRecordPckg(); |
|
487 asyCommandParamRecord.iCmdValue = 0; |
|
488 asyCommandParamRecord.iGenericID = genericIDPckg(); |
|
489 |
|
490 //get capability |
|
491 TUint32 name; |
|
492 asyCommandParamRecord.iNameRecord.GetName( name); |
|
493 |
|
494 CCapValue * capValue = iServerModel->CapabilityStorage().GetCapability( genericIDPckg(), name ); |
|
495 |
|
496 if ( !capValue ) |
|
497 { |
|
498 User::Leave( KErrArgument ); |
|
499 } |
|
500 |
|
501 switch ( capValue->Location() ) |
|
502 { |
|
503 case EAPVPolicy: |
|
504 { |
|
505 |
|
506 TPtrC8 ptrc8value; |
|
507 User::LeaveIfError( capValue->ValueDesc( ptrc8value ) ); |
|
508 |
|
509 TPtr8 polBufPtr ( const_cast< TUint8* >( ptrc8value.Ptr() ), |
|
510 ptrc8value.Length(), ptrc8value.Length() ); |
|
511 |
|
512 //Value is located in Accessory Policy DB, request can be completed |
|
513 iMessage = aMessage; |
|
514 |
|
515 HandleValueMessageL( EGetValue, |
|
516 0, |
|
517 &polBufPtr, |
|
518 KErrNone ); |
|
519 } |
|
520 break; |
|
521 |
|
522 case EAPVAccessory: |
|
523 { |
|
524 //Forward request to ASY Proxy Handler |
|
525 iConnectionController->ASYProxyHandler().HandleASYCommsL( |
|
526 ECmdGetObjectValue, |
|
527 asyCommandParamRecord, |
|
528 &ptrBuf ); |
|
529 |
|
530 |
|
531 |
|
532 //Store session to queue so that it will be informed when ASY has |
|
533 //served request |
|
534 iConnectionController->NotificationQueue().RegisterControlMessage( |
|
535 EGetValue, |
|
536 this ); |
|
537 |
|
538 //Copy client message for completion after ASY has served request |
|
539 iMessage = aMessage; |
|
540 } |
|
541 break; |
|
542 |
|
543 default: |
|
544 { |
|
545 //Capability given as a parameter doesn't support other locations |
|
546 User::Leave( KErrArgument ); |
|
547 } |
|
548 break; |
|
549 } |
|
550 |
|
551 CleanupStack::PopAndDestroy( buf ); |
|
552 |
|
553 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetValueObjectBaseL - return void" ); |
|
554 } |
|
555 // ----------------------------------------------------------------------------- |
|
556 // CAccSrvSubConnectionBase::GetValueObjectBaseL |
|
557 // ----------------------------------------------------------------------------- |
|
558 // |
|
559 void CAccSrvSubConnectionBase::GetObjectValueL( const RMessage2& aMessage ) |
|
560 { |
|
561 |
|
562 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetObjectValueL() - Get Object" ); |
|
563 |
|
564 if( iDataBuf ) |
|
565 { |
|
566 // Write data to client. |
|
567 aMessage.WriteL( KAccServParamPosFirst, iDataBuf->Ptr(0) ); |
|
568 //Delete stored data. |
|
569 delete iDataBuf; |
|
570 iDataBuf = NULL; |
|
571 } |
|
572 else |
|
573 { |
|
574 //Write NULL to the buffer |
|
575 _LIT( KNull, "" ); |
|
576 aMessage.WriteL( KAccServParamPosFirst, KNull ); |
|
577 } |
|
578 |
|
579 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::GetObjectValueL - Get Object - return void" ); |
|
580 |
|
581 } |
|
582 // ----------------------------------------------------------------------------- |
|
583 // CAccSrvSubConnectionBase::DispatchMessageL |
|
584 // Handles client request |
|
585 // ----------------------------------------------------------------------------- |
|
586 // |
|
587 void CAccSrvSubConnectionBase::DispatchMessageL( const RMessage2& aMessage ) |
|
588 { |
|
589 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::DispatchMessageL()" ); |
|
590 |
|
591 TInt function = aMessage.Function(); |
|
592 |
|
593 switch ( function ) |
|
594 { |
|
595 case EAccSrvGetSubblockNameArray: |
|
596 { |
|
597 GetSubblockNameArrayL( aMessage ); |
|
598 break; |
|
599 } |
|
600 case EAccSrvGetValueTBool: |
|
601 { |
|
602 GetValueTBoolL( aMessage ); |
|
603 break; |
|
604 } |
|
605 case EAccSrvGetValueTInt: |
|
606 { |
|
607 GetValueTIntL( aMessage ); |
|
608 break; |
|
609 } |
|
610 case EAccSrvGetValueTDes8: |
|
611 { |
|
612 GetValueTDes8L( aMessage ); |
|
613 break; |
|
614 } |
|
615 case EAccSrvGetValueObjectBase: |
|
616 { |
|
617 GetValueObjectBaseL( aMessage ); |
|
618 break; |
|
619 } |
|
620 case EAccSrvGetObjectValue: |
|
621 { |
|
622 GetObjectValueL( aMessage ); |
|
623 break; |
|
624 } |
|
625 |
|
626 default: |
|
627 { |
|
628 TRACE_ASSERT_ALWAYS; |
|
629 COM_TRACE_1( "[AccFW:AccServer] CAccSrvSubConnectionBase::DispatchMessageL - unhandled function %d", function ); |
|
630 User::Leave( KErrGeneral ); |
|
631 break; |
|
632 } |
|
633 } // switch( function ) |
|
634 |
|
635 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::DispatchMessageL - return void" ); |
|
636 } |
|
637 |
|
638 // ----------------------------------------------------------------------------- |
|
639 // CAccSrvSubConnectionBase::HandleValueMessageL |
|
640 // ----------------------------------------------------------------------------- |
|
641 // |
|
642 void CAccSrvSubConnectionBase::HandleValueMessageL( TMsgID aMsgID, |
|
643 TAccValueTypeTBool aCmdResponse, |
|
644 TInt aErrorCode, |
|
645 TInt /*aTrId*/ ) |
|
646 { |
|
647 COM_TRACE_3( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL(msgID=%d value=%d err=%d) - TBool", aMsgID, aCmdResponse.iValue, aErrorCode ); |
|
648 |
|
649 TAccPolGenericID genericID; |
|
650 TAccSrvGenericIDPckg genericIDPckg( genericID ); |
|
651 TAccPolNameRecord nameRecord; |
|
652 TAccSrvNameRecordPckg nameRecordPckg( nameRecord ); |
|
653 |
|
654 // Read client parameters |
|
655 iMessage.ReadL( KAccServParamPosFirst, genericIDPckg ); |
|
656 iMessage.ReadL( KAccServParamPosSecond, nameRecordPckg ); |
|
657 |
|
658 switch ( aMsgID ) |
|
659 { |
|
660 case EGetValue: |
|
661 { |
|
662 //Store value to cap storage |
|
663 StoreValueL( genericID, nameRecord, aCmdResponse.iValue ); |
|
664 |
|
665 TPckg<TAccValueTypeTBool> valuePckg( aCmdResponse ); |
|
666 iMessage.WriteL( KAccServParamPosThird, valuePckg ); |
|
667 iMessage.Complete( aErrorCode ); |
|
668 } |
|
669 break; |
|
670 |
|
671 default: |
|
672 { |
|
673 TRACE_ASSERT_ALWAYS; |
|
674 User::Leave( KErrGeneral ); |
|
675 } |
|
676 break; |
|
677 } |
|
678 |
|
679 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL - TBool - return void" ); |
|
680 } |
|
681 |
|
682 // ----------------------------------------------------------------------------- |
|
683 // CAccSrvSubConnectionBase::HandleValueMessageL |
|
684 // ----------------------------------------------------------------------------- |
|
685 // |
|
686 void CAccSrvSubConnectionBase::HandleValueMessageL( TMsgID aMsgID, |
|
687 TAccValueTypeTInt aCmdResponse, |
|
688 TInt aErrorCode, |
|
689 TInt /*aTrId*/ ) |
|
690 { |
|
691 COM_TRACE_3( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL(msgID=%d value=%d err=%d) - TInt", aMsgID, aCmdResponse.iValue, aErrorCode ); |
|
692 |
|
693 TAccPolGenericID genericID; |
|
694 TAccSrvGenericIDPckg genericIDPckg( genericID ); |
|
695 TAccPolNameRecord nameRecord; |
|
696 TAccSrvNameRecordPckg nameRecordPckg( nameRecord ); |
|
697 |
|
698 // Read client parameters |
|
699 iMessage.ReadL( KAccServParamPosFirst, genericIDPckg ); |
|
700 iMessage.ReadL( KAccServParamPosSecond, nameRecordPckg ); |
|
701 |
|
702 switch ( aMsgID ) |
|
703 { |
|
704 case EGetValue: |
|
705 { |
|
706 //Value for this name is stored to Policy DB if it doesn't exist there yet |
|
707 StoreValueL( genericID, nameRecord, aCmdResponse.iValue ); |
|
708 |
|
709 TPckgBuf<TAccValueTypeTInt> valueBuf( aCmdResponse ); |
|
710 iMessage.WriteL( KAccServParamPosThird, valueBuf ); |
|
711 iMessage.Complete( aErrorCode ); |
|
712 } |
|
713 break; |
|
714 |
|
715 default: |
|
716 { |
|
717 TRACE_ASSERT_ALWAYS; |
|
718 User::Leave( KErrGeneral ); |
|
719 } |
|
720 break; |
|
721 } |
|
722 |
|
723 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL - TInt - return void" ); |
|
724 } |
|
725 |
|
726 // ----------------------------------------------------------------------------- |
|
727 // CAccSrvSubConnectionBase::HandleValueMessageL |
|
728 // ----------------------------------------------------------------------------- |
|
729 // |
|
730 void CAccSrvSubConnectionBase::HandleValueMessageL( TMsgID aMsgID, |
|
731 TDesC8& aValue, |
|
732 TInt aErrorCode, |
|
733 TInt /*aTrId*/ ) |
|
734 { |
|
735 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL() - TDesC8t" ); |
|
736 |
|
737 switch ( aMsgID ) |
|
738 { |
|
739 case EGetValue: |
|
740 { |
|
741 TInt writeSize( aValue.Size() );//Size of the data to be written to client side |
|
742 TInt reservedSize( 0 );//Client has reserved buffer of this size |
|
743 TPckg<TInt> reservedSizePckg( reservedSize ); |
|
744 iMessage.ReadL( KAccServParamPosThird, reservedSizePckg ); |
|
745 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL() - Stage 1" ); |
|
746 |
|
747 if( writeSize > 0 ) |
|
748 { |
|
749 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL() - Stage 2" ); |
|
750 if( writeSize <= reservedSize ) |
|
751 { |
|
752 iMessage.WriteL( KAccServParamPosSecond, aValue ); |
|
753 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL() - Stage 2.1" ); |
|
754 iMessage.Complete( aErrorCode ); |
|
755 } |
|
756 else |
|
757 { |
|
758 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL() - Stage 2.2" ); |
|
759 User::Leave( KErrOverflow ); |
|
760 } |
|
761 } |
|
762 else |
|
763 { |
|
764 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL() - Stage 3" ); |
|
765 if( aErrorCode != KErrNone ) |
|
766 { |
|
767 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL() - Stage 3.1" ); |
|
768 iMessage.Complete( aErrorCode ); |
|
769 } |
|
770 else |
|
771 { |
|
772 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL() - Stage 3.2" ); |
|
773 User::Leave( KErrArgument ); |
|
774 } |
|
775 } |
|
776 } |
|
777 break; |
|
778 |
|
779 default: |
|
780 { |
|
781 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL() - Stage 4" ); |
|
782 TRACE_ASSERT_ALWAYS; |
|
783 User::Leave( KErrGeneral ); |
|
784 } |
|
785 break; |
|
786 } |
|
787 |
|
788 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL - TDesC8 - return void" ); |
|
789 } |
|
790 |
|
791 // ----------------------------------------------------------------------------- |
|
792 // CAccSrvSubConnectionBase::HandleValueMessageL |
|
793 // ----------------------------------------------------------------------------- |
|
794 // |
|
795 void CAccSrvSubConnectionBase::HandleValueMessageL( TMsgID aMsgID, |
|
796 TInt /*aTrId*/, |
|
797 TPtr8* aPtrBuf, |
|
798 TInt aErrorCode ) |
|
799 { |
|
800 |
|
801 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL() - Object" ); |
|
802 |
|
803 switch ( aMsgID ) |
|
804 { |
|
805 case EGetValue: |
|
806 { |
|
807 TInt clientBufSize( iMessage.GetDesLength( KAccServParamPosThird ) ); |
|
808 TInt dataBufSize ( aPtrBuf->Size() ); |
|
809 |
|
810 if( dataBufSize > 0 ) |
|
811 { |
|
812 if( dataBufSize <= clientBufSize ) |
|
813 { |
|
814 // Write data to client. |
|
815 iMessage.WriteL( KAccServParamPosThird, *aPtrBuf ); |
|
816 |
|
817 //Complete message. |
|
818 iMessage.Complete( aErrorCode ); |
|
819 } |
|
820 else |
|
821 { |
|
822 |
|
823 |
|
824 CBufFlat* buf = CBufFlat::NewL( sizeof( KMaxTUint ) ); |
|
825 CleanupStack::PushL( buf ); |
|
826 buf->ResizeL( sizeof(KMaxTUint) ); |
|
827 |
|
828 RBufWriteStream wStrm; |
|
829 (void) wStrm.Open( *buf ); |
|
830 CleanupClosePushL( wStrm ); |
|
831 wStrm.WriteInt32L( dataBufSize );//new buffer size |
|
832 wStrm.CommitL(); |
|
833 CleanupStack::PopAndDestroy( &wStrm ); |
|
834 |
|
835 //write a new buffer size to client |
|
836 TPtr8 ptr( buf->Ptr( 0 ) ); |
|
837 iMessage.WriteL( KAccServParamPosThird, ptr ); |
|
838 iMessage.Complete( KErrOverflow ); |
|
839 |
|
840 CleanupStack::PopAndDestroy( buf ); |
|
841 // Store data to connection base subsession. |
|
842 iDataBuf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); |
|
843 iDataBuf->ResizeL( dataBufSize ); |
|
844 iDataBuf->Write( 0, *aPtrBuf ); |
|
845 } |
|
846 } |
|
847 else |
|
848 { |
|
849 if( aErrorCode != KErrNone ) |
|
850 { |
|
851 iMessage.Complete( aErrorCode );//Complete message. |
|
852 } |
|
853 else |
|
854 { |
|
855 iMessage.Complete( KErrArgument );//Complete message. |
|
856 } |
|
857 |
|
858 } |
|
859 } |
|
860 break; |
|
861 |
|
862 default: |
|
863 { |
|
864 TRACE_ASSERT_ALWAYS; |
|
865 User::Leave( KErrGeneral ); |
|
866 } |
|
867 break; |
|
868 } |
|
869 |
|
870 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::HandleValueMessageL - Object - return void" ); |
|
871 } |
|
872 |
|
873 |
|
874 // ----------------------------------------------------------------------------- |
|
875 // CAccSrvSubConnectionBase::StoreValueToPolicyDB |
|
876 // ----------------------------------------------------------------------------- |
|
877 // |
|
878 void CAccSrvSubConnectionBase::StoreValueL( |
|
879 const TAccPolGenericID& aGenericID, |
|
880 TAccPolNameRecord& aNameRecord, |
|
881 TInt aValue ) |
|
882 { |
|
883 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::StoreValueL()" ); |
|
884 |
|
885 TUint32 name; |
|
886 aNameRecord.GetName( name ); |
|
887 |
|
888 CCapValue * capValue = iServerModel->CapabilityStorage().GetCapability( aGenericID, name); |
|
889 |
|
890 if ( !capValue ) |
|
891 { |
|
892 User::Leave( KErrArgument ); |
|
893 } |
|
894 |
|
895 capValue->SetValueL( aValue ); |
|
896 |
|
897 |
|
898 COM_TRACE_( "[AccFW:AccServer] CAccSrvSubConnectionBase::StoreValueL - return void" ); |
|
899 } |
|
900 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
901 |
|
902 // End of File |