multimediacommsengine/tsrc/MMCTestDriver/MCETester/src/CDelayedProcess.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    Implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "CDelayedProcess.h"
       
    22 #include <MceMediaStream.h>
       
    23 #include <MceMediaSource.h>
       
    24 #include <e32debug.h>
       
    25 
       
    26 /**
       
    27  * Standard Symbian OS static function for creating an instance of the object.
       
    28  * If creation fails, a leave will be sent.
       
    29  * @param aDtmfSource pointer to the CMceMediaSource containing the dtmf source.
       
    30  */
       
    31 CDelayedProcess* CDelayedProcess::NewL(CMceMediaSource* aDtmfSource)
       
    32 {
       
    33 	CDelayedProcess* self = new (ELeave) CDelayedProcess(aDtmfSource);
       
    34 	CleanupStack::PushL(self);
       
    35 	self->ConstructL();
       
    36 	CleanupStack::Pop(self);
       
    37 	return self;
       
    38 }
       
    39 
       
    40 CDelayedProcess::CDelayedProcess(CMceMediaSource* aDtmfSource)
       
    41 : CActive(CActive::EPriorityStandard),
       
    42 iDtmfSrc(aDtmfSource)
       
    43 {
       
    44 	// Call base constructor of CActive with the standard priority
       
    45 	// Add this active object instance to the Active Scheduler:
       
    46 	CActiveScheduler::Add(this);
       
    47 }
       
    48 
       
    49 void CDelayedProcess::ConstructL()
       
    50 {
       
    51 	// Create a thread-relative timer.
       
    52 	User::LeaveIfError(iTimer.CreateLocal());
       
    53 }
       
    54 
       
    55 CDelayedProcess::~CDelayedProcess()
       
    56 {
       
    57 	// Call cancel-function of CActive base class, which will call DoCancel()
       
    58 	Cancel();
       
    59 	// Close the handle to the timer.
       
    60 	iTimer.Close();
       
    61 }
       
    62 
       
    63 /**
       
    64  * Request from the application to start an asynchronous process.
       
    65  * @param aDelay delay until the asynch. timer event occurs, in microseconds.
       
    66  */
       
    67 void CDelayedProcess::StartProcess(TTimeIntervalMicroSeconds32 aDelay)
       
    68 {
       
    69 	// Make sure that the active object is currently inactive
       
    70 	_LIT(KDelayedProcessPanic, "CDelayedProcess");
       
    71 	__ASSERT_ALWAYS(!IsActive(), User::Panic(KDelayedProcessPanic, KErrInUse));
       
    72 
       
    73 
       
    74 	iTimer.After(iStatus, aDelay);
       
    75 
       
    76 	// Indicates that the active object has issued a request and that it is now outstanding.
       
    77 	SetActive();
       
    78 }
       
    79 
       
    80 /**
       
    81  * Handles an active object’s request completion event.
       
    82  */
       
    83 void CDelayedProcess::RunL()
       
    84 {
       
    85 	
       
    86 	_LIT(KTimerExpired, "Timer Expired\n");
       
    87 	RDebug::Print(KTimerExpired);
       
    88 
       
    89 	// Stop sending the tone
       
    90 	if( iDtmfSrc->DtmfActive() )
       
    91 	{
       
    92 		iDtmfSrc->StopDtmfToneL();	
       
    93 		
       
    94 	}
       
    95 	
       
    96 	TRequestStatus* status = &iStatus;
       
    97 	// Generates event on itself
       
    98 //	User::RequestComplete(status, KErrNone);
       
    99 	
       
   100 }
       
   101 
       
   102 /**
       
   103  * Implements cancellation of an outstanding request.
       
   104  */
       
   105 void CDelayedProcess::DoCancel()
       
   106 {
       
   107 	iTimer.Cancel();
       
   108 }