// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module ash.ime.mojom;

import "chromeos/ash/services/ime/public/mojom/user_data_japanese_dictionary.mojom";
import "mojo/public/mojom/base/big_string.mojom";

struct Status {
  bool success;
  // Reason is usually given for an error response.
  string? reason;
};

union JapaneseDictionaryResponse {
  string error_reason;
  array<JapaneseDictionary> dictionaries;
};

// InputMethodUserDataService is used to manage user data that requires the
// IME shared library to manage.
interface InputMethodUserDataService {
  // Fetches the Japanese user dictionaries used by Japanese IME.
  FetchJapaneseDictionary() => (JapaneseDictionaryResponse response);

  // Adds an entry into the Japanese dictionary specified by the dict_id.
  AddJapaneseDictionaryEntry(uint64 dict_id, JapaneseDictionaryEntry entry)
      => (Status status);

  // Edits an entry in the Japanese dictionary specified by the dict_id.
  EditJapaneseDictionaryEntry(
      uint64 dict_id, uint32 entry_index, JapaneseDictionaryEntry entry)
      => (Status status);

  // Deletes an entry at entry_index in the Japanese dictionary specified by the
  // dict_id.
  DeleteJapaneseDictionaryEntry(uint64 dict_id, uint32 entry_index)
      => (Status status);

  // Create a new Japanese dictionary with the name provided.
  CreateJapaneseDictionary(string dictionary_name) => (Status status);

  // Rename the Japanese dictionary specified by the dict_id.
  RenameJapaneseDictionary(uint64 dict_id, string dictionary_name)
      => (Status status);

  // Delete the Japanese dictionary specified by the dict_id.
  DeleteJapaneseDictionary(uint64 dict_id) => (Status status);

  // Get tab separated values that represent the dictionary.
  ExportJapaneseDictionary(uint64 dict_id)
      => (mojo_base.mojom.BigString result);

  // Import tab separated entries into the dictionary.
  // The tsv_data is a user provided dictionary that would be loaded from a file
  // and then sent directly to the sandboxed IMEService.
  ImportJapaneseDictionary(
      uint64 dict_id, mojo_base.mojom.BigString tsv_data) => (Status status);

  // Clears the Japanese personalization data on the device.
  // clear_conversion_history set to true will clear the conversion history for
  // Japanese input.
  // clear_suggestion_history set to true will clear the suggestion history for
  // Japanese input.
  ClearJapanesePersonalizationData(
      bool clear_conversion_history, bool clear_suggestion_history)
      => (Status status);
};
