예제 #1
0
 public static void runOnEventThread(Runnable r) {
   if (Application.isEventDispatchThread()) {
     r.run();
   } else {
     Application.getApplication().invokeLater(r);
   }
 }
예제 #2
0
  private void processPushMessage(final byte[] data) {
    Application.getApplication()
        .invokeLater(
            new Runnable() {
              public void run() {
                String msg = new String(data);
                LOG.TRACE("Triger sync on PUSH message [" + msg + " ]\n");

                String[] op;
                String[] ops = split(msg, "\n");
                for (int loop = 0; loop < ops.length; loop++) {
                  if (ops[loop].startsWith("do_sync")) {
                    op = splitOnce(ops[loop], "=");
                    if (op.length <= 1 || "all".equalsIgnoreCase(op[1])) {
                      SyncThread.doSyncAllSources();
                    } else if ((op[1] != null) && (op[1].length() > 0)) {
                      SyncThread.doSyncSource(op[1].trim());
                    }
                  } else if (ops[loop].startsWith("show_popup")) {
                    op = splitOnce(ops[loop], "=");
                    if (op.length > 1) {
                      showPopup(op[1]);
                    }
                  } else if (ops[loop].startsWith("vibrate")) {
                    op = splitOnce(ops[loop], "=");
                    if (op.length > 1) {
                      vibrate(op[1]);
                    } else {
                      vibrate("2500");
                    }
                  } else if (ops[loop].startsWith("play_file")) {
                    op = splitOnce(ops[loop], "=");
                    if (op.length > 1) {
                      op = splitOnce(op[1], ",");
                      if (op.length > 1) {
                        play_file(op[0], op[1]);
                      } else {
                        play_file(op[0], null);
                      }
                    }
                  }
                }
              }
            });
  }
  protected void respondAdmin(HttpServletRequest req, HttpServletResponse res) throws IOException {
    res.setContentType("text/xml");
    StringBuffer buf = new StringBuffer();

    String _details = req.getParameter("details");
    boolean details = (_details != null && _details.equals("1"));

    ConnectionGroup.dumpGroupsXML(buf, details);

    String appName = req.getParameter("application");
    if (appName != null && !appName.equals("")) {
      if (appName.equals("*")) {
        Application.dumpApplicationsXML(buf, details);
      } else {
        Application application = Application.getApplication(appName, false);
        if (application != null) application.toString();
      }
    }

    ConnectionAgent.dumpAgentsXML(buf, details);

    ServletOutputStream out = res.getOutputStream();
    try {
      out.println(
          "<connection-info "
              + " max-message-length=\""
              + HTTPConnection.getMaxMessageLen()
              + "\""
              + " connection-length=\""
              + HTTPConnection.getConnectionLength()
              + "\""
              + " reconnection-wait-interval=\""
              + HTTPConnection.getReconnectionWaitInterval()
              + "\""
              + " >");
      out.println(buf.toString());
      out.println("</connection-info>");
    } finally {
      FileUtils.close(out);
    }
  }