working build scripts
This commit is contained in:
parent
8d43313512
commit
058f68cffb
6 changed files with 78 additions and 101 deletions
|
|
@ -46,23 +46,14 @@ class ClientController extends Notifier<int> {
|
|||
return handle;
|
||||
}
|
||||
|
||||
(int requestId, Map<String, dynamic> response) sendCommand(
|
||||
String command,
|
||||
Map<String, dynamic> data,
|
||||
) {
|
||||
final responsePtr = calloc<GomuksBuffer>();
|
||||
try {
|
||||
final requestId = GomuksSubmitCommand(
|
||||
state,
|
||||
command.toNativeUtf8().cast<Char>(),
|
||||
data.toGomuksBuffer(),
|
||||
responsePtr,
|
||||
);
|
||||
void sendCommand(String command, Map<String, dynamic> data) {
|
||||
// final response = GomuksSubmitCommand(
|
||||
// state,
|
||||
// command.toNativeUtf8().cast<Char>(),
|
||||
// data.toGomuksBuffer(),
|
||||
// );
|
||||
|
||||
return (requestId, responsePtr.ref.toJson());
|
||||
} finally {
|
||||
calloc.free(responsePtr);
|
||||
}
|
||||
// return response.buf; TODO
|
||||
}
|
||||
|
||||
static final provider = NotifierProvider<ClientController, int>(
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@ import "package:ffi/ffi.dart";
|
|||
import "package:nexus/src/third_party/gomuks.g.dart";
|
||||
|
||||
extension GomuksBufferToJson on GomuksBorrowedBuffer {
|
||||
Uint8List toBytes() {
|
||||
if (base == nullptr || length <= 0) return Uint8List(0);
|
||||
return base.asTypedList(length);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final bytes = toBytes();
|
||||
if (bytes.isEmpty) return {};
|
||||
|
|
@ -14,21 +19,21 @@ extension GomuksBufferToJson on GomuksBorrowedBuffer {
|
|||
}
|
||||
|
||||
extension JsonToGomuksBuffer on Map<String, dynamic> {
|
||||
GomuksBuffer toGomuksBuffer() {
|
||||
final jsonString = json.encode(this);
|
||||
final bytes = utf8.encode(jsonString);
|
||||
// GomuksBorrowedBuffer toGomuksBuffer() {
|
||||
// final jsonString = json.encode(this);
|
||||
// final bytes = utf8.encode(jsonString);
|
||||
|
||||
final dataPtr = calloc<Uint8>(bytes.length);
|
||||
dataPtr.asTypedList(bytes.length).setAll(0, bytes);
|
||||
// final dataPtr = calloc<Uint8>(bytes.length);
|
||||
// dataPtr.asTypedList(bytes.length).setAll(0, bytes);
|
||||
|
||||
final bufPtr = calloc<GomuksBuffer>();
|
||||
bufPtr.ref.base = dataPtr;
|
||||
bufPtr.ref.length = bytes.length;
|
||||
// final bufPtr = calloc<GomuksBuffer>();
|
||||
// bufPtr.ref.base = dataPtr;
|
||||
// bufPtr.ref.length = bytes.length;
|
||||
|
||||
final bufByValue = bufPtr.ref;
|
||||
// final bufByValue = bufPtr.ref;
|
||||
|
||||
calloc.free(bufPtr);
|
||||
// calloc.free(bufPtr);
|
||||
|
||||
return bufByValue;
|
||||
}
|
||||
// return bufByValue;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ class App extends ConsumerWidget {
|
|||
"username": "quadradical",
|
||||
"password": "Quadmarad1!",
|
||||
});
|
||||
debugPrint("$response");
|
||||
return Placeholder();
|
||||
},
|
||||
// .betterWhen(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue