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