home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / Epoc / Palmtime / files / FrotzS5_src.ZIP / Frotzs5.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-11  |  5.7 KB  |  237 lines

  1. // FROTZS5.H
  2. //
  3.  
  4.  
  5. #ifndef __FROTZS5_H__
  6. #define __FROTZS5_H__
  7.  
  8. #include <e32svr.h>
  9. #include <e32math.h>
  10. #include <eikconso.h>
  11. #include <e32keys.h>
  12. #include <barsread.h>
  13. #include <coecntrl.h>
  14. #include <eikdef.h>
  15. #include <eikenv.h>
  16. #include <eikappui.h>
  17. #include <eikdialg.h>
  18. #include <eikdialg.hrh>
  19. #include <eikcapc.h>
  20. #include <eikcapca.h>
  21. #include <eikctrls.hrh>
  22. #include <eikcmds.hrh>
  23. #include <eikmfne.h>
  24. #include <eikmfne.hrh>
  25. #include <eikfpne.h>
  26. #include <eikedwin.hrh>
  27. #include <eikcmbut.h>
  28. #include <eiklabel.h>
  29. #include <eikseced.h>
  30. #include <eikrted.h>
  31. #include <txtrich.h>
  32. #include <eiktbar.h>
  33. #include <eikchred.h>
  34. #include <eikchmap.h>
  35. #include <eikrted.h>
  36. #include <eikopbut.h>
  37. #include <eikhopbt.h>
  38. #include <eikchkbx.h>
  39. #include <eikmenub.h>
  40. #include <eikmenup.h>
  41. #include <eikmenu.hrh>
  42. #include <eikfsel.h>
  43. #include <eikapp.h>
  44. #include <eikdoc.h>
  45. #include <eikon.rsg>
  46. #include <basched.h>
  47. #include <frotzs5.rsg>
  48. #include "frotzs5.hrh"
  49.  
  50.   // Convenient TInt used in the pragma data_seg.
  51.   // See definition of symbol KNarrowReleaseUid defined in E32UID.H
  52. const TInt KFrotzNarrowRelUidValue = 0x10000079;
  53.  
  54. // needed for creating server thread.
  55. const TUint KDefaultHeapSize=0x100000;
  56.  
  57. // server name
  58. #define MAIN_SERVER_NAME _L("FrotzServer")
  59.  
  60. // A version must be specifyed when creating a session with the server
  61.  
  62. const TUint KMainServMajorVersionNumber=0;
  63. const TUint KMainServMinorVersionNumber=1;
  64. const TUint KMainServBuildVersionNumber=1;
  65.  
  66. IMPORT_C TInt StartThread();
  67.  
  68. // opcodes used in message passing between client and server
  69. enum TMainServRqst
  70.     {
  71.     EMainServCreate,
  72.     EMainServClose,
  73.     EMainServStop,
  74.     EMainServPrintf,
  75.     EMainServGetCh,
  76.     EMainServKeyTimer,
  77.     EMainServEraseRect,
  78.     EMainServScroll,
  79.     EMainServCursor,
  80.     EMainServTextAttr,
  81.     EMainServPutChar,
  82.     EMainServPutString,
  83.     EMainServSetCursor,
  84.     EMainServDlgOpen,
  85.     EMainServDlgSave,
  86.     EMainServGetApp,
  87.     EMainServGetStoryName,
  88.     EMainServTerminate
  89.     };
  90.  
  91. enum TMainServLeave
  92. {
  93.     ENonNumericString
  94. };
  95.  
  96. // reasons for server panic
  97. enum TMainServPanic
  98.     {
  99.     EBadRequest,
  100.     EBadDescriptor,
  101.     EMainSchedulerError,
  102.     ESvrCreateServer,
  103.     ESvrStartServer,
  104.     ECreateTrapCleanup,
  105.     ENotImplementedYet,
  106.     };
  107.  
  108.  
  109. int DlgOpen(char *pathsrc, char *file);
  110. TInt FrotzStartFunction(TAny* aParam);
  111.  
  112. //**********************************
  113. //CFrotzServServer
  114. //**********************************
  115. //The server class; an active object.
  116. //Contains an instance of RServer; a handle to the kernel server representation which is used
  117. //to receive messages.
  118.  
  119.  
  120. //**********************************
  121. //global functions
  122. //**********************************
  123.  
  124. // function to panic the server
  125. GLREF_C void PanicServer(TMainServPanic aPanic);
  126. // thread function for server
  127. GLREF_C TInt MainServerThread(TAny *);
  128. class CFrotzAppUi;
  129. class CMainServServer : public CServer
  130.     {
  131. public:
  132.     enum {EPriority=950}; // mpt - need to explain the magic here!
  133.     CFrotzAppUi *papp;
  134. public:
  135. //    static TInt ThreadFunction(TAny* aStarted);
  136.     static CMainServServer* New(CFrotzAppUi *ptr);
  137. //    void Delete();
  138.     virtual CSession *NewSessionL(RThread aClient,const TVersion &aVersion) const;
  139. //    static TInt StartFunction();
  140. public:
  141.     CMainServServer(TInt aPriority);
  142. private:
  143.     TInt                iActive;
  144.     };
  145.  
  146. //**********************************
  147. //CMainServSession
  148. //**********************************
  149. //This class represents a session in the server.
  150. //CSession::Client() returns the client thread.
  151. //Functions are provided to respond appropriately to client messages.
  152.  
  153.  
  154. class CMainServSession : public CSession
  155.     {
  156. public:
  157.     // construct/destruct
  158.     CMainServSession(RThread &aClient, CMainServServer * aServer);
  159.     static CMainServSession* NewL(RThread &aClient, CMainServServer * aServer);
  160.     //service request
  161.     virtual void ServiceL(const RMessage &aMessage);
  162.     void DispatchMessageL(const RMessage &aMessage);
  163.     CFrotzAppUi *papp;
  164.  
  165. protected:
  166.     // panic the client
  167.     void PanicClient(TInt aPanic) const;
  168.     // safewrite between client and server
  169.     void Write(const TAny* aPtr,const TDesC8& aDes,TInt anOffset=0);
  170. private:
  171.     //CMainServServer *iMainSvr;
  172.     TInt iMain;
  173.     int err;
  174.     };
  175. ////////////////////////////////////////////////////////////////////////////////////////
  176. // CFrotzAppUi
  177. ////////////////////////////////////////////////////////////////////////////////////////
  178. class CKeyTimer;
  179.  
  180. class CFrotzAppUi : public CEikAppUi
  181.     {
  182. public:
  183.     void ConstructL();
  184.     virtual ~CFrotzAppUi();
  185.     void ReadProfile();
  186.     void UpdateProfile();
  187.     void DrawUserScreen();
  188.     CCirBuf<TKeyEvent>* iKeyEventQ;
  189.     CEikConsoleScreen *iCons;
  190.     CEikConsoleControl *iControl;
  191.     CKeyTimer *keytimer;
  192.     //int keyreceived;
  193.     CMainServServer *pS;
  194.     //For thread
  195.     char thestoryname[256];
  196.     int storyrunning;
  197.     int keyready;
  198.     int waitingkey;
  199.     RSemaphore SemaKey;
  200.     int cattr;
  201.     int cfontsize;
  202.     int ctoolbar;
  203.     int cscreenwidth, cscreenheight;
  204.     int consolepixelwidth, consolepixelheight;
  205.     int cboldmode;
  206.     char storypath[128];
  207.     char savepath[128];
  208.     int boldtoggled;
  209. private: // framework
  210.     CMainServServer *iMainSvr;
  211.     virtual void HandleCommandL(TInt aCommand);
  212.     void DynInitMenuPaneL(TInt aMenuId,CEikMenuPane* aMenuPane);
  213.     void MakeToolBarVisible(TBool aVisible);
  214.     TRequestStatus iLogonStatus;
  215.     RThread FrotzThread;
  216.     void HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
  217.     };
  218.  
  219. class CKeyTimer : public CTimer
  220. {
  221.   public:
  222.   CFrotzAppUi *papp;
  223.   CKeyTimer():CTimer(EPriorityHigh){}
  224.   ~CKeyTimer(){Cancel();}
  225.   void Start(CFrotzAppUi *ptr, int delay);
  226.   virtual void RunL(void);
  227. };
  228.  
  229. class CExampleAboutDialog : public CEikDialog
  230.     {
  231. public:
  232.       // Construction
  233.     CExampleAboutDialog(){};
  234.     };
  235.  
  236. #endif
  237.