示例#1
0
  /** Performs the start action into the VNC Component. */
  public static synchronized void start(
      String host, int port, String protoVersion, String password, boolean bypassProxy) {

    if ((running) && (swtDisplay != null)) {

      if (swtDisplay.isActive()) {
        swtDisplay.stop();
      }

      try {

        HashMap<String, Object> parameters = new HashMap<String, Object>();
        String protocolId = ProtocolIdTranslator.getProtocolId(protoVersion);

        parameters.put("password", password); // $NON-NLS-1$
        parameters.put(
            "connectionRetries",
            swtDisplay //$NON-NLS-1$
                .getConnectionRetries());

        parameters.put("bypassProxy", new Boolean(bypassProxy)); // $NON-NLS-1$

        VNCViewerView.protocolHandle =
            PluginProtocolActionDelegate.requestStartProtocolAsClient(
                protocolId, new VNCProtocolExceptionHandler(), host, port, parameters);

        while (!PluginProtocolActionDelegate.isProtocolRunning(VNCViewerView.protocolHandle)) {
          Thread.sleep(500);
        }

        swtDisplay.start(protocolHandle);
        currentHost = host;
        currentPort = Integer.toString(port);

      } catch (Exception e) {

        log(VNCViewerView.class).error(VIEWER_COULD_NOT_BE_STARTED + e.getMessage());

        Canvas canvas = swtDisplay.getCanvas();
        if ((canvas != null) && (!canvas.isDisposed())) {
          GC gc = new GC(swtDisplay.getCanvas());
          gc.fillRectangle(0, 0, swtDisplay.getScreenWidth(), swtDisplay.getScreenHeight());
          gc.dispose();
        }
      }
    }
  }
示例#2
0
  private void sendAndroidMouseEventMessage(int x, int y) {
    ProtocolMessage message = new ProtocolMessage(VNC_POINTEREVENT_MESSAGE_CODE);
    message.setFieldValue("buttonMask", (buttonPressed ? 1 : 0));
    message.setFieldValue("x-position", x);
    message.setFieldValue("y-position", y);

    try {
      PluginProtocolActionDelegate.sendMessageToServer(getInstance().getProtocolHandle(), message);
    } catch (Exception e) {
      // Do nothing
    }
  }
示例#3
0
  @Override
  public void sendKey(int character, int keycode, Properties keyCodeMap) {
    ProtocolMessage message = new ProtocolMessage(VNC_KEYEVENT_MESSAGE_CODE);
    message.setFieldValue("padding", 0);
    message.setFieldValue("downFlag", 1);
    message.setFieldValue("key", keycode);

    try {
      PluginProtocolActionDelegate.sendMessageToServer(getInstance().getProtocolHandle(), message);
    } catch (Exception e) {
      // Do nothing
    }
  }
示例#4
0
  public static void stopProtocol() throws IOException {

    if (protocolHandle != null) {
      PluginProtocolActionDelegate.requestStopProtocol(protocolHandle);
    }
  }