Host / Chassis (Windows): remove options --*-use-wmi

This commit is contained in:
李通洲
2024-01-06 10:43:51 +08:00
parent 33f3199383
commit d578f1006c
18 changed files with 17 additions and 103 deletions
+2
View File
@@ -2,11 +2,13 @@
Changes:
* Remove support of option `--battery-dir`. We detect a lot of things in `/sys/class/*` and only module `Battery` supports specifying a custom directory for some reason, which is weird.
* Remove `--chassis-use-wmi` which is no longer used.
Features:
* Add `ENABLE_PROPRIETARY_GPU_DRIVER_API` cmake option to disable using of proprietary GPU driver APIs (GPU)
* Add power adapter detection support for Asahi Linux (PowerAdapter, Linux)
* Add battery serial number detection (Battery)
* Add host serial number and UUID detection (Host)
Bugfixes:
* Fix support of macOS Sonoma (Wallpaper, macOS)
-10
View File
@@ -875,11 +875,6 @@
"const": "chassis",
"description": "Print chassis type (desktop, laptop, etc)"
},
"useWmi": {
"description": "Set if WMI query should be used on Windows, which detects more information but slower",
"type": "boolean",
"default": false
},
"key": {
"$ref": "#/$defs/key"
},
@@ -1224,11 +1219,6 @@
"const": "host",
"description": "Print product name of your computer",
},
"useWmi": {
"description": "Set if WMI query should be used on Windows, which detects more information but slower",
"type": "boolean",
"default": false
},
"key": {
"$ref": "#/$defs/key"
},
-20
View File
@@ -842,26 +842,6 @@
"default": "default"
}
},
{
"long": "host-use-wmi",
"desc": "Set if WMI query should be used on Windows when detecting host",
"remark": "WMI query detects more information (UUID and serial number) but is slower. Windows only",
"arg": {
"type": "bool",
"optional": true,
"default": false
}
},
{
"long": "chassis-use-wmi",
"desc": "Set if WMI query should be used on Windows when detecting chassis",
"remark": "WMI query detects more information (vendor and version) but is slower. Windows only",
"arg": {
"type": "bool",
"optional": true,
"default": false
}
},
{
"long": "separator-string",
"desc": "Set the string printed by the separator module",
+1 -1
View File
@@ -9,5 +9,5 @@ typedef struct FFChassisResult
FFstrbuf version;
} FFChassisResult;
const char* ffDetectChassis(FFChassisResult* result, FFChassisOptions* options);
const char* ffDetectChassis(FFChassisResult* result);
const char* ffChassisTypeToString(uint32_t type);
+1 -1
View File
@@ -2,7 +2,7 @@
#include "common/settings.h"
#include "util/smbiosHelper.h"
const char* ffDetectChassis(FFChassisResult* result, FF_MAYBE_UNUSED FFChassisOptions* options)
const char* ffDetectChassis(FFChassisResult* result)
{
// Unlike other platforms, `smbios.chassis.type` return display string directly on my machine
ffSettingsGetFreeBSDKenv("smbios.chassis.type", &result->type);
+1 -1
View File
@@ -4,7 +4,7 @@
#include <stdlib.h>
const char* ffDetectChassis(FFChassisResult* result, FF_MAYBE_UNUSED FFChassisOptions* options)
const char* ffDetectChassis(FFChassisResult* result)
{
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/chassis_type", "/sys/class/dmi/id/chassis_type", &result->type);
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/chassis_vendor", "/sys/class/dmi/id/chassis_vendor", &result->vendor);
+1 -1
View File
@@ -1,6 +1,6 @@
#include "chassis.h"
const char* ffDetectChassis(FF_MAYBE_UNUSED FFChassisResult* result, FF_MAYBE_UNUSED FFChassisOptions* options)
const char* ffDetectChassis(FF_MAYBE_UNUSED FFChassisResult* result)
{
return "Not supported on this platform";
}
+1 -1
View File
@@ -18,7 +18,7 @@ typedef struct FFSmbiosSystemEnclosure
uint8_t NumberOfPowerCords;
} FFSmbiosSystemEnclosure;
const char* ffDetectChassis(FFChassisResult* result, FFChassisOptions* options)
const char* ffDetectChassis(FFChassisResult* result)
{
const FFRawSmbiosData* data = ffGetSmbiosData();
+1 -1
View File
@@ -13,4 +13,4 @@ typedef struct FFHostResult
FFstrbuf vendor;
} FFHostResult;
const char* ffDetectHost(FFHostResult* host, FFHostOptions* options);
const char* ffDetectHost(FFHostResult* host);
+1 -1
View File
@@ -2,7 +2,7 @@
#include "common/settings.h"
#include <ctype.h>
const char* ffDetectHost(FFHostResult* host, FF_MAYBE_UNUSED FFHostOptions* options)
const char* ffDetectHost(FFHostResult* host)
{
// http://newandroidbook.com/ddb/
ffSettingsGetAndroidProperty("ro.product.device", &host->family);
+1 -1
View File
@@ -201,7 +201,7 @@ const char* getOthersByIokit(FFHostResult* host)
return NULL;
}
const char* ffDetectHost(FFHostResult* host, FF_MAYBE_UNUSED FFHostOptions* options)
const char* ffDetectHost(FFHostResult* host)
{
const char* error = ffSysctlGetString("hw.model", &host->family);
if (error) return error;
+1 -1
View File
@@ -2,7 +2,7 @@
#include "common/settings.h"
#include "util/smbiosHelper.h"
const char* ffDetectHost(FFHostResult* host, FF_MAYBE_UNUSED FFHostOptions* options)
const char* ffDetectHost(FFHostResult* host)
{
ffSettingsGetFreeBSDKenv("smbios.system.product", &host->name);
ffCleanUpSmbiosValue(&host->name);
+1 -1
View File
@@ -27,7 +27,7 @@ static void getHostProductName(FFstrbuf* name)
ffStrbufClear(name);
}
const char* ffDetectHost(FFHostResult* host, FF_MAYBE_UNUSED FFHostOptions* options)
const char* ffDetectHost(FFHostResult* host)
{
ffGetSmbiosValue("/sys/devices/virtual/dmi/id/product_family", "/sys/class/dmi/id/product_family", &host->family);
getHostProductName(&host->name);
+1 -1
View File
@@ -20,7 +20,7 @@ typedef struct FFSmbiosSystemInfo
uint8_t Family;
} FFSmbiosSystemInfo;
const char* ffDetectHost(FFHostResult* host, FFHostOptions* options)
const char* ffDetectHost(FFHostResult* host)
{
const FFRawSmbiosData* fullData = ffGetSmbiosData();
+2 -27
View File
@@ -13,7 +13,7 @@ void ffPrintChassis(FFChassisOptions* options)
ffStrbufInit(&result.vendor);
ffStrbufInit(&result.version);
const char* error = ffDetectChassis(&result, options);
const char* error = ffDetectChassis(&result);
if(error)
{
@@ -57,14 +57,6 @@ bool ffParseChassisCommandOptions(FFChassisOptions* options, const char* key, co
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
return true;
#ifdef _WIN32
if (ffStrEqualsIgnCase(subKey, "use-wmi"))
{
options->useWmi = ffOptionParseBoolean(value);
return true;
}
#endif
return false;
}
@@ -81,14 +73,6 @@ void ffParseChassisJsonObject(FFChassisOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue;
#ifdef _WIN32
if (ffStrEqualsIgnCase(key, "useWmi"))
{
options->useWmi = yyjson_get_bool(val);
continue;
}
#endif
ffPrintError(FF_CHASSIS_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
}
}
@@ -99,11 +83,6 @@ void ffGenerateChassisJsonConfig(FFChassisOptions* options, yyjson_mut_doc* doc,
ffInitChassisOptions(&defaultOptions);
ffJsonConfigGenerateModuleArgsConfig(doc, module, &defaultOptions.moduleArgs, &options->moduleArgs);
#ifdef _WIN32
if (options->useWmi != defaultOptions.useWmi)
yyjson_mut_obj_add_bool(doc, module, "useWmi", options->useWmi);
#endif
}
void ffGenerateChassisJsonResult(FF_MAYBE_UNUSED FFChassisOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
@@ -113,7 +92,7 @@ void ffGenerateChassisJsonResult(FF_MAYBE_UNUSED FFChassisOptions* options, yyjs
ffStrbufInit(&result.vendor);
ffStrbufInit(&result.version);
const char* error = ffDetectChassis(&result, options);
const char* error = ffDetectChassis(&result);
if (error)
{
@@ -161,10 +140,6 @@ void ffInitChassisOptions(FFChassisOptions* options)
ffGenerateChassisJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs);
#ifdef _WIN32
options->useWmi = false;
#endif
}
void ffDestroyChassisOptions(FFChassisOptions* options)
-4
View File
@@ -8,8 +8,4 @@ typedef struct FFChassisOptions
{
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
#ifdef _WIN32
bool useWmi;
#endif
} FFChassisOptions;
+2 -27
View File
@@ -17,7 +17,7 @@ void ffPrintHost(FFHostOptions* options)
ffStrbufInit(&host.uuid);
ffStrbufInit(&host.vendor);
const char* error = ffDetectHost(&host, options);
const char* error = ffDetectHost(&host);
if(error)
{
ffPrintError(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "%s", error);
@@ -76,14 +76,6 @@ bool ffParseHostCommandOptions(FFHostOptions* options, const char* key, const ch
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
return true;
#ifdef _WIN32
if (ffStrEqualsIgnCase(subKey, "use-wmi"))
{
options->useWmi = ffOptionParseBoolean(value);
return true;
}
#endif
return false;
}
@@ -100,14 +92,6 @@ void ffParseHostJsonObject(FFHostOptions* options, yyjson_val* module)
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
continue;
#ifdef _WIN32
if (ffStrEqualsIgnCase(key, "useWmi"))
{
options->useWmi = yyjson_get_bool(val);
continue;
}
#endif
ffPrintError(FF_HOST_MODULE_NAME, 0, &options->moduleArgs, "Unknown JSON key %s", key);
}
}
@@ -118,11 +102,6 @@ void ffGenerateHostJsonConfig(FFHostOptions* options, yyjson_mut_doc* doc, yyjso
ffInitHostOptions(&defaultOptions);
ffJsonConfigGenerateModuleArgsConfig(doc, module, &defaultOptions.moduleArgs, &options->moduleArgs);
#ifdef _WIN32
if (options->useWmi != defaultOptions.useWmi)
yyjson_mut_obj_add_bool(doc, module, "useWmi", options->useWmi);
#endif
}
void ffGenerateHostJsonResult(FF_MAYBE_UNUSED FFHostOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
@@ -136,7 +115,7 @@ void ffGenerateHostJsonResult(FF_MAYBE_UNUSED FFHostOptions* options, yyjson_mut
ffStrbufInit(&host.uuid);
ffStrbufInit(&host.vendor);
const char* error = ffDetectHost(&host, options);
const char* error = ffDetectHost(&host);
if (error)
{
yyjson_mut_obj_add_str(doc, module, "error", error);
@@ -195,10 +174,6 @@ void ffInitHostOptions(FFHostOptions* options)
ffGenerateHostJsonConfig
);
ffOptionInitModuleArg(&options->moduleArgs);
#ifdef _WIN32
options->useWmi = false;
#endif
}
void ffDestroyHostOptions(FFHostOptions* options)
-4
View File
@@ -8,8 +8,4 @@ typedef struct FFHostOptions
{
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
#ifdef _WIN32
bool useWmi;
#endif
} FFHostOptions;