Exemplo n.º 1
0
  void displayWifiPassword() {
    Config config = Config.instance();
    config.setEmail(emailField.getText());
    config.setRememberPassword(rememberPasswordCheckbox.getState());
    config.setPassword(passField.getText());

    config.updateConfig();

    if (Config.instance().getQRImage() == null || Config.instance().getWifiPassword().isEmpty()) {
      if (Config.instance().getWifiPassword().isEmpty()) {
        wifiPasswordField.setText("");
      }

      hintLabel.setText("QRCode has not been generated");
      qrCodeLabel.setIcon(idleIcon);
      return;
    }

    try {

      wifiPasswordField.setText(Config.instance().getWifiPassword());

      BufferedImage qrImage = Config.instance().getQRImage();

      int width = qrCodeLabel.getWidth();
      int height = qrCodeLabel.getHeight();

      // make a square image
      int length = width < height ? width : height;

      ImageIcon imgIcon = new ImageIcon();
      imgIcon.setImage(qrImage.getScaledInstance(length, length, Image.SCALE_AREA_AVERAGING));

      hintLabel.setText("Scan QRCode with mobile client to login clear-guest!");
      wifiPasswordField.setText(Config.instance().getWifiPassword());
      qrCodeLabel.setIcon(imgIcon);
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          mainPanel,
          "Failed to generate QR Image, please try again",
          "QRCode Generation Failed",
          JOptionPane.ERROR_MESSAGE);
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
  void fetchPassword() {
    Config config = Config.instance();
    config.updateConfig(
        this.emailField.getText(),
        this.passField.getText(),
        "",
        this.rememberPasswordCheckbox.getState());

    if (config.getEmail().isEmpty() || config.getPassword().isEmpty()) {
      JOptionPane.showMessageDialog(
          mainPanel, "Empty email or SSO password", "Bad SSO Account", JOptionPane.ERROR_MESSAGE);
      return;
    }

    taskThread = new TwoTaskThread(TwoTaskThread.GEN_PASSWORD | TwoTaskThread.GEN_QRCODE);

    setBusy();
    taskThread.start();
    timer.start();
  }