1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/*
* HardInfo - Displays System Information
* Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <gtk/gtk.h>
#include <config.h>
#include <string.h>
#include <hardinfo.h>
#include <shell.h>
#include <iconcache.h>
enum {
DEVICES_KERNEL_MODULES,
DEVICES_PCI,
DEVICES_USB,
DEVICES_PRINTERS,
DEVICES_INPUT,
DEVICES_STORAGE,
} Entries;
static ModuleEntry hi_entries[] = {
{"Kernel Modules", "module.png"},
{"PCI Devices", "devices.png"},
{"USB Devices", "usb.png"},
{"Printers", "printer.png"},
{"Input Devices", "keyboard.png"},
{"Storage", "hdd.png"},
};
static GHashTable *devices = NULL;
static gchar *module_list = "";
static gchar *printer_list = NULL;
static gchar *pci_list = "";
static gchar *input_list = NULL;
static gchar *storage_list = "";
#define WALK_UNTIL(x) while((*buf != '\0') && (*buf != x)) buf++
#define GET_STR(field_name,ptr) \
if (strstr(tmp[0], field_name)) { \
ptr = g_markup_escape_text(g_strstrip(tmp[1]), strlen(tmp[1])); \
g_strfreev(tmp); \
continue; \
}
#include <arch/this/pci.h>
#include <arch/this/modules.h>
#include <arch/common/printers.h>
#include <arch/this/inputdevices.h>
#include <arch/this/usb.h>
#include <arch/this/storage.h>
static void
detect_devices(void)
{
devices = g_hash_table_new(g_str_hash, g_str_equal);
shell_status_update("Getting loaded modules information...");
scan_modules();
shell_status_update("Scanning PCI devices...");
scan_pci();
shell_status_update("Searching for printers...");
scan_printers();
shell_status_update("Scanning input devices...");
scan_inputdevices();
shell_status_update("Scanning USB devices...");
scan_usb();
shell_status_update("Scanning IDE devices...");
scan_ide();
shell_status_update("Scanning SCSI devices...");
scan_scsi();
}
gchar *
hi_more_info(gchar * entry)
{
gchar *info = (gchar *) g_hash_table_lookup(devices, entry);
if (info)
return g_strdup(info);
return g_strdup("[Empty]");
}
void
hi_reload(gint entry)
{
switch (entry) {
case DEVICES_INPUT:
scan_inputdevices();
break;
case DEVICES_PRINTERS:
scan_printers();
break;
case DEVICES_USB:
scan_usb();
break;
case DEVICES_STORAGE:
if (storage_list) {
g_free(storage_list);
g_free(storage_icons);
storage_list = g_strdup("");
storage_icons = g_strdup("");
}
scan_ide();
scan_scsi();
break;
}
}
gchar *
hi_info(gint entry)
{
if (!devices) {
detect_devices();
}
switch (entry) {
case DEVICES_KERNEL_MODULES:
return g_strdup_printf("[Loaded Modules]\n"
"%s"
"[$ShellParam$]\n"
"ViewType=1",
module_list);
case DEVICES_PCI:
return g_strdup_printf("[PCI Devices]\n"
"%s"
"[$ShellParam$]\n"
"ViewType=1\n",
pci_list);
case DEVICES_PRINTERS:
return g_strdup_printf("%s\n"
"[$ShellParam$]\n"
"ReloadInterval=5000", printer_list);
case DEVICES_STORAGE:
return g_strdup_printf("%s\n"
"[$ShellParam$]\n"
"ReloadInterval=5000\n"
"ViewType=1\n%s", storage_list, storage_icons);
case DEVICES_INPUT:
return g_strdup_printf("[Input Devices]\n"
"%s"
"[$ShellParam$]\n"
"ViewType=1\n"
"ReloadInterval=5000\n%s", input_list, input_icons);
case DEVICES_USB:
return g_strdup_printf("%s"
"[$ShellParam$]\n"
"ViewType=1\n"
"ReloadInterval=5000\n",
usb_list);
default:
return g_strdup("[Empty]\nNo info available=");
}
}
gint
hi_n_entries(void)
{
return G_N_ELEMENTS(hi_entries) - 1;
}
GdkPixbuf *
hi_icon(gint entry)
{
return icon_cache_get_pixbuf(hi_entries[entry].icon);
}
gchar *
hi_name(gint entry)
{
return hi_entries[entry].name;
}
|