sysstatemgmt/systemstateplugins/adptplugin/src/rtcadaptationref.cpp
branchRCL_3
changeset 21 ccb4f6b3db21
parent 0 4e1aa6a622a0
child 22 8cb079868133
equal deleted inserted replaced
20:1ddbe54d0645 21:ccb4f6b3db21
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-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 KRtcAdaptationPluginPropertyKey (0x2000D76A)
    14 //
    19 //
    15 
    20 
    16 #include "rtcadaptationref.h"
    21 #include "rtcadaptationref.h"
    17 
    22 
    18 #include <e32property.h>
    23 #include <e32property.h>
       
    24 #include "ssmdebug.h"
    19 
    25 
    20 const TUid KAlarmServerUID = {0x101f5027};
    26 const TUid KAlarmServerUID = {0x101f5027};
    21 const TInt KTestRTCValueKey = 200;
    27 const TInt KTestRTCValueKey = 200;
    22 
    28 
       
    29 
       
    30 const TUint32 KRtcAdaptationPluginPropertyKey = 0x2000D76C;
       
    31 const TUid KPropertyCategory={0x2000D75B};
       
    32 
    23 /**
    33 /**
    24 Function to create new Rtc Adaptation Plugin.
    34 Function to create new Rtc Adaptation Plugin.
    25 
    35 
    26 @return	a new instance of MRtcAdaptation for RTC (Real Time Clock) Adaptations.
    36 @return	a new instance of MRtcAdaptation for RTC (Real Time Clock) Adaptations.
    27 */
    37 */
    32 	}
    42 	}
    33 
    43 
    34 CRtcAdaptationRef* CRtcAdaptationRef::NewL()
    44 CRtcAdaptationRef* CRtcAdaptationRef::NewL()
    35 	{
    45 	{
    36 	CRtcAdaptationRef* self = new(ELeave) CRtcAdaptationRef;
    46 	CRtcAdaptationRef* self = new(ELeave) CRtcAdaptationRef;
       
    47 	
       
    48 	CleanupStack::PushL(self);
       
    49 	self->ConstructL();
       
    50 	CleanupStack::Pop();
       
    51 	
    37 	return self;	
    52 	return self;	
    38 	}
    53 	}
    39 
    54 
       
    55 void CRtcAdaptationRef::ConstructL()
       
    56     {
       
    57     DEBUGPRINT1A("Loading Actual plugins");
       
    58     _LIT(KSaaRtcAdaptationDLL, "saartcadaptation.dll");
       
    59     User::LeaveIfError(iSaaRtcAdaptationLib.Load(KSaaRtcAdaptationDLL));
       
    60     iSaaRtcAdaptationDll = (MRtcAdaptation *)(iSaaRtcAdaptationLib.Lookup(1)());    
       
    61     }
       
    62 
    40 CRtcAdaptationRef::~CRtcAdaptationRef()
    63 CRtcAdaptationRef::~CRtcAdaptationRef()
    41 	{
    64 	{
       
    65 	iSaaRtcAdaptationLib.Close();
    42 	}
    66 	}
    43 
    67 
    44 CRtcAdaptationRef::CRtcAdaptationRef()
    68 CRtcAdaptationRef::CRtcAdaptationRef()
    45 	{
    69 	{
    46 	}
    70 	}
    48 /**
    72 /**
    49  Deletes and frees memory allocated.
    73  Deletes and frees memory allocated.
    50 */
    74 */
    51 void CRtcAdaptationRef::Release()
    75 void CRtcAdaptationRef::Release()
    52 	{
    76 	{
    53 	delete this;
    77     if(!IsTestPsKeyDefined())
       
    78         {
       
    79         DEBUGPRINT1A("Release:: Calling Actual plugins functions (saartcadaptation.dll)");
       
    80         iSaaRtcAdaptationDll->Release();
       
    81         }
       
    82     delete this;
    54 	}
    83 	}
    55 
    84 
    56 /**
    85 /**
    57  Check that the RTC is valid.
    86  Check that the RTC is valid.
    58  Reference implementation completes the request with KErrNotSupported as support for RTC is not available on Techview/H4 hrp.
    87  Reference implementation completes the request with KErrNotSupported. This is required for automated testing.
    59 
    88  Actual plugins return expected values and this can be verified by manual testing
       
    89  
    60  @param aValidityPckg on return contains the status of the validity of the RTC as a boolean value
    90  @param aValidityPckg on return contains the status of the validity of the RTC as a boolean value
    61  @param aStatus to complete when the operation has finished
    91  @param aStatus to complete when the operation has finished
    62 
    92 
    63  @see TRequestStatus
    93  @see TRequestStatus
    64 */
    94 */
    65 void CRtcAdaptationRef::ValidateRtc(TDes8& /*aValidityPckg*/, TRequestStatus& aStatus)
    95 void CRtcAdaptationRef::ValidateRtc(TDes8& aValidityPckg, TRequestStatus& aStatus)
    66 	{
    96 	{
    67 	aStatus = KRequestPending;
    97     if(!IsTestPsKeyDefined())
    68 	TRequestStatus* status = &aStatus;
    98         {
    69 	User::RequestComplete(status, KErrNotSupported);
    99         DEBUGPRINT1A("ValidateRtc:: Calling Actual plugins functions (saartcadaptation.dll)");
       
   100         iSaaRtcAdaptationDll->ValidateRtc(aValidityPckg, aStatus);
       
   101         }
       
   102     else
       
   103         {
       
   104         DEBUGPRINT1A("ValidateRtc:: Calling ref plugins functions (rtcadaptationref.dll)");
       
   105         aStatus = KRequestPending;
       
   106         TRequestStatus* status = &aStatus;
       
   107         User::RequestComplete(status, KErrNotSupported);
       
   108         }
    70 	}
   109 	}
    71 
   110 
    72 /**
   111 /**
    73  Set a device wake-up alarm time, in UTC (coordinated universal time), in the RTC.
   112  Set a device wake-up alarm time, in UTC (coordinated universal time), in the RTC.
    74  Reference implementation completes the request with KErrNotSupported as support for RTC is not available on Techview/H4 hrp.
   113  Reference implementation completes the request with KErrNotSupported. This is required for automated testing.
       
   114  Actual plugins return expected values and this can be verified by manual testing
    75  For testing purposes it sets a pub sub property defined in test code.
   115  For testing purposes it sets a pub sub property defined in test code.
    76 
   116 
    77  @param aAlarmTimePckg requested wake up time
   117  @param aAlarmTimePckg requested wake up time
    78  @param aStatus to complete when the operation has finished
   118  @param aStatus to complete when the operation has finished
    79 
   119 
    80  @see TRequestStatus
   120  @see TRequestStatus
    81 */
   121 */
    82 void CRtcAdaptationRef::SetWakeupAlarm(TDesC8& aAlarmTimePckg, TRequestStatus& aStatus)
   122 void CRtcAdaptationRef::SetWakeupAlarm(TDesC8& aAlarmTimePckg, TRequestStatus& aStatus)
    83 	{
   123 	{
    84 	// Set this pub sub property (for testing purposes)
   124     if(!IsTestPsKeyDefined())
    85 	// The property is defined in the test code.  In normal operation this will fail silently because the property has not been defined.
   125         {
    86 	RProperty::Set(KAlarmServerUID, KTestRTCValueKey, aAlarmTimePckg);
   126         DEBUGPRINT1A("SetWakeupAlarm:: Calling Actual plugins functions (saartcadaptation.dll)");
    87 
   127         iSaaRtcAdaptationDll->SetWakeupAlarm(aAlarmTimePckg, aStatus);
    88 	aStatus = KRequestPending;
   128         }
    89 	TRequestStatus* status = &aStatus;
   129     else
    90 	// No support for RTC on HRP/Techview.
   130         {
    91 	User::RequestComplete(status, KErrNotSupported);
   131         DEBUGPRINT1A("SetWakeupAlarm:: Calling ref plugins functions (rtcadaptationref.dll)");
    92 	}
   132         // Set this pub sub property (for testing purposes)
       
   133         // The property is defined in the test code.  In normal operation this will fail silently because the property has not been defined.
       
   134         RProperty::Set(KAlarmServerUID, KTestRTCValueKey, aAlarmTimePckg);
       
   135         aStatus = KRequestPending;
       
   136         TRequestStatus* status = &aStatus;
       
   137         // No support for RTC on HRP/Techview.
       
   138         User::RequestComplete(status, KErrNotSupported);
       
   139         }
       
   140 	}
       
   141 
    93 
   142 
    94 /**
   143 /**
    95  Delete the current device wake-up alarm time in the RTC.
   144  Delete the current device wake-up alarm time in the RTC.
    96  Reference implementation completes the request with KErrNotSupported as support for RTC is not available on Techview/H4 hrp.
   145  Reference implementation completes the request with KErrNotSupported. This is required for automated testing.
       
   146  Actual plugins return expected values and this can be verified by manual testing
    97  For testing purposes it sets a pub sub property to a NULL value defined in test code.
   147  For testing purposes it sets a pub sub property to a NULL value defined in test code.
    98 
   148 
    99  @param aStatus to complete when the operation has finished
   149  @param aStatus to complete when the operation has finished
   100 
   150 
   101  @see TRequestStatus
   151  @see TRequestStatus
   102 */
   152 */
   103 void CRtcAdaptationRef::UnsetWakeupAlarm(TRequestStatus& aStatus)
   153 void CRtcAdaptationRef::UnsetWakeupAlarm(TRequestStatus& aStatus)
   104 	{
   154 	{
   105 	// Set this pub sub property to a NULL value because we are unsetting the RTC (for testing purposes)
   155     if(!IsTestPsKeyDefined())
   106 	// The property is defined in the test code. In normal operation this will fail silently because the property has not been defined.
   156         {
   107 	TTime nullTime(Time::NullTTime());
   157         DEBUGPRINT1A("UnsetWakeupAlarm:: Calling Actual plugins functions (saartcadaptation.dll)");
   108 	TPckgC<TTime> wakeupAlarmTimePckg(nullTime);
   158         iSaaRtcAdaptationDll->UnsetWakeupAlarm(aStatus);
   109 	RProperty::Set(KAlarmServerUID, KTestRTCValueKey, wakeupAlarmTimePckg);
   159         }
   110 
   160     else
   111 	aStatus = KRequestPending;
   161         {
   112 	TRequestStatus* status = &aStatus;
   162         DEBUGPRINT1A("UnsetWakeupAlarm:: Calling ref plugins functions (rtcadaptationref.dll)");
   113 	// No support for RTC on HRP/Techview.
   163         // Set this pub sub property to a NULL value because we are unsetting the RTC (for testing purposes)
   114 	User::RequestComplete(status, KErrNotSupported);
   164         // The property is defined in the test code. In normal operation this will fail silently because the property has not been defined.
       
   165         TTime nullTime(Time::NullTTime());
       
   166         TPckgC<TTime> wakeupAlarmTimePckg(nullTime);
       
   167         RProperty::Set(KAlarmServerUID, KTestRTCValueKey, wakeupAlarmTimePckg);
       
   168         aStatus = KRequestPending;
       
   169         TRequestStatus* status = &aStatus;
       
   170         // No support for RTC on HRP/Techview.
       
   171         User::RequestComplete(status, KErrNotSupported);
       
   172         }
   115 	}
   173 	}
   116 
   174 
   117 /**
   175 /**
   118   Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel.
   176   Cancel the outstanding request. Reference implementation completes the requests immediately so there is nothing to Cancel.
   119   On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled.
   177   On a device, Cancel() needs an implementation as the Request might be outstanding and it needs to be cancelled.
   120 */
   178 */
   121 void CRtcAdaptationRef::Cancel()
   179 void CRtcAdaptationRef::Cancel()
   122 	{
   180 	{
   123 	}
   181     if(!IsTestPsKeyDefined())
       
   182         {
       
   183         DEBUGPRINT1A("Cancel:: Calling Actual plugins functions (saartcadaptation.dll)");
       
   184         iSaaRtcAdaptationDll->Cancel();
       
   185         }
       
   186 	}
       
   187 
       
   188 /**
       
   189     Helper function to check for P&S Key
       
   190 */
       
   191 TBool CRtcAdaptationRef::IsTestPsKeyDefined()
       
   192     {
       
   193     TBool testPsKeyDefined = EFalse;
       
   194     TInt result = RProperty::Get(KPropertyCategory, KRtcAdaptationPluginPropertyKey, testPsKeyDefined);
       
   195     DEBUGPRINT3(_L("KRtcAdaptationPluginPropertyKey %d Error %d"), testPsKeyDefined, result);
       
   196     if ((KErrNone != result) && (KErrNotFound != result))
       
   197         {
       
   198         //Could not retrieve property value. Tests might fail 
       
   199         DEBUGPRINT1A("IsTestPsKeyDefined ERROR :: Could not retrieve property value)");
       
   200         }
       
   201     return testPsKeyDefined;
       
   202     }