examples/Networking/SecureSockets/SecEngine.h

00001 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // This component and the accompanying materials are made available
00004 // under the terms of "Eclipse Public License v1.0"
00005 // which accompanies this distribution, and is available
00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 //
00015 
00016 #ifndef __SECENGINE_H__
00017 #define __SECENGINE_H__
00018 
00019 #include <e32cons.h>
00020 #include <c32comm.h>
00021 #include <in_sock.h>
00022 #include <securesocket.h>
00023 #include <x509cert.h>
00024 
00026 const TInt KSettingFieldWidth = 128;
00027 
00029 struct TConnectSettings
00030         {
00032         TBuf<KSettingFieldWidth> iAddress;
00034         TInt iPortNum;
00036         TBuf8<KSettingFieldWidth> iPage;
00037         };
00038 
00042 class CSecEngine : public CActive
00043         {
00044 public:
00049         static CSecEngine *NewL();
00053         ~CSecEngine();
00072         void ConnectL( const TConnectSettings& aConnectSettings );
00078         void SetConsole( CConsoleBase& aConsole );
00079 
00085         void SetOutputFile( RFile& aOutputFile );
00086 
00092         TBool InUse();
00093 
00094 private:
00096         enum TStates  
00097                 {
00099                 ESocketConnected,
00101                 ESettingCiphers,
00103                 ESecureConnected,
00105                 EGetRequestSent,
00107                 EDataReceived,
00109                 EConnectionClosed
00110                 };
00111         
00112 private:
00114         CSecEngine();    
00116         void ConstructL();
00117 
00118         // Methods from CActive
00120         void RunL();
00122         void DoCancel();
00124         TInt RunError( TInt aError );
00125         
00126         // Handle particular engine states
00128         void MakeSecureConnectionL();
00130         void MakePageRequestL();
00132         void GetServerResponseL();
00134         void ReadServerResponseL();
00136         void ConnectionClosed();
00137 
00139         void PrintCipherNameL(const TDes8& aBuf);
00141         void PrintCertInfo(const CX509Certificate& aSource);
00142 
00143 private:
00144         // Sockets objects
00146         RSocketServ iSocketServ;
00148         RSocket iSocket;
00150         RHostResolver iHostResolver;
00152         TInetAddr iInetAddr;
00154         CSecureSocket* iTlsSocket;
00155 
00156         // Connection parameters
00157         const TConnectSettings* iConnectSettings;
00158 
00159         // Transfer buffers and counters
00161         TPtr8 iSndBuffer;
00163         TSockXfrLength iBytesSent;
00165         TPtr8 iRcvBuffer;
00167         TInt iTotalBytesRead;
00168 
00170         RTimer iTimer;
00171 
00173         CConsoleBase *iConsole;
00175         RFile* iOutputFile;
00176 
00177         // Flags and state
00179         TBool           iSuccess;
00181         TBool   iFirstRunFlag;
00183         TBool   iInUse;
00185         TInt    iRunState;
00186         };
00187 
00188 #endif

Generated on Thu Jan 21 10:33:00 2010 for TB10.1 Example Applications by  doxygen 1.5.3