@namespace("keybase.1")

protocol kbfsCommon {
  enum FSStatusCode {
    START_0,
    FINISH_1,
    ERROR_2
  }

  enum FSNotificationType {
    ENCRYPTING_0,
    DECRYPTING_1,
    SIGNING_2,
    VERIFYING_3,
    REKEYING_4,
    CONNECTION_5,
    MD_READ_SUCCESS_6,
    FILE_CREATED_7,
    FILE_MODIFIED_8,
    FILE_DELETED_9,
    FILE_RENAMED_10
  }

  enum FSErrorType {
    ACCESS_DENIED_0,
    USER_NOT_FOUND_1,
    REVOKED_DATA_DETECTED_2,
    NOT_LOGGED_IN_3,
    TIMEOUT_4,
    REKEY_NEEDED_5,
    BAD_FOLDER_6,
    NOT_IMPLEMENTED_7,
    OLD_VERSION_8,
    OVER_QUOTA_9,
    NO_SIG_CHAIN_10,
    TOO_MANY_FOLDERS_11,
    EXDEV_NOT_SUPPORTED_12
  }

  record FSNotification {
    boolean publicTopLevelFolder;
    string filename;
    string status;
    FSStatusCode statusCode;
    FSNotificationType notificationType;
    FSErrorType errorType;
    map<string> params;
    @lint("ignore")
    UID writerUid;
    Time localTime;
  }

  record FSEditListRequest {
    Folder folder;
    int requestID;
  }

  record FSSyncStatusRequest {
    int requestID;
  }

  record FSPathSyncStatus {
    boolean publicTopLevelFolder;
    string path;  // could be a file or directory
    // How many total encrypted, padded bytes are still syncing, as part of
    // operations on this path.
    int64 syncingBytes;
    // How many outstanding operations are there for this path?
    int64 syncingOps;

    // If this notification happened due to a completed sync for this
    // path, how many bytes just finished syncing?
    int64 syncedBytes;
  }

  record FSSyncStatus {
    // How many total encrypted, padded bytes are still syncing, across
    // all TLFs?
    int64 totalSyncingBytes;
    // How many outstanding operations are there across all TLFs?
    int64 totalSyncingOps;
    // Individual status for each path without standing operations.
    array<FSPathSyncStatus> pathStatuses;
  }
}
