Example #1
0
 public void getData(PositionWindowMsgArgs msgArgs) throws EOFException {
   bufQueue.skipBytes(3); // Skip 3 bytes of pad
   msgArgs.clientId = bufQueue.nextInt();
   msgArgs.wid = bufQueue.nextInt();
   msgArgs.x = bufQueue.nextShort();
   msgArgs.y = bufQueue.nextShort();
 }
Example #2
0
 public void getData(WindowSetRotateYMsgArgs msgArgs) throws EOFException {
   bufQueue.skipBytes(3); // Skip 3 bytes of pad
   msgArgs.clientId = bufQueue.nextInt();
   msgArgs.wid = bufQueue.nextInt();
   int iroty = bufQueue.nextInt();
   msgArgs.roty = Float.intBitsToFloat(iroty);
 }
Example #3
0
  public void getData(ControllerStatusMsgArgs msgArgs) throws EOFException {
    int status = (int) bufQueue.nextByte();
    msgArgs.status = Proto.ControllerStatus.values()[status];

    // Skip 2 bytes of pad
    bufQueue.nextShort();

    msgArgs.clientId = bufQueue.nextInt();
  }
Example #4
0
  public void getData(SetPopupParentMsgArgs msgArgs) throws EOFException {

    // Skip 3 bytes of pad
    bufQueue.nextByte();
    bufQueue.nextShort();

    msgArgs.wid = bufQueue.nextInt();
    msgArgs.parentWid = bufQueue.nextInt();
  }
Example #5
0
 public void getData(CreateWindowMsgArgs msgArgs) throws EOFException {
   msgArgs.decorated = bufQueue.nextByte() != 0;
   bufQueue.nextShort(); // Skip 2 bytes of pad
   msgArgs.wid = bufQueue.nextInt();
   msgArgs.x = bufQueue.nextShort();
   msgArgs.y = bufQueue.nextShort();
   msgArgs.wAndBorder = bufQueue.nextInt();
   msgArgs.hAndBorder = bufQueue.nextInt();
 }
Example #6
0
  // TODO: 0.4 protocol
  public void getData(MoveCursorMsgArgs msg) throws EOFException {
    // Skip 3 bytes of pad
    bufQueue.nextByte();
    bufQueue.nextShort();

    msg.wid = bufQueue.nextInt();
    msg.x = bufQueue.nextInt();
    msg.y = bufQueue.nextInt();
  }
Example #7
0
 public void getData(WindowSetUserDisplMsgArgs msgArgs) throws EOFException {
   bufQueue.skipBytes(3); // Skip 3 bytes of pad
   msgArgs.clientId = bufQueue.nextInt();
   msgArgs.wid = bufQueue.nextInt();
   int ix = bufQueue.nextInt();
   int iy = bufQueue.nextInt();
   int iz = bufQueue.nextInt();
   msgArgs.userDispl =
       new Vector3f(Float.intBitsToFloat(ix), Float.intBitsToFloat(iy), Float.intBitsToFloat(iz));
 }
Example #8
0
  public void getData(ShowWindowMsgArgs msgArgs) throws EOFException {
    msgArgs.show = (bufQueue.nextByte() != 0);

    // TODO: 0.4 protocol: skip 2 bytes of transient and pad (ignore transient for now)
    // TODO: 0.5 protocol: skip 2 bytes of pad
    bufQueue.nextShort();

    msgArgs.wid = bufQueue.nextInt();

    // TODO: 0.5 protocol: not yet
    // msgArgs.transientFor = bufQueue.nextInt();
  }
Example #9
0
  public void getData(SetWindowTitleMsgArgs msgArgs) throws EOFException {
    // Skip 3 byte of pad
    bufQueue.nextByte();
    bufQueue.nextShort();

    msgArgs.wid = bufQueue.nextInt();
    int strLen = bufQueue.nextInt();

    byte[] bytes = new byte[strLen];
    for (int i = 0; i < strLen; i++) {
      bytes[i] = bufQueue.nextByte();
    }
    msgArgs.title = new String(bytes);
  }
Example #10
0
  public void getData(UserNameMsgArgs msgArgs) throws EOFException {

    // Skip 1 byte of pad
    bufQueue.nextByte();

    int strLen = bufQueue.nextShort();
    if (strLen > 0) {
      byte[] bytes = new byte[strLen];
      for (int i = 0; i < strLen; i++) {
        bytes[i] = bufQueue.nextByte();
      }
      msgArgs.userName = new String(bytes);
    } else {
      msgArgs.userName = null;
    }

    controllingUserName = msgArgs.userName;
  }
Example #11
0
 public void cleanup() {
   disconnect();
   client = null;
   scanLineBuf = null;
   if (bufQueue != null) {
     bufQueue.close();
     bufQueue = null;
   }
   AppXrw.logger.info("ServerProxySlave cleaned up");
 }
Example #12
0
 public Proto.ServerMessageType getMessageType() throws EOFException {
   if (bufQueue == null) {
     return Proto.ServerMessageType.SERVER_DISCONNECT;
   }
   try {
     int msgCode = (int) bufQueue.nextByte();
     AppXrw.logger.info("msgCode = " + msgCode);
     return Proto.ServerMessageType.values()[msgCode];
   } catch (EOFException ex) {
     return Proto.ServerMessageType.SERVER_DISCONNECT;
   }
 }
Example #13
0
  public void getData(CopyAreaMsgArgs msgArgs) throws EOFException {
    // Skip 3 bytes of pad
    bufQueue.nextByte();
    bufQueue.nextShort();

    msgArgs.wid = bufQueue.nextInt();
    msgArgs.srcX = bufQueue.nextInt();
    msgArgs.srcY = bufQueue.nextInt();
    msgArgs.width = bufQueue.nextInt();
    msgArgs.height = bufQueue.nextInt();
    msgArgs.dstX = bufQueue.nextInt();
    msgArgs.dstY = bufQueue.nextInt();
  }
Example #14
0
 public void getData(ConfigureWindowMsgArgs msgArgs) throws EOFException {
   bufQueue.skipBytes(3); // Skip 3 bytes of pad
   msgArgs.clientId = bufQueue.nextInt();
   msgArgs.wid = bufQueue.nextInt();
   msgArgs.x = bufQueue.nextShort();
   msgArgs.y = bufQueue.nextShort();
   msgArgs.wAndBorder = bufQueue.nextInt();
   msgArgs.hAndBorder = bufQueue.nextInt();
   msgArgs.sibid = bufQueue.nextInt();
 }
Example #15
0
  public void getData(DisplayPixelsMsgArgs msgArgs) throws EOFException {
    int encodingCode = bufQueue.nextByte();
    msgArgs.encoding = Proto.PixelEncoding.values()[encodingCode];

    msgArgs.x = bufQueue.nextShort();
    msgArgs.wid = bufQueue.nextInt();
    msgArgs.y = bufQueue.nextShort();
    msgArgs.w = bufQueue.nextShort();
    msgArgs.h = bufQueue.nextShort();

    // Skip 2 bytes of pad
    bufQueue.nextShort();
  }
Example #16
0
  // TODO: 0.4 protocol
  public void getData(DisplayCursorMsgArgs msg) throws EOFException {
    // Skip 3 bytes of pad
    bufQueue.nextByte();
    bufQueue.nextShort();

    msg.width = bufQueue.nextShort();
    msg.height = bufQueue.nextShort();
    msg.xhot = bufQueue.nextShort();
    msg.yhot = bufQueue.nextShort();

    int numPixels = msg.width * msg.height;
    msg.pixels = new int[numPixels];
    for (int i : msg.pixels) {
      msg.pixels[i] = bufQueue.nextInt();
    }
  }
Example #17
0
 public void readRleChunk(byte[] buf, int len) throws EOFException {
   bufQueue.nextBytes(buf, len);
 }
Example #18
0
 public int readRleInt() throws EOFException {
   int value = bufQueue.nextInt();
   return value;
 }
Example #19
0
 public byte[] readScanLine() throws EOFException {
   return bufQueue.nextBuffer();
 }
Example #20
0
 // TODO: 0.4 protocol
 public void getData(ShowCursorMsgArgs msg) throws EOFException {
   msg.show = (bufQueue.nextByte() == 1) ? true : false;
 }
Example #21
0
  private void syncWindowStateNext() throws EOFException {
    AppXrw.logger.info("Enter syncWindowStateNext");

    CreateWindowMsgArgs crtMsgArgs = new CreateWindowMsgArgs();
    WindowXrw win;
    int controllingUserLen;
    int desiredZOrder;
    float rotY; // Currently ignored
    Vector3f userTranslation = new Vector3f();

    crtMsgArgs.wid = bufQueue.nextInt();
    crtMsgArgs.x = (short) bufQueue.nextInt();
    crtMsgArgs.y = (short) bufQueue.nextInt();
    crtMsgArgs.wAndBorder = bufQueue.nextInt();
    crtMsgArgs.hAndBorder = bufQueue.nextInt();
    crtMsgArgs.borderWidth = bufQueue.nextInt();
    controllingUserLen = bufQueue.nextInt();
    desiredZOrder = bufQueue.nextInt();
    rotY = bufQueue.nextFloat(); // Just skipped
    userTranslation.x = bufQueue.nextFloat();
    userTranslation.y = bufQueue.nextFloat();
    userTranslation.z = bufQueue.nextFloat();
    AppXrw.logger.info("userTranslation = " + userTranslation);
    /* TODO: 0.4 protocol:
    int transientFor = bufQueue.nextInt();
    AppXrw.logger.info("transientFor = " + transientFor);
     */
    // TODO: 0.4 protocol: skip isTransient
    int transientFor = bufQueue.nextInt();
    int typeOrdinal = bufQueue.nextInt();
    Window2D.Type type = Window2D.Type.values()[typeOrdinal];
    AppXrw.logger.info("type = " + type);
    int parentWid = bufQueue.nextInt();
    AppXrw.logger.info("parentWid = " + parentWid);

    crtMsgArgs.decorated = (bufQueue.nextByte() == 1) ? true : false;
    AppXrw.logger.info("client = " + client);
    AppXrw.logger.info("crtMsgArgs = " + crtMsgArgs);
    AppXrw.logger.info("desiredZOrder= " + desiredZOrder);

    // Make sure window is ready to receive data on creation
    win = client.createWindow(crtMsgArgs);
    if (win == null) {
      AppXrw.logger.warning("Cannot create slave window for " + crtMsgArgs.wid);
      return;
    }

    if (win.getType() != type) {
      win.setType(type);
    }

    // Defer parent assignment until all windows are created
    if (parentWid != WindowXrw.INVALID_WID) {
      windowParents.put(win, parentWid);
    }

    win.setDesiredZOrder(desiredZOrder);

    CellTransform userTransformCell = new CellTransform(null, null);
    userTransformCell.setTranslation(userTranslation);
    win.setUserTransformCellLocal(userTransformCell);

    boolean show = (bufQueue.nextByte() == 1) ? true : false;
    AppXrw.logger.info("show = " + show);

    if (controllingUserLen > 0) {
      byte[] controllingUserBuf = bufQueue.nextBuffer();
      String controllingUser = new String(controllingUserBuf);
      AppXrw.logger.info("controlling user = " + controllingUser);
      win.setControllingUser(controllingUser);
    }

    int srcWidth = crtMsgArgs.wAndBorder;
    int srcHeight = crtMsgArgs.hAndBorder;
    int[] pixels = new int[srcWidth * srcHeight];

    for (int y = 0; y < srcHeight; y++) {
      int srcLineOffset = y * srcWidth;
      for (int x = 0; x < srcWidth; x++) {
        pixels[srcLineOffset + x] = bufQueue.nextInt();
      }
    }
    win.displayPixels(0, 0, srcWidth, srcHeight, pixels);

    /* TODO: 0.4 protocol:
    WindowXrw winTransientFor = client.lookupWindow(transientFor);
    win.setVisibleApp(show, winTransientFor);
     */
    win.setVisibleApp(show);
  }
Example #22
0
 public void getData(DestroyWindowMsgArgs msgArgs) throws EOFException {
   bufQueue.skipBytes(3); // Skip 3 bytes of pad
   msgArgs.wid = bufQueue.nextInt();
 }
Example #23
0
 public void getData(WindowSetDecoratedMsgArgs msgArgs) throws EOFException {
   msgArgs.decorated = (bufQueue.nextByte() == 1) ? true : false;
   bufQueue.nextShort(); // Skip 2 bytes of pad
   msgArgs.wid = bufQueue.nextInt();
 }
Example #24
0
 public void getData(SlaveCloseWindowMsgArgs msgArgs) throws EOFException {
   bufQueue.skipBytes(3); // Skip 3 bytes of pad
   msgArgs.clientId = bufQueue.nextInt();
   msgArgs.wid = bufQueue.nextInt();
 }
Example #25
0
 public void getData(WindowSetBorderWidthMsgArgs msgArgs) throws EOFException {
   bufQueue.nextByte(); // Skip 1 byte of pad
   msgArgs.borderWidth = bufQueue.nextShort();
   msgArgs.wid = bufQueue.nextInt();
 }
Example #26
0
  private void initialHandshake() throws EOFException {

    String userName = session.getUserID().getUsername();
    int strLen = userName.length();

    // Inform the server  that we have connected by sending a hello message
    // with the name of this user
    byte[] helloBuf =
        new byte[Proto.ClientMessageType.HELLO.size() + strLen + Proto.SIGNATURE_SIZE];
    helloBuf[0] = (byte) Proto.ClientMessageType.HELLO.ordinal();
    helloBuf[1] = (byte) 0; // pad
    helloBuf[2] = (byte) ((strLen >> 8) & 0xff);
    helloBuf[3] = (byte) (strLen & 0xff);
    System.arraycopy(userName.getBytes(), 0, helloBuf, 4, strLen);
    try {
      slaveSocket.send(sign(helloBuf));
    } catch (IOException ex) {
      throw new RuntimeException(ex);
    }

    AppXrw.logger.info("Broadcast slave Hello message for user " + userName);

    // Get the welcome message from the server. This contains the client id
    // Note: because the master hub broadcasts to all slaves, there is a chance
    // there might be irrelevant messages queued up for this
    // slave. These should be ignored. This come from the fact that it takes
    // some time after the slave joins the connection for the master to become
    // aware of it and to compose and send the welcome message. During this time
    // if there are any incoming messages from the X server they will be
    // forwarded to this slave even if it has not yet been officially welcomed.
    // Since the content of these messages will be reflected in the welcome message
    // and the slave can't really do anything until it is welcomed we need
    // to ignore these messages.

    ServerMessageType type = null;
    do {
      type = getMessageType();
    } while (type != ServerMessageType.WELCOME);
    // TODO: eventually we should add a timeout

    // Skip 3 bytes of pad
    bufQueue.nextByte();
    bufQueue.nextShort();

    clientId = bufQueue.nextInt();
    client.setClientId(clientId);

    windowParents.clear();

    // Read the initial window state synchronization
    // part of the welcome message
    int numWins = bufQueue.nextInt();
    AppXrw.logger.info("numWins = " + numWins);
    for (int i = 0; i < numWins; i++) {
      syncWindowStateNext();
    }

    // All windows have been defined. Now assign the parents
    for (WindowXrw win : windowParents.keySet()) {
      Integer parentWid = windowParents.get(win);
      if (parentWid != null) {
        WindowXrw parentWin = client.lookupWindow(parentWid.intValue());
        win.setParent(parentWin);
      }
    }
    windowParents.clear();

    client.updateSlaveWindows();
  }