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

ProtocolTypes.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2002 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #ifndef PROTOCOLTYPES_H
00016 #define PROTOCOLTYPES_H
00017 
00018 #include "BasicTypes.h"
00019 
00020 // protocol version number
00021 // 1.0:  initial protocol
00022 // 1.1:  adds KeyCode to key press, release, and repeat
00023 // 1.2:  adds mouse relative motion
00024 // 1.3:  adds keep alive and deprecates heartbeats,
00025 //       adds horizontal mouse scrolling
00026 static const SInt16     kProtocolMajorVersion = 1;
00027 static const SInt16     kProtocolMinorVersion = 3;
00028 
00029 // default contact port number
00030 static const UInt16     kDefaultPort = 24800;
00031 
00032 // maximum total length for greeting returned by client
00033 static const UInt32     kMaxHelloLength = 1024;
00034 
00035 // time between kMsgCKeepAlive (in seconds).  a non-positive value disables
00036 // keep alives.  this is the default rate that can be overridden using an
00037 // option.
00038 static const double     kKeepAliveRate = 3.0;
00039 
00040 // number of skipped kMsgCKeepAlive messages that indicates a problem
00041 static const double     kKeepAlivesUntilDeath = 3.0;
00042 
00043 // obsolete heartbeat stuff
00044 static const double     kHeartRate = -1.0;
00045 static const double     kHeartBeatsUntilDeath = 3.0;
00046 
00047 // direction constants
00048 enum EDirection {
00049     kNoDirection,
00050     kLeft,
00051     kRight,
00052     kTop,
00053     kBottom,
00054     kFirstDirection = kLeft,
00055     kLastDirection = kBottom,
00056     kNumDirections = kLastDirection - kFirstDirection + 1
00057 };
00058 enum EDirectionMask {
00059     kNoDirMask  = 0,
00060     kLeftMask   = 1 << kLeft,
00061     kRightMask  = 1 << kRight,
00062     kTopMask    = 1 << kTop,
00063     kBottomMask = 1 << kBottom
00064 };
00065 
00066 
00067 //
00068 // message codes (trailing NUL is not part of code).  in comments, $n
00069 // refers to the n'th argument (counting from one).  message codes are
00070 // always 4 bytes optionally followed by message specific parameters
00071 // except those for the greeting handshake.
00072 //
00073 
00074 //
00075 // positions and sizes are signed 16 bit integers.
00076 //
00077 
00078 //
00079 // greeting handshake messages
00080 //
00081 
00082 // say hello to client;  primary -> secondary
00083 // $1 = protocol major version number supported by server.  $2 =
00084 // protocol minor version number supported by server.
00085 extern const char*      kMsgHello;
00086 
00087 // respond to hello from server;  secondary -> primary
00088 // $1 = protocol major version number supported by client.  $2 =
00089 // protocol minor version number supported by client.  $3 = client
00090 // name.
00091 extern const char*      kMsgHelloBack;
00092 
00093 
00094 //
00095 // command codes
00096 //
00097 
00098 // no operation;  secondary -> primary
00099 extern const char*      kMsgCNoop;
00100 
00101 // close connection;  primary -> secondary
00102 extern const char*      kMsgCClose;
00103 
00104 // enter screen:  primary -> secondary
00105 // entering screen at screen position $1 = x, $2 = y.  x,y are
00106 // absolute screen coordinates.  $3 = sequence number, which is
00107 // used to order messages between screens.  the secondary screen
00108 // must return this number with some messages.  $4 = modifier key
00109 // mask.  this will have bits set for each toggle modifier key
00110 // that is activated on entry to the screen.  the secondary screen
00111 // should adjust its toggle modifiers to reflect that state.
00112 extern const char*      kMsgCEnter;
00113 
00114 // leave screen:  primary -> secondary
00115 // leaving screen.  the secondary screen should send clipboard
00116 // data in response to this message for those clipboards that
00117 // it has grabbed (i.e. has sent a kMsgCClipboard for and has
00118 // not received a kMsgCClipboard for with a greater sequence
00119 // number) and that were grabbed or have changed since the
00120 // last leave.
00121 extern const char*      kMsgCLeave;
00122 
00123 // grab clipboard:  primary <-> secondary
00124 // sent by screen when some other app on that screen grabs a
00125 // clipboard.  $1 = the clipboard identifier, $2 = sequence number.
00126 // secondary screens must use the sequence number passed in the
00127 // most recent kMsgCEnter.  the primary always sends 0.
00128 extern const char*      kMsgCClipboard;
00129 
00130 // screensaver change:  primary -> secondary
00131 // screensaver on primary has started ($1 == 1) or closed ($1 == 0)
00132 extern const char*      kMsgCScreenSaver;
00133 
00134 // reset options:  primary -> secondary
00135 // client should reset all of its options to their defaults.
00136 extern const char*      kMsgCResetOptions;
00137 
00138 // resolution change acknowledgment:  primary -> secondary
00139 // sent by primary in response to a secondary screen's kMsgDInfo.
00140 // this is sent for every kMsgDInfo, whether or not the primary
00141 // had sent a kMsgQInfo.
00142 extern const char*      kMsgCInfoAck;
00143 
00144 // keep connection alive:  primary <-> secondary
00145 // sent by the server periodically to verify that connections are still
00146 // up and running.  clients must reply in kind on receipt.  if the server
00147 // gets an error sending the message or does not receive a reply within
00148 // a reasonable time then the server disconnects the client.  if the
00149 // client doesn't receive these (or any message) periodically then it
00150 // should disconnect from the server.  the appropriate interval is
00151 // defined by an option.
00152 extern const char*      kMsgCKeepAlive;
00153 
00154 
00155 //
00156 // data codes
00157 //
00158 
00159 // key pressed:  primary -> secondary
00160 // $1 = KeyID, $2 = KeyModifierMask, $3 = KeyButton
00161 // the KeyButton identifies the physical key on the primary used to
00162 // generate this key.  the secondary should note the KeyButton along
00163 // with the physical key it uses to generate the key press.  on
00164 // release, the secondary can then use the primary's KeyButton to
00165 // find its corresponding physical key and release it.  this is
00166 // necessary because the KeyID on release may not be the KeyID of
00167 // the press.  this can happen with combining (dead) keys or if
00168 // the keyboard layouts are not identical and the user releases
00169 // a modifier key before releasing the modified key.
00170 extern const char*      kMsgDKeyDown;
00171 
00172 // key pressed 1.0:  same as above but without KeyButton
00173 extern const char*      kMsgDKeyDown1_0;
00174 
00175 // key auto-repeat:  primary -> secondary
00176 // $1 = KeyID, $2 = KeyModifierMask, $3 = number of repeats, $4 = KeyButton
00177 extern const char*      kMsgDKeyRepeat;
00178 
00179 // key auto-repeat 1.0:  same as above but without KeyButton
00180 extern const char*      kMsgDKeyRepeat1_0;
00181 
00182 // key released:  primary -> secondary
00183 // $1 = KeyID, $2 = KeyModifierMask, $3 = KeyButton
00184 extern const char*      kMsgDKeyUp;
00185 
00186 // key released 1.0:  same as above but without KeyButton
00187 extern const char*      kMsgDKeyUp1_0;
00188 
00189 // mouse button pressed:  primary -> secondary
00190 // $1 = ButtonID
00191 extern const char*      kMsgDMouseDown;
00192 
00193 // mouse button released:  primary -> secondary
00194 // $1 = ButtonID
00195 extern const char*      kMsgDMouseUp;
00196 
00197 // mouse moved:  primary -> secondary
00198 // $1 = x, $2 = y.  x,y are absolute screen coordinates.
00199 extern const char*      kMsgDMouseMove;
00200 
00201 // relative mouse move:  primary -> secondary
00202 // $1 = dx, $2 = dy.  dx,dy are motion deltas.
00203 extern const char*      kMsgDMouseRelMove;
00204 
00205 // mouse scroll:  primary -> secondary
00206 // $1 = xDelta, $2 = yDelta.  the delta should be +120 for one tick forward
00207 // (away from the user) or right and -120 for one tick backward (toward
00208 // the user) or left.
00209 extern const char*      kMsgDMouseWheel;
00210 
00211 // mouse vertical scroll:  primary -> secondary
00212 // like as kMsgDMouseWheel except only sends $1 = yDelta.
00213 extern const char*      kMsgDMouseWheel1_0;
00214 
00215 // clipboard data:  primary <-> secondary
00216 // $2 = sequence number, $3 = clipboard data.  the sequence number
00217 // is 0 when sent by the primary.  secondary screens should use the
00218 // sequence number from the most recent kMsgCEnter.  $1 = clipboard
00219 // identifier.
00220 extern const char*      kMsgDClipboard;
00221 
00222 // client data:  secondary -> primary
00223 // $1 = coordinate of leftmost pixel on secondary screen,
00224 // $2 = coordinate of topmost pixel on secondary screen,
00225 // $3 = width of secondary screen in pixels,
00226 // $4 = height of secondary screen in pixels,
00227 // $5 = size of warp zone, (obsolete)
00228 // $6, $7 = the x,y position of the mouse on the secondary screen.
00229 //
00230 // the secondary screen must send this message in response to the
00231 // kMsgQInfo message.  it must also send this message when the
00232 // screen's resolution changes.  in this case, the secondary screen
00233 // should ignore any kMsgDMouseMove messages until it receives a
00234 // kMsgCInfoAck in order to prevent attempts to move the mouse off
00235 // the new screen area.
00236 extern const char*      kMsgDInfo;
00237 
00238 // set options:  primary -> secondary
00239 // client should set the given option/value pairs.  $1 = option/value
00240 // pairs.
00241 extern const char*      kMsgDSetOptions;
00242 
00243 
00244 //
00245 // query codes
00246 //
00247 
00248 // query screen info:  primary -> secondary
00249 // client should reply with a kMsgDInfo.
00250 extern const char*      kMsgQInfo;
00251 
00252 
00253 //
00254 // error codes
00255 //
00256 
00257 // incompatible versions:  primary -> secondary
00258 // $1 = major version of primary, $2 = minor version of primary.
00259 extern const char*      kMsgEIncompatible;
00260 
00261 // name provided when connecting is already in use:  primary -> secondary
00262 extern const char*      kMsgEBusy;
00263 
00264 // unknown client:  primary -> secondary
00265 // name provided when connecting is not in primary's screen
00266 // configuration map.
00267 extern const char*      kMsgEUnknown;
00268 
00269 // protocol violation:  primary -> secondary
00270 // primary should disconnect after sending this message.
00271 extern const char*      kMsgEBad;
00272 
00273 
00274 //
00275 // structures
00276 //
00277 
00279 
00282 class CClientInfo {
00283 public:
00285 
00289     SInt32              m_x, m_y;
00290 
00292 
00295     SInt32              m_w, m_h;
00296 
00298     SInt32              obsolete1;
00299 
00301 
00304     SInt32              m_mx, m_my;
00305 };
00306 
00307 #endif
00308 

Generated on Fri Nov 6 00:21:15 2009 for synergy-plus by  doxygen 1.3.9.1