engine.h
上传用户:sempras
上传日期:2007-03-04
资源大小:821k
文件大小:2k
源码类别:

Symbian

开发平台:

C/C++

  1. //
  2. //    engine.h
  3. //
  4. //    Copyright (C) 2001, Forum Nokia - The Developer Community 
  5. //
  6. ////////////////////////////////////////////////////////////////
  7. #ifndef __ENGINE_H
  8. #define __ENGINE_H
  9. #include <es_sock.h>
  10. #include <in_sock.h>
  11. class CTcpUdpView;
  12. class CMyTimer;
  13. //Contains engine's saved preferences
  14. class TPreferences
  15. {
  16. public:
  17. TUint  iProtocol;
  18. TUint  iRemotePort;
  19. TUint  iLocalPort;
  20. TUint    iCount;
  21. TBool    iTrace;
  22. TUint  iPacketSize;
  23. TBuf<60> iRemoteAddr;
  24. TBuf<60> iLocalAddr;
  25. };
  26. class CRunEngine : public CActive
  27. {
  28. public:
  29. //constructor
  30. CRunEngine();
  31. //destructor
  32. ~CRunEngine();
  33. //second phase constructor
  34. void ConstructL(CTcpUdpView *aAppView);
  35. TInt Start();
  36. void Stop();
  37. inline CTcpUdpView *AppView()
  38. {return iAppView;};
  39. inline TBool Running()
  40. {return (iState != EIdle);};
  41. static void DefaultPreferences(TPreferences &aPref);
  42. void GetPreferences(TPreferences &aPref);
  43. void SetPreferences(TPreferences &aPref);
  44. protected:
  45.     // Active Object functions
  46.     void RunL();
  47. void DoCancel();
  48. private:
  49. void ReceivePacket();
  50.     void SendPacket();
  51.     void CloseSockets();
  52. public:
  53. // Variables accessed from the options dialog
  54. TUint  iProtocol;
  55. TUint  iRemotePort;
  56. TUint  iLocalPort;
  57. TBuf<60> iRemoteAddr;
  58. TBuf<60> iLocalAddr;
  59. TUint    iCount;
  60. TBool    iTrace;
  61. TUint  iPacketSize;
  62. TInetAddr   iRecAddr;
  63. private:
  64. CTcpUdpView   *iAppView;
  65.     RSocketServ   iSocketServer;
  66. RSocket   iSocket;
  67. TInetAddr   iSendAddr;
  68. enum TState   {EIdle,EConnected,EReceiving,ESending,EClosing};
  69.     TState        iState;
  70.     TInt          iTotalBytesRcvd;
  71.     HBufC8        *iRecBuffer;
  72.     TPtr8         iRecData;
  73. HBufC8        *iSendBuffer;
  74. TPtr8         iSendData;
  75.     TSockXfrLength iNumRcvd;
  76.     CMyTimer      *iMyTimer;
  77. TUint         iRecvPackets;
  78. TUint         iSentPackets;
  79. };
  80. class CMyTimer : public CTimer
  81. {
  82. public:
  83. CMyTimer();
  84. void ConstructL(CRunEngine *aEngine);
  85. void RunL();
  86. private:
  87.     CRunEngine *iEngine;
  88. };
  89. #endif