sysstatemgmt/systemstateplugins/adptplugin/src/simadaptationref.cpp
changeset 45 c6215323ad55
parent 0 4e1aa6a622a0
child 61 8cb079868133
equal deleted inserted replaced
44:2c28af138640 45:c6215323ad55
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2008-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".
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description: This adaptation plugin implementation is for test/reference purposes.   
       
    14 // The loading of this plugin is controlled through test macro defined in the iby file "ssmcompatibility.iby".
       
    15 // If the macro "TEST_SSM_MACRO" is not defined, original plugins are loaded and this plugin is not loaded.
       
    16 // If the test P & S key is set in the test code, the calls are routed to the reference or dummy implementations.
       
    17 // Else the actual plugins are loaded and the calls are routed to the actual implementations.
       
    18 // The test P & S key which it looks for is KSimPluginPropertyKey (0x2000D76A)
    14 //
    19 //
    15 
    20 
    16 #include "simadaptationref.h"
    21 #include "simadaptationref.h"
       
    22 #include "ssmdebug.h"
       
    23 #include <e32property.h> 
       
    24 
       
    25 const TUint32 KSimPluginPropertyKey = 0x2000D76B;
       
    26 const TUid KPropertyCategory={0x2000D75B};
    17 
    27 
    18 /**
    28 /**
    19 Function to create new Sim Adaptation Plugin.
    29 Function to create new Sim Adaptation Plugin.
    20 
    30 
    21 @return	a new plugin object for Sim Adaptations.
    31 @return	a new plugin object for Sim Adaptations.
    38 	}
    48 	}
    39 
    49 
    40 CSimAdaptationRef::~CSimAdaptationRef()
    50 CSimAdaptationRef::~CSimAdaptationRef()
    41 	{
    51 	{
    42 	delete iTimer;
    52 	delete iTimer;
       
    53 	iSaaSimAdaptationLib.Close();
    43 	}
    54 	}
    44 
    55 
    45 CSimAdaptationRef::CSimAdaptationRef()
    56 CSimAdaptationRef::CSimAdaptationRef()
    46 	{
    57 	{
    47 	}
    58 	}
    48 
    59 
    49 void CSimAdaptationRef::ConstructL()
    60 void CSimAdaptationRef::ConstructL()
    50 	{
    61 	{
       
    62 	DEBUGPRINT1A("Loading Actual plugins");
       
    63     _LIT(KSaaSimAdaptationDLL, "saaSimadaptation.dll");
       
    64     User::LeaveIfError(iSaaSimAdaptationLib.Load(KSaaSimAdaptationDLL));
       
    65     iSaaSimAdaptationDll = (MSimAdaptation *)(iSaaSimAdaptationLib.Lookup(1)()); 
       
    66     
    51 	iTimer = CSimRefAdaptationTimer::NewL();
    67 	iTimer = CSimRefAdaptationTimer::NewL();
    52 	}
    68 	}
    53 
    69 
    54 //from MSimAdaptation
    70 //from MSimAdaptation
    55 void CSimAdaptationRef::Release()
    71 void CSimAdaptationRef::Release()
    56 	{
    72 	{
    57 	delete this;
    73 	delete this;
    58 	}
    74 	}
    59 
    75 
    60 void CSimAdaptationRef::GetSimOwned(TDes8& /*aOwnedPckg*/, TRequestStatus& aStatus)
    76 void CSimAdaptationRef::GetSimOwned(TDes8& aOwnedPckg, TRequestStatus& aStatus)
    61 	{
    77 	{
    62 	aStatus = KRequestPending;
    78 	if(!IsTestPsKeyDefined())
    63 	TRequestStatus* pStatus = &aStatus;
    79         {
    64 	User::RequestComplete(pStatus, KErrNone);
    80         DEBUGPRINT1A("GetSimOwned:: Calling Actual plugins functions (saaSimadaptation.dll)");
       
    81         iSaaSimAdaptationDll->GetSimOwned(aOwnedPckg,aStatus);
       
    82         }
       
    83     else
       
    84         {
       
    85         DEBUGPRINT1A("GetSimOwned :: Calling ref plugins functions (Simadaptationref.dll)");
       
    86         aStatus = KRequestPending;
       
    87         TRequestStatus* pStatus = &aStatus;
       
    88         User::RequestComplete(pStatus, KErrNone);      
       
    89         }	
    65 	}
    90 	}
    66 
    91 
    67 /**
    92 /**
    68   Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel.
    93   Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel.
    69   On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled.
    94   On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled.
    70 */
    95 */
    71 void CSimAdaptationRef::GetCancel()
    96 void CSimAdaptationRef::GetCancel()
    72 	{
    97 	{
    73 	}
    98 	if(!IsTestPsKeyDefined())
    74 
    99         {
    75 /**
   100         DEBUGPRINT1A("GetCancel ::Calling Actual plugins functions (saaSimadaptation.dll)");
    76   The reference implementation completes with KErrNotSupported since there is no SIM support on HRP/Techview.
   101         iSaaSimAdaptationDll->GetCancel();
       
   102         }
       
   103 	}
       
   104 
       
   105 /**
       
   106   The reference implementation completes with KErrNotSupported. This is required for automated testing.
       
   107   Actual plugins return expected values and this can be verified by manual testing
    77   On a device, Sim Adaptation Plug-in would complete 'aTypePckg' with one of the event types in TSsmSimEventType.
   108   On a device, Sim Adaptation Plug-in would complete 'aTypePckg' with one of the event types in TSsmSimEventType.
    78   
   109   
    79   
   110   
    80   The above mentioned implementation is modified to facilitate testing and increase the code coverage of the Adaptation 
   111   The above mentioned implementation is modified to facilitate testing and increase the code coverage of the Adaptation 
    81   server code.The modified functionality is as follows.
   112   server code.The modified functionality is as follows.
    92   
   123   
    93   
   124   
    94 */
   125 */
    95 void CSimAdaptationRef::NotifySimEvent(TDes8& /*aTypePckg*/, TRequestStatus& aStatus)
   126 void CSimAdaptationRef::NotifySimEvent(TDes8& /*aTypePckg*/, TRequestStatus& aStatus)
    96 	{
   127 	{
    97 	aStatus = KRequestPending;
   128 	if(!IsTestPsKeyDefined())
    98 	iTimer->After(2000000,aStatus);
   129         {
       
   130         DEBUGPRINT1A("NotifySimEvent :: Calling Actual plugins functions (saaSimadaptation.dll)");
       
   131         /* Only clayersup.dll has an outstanding request. If this is passed to the actual plugin, the
       
   132         request will never complete till a SIM event happens. This would add the test code requests in a queue
       
   133         and the test code waits indefinitely. Hence, complete the request with KErrCancel. This would free the 
       
   134         queue for test code to be executed. It has not impact on the test environment */
       
   135         TRequestStatus *request = &aStatus; 
       
   136         User::RequestComplete(request, KErrCancel);
       
   137         }
       
   138     else
       
   139         {
       
   140         DEBUGPRINT1A("NotifySimEvent :: Calling ref plugins functions (Simadaptationref.dll)");
       
   141         aStatus = KRequestPending;
       
   142         iTimer->After(2000000,aStatus);      
       
   143         }   
       
   144 
    99 	}
   145 	}
   100 
   146 
   101 /**
   147 /**
   102   Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel.
   148   Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel.
   103   On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled.
   149   On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled.
   104 */
   150 */
   105 void CSimAdaptationRef::NotifyCancel()
   151 void CSimAdaptationRef::NotifyCancel()
   106 	{
   152 	{
   107 	if(iTimer->IsActive())
   153 	if(!IsTestPsKeyDefined())
   108 		{
   154         {
   109 		iTimer->Cancel();			
   155         DEBUGPRINT1A("NotifyCancel :: Calling Actual plugins functions (saaSimadaptation.dll)");
   110 		}
   156         iSaaSimAdaptationDll->NotifyCancel();
   111 	}
   157         }
   112 
   158     else
       
   159         {
       
   160         DEBUGPRINT1A("NotifyCancel :: Calling ref plugins functions (Simadaptationref.dll)");
       
   161         if(iTimer->IsActive())
       
   162             {
       
   163             iTimer->Cancel();           
       
   164             }     
       
   165         }	
       
   166 	}
       
   167 
       
   168 /**
       
   169     Helper function to check for P&S Key
       
   170 */
       
   171 TBool CSimAdaptationRef::IsTestPsKeyDefined()
       
   172     {
       
   173     TBool testPsKeyDefined = EFalse;
       
   174     TInt result = RProperty::Get(KPropertyCategory, KSimPluginPropertyKey, testPsKeyDefined);
       
   175     DEBUGPRINT3(_L("KSimPluginPropertyKey %d Error %d"), testPsKeyDefined, result);
       
   176     if ((KErrNone != result) && (KErrNotFound != result))
       
   177         {
       
   178         //Could not retrieve property value. Tests might fail 
       
   179         DEBUGPRINT1A("IsTestPsKeyDefined ERROR :: Could not retrieve property value)");
       
   180         }
       
   181     return testPsKeyDefined;
       
   182     }
   113 
   183 
   114 
   184 
   115 CSimRefAdaptationTimer::CSimRefAdaptationTimer():CTimer(CActive::EPriorityUserInput)
   185 CSimRefAdaptationTimer::CSimRefAdaptationTimer():CTimer(CActive::EPriorityUserInput)
   116 	{
   186 	{
   117    	CActiveScheduler::Add(this);
   187    	CActiveScheduler::Add(this);