Example #1
0
  static void reqRotateProperties(Client c) throws IOException {
    int foo, propty;
    IO io = c.client;

    foo = io.readInt();
    Window w = c.lookupWindow(foo);
    c.length -= 2;
    if (w == null) {
      c.errorValue = foo;
      c.errorReason = 3; // BadWindow;
      return;
    }
    int n = (short) io.readShort();
    int delta = (short) io.readShort();

    c.length--;

    if (n == 0) {
      return;
    }

    int[] atoms = new int[n];
    Property[] props = new Property[n];
    Property p;
    int i = 0;
    while (n != 0) {
      atoms[i] = io.readInt();
      c.length--;
      if (!Atom.valid(atoms[i])) {
        c.errorValue = atoms[i];
        c.errorReason = 5; // BadAtom
        return;
      }
      p = w.getProperty();
      while (p != null) {
        if (p.propertyName == atoms[i]) {
          props[i] = p;
          break;
        }
        p = p.next;
      }
      if (p == null) {
        c.errorReason = 8; // BadMatch
        return;
      }
      i++;
      n--;
    }
    for (int j = 0; j < atoms.length; j++) {
      for (int k = j + 1; k < atoms.length; k++) {
        if (atoms[j] == atoms[k]) {
          c.errorReason = 8; // BadMatch
          return;
        }
      }
    }
    if (((delta < 0 ? -1 * delta : delta) % atoms.length) != 0) {
      while (delta < 0) {
        delta += atoms.length;
      }
      for (i = 0; i < atoms.length; i++) {
        c.cevent.mkPropertyNotify(
            w.id,
            props[i].propertyName,
            (int) System.currentTimeMillis(),
            // Property.PropertyNewValue
            0);
        w.sendEvent(c.cevent, 1, null);
        props[i].propertyName = atoms[(i + delta) % atoms.length];
      }
    }
  }