syntax = "proto3";

package rpcscanning;

service RpcScanner {
	rpc InitializeScanner(ScannerConfiguration) returns (Empty) {}
	
	rpc Scan(Empty) returns (stream .rpcscanning.RpcMessage) {}
	rpc StopScanning(Empty) returns (Empty) {}
	rpc ReleaseScanner(Empty) returns (Empty) {}
	
	rpc BatchAborted(Empty) returns (stream Empty) {}
	
	rpc GetConnectedScanners(Empty) returns (ScannerModelNames) {}
	rpc GetInstalledScanners(Empty) returns (ScannerModelNames) {}
	rpc ConfigureViaGui(Hwnd) returns (Empty) {}
}

message Empty {
}

message Hwnd {
	int32 handle = 1;
}

message DocumentsScanned {
	int32 Scanned = 1;
}

message Error {
	int32 ErrorCode = 1;
	string ErrorText = 2;
}

message RpcMessage
{
.rpcscanning.EventType EventType = 1;
.rpcscanning.Document Document = 2;
string ErrorMessage = 3;
int32 ErrorCode = 4;
}

enum EventType {
	NewScannedDocument = 0;
	FeederEmpty = 1;
	Exception = 2;
}

message Document {
	bytes FrontImage = 1;
	bytes BackImage = 2;
	bool AreDeskewed = 3;
	bool Cancel = 4;
	string FrontImageHash = 5;
	string BackImageHash = 6;
}

message ScannerConfiguration {
	string DriverDescription = 1;
	string ConfigFile = 2;
}

message ScannerModelNames {
	repeated string DriverDescriptions = 1;
}
