home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / pmvnc100.zip / pmvncdef.h < prev    next >
C/C++ Source or Header  |  1999-08-03  |  6KB  |  235 lines

  1. /*
  2.  * pmvncdef.h - PM VNC Viewer, Global Definitions
  3.  */
  4.  
  5. #ifndef _PMVNCDEF_H
  6. #define _PMVNCDEF_H
  7.  
  8. /*
  9.  * Debugging Macro
  10.  */
  11.  
  12. #ifdef  DEBUG
  13. #define TRACE       printf
  14. #else
  15. #define TRACE
  16. #endif
  17.  
  18. /*
  19.  * Types required for 'rfbproto.h'
  20.  */
  21.  
  22. typedef CHAR    INT8   ;
  23. typedef SHORT   INT16  ;
  24. typedef LONG    INT32  ;
  25. typedef UCHAR   CARD8  ;
  26. typedef USHORT  CARD16 ;
  27. typedef ULONG   CARD32 ;
  28.  
  29. #include "rfbproto.h"
  30.  
  31. /*
  32.  * Program Name & Profile Path
  33.  */
  34.  
  35. extern  UCHAR   ProgramVers[] ;
  36. extern  UCHAR   ProgramPath[] ;
  37. extern  UCHAR   ProgramName[] ;
  38. extern  UCHAR   ProfilePath[] ;
  39.  
  40. /*
  41.  * Common Functions & Macros
  42.  */
  43.  
  44. void    errMessage(PSZ msg) ;
  45. void    dialogAtMouse(HWND hwndDialog, int target) ;
  46. void    dialogAtCenter(HWND hwndDialog) ;
  47.  
  48. #define swap16(x)   ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
  49. #define swap32(x)   ((((x) & 0xff000000) >> 24) | \
  50.                      (((x) & 0x00ff0000) >>  8) | \
  51.              (((x) & 0x0000ff00) <<  8) | \
  52.              (((x) & 0x000000ff) << 24))
  53.  
  54. /*
  55.  * Session Setup
  56.  */
  57.  
  58. extern  UCHAR   SessServerName[] ;
  59. extern  CARD32  SessPreferredEncoding ;     /* see rfbproto.h   */
  60. extern  SHORT   SessPixelFormat       ;     /* see below        */
  61. extern  BOOL    SessOptShared         ;
  62. extern  BOOL    SessOptViewonly       ;
  63. extern  BOOL    SessOptDeiconify      ;
  64.  
  65. extern  BOOL    SessDlgCenter  ;    /* TRUE if dialog at center     */
  66. extern  PUCHAR  SessPasswdFile ;    /* Name of Password File        */
  67.  
  68. extern  SIZEL   SessSavedRfb ;      /* RFB size   on last session   */
  69. extern  POINTL  SessSavedPos ;      /* Frame pos  on last session   */
  70. extern  SIZEL   SessSavedSiz ;      /* Frame size on last session   */
  71. extern  POINTL  SessSavedOff ;      /* RFB offset on last session   */
  72.  
  73. #define PIXFMT_32   0       /* req. 32 bits true color, use 24 bits bitmap  */
  74. #define PIXFMT_8    1       /* req. BGR233, use 8 bits bitmap               */
  75. #define PIXFMT_TINY 2       /* req. BGR233, mapped to def. 16 colors        */
  76. #define PIXFMT_GRAY 3       /* req. BGR233, mapped to 4 level gray scale    */
  77.  
  78. void    sessParse(int ac, char *av[]) ;
  79. BOOL    sessSetup(HAB hab)  ;
  80. BOOL    sessModify(HAB hab) ;
  81. BOOL    sessSaveProfile(HAB hab) ;
  82.  
  83. /*
  84.  * Windows for VNC Viewer
  85.  */
  86.  
  87. extern  HWND    hwndFrame  ;
  88. extern  HWND    hwndClient ;
  89. extern  HWND    hwndHorz   ;        /* Horizontal Scroll Bar    */
  90. extern  HWND    hwndVert   ;        /* Vertical   Scroll Bar    */
  91.  
  92. BOOL    winCreate(HAB hab)  ;
  93. void    winDispose(HAB hab) ;
  94.  
  95. void    winShowScroll(BOOL show) ;
  96. BOOL    winIconized(void) ;
  97.  
  98. /*
  99.  * Messages from Network Thread (request GUI/Graphics Operation)
  100.  */
  101.  
  102. #define WM_VNC_FAIL     (WM_USER + 1)       /* error on network     */
  103.  
  104. #define WM_VNC_AUTH     (WM_USER + 2)       /* authentication       */
  105. #define WM_VNC_INIT     (WM_USER + 3)       /* size/name of RFB     */
  106.  
  107. #define WM_VNC_BELL     (WM_USER + 4)       /* bell                 */
  108. #define WM_VNC_CLIP     (WM_USER + 5)       /* remote text clip     */
  109.  
  110. #define WM_VNC_UPDATE   (WM_USER + 6)       /* update on RFB        */
  111.  
  112. /*
  113.  * Mouse Event Handlings
  114.  */
  115.  
  116. void    mouseInit(HWND hwnd) ;
  117. void    mouseDone(HWND hwnd) ;
  118. void    mouseMove(HWND hwnd, PPOINTL pt) ;
  119. void    mouseEvent(HWND hwnd, ULONG msg, PPOINTL pt) ;
  120. void    mouseTimer(HWND hwnd) ;
  121.  
  122. /*
  123.  * Keyboard Event Handling
  124.  */
  125.  
  126. void    keyEvent(HWND hwnd, USHORT flags, USHORT ch, USHORT vk, USHORT sc) ;
  127. void    keyLostFocus(HWND hwnd) ;
  128. void    keyEmulateFixed(SHORT id) ;
  129. void    keyEmulateToggle(SHORT id) ;
  130.  
  131. /*
  132.  * Manages Modal Key State
  133.  */
  134.  
  135. BOOL    kstCreate(HWND hwndFrame) ;
  136. void    kstDestroy(void) ;
  137. void    kstAdjust(HWND hwndFrame) ;
  138. void    kstCtlState(BOOL down) ;
  139. void    kstAltState(BOOL down) ;
  140.  
  141. /*
  142.  * User Define Keymap (Scan -> XKeySym)
  143.  */
  144.  
  145. BOOL    kmapLoad(PUCHAR name) ;
  146. void    kmapFree(void)        ;
  147. ULONG   kmapQuery(USHORT sc)  ;
  148.  
  149. /*
  150.  * Menus on Windows
  151.  */
  152.  
  153. BOOL    menuInit(HWND hwndFrame) ;
  154. void    menuHook(HWND hwnd, USHORT id) ;    /* on WM_INITMENU   */
  155. void    menuProc(HWND hwnd, USHORT id) ;    /* on WM_COMMAND    */
  156.  
  157. /*
  158.  * Clipboard handlings
  159.  */
  160.  
  161. void    clipHold(HWND hwnd, PUCHAR text) ;
  162. BOOL    clipChkLocalClip(HWND hwnd)  ;
  163. BOOL    clipChkRemoteClip(HWND hwnd) ;
  164. void    clipCopy(HWND hwnd)  ;
  165. void    clipPaste(HWND hwnd) ;
  166.  
  167. /*
  168.  * Networking for VNC Viewer
  169.  */
  170.  
  171. extern  HAB     habNetwork ;
  172. extern  HMQ     hmqNetwork ;
  173.  
  174. BOOL    netStartup(HAB hab) ;
  175. void    netFinish(HAB hab)  ;
  176.  
  177. void    netFail(PUCHAR msg) ;
  178. void    netNotify(int ev, MPARAM mp1, MPARAM mp2) ;
  179.  
  180. BOOL    netSend(PUCHAR buf, int len) ;
  181. BOOL    netRecv(PUCHAR buf, int len) ;
  182. void    netDump(PUCHAR buf, int len) ;      /* for DEBUG */
  183.  
  184. /*
  185.  * RFB Protocol Handling
  186.  */
  187.  
  188. typedef struct _VNCREC {
  189.     rfbPixelFormat                  rectFormat  ;
  190.     void    (*rectDone)  (void)                 ;
  191.     BOOL    (*rectInit)  (int cx, int cy)       ;
  192.     BOOL    (*rectDraw)  (HPS hps, PPOINTL apt) ;
  193.     BOOL    (*rectRaw)   (rfbRectangle *r)      ;
  194.     BOOL    (*rectCopy)  (rfbRectangle *r)      ;
  195.     BOOL    (*rectRRE)   (rfbRectangle *r)      ;
  196.     BOOL    (*rectCoRRE) (rfbRectangle *r)      ;
  197.     BOOL    (*rectTile)  (rfbRectangle *r)      ;
  198. } VNCREC, *VNCPTR ;
  199.  
  200. int     queryColorIndex(void) ;     /* Number of color map          */
  201.  
  202. extern  VNCREC      VncCtx32    ;   /* for 32 bits true color       */
  203.  
  204. extern  VNCREC      VncCtx8     ;   /* for 8 bits BGR233            */
  205. extern  VNCREC      VncCtx8Tiny ;   /* BGR233 with def. 16 colors   */
  206. extern  VNCREC      VncCtx8Gray ;   /* BGR233 with 4 gray scale     */
  207.  
  208. extern  VNCREC      VncCtx4Tiny ;   /* BGR233 with def. 16 colors   */
  209. extern  VNCREC      VncCtx4Gray ;   /* BGR233 with 4 gray scale     */
  210.  
  211. extern  VNCPTR      VncCtx   ;
  212. extern  UCHAR       VncGreeting[] ;
  213.  
  214. BOOL    protoConnInit(void) ;
  215. BOOL    protoSendAuth(void) ;
  216.  
  217. PUCHAR  protoConnInfo(rfbServerInitMsg *si, int *major, int *minor) ;
  218.  
  219. BOOL    protoSendFmtEnc(void) ;
  220. BOOL    protoSendRequest(BOOL inc, PRECTL rect) ;
  221.  
  222. BOOL    protoDispatch(void) ;
  223.  
  224. BOOL    protoSendMouEvent(USHORT state, PPOINTL pt) ;
  225. BOOL    protoSendKeyEvent(BOOL down, ULONG key)     ;
  226. BOOL    protoSendCutText(PUCHAR text) ;
  227.  
  228. /*
  229.  * Authentication
  230.  */
  231.  
  232. BOOL    authCypher(HWND hwnd, PUCHAR key) ;
  233.  
  234. #endif  /* _PMVNCDEF_H */
  235.