Fix for Bug #14822 Apps/Devices ACPI button handling

* Patch checks for pathless results, and in cases where acpi/hid is returned uses the hid element.
  In case of any non-hid nodes returning no path, a separate "unknown" entry is also added.

* Also disables one "not implemented" message in line with https://review.haiku-os.org/c/haiku/+/696

Change-Id: I7ac92c7f3c5cb03401b9502aa345a86f117a5a20
Reviewed-on: https://review.haiku-os.org/c/879
Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
This commit is contained in:
Rob Gill 2019-01-14 14:58:32 +00:00 committed by Axel Dörfler
parent 57e2488804
commit ee3106db4a

View File

@ -1,8 +1,9 @@
/*
* Copyright 2008-2010 Haiku Inc. All rights reserved.
* Copyright 2008-2019 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Rob Gill <rrobgill@protonmail.com>
* Alexander von Gluck (kallisti5)
*/
@ -36,8 +37,10 @@ DeviceACPI::InitFromAttributes()
BString outlineName;
BString nodeACPIPath;
BString rootACPIPath;
BString nodeACPIHid;
rootACPIPath = nodeACPIPath = GetAttribute("acpi/path").fValue;
nodeACPIHid = GetAttribute("acpi/hid").fValue;
// Grab just the root node info
// We grab 6 characters to not identify sub nodes of root node
@ -60,16 +63,28 @@ DeviceACPI::InitFromAttributes()
outlineName << string.String();
} else if (rootACPIPath == "\\_SI_") {
outlineName = B_TRANSLATE("ACPI System Indicator");
} else {
} else if (nodeACPIPath != "") {
// This allows to localize apostrophes, too
BString string(B_TRANSLATE("ACPI node '%1'"));
string.ReplaceFirst("%1", nodeACPIPath);
outlineName << string.String();
}
} else if (nodeACPIPath == "" && nodeACPIHid != "") {
// Handle ACPI HID entries that do not return a path
nodeACPIHid.Remove(0, nodeACPIHid.FindLast("_") + 1);
BString string(B_TRANSLATE("ACPI Button '%1'"));
string.ReplaceFirst("%1", nodeACPIHid);
outlineName << string.String();
} else {
BString string(B_TRANSLATE("ACPI <unknown>"));
outlineName << string.String();
}
SetAttribute(B_TRANSLATE("Device name"), outlineName.String());
#if 0
// These are a source of confusion for users.
// Until we can display something useful, let's not show the lines at all.
SetAttribute(B_TRANSLATE("Manufacturer"), B_TRANSLATE("Not implemented"));
#endif
SetText(outlineName.String());
}