Example #1
0
 public IFormBuilder apply(Alts.AltChooser altChooser) {
   String s = Alts.chooseElement(alts, this, altChooser);
   if (s != null) {
     FormBuilder formBuilder = new FormBuilder();
     formBuilder.add(s);
     return formBuilder;
   } else {
     return null;
   }
 }
  private String setupAuthentication(String response) throws IOException, URISyntaxException {
    isStartup = false;
    // Pattern pattern = Pattern.compile("Auth=(?<AUTH>(.*?))$", Pattern.CASE_INSENSITIVE);
    // String auth = pattern.matcher(EntityUtils.toString(response.getEntity())).group();

    int startIndex = response.indexOf("Auth=") + "Auth=".length();
    int endIndex = response.indexOf("\n", startIndex);

    authorizationToken = response.substring(startIndex, endIndex).trim();
    return dispatchPost(
        new URI("https://play.google.com/music/listen?hl=en&u=0"), FormBuilder.getEmpty());
  }
  @Override
  public final synchronized String dispatchPost(URI address, FormBuilder form)
      throws IOException, URISyntaxException {
    HttpURLConnection connection = prepareConnection(address, true, "POST");
    if (!Strings.isNullOrEmpty(form.getContentType())) {
      connection.setRequestProperty("Content-Type", form.getContentType());
    }
    connection.connect();
    connection.getOutputStream().write(form.getBytes());
    if (connection.getResponseCode() != 200) {
      throw new IllegalStateException(
          "Statuscode " + connection.getResponseCode() + " not supported");
    }

    String response = IOUtils.toString(connection.getInputStream());

    setCookie(connection);

    if (!isStartup) {
      return response;
    }
    return setupAuthentication(response);
  }
Example #4
0
  /** untuk menjalankan ini harus sudah build label dan build form */
  public void buildPanel() {
    panel = new JPanel(new BorderLayout());
    panelForm = builder.getPanel();

    panelForm.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              if (master != null) {
                if (master.isPerspectiveDefault()) {
                  if (typeEfectWidget == WIDGET_1) {
                    master.perspective1();
                  } else if (typeEfectWidget == WIDGET_2) {
                    master.perspective2();
                  } else if (typeEfectWidget == WIDGET_3) {
                    master.perspective3();
                  } else if (typeEfectWidget == WIDGET_4) {
                    master.perspective4();
                  }
                } else {
                  master.perspectiveDefault();
                }
              } else {
                App.showErrSementara("Master null");
              }
            }
          }

          public void mouseReleased(MouseEvent e) {}
        });

    pane = new JScrollPane(panelForm);

    pane.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    panel.add(pane, BorderLayout.CENTER);
    panel.add(label, BorderLayout.NORTH);
  }