Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

umsproto.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  umsproto.hpp: Ubit Protocol for the UMS (Ubit Mouse/Message Server)
00004  *  Ubit Project [Elc][2003]
00005  *  Author: Eric Lecolinet
00006  *
00007  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00008  *
00009  *  (C) 1999-2003 Eric Lecolinet @ ENST Paris
00010  *  WWW: http://www.enst.fr/~elc/ubit   Email: elc@enst.fr (subject: ubit)
00011  *
00012  * ***********************************************************************
00013  * COPYRIGHT NOTICE : 
00014  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00015  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00016  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00017  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00018  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00019  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00020  * ***********************************************************************
00021  *
00022  * ==================================================== [Elc:03] ======= *
00023  * ==================================================== ======== ======= */
00024 
00025 #ifndef _umsproto_hpp_
00026 #define _umsproto_hpp_
00027 //pragma ident  "@(#)umsproto.hpp       ubit:03.05.03"
00028 #include <ubit/udefs.hpp>
00029 
00030 /* ==================================================== [Elc:03] ======= */
00031 /* ==================================================== ======== ======= */
00032 
00035 struct UMSprotocol {
00036 
00037   static const int UMS_DEFAULT_PORT = 9666;
00042   static const u_id UBIT_EVENT_FLOW = 1<<14;
00050   static const char *UBIT_SELECTION, *UBIT_MESSAGE, *UBIT_WINDOW;
00055   static void setUbitProtocols(class UNatDisp*, class UNatWin*);
00056 };
00057 
00058 /* ==================================================== [Elc:03] ======= */
00059 /* ==================================================== ======== ======= */
00060 
00081 struct UMSrequest {
00082   enum RequestType { 
00083     MOUSE_CTRL        = 1,   
00084     SEND_EVENT        = 2,   
00085     SEND_MESSAGE      = 3,
00086     OPEN_WIN          = 5, 
00087     CLOSE_WIN         = 6,
00088     OPEN_CNX          = 7, 
00089     CLOSE_CNX         = 8
00090   };
00091 
00092   // comm status
00093   enum Stat {Error = -1, CloseCnx = 0, Ok = 1, KeepCnx = 2};
00094 
00095   UMSrequest();
00096   UMSrequest(unsigned char reqtype);
00097 
00098   int size() {return data[0]*8;}
00100 
00101   void readEvent(unsigned char& event_type, 
00102                  unsigned char& event_flow, 
00103                  long& x, long& y, unsigned long& detail);
00104 
00105   void writeEvent(unsigned char event_type, 
00106                   unsigned char event_flow, 
00107                   long x, long y, unsigned long detail);
00108 
00109   char readChar();
00110   void writeChar(char);
00111 
00112   short readShort();
00113   void writeShort(short);
00114 
00115   long readLong();
00116   void writeLong(long);
00117 
00118   bool writeString(const char*);
00119   char* getString();
00121   
00122   unsigned char data[8*256];
00129   int count;
00135 };
00136 
00137 /* ==================================================== [TheEnd] ======= */
00138 /* ==================================================== [Elc:03] ======= */
00139 #endif

Generated on Thu Mar 3 06:36:49 2005 for Ubit[Eric.Lecolinet@enst.fr] by  doxygen 1.4.1