os/security/cryptomgmtlibs/securitytestfw/test/testutil/server/testutilsession.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2004-2009 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 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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * testutil - server classes
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file 
    22  @test
    23  @internalComponent
    24 */
    25 
    26 #include <e32base.h>
    27 #include "testutilfilewatcher.h"
    28 
    29 class CTestUtilServer;
    30 
    31 class MTimeoutClient
    32 	{
    33 public:
    34 	/** Client's implementation gets called on timer expiry */
    35 	virtual void HandleTimeout() = 0;
    36 	};
    37 
    38 /** Simple timer class which calls a callback on timer expiry */
    39 class CGenericTimer : public CTimer
    40 	{
    41 public:
    42 	static CGenericTimer* NewL(MTimeoutClient& aClient);
    43 private:
    44 	CGenericTimer(MTimeoutClient& aClient);
    45 	void RunL();
    46 private:
    47 	MTimeoutClient& iClient;
    48 	};
    49 
    50 class CTestFileDetector : public CActive, public MTimeoutClient
    51 	{
    52 public:
    53 	static CTestFileDetector* NewL(const RMessage2& iMessage, RFs& aFs);
    54 	CTestFileDetector(const RMessage2& iMessage, RFs& aFs);
    55 	~CTestFileDetector();
    56 	void DetectFile();
    57 private:
    58 	void ConstructL();
    59 	virtual void HandleTimeout();
    60 	void RunL();
    61 	void DoCancel();
    62 	void CheckAndComplete();
    63 private:
    64 	RFs& iFs;
    65 	CGenericTimer* iTimer;
    66 	HBufC* iFileName;
    67 	TInt iTimeInterval;
    68 	const RMessage2& iMessage;
    69 	};
    70 
    71 class CTestUtilSession : public CSession2
    72 	{
    73 public:
    74 	CTestUtilSession();
    75 	void CreateL();
    76 private:
    77 	~CTestUtilSession();
    78 	inline CTestUtilServer& Server();
    79 	void ServiceL(const RMessage2& aMessage);
    80 	void ServiceError(const RMessage2& aMessage,TInt aError);
    81 private:
    82 	RArray<RFile> iLockedFileHandles;
    83 	CFileWatcher* iFileWatcher;
    84 	CTestFileDetector* iDetector;
    85 	};
    86 
    87 
    88 inline CTestUtilServer& CTestUtilSession::Server()
    89 	{return *static_cast<CTestUtilServer*>(const_cast<CServer2*>(CSession2::Server()));}