diff -r 000000000000 -r 8e480a14352b messagingfw/watcherfw/test/src/testwatcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messagingfw/watcherfw/test/src/testwatcher.cpp Mon Jan 18 20:36:02 2010 +0200 @@ -0,0 +1,95 @@ +// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include +#include "testwatcher.h" + +#define KTestDelay 5000000 +_LIT(KTestFile, "c:\\ECOMTESTWATCHER"); + +//********************************** +// Globals +//********************************** + + +//********************************** +// CTestWatcher +//********************************** + +// static + +#include + +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x10008D9D, CTestWatcher::NewL) + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + +CTestWatcher* CTestWatcher::NewL(TAny* aWatcherParams) + { + TWatcherParams* params = reinterpret_cast(aWatcherParams); + CTestWatcher* self = new (ELeave) CTestWatcher(EPriorityStandard, params->iFs, params->iLog); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +CTestWatcher::CTestWatcher(TInt aPriority, RFs& aFs, CWatcherLog& aLog) +: CTimer(aPriority), iLog(aLog), iFs(aFs) + { + CActiveScheduler::Add(this); + } + +CTestWatcher::~CTestWatcher() + { + Cancel(); + } + +void CTestWatcher::ConstructL() + { + TRAPD(err, CTimer::ConstructL(); After(KTestDelay)); + RDebug::Print(_L("Constructed test watcher with error %d"), err); + User::LeaveIfError(err); + } + +void CTestWatcher::RunL() + { + iLog.Printf(_L("EcomTestWatcher: Creating test file")); + + RFile file; + TInt err = file.Replace(iFs, KTestFile, EFileShareExclusive); + + if (err) + err = file.Create(iFs, KTestFile, EFileShareExclusive); + + if (!err) + { + file.Write(_L8("Hello\n")); + file.Flush(); + file.Close(); + } + + After(KTestDelay); + } +