os/security/cryptomgmtlibs/securitytestfw/test/testutil/server/testutilfilewatcher.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptomgmtlibs/securitytestfw/test/testutil/server/testutilfilewatcher.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,84 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* TestUtil - filewatcher implementation
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +/**
    1.24 + @file 
    1.25 + @test
    1.26 + @internalComponent
    1.27 +*/
    1.28 +
    1.29 +#include "testutilfilewatcher.h"
    1.30 +
    1.31 +// CFileWatcher
    1.32 +
    1.33 +/*static*/ CFileWatcher* CFileWatcher::NewL(RFs& aFs, const RMessagePtr2& aMessage)
    1.34 +	{
    1.35 +	CFileWatcher* self=NewLC(aFs, aMessage);
    1.36 +	CleanupStack::Pop(self);
    1.37 +	return self;
    1.38 +	}
    1.39 +	
    1.40 +/*static*/ CFileWatcher* CFileWatcher::NewLC(RFs& aFs, const RMessagePtr2& aMessage)
    1.41 +	{
    1.42 +	CFileWatcher* self=new(ELeave) CFileWatcher(aFs, aMessage);
    1.43 +	CleanupStack::PushL(self);
    1.44 +	self->ConstructL();
    1.45 +	return self;	
    1.46 +	}
    1.47 +	
    1.48 +CFileWatcher::~CFileWatcher()
    1.49 +	{
    1.50 +	Cancel();
    1.51 +	}
    1.52 +
    1.53 +CFileWatcher::CFileWatcher(RFs& aFs, const RMessagePtr2& aMessage)
    1.54 +	: CActive(EPriorityHigh), iFs(aFs), iMessage(aMessage)
    1.55 +	{
    1.56 +	CActiveScheduler::Add(this);
    1.57 +	}
    1.58 +
    1.59 +void CFileWatcher::ConstructL()
    1.60 +	{
    1.61 +	TInt srcLen = iMessage.GetDesLength(0);
    1.62 +	HBufC* fileName=HBufC::NewLC(srcLen);
    1.63 +	TPtr ptr(fileName->Des());
    1.64 +	TRAPD(err, iMessage.ReadL(0, ptr));
    1.65 +	if (err!=KErrNone)
    1.66 +		{
    1.67 +		iMessage.Complete(KErrBadDescriptor);
    1.68 +		}
    1.69 +	else
    1.70 +		{
    1.71 +		iFs.NotifyChange(ENotifyFile, iStatus, *fileName);
    1.72 +		SetActive();	
    1.73 +		}
    1.74 +	CleanupStack::PopAndDestroy(fileName);
    1.75 +	}
    1.76 +
    1.77 +void CFileWatcher::DoCancel()
    1.78 +	{
    1.79 +	iFs.NotifyChangeCancel(iStatus);
    1.80 +	iMessage.Complete(KErrCancel);
    1.81 +	}
    1.82 +
    1.83 +void CFileWatcher::RunL()
    1.84 +	{
    1.85 +	iMessage.Complete(iStatus.Int());
    1.86 +	}
    1.87 +