os/security/cryptomgmtlibs/securitytestfw/test/sntpclient/sntpclientengine.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/cryptomgmtlibs/securitytestfw/test/sntpclient/sntpclientengine.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,107 @@
     1.4 +#ifndef __SNTPCLIENTENGINE_H__
     1.5 +#define __SNTPCLIENTENGINE_H__/*
     1.6 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.7 +* All rights reserved.
     1.8 +* This component and the accompanying materials are made available
     1.9 +* under the terms of the License "Eclipse Public License v1.0"
    1.10 +* which accompanies this distribution, and is available
    1.11 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.12 +*
    1.13 +* Initial Contributors:
    1.14 +* Nokia Corporation - initial contribution.
    1.15 +*
    1.16 +* Contributors:
    1.17 +*
    1.18 +* Description: 
    1.19 +*
    1.20 +*/
    1.21 +
    1.22 +
    1.23 +#include <e32base.h>
    1.24 +#include <es_sock.h>
    1.25 +#include <in_sock.h>
    1.26 +
    1.27 +#include "commandlineargs.h"
    1.28 +
    1.29 +enum TSNTPClientState {
    1.30 +	EStateIdle = 0,
    1.31 +	EStateResolve,
    1.32 +	EStateWrite,
    1.33 +	EStateRead,
    1.34 +	EStateComplete,
    1.35 +	EStateFailed,
    1.36 +	EStateAborted
    1.37 +	};
    1.38 +
    1.39 +class MTimeOutNotify
    1.40 +	{
    1.41 +public:
    1.42 +	virtual void TimerExpired() = 0;
    1.43 +	};
    1.44 +	
    1.45 +// timeout handler
    1.46 +
    1.47 +class CTimeOutTimer: public CTimer
    1.48 +	{
    1.49 +public:
    1.50 +	static CTimeOutTimer* NewL(const TInt aPriority, MTimeOutNotify& aTimeOutNotify);
    1.51 +	~CTimeOutTimer();
    1.52 +
    1.53 +protected:
    1.54 +    CTimeOutTimer(const TInt aPriority);
    1.55 +	void ConstructL(MTimeOutNotify& aTimeOutNotify);
    1.56 +    virtual void RunL();
    1.57 +
    1.58 +private:
    1.59 +	MTimeOutNotify* iNotify;
    1.60 +	};
    1.61 +	
    1.62 +// The main client engine
    1.63 +	
    1.64 +class CSNTPClient : public CActive, public MTimeOutNotify
    1.65 +	{
    1.66 +
    1.67 +public:
    1.68 +	static CSNTPClient* NewL(TCommandLineArgs& aArgs);
    1.69 +	static CSNTPClient* NewLC(TCommandLineArgs& aArgs);
    1.70 +	
    1.71 +	TSNTPClientState State();
    1.72 +	void Start();
    1.73 +	
    1.74 +	~CSNTPClient();
    1.75 +	
    1.76 +private:
    1.77 +	CSNTPClient(TCommandLineArgs& aArgs);
    1.78 +
    1.79 +	void ConstructL();
    1.80 +	
    1.81 +	/* CActive methods */
    1.82 +	void RunL();
    1.83 +	void DoCancel();
    1.84 +	TInt RunError(TInt aError);
    1.85 +	
    1.86 +	/* MTimeOutNotify methods */
    1.87 +	void TimerExpired();
    1.88 +	
    1.89 +	void SetTimeL(); 
    1.90 +	
    1.91 +private:
    1.92 +	RSocketServ	iSockServ;
    1.93 +	RSocket iSock;
    1.94 +	RHostResolver iResolver;
    1.95 +
    1.96 +	TCommandLineArgs& iArgs;
    1.97 +	TSNTPClientState iState;
    1.98 +	TNameEntry iNameEntry;
    1.99 +	
   1.100 +	CTimeOutTimer* iTimer;
   1.101 +	
   1.102 +	// An NTP packet is exactly 48 bytes
   1.103 +	TBuf8<48> iBuffer;
   1.104 +	
   1.105 +	TInt iServerIndex;
   1.106 +	};
   1.107 +
   1.108 +
   1.109 +
   1.110 +#endif /* _SNTPCLIENTENGINE_H__ */