3
Copyright 1998 Helge Deller deller@gmx.de
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License or (at your option) version 3 or any later version
9
accepted by the membership of KDE e.V. (or its successor approved
10
by the membership of KDE e.V.), which shall act as a proxy
11
defined in Section 14 of version 3 of the license.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
26
#include <linux/kernel.h>
28
#include "config-infocenter.h"
32
#endif //HAVE_PCIUTILS
35
#include <QHeaderView>
38
#include <kiconloader.h>
39
#include <kglobalsettings.h>
42
#define INFO_IRQ "/proc/interrupts"
43
#define INFO_DMA "/proc/dma"
45
#define INFO_PCI "/proc/pci"
47
#define INFO_IOPORTS "/proc/ioports"
49
#define INFO_MISC "/proc/misc"
51
#define INFO_SCSI "/proc/scsi/scsi"
53
#define MAXCOLUMNWIDTH 600
55
bool GetInfo_ReadfromFile(QTreeWidget* tree, const char *FileName, const QChar& splitChar) {
63
if (!file.open(QIODevice::ReadOnly)) {
66
QTextStream stream(&file);
68
QString line = stream.readLine();
70
while (!line.isNull()) {
72
if (!line.isEmpty()) {
73
if (!splitChar.isNull()) {
74
int pos = line.indexOf(splitChar);
75
s1 = line.left(pos-1).trimmed();
76
s2 = line.mid(pos+1).trimmed();
82
new QTreeWidgetItem(tree, list);
84
line = stream.readLine();
92
bool GetInfo_IRQ(QTreeWidget* tree) {
93
tree->setFont(KGlobalSettings::fixedFont());
94
tree->setHeaderHidden(true);
96
return GetInfo_ReadfromFile(tree, INFO_IRQ, 0);
99
bool GetInfo_DMA(QTreeWidget* tree) {
100
QFile file(INFO_DMA);
103
headers << i18n("DMA-Channel") << i18n("Used By");
104
tree->setHeaderLabels(headers);
106
if (file.exists() && file.open(QIODevice::ReadOnly)) {
107
QTextStream stream(&file);
110
line = stream.readLine();
111
while (!line.isNull()) {
112
if (!line.isEmpty()) {
113
QRegExp rx("^\\s*(\\S+)\\s*:\\s*(\\S+)");
114
if (-1 != rx.indexIn(line)) {
116
list << rx.cap(1) << rx.cap(2);
117
new QTreeWidgetItem(tree, list);
120
line = stream.readLine();
130
bool GetInfo_PCI(QTreeWidget* tree) {
134
if ( (num = GetInfo_PCIUtils(tree))) {
138
#endif //HAVE_PCIUTILS
139
tree->setHeaderHidden(true);
140
tree->setSortingEnabled(false);
142
/* try to get the output of the lspci package first */
143
if ((num = GetInfo_ReadfromPipe(tree, "lspci -v", true)) || (num = GetInfo_ReadfromPipe(tree, "/sbin/lspci -v", true)) || (num = GetInfo_ReadfromPipe(tree, "/usr/sbin/lspci -v", true)) || (num = GetInfo_ReadfromPipe(tree, "/usr/local/sbin/lspci -v", true)) || (num = GetInfo_ReadfromPipe(tree,
144
"/usr/bin/lspci -v", true)))
147
/* if lspci failed, read the contents of /proc/pci */
148
return GetInfo_ReadfromFile(tree, INFO_PCI, 0);
152
bool GetInfo_IO_Ports(QTreeWidget* tree) {
154
headers << i18n("I/O-Range") << i18n("Used By");
155
tree->setHeaderLabels(headers);
156
return GetInfo_ReadfromFile(tree, INFO_IOPORTS, ':');
159
bool GetInfo_SCSI(QTreeWidget* tree) {
160
return GetInfo_ReadfromFile(tree, INFO_SCSI, 0);
163
static void cleanPassword(QString & str) {
165
QString passwd("password=");
168
index = str.indexOf(passwd, index, Qt::CaseInsensitive);
170
index += passwd.length();
171
while (index < (int) str.length() && str[index] != ' ' && str[index] != ',')
177
bool GetInfo_XServer_and_Video(QTreeWidget* tree) {
178
return GetInfo_XServer_Generic(tree);