-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
202 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import 'package:sane/src/isolate_messages/interface.dart'; | ||
import 'package:sane/src/sane.dart'; | ||
import 'package:sane/src/structures.dart'; | ||
|
||
class CancelMessage implements IsolateMessage { | ||
CancelMessage({required this.handle}); | ||
CancelMessage({required this.saneHandle}); | ||
|
||
final SaneHandle handle; | ||
final SaneHandle saneHandle; | ||
|
||
@override | ||
Future<CancelResponse> handle(Sane sane) async { | ||
await sane.cancel(saneHandle); | ||
return CancelResponse(); | ||
} | ||
} | ||
|
||
class CancelResponse implements IsolateResponse {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import 'package:sane/sane.dart'; | ||
import 'package:sane/src/isolate_messages/interface.dart'; | ||
import 'package:sane/src/structures.dart'; | ||
|
||
class CloseMessage implements IsolateMessage { | ||
CloseMessage({required this.handle}); | ||
CloseMessage({required this.saneHandle}); | ||
|
||
final SaneHandle handle; | ||
final SaneHandle saneHandle; | ||
|
||
@override | ||
Future<CloseResponse> handle(Sane sane) async { | ||
await sane.close(saneHandle); | ||
return CloseResponse(); | ||
} | ||
} | ||
|
||
class CloseResponse implements IsolateResponse {} |
15 changes: 13 additions & 2 deletions
15
packages/sane/lib/src/isolate_messages/control_button_option.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 51 additions & 6 deletions
57
packages/sane/lib/src/isolate_messages/control_option.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,67 @@ | ||
import 'package:sane/src/isolate_messages/interface.dart'; | ||
import 'package:sane/src/sane.dart'; | ||
import 'package:sane/src/structures.dart'; | ||
|
||
class ControlOptionMessage<T> implements IsolateMessage { | ||
ControlOptionMessage({ | ||
required this.handle, | ||
class ControlValueOptionMessage<T> implements IsolateMessage { | ||
ControlValueOptionMessage({ | ||
required this.saneHandle, | ||
required this.index, | ||
required this.action, | ||
this.value, | ||
}); | ||
|
||
final SaneHandle handle; | ||
final SaneHandle saneHandle; | ||
final int index; | ||
final SaneAction action; | ||
final T? value; | ||
|
||
@override | ||
Future<ControlValueOptionResponse> handle(Sane sane) async { | ||
switch (value) { | ||
case final bool value: | ||
return ControlValueOptionResponse<bool>( | ||
result: await sane.controlBoolOption( | ||
handle: saneHandle, | ||
index: index, | ||
action: action, | ||
value: value, | ||
), | ||
); | ||
case final int value: | ||
return ControlValueOptionResponse<int>( | ||
result: await sane.controlIntOption( | ||
handle: saneHandle, | ||
index: index, | ||
action: action, | ||
value: value, | ||
), | ||
); | ||
case final double value: | ||
return ControlValueOptionResponse<double>( | ||
result: await sane.controlFixedOption( | ||
handle: saneHandle, | ||
index: index, | ||
action: action, | ||
value: value, | ||
), | ||
); | ||
case final String value: | ||
return ControlValueOptionResponse<String>( | ||
result: await sane.controlStringOption( | ||
handle: saneHandle, | ||
index: index, | ||
action: action, | ||
value: value, | ||
), | ||
); | ||
default: | ||
throw Exception('Invalid value type.'); | ||
} | ||
} | ||
} | ||
|
||
class ControlOptionResponse<T> implements IsolateResponse { | ||
ControlOptionResponse({required this.result}); | ||
class ControlValueOptionResponse<T> implements IsolateResponse { | ||
ControlValueOptionResponse({required this.result}); | ||
|
||
final SaneOptionResult<T> result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import 'package:sane/src/isolate_messages/interface.dart'; | ||
import 'package:sane/src/sane.dart'; | ||
|
||
class ExitMessage implements IsolateMessage {} | ||
class ExitMessage implements IsolateMessage { | ||
@override | ||
Future<ExitResponse> handle(Sane sane) async { | ||
await sane.exit(); | ||
return ExitResponse(); | ||
} | ||
} | ||
|
||
class ExitResponse implements IsolateResponse {} |
12 changes: 10 additions & 2 deletions
12
packages/sane/lib/src/isolate_messages/get_all_option_descriptors.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
packages/sane/lib/src/isolate_messages/get_option_descriptor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
packages/sane/lib/src/isolate_messages/get_parameters.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
interface class IsolateMessage {} | ||
import 'package:sane/src/sane.dart'; | ||
|
||
interface class IsolateResponse {} | ||
abstract interface class IsolateMessage { | ||
Future<IsolateResponse> handle(Sane sane); | ||
} | ||
|
||
abstract interface class IsolateResponse {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
import 'package:sane/src/isolate_messages/interface.dart'; | ||
import 'package:sane/src/sane.dart'; | ||
import 'package:sane/src/structures.dart'; | ||
|
||
class SetIOModeMessage implements IsolateMessage { | ||
SetIOModeMessage({ | ||
required this.handle, | ||
required this.saneHandle, | ||
required this.ioMode, | ||
}); | ||
|
||
final SaneHandle handle; | ||
final SaneHandle saneHandle; | ||
final SaneIOMode ioMode; | ||
|
||
@override | ||
Future<SetIOModeResponse> handle(Sane sane) async { | ||
await sane.setIOMode(saneHandle, ioMode); | ||
return SetIOModeResponse(); | ||
} | ||
} | ||
|
||
class SetIOModeResponse implements IsolateResponse {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import 'package:sane/src/isolate_messages/interface.dart'; | ||
import 'package:sane/src/sane.dart'; | ||
import 'package:sane/src/structures.dart'; | ||
|
||
class StartMessage implements IsolateMessage { | ||
StartMessage({required this.handle}); | ||
StartMessage({required this.saneHandle}); | ||
|
||
final SaneHandle handle; | ||
final SaneHandle saneHandle; | ||
|
||
@override | ||
Future<StartResponse> handle(Sane sane) async { | ||
await sane.start(saneHandle); | ||
return StartResponse(); | ||
} | ||
} | ||
|
||
class StartResponse implements IsolateResponse {} |
Oops, something went wrong.