sysstatemgmt/systemstateplugins/adptplugin/src/rtcadaptationref.cpp
changeset 0 4e1aa6a622a0
child 21 ccb4f6b3db21
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "rtcadaptationref.h"
       
    17 
       
    18 #include <e32property.h>
       
    19 
       
    20 const TUid KAlarmServerUID = {0x101f5027};
       
    21 const TInt KTestRTCValueKey = 200;
       
    22 
       
    23 /**
       
    24 Function to create new Rtc Adaptation Plugin.
       
    25 
       
    26 @return	a new instance of MRtcAdaptation for RTC (Real Time Clock) Adaptations.
       
    27 */
       
    28 EXPORT_C MRtcAdaptation* CreateRtcAdaptationRefL()
       
    29 	{
       
    30 	CRtcAdaptationRef* rtcAdaptationRef = CRtcAdaptationRef::NewL();
       
    31 	return (static_cast<MRtcAdaptation*>(rtcAdaptationRef));
       
    32 	}
       
    33 
       
    34 CRtcAdaptationRef* CRtcAdaptationRef::NewL()
       
    35 	{
       
    36 	CRtcAdaptationRef* self = new(ELeave) CRtcAdaptationRef;
       
    37 	return self;	
       
    38 	}
       
    39 
       
    40 CRtcAdaptationRef::~CRtcAdaptationRef()
       
    41 	{
       
    42 	}
       
    43 
       
    44 CRtcAdaptationRef::CRtcAdaptationRef()
       
    45 	{
       
    46 	}
       
    47 
       
    48 /**
       
    49  Deletes and frees memory allocated.
       
    50 */
       
    51 void CRtcAdaptationRef::Release()
       
    52 	{
       
    53 	delete this;
       
    54 	}
       
    55 
       
    56 /**
       
    57  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.
       
    59 
       
    60  @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
       
    62 
       
    63  @see TRequestStatus
       
    64 */
       
    65 void CRtcAdaptationRef::ValidateRtc(TDes8& /*aValidityPckg*/, TRequestStatus& aStatus)
       
    66 	{
       
    67 	aStatus = KRequestPending;
       
    68 	TRequestStatus* status = &aStatus;
       
    69 	User::RequestComplete(status, KErrNotSupported);
       
    70 	}
       
    71 
       
    72 /**
       
    73  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.
       
    75  For testing purposes it sets a pub sub property defined in test code.
       
    76 
       
    77  @param aAlarmTimePckg requested wake up time
       
    78  @param aStatus to complete when the operation has finished
       
    79 
       
    80  @see TRequestStatus
       
    81 */
       
    82 void CRtcAdaptationRef::SetWakeupAlarm(TDesC8& aAlarmTimePckg, TRequestStatus& aStatus)
       
    83 	{
       
    84 	// Set this pub sub property (for testing purposes)
       
    85 	// The property is defined in the test code.  In normal operation this will fail silently because the property has not been defined.
       
    86 	RProperty::Set(KAlarmServerUID, KTestRTCValueKey, aAlarmTimePckg);
       
    87 
       
    88 	aStatus = KRequestPending;
       
    89 	TRequestStatus* status = &aStatus;
       
    90 	// No support for RTC on HRP/Techview.
       
    91 	User::RequestComplete(status, KErrNotSupported);
       
    92 	}
       
    93 
       
    94 /**
       
    95  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.
       
    97  For testing purposes it sets a pub sub property to a NULL value defined in test code.
       
    98 
       
    99  @param aStatus to complete when the operation has finished
       
   100 
       
   101  @see TRequestStatus
       
   102 */
       
   103 void CRtcAdaptationRef::UnsetWakeupAlarm(TRequestStatus& aStatus)
       
   104 	{
       
   105 	// Set this pub sub property to a NULL value because we are unsetting the RTC (for testing purposes)
       
   106 	// The property is defined in the test code. In normal operation this will fail silently because the property has not been defined.
       
   107 	TTime nullTime(Time::NullTTime());
       
   108 	TPckgC<TTime> wakeupAlarmTimePckg(nullTime);
       
   109 	RProperty::Set(KAlarmServerUID, KTestRTCValueKey, wakeupAlarmTimePckg);
       
   110 
       
   111 	aStatus = KRequestPending;
       
   112 	TRequestStatus* status = &aStatus;
       
   113 	// No support for RTC on HRP/Techview.
       
   114 	User::RequestComplete(status, KErrNotSupported);
       
   115 	}
       
   116 
       
   117 /**
       
   118   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.
       
   120 */
       
   121 void CRtcAdaptationRef::Cancel()
       
   122 	{
       
   123 	}