messagingfw/watcherfw/test/src/ctestactivewatcher.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2004-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 "ctestactivewatcher.h"
       
    17 
       
    18 #include <implementationproxy.h>
       
    19 #include <watcher.h>
       
    20 
       
    21 const TInt KDelay = 10000000;
       
    22 
       
    23 const TImplementationProxy ImplementationTable[] = 
       
    24 	{
       
    25 		IMPLEMENTATION_PROXY_ENTRY(0x10008D9D,	CTestActiveWatcher::NewL)
       
    26 	};
       
    27 
       
    28 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
    29 	{
       
    30 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
    31 
       
    32 	return ImplementationTable;
       
    33 	}
       
    34 
       
    35 CTestActiveWatcher* CTestActiveWatcher::NewL(TAny* aWatcherParams)
       
    36 	{
       
    37 	CActiveWatcher::TWatcherParams* params = reinterpret_cast<CActiveWatcher::TWatcherParams*>(aWatcherParams);
       
    38 	CTestActiveWatcher* self = new (ELeave)	CTestActiveWatcher(params->iFs, params->iLog);
       
    39 	CleanupStack::PushL(self);
       
    40 	self->ConstructL();
       
    41 	CleanupStack::Pop(self);
       
    42 	return self;
       
    43 	}
       
    44 	
       
    45 CTestActiveWatcher::CTestActiveWatcher(RFs& aFs, CWatcherLog& aLog)
       
    46 : CActiveWatcher(CActive::EPriorityStandard, aFs, aLog)
       
    47 	{
       
    48 	CActiveScheduler::Add(this);
       
    49 	}
       
    50 	
       
    51 void CTestActiveWatcher::ConstructL()
       
    52 	{
       
    53 	User::LeaveIfError(iTimer.CreateLocal());
       
    54 
       
    55 	iTimer.After(iStatus, KDelay);
       
    56 	SetActive();
       
    57 	}
       
    58 	
       
    59 CTestActiveWatcher::~CTestActiveWatcher()
       
    60 	{
       
    61 	Cancel();	
       
    62 	}
       
    63 	
       
    64 void CTestActiveWatcher::RunL()
       
    65 	{
       
    66 	iLog.Printf(_L("Watcher TestWatcher starting..."));
       
    67 
       
    68 	User::Invariant();
       
    69 	}
       
    70 	
       
    71 void CTestActiveWatcher::DoCancel()
       
    72 	{
       
    73 	iTimer.Cancel();
       
    74 	}
       
    75