floorp: bump version

This commit is contained in:
Gerasim Troeglazov
2025-05-08 13:08:36 +10:00
parent 4ffb566e28
commit f61343ea20
4 changed files with 538 additions and 36 deletions

View File

@@ -0,0 +1,57 @@
resource app_flags B_MULTIPLE_LAUNCH;
resource app_version {
major = @MAJOR@,
middle = @MIDDLE@,
minor = @MINOR@,
variety = B_APPV_FINAL,
internal = 0,
short_info = "Floorp Browser",
long_info = "@LONG_INFO@"
};
resource app_signature "application/x-vnd.floorp-launcher";
resource file_types message {
"types" = "text/html",
"types" = "image/svg+xml",
"types" = "application/xhtml+xml",
"types" = "application/x-vnd.Be.URL.file",
"types" = "application/x-vnd.Be.URL.ftp",
"types" = "application/x-vnd.Be.URL.http",
"types" = "application/x-vnd.Be.URL.https",
"types" = "application/pdf",
"types" = "application/x-pdf"
};
resource vector_icon {
$"6E63696605020006022791803D76A9BD76A927918044281B4A00A1007105E8FF"
$"060FE8020106030000003F3400BF340000000049FFED000000005338ACB21C06"
$"6EFF1C066E020116030000003F4A50BF4A500000004A011300000000E37CFFFF"
$"B5050104017303020EBB3DB4B1BB3DB4B1BE3FB4B1C442B4B1C140B4B1C54BB4"
$"B1C711B650C68DB56BC892B8EBCB94BE20CA13BB86CC18BF06CB94C15FCC18C0"
$"79CA13C3F9C711C92FC892C694C68DCA14C442CACEC54BCACEC140CACEBB3DCA"
$"CEBE3FCACEBA34CACEB86EC92FB8F2CA14B6EDC694B3EBC15FB56CC3F921C079"
$"B3EBBE2021BF06B56CBB86B86EB650B6EDB8EBB8F2B56BBB3DB4B1BA34B4B1BB"
$"3DB4B1BB3DB4B1BB3DB4B1BB3DB4B1020EC458B85FC458B85FC5B5BABBC870BF"
$"75C713BD18C887BF9EC870C00AC887BFE1C713C267C458C720C5B5C4C4C440C7"
$"4AC3D7C76BC407C76BC11DC76BBBA8C76BBE62C76BBB78C76BBB27C720BB3FC7"
$"4AB9CAC4C4B70FC00AB86CC267B6F8BFE1B70FBF75B6F8BF9EB86CBD18BB27B8"
$"5FB9CABABBBB3FB835BBA8B814BB78B814BE62B814C3D7B814C11DB814C407B8"
$"14C458B85FC440B835C458B85FC458B85FC458B85FC458B85F0219BBB9B788BB"
$"B9B788BB53B788BAA4B828BAD7B7CFB94DBA7AB69EBF20B7F6BCCDB66CBF78B6"
$"9EC05FB66CC007B7F6C2B2BAA4C757B94DC505BAD7C7B0BBB9C7F7BB53C7F7BB"
$"C7C7F7BBE1C7F7BBD4C7F7BC1AC7F7BC47C791BC47C7CABC47C5CFBC47C24BBC"
$"47C40DBC47C221BC94C1FFBC69C1FFC042C1FFC79EC1FFC3F0C1FFC7CBC1FFC8"
$"1AC1B8C803C1DFC85CC145C8E1C05FC89EC0D2C913C007C8E1BF20C913BF78C8"
$"D6BF0EC8C2BEEBC8CCBEFCC8ACBEC4C849BEA5C875BEA5C462BEA5BC94BEA5C0"
$"7BBEA5BC69BEA5BC47BE58BC47BE83BC47BD47BC47BB24BC47BC36BC47BAFABC"
$"94BAD8BC69BAD8BFADBAD8C5DFBAD8C2C6BAD8C62BBAD8C624BA61C649BAA3C5"
$"B6B9A3C4DBB828C548B8E5C4A8B7CFC3C6B788C42CB788C117B788BBB9B788BE"
$"68B788BBB9B788050A040100023F48180000000000003C60D2470FCE4ABFCB0A"
$"030100123F9BB00000000000003FB63243227C434E6E01178500040A00010002"
$"3F9BB00000000000003FB63243227C434E6E0A010101023F9BB0000000000000"
$"3FB63243227C434E6E0A020102023F9BB00000000000003FB63243227C434E6E"
};

View File

@@ -16,20 +16,24 @@ COPYRIGHT="1995-2025 Mozilla Developers, Floorp Projects & Ablaze"
LICENSE="MPL v2.0"
REVISION="1"
SOURCE_URI="https://github.com/Floorp-Projects/Floorp/archive/refs/tags/v$portVersion.tar.gz"
CHECKSUM_SHA256="ad975ceb1934f55f09a74b991fbe0c91111127ee8bb55091f6cfef8a63b8879b"
CHECKSUM_SHA256="7123659c4290b0162ef1cfd1defda0b692b3471d17a35c7608db6a88c945315d"
SOURCE_DIR="Floorp-$portVersion"
srcGitRev2="c7a8b87560e62ffe00cf3b7289cc94e73a8198b2"
srcGitRev2="af5e7227fdd96c64c10abc731e4b9bbc44cd7f5a"
SOURCE_URI_2="https://github.com/Floorp-Projects/Floorp-core/archive/$srcGitRev2.tar.gz"
CHECKSUM_SHA256_2="db8a241217977dab9fdb2ffc51ecc40aa7e0a20d581f3f1d232ba241f3fa3031"
CHECKSUM_SHA256_2="4c86f44e0fdd606545bf314925935e44baaa04586830b5210eb735f3c2d56fc1"
SOURCE_DIR_2="Floorp-core-$srcGitRev2"
srcGitRev3="29bb9bed37ae970fbac4c8222010328b7fbf7e15"
SOURCE_URI_3="https://github.com/Floorp-Projects/Unified-l10n-central/archive/$srcGitRev3.tar.gz"
CHECKSUM_SHA256_3="5c848efe5be9fcbe73adea56f78d3c2d6de10f7b802f6380bf853242822858aa"
SOURCE_DIR_3="Unified-l10n-central-$srcGitRev3"
PATCHES="floorp-$portVersion.patchset"
PATCHES="
floorp-$portVersion.patchset
floorp_launcher-$portVersion.patchset
"
ADDITIONAL_FILES="
floorp.rdef.in
floorp_launcher.rdef.in
mozconfig
"
@@ -131,6 +135,9 @@ BUILD()
./mach python python/mozbuild/mozbuild/gn_processor.py dom/media/webrtc/third_party_build/gn-configs/webrtc.json
./mach build
cd tools/haiku-launcher
gcc -o "Floorp Browser" launcher.cpp -lbe
}
INSTALL()
@@ -145,6 +152,7 @@ INSTALL()
mv /usr/local/lib/floorp $appsDir/Floorp
mv $appsDir/Floorp/floorp $appsDir/Floorp/Floorp
cp "tools/haiku-launcher/Floorp Browser" $appsDir/Floorp
mkdir -p $appsDir/Floorp/lib
@@ -175,7 +183,15 @@ INSTALL()
-e "s|@LONG_INFO@|$LONG_INFO|" \
$portDir/additional-files/floorp.rdef.in > floorp.rdef
sed \
-e "s|@MAJOR@|$MAJOR|" \
-e "s|@MIDDLE@|$MIDDLE|" \
-e "s|@MINOR@|$MINOR|" \
-e "s|@LONG_INFO@|$LONG_INFO|" \
$portDir/additional-files/floorp_launcher.rdef.in > floorp_launcher.rdef
addResourcesToBinaries floorp.rdef $appsDir/Floorp/Floorp
addResourcesToBinaries floorp_launcher.rdef "$appsDir/Floorp/Floorp Browser"
addAppDeskbarSymlink $appsDir/Floorp/Floorp
}

View File

@@ -1,6 +1,6 @@
From 1c36b72e727dac7c115618f7791ac654c34443bb Mon Sep 17 00:00:00 2001
From 44a8884305b2dd876fbecc4eb9362af0b1844419 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Tue, 1 Apr 2025 13:50:00 +1000
Date: Thu, 8 May 2025 10:43:27 +1000
Subject: Add Haiku build support
Based on patches sourced from https://github.com/kenz-gelsoft/gecko-dev/
@@ -11,6 +11,7 @@ Based on patches sourced from https://github.com/kenz-gelsoft/gecko-dev/
- Fixed build with WebRTC enabled.
- Implemented WebRTC modules for desktop capture and video capture.
- Made additional modifications for Haiku compatibility.
- Implement remote server
diff --git a/.cargo/config.toml.in b/.cargo/config.toml.in
index 827f912..b726474 100644
@@ -2575,6 +2576,36 @@ index 85ead41..459712b 100644
if (is_win) {
defines += [ "WEBRTC_WIN" ]
}
diff --git a/third_party/libwebrtc/build/config/BUILDCONFIG.gn b/third_party/libwebrtc/build/config/BUILDCONFIG.gn
index 571ae5f..595c93b 100644
--- a/third_party/libwebrtc/build/config/BUILDCONFIG.gn
+++ b/third_party/libwebrtc/build/config/BUILDCONFIG.gn
@@ -184,7 +184,7 @@ if (host_toolchain == "") {
# TODO(dpranke): Add some sort of assert here that verifies that
# no toolchain omitted host_toolchain from its toolchain_args().
- if (host_os == "linux" || host_os == "openbsd") {
+ if (host_os == "linux" || host_os == "openbsd" || host_os == "haiku") {
if (target_os != "linux") {
host_toolchain = "//build/toolchain/linux:clang_$host_cpu"
} else if (is_clang) {
@@ -222,7 +222,7 @@ if (target_os == "android") {
assert(host_os == "linux" || host_os == "mac",
"Android builds are only supported on Linux and Mac hosts.")
_default_toolchain = "//build/toolchain/android:android_clang_$target_cpu"
-} else if (target_os == "chromeos" || target_os == "linux" || target_os == "openbsd") {
+} else if (target_os == "chromeos" || target_os == "linux" || target_os == "openbsd" || target_os == "haiku") {
# See comments in build/toolchain/cros/BUILD.gn about board compiles.
if (is_clang) {
_default_toolchain = "//build/toolchain/linux:clang_$target_cpu"
@@ -286,6 +286,7 @@ if (custom_toolchain != "") {
is_android = current_os == "android"
is_chromeos = current_os == "chromeos"
is_fuchsia = current_os == "fuchsia"
+is_haiku = current_os == "haiku"
is_ios = current_os == "ios"
is_linux = current_os == "linux"
is_bsd = current_os == "openbsd"
diff --git a/third_party/libwebrtc/modules/desktop_capture/BUILD.gn b/third_party/libwebrtc/modules/desktop_capture/BUILD.gn
index 34fba62..eb03d26 100644
--- a/third_party/libwebrtc/modules/desktop_capture/BUILD.gn
@@ -4336,6 +4367,308 @@ index ee9d07c..0b44d4c 100644
else:
UNIFIED_SOURCES += ["ProcInfo_linux.cpp"]
elif toolkit == "windows":
diff --git a/toolkit/components/remote/RemoteUtils.h b/toolkit/components/remote/RemoteUtils.h
index 2d21293..1c271d0 100644
--- a/toolkit/components/remote/RemoteUtils.h
+++ b/toolkit/components/remote/RemoteUtils.h
@@ -11,7 +11,7 @@
# include "WinUtils.h"
#endif
-#if defined XP_WIN || defined XP_MACOSX
+#if defined XP_WIN || defined XP_MACOSX || defined XP_HAIKU
static void BuildClassName(const char* aProgram, const char* aProfile,
nsString& aClassName) {
aClassName.AppendPrintf("Mozilla_%s", aProgram);
diff --git a/toolkit/components/remote/moz.build b/toolkit/components/remote/moz.build
index 4ac1408..caa5fba 100644
--- a/toolkit/components/remote/moz.build
+++ b/toolkit/components/remote/moz.build
@@ -16,7 +16,7 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
"nsUnixRemoteServer.cpp",
"RemoteUtils.cpp",
]
- if CONFIG["MOZ_ENABLE_DBUS"]:
+ if CONFIG["MOZ_ENABLE_DBUS"] and CONFIG["OS_ARCH"] != "Haiku":
SOURCES += [
"nsDBusRemoteClient.cpp",
"nsDBusRemoteServer.cpp",
@@ -27,11 +27,22 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
]
CXXFLAGS += CONFIG["MOZ_DBUS_CFLAGS"]
else:
- SOURCES += [
- "nsGTKRemoteServer.cpp",
- "nsXRemoteClient.cpp",
- "nsXRemoteServer.cpp",
- ]
+ if CONFIG["OS_ARCH"] == "Haiku":
+ SOURCES += [
+ "nsHaikuRemoteClient.cpp",
+ "nsHaikuRemoteServer.cpp",
+ ]
+ EXPORTS += [
+ "nsUnixRemoteServer.h",
+ "RemoteUtils.h",
+ ]
+ CXXFLAGS += CONFIG["MOZ_GTK3_CFLAGS"]
+ else:
+ SOURCES += [
+ "nsGTKRemoteServer.cpp",
+ "nsXRemoteClient.cpp",
+ "nsXRemoteServer.cpp",
+ ]
CXXFLAGS += CONFIG["MOZ_GTK3_CFLAGS"]
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows":
diff --git a/toolkit/components/remote/nsHaikuRemoteClient.cpp b/toolkit/components/remote/nsHaikuRemoteClient.cpp
new file mode 100644
index 0000000..17c8513
--- /dev/null
+++ b/toolkit/components/remote/nsHaikuRemoteClient.cpp
@@ -0,0 +1,37 @@
+#include <vector>
+#include <string.h>
+
+#include "nsHaikuRemoteClient.h"
+
+#include "RemoteUtils.h"
+
+nsresult nsHaikuRemoteClient::Init() {
+ return NS_OK;
+}
+
+nsresult nsHaikuRemoteClient::SendCommandLine(
+ const char* aProgram, const char* aProfile, int32_t argc, char** argv,
+ const char* aDesktopStartupID, char** aResponse, bool* aSucceeded) {
+ *aSucceeded = false;
+
+ nsString className;
+ BuildClassName(aProgram, aProfile, className);
+ BString portName;
+ portName.SetTo(NS_ConvertUTF16toUTF8(className.get()).get());
+
+ port_id port = find_port(portName.String());
+ if (port < 0) {
+ return NS_ERROR_NOT_AVAILABLE;
+ }
+
+ BString message;
+ for (int i = 0; i < argc; i++) {
+ if (i > 0)
+ message << "|";
+ message << argv[i];
+ }
+
+ status_t result = write_port(port, 1, message.String(), message.Length() + 1);
+ *aSucceeded = (result == B_OK);
+ return (result == B_OK) ? NS_OK : NS_ERROR_FAILURE;
+}
diff --git a/toolkit/components/remote/nsHaikuRemoteClient.h b/toolkit/components/remote/nsHaikuRemoteClient.h
new file mode 100644
index 0000000..290c4a5
--- /dev/null
+++ b/toolkit/components/remote/nsHaikuRemoteClient.h
@@ -0,0 +1,22 @@
+#ifndef HAIKU_REMOTE_CLIENT_H
+#define HAIKU_REMOTE_CLIENT_H
+
+#pragma GCC visibility push(default)
+#include <kernel/OS.h>
+#include <app/Messenger.h>
+#include <support/String.h>
+#pragma GCC visibility pop
+
+#include "nsRemoteClient.h"
+
+class nsHaikuRemoteClient : public nsRemoteClient {
+public:
+ virtual ~nsHaikuRemoteClient() = default;
+
+ nsresult Init() override;
+ nsresult SendCommandLine(const char* aProgram, const char* aProfile,
+ int32_t argc, char** argv, const char* aStartupToken,
+ char** aResponse, bool* aSucceeded) override;
+};
+
+#endif
diff --git a/toolkit/components/remote/nsHaikuRemoteServer.cpp b/toolkit/components/remote/nsHaikuRemoteServer.cpp
new file mode 100644
index 0000000..dacd6a7
--- /dev/null
+++ b/toolkit/components/remote/nsHaikuRemoteServer.cpp
@@ -0,0 +1,90 @@
+#include "nsHaikuRemoteServer.h"
+#include "RemoteUtils.h"
+
+#include "nsCommandLine.h"
+#include "nsICommandLineRunner.h"
+#include "nsICommandLine.h"
+#include "nsCOMPtr.h"
+#include "nsThreadUtils.h"
+
+#include <unistd.h>
+
+nsHaikuRemoteServer::nsHaikuRemoteServer()
+ : fRunning(false), fPort(B_BAD_PORT_ID) {}
+
+nsHaikuRemoteServer::~nsHaikuRemoteServer() {
+ Shutdown();
+}
+
+nsresult nsHaikuRemoteServer::Startup(const char* aAppName, const char* aProfileName) {
+ nsString className;
+ BuildClassName(aAppName, aProfileName, className);
+ BString portName;
+ portName.SetTo(NS_ConvertUTF16toUTF8(className.get()).get());
+
+ fPort = create_port(10, portName.String());
+ if (fPort < 0) {
+ return NS_ERROR_FAILURE;
+ }
+
+ fRunning = true;
+ fListenerThread = std::thread([this]() { ListenLoop(); });
+
+ return NS_OK;
+}
+
+void nsHaikuRemoteServer::Shutdown() {
+ fRunning = false;
+ if (fPort >= 0) {
+ delete_port(fPort);
+ fPort = B_BAD_PORT_ID;
+ }
+ if (fListenerThread.joinable()) {
+ fListenerThread.join();
+ }
+}
+
+void nsHaikuRemoteServer::ListenLoop() {
+ while (fRunning) {
+ char buffer[B_PATH_NAME_LENGTH * 2];
+ int32 code;
+ ssize_t len = read_port(fPort, &code, buffer, sizeof(buffer));
+ if (len > 0) {
+ buffer[len] = '\0';
+ HandleMessage(buffer);
+ } else {
+ snooze(50000);
+ }
+ }
+}
+
+nsresult nsHaikuRemoteServer::HandleMessage(const char* message) {
+ return NS_DispatchToMainThread(
+ NS_NewRunnableFunction("HandleMessageOnMainThread", [this, msg = std::string(message)]() {
+ this->HandleMessageOnMainThread(msg.c_str());
+ })
+ );
+}
+
+void nsHaikuRemoteServer::HandleMessageOnMainThread(const char* message) {
+ BString messageString(message);
+ BStringList argsList;
+ messageString.Split("|", true, argsList);
+
+ if (argsList.IsEmpty())
+ return;
+
+ int argc = argsList.CountStrings();
+ const char** argv = new const char*[argc];
+ for (int i = 0; i < argc; i++) {
+ argv[i] = argsList.StringAt(i).String();
+ }
+
+ nsCOMPtr<nsICommandLineRunner> cmdLine(new nsCommandLine());
+ nsresult rv = cmdLine->Init(argc, argv, nullptr, nsICommandLine::STATE_REMOTE_AUTO);
+ delete[] argv;
+
+ if (NS_SUCCEEDED(rv)) {
+ cmdLine->Run();
+ }
+}
diff --git a/toolkit/components/remote/nsHaikuRemoteServer.h b/toolkit/components/remote/nsHaikuRemoteServer.h
new file mode 100644
index 0000000..7c6d057
--- /dev/null
+++ b/toolkit/components/remote/nsHaikuRemoteServer.h
@@ -0,0 +1,37 @@
+#ifndef HAIKU_REMOTE_SERVER_H
+#define HAIKU_REMOTE_SERVER_H
+
+#include "nsRemoteServer.h"
+
+#include <thread>
+#include <atomic>
+
+#pragma GCC visibility push(default)
+#include <kernel/OS.h>
+#include <app/Application.h>
+#include <app/Messenger.h>
+#include <app/Roster.h>
+#include <interface/Window.h>
+#include <support/String.h>
+#include <support/StringList.h>
+#pragma GCC visibility pop
+
+class nsHaikuRemoteServer : public nsRemoteServer {
+public:
+ nsHaikuRemoteServer();
+ ~nsHaikuRemoteServer() override;
+
+ nsresult Startup(const char* aAppName, const char* aProfileName) override;
+ void Shutdown() override;
+
+private:
+ void ListenLoop();
+ nsresult HandleMessage(const char* message);
+ void HandleMessageOnMainThread(const char* message);
+
+ std::atomic<bool> fRunning;
+ std::thread fListenerThread;
+ port_id fPort;
+};
+
+#endif
diff --git a/toolkit/components/remote/nsRemoteService.cpp b/toolkit/components/remote/nsRemoteService.cpp
index 3e8e4b5..59cdc7b 100644
--- a/toolkit/components/remote/nsRemoteService.cpp
+++ b/toolkit/components/remote/nsRemoteService.cpp
@@ -6,7 +6,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef MOZ_WIDGET_GTK
-# ifdef MOZ_ENABLE_DBUS
+# if defined(XP_HAIKU)
+# include "nsHaikuRemoteServer.h"
+# include "nsHaikuRemoteClient.h"
+# elif defined(MOZ_ENABLE_DBUS)
# include "nsDBusRemoteServer.h"
# include "nsDBusRemoteClient.h"
# else
@@ -99,7 +102,9 @@ RemoteResult nsRemoteService::StartClient(const char* aStartupToken) {
UniquePtr<nsRemoteClient> client;
#ifdef MOZ_WIDGET_GTK
-# if defined(MOZ_ENABLE_DBUS)
+# if defined(XP_HAIKU)
+ client = MakeUnique<nsHaikuRemoteClient>();
+# elif defined(MOZ_ENABLE_DBUS)
client = MakeUnique<nsDBusRemoteClient>();
# else
client = MakeUnique<nsXRemoteClient>();
@@ -143,7 +148,9 @@ void nsRemoteService::StartupServer() {
}
#ifdef MOZ_WIDGET_GTK
-# if defined(MOZ_ENABLE_DBUS)
+# if defined(XP_HAIKU)
+ mRemoteServer = MakeUnique<nsHaikuRemoteServer>();
+# elif defined(MOZ_ENABLE_DBUS)
mRemoteServer = MakeUnique<nsDBusRemoteServer>();
# else
mRemoteServer = MakeUnique<nsGTKRemoteServer>();
diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build
index c33d81a..e58f269 100644
--- a/toolkit/library/moz.build
@@ -5305,36 +5638,6 @@ index dbd9993..1431340 100644
# endif
# include <sys/types.h>
# include <signal.h>
diff --git a/third_party/libwebrtc/build/config/BUILDCONFIG.gn b/third_party/libwebrtc/build/config/BUILDCONFIG.gn
index 571ae5f..595c93b 100644
--- a/third_party/libwebrtc/build/config/BUILDCONFIG.gn
+++ b/third_party/libwebrtc/build/config/BUILDCONFIG.gn
@@ -184,7 +184,7 @@ if (host_toolchain == "") {
# TODO(dpranke): Add some sort of assert here that verifies that
# no toolchain omitted host_toolchain from its toolchain_args().
- if (host_os == "linux" || host_os == "openbsd") {
+ if (host_os == "linux" || host_os == "openbsd" || host_os == "haiku") {
if (target_os != "linux") {
host_toolchain = "//build/toolchain/linux:clang_$host_cpu"
} else if (is_clang) {
@@ -222,7 +222,7 @@ if (target_os == "android") {
assert(host_os == "linux" || host_os == "mac",
"Android builds are only supported on Linux and Mac hosts.")
_default_toolchain = "//build/toolchain/android:android_clang_$target_cpu"
-} else if (target_os == "chromeos" || target_os == "linux" || target_os == "openbsd") {
+} else if (target_os == "chromeos" || target_os == "linux" || target_os == "openbsd" || target_os == "haiku") {
# See comments in build/toolchain/cros/BUILD.gn about board compiles.
if (is_clang) {
_default_toolchain = "//build/toolchain/linux:clang_$target_cpu"
@@ -286,6 +286,7 @@ if (custom_toolchain != "") {
is_android = current_os == "android"
is_chromeos = current_os == "chromeos"
is_fuchsia = current_os == "fuchsia"
+is_haiku = current_os == "haiku"
is_ios = current_os == "ios"
is_linux = current_os == "linux"
is_bsd = current_os == "openbsd"
--
2.48.1

View File

@@ -0,0 +1,126 @@
From 87d14d4ef2e06f7dfeeb66aa2fac74fef2e58cc6 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 6 Apr 2025 10:13:00 +1000
Subject: Add simple launcher app
diff --git a/tools/haiku-launcher/launcher.cpp b/tools/haiku-launcher/launcher.cpp
new file mode 100644
index 0000000..86a9f22
--- /dev/null
+++ b/tools/haiku-launcher/launcher.cpp
@@ -0,0 +1,111 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include <Application.h>
+#include <Alert.h>
+#include <String.h>
+#include <Resources.h>
+#include <Roster.h>
+#include <Mime.h>
+#include <Path.h>
+#include <AppFileInfo.h>
+#include <kernel/image.h>
+
+class BrowserLauncherApp : public BApplication {
+ public:
+ BrowserLauncherApp(const char *signature, int argc, char **argv);
+ ~BrowserLauncherApp() {};
+
+ virtual void RefsReceived(BMessage *pmsg);
+ virtual void ArgvRecieved(int32 argc, char**argv);
+ virtual void ReadyToRun();
+ BString GetBinPath(void);
+
+ private:
+ BString fCommandLine;
+};
+
+BrowserLauncherApp::BrowserLauncherApp(const char *signature, int argc, char **argv)
+ : BApplication(signature)
+{
+ ArgvRecieved(argc, argv);
+}
+
+BString
+BrowserLauncherApp::GetBinPath(void)
+{
+ BPath binPath;
+
+ image_info info;
+ int32 cookie = 0;
+
+ while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
+ if (info.type == B_APP_IMAGE) {
+ binPath.SetTo(info.name);
+ binPath.GetParent(&binPath);
+ break;
+ }
+ }
+
+ binPath.Append("Floorp");
+
+ return binPath.Path();
+}
+
+void
+BrowserLauncherApp::RefsReceived(BMessage *pmsg)
+{
+ fCommandLine = GetBinPath();
+
+ entry_ref ref;
+ for (int32 i = 0; pmsg->FindRef("refs", i, &ref) == B_OK; i++) {
+ BPath file = BPath(&ref);
+ fCommandLine += " \"";
+ fCommandLine += file.Path();
+ fCommandLine += "\"";
+ }
+
+ BString url;
+ for (int32 i = 0; pmsg->FindString("url", i, &url) == B_OK; i++) {
+ fCommandLine += " \"";
+ fCommandLine += url;
+ fCommandLine += "\"";
+ }
+
+ fCommandLine += " &";
+}
+
+void
+BrowserLauncherApp::ArgvRecieved(int32 argc, char**argv)
+{
+ BMessage message(B_REFS_RECEIVED);
+ for (int i = 1; i < argc; i++) {
+ const char* url = argv[i];
+ BEntry entry(argv[i], true);
+ BPath path;
+ if (entry.Exists() && entry.GetPath(&path) == B_OK)
+ url = path.Path();
+ message.AddString("url", url);
+ }
+ RefsReceived(&message);
+}
+
+void
+BrowserLauncherApp::ReadyToRun()
+{
+ if (!fCommandLine.IsEmpty())
+ system(fCommandLine.String());
+
+ Quit();
+}
+
+int main(int argc, char **argv)
+{
+ BrowserLauncherApp application("application/x-vnd.floorp-launcher", argc, argv);
+ application.Run();
+ return 0;
+}
+
+
--
2.48.1