diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ab1453be..104e67fde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -421,7 +421,8 @@ if(LINUX) src/detection/users/users_linux.c src/detection/wallpaper/wallpaper_linux.c src/detection/wifi/wifi_linux.c - src/detection/wmde/wmde_linux.c + src/detection/wm/wm_nosupport.c + src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c src/util/platform/FFPlatform_unix.c ) @@ -471,6 +472,8 @@ elseif(ANDROID) src/detection/users/users_linux.c src/detection/wallpaper/wallpaper_nosupport.c src/detection/wifi/wifi_android.c + src/detection/wm/wm_nosupport.c + src/detection/de/de_nosupport.c src/detection/wmtheme/wmtheme_nosupport.c src/util/platform/FFPlatform_unix.c ) @@ -530,6 +533,8 @@ elseif(BSD) src/detection/wallpaper/wallpaper_linux.c src/detection/wifi/wifi_bsd.c src/detection/wmde/wmde_linux.c + src/detection/wm/wm_nosupport.c + src/detection/de/de_linux.c src/detection/wmtheme/wmtheme_linux.c src/util/platform/FFPlatform_unix.c ) @@ -580,7 +585,8 @@ elseif(APPLE) src/detection/users/users_linux.c src/detection/wallpaper/wallpaper_apple.c src/detection/wifi/wifi_apple.m - src/detection/wmde/wmde_apple.c + src/detection/wm/wm_apple.c + src/detection/de/de_nosupport.c src/detection/wmtheme/wmtheme_apple.m src/util/apple/cf_helpers.c src/util/apple/osascript.m @@ -633,6 +639,8 @@ elseif(WIN32) src/detection/users/users_windows.c src/detection/wallpaper/wallpaper_windows.c src/detection/wifi/wifi_windows.c + src/detection/wm/wm_nosupport.c + src/detection/de/de_nosupport.c src/detection/wmtheme/wmtheme_windows.c src/util/windows/getline.c src/util/windows/com.cpp diff --git a/src/detection/de/de.h b/src/detection/de/de.h new file mode 100644 index 000000000..9d8b2201f --- /dev/null +++ b/src/detection/de/de.h @@ -0,0 +1,5 @@ +#pragma once + +#include "fastfetch.h" + +const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FFDEOptions* options); diff --git a/src/detection/de/de_linux.c b/src/detection/de/de_linux.c new file mode 100644 index 000000000..b96a52399 --- /dev/null +++ b/src/detection/de/de_linux.c @@ -0,0 +1,169 @@ +#include "de.h" + +#include "common/parsing.h" +#include "common/properties.h" +#include "common/processing.h" +#include "detection/displayserver/displayserver.h" + +static void getKDE(FFstrbuf* result) +{ + ffParsePropFileValues("/usr/share/xsessions/plasmax11.desktop", 1, (FFpropquery[]) { + {"X-KDE-PluginInfo-Version =", result} + }); + if(result->length == 0) + ffParsePropFileData("xsessions/plasma.desktop", "X-KDE-PluginInfo-Version =", result); + if(result->length == 0) + ffParsePropFileData("xsessions/plasma5.desktop", "X-KDE-PluginInfo-Version =", result); + if(result->length == 0) + { + ffParsePropFileValues("/usr/share/wayland-sessions/plasma.desktop", 1, (FFpropquery[]) { + {"X-KDE-PluginInfo-Version =", result} + }); + } + if(result->length == 0) + ffParsePropFileData("wayland-sessions/plasmawayland.desktop", "X-KDE-PluginInfo-Version =", result); + if(result->length == 0) + ffParsePropFileData("wayland-sessions/plasmawayland5.desktop", "X-KDE-PluginInfo-Version =", result); + + if(result->length == 0 && instance.config.general.allowSlowOperations) + { + if (ffProcessAppendStdOut(result, (char* const[]){ + "plasmashell", + "--version", + NULL + }) == NULL) // plasmashell 5.27.5 + ffStrbufSubstrAfterLastC(result, ' '); + } +} + +static void getGnome(FFstrbuf* result) +{ + ffParsePropFileData("gnome-shell/org.gnome.Extensions", "version :", result); + + if (result->length == 0) + { + if (ffProcessAppendStdOut(result, (char* const[]){ + "gnome-shell", + "--version", + NULL + }) == NULL) // GNOME Shell 44.1 + ffStrbufSubstrAfterLastC(result, ' '); + } +} + +static void getCinnamon(FFstrbuf* result) +{ + ffParsePropFileData("applications/cinnamon.desktop", "X-GNOME-Bugzilla-Version =", result); +} + +static void getMate(FFstrbuf* result) +{ + FF_STRBUF_AUTO_DESTROY major = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY micro = ffStrbufCreate(); + + ffParsePropFileDataValues("mate-about/mate-version.xml", 3, (FFpropquery[]) { + {"", &major}, + {"", &minor}, + {"", µ} + }); + + ffParseSemver(result, &major, &minor, µ); + + if(result->length == 0 && instance.config.general.allowSlowOperations) + { + ffProcessAppendStdOut(result, (char* const[]){ + "mate-session", + "--version", + NULL + }); + + ffStrbufSubstrAfterFirstC(result, ' '); + ffStrbufTrim(result, ' '); + } +} + +static void getXFCE4(FFstrbuf* result) +{ + ffParsePropFileData("gtk-doc/html/libxfce4ui/index.html", "

Version", result); + + #ifdef __FreeBSD__ + if(result->length == 0) + { + FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/usr/local/share/licenses/"); + if (dirp) + { + struct dirent* entry; + while((entry = readdir(dirp)) != NULL) + { + if(!ffStrStartsWith(entry->d_name, "xfce-") || !isdigit(entry->d_name[5])) + continue; + ffStrbufAppendS(result, &entry->d_name[5]); + } + } + } + #endif + + if(result->length == 0 && instance.config.general.allowSlowOperations) + { + //This is somewhat slow + ffProcessAppendStdOut(result, (char* const[]){ + "xfce4-session", + "--version", + NULL + }); + + ffStrbufSubstrBeforeFirstC(result, '('); + ffStrbufSubstrAfterFirstC(result, ' '); + ffStrbufTrim(result, ' '); + } +} + +static void getLXQt(FFstrbuf* result) +{ + ffParsePropFileData("gconfig/lxqt.pc", "Version:", result); + + if(result->length == 0) + ffParsePropFileData("cmake/lxqt/lxqt-config.cmake", "set ( LXQT_VERSION", result); + if(result->length == 0) + ffParsePropFileData("cmake/lxqt/lxqt-config-version.cmake", "set ( PACKAGE_VERSION", result); + + if(result->length == 0 && instance.config.general.allowSlowOperations) + { + //This is really, really, really slow. Thank you, LXQt developers + ffProcessAppendStdOut(result, (char* const[]){ + "lxqt-session", + "-v", + NULL + }); + + result->length = 0; //don't set '\0' byte + ffParsePropLines(result->chars , "liblxqt", result); + } +} + +static void getBudgie(FFstrbuf* result) +{ + ffParsePropFileData("budgie/budgie-version.xml", "", result); +} + +const char* ffDetectDEVersion(const FFstrbuf* deName, FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) +{ + if (ffStrbufEqualS(deName, FF_DE_PRETTY_PLASMA)) + getKDE(result); + else if (ffStrbufEqualS(deName, FF_DE_PRETTY_GNOME) || ffStrbufEqualS(deName, FF_DE_PRETTY_GNOME)) + getGnome(result); + else if (ffStrbufEqualS(deName, FF_DE_PRETTY_CINNAMON)) + getCinnamon(result); + else if (ffStrbufEqualS(deName, FF_DE_PRETTY_XFCE4)) + getXFCE4(result); + else if (ffStrbufEqualS(deName, FF_DE_PRETTY_MATE)) + getMate(result); + else if (ffStrbufEqualS(deName, FF_DE_PRETTY_LXQT)) + getLXQt(result); + else if (ffStrbufEqualS(deName, FF_DE_PRETTY_BUDGIE)) + getBudgie(result); + else + return "Unsupported DE"; + return NULL; +} diff --git a/src/detection/de/de_nosupport.c b/src/detection/de/de_nosupport.c new file mode 100644 index 000000000..943e035f0 --- /dev/null +++ b/src/detection/de/de_nosupport.c @@ -0,0 +1,6 @@ +#include "de.h" + +const char* ffDetectDEVersion(FF_MAYBE_UNUSED const FFstrbuf* deName, FF_MAYBE_UNUSED FFstrbuf* result, FF_MAYBE_UNUSED FFDEOptions* options) +{ + return "Not supported on this platform"; +} diff --git a/src/detection/displayserver/displayserver.h b/src/detection/displayserver/displayserver.h index b4ab5283b..4ae40320f 100644 --- a/src/detection/displayserver/displayserver.h +++ b/src/detection/displayserver/displayserver.h @@ -68,7 +68,6 @@ typedef struct FFDisplayServerResult FFstrbuf wmProtocolName; FFstrbuf deProcessName; FFstrbuf dePrettyName; - FFstrbuf deVersion; FFlist displays; //List of FFDisplayResult } FFDisplayServerResult; diff --git a/src/detection/displayserver/displayserver_android.c b/src/detection/displayserver/displayserver_android.c index f60c315f4..a1c7508ac 100644 --- a/src/detection/displayserver/displayserver_android.c +++ b/src/detection/displayserver/displayserver_android.c @@ -107,7 +107,6 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) ffStrbufInit(&ds->wmProtocolName); ffStrbufInit(&ds->deProcessName); ffStrbufInit(&ds->dePrettyName); - ffStrbufInit(&ds->deVersion); ffListInitA(&ds->displays, sizeof(FFDisplayResult), 0); if (!detectWithGetprop(ds)) diff --git a/src/detection/displayserver/displayserver_apple.c b/src/detection/displayserver/displayserver_apple.c index cb1583270..352feafb3 100644 --- a/src/detection/displayserver/displayserver_apple.c +++ b/src/detection/displayserver/displayserver_apple.c @@ -86,7 +86,6 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) ffStrbufInit(&ds->deProcessName); ffStrbufInitStatic(&ds->dePrettyName, "Aqua"); - ffStrbufInit(&ds->deVersion); ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4); detectDisplays(ds); diff --git a/src/detection/displayserver/displayserver_windows.c b/src/detection/displayserver/displayserver_windows.c index b8e2b54a8..5573d3601 100644 --- a/src/detection/displayserver/displayserver_windows.c +++ b/src/detection/displayserver/displayserver_windows.c @@ -158,7 +158,6 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) ffStrbufInit(&ds->wmProtocolName); ffStrbufInit(&ds->deProcessName); ffStrbufInit(&ds->dePrettyName); - ffStrbufInit(&ds->deVersion); ffListInit(&ds->displays, sizeof(FFDisplayResult)); detectDisplays(ds); diff --git a/src/detection/displayserver/linux/displayserver_linux.c b/src/detection/displayserver/linux/displayserver_linux.c index 3de10d9dc..b0ceabfde 100644 --- a/src/detection/displayserver/linux/displayserver_linux.c +++ b/src/detection/displayserver/linux/displayserver_linux.c @@ -85,7 +85,6 @@ void ffConnectDisplayServerImpl(FFDisplayServerResult* ds) ffStrbufInit(&ds->wmProtocolName); ffStrbufInit(&ds->deProcessName); ffStrbufInit(&ds->dePrettyName); - ffStrbufInit(&ds->deVersion); ffListInitA(&ds->displays, sizeof(FFDisplayResult), 4); if (!instance.config.general.dsForceDrm) diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index 8829f2352..87594ea10 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -1,7 +1,6 @@ #include "displayserver_linux.h" #include "common/io/io.h" #include "common/properties.h" -#include "common/parsing.h" #include "common/processing.h" #include "util/stringUtils.h" @@ -131,177 +130,6 @@ static void applyBetterWM(FFDisplayServerResult* result, const char* processName ffStrbufAppend(&result->wmPrettyName, &result->wmProcessName); } -static void getKDE(FFDisplayServerResult* result) -{ - ffStrbufSetS(&result->deProcessName, "plasmashell"); - ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_PLASMA); - - ffParsePropFileValues("/usr/share/xsessions/plasmax11.desktop", 1, (FFpropquery[]) { - {"X-KDE-PluginInfo-Version =", &result->deVersion} - }); - if(result->deVersion.length == 0) - ffParsePropFileData("xsessions/plasma.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); - if(result->deVersion.length == 0) - ffParsePropFileData("xsessions/plasma5.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); - if(result->deVersion.length == 0) - { - ffParsePropFileValues("/usr/share/wayland-sessions/plasma.desktop", 1, (FFpropquery[]) { - {"X-KDE-PluginInfo-Version =", &result->deVersion} - }); - } - if(result->deVersion.length == 0) - ffParsePropFileData("wayland-sessions/plasmawayland.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); - if(result->deVersion.length == 0) - ffParsePropFileData("wayland-sessions/plasmawayland5.desktop", "X-KDE-PluginInfo-Version =", &result->deVersion); - - if(result->deVersion.length == 0 && instance.config.general.allowSlowOperations) - { - if (ffProcessAppendStdOut(&result->deVersion, (char* const[]){ - "plasmashell", - "--version", - NULL - }) == NULL) // plasmashell 5.27.5 - ffStrbufSubstrAfterLastC(&result->deVersion, ' '); - } - - - applyBetterWM(result, getenv("KDEWM")); -} - -static void getGnome(FFDisplayServerResult* result) -{ - ffStrbufSetS(&result->deProcessName, "gnome-shell"); - const char* sessionMode = getenv("GNOME_SHELL_SESSION_MODE"); - if (sessionMode && ffStrEquals(sessionMode, "classic")) - ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_GNOME_CLASSIC); - else - ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_GNOME); - - ffParsePropFileData("gnome-shell/org.gnome.Extensions", "version :", &result->deVersion); - - if (result->deVersion.length == 0) - { - if (ffProcessAppendStdOut(&result->deVersion, (char* const[]){ - "gnome-shell", - "--version", - NULL - }) == NULL) // GNOME Shell 44.1 - ffStrbufSubstrAfterLastC(&result->deVersion, ' '); - } -} - -static void getCinnamon(FFDisplayServerResult* result) -{ - ffStrbufSetS(&result->deProcessName, "cinnamon"); - ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_CINNAMON); - ffParsePropFileData("applications/cinnamon.desktop", "X-GNOME-Bugzilla-Version =", &result->deVersion); -} - -static void getMate(FFDisplayServerResult* result) -{ - ffStrbufSetS(&result->deProcessName, "mate-session"); - ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_MATE); - - FF_STRBUF_AUTO_DESTROY major = ffStrbufCreate(); - FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate(); - FF_STRBUF_AUTO_DESTROY micro = ffStrbufCreate(); - - ffParsePropFileDataValues("mate-about/mate-version.xml", 3, (FFpropquery[]) { - {"", &major}, - {"", &minor}, - {"", µ} - }); - - ffParseSemver(&result->deVersion, &major, &minor, µ); - - if(result->deVersion.length == 0 && instance.config.general.allowSlowOperations) - { - ffProcessAppendStdOut(&result->deVersion, (char* const[]){ - "mate-session", - "--version", - NULL - }); - - ffStrbufSubstrAfterFirstC(&result->deVersion, ' '); - ffStrbufTrim(&result->deVersion, ' '); - } -} - -static void getXFCE4(FFDisplayServerResult* result) -{ - ffStrbufSetS(&result->deProcessName, "xfce4-session"); - ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_XFCE4); - ffParsePropFileData("gtk-doc/html/libxfce4ui/index.html", "

Version", &result->deVersion); - - #ifdef __FreeBSD__ - if(result->deVersion.length == 0) - { - FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/usr/local/share/licenses/"); - if (dirp) - { - struct dirent* entry; - while((entry = readdir(dirp)) != NULL) - { - if(!ffStrStartsWith(entry->d_name, "xfce-") || !isdigit(entry->d_name[5])) - continue; - ffStrbufAppendS(&result->deVersion, &entry->d_name[5]); - } - } - } - #endif - - if(result->deVersion.length == 0 && instance.config.general.allowSlowOperations) - { - //This is somewhat slow - ffProcessAppendStdOut(&result->deVersion, (char* const[]){ - "xfce4-session", - "--version", - NULL - }); - - ffStrbufSubstrBeforeFirstC(&result->deVersion, '('); - ffStrbufSubstrAfterFirstC(&result->deVersion, ' '); - ffStrbufTrim(&result->deVersion, ' '); - } -} - -static void getLXQt(FFDisplayServerResult* result) -{ - ffStrbufSetS(&result->deProcessName, "lxqt-session"); - ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_LXQT); - ffParsePropFileData("gconfig/lxqt.pc", "Version:", &result->deVersion); - - if(result->deVersion.length == 0) - ffParsePropFileData("cmake/lxqt/lxqt-config.cmake", "set ( LXQT_VERSION", &result->deVersion); - if(result->deVersion.length == 0) - ffParsePropFileData("cmake/lxqt/lxqt-config-version.cmake", "set ( PACKAGE_VERSION", &result->deVersion); - - if(result->deVersion.length == 0 && instance.config.general.allowSlowOperations) - { - //This is really, really, really slow. Thank you, LXQt developers - ffProcessAppendStdOut(&result->deVersion, (char* const[]){ - "lxqt-session", - "-v", - NULL - }); - - result->deVersion.length = 0; //don't set '\0' byte - ffParsePropLines(result->deVersion.chars , "liblxqt", &result->deVersion); - } - - FF_STRBUF_AUTO_DESTROY wmProcessNameBuffer = ffStrbufCreate(); - - ffParsePropFileConfig("lxqt/session.conf", "window_manager =", &wmProcessNameBuffer); - applyBetterWM(result, wmProcessNameBuffer.chars); -} - -static void getBudgie(FFDisplayServerResult* result) -{ - ffStrbufSetS(&result->deProcessName, "budgie-desktop"); - ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_BUDGIE); - ffParsePropFileData("budgie/budgie-version.xml", "", &result->deVersion); -} - static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name) { if(!ffStrSet(name)) @@ -312,19 +140,33 @@ static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name) strcasecmp(name, "plasma") == 0 || strcasecmp(name, "plasmashell") == 0 || strcasecmp(name, "plasmawayland") == 0 - ) getKDE(result); + ) { + ffStrbufSetStatic(&result->deProcessName, "plasmashell"); + ffStrbufSetStatic(&result->dePrettyName, FF_DE_PRETTY_PLASMA); + applyBetterWM(result, getenv("KDEWM")); + } else if( strcasecmp(name, "Gnome") == 0 || strcasecmp(name, "ubuntu:GNOME") == 0 || strcasecmp(name, "ubuntu") == 0 || strcasecmp(name, "gnome-shell") == 0 - ) getGnome(result); + ) { + ffStrbufSetStatic(&result->deProcessName, "gnome-shell"); + const char* sessionMode = getenv("GNOME_SHELL_SESSION_MODE"); + if (sessionMode && ffStrEquals(sessionMode, "classic")) + ffStrbufSetStatic(&result->dePrettyName, FF_DE_PRETTY_GNOME_CLASSIC); + else + ffStrbufSetStatic(&result->dePrettyName, FF_DE_PRETTY_GNOME); + } else if( strcasecmp(name, "X-Cinnamon") == 0 || strcasecmp(name, "Cinnamon") == 0 - ) getCinnamon(result); + ) { + ffStrbufSetS(&result->deProcessName, "cinnamon"); + ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_CINNAMON); + } else if( strcasecmp(name, "XFCE") == 0 || @@ -332,26 +174,41 @@ static void applyPrettyNameIfDE(FFDisplayServerResult* result, const char* name) strcasecmp(name, "XFCE4") == 0 || strcasecmp(name, "X-XFCE4") == 0 || strcasecmp(name, "xfce4-session") == 0 - ) getXFCE4(result); + ) { + ffStrbufSetS(&result->deProcessName, "xfce4-session"); + ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_XFCE4); + } else if( strcasecmp(name, "MATE") == 0 || strcasecmp(name, "X-MATE") == 0 || strcasecmp(name, "mate-session") == 0 - ) getMate(result); + ) { + ffStrbufSetS(&result->deProcessName, "mate-session"); + ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_MATE); + } else if( strcasecmp(name, "LXQt") == 0 || strcasecmp(name, "X-LXQT") == 0 || strcasecmp(name, "lxqt-session") == 0 - ) getLXQt(result); + ) { + ffStrbufSetS(&result->deProcessName, "lxqt-session"); + ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_LXQT); + FF_STRBUF_AUTO_DESTROY wmProcessNameBuffer = ffStrbufCreate(); + ffParsePropFileConfig("lxqt/session.conf", "window_manager =", &wmProcessNameBuffer); + applyBetterWM(result, wmProcessNameBuffer.chars); + } else if( strcasecmp(name, "Budgie") == 0 || strcasecmp(name, "X-Budgie") == 0 || strcasecmp(name, "budgie-desktop") == 0 || strcasecmp(name, "Budgie:GNOME") == 0 - ) getBudgie(result); + ) { + ffStrbufSetS(&result->deProcessName, "budgie-desktop"); + ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_BUDGIE); + } } static void getWMProtocolNameFromEnv(FFDisplayServerResult* result) diff --git a/src/detection/wmde/wmde.h b/src/detection/wm/wm.h similarity index 73% rename from src/detection/wmde/wmde.h rename to src/detection/wm/wm.h index 2e944991e..5301cff94 100644 --- a/src/detection/wmde/wmde.h +++ b/src/detection/wm/wm.h @@ -3,4 +3,3 @@ #include "fastfetch.h" const char* ffDetectWMPlugin(FFstrbuf* pluginName); -const char* ffDetectDEVersion(); diff --git a/src/detection/wmde/wmde_apple.c b/src/detection/wm/wm_apple.c similarity index 93% rename from src/detection/wmde/wmde_apple.c rename to src/detection/wm/wm_apple.c index feb7a611f..b767f8e1e 100644 --- a/src/detection/wmde/wmde_apple.c +++ b/src/detection/wm/wm_apple.c @@ -1,4 +1,4 @@ -#include "wmde.h" +#include "wm.h" #include "common/sysctl.h" #include "util/mallocHelper.h" @@ -35,8 +35,3 @@ const char* ffDetectWMPlugin(FFstrbuf* pluginName) return NULL; } - -const char* ffDetectDEVersion() -{ - return "No support"; -} diff --git a/src/detection/wm/wm_nosupport.c b/src/detection/wm/wm_nosupport.c new file mode 100644 index 000000000..37c0105d7 --- /dev/null +++ b/src/detection/wm/wm_nosupport.c @@ -0,0 +1,6 @@ +#include "wm.h" + +const char* ffDetectWMPlugin(FF_MAYBE_UNUSED FFstrbuf* pluginName) +{ + return "Not supported on this platform"; +} diff --git a/src/detection/wmde/wmde_linux.c b/src/detection/wmde/wmde_linux.c deleted file mode 100644 index 047fd5905..000000000 --- a/src/detection/wmde/wmde_linux.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "wmde.h" - -const char* ffDetectWMPlugin(FFstrbuf* pluginName) -{ - return "No support"; -} - -const char* ffDetectDEVersion() -{ - -} diff --git a/src/detection/wmde/wmde_nosupport.c b/src/detection/wmde/wmde_nosupport.c deleted file mode 100644 index 047fd5905..000000000 --- a/src/detection/wmde/wmde_nosupport.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "wmde.h" - -const char* ffDetectWMPlugin(FFstrbuf* pluginName) -{ - return "No support"; -} - -const char* ffDetectDEVersion() -{ - -} diff --git a/src/modules/de/de.c b/src/modules/de/de.c index ace665bf8..7cab66701 100644 --- a/src/modules/de/de.c +++ b/src/modules/de/de.c @@ -1,6 +1,7 @@ #include "common/printing.h" #include "common/jsonconfig.h" #include "detection/displayserver/displayserver.h" +#include "detection/de/de.h" #include "modules/de/de.h" #include "util/stringUtils.h" @@ -16,16 +17,19 @@ void ffPrintDE(FFDEOptions* options) return; } + FF_STRBUF_AUTO_DESTROY version = ffStrbufCreate(); + ffDetectDEVersion(&result->dePrettyName, &version, options); + if(options->moduleArgs.outputFormat.length == 0) { ffPrintLogoAndKey(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT); ffStrbufWriteTo(&result->dePrettyName, stdout); - if(result->deVersion.length > 0) + if(version.length > 0) { putchar(' '); - ffStrbufWriteTo(&result->deVersion, stdout); + ffStrbufWriteTo(&version, stdout); } putchar('\n'); @@ -35,7 +39,7 @@ void ffPrintDE(FFDEOptions* options) ffPrintFormat(FF_DE_MODULE_NAME, 0, &options->moduleArgs, FF_DE_NUM_FORMAT_ARGS, (FFformatarg[]){ {FF_FORMAT_ARG_TYPE_STRBUF, &result->deProcessName}, {FF_FORMAT_ARG_TYPE_STRBUF, &result->dePrettyName}, - {FF_FORMAT_ARG_TYPE_STRBUF, &result->deVersion} + {FF_FORMAT_ARG_TYPE_STRBUF, &version} }); } } @@ -47,6 +51,12 @@ bool ffParseDECommandOptions(FFDEOptions* options, const char* key, const char* if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs)) return true; + if (ffStrEqualsIgnCase(key, "slow-version-detection")) + { + options->slowVersionDetection = ffOptionParseBoolean(value); + return true; + } + return false; } @@ -63,6 +73,12 @@ void ffParseDEJsonObject(FFDEOptions* options, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) continue; + if (ffStrEqualsIgnCase(key, "slowVersionDetection")) + { + options->slowVersionDetection = yyjson_get_bool(val); + continue; + } + ffPrintError(FF_DE_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key); } } @@ -73,6 +89,9 @@ void ffGenerateDEJsonConfig(FFDEOptions* options, yyjson_mut_doc* doc, yyjson_mu ffInitDEOptions(&defaultOptions); ffJsonConfigGenerateModuleArgsConfig(doc, module, &defaultOptions.moduleArgs, &options->moduleArgs); + + if (defaultOptions.slowVersionDetection != options->slowVersionDetection) + yyjson_mut_obj_add_bool(doc, module, "slowVersionDetection", options->slowVersionDetection); } void ffGenerateDEJsonResult(FF_MAYBE_UNUSED FFDEOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module) @@ -85,10 +104,13 @@ void ffGenerateDEJsonResult(FF_MAYBE_UNUSED FFDEOptions* options, yyjson_mut_doc return; } + FF_STRBUF_AUTO_DESTROY version = ffStrbufCreate(); + ffDetectDEVersion(&result->dePrettyName, &version, options); + yyjson_mut_val* obj = yyjson_mut_obj_add_obj(doc, module, "result"); yyjson_mut_obj_add_strbuf(doc, obj, "processName", &result->deProcessName); yyjson_mut_obj_add_strbuf(doc, obj, "prettyName", &result->dePrettyName); - yyjson_mut_obj_add_strbuf(doc, obj, "version", &result->deVersion); + yyjson_mut_obj_add_strbuf(doc, obj, "version", &version); } void ffPrintDEHelpFormat(void) @@ -113,6 +135,8 @@ void ffInitDEOptions(FFDEOptions* options) ffGenerateDEJsonConfig ); ffOptionInitModuleArg(&options->moduleArgs); + + options->slowVersionDetection = false; } void ffDestroyDEOptions(FFDEOptions* options) diff --git a/src/modules/de/option.h b/src/modules/de/option.h index 8ad2b2000..f94797666 100644 --- a/src/modules/de/option.h +++ b/src/modules/de/option.h @@ -8,4 +8,6 @@ typedef struct FFDEOptions { FFModuleBaseInfo moduleInfo; FFModuleArgs moduleArgs; + + bool slowVersionDetection; } FFDEOptions; diff --git a/src/modules/wm/wm.c b/src/modules/wm/wm.c index 6c1e185f3..460eea4f4 100644 --- a/src/modules/wm/wm.c +++ b/src/modules/wm/wm.c @@ -1,7 +1,7 @@ #include "common/printing.h" #include "common/jsonconfig.h" #include "detection/displayserver/displayserver.h" -#include "detection/wmde/wmde.h" +#include "detection/wm/wm.h" #include "modules/wm/wm.h" #include "util/stringUtils.h"