// Copyright 2010-2021, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//     * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

syntax = "proto2";

package mozc;

option java_outer_classname = "ProtoEngineBuilder";
option java_package = "org.mozc.android.inputmethod.japanese.protobuf";

message EngineReloadRequest {
  // Specify the type of engine to build.
  enum EngineType {
    DESKTOP = 0;
    MOBILE = 1;
  }
  required EngineType engine_type = 1;

  // Path to the data file to be loaded in a new engine.
  required string file_path = 2;

  // If provided, also atomically renames |file_path| to this location.  Since
  // EngineBuilder validates the data file content before creating a new engine
  // instance, this option is useful when you want to perform i) data
  // verification, ii) install (file rename), and iii) engine reload at the same
  // time in Mozc server side.
  optional string install_location = 3;

  // Explicitly specifies the magic number to be used for data validation.
  // Since acceptable magic number is embedded in Mozc server, this option is
  // unnecessary for normal cases.  However, this is required for some unit
  // tests as test data has a different magic number.
  optional string magic_number = 4;
}

message EngineReloadResponse {
  enum Status {
    // Reload command is accepted.
    ACCEPTED = 0;

    // New data is verified and ready.
    RELOAD_READY = 1;

    // Engine was replaced by a new instance.
    RELOADED = 2;

    // The following are errors.

    // Failed to start reload because another reload job is currently running.
    ALREADY_RUNNING = 3;

    // Erros in data file.
    ENGINE_VERSION_MISMATCH = 4;
    DATA_MISSING = 5;
    DATA_BROKEN = 6;

    // File doesn't exist or underlying memory mapping failed.
    MMAP_FAILURE = 7;

    // File rename is failed.
    INSTALL_FAILURE = 8;

    UNKNOWN_ERROR = 9;
  }
  required Status status = 1;

  // The original request is copied in response for convenience (the reload
  // command runs asynchronously but client doesn't need to keep the original
  // request).
  optional EngineReloadRequest request = 2;
}
