aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hardinfo/info.c2
-rw-r--r--includes/info.h1
-rw-r--r--modules/computer.c2
-rw-r--r--modules/devices.c41
-rw-r--r--modules/devices/storage.c30
5 files changed, 55 insertions, 21 deletions
diff --git a/hardinfo/info.c b/hardinfo/info.c
index af3af60f..f888ddac 100644
--- a/hardinfo/info.c
+++ b/hardinfo/info.c
@@ -109,7 +109,7 @@ struct InfoField info_field_printf(const gchar *name, const gchar *format, ...)
};
}
-static void info_group_strip_extra(struct InfoGroup *group)
+void info_group_strip_extra(struct InfoGroup *group)
{
guint fi;
char *val, *oldval;
diff --git a/includes/info.h b/includes/info.h
index 14e1b9eb..794e3679 100644
--- a/includes/info.h
+++ b/includes/info.h
@@ -76,6 +76,7 @@ struct InfoField {
struct Info *info_new(void);
struct InfoGroup *info_add_group(struct Info *info, const gchar *group_name, ...);
+void info_group_strip_extra(struct InfoGroup *group);
void info_add_computed_group(struct Info *info, const gchar *name, const gchar *value);
void info_add_computed_group_wo_extra(struct Info *info, const gchar *name, const gchar *value);
diff --git a/modules/computer.c b/modules/computer.c
index 284e44a7..67ce2d21 100644
--- a/modules/computer.c
+++ b/modules/computer.c
@@ -1009,7 +1009,7 @@ gchar *hi_module_get_summary(void)
"Method=computer::getDisplaySummary\n"
"[%s]\n"
"Icon=hdd.png\n"
- "Method=devices::getStorageDevices\n"
+ "Method=devices::getStorageDevicesSimple\n"
"[%s]\n"
"Icon=printer.png\n"
"Method=devices::getPrinters\n"
diff --git a/modules/devices.c b/modules/devices.c
index 850dd9d4..429dd6b6 100644
--- a/modules/devices.c
+++ b/modules/devices.c
@@ -272,6 +272,44 @@ gchar *get_processor_name_and_desc(void)
return nd;
}
+gchar *get_storage_devices_simple(void)
+{
+ scan_storage(FALSE);
+
+ struct Info *info = info_unflatten(storage_list);
+ if (!info) {
+ return "";
+ }
+
+ int i, fi;
+ struct InfoGroup *group;
+ struct InfoField *field;
+ gchar *storage_devs = NULL, *tmp;
+ const gchar *dev_label, *model_wo_tags;
+
+ GRegex *regex;
+ regex = g_regex_new ("<.*>", 0, 0, NULL);
+
+ for (i = 0; i < info->groups->len; i++) {
+ group = &g_array_index(info->groups, struct InfoGroup, info->groups->len - 1);
+ if (!group)
+ continue;
+
+ info_group_strip_extra(group);
+ for (fi = 0; fi < group->fields->len; fi++) {
+ field = &g_array_index(group->fields, struct InfoField, fi);
+ if (!field->value)
+ continue;
+
+ tmp = g_regex_replace(regex, field->value, -1, 0, "", 0, NULL); // remove html tags
+ storage_devs = h_strdup_cprintf("%s\n", storage_devs, tmp);
+ g_free(tmp);
+ }
+ }
+ g_free(info);
+
+ return storage_devs;
+}
gchar *get_storage_devices(void)
{
@@ -515,6 +553,7 @@ ShellModuleMethod *hi_exported_methods(void)
{"getProcessorFrequency", get_processor_max_frequency},
{"getProcessorFrequencyDesc", get_processor_frequency_desc},
{"getStorageDevices", get_storage_devices},
+ {"getStorageDevicesSimple", get_storage_devices_simple},
{"getPrinters", get_printers},
{"getInputDevices", get_input_devices},
{"getMotherboard", get_motherboard},
@@ -745,7 +784,7 @@ gchar *callback_storage()
"ColumnTitle$Value=%s\n"
"ColumnTitle$Extra1=%s\n"
"ShowColumnHeaders=true\n"
- "ViewType=1\n%s", storage_list, _("Model"), _("Vendor"), _("Size"), storage_icons);
+ "ViewType=1\n%s", storage_list, _("Device"), _("Size"), _("Model"), storage_icons);
}
gchar *callback_input()
diff --git a/modules/devices/storage.c b/modules/devices/storage.c
index b4e34994..aef282f5 100644
--- a/modules/devices/storage.c
+++ b/modules/devices/storage.c
@@ -81,8 +81,8 @@ gboolean __scan_udisks2_devices(void) {
udiskp *part;
udisksa *attrib;
gchar *udisks2_storage_list = NULL, *features = NULL, *moreinfo = NULL;
- gchar *devid, *label, *size, *tmp = NULL, *media_comp = NULL, *ven_tag = NULL;
- const gchar *url, *vendor_str, *media_label, *alabel, *icon, *media_curr = NULL;
+ gchar *devid, *size, *tmp = NULL, *media_comp = NULL, *ven_tag = NULL;
+ const gchar *url, *media_label, *alabel, *icon, *media_curr = NULL;
int n = 0, i, j;
// http://storaged.org/doc/udisks2-api/latest/gdbus-org.freedesktop.UDisks2.Drive.html#gdbus-property-org-freedesktop-UDisks2-Drive.MediaCompatibility
@@ -195,13 +195,6 @@ gboolean __scan_udisks2_devices(void) {
disk = (udiskd *)node->data;
devid = g_strdup_printf("UDISKS%d", n++);
- if (disk->vendor && strlen(disk->vendor) > 0)
- vendor_str = disk->vendor;
- else
- vendor_str = _("(Unknown)");
-
- label = g_strdup(disk->model);
-
icon = NULL;
media_curr = disk->media;
@@ -245,8 +238,8 @@ gboolean __scan_udisks2_devices(void) {
size = size_human_readable((gfloat) disk->size);
ven_tag = vendor_list_ribbon(disk->vendors, params.fmt_opts);
- udisks2_storage_list = h_strdup_cprintf("$%s$%s=%s|%s\n", udisks2_storage_list, devid, label, ven_tag ? ven_tag : "", size);
- storage_icons = h_strdup_cprintf("Icon$%s$%s=%s.png\n", storage_icons, devid, label, icon);
+ udisks2_storage_list = h_strdup_cprintf("$%s$%s=%s|%s %s\n", udisks2_storage_list, devid, disk->block_dev, size, ven_tag ? ven_tag : "", disk->model);
+ storage_icons = h_strdup_cprintf("Icon$%s$%s=%s.png\n", storage_icons, devid, disk->model, icon);
features = h_strdup_cprintf("%s", features, disk->removable ? _("Removable"): _("Fixed"));
if (disk->ejectable) {
@@ -267,11 +260,13 @@ gboolean __scan_udisks2_devices(void) {
moreinfo = g_strdup_printf(_("[Drive Information]\n"
"Model=%s\n"),
- label);
+ disk->model);
- moreinfo = h_strdup_cprintf("$^$%s=%s\n",
- moreinfo,
- _("Vendor"), vendor_str);
+ if (disk->vendor && *disk->vendor) {
+ moreinfo = h_strdup_cprintf("$^$%s=%s\n",
+ moreinfo,
+ _("Vendor"), disk->vendor);
+ }
moreinfo = h_strdup_cprintf(_("Revision=%s\n"
"Block Device=%s\n"
@@ -391,7 +386,6 @@ gboolean __scan_udisks2_devices(void) {
moreinfo_add_with_prefix("DEV", devid, moreinfo);
g_free(devid);
g_free(features);
- g_free(label);
g_free(media_comp);
media_comp = NULL;
@@ -497,7 +491,7 @@ void __scan_scsi_devices(void)
}
gchar *devid = g_strdup_printf("SCSI%d", n);
- scsi_storage_list = h_strdup_cprintf("$%s$%s=\n", scsi_storage_list, devid, model);
+ scsi_storage_list = h_strdup_cprintf("$%s$scsi%d=|%s\n", scsi_storage_list, devid, scsi_controller, model);
storage_icons = h_strdup_cprintf("Icon$%s$%s=%s.png\n", storage_icons, devid, model, icon);
gchar *strhash = g_strdup_printf(_("[Device Information]\n"
@@ -694,7 +688,7 @@ void __scan_ide_devices(void)
gchar *devid = g_strdup_printf("IDE%d", n);
- ide_storage_list = h_strdup_cprintf("$%s$%s=\n", ide_storage_list, devid, model);
+ ide_storage_list = h_strdup_cprintf("$%s$%hd%c=|%s\n", ide_storage_list, devid, iface, model);
storage_icons =
h_strdup_cprintf("Icon$%s$%s=%s.png\n", storage_icons,
devid, model, g_str_equal(media, "cdrom") ? "cdrom" : "hdd");