Esempio n. 1
0
  /** Displays the existing messages and offer the option to send a new one. */
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/html");
    PrintWriter out = resp.getWriter();

    out.print("<html><body>");
    out.print("<head>");
    out.print("  <title>GCM Demo</title>");
    out.print("  <link rel='icon' href='favicon.png'/>");
    out.print("</head>");
    String status = (String) req.getAttribute(ATTRIBUTE_STATUS);
    if (status != null) {
      out.print(status);
    }
    int total = Datastore.getTotalDevices();
    if (total == 0) {
      out.print("<h2>No devices registered!</h2>");
    } else {
      out.print("<h2>" + total + " device(s) registered!</h2>");
      out.print("<form name='form' method='POST' action='sendAll'>");
      out.print("<input type='submit' value='Send Message' />");
      out.print("</form>");
    }
    out.print("</body></html>");
    resp.setStatus(HttpServletResponse.SC_OK);
  }
  /** Displays the existing messages and offer the option to send a new one. */
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/html");
    resp.setCharacterEncoding("utf-8");
    PrintWriter out = resp.getWriter();

    out.print("<html><body>");
    out.print("<head>");
    out.print("  <title>Agnes Backdoor</title>");
    out.print("  <link rel='icon' href='/favicon.ico'/>");
    out.print("  <meta charset='utf-8' />");
    out.print("</head>");
    out.print(
        "<body style=\"background-image:url('matrix.png'); color:white;text-align:center\"><div style=\"display:inline-block;background-color: rgba(0%, 0%, 0%, 0.7)\">");
    String status = (String) req.getAttribute(ATTRIBUTE_STATUS);
    if (status != null) {
      out.print(status);
    }
    int total = Datastore.getTotalDevices();
    if (total == 0) {
      out.print("<h2>No slaves registered!</h2>");
    } else {
      out.print("<h3>" + total + " slave devices active!</h3>");
      out.print("<h2>Override AI behavior (Version code >= 15):</h2>");
      out.print(
          "<p>Last message: <span style='color: #E00; font-size: 20;'>"
              + Datastore.readLastMessage()
              + "</span></p>");
      out.print("<form name='form' method='POST' action='sendAll'>");
      out.print("<textarea name='message' cols='40' rows='4'></textarea><br />");
      out.print(
          "<input type='checkbox' name='notify' value='true' /> Flood their notifications<br />");
      out.print(
          "<input type='checkbox' name='vibrate' value='true' /> Vibrate-shock their pockets<br />");
      out.print(
          "<input type='checkbox' name='append' value='false' /> Append message to dialog<br />");
      out.print("<br />Choose the UI<br />");
      out.print("Agnes <input type='radio' name='ui_name' value='Agnes'>");
      out.print("Eddie <input type='radio' name='ui_name' value='Eddie' checked='checked'><br />");
      out.print("<input type='submit' value='Push to all humans' />");
      out.print("</form>");
      out.print("<h2>Update hard-wired personality files:</h2>");
      out.print("<form name='form' method='POST' action='sendAll'>");
      out.print("<input type='hidden' name='update' value='true' />");
      out.print("<input type=\"submit\" value=\"Let's hope she won't notice\" />");
      out.print("</form>");
    }
    out.print("</div></body></html>");
    resp.setStatus(HttpServletResponse.SC_OK);
  }