diff -r 1ddbe54d0645 -r ccb4f6b3db21 sysstatemgmt/systemstateplugins/adptplugin/src/simadaptationref.cpp --- a/sysstatemgmt/systemstateplugins/adptplugin/src/simadaptationref.cpp Thu Aug 19 11:09:10 2010 +0300 +++ b/sysstatemgmt/systemstateplugins/adptplugin/src/simadaptationref.cpp Tue Aug 31 16:29:05 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -10,10 +10,20 @@ // // Contributors: // -// Description: +// Description: This adaptation plugin implementation is for test/reference purposes. +// The loading of this plugin is controlled through test macro defined in the iby file "ssmcompatibility.iby". +// If the macro "TEST_SSM_MACRO" is not defined, original plugins are loaded and this plugin is not loaded. +// If the test P & S key is set in the test code, the calls are routed to the reference or dummy implementations. +// Else the actual plugins are loaded and the calls are routed to the actual implementations. +// The test P & S key which it looks for is KSimPluginPropertyKey (0x2000D76A) // #include "simadaptationref.h" +#include "ssmdebug.h" +#include + +const TUint32 KSimPluginPropertyKey = 0x2000D76B; +const TUid KPropertyCategory={0x2000D75B}; /** Function to create new Sim Adaptation Plugin. @@ -40,6 +50,7 @@ CSimAdaptationRef::~CSimAdaptationRef() { delete iTimer; + iSaaSimAdaptationLib.Close(); } CSimAdaptationRef::CSimAdaptationRef() @@ -48,6 +59,11 @@ void CSimAdaptationRef::ConstructL() { + DEBUGPRINT1A("Loading Actual plugins"); + _LIT(KSaaSimAdaptationDLL, "saaSimadaptation.dll"); + User::LeaveIfError(iSaaSimAdaptationLib.Load(KSaaSimAdaptationDLL)); + iSaaSimAdaptationDll = (MSimAdaptation *)(iSaaSimAdaptationLib.Lookup(1)()); + iTimer = CSimRefAdaptationTimer::NewL(); } @@ -57,11 +73,20 @@ delete this; } -void CSimAdaptationRef::GetSimOwned(TDes8& /*aOwnedPckg*/, TRequestStatus& aStatus) +void CSimAdaptationRef::GetSimOwned(TDes8& aOwnedPckg, TRequestStatus& aStatus) { - aStatus = KRequestPending; - TRequestStatus* pStatus = &aStatus; - User::RequestComplete(pStatus, KErrNone); + if(!IsTestPsKeyDefined()) + { + DEBUGPRINT1A("GetSimOwned:: Calling Actual plugins functions (saaSimadaptation.dll)"); + iSaaSimAdaptationDll->GetSimOwned(aOwnedPckg,aStatus); + } + else + { + DEBUGPRINT1A("GetSimOwned :: Calling ref plugins functions (Simadaptationref.dll)"); + aStatus = KRequestPending; + TRequestStatus* pStatus = &aStatus; + User::RequestComplete(pStatus, KErrNone); + } } /** @@ -70,10 +95,16 @@ */ void CSimAdaptationRef::GetCancel() { + if(!IsTestPsKeyDefined()) + { + DEBUGPRINT1A("GetCancel ::Calling Actual plugins functions (saaSimadaptation.dll)"); + iSaaSimAdaptationDll->GetCancel(); + } } /** - The reference implementation completes with KErrNotSupported since there is no SIM support on HRP/Techview. + The reference implementation completes with KErrNotSupported. This is required for automated testing. + Actual plugins return expected values and this can be verified by manual testing On a device, Sim Adaptation Plug-in would complete 'aTypePckg' with one of the event types in TSsmSimEventType. @@ -94,8 +125,23 @@ */ void CSimAdaptationRef::NotifySimEvent(TDes8& /*aTypePckg*/, TRequestStatus& aStatus) { - aStatus = KRequestPending; - iTimer->After(2000000,aStatus); + if(!IsTestPsKeyDefined()) + { + DEBUGPRINT1A("NotifySimEvent :: Calling Actual plugins functions (saaSimadaptation.dll)"); + /* Only clayersup.dll has an outstanding request. If this is passed to the actual plugin, the + request will never complete till a SIM event happens. This would add the test code requests in a queue + and the test code waits indefinitely. Hence, complete the request with KErrCancel. This would free the + queue for test code to be executed. It has not impact on the test environment */ + TRequestStatus *request = &aStatus; + User::RequestComplete(request, KErrCancel); + } + else + { + DEBUGPRINT1A("NotifySimEvent :: Calling ref plugins functions (Simadaptationref.dll)"); + aStatus = KRequestPending; + iTimer->After(2000000,aStatus); + } + } /** @@ -104,12 +150,36 @@ */ void CSimAdaptationRef::NotifyCancel() { - if(iTimer->IsActive()) - { - iTimer->Cancel(); - } + if(!IsTestPsKeyDefined()) + { + DEBUGPRINT1A("NotifyCancel :: Calling Actual plugins functions (saaSimadaptation.dll)"); + iSaaSimAdaptationDll->NotifyCancel(); + } + else + { + DEBUGPRINT1A("NotifyCancel :: Calling ref plugins functions (Simadaptationref.dll)"); + if(iTimer->IsActive()) + { + iTimer->Cancel(); + } + } } +/** + Helper function to check for P&S Key +*/ +TBool CSimAdaptationRef::IsTestPsKeyDefined() + { + TBool testPsKeyDefined = EFalse; + TInt result = RProperty::Get(KPropertyCategory, KSimPluginPropertyKey, testPsKeyDefined); + DEBUGPRINT3(_L("KSimPluginPropertyKey %d Error %d"), testPsKeyDefined, result); + if ((KErrNone != result) && (KErrNotFound != result)) + { + //Could not retrieve property value. Tests might fail + DEBUGPRINT1A("IsTestPsKeyDefined ERROR :: Could not retrieve property value)"); + } + return testPsKeyDefined; + } CSimRefAdaptationTimer::CSimRefAdaptationTimer():CTimer(CActive::EPriorityUserInput)