diff --git a/app/src/main/java/app/logorrr/OsxBridge.java b/app/src/main/java/app/logorrr/OsxBridge.java
index 69f3d78d..da2ec541 100644
--- a/app/src/main/java/app/logorrr/OsxBridge.java
+++ b/app/src/main/java/app/logorrr/OsxBridge.java
@@ -4,9 +4,25 @@
* Provides interface methods for native code
*/
public class OsxBridge {
-
+ /**
+ * register a file in the macosx permission system
+ *
+ * @param path absolute path to the file
+ */
public static native void registerPath(String path);
+ /**
+ * release a path (if the path is no longer used for example)
+ *
+ * @param path absolute path to the file
+ */
public static native void releasePath(String path);
+ /**
+ * open an url via the native browser
+ *
+ * @param url the url to open, for example https://www.logorrr.app/
+ */
+ public static native void openUrl(String url);
+
}
diff --git a/app/src/main/scala/app/logorrr/services/hostservices/NativeHostServices.scala b/app/src/main/scala/app/logorrr/services/hostservices/NativeHostServices.scala
index d65b53f0..76874b91 100644
--- a/app/src/main/scala/app/logorrr/services/hostservices/NativeHostServices.scala
+++ b/app/src/main/scala/app/logorrr/services/hostservices/NativeHostServices.scala
@@ -1,9 +1,19 @@
package app.logorrr.services.hostservices
+import app.logorrr.OsxBridge
+import app.logorrr.util.OsUtil
import javafx.application.HostServices
class NativeHostServices(hostServices: => HostServices) extends LogoRRRHostServices {
- override def showDocument(url: String): Unit = hostServices.showDocument(url)
+ override def showDocument(url: String): Unit = {
+ // hostServices.showDocument doesn't work with Entitlements / Gatekeeper
+ // delegate to native method
+ if (OsUtil.isMac) {
+ OsxBridge.openUrl(url)
+ } else {
+ hostServices.showDocument(url)
+ }
+ }
}
diff --git a/dist/dist-osx/installer-osx/src/main/installer/LogoRRR.entitlements.xml b/dist/dist-osx/installer-osx/src/main/installer/LogoRRR.entitlements.xml
index 2718cf4d..8365989b 100644
--- a/dist/dist-osx/installer-osx/src/main/installer/LogoRRR.entitlements.xml
+++ b/dist/dist-osx/installer-osx/src/main/installer/LogoRRR.entitlements.xml
@@ -23,5 +23,8 @@
com.apple.security.files.bookmarks.app-scope
+
+ com.apple.security.network.client
+
\ No newline at end of file
diff --git a/native/native-osx/src/main/c/LogoRRRSwift.swift b/native/native-osx/src/main/c/LogoRRRSwift.swift
index 1d69b5f0..2fa30c5d 100644
--- a/native/native-osx/src/main/c/LogoRRRSwift.swift
+++ b/native/native-osx/src/main/c/LogoRRRSwift.swift
@@ -1,4 +1,15 @@
import Foundation
+import Cocoa
+
+@_cdecl("openUrl")
+public func openUrl(path : UnsafePointer) {
+ if let urlString = String(validatingUTF8: path) {
+ if let url = URL(string: urlString) {
+ NSWorkspace.shared.open(url)
+ }
+ }
+}
+
@_cdecl("releasePath")
public func releasePath(path: UnsafePointer) {
diff --git a/native/native-osx/src/main/c/OsxBridge.c b/native/native-osx/src/main/c/OsxBridge.c
index d351f760..ff5cb45e 100644
--- a/native/native-osx/src/main/c/OsxBridge.c
+++ b/native/native-osx/src/main/c/OsxBridge.c
@@ -5,7 +5,7 @@
JNIEXPORT void JNICALL Java_app_logorrr_OsxBridge_registerPath(JNIEnv *env, jobject obj, jstring path) {
const char *pathChars = (*env)->GetStringUTFChars(env, path, NULL);
- if (pathChars != NULL) {
+ if (pathChars != NULL) {
// Call the Swift function from C
registerPath(pathChars);
@@ -14,11 +14,19 @@ JNIEXPORT void JNICALL Java_app_logorrr_OsxBridge_registerPath(JNIEnv *env, jobj
}
}
-
JNIEXPORT void JNICALL Java_app_logorrr_OsxBridge_releasePath(JNIEnv *env, jobject obj, jstring path) {
const char *pathChars = (*env)->GetStringUTFChars(env, path, NULL);
- if (pathChars != NULL) {
+ if (pathChars != NULL) {
releasePath(pathChars);
(*env)->ReleaseStringUTFChars(env, path, pathChars);
- }
+ }
}
+
+JNIEXPORT void JNICALL Java_app_logorrr_OsxBridge_openUrl(JNIEnv *env, jobject obj, jstring path) {
+ const char *urlChars = (*env)->GetStringUTFChars(env, path, NULL);
+ if (urlChars != NULL) {
+ openUrl(urlChars);
+ (*env)->ReleaseStringUTFChars(env, path, urlChars);
+ }
+}
+
diff --git a/native/native-osx/src/main/c/app_logorrr_OsxBridge.h b/native/native-osx/src/main/c/app_logorrr_OsxBridge.h
index 90857d67..950f4fb2 100644
--- a/native/native-osx/src/main/c/app_logorrr_OsxBridge.h
+++ b/native/native-osx/src/main/c/app_logorrr_OsxBridge.h
@@ -23,6 +23,14 @@ JNIEXPORT void JNICALL Java_app_logorrr_OsxBridge_registerPath
JNIEXPORT void JNICALL Java_app_logorrr_OsxBridge_releasePath
(JNIEnv *, jclass, jstring);
+/*
+ * Class: app_logorrr_OsxBridge
+ * Method: openUrl
+ * Signature: (Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_app_logorrr_OsxBridge_openUrl
+ (JNIEnv *, jclass, jstring);
+
#ifdef __cplusplus
}
#endif
diff --git a/native/native-osx/src/main/c/app_logorrr_OsxBridge_swift.h b/native/native-osx/src/main/c/app_logorrr_OsxBridge_swift.h
index f599bfb8..744cffb8 100644
--- a/native/native-osx/src/main/c/app_logorrr_OsxBridge_swift.h
+++ b/native/native-osx/src/main/c/app_logorrr_OsxBridge_swift.h
@@ -1,2 +1,3 @@
void registerPath(const char* path);
-void releasePath(const char* path);
\ No newline at end of file
+void releasePath(const char* path);
+void openUrl(const char* url);
\ No newline at end of file