Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1204,8 +1204,8 @@ elseif(Haiku)
src/detection/battery/battery_haiku.c
src/detection/bios/bios_windows.c
src/detection/board/board_windows.c
src/detection/bootmgr/bootmgr_nosupport.c
src/detection/brightness/brightness_nosupport.c
src/detection/bootmgr/bootmgr_haiku.cpp
src/detection/brightness/brightness_haiku.cpp
src/detection/btrfs/btrfs_nosupport.c
src/detection/chassis/chassis_windows.c
src/detection/cpu/cpu_haiku.c
Expand Down Expand Up @@ -1257,7 +1257,7 @@ elseif(Haiku)
src/detection/wifi/wifi_nosupport.c
src/detection/wm/wm_nosupport.c
src/detection/de/de_nosupport.c
src/detection/wmtheme/wmtheme_nosupport.c
src/detection/wmtheme/wmtheme_haiku.cpp
src/detection/camera/camera_nosupport.c
)
elseif(GNU)
Expand Down
17 changes: 17 additions & 0 deletions src/detection/bootmgr/bootmgr_haiku.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
extern "C" {
#include "bootmgr.h"
#include "common/io.h"
}

const char* ffDetectBootmgr(FFBootmgrResult* result) {
// TODO: glob haiku_loader.* + check EFI partition
if (ffPathExists("/system/haiku_loader.bios_ia32", FF_PATHTYPE_FILE)) {
ffStrbufSetStatic(&result->firmware, "/system/haiku_loader.bios_ia32");
}

ffStrbufSetStatic(&result->name, "haiku_loader");

// TODO: detectSecureBoot(&result->secureBoot);

return NULL;
}
46 changes: 46 additions & 0 deletions src/detection/brightness/brightness_haiku.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
extern "C" {
#include "brightness.h"
#include "common/strutil.h"
}

#include <Application.h>

Check warning on line 6 in src/detection/brightness/brightness_haiku.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/detection/brightness/brightness_haiku.cpp#L6

Include file: <Application.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ LOW RISK

Nitpick: The std::nanf function requires the <cmath> header.

Suggested change
#include <Application.h>
#include <cmath>
#include <Application.h>

#include <Screen.h>

Check warning on line 7 in src/detection/brightness/brightness_haiku.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/detection/brightness/brightness_haiku.cpp#L7

Include file: <Screen.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) {
// We need a valid be_app to query the app_server here.
BApplication app("application/x-vnd.fastfetch-cli-fastfetch");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

Haiku only allows one BApplication per process. Multiple modules are creating their own instances, which will lead to a crash. Check if 'be_app' is already initialized.

Try running the following prompt in your coding agent:

Refactor the BApplication initialization in Haiku modules to check if be_app is already non-null before creating a new BApplication instance.

BScreen screen{}; // default screen is the main one

do {
if (!screen.IsValid()) {
continue;
}

float value = 1.0f;
status_t status = screen.GetBrightness(&value);
if (status != B_OK) {
continue;
}

monitor_info monitor;
// WARNING: This is experimental new Haiku API
status_t err = screen.GetMonitorInfo(&monitor);

FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result);

if (err == B_OK) {
ffStrbufInitF(&brightness->name, "%s %s (%ld)", monitor.vendor, monitor.name, screen.ID().id);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Potential format string mismatch for int32 on 64-bit systems. screen.ID().id returns an int32, but %ld is used.

Suggested change
ffStrbufInitF(&brightness->name, "%s %s (%ld)", monitor.vendor, monitor.name, screen.ID().id);
ffStrbufInitF(&brightness->name, "%s %s (%ld)", monitor.vendor, monitor.name, (long) screen.ID().id);

ffStrbufTrimRightSpace(&brightness->name);
} else {
ffStrbufInitF(&brightness->name, "Screen %ld", screen.ID().id);
}

brightness->max = 1.0f;
brightness->min = 0.0f;
brightness->current = value;
brightness->builtin = true;

} while (screen.SetToNext() == B_OK);

return NULL;
}
13 changes: 7 additions & 6 deletions src/detection/os/os_haiku.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "os.h"
#include <OS.h>
#include <image.h>
#include <SupportDefs.h>

Check warning on line 4 in src/detection/os/os_haiku.c

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/detection/os/os_haiku.c#L4

Include file: <SupportDefs.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

void ffDetectOSImpl(FFOSResult* os) {
ffStrbufSetStatic(&os->name, "Haiku");
Expand Down Expand Up @@ -32,24 +33,24 @@
int32 relVer = ver / 0x10000;
ver %= 0x10000;
if (ver == 0) {
ffStrbufSetF(&os->version, "R%d", relVer);
ffStrbufSetF(&os->version, "R%" B_PRId32, relVer);
} else {
relVer++;

bool isPre = !!(ver & 1);
if (ver < B_HAIKU_VERSION_1_PRE_BETA_1) {
int32 alphaVer = ver / 0x100;
if (isPre) {
ffStrbufSetF(&os->version, "R%dA%d-", relVer, alphaVer + 1);
ffStrbufSetF(&os->version, "R%" B_PRId32 "A%ld-", relVer, alphaVer + 1);
} else {
ffStrbufSetF(&os->version, "R%dA%d", relVer, alphaVer);
ffStrbufSetF(&os->version, "R%" B_PRId32 "A%ld", relVer, alphaVer);
}
} else if (ver < 0x00010000 /* B_HAIKU_VERSION_1 */) {
int32 betaVer = (ver - B_HAIKU_VERSION_1_ALPHA_4) / 0x100;
if (isPre) {
ffStrbufSetF(&os->version, "R%dB%d-", relVer, betaVer + 1);
ffStrbufSetF(&os->version, "R%" B_PRId32 "B%ld-", relVer, betaVer + 1);
} else {
ffStrbufSetF(&os->version, "R%dB%d", relVer, betaVer);
ffStrbufSetF(&os->version, "R%" B_PRId32 "B%ld", relVer, betaVer);
}
}
}
Expand All @@ -59,7 +60,7 @@
if (!os->version.length) {
system_info sys;
if (get_system_info(&sys) == B_OK) {
ffStrbufAppendF(&os->version, "R%ldx", sys.kernel_version);
ffStrbufAppendF(&os->version, "R%" B_PRIx64, sys.kernel_version);
}
}
}
30 changes: 30 additions & 0 deletions src/detection/wmtheme/wmtheme_haiku.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
extern "C" {
#include "fastfetch.h"
#include "wmtheme.h"
}

#include <Application.h>

Check warning on line 6 in src/detection/wmtheme/wmtheme_haiku.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/detection/wmtheme/wmtheme_haiku.cpp#L6

Include file: <Application.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <private/interface/DecorInfo.h>

Check warning on line 7 in src/detection/wmtheme/wmtheme_haiku.cpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/detection/wmtheme/wmtheme_haiku.cpp#L7

Include file: <private/interface/DecorInfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

bool ffDetectWmTheme(FFstrbuf* themeOrError)
{
// We need a valid be_app to query the app_server here.
BApplication app("application/x-vnd.fastfetch-cli-fastfetch");

DecorInfoUtility *util = new DecorInfoUtility();
DecorInfo* decor = NULL;

if (util) {
decor = util->CurrentDecorator();
if (decor) {
ffStrbufAppendS(themeOrError, decor->Name().String());
}
delete util;
if (decor) {
return true;
}
}

ffStrbufAppendS(themeOrError, "Failed to get DecorInfo");
return false;
}
Loading