diff options
author | Simon Quigley <tsimonq2@ubuntu.com> | 2017-06-19 14:38:48 -0500 |
---|---|---|
committer | Simon Quigley <tsimonq2@ubuntu.com> | 2017-06-19 14:38:48 -0500 |
commit | 4979bb6cbbbe39eb44c32530cd13f86bf44e5d77 (patch) | |
tree | 614372cf2510ad45311ecea088012683635d0b76 /devices.c | |
parent | ee6c3f9b4cf08a276c971dee66e1acdb32b3dff9 (diff) |
Import Upstream version 0.5c
Diffstat (limited to 'devices.c')
-rw-r--r-- | devices.c | 107 |
1 files changed, 92 insertions, 15 deletions
@@ -1,6 +1,6 @@ /* * HardInfo - Displays System Information - * Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br> + * Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@hardinfo.org> * * 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 @@ -16,6 +16,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef __USE_XOPEN +#define __USE_XOPEN +#endif /* __USE_XOPEN */ + +#ifndef _XOPEN_SOURCE +#define _XOPEN_SOURCE +#endif /* _XOPEN_SOURCE */ + #include <gtk/gtk.h> #include <config.h> #include <string.h> @@ -28,18 +36,6 @@ #include <expr.h> #include <socket.h> -enum { - DEVICES_PROCESSORS, - DEVICES_MEMORY, - DEVICES_PCI, - DEVICES_USB, - DEVICES_PRINTERS, - DEVICES_BATTERY, - DEVICES_SENSORS, - DEVICES_INPUT, - DEVICES_STORAGE, -} Entries; - gchar *callback_processors(); gchar *callback_memory(); gchar *callback_battery(); @@ -49,6 +45,10 @@ gchar *callback_printers(); gchar *callback_storage(); gchar *callback_input(); gchar *callback_usb(); +#if defined(ARCH_i386) || defined(ARCH_x86_64) +gchar *callback_dmi(); +#endif +gchar *callback_device_resources(); void scan_processors(gboolean reload); void scan_memory(gboolean reload); @@ -59,6 +59,10 @@ void scan_printers(gboolean reload); void scan_storage(gboolean reload); void scan_input(gboolean reload); void scan_usb(gboolean reload); +#if defined(ARCH_i386) || defined(ARCH_x86_64) +void scan_dmi(gboolean reload); +#endif +void scan_device_resources(gboolean reload); static ModuleEntry entries[] = { {"Processor", "processor.png", callback_processors, scan_processors}, @@ -70,6 +74,10 @@ static ModuleEntry entries[] = { {"Sensors", "therm.png", callback_sensors, scan_sensors}, {"Input Devices", "inputdevices.png", callback_input, scan_input}, {"Storage", "hdd.png", callback_storage, scan_storage}, +#if defined(ARCH_i386) || defined(ARCH_x86_64) + {"DMI", "computer.png", callback_dmi, scan_dmi}, +#endif /* x86 or x86_64 */ + {"Resources", "resources.png", callback_device_resources, scan_device_resources}, {NULL} }; @@ -123,6 +131,11 @@ typedef struct _Processor Processor; #include <arch/this/battery.h> #include <arch/this/sensors.h> #include <arch/this/devmemory.h> +#include <arch/this/resources.h> + +#if defined(ARCH_i386) || defined(ARCH_x86_64) +#include <arch/this/dmi.h> +#endif /* x86 or x86_64 */ gchar *get_processor_name(void) { @@ -160,13 +173,59 @@ gchar *get_input_devices(void) return input_list; } +gchar *get_processor_count(void) +{ + scan_processors(FALSE); + + return g_strdup_printf("%d", g_slist_length(processors)); +} + +gchar *get_processor_frequency(void) +{ + Processor *p; + + scan_processors(FALSE); + + p = (Processor *)processors->data; + if (p->cpu_mhz == 0.0f) { + return g_strdup("Unknown"); + } else { + return g_strdup_printf("%.0f", p->cpu_mhz); + } +} + +gchar *get_pci_device_description(gchar *pci_id) +{ + gchar *description; + + if (!_pci_devices) { + scan_pci(FALSE); + } + + if ((description = g_hash_table_lookup(_pci_devices, pci_id))) { + return g_strdup(description); + } + + return NULL; +} + +gchar *get_memory_total(void) +{ + /* FIXME */ + return g_strdup("0.0"); +} + ShellModuleMethod *hi_exported_methods(void) { static ShellModuleMethod m[] = { + {"getProcessorCount", get_processor_count}, {"getProcessorName", get_processor_name}, + {"getProcessorFrequency", get_processor_frequency}, + {"getMemoryTotal", get_memory_total}, {"getStorageDevices", get_storage_devices}, {"getPrinters", get_printers}, {"getInputDevices", get_input_devices}, + {"getPCIDeviceDescription", get_pci_device_description}, {NULL} }; @@ -176,7 +235,7 @@ ShellModuleMethod *hi_exported_methods(void) gchar *hi_more_info(gchar * entry) { gchar *info = (gchar *) g_hash_table_lookup(moreinfo, entry); - + if (info) return g_strdup(info); @@ -193,6 +252,15 @@ gchar *hi_get_field(gchar * field) return g_strdup(field); } +#if defined(ARCH_i386) || defined(ARCH_x86_64) +void scan_dmi(gboolean reload) +{ + SCAN_START(); + __scan_dmi(); + SCAN_END(); +} +#endif + void scan_processors(gboolean reload) { SCAN_START(); @@ -266,6 +334,13 @@ gchar *callback_processors() return processor_get_info(processors); } +#if defined(ARCH_i386) || defined(ARCH_x86_64) +gchar *callback_dmi() +{ + return dmi_info; +} +#endif + gchar *callback_memory() { return g_strdup_printf("[Memory]\n" @@ -301,6 +376,7 @@ gchar *callback_printers() { return g_strdup_printf("%s\n" "[$ShellParam$]\n" + "ViewType=1\n" "ReloadInterval=5000", printer_list); } @@ -342,7 +418,7 @@ gchar *hi_module_get_name(void) guchar hi_module_get_weight(void) { - return 160; + return 85; } void hi_module_init(void) @@ -362,6 +438,7 @@ void hi_module_init(void) moreinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); __init_memory_labels(); + __init_cups(); } ModuleAbout *hi_module_get_about(void) |