turn off macos sandbox mode; ffi refactor to get library path so isolate polling appbus events always gets new platform updates
This commit is contained in:
parent
8e3ba6af1c
commit
3f22dd83b1
|
@ -67,25 +67,35 @@ typedef GetJsonBlobFromStrStrStrFn = Pointer<Utf8> Function(Pointer<Utf8>, int,
|
|||
typedef appbus_events_function = Pointer<Utf8> Function();
|
||||
typedef AppbusEventsFn = Pointer<Utf8> Function();
|
||||
|
||||
const String UNSUPPORTED_OS = "unsupported-os";
|
||||
|
||||
class CwtchFfi implements Cwtch {
|
||||
late DynamicLibrary library;
|
||||
late CwtchNotifier cwtchNotifier;
|
||||
late Isolate cwtchIsolate;
|
||||
ReceivePort _receivePort = ReceivePort();
|
||||
|
||||
CwtchFfi(CwtchNotifier _cwtchNotifier) {
|
||||
static String getLibraryPath() {
|
||||
if (Platform.isWindows) {
|
||||
library = DynamicLibrary.open("libCwtch.dll");
|
||||
return "libCwtch.dll";
|
||||
} else if (Platform.isLinux) {
|
||||
library = DynamicLibrary.open("libCwtch.so");
|
||||
return "libCwtch.so";
|
||||
} else if (Platform.isMacOS) {
|
||||
print(dirname(Platform.script.path));
|
||||
library = DynamicLibrary.open("libCwtch.dylib");
|
||||
return "libCwtch.dylib";
|
||||
} else {
|
||||
return UNSUPPORTED_OS;
|
||||
}
|
||||
}
|
||||
|
||||
CwtchFfi(CwtchNotifier _cwtchNotifier) {
|
||||
String library_path = getLibraryPath();
|
||||
if (library_path == UNSUPPORTED_OS) {
|
||||
print("OS ${Platform.operatingSystem} not supported by cwtch/ffi");
|
||||
// emergency, ideally the app stays on splash and just posts the error till user closes
|
||||
exit(0);
|
||||
}
|
||||
library = DynamicLibrary.open(library_path);
|
||||
cwtchNotifier = _cwtchNotifier;
|
||||
}
|
||||
|
||||
|
@ -160,12 +170,7 @@ class CwtchFfi implements Cwtch {
|
|||
|
||||
// Steam of appbus events. Call blocks in libcwtch-go GetAppbusEvent. Static so the isolate can use it
|
||||
static Stream<String> pollAppbusEvents() async* {
|
||||
late DynamicLibrary library;
|
||||
if (Platform.isWindows) {
|
||||
library = DynamicLibrary.open("libCwtch.dll");
|
||||
} else if (Platform.isLinux) {
|
||||
library = DynamicLibrary.open("libCwtch.so");
|
||||
}
|
||||
late DynamicLibrary library = DynamicLibrary.open(getLibraryPath());
|
||||
|
||||
var getAppbusEventC = library.lookup<NativeFunction<appbus_events_function>>("c_GetAppBusEvent");
|
||||
// ignore: non_constant_identifier_names
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<false/>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.server</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<false/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
</dict>
|
||||
|
|
Loading…
Reference in New Issue