1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
57 KSecurityCheckForRequest3, |
57 KSecurityCheckForRequest3, |
58 CPolicyServer::ENotSupported |
58 CPolicyServer::ENotSupported |
59 }; |
59 }; |
60 |
60 |
61 //ESetAsPriorityClient request is allowed only for priotity clients(Telephony). Inorder to prevent the access |
61 //ESetAsPriorityClient request is allowed only for priotity clients(Telephony). Inorder to prevent the access |
62 //client request will be policed using C32 SID |
62 //client request will be policed using C32exe.exe SID |
63 #define KC32SecureId 0x10003D33 |
63 #define KC32SecureId 0x101F7989 |
64 |
64 |
65 /** |
65 /** |
66 Array containing the different security checks performed by this server |
66 Array containing the different security checks performed by this server |
67 */ |
67 */ |
68 const CPolicyServer::TPolicyElement KPolicyElements[] = |
68 const CPolicyServer::TPolicyElement KPolicyElements[] = |
205 |
204 |
206 /** |
205 /** |
207 */ |
206 */ |
208 CSsmAdaptationServer* CSsmAdaptationServer::NewLC( ) |
207 CSsmAdaptationServer* CSsmAdaptationServer::NewLC( ) |
209 { |
208 { |
210 CSsmAdaptationServer* server = new(ELeave) CSsmAdaptationServer(); |
209 return CSsmAdaptationServer::NewLC(KSusAdaptionServerName); |
211 CleanupStack::PushL (server ); |
210 } |
212 server->ConstructL ( ); |
211 |
213 return server; |
212 /** |
214 } |
213 * Overloaded NewLC, which starts the server with the provided name. |
215 |
214 @param aServerName - Name of the Server. |
216 /** |
215 */ |
217 */ |
216 CSsmAdaptationServer* CSsmAdaptationServer::NewLC(const TDesC& aServerName) |
218 void CSsmAdaptationServer::ConstructL( ) |
217 { |
|
218 CSsmAdaptationServer* server = new(ELeave) CSsmAdaptationServer(); |
|
219 CleanupStack::PushL(server); |
|
220 server->ConstructL(aServerName); |
|
221 return server; |
|
222 } |
|
223 |
|
224 |
|
225 /** |
|
226 * ConstructL() |
|
227 */ |
|
228 void CSsmAdaptationServer::ConstructL(const TDesC& aServerName) |
219 { |
229 { |
220 |
230 |
221 __ASSERT_ALWAYS( KErrNone == User::SetCritical(User::ESystemCritical), |
231 __ASSERT_ALWAYS( KErrNone == User::SetCritical(User::ESystemCritical), |
222 User::Panic(KPanicSsmSus, EAdaptionServerError1)); |
232 User::Panic(KPanicSsmSus, EAdaptionServerError1)); |
223 |
233 |
224 __ASSERT_ALWAYS( KErrNone == User::RenameThread(KSusAdaptionServerName), |
234 __ASSERT_ALWAYS( KErrNone == User::RenameThread(KSusAdaptionServerName), |
225 User::Panic(KPanicSsmSus, EAdaptionServerError2)); |
235 User::Panic(KPanicSsmSus, EAdaptionServerError2)); |
226 |
236 |
227 iSusAdaptationPluginLoader = CSusAdaptationPluginLoader::NewL(); |
237 iSusAdaptationPluginLoader = CSusAdaptationPluginLoader::NewL(); |
228 TInt err = Start(KSusAdaptionServerName); |
238 TInt err = Start(aServerName); |
229 #ifdef TESTSUSADAPTATIONPLUGINLOAD_OOM |
239 #ifdef TESTSUSADAPTATIONPLUGINLOAD_OOM |
230 if (err != KErrNone && err != KErrAlreadyExists) |
240 if (err != KErrNone && err != KErrAlreadyExists) |
231 { |
241 { |
232 User::Leave(err); |
242 User::Leave(err); |
233 } |
243 } |
499 { |
509 { |
500 if( iEmergencyCallRfAdaptation == NULL ) |
510 if( iEmergencyCallRfAdaptation == NULL ) |
501 { |
511 { |
502 LoadEmergencyCallRfAdaptationL(); |
512 LoadEmergencyCallRfAdaptationL(); |
503 } |
513 } |
504 |
|
505 iEmergencyCallRfAdaptation->DoEmergencyCallRfAdaptationCancelL(aMessage); |
514 iEmergencyCallRfAdaptation->DoEmergencyCallRfAdaptationCancelL(aMessage); |
506 } |
515 } |
507 |
|
508 |
|
509 |
|
510 |
516 |
511 void CSsmAdaptationServer::LoadStateAdaptationL() |
517 void CSsmAdaptationServer::LoadStateAdaptationL() |
512 { |
518 { |
513 MStateAdaptation *stateAdaptationPlugin = iSusAdaptationPluginLoader->CreateStateAdaptationL(); |
519 MStateAdaptation *stateAdaptationPlugin = iSusAdaptationPluginLoader->CreateStateAdaptationL(); |
514 CleanupReleasePushL(*stateAdaptationPlugin); |
520 CleanupReleasePushL(*stateAdaptationPlugin); |
562 } |
568 } |
563 void CSsmAdaptationServer::LoadEmergencyCallRfAdaptationL() |
569 void CSsmAdaptationServer::LoadEmergencyCallRfAdaptationL() |
564 { |
570 { |
565 MEmergencyCallRfAdaptation *emergencyCallRfAdaptationPlugin = iSusAdaptationPluginLoader->CreateEmergencyCallRfAdaptationL(); |
571 MEmergencyCallRfAdaptation *emergencyCallRfAdaptationPlugin = iSusAdaptationPluginLoader->CreateEmergencyCallRfAdaptationL(); |
566 CleanupReleasePushL(*emergencyCallRfAdaptationPlugin); |
572 CleanupReleasePushL(*emergencyCallRfAdaptationPlugin); |
567 //From here emergencyCallRfAdaptationPlugin object will be owned by iEmergencyCallRfAdaptation |
573 //From here emergencyCallRfAdaptationPlugin object will be owned by iEmergencyCallRfAdaptation |
568 iEmergencyCallRfAdaptation = CEmergencyCallRfAdaptation::NewL(*emergencyCallRfAdaptationPlugin); |
574 iEmergencyCallRfAdaptation = CEmergencyCallRfAdaptation::NewL(emergencyCallRfAdaptationPlugin); |
569 CleanupStack::Pop(emergencyCallRfAdaptationPlugin); |
575 CleanupStack::Pop(emergencyCallRfAdaptationPlugin); |
570 //Reserve memory for performing Emergency call during OOM condition |
|
571 iEmergencyCallRfAdaptation->ReserveMemoryL(); |
|
572 } |
576 } |
573 |
577 |
574 #ifdef _DEBUG |
578 #ifdef _DEBUG |
575 void CSsmAdaptationServer::UnloadAdaptationsAndObservers() |
579 void CSsmAdaptationServer::UnloadAdaptationsAndObservers() |
576 { |
580 { |
654 { |
658 { |
655 iMessage.WriteL(aParam,aDes); |
659 iMessage.WriteL(aParam,aDes); |
656 } |
660 } |
657 |
661 |
658 CAdaptationMessage::CAdaptationMessage(const RMessage2 &aMessage): CBase(),iMessage(aMessage) |
662 CAdaptationMessage::CAdaptationMessage(const RMessage2 &aMessage): CBase(),iMessage(aMessage) |
659 ,iMessageAvailable(ETrue),iUsingReservedHeap(EFalse) |
|
660 { |
663 { |
661 } |
664 } |
662 |
665 |
663 void CAdaptationMessage::Complete(TInt aReason) |
666 void CAdaptationMessage::Complete(TInt aReason) |
664 { |
667 { |
665 iMessage.Complete(aReason); |
668 if (!(iMessage.IsNull())) |
666 } |
669 { |
667 |
670 iMessage.Complete(aReason); |
|
671 } |
|
672 } |
|
673 |
|
674 void CAdaptationMessage::SetMessage(const RMessage2& aMessage) |
|
675 { |
|
676 iMessage = const_cast<RMessage2&> (aMessage); |
|
677 } |
668 |
678 |
669 void RSsmAdaptationRequestQueue::NotifyAndRemoveAll() |
679 void RSsmAdaptationRequestQueue::NotifyAndRemoveAll() |
670 { |
680 { |
671 TInt index,count = iQueue.Count(); |
681 TInt index,count = iQueue.Count(); |
672 |
682 |
676 delete iQueue[index]; |
686 delete iQueue[index]; |
677 iQueue[index] = NULL; |
687 iQueue[index] = NULL; |
678 } |
688 } |
679 iQueue.Reset(); |
689 iQueue.Reset(); |
680 } |
690 } |
681 |
|
682 void RSsmAdaptationRequestQueue::NotifyAndRemoveAll(RHeap *aReservedHeap) |
|
683 { |
|
684 TInt index,count = iQueue.Count(); |
|
685 |
|
686 for(index =0;index < count ;index++) |
|
687 { |
|
688 iQueue[index]->Complete(KErrServerTerminated); |
|
689 if(iQueue[index]->iUsingReservedHeap) |
|
690 { |
|
691 aReservedHeap->Free(iQueue[index]); |
|
692 } |
|
693 else |
|
694 { |
|
695 delete iQueue[index]; |
|
696 } |
|
697 iQueue[index] = NULL; |
|
698 } |
|
699 iQueue.Reset(); |
|
700 } |
|
701 |
691 |
702 void RSsmAdaptationRequestQueue::Close() |
692 void RSsmAdaptationRequestQueue::Close() |
703 { |
693 { |
704 iQueue.Close(); |
694 iQueue.Close(); |
705 } |
695 } |
734 } |
724 } |
735 } |
725 } |
736 |
726 |
737 } |
727 } |
738 |
728 |
739 void RSsmAdaptationRequestQueue::RemoveFromQueueAndComplete(const RMessage2 &aMessage, RHeap *aReservedHeap ) |
|
740 { |
|
741 |
|
742 CAdaptationMessage *messageToBeDeleted; |
|
743 |
|
744 // iQueue.Count() is recalculated each time as the object is removed from the |
|
745 // array(which reduces the number of object pointers in the array |
|
746 for(TInt index = 0; index < iQueue.Count(); ++index ) |
|
747 { |
|
748 if(aMessage.Session() == iQueue[index]->Session()) |
|
749 { |
|
750 messageToBeDeleted = iQueue[index]; |
|
751 DEBUGPRINT2A("RSsmAdaptationRequestQueue(aMessage,ReservedHeap)called to cancel the request with function id: %d", messageToBeDeleted->Function()); |
|
752 iQueue.Remove(index); |
|
753 messageToBeDeleted->Complete(KErrCancel); |
|
754 if(messageToBeDeleted->iUsingReservedHeap) |
|
755 { |
|
756 aReservedHeap->Free(messageToBeDeleted); |
|
757 } |
|
758 else |
|
759 { |
|
760 delete messageToBeDeleted; |
|
761 } |
|
762 --index; |
|
763 } |
|
764 } |
|
765 } |
|
766 void RSsmAdaptationRequestQueue::Dequeue(CAdaptationMessage *&aCurrentMessage) |
729 void RSsmAdaptationRequestQueue::Dequeue(CAdaptationMessage *&aCurrentMessage) |
767 { |
730 { |
768 aCurrentMessage = iQueue[0]; |
731 aCurrentMessage = iQueue[0]; |
769 iQueue.Remove(0); |
732 iQueue.Remove(0); |
770 } |
733 } |
771 TInt RSsmAdaptationRequestQueue::Queue(CAdaptationMessage *aPendingRequest) |
734 TInt RSsmAdaptationRequestQueue::Queue(CAdaptationMessage *aPendingRequest) |
772 { |
735 { |
773 return iQueue.Append(aPendingRequest); |
736 return iQueue.Append(aPendingRequest); |
774 } |
737 } |
775 |
|
776 TInt RSsmAdaptationRequestQueue::Reserve(TInt aReserverCount) |
|
777 { |
|
778 return(iQueue.Reserve(aReserverCount)); |
|
779 } |
|
780 |
738 |
781 /** |
739 /** |
782 * Method to get number of object pointers in the Queue |
740 * Method to get number of object pointers in the Queue |
783 */ |
741 */ |
784 TInt RSsmAdaptationRequestQueue::Count() |
742 TInt RSsmAdaptationRequestQueue::Count() |