diff --git a/daemon/Daemon.cpp b/daemon/Daemon.cpp index 5c4f9c97..57cbcef6 100644 --- a/daemon/Daemon.cpp +++ b/daemon/Daemon.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2024, The PurpleI2P Project +* Copyright (c) 2013-2025, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -118,8 +118,8 @@ namespace util if (logclftime) i2p::log::Logger().SetTimeFormat ("[%d/%b/%Y:%H:%M:%S %z]"); -#ifdef WIN32_APP - // Win32 app with GUI supports only logging to file +#if defined(WIN32_APP) || defined(__HAIKU__) + // Win32 app with GUI or Haiku supports only logging to file logs = "file"; #else if (isDaemon && (logs == "" || logs == "stdout")) diff --git a/daemon/Daemon.h b/daemon/Daemon.h index 3f53b89f..6f428ce4 100644 --- a/daemon/Daemon.h +++ b/daemon/Daemon.h @@ -98,7 +98,6 @@ namespace util } }; #else // Unix-like systems, including Linux -#define Daemon i2p::util::DaemonUnix::Instance() class DaemonUnix : public Daemon_Singleton { public: @@ -122,6 +121,24 @@ namespace util int gracefulShutdownInterval; // in seconds }; +#if !defined(__HAIKU__) + #define Daemon i2p::util::DaemonUnix::Instance() +#else + class DaemonHaiku: public DaemonUnix + { + public: + + static DaemonHaiku& Instance () + { + static DaemonHaiku instance; + return instance; + } + + void run (); + }; +#define Daemon i2p::util::DaemonHaiku::Instance() +#endif + #endif } } diff --git a/daemon/HaikuDaemon.cpp b/daemon/HaikuDaemon.cpp new file mode 100644 index 00000000..0a8b8a31 --- /dev/null +++ b/daemon/HaikuDaemon.cpp @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2025, The PurpleI2P Project +* +* This file is part of Purple i2pd project and licensed under BSD3 +* +* See full license text in LICENSE file at top of project tree +*/ + +#if defined(__HAIKU__) + +#include "Daemon.h" + +#include +#include +#include +#include + +class MainWindow: public BWindow +{ + public: + MainWindow (); +}; + +class I2PApp: public BApplication +{ + public: + I2PApp (); +}; + +MainWindow::MainWindow (): + BWindow (BRect(100, 100, 500, 400), "i2pd", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) +{ + auto r = Bounds (); r.bottom = 20; + auto menuBar = new BMenuBar (r, "menubar"); + AddChild (menuBar); + auto runMenu = new BMenu ("Run"); + runMenu->AddItem (new BMenuItem ("Quit", new BMessage (B_QUIT_REQUESTED), 'Q')); + menuBar->AddItem (runMenu); +} + +I2PApp::I2PApp (): BApplication("application/x-vnd.purplei2p-i2pd") +{ + auto mainWindow = new MainWindow (); + mainWindow->Show (); +} + +namespace i2p +{ +namespace util +{ + void DaemonHaiku::run () + { + if (isDaemon) + DaemonUnix::run (); + else + { + I2PApp app; + app.Run (); + } + } +} +} + +#endif + + +