示例#1
0
 public void disconnect() {
   for (RdpConnectionOvd connection : this.co) {
     if (connection != null && connection.isConnected()) connection.disconnect();
   }
 }
示例#2
0
  private void parseOptions(Params params) throws RdesktopException {
    byte flags = 0x00;

    if (params.seamless) flags |= RdpConnectionOvd.MODE_APPLICATION;
    else flags |= RdpConnectionOvd.MODE_DESKTOP;

    if (params.multimedia) flags |= RdpConnectionOvd.MODE_MULTIMEDIA;

    RdpConnectionOvd connection = new RdpConnectionOvd(flags);

    if (params.shell != null) connection.setShell(params.shell);
    if (params.seamless) {
      Rectangle maxWindowSize =
          GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
      params.width = maxWindowSize.width - maxWindowSize.x;
      params.height = maxWindowSize.height - maxWindowSize.y;

      if (params.shell.equalsIgnoreCase(seamlessShell)
          || params.shell.equalsIgnoreCase(seamlessShell.concat(".exe")))
        connection.setSeamForm(true);
      connection.getSeamlessChannel().setMainFrame(this);
    }

    connection.setServer(params.server, params.port);
    connection.setCredentials(params.username, params.password);
    connection.setGraphic(params.width, params.height, params.bpp);

    connection.setPacketCompression(params.packetCompression);

    connection.setVolatileCaching(params.volatileCache);
    if (params.volatileCache && params.persistentCache) {
      connection.setPersistentCaching(true);
      connection.setPersistentCachingPath(params.persistentCachePath);
      connection.setPersistentCachingMaxSize(params.persistentCacheMaxSize);
    }

    connection.initSecondaryChannels();

    connection.addRdpListener(this);

    connection.setKeymap(LayoutDetector.get());
    this.co.add(connection);
  }
示例#3
0
 public void connect() throws OvdException {
   for (RdpConnectionOvd connection : this.co) connection.connect();
 }
示例#4
0
  private void initOVDSession(Params params) throws RdesktopException {
    if (params.ovd_mode == Properties.MODE_REMOTEAPPS) this.ovd_mode_application = true;

    SessionManagerCommunication sm =
        new SessionManagerCommunication(
            params.server, SessionManagerCommunication.DEFAULT_PORT, true);
    try {
      sm.askForSession(params.username, params.password, new Properties(params.ovd_mode));
    } catch (SessionManagerException ex) {
      RdpClient.logger.error("Unable to ask session: " + ex.getMessage());
    }

    Properties response = sm.getResponseProperties();
    int mode = response.getMode();
    if (mode != params.ovd_mode) {
      RdpClient.logger.error("Unable to get the request session mode");
      return;
    }

    byte flags = 0x00;
    Dimension screenSize = null;

    if (mode == Properties.MODE_DESKTOP) {
      flags |= RdpConnectionOvd.MODE_DESKTOP;
      screenSize = new Dimension(params.width, params.height);
    } else {
      flags |= RdpConnectionOvd.MODE_APPLICATION;
      screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    }

    if (response.isMultimedia()) flags |= RdpConnectionOvd.MODE_MULTIMEDIA;

    if (response.isPrinters()) flags |= RdpConnectionOvd.MOUNT_PRINTERS;

    for (ServerAccess server : sm.getServers()) {
      RdpConnectionOvd rc = null;

      try {
        rc = new RdpConnectionOvd(flags);
      } catch (RdesktopException ex) {
        RdpClient.logger.error("Unable to create RdpConnectionOvd object: " + ex.getMessage());
        return;
      }

      try {
        rc.initSecondaryChannels();
      } catch (RdesktopException ex) {
        RdpClient.logger.error(
            "Unable to init channels of RdpConnectionOvd object: " + ex.getMessage());
      }

      rc.setServer(server.getHost());
      rc.setCredentials(server.getLogin(), server.getPassword());
      // Ensure that width is multiple of 4
      // Prevent artifact on screen with a with resolution
      // not divisible by 4
      rc.setGraphic(
          (int) screenSize.width & ~3, (int) screenSize.height, RdpConnectionOvd.DEFAULT_BPP);

      for (org.ulteo.ovd.sm.Application appItem : server.getApplications()) {
        try {
          Application app =
              new Application(
                  rc,
                  appItem.getId(),
                  appItem.getName(),
                  appItem.getMimes(),
                  sm.askForIcon(Integer.toString(appItem.getId())));
          rc.addApp(app);
        } catch (SessionManagerException ex) {
          RdpClient.logger.warn(
              "Cannot get the \"" + appItem.getName() + "\" icon: " + ex.getMessage());
        }
      }

      this.co.add(rc);
    }

    List<ServerAccess> servers = sm.getServers();
    for (RdpConnectionOvd rc : this.co) {
      if (!this.ovd_mode_application) rc.setGraphic(params.width, params.height);
      rc.addRdpListener(this);
    }
  }