set env for gomuks

Fixes #62
This commit is contained in:
Henry Hiles 2026-09-19 18:41:09 -04:00
commit 4f3b77f9f3
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
3 changed files with 16 additions and 12 deletions

View file

@ -54,8 +54,19 @@ import "package:path_provider/path_provider.dart";
class ClientController extends AsyncNotifier<int> {
@override
Future<int> build() async {
final path = "${(await getApplicationSupportDirectory()).path}/gomuks";
final handle = await init(path);
if (Platform.isAndroid || Platform.isIOS) {
final env = {
"GOMUKS_ROOT": (await getApplicationSupportDirectory()).path,
"GOMUKS_CACHE_HOME": (await getApplicationCacheDirectory()).path,
};
for (final MapEntry(:key, :value) in env.entries) {
GomuksSetEnv(
key.toNativeUtf8().cast<Char>(),
value.toNativeUtf8().cast<Char>(),
);
}
}
final handle = await Isolate.run(GomuksInit);
final callable =
NativeCallable<
@ -152,13 +163,6 @@ class ClientController extends AsyncNotifier<int> {
throw Exception("GomuksStart returned error code $errorCode");
}
Future<int> init(String path) => Isolate.run(
() => GomuksInit(
((Platform.isAndroid || Platform.isIOS) ? path.toNativeUtf8() : nullptr)
.cast(),
),
);
Future<dynamic> callGomuksMethod(
Map<String, dynamic> data,
FutureOr<GomuksResponse> Function(int handle, GomuksBorrowedBuffer data)