1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptomgmtlibs/securitytestfw/test/testutil/server/testutilsession.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,89 @@
1.4 +/*
1.5 +* Copyright (c) 2004-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 - server classes
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 <e32base.h>
1.30 +#include "testutilfilewatcher.h"
1.31 +
1.32 +class CTestUtilServer;
1.33 +
1.34 +class MTimeoutClient
1.35 + {
1.36 +public:
1.37 + /** Client's implementation gets called on timer expiry */
1.38 + virtual void HandleTimeout() = 0;
1.39 + };
1.40 +
1.41 +/** Simple timer class which calls a callback on timer expiry */
1.42 +class CGenericTimer : public CTimer
1.43 + {
1.44 +public:
1.45 + static CGenericTimer* NewL(MTimeoutClient& aClient);
1.46 +private:
1.47 + CGenericTimer(MTimeoutClient& aClient);
1.48 + void RunL();
1.49 +private:
1.50 + MTimeoutClient& iClient;
1.51 + };
1.52 +
1.53 +class CTestFileDetector : public CActive, public MTimeoutClient
1.54 + {
1.55 +public:
1.56 + static CTestFileDetector* NewL(const RMessage2& iMessage, RFs& aFs);
1.57 + CTestFileDetector(const RMessage2& iMessage, RFs& aFs);
1.58 + ~CTestFileDetector();
1.59 + void DetectFile();
1.60 +private:
1.61 + void ConstructL();
1.62 + virtual void HandleTimeout();
1.63 + void RunL();
1.64 + void DoCancel();
1.65 + void CheckAndComplete();
1.66 +private:
1.67 + RFs& iFs;
1.68 + CGenericTimer* iTimer;
1.69 + HBufC* iFileName;
1.70 + TInt iTimeInterval;
1.71 + const RMessage2& iMessage;
1.72 + };
1.73 +
1.74 +class CTestUtilSession : public CSession2
1.75 + {
1.76 +public:
1.77 + CTestUtilSession();
1.78 + void CreateL();
1.79 +private:
1.80 + ~CTestUtilSession();
1.81 + inline CTestUtilServer& Server();
1.82 + void ServiceL(const RMessage2& aMessage);
1.83 + void ServiceError(const RMessage2& aMessage,TInt aError);
1.84 +private:
1.85 + RArray<RFile> iLockedFileHandles;
1.86 + CFileWatcher* iFileWatcher;
1.87 + CTestFileDetector* iDetector;
1.88 + };
1.89 +
1.90 +
1.91 +inline CTestUtilServer& CTestUtilSession::Server()
1.92 + {return *static_cast<CTestUtilServer*>(const_cast<CServer2*>(CSession2::Server()));}