searcher/tsrc/cpixsearchertest/src/aotestclass.cpp
changeset 0 671dee74050a
equal deleted inserted replaced
-1:000000000000 0:671dee74050a
       
     1 /*
       
     2 * Copyright (c) 2010 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include "AOTestClass.h"
       
    19 
       
    20 CAOTestClass::CAOTestClass(MAOTestObserver* aObserver) :
       
    21 	CActive(EPriorityStandard) // Standard priority
       
    22 	{
       
    23 	iObserver = aObserver;
       
    24 	}
       
    25 
       
    26 CAOTestClass* CAOTestClass::NewLC(MAOTestObserver* aObserver)
       
    27 	{
       
    28 	CAOTestClass* self = new (ELeave) CAOTestClass(aObserver);
       
    29 	CleanupStack::PushL(self);
       
    30 	self->ConstructL();
       
    31 	return self;
       
    32 	}
       
    33 
       
    34 CAOTestClass* CAOTestClass::NewL(MAOTestObserver* aObserver)
       
    35 	{
       
    36 	CAOTestClass* self = CAOTestClass::NewLC(aObserver);
       
    37 	CleanupStack::Pop(); // self;
       
    38 	return self;
       
    39 	}
       
    40 
       
    41 void CAOTestClass::ConstructL()
       
    42 	{
       
    43 	User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
       
    44 	CActiveScheduler::Add(this); // Add to scheduler
       
    45 	}
       
    46 
       
    47 CAOTestClass::~CAOTestClass()
       
    48 	{
       
    49 	Cancel(); // Cancel any request, if outstanding
       
    50 	iTimer.Close(); // Destroy the RTimer object
       
    51 	// Delete instance variables if any
       
    52 	}
       
    53 
       
    54 void CAOTestClass::DoCancel()
       
    55 	{
       
    56 	iTimer.Cancel();
       
    57 	}
       
    58 
       
    59 void CAOTestClass::StartL(TTimeIntervalMicroSeconds32 aDelay)
       
    60 	{
       
    61 	Cancel(); // Cancel any request, just to be sure
       
    62 	iState = EUninitialized;
       
    63 	iTimer.After(iStatus, aDelay); // Set for later
       
    64 	SetActive(); // Tell scheduler a request is active
       
    65 	}
       
    66 
       
    67 void CAOTestClass::RunL()
       
    68 	{
       
    69 	if (iState == EUninitialized)
       
    70 		{
       
    71 		// Do something the first time RunL() is called
       
    72 		iState = EInitialized;
       
    73 		}
       
    74 	else if (iState != EError)
       
    75 		{
       
    76 		// Do something
       
    77 		}
       
    78 	iObserver->CallCompleted( 2 );
       
    79 	}
       
    80 
       
    81 TInt CAOTestClass::RunError(TInt aError)
       
    82 	{
       
    83 	return aError;
       
    84 	}