os/security/cryptomgmtlibs/securitytestfw/test/testutil/server/testutilfilewatcher.cpp
Update contrib.
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * TestUtil - filewatcher implementation
26 #include "testutilfilewatcher.h"
30 /*static*/ CFileWatcher* CFileWatcher::NewL(RFs& aFs, const RMessagePtr2& aMessage)
32 CFileWatcher* self=NewLC(aFs, aMessage);
33 CleanupStack::Pop(self);
37 /*static*/ CFileWatcher* CFileWatcher::NewLC(RFs& aFs, const RMessagePtr2& aMessage)
39 CFileWatcher* self=new(ELeave) CFileWatcher(aFs, aMessage);
40 CleanupStack::PushL(self);
45 CFileWatcher::~CFileWatcher()
50 CFileWatcher::CFileWatcher(RFs& aFs, const RMessagePtr2& aMessage)
51 : CActive(EPriorityHigh), iFs(aFs), iMessage(aMessage)
53 CActiveScheduler::Add(this);
56 void CFileWatcher::ConstructL()
58 TInt srcLen = iMessage.GetDesLength(0);
59 HBufC* fileName=HBufC::NewLC(srcLen);
60 TPtr ptr(fileName->Des());
61 TRAPD(err, iMessage.ReadL(0, ptr));
64 iMessage.Complete(KErrBadDescriptor);
68 iFs.NotifyChange(ENotifyFile, iStatus, *fileName);
71 CleanupStack::PopAndDestroy(fileName);
74 void CFileWatcher::DoCancel()
76 iFs.NotifyChangeCancel(iStatus);
77 iMessage.Complete(KErrCancel);
80 void CFileWatcher::RunL()
82 iMessage.Complete(iStatus.Int());