commonappservices/alarmservertest/TestMultipleAlarmsSuite/src/AlarmActionPerformer.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2005-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 // Contains implementation of CAlarmActionPerformer class
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology 
       
    21 */
       
    22 
       
    23 // User Include
       
    24 #include "AlarmActionPerformer.h"
       
    25 
       
    26 // System Include
       
    27 #include <uikon/eikalsup.h>
       
    28 
       
    29 /**
       
    30 Constructor. 
       
    31 Adds itself to the active scheduler
       
    32 @internalTechnology
       
    33 @test
       
    34 */
       
    35 CAlarmActionPerformer::CAlarmActionPerformer() : CActive(EPriorityStandard)
       
    36 	{
       
    37 	CActiveScheduler::Add(this);
       
    38 	}
       
    39 
       
    40 /**
       
    41 From CActive. Performs the action and completes the test step thread
       
    42 @internalTechnology
       
    43 @test
       
    44 */
       
    45 void CAlarmActionPerformer::RunL()	
       
    46 	{
       
    47 	TInt error = KErrNone;
       
    48 	switch(iAlarmAction)
       
    49 		{
       
    50 		case TestMultipleAlarms::ESnooze:
       
    51 			{
       
    52 			TRAP(error, iAlarmControl->Supervisor()->CmdTaskAwayFromAlarmL(iMinsToSnooze));
       
    53 			break;
       
    54 			}
       
    55 		case TestMultipleAlarms::EClear:
       
    56 			{
       
    57 			iAlarmControl->Supervisor()->CmdAcknowledgeAlarm();
       
    58 			break;
       
    59 			}
       
    60 		case TestMultipleAlarms::EStopActiveScheduler:
       
    61 			{
       
    62 			CActiveScheduler::Stop();
       
    63 			break;
       
    64 			}
       
    65 		default:
       
    66 			error = KErrNotSupported;
       
    67 			break;
       
    68 		}
       
    69 	iTestStepThreadDuplicateHandle.RequestComplete(iExternalRequest, error);
       
    70 	iTestStepThreadDuplicateHandle.Close();
       
    71 	}
       
    72 
       
    73 /**
       
    74 From CActive. Completes the test step thread with KErrCancel
       
    75 @internalTechnology
       
    76 @test
       
    77 */
       
    78 void CAlarmActionPerformer::DoCancel()
       
    79 	{
       
    80 	if(iTestStepThreadDuplicateHandle.Handle() != KNullHandle)
       
    81 		{
       
    82 		iTestStepThreadDuplicateHandle.RequestComplete(iExternalRequest, KErrCancel);
       
    83 		iTestStepThreadDuplicateHandle.Close();
       
    84 		}
       
    85 	}	
       
    86 	
       
    87 /**
       
    88 Sets up the Alarm Action Performer to perform an action
       
    89 @param aAlarmControl The alarm control object which we have to snooze/clear
       
    90 @param aStatus Pointer to the request status which we will complete once we 
       
    91 are done
       
    92 @param aTestStepThreadDuplicateHandle A duplicate handle to the test step thread
       
    93 @param aAlarmAction The action to be performed, i.e, snooze/clear
       
    94 @internalTechnology
       
    95 @test
       
    96 */
       
    97 void CAlarmActionPerformer::SetCommonParams(CDummyAlarmControl* aAlarmControl, TRequestStatus* aStatus, RThread& aTestStepThreadDuplicateHandle, const TestMultipleAlarms::TAlarmAction& aAlarmAction)
       
    98 	{
       
    99 	iStatus = KRequestPending;
       
   100 	SetActive(); 
       
   101 	iExternalRequest = aStatus;
       
   102 	iAlarmControl = aAlarmControl;
       
   103 	iTestStepThreadDuplicateHandle = aTestStepThreadDuplicateHandle;
       
   104 	iAlarmAction = aAlarmAction;
       
   105 	}
       
   106 	
       
   107 /**
       
   108 Sets the number of minutes to snooze the alarm
       
   109 @param aMinsToSnooze The number of minutes to snooze the alarm
       
   110 @internalTechnology
       
   111 @test
       
   112 */
       
   113 void CAlarmActionPerformer::SetMinsToSnooze(const TInt& aMinsToSnooze)
       
   114 	{
       
   115 	iMinsToSnooze = aMinsToSnooze;
       
   116 	}
       
   117 	
       
   118 /**
       
   119 Returns a pointer to the request status object of this AO
       
   120 @return A pointer to the request status object of this AO
       
   121 @internalTechnology
       
   122 @test
       
   123 */
       
   124 TRequestStatus* CAlarmActionPerformer::Status()	
       
   125 	{
       
   126 	return &iStatus;
       
   127 	}
       
   128