syntax = "proto2";

package Protocol.Data.File;

message Packet {
    optional FileHeader file_header = 1;
    optional FileHeaderAck file_header_ack = 2;
    optional FileHeaderResponse file_header_response = 3;
    optional FileChunk file_chunk = 4;
    optional FileChunkAck file_chunk_ack = 5;
    optional FileTransferCompleteNotification file_transfer_complete_notification = 6;
}

message FileHeader {
    optional uint32 file_id = 1;
    optional uint64 file_size = 2;
    optional string name = 3;
    optional bytes file_hash = 4;
}

message FileHeaderAck {
    optional uint32 file_id = 1;
    optional bool accepted = 2 [default = false];
}

message FileHeaderResponse {
    optional uint32 file_id = 1;
    optional int32 response = 2;
}

message FileChunk {
    optional uint32 file_id = 1;
    optional bytes chunk_data = 2;
}
message FileChunkAck {
    optional uint32 file_id = 1;
    optional uint64 bytes_received = 2;
}

enum FileTransferResult {
    Success = 0;
    Failure = 1;
    Cancelled = 2;
}

message FileTransferCompleteNotification {
    optional uint32 file_id = 1;
    optional FileTransferResult result = 2;
}