00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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
00120 void RunL();
00122 void DoCancel();
00124 TInt RunError( TInt aError );
00125
00126
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
00146 RSocketServ iSocketServ;
00148 RSocket iSocket;
00150 RHostResolver iHostResolver;
00152 TInetAddr iInetAddr;
00154 CSecureSocket* iTlsSocket;
00155
00156
00157 const TConnectSettings* iConnectSettings;
00158
00159
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
00179 TBool iSuccess;
00181 TBool iFirstRunFlag;
00183 TBool iInUse;
00185 TInt iRunState;
00186 };
00187
00188 #endif