Android Open Source - security-cam Protocol






From Project

Back to project page security-cam.

License

The source code is released under:

MIT License

If you think the Android project security-cam listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package berlin.reiche.securitas.model;
/*  w  w w. j a  v  a2s. c o  m*/
import android.os.Message;
import android.util.SparseArray;

/**
 * Protocol defining the REST API on which the client-server communication
 * functions.
 * 
 * @author Konrad Reiche
 * 
 */
public enum Protocol {

  /**
   * Register the device on the endpoint.
   */
  REGISTER_DEVICE(100, "/device/register"),

  /**
   * Unregisters the device from the endpoint.
   */
  UNREGISTER_DEVICE(101, "/device/unregister"),

  /**
   * Switch the server into the motion detection state.
   */
  START_DETECTION(102, "/motion/detection/start"),

  /**
   * Switch the server into the idle state.
   */
  STOP_DETECTION(103, "/motion/detection/stop"),

  /**
   * Download a specific motion snapshot.
   */
  DOWNLOAD_MOTION_SNAPSHOT(104, "/static/captures/"),

  /**
   * Issues the server to create a current snapshot and downloads this
   * snapshot afterwards.
   */
  DOWNLOAD_LATEST_SNAPSHOT(105, "/server/action/snapshot"),

  /**
   * Synchronize the client state with the server state.
   */
  RESTORE_CLIENT_STATE(106, "/server/status");

  /**
   * The integer code for representing the REST action. This is necessary in
   * order to be compatible with the {@link Message} methods.
   */
  public final int code;

  /**
   * The operation which defines a URI path.
   */
  public final String operation;

  /**
   * Default constructor.
   * 
   * @param code
   *            the integer representation of the REST URI.
   * @param operation
   *            the REST URI which identifies the action.
   */
  Protocol(int code, String operation) {
    this.code = code;
    this.operation = operation;
  }

  /**
   * Stores the different code integer values and maps them to their respect
   * {@link Protocol} enumeration constant. A sparse array is used, which maps
   * integers to objects and is more efficient in the implementation.
   */
  private static final SparseArray<Protocol> codes;

  static {
    Protocol[] values = Protocol.values();
    codes = new SparseArray<Protocol>(values.length);
    for (Protocol value : values) {
      codes.put(value.code, value);
    }
  }

  /**
   * Maps an integer code to the respective protocol action. This method is
   * used when processing messages. This way a {@link Protocol} instance can
   * be constructed and easily compared.
   * 
   * @param what
   *            the integer code.
   * @return the protocol instance.
   */
  public static Protocol valueOf(int what) {
    Protocol value = codes.get(what);
    if (value != null) {
      return codes.get(what);
    }
    throw new IllegalArgumentException();
  }
}




Java Source Code List

berlin.reiche.securitas.Client.java
berlin.reiche.securitas.Settings.java
berlin.reiche.securitas.activities.Action.java
berlin.reiche.securitas.activities.LauncherActivity.java
berlin.reiche.securitas.activities.MainActivity.java
berlin.reiche.securitas.activities.SettingsActivity.java
berlin.reiche.securitas.activities.package-info.java
berlin.reiche.securitas.controller.ClientController.java
berlin.reiche.securitas.controller.Controller.java
berlin.reiche.securitas.controller.GCMIntentService.java
berlin.reiche.securitas.controller.GCMReceiver.java
berlin.reiche.securitas.controller.InboxHandler.java
berlin.reiche.securitas.controller.states.ControllerState.java
berlin.reiche.securitas.controller.states.DetectionState.java
berlin.reiche.securitas.controller.states.IdleState.java
berlin.reiche.securitas.controller.states.package-info.java
berlin.reiche.securitas.controller.tasks.BitmapDownloadTask.java
berlin.reiche.securitas.controller.tasks.DetectionRequest.java
berlin.reiche.securitas.controller.tasks.DeviceRegistration.java
berlin.reiche.securitas.controller.tasks.StatusTask.java
berlin.reiche.securitas.controller.tasks.package-info.java
berlin.reiche.securitas.controller.package-info.java
berlin.reiche.securitas.model.ClientModel.java
berlin.reiche.securitas.model.Model.java
berlin.reiche.securitas.model.Protocol.java
berlin.reiche.securitas.model.package-info.java
berlin.reiche.securitas.util.FlushedInputStream.java
berlin.reiche.securitas.util.HttpUtilities.java
berlin.reiche.securitas.util.NotificationDialog.java
berlin.reiche.securitas.util.package-info.java
berlin.reiche.securitas.package-info.java