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

4
.gitmodules vendored
View file

@ -1,4 +1,4 @@
[submodule "gomuks"]
path = gomuks
url = https://github.com/gomuks/gomuks
branch = main
url = https://github.com/Henry-Hiles/gomuks
branch = quad/chore/remove-root-set

2
gomuks

@ -1 +1 @@
Subproject commit 0e06c7b74f96d3e29a8101893ca1921d13a90573
Subproject commit 9e45ee426cc8be0bfada269f4abc4957c30e994e

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)