Ejemplo n.º 1
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();
  }
Ejemplo n.º 2
0
  public MainWindow() {
    Config config = Config.instance();

    {
      URL url = MainWindow.class.getResource("/idle.png");
      if (url != null) {
        idleIcon = new ImageIcon(url);
      }

      url = MainWindow.class.getResource("/wait_cursor.gif");
      if (url != null) {
        waitIcon = new ImageIcon(url);
      }
    }

    loadGUI();

    timer =
        new Timer(
            100,
            new ActionListener() {
              public void actionPerformed(ActionEvent arg0) {
                if (!taskThread.isAlive()) {
                  // task finished without errors
                  if (!taskThread.error.isEmpty()) {
                    if (taskThread.isGenPassword() && Config.instance().wifiPassword.isEmpty()) {
                      passField.setText("");
                      JOptionPane.showMessageDialog(
                          mainPanel,
                          "Invalid SSO info, please try again:" + taskThread.error,
                          "Login Failed",
                          JOptionPane.ERROR_MESSAGE);
                    } else if (taskThread.isGenQRCode()) {
                      JOptionPane.showMessageDialog(
                          mainPanel,
                          "Failed to generate QR Image, please try again: " + taskThread.error,
                          "QRCode Generation Failed",
                          JOptionPane.ERROR_MESSAGE);
                    }
                  }
                  timer.stop();
                  taskThread = null;

                  displayWifiPassword();

                  buttonGetPassword.setText(idleButtonText);
                  buttonGetPassword.setEnabled(true);
                }
              }
            });

    if (!config.getWifiPassword().isEmpty()) {
      taskThread = new TwoTaskThread(TwoTaskThread.GEN_QRCODE);

      qrCodeLabel.setIcon(waitIcon);

      setBusy();
      taskThread.start();
      timer.start();
    } else if (!(config.getEmail().isEmpty() || config.getPassword().isEmpty())) {
      fetchPassword();
    } else {
      qrCodeLabel.setIcon(idleIcon);
    }
  }