280 // CCPServerSession::ExecuteActionL |
282 // CCPServerSession::ExecuteActionL |
281 // --------------- -------------------------------------------------------------- |
283 // --------------- -------------------------------------------------------------- |
282 // |
284 // |
283 void CCPServerSession::ExecuteActionL( const RMessage2& aMessage ) |
285 void CCPServerSession::ExecuteActionL( const RMessage2& aMessage ) |
284 { |
286 { |
|
287 CP_DEBUG( _L8("CCPServerSession::ExecuteActionSizeL()" ) ); |
|
288 TUint options = static_cast<TUint>( aMessage.Int2() ); // 2 == KOptionsPosition |
|
289 CCPLiwMap* map = UnpackFromClientLC( aMessage ); |
|
290 ExecuteActionL( map, EFalse, options ); |
|
291 CleanupStack::PopAndDestroy( map ); |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 // --------------- -------------------------------------------------------------- |
|
297 // |
|
298 void CCPServerSession::ExecuteActionL(const CCPLiwMap* aMap, |
|
299 TBool aEnableCache, TUint aOptions) |
|
300 { |
|
301 CP_DEBUG( _L8("CCPServerSession::ExecuteActionSizeL()" ) ); |
285 TInt error(KErrNone); |
302 TInt error(KErrNone); |
286 CP_DEBUG( _L8("CCPServerSession::ExecuteActionSizeL()" ) ); |
303 CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC(); |
287 |
|
288 TUint options = static_cast<TUint>( aMessage.Int2() ); // 2 == KOptionsPosition |
|
289 |
|
290 CCPLiwMap* map = UnpackFromClientLC( aMessage ); |
|
291 CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC( ); |
|
292 CLiwDefaultList* list = CLiwDefaultList::NewLC(); |
304 CLiwDefaultList* list = CLiwDefaultList::NewLC(); |
293 error = iDataManager->GetActionL( *map, *paramList, list ); |
305 error = iDataManager->GetActionsL(*aMap, aEnableCache, *paramList, list ); |
294 //we notify apart from action execution result. So in fact |
306 //we notify apart from action execution result. So in fact |
295 //notification means there was an attempt to execute action |
307 //notification means there was an attempt to execute action |
296 if ( !( options & KDisableNotification ) ) |
308 if (!(aOptions & KDisableNotification)) |
297 { |
309 { |
298 iDataManager->HandleChangeL( list ); |
310 iDataManager->HandleChangeL(list); |
299 } |
311 } |
300 User::LeaveIfError( error ); |
312 User::LeaveIfError(error); |
301 ExecuteL( *paramList ); |
313 ExecuteL(*paramList); |
302 CleanupStack::PopAndDestroy( list ); |
314 CleanupStack::PopAndDestroy(list); |
303 CleanupStack::PopAndDestroy( paramList ); |
315 CleanupStack::PopAndDestroy(paramList); |
304 CleanupStack::PopAndDestroy( map ); |
316 } |
|
317 |
|
318 // ----------------------------------------------------------------------------- |
|
319 // CCPServerSession::ExecuteMultipleActionsL |
|
320 // --------------- -------------------------------------------------------------- |
|
321 // |
|
322 void CCPServerSession::ExecuteMultipleActionsL(const RMessage2& aMessage) |
|
323 { |
|
324 CP_DEBUG( _L8("CCPServerSession::ExecuteMultipleActionsL()" ) ); |
|
325 |
|
326 CLiwGenericParamList* genericList = UnpackForMultiExecuteLC(aMessage); |
|
327 TUint options = static_cast<TUint> (aMessage.Int2()); // 2 == KOptionsPosition |
|
328 |
|
329 const TLiwGenericParam* param = NULL; |
|
330 TInt pos(0); |
|
331 param = genericList->FindFirst(pos, KFilters); |
|
332 const CLiwList* maps = param->Value().AsList(); |
|
333 CLiwDefaultList* cpMaps = CheckValidityLC(maps); |
|
334 |
|
335 //execute actions |
|
336 for (TInt i = 0; i < cpMaps->Count(); i++) |
|
337 { |
|
338 TLiwVariant mapVariant; |
|
339 mapVariant.PushL(); |
|
340 cpMaps->AtL(i, mapVariant); |
|
341 const CCPLiwMap* map = |
|
342 static_cast<const CCPLiwMap*> (mapVariant.AsMap()); |
|
343 ExecuteActionL(map, ETrue, options); |
|
344 CleanupStack::PopAndDestroy(&mapVariant); |
|
345 } |
|
346 |
|
347 CleanupStack::PopAndDestroy(cpMaps); |
|
348 CleanupStack::PopAndDestroy(genericList); |
305 } |
349 } |
306 |
350 |
307 // ----------------------------------------------------------------------------- |
351 // ----------------------------------------------------------------------------- |
308 // CCPServerSession::ExecuteL |
352 // CCPServerSession::ExecuteL |
309 // --------------- -------------------------------------------------------------- |
353 // --------------- -------------------------------------------------------------- |
486 if (aInsertTrigger) |
530 if (aInsertTrigger) |
487 { |
531 { |
488 aMap->InsertL( KActionTrigger, TLiwVariant( KActivateTrigger ) ); |
532 aMap->InsertL( KActionTrigger, TLiwVariant( KActivateTrigger ) ); |
489 } |
533 } |
490 CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC(); |
534 CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC(); |
491 iDataManager->GetActionL( *aMap, *paramList, aNotificationList ); |
535 iDataManager->GetActionsL( *aMap, EFalse, *paramList, aNotificationList ); |
492 iActionHandlerThread->ExecuteL( *paramList ); |
536 iActionHandlerThread->ExecuteL( *paramList ); |
493 CleanupStack::PopAndDestroy( paramList ); |
537 CleanupStack::PopAndDestroy( paramList ); |
494 } |
538 } |
495 |
539 |
496 // ----------------------------------------------------------------------------- |
540 // ----------------------------------------------------------------------------- |
502 // Allways allow to unregister |
546 // Allways allow to unregister |
503 return ( (aMessage.Function() != ECpServerUnRegisterObserver) |
547 return ( (aMessage.Function() != ECpServerUnRegisterObserver) |
504 && iServer->GetLock() ); |
548 && iServer->GetLock() ); |
505 |
549 |
506 } |
550 } |
|
551 |
|
552 // ----------------------------------------------------------------------------- |
|
553 // |
|
554 // --------------- -------------------------------------------------------------- |
|
555 // |
|
556 CLiwGenericParamList* CCPServerSession::UnpackForMultiExecuteLC( |
|
557 const RMessage2& aMessage) |
|
558 { |
|
559 TInt deslen = aMessage.GetDesLengthL(KDescriptorPosition); |
|
560 HBufC8* buffer = HBufC8::NewLC(deslen); |
|
561 TPtr8 tempDes = buffer->Des(); |
|
562 aMessage.Read(KDescriptorPosition, tempDes); |
|
563 RDesReadStream datastrm(*buffer); |
|
564 CleanupClosePushL(datastrm); |
|
565 CLiwGenericParamList* genericList = CLiwGenericParamList::NewL(datastrm); |
|
566 CleanupStack::PopAndDestroy(&datastrm); |
|
567 CleanupStack::PopAndDestroy(buffer); |
|
568 CleanupStack::PushL(genericList); |
|
569 return genericList; |
|
570 } |
|
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // |
|
574 // --------------- -------------------------------------------------------------- |
|
575 // |
|
576 CLiwDefaultList* CCPServerSession::CheckValidityLC(const CLiwList* aMaps) |
|
577 { |
|
578 CLiwDefaultList* cpMaps = CLiwDefaultList::NewLC(); |
|
579 for (TInt i = 0; i < aMaps->Count(); i++) |
|
580 { |
|
581 TLiwVariant mapVariant; |
|
582 mapVariant.PushL(); |
|
583 aMaps->AtL(i, mapVariant); |
|
584 if (mapVariant.TypeId() != LIW::EVariantTypeMap) |
|
585 { |
|
586 User::Leave(KErrBadName); |
|
587 } |
|
588 CCPLiwMap* map = CCPLiwMap::NewL(*mapVariant.AsMap()); |
|
589 map->PushL(); |
|
590 map->IsValidForActionL(); |
|
591 cpMaps->AppendL(TLiwVariant(map)); |
|
592 CleanupStack::PopAndDestroy(map); |
|
593 CleanupStack::PopAndDestroy(&mapVariant); |
|
594 } |
|
595 return cpMaps; |
|
596 } |
|
597 |
507 // End of File |
598 // End of File |