diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-01-03 20:26:24 +0000 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-01-03 20:26:24 +0000 |
commit | 0196020beb33bff391c5810b07a8ce34ce709278 (patch) | |
tree | 7a999dc9b2008b08e7db6e3dc5b69729523c10a4 | |
parent | 15bc02200336c0b032d79e7a4afa63bb26637481 (diff) |
Preliminary memory information support.
-rw-r--r-- | hardinfo2/arch/common/printers.h | 2 | ||||
l--------- | hardinfo2/arch/linux/alpha/devmemory.h | 1 | ||||
l--------- | hardinfo2/arch/linux/armv4l/devmemory.h | 1 | ||||
-rw-r--r-- | hardinfo2/arch/linux/common/devmemory.h | 50 | ||||
l--------- | hardinfo2/arch/linux/ia64/devmemory.h | 1 | ||||
l--------- | hardinfo2/arch/linux/m68k/devmemory.h | 1 | ||||
l--------- | hardinfo2/arch/linux/mips/devmemory.h | 1 | ||||
l--------- | hardinfo2/arch/linux/parisc/devmemory.h | 1 | ||||
l--------- | hardinfo2/arch/linux/ppc/devmemory.h | 1 | ||||
l--------- | hardinfo2/arch/linux/s390/devmemory.h | 1 | ||||
l--------- | hardinfo2/arch/linux/sparc/devmemory.h | 1 | ||||
l--------- | hardinfo2/arch/linux/x86/devmemory.h | 1 | ||||
-rw-r--r-- | hardinfo2/computer.c | 2 | ||||
-rw-r--r-- | hardinfo2/devices.c | 29 | ||||
-rw-r--r-- | hardinfo2/hardinfo.c | 12 | ||||
-rw-r--r-- | hardinfo2/iconcache.c | 1 | ||||
-rw-r--r-- | hardinfo2/shell.c | 22 | ||||
-rw-r--r-- | hardinfo2/stock.c | 3 | ||||
-rw-r--r-- | hardinfo2/util.c | 10 |
19 files changed, 128 insertions, 13 deletions
diff --git a/hardinfo2/arch/common/printers.h b/hardinfo2/arch/common/printers.h index 9fd146c0..3daf28e6 100644 --- a/hardinfo2/arch/common/printers.h +++ b/hardinfo2/arch/common/printers.h @@ -78,6 +78,6 @@ __scan_printers(void) } } else { printer_list = g_strdup("[Printers]\n" - "No printers found"); + "No printers found=\n"); } } diff --git a/hardinfo2/arch/linux/alpha/devmemory.h b/hardinfo2/arch/linux/alpha/devmemory.h new file mode 120000 index 00000000..f8a833e7 --- /dev/null +++ b/hardinfo2/arch/linux/alpha/devmemory.h @@ -0,0 +1 @@ +../../../arch/linux/common/devmemory.h
\ No newline at end of file diff --git a/hardinfo2/arch/linux/armv4l/devmemory.h b/hardinfo2/arch/linux/armv4l/devmemory.h new file mode 120000 index 00000000..f8a833e7 --- /dev/null +++ b/hardinfo2/arch/linux/armv4l/devmemory.h @@ -0,0 +1 @@ +../../../arch/linux/common/devmemory.h
\ No newline at end of file diff --git a/hardinfo2/arch/linux/common/devmemory.h b/hardinfo2/arch/linux/common/devmemory.h new file mode 100644 index 00000000..ca8ec4e6 --- /dev/null +++ b/hardinfo2/arch/linux/common/devmemory.h @@ -0,0 +1,50 @@ +/* + * HardInfo - Displays System Information + * Copyright (C) 2003-2007 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 + */ + +static void __scan_memory() +{ + gchar **keys; + gint i; + + g_file_get_contents("/proc/meminfo", &meminfo, NULL, NULL); + + keys = g_strsplit(meminfo, "\n", 0); + + g_free(meminfo); + meminfo = ""; + + g_free(lginterval); + lginterval = ""; + + for (i = 0; keys[i]; i++) { + gchar **newkeys = g_strsplit(keys[i], ":", 0); + + if (!newkeys[0]) break; + + g_strstrip(newkeys[1]); + + g_hash_table_replace(moreinfo, g_strdup(newkeys[0]), g_strdup(newkeys[1])); + meminfo = g_strconcat(meminfo, newkeys[0], "=", newkeys[1], "\n", NULL); + lginterval = g_strconcat(lginterval, + "LoadGraphInterval$", newkeys[0], "=500\n", + "UpdateInterval$", newkeys[0], "=500\n", NULL); + + g_strfreev(newkeys); + } + g_strfreev(keys); +} diff --git a/hardinfo2/arch/linux/ia64/devmemory.h b/hardinfo2/arch/linux/ia64/devmemory.h new file mode 120000 index 00000000..f8a833e7 --- /dev/null +++ b/hardinfo2/arch/linux/ia64/devmemory.h @@ -0,0 +1 @@ +../../../arch/linux/common/devmemory.h
\ No newline at end of file diff --git a/hardinfo2/arch/linux/m68k/devmemory.h b/hardinfo2/arch/linux/m68k/devmemory.h new file mode 120000 index 00000000..f8a833e7 --- /dev/null +++ b/hardinfo2/arch/linux/m68k/devmemory.h @@ -0,0 +1 @@ +../../../arch/linux/common/devmemory.h
\ No newline at end of file diff --git a/hardinfo2/arch/linux/mips/devmemory.h b/hardinfo2/arch/linux/mips/devmemory.h new file mode 120000 index 00000000..f8a833e7 --- /dev/null +++ b/hardinfo2/arch/linux/mips/devmemory.h @@ -0,0 +1 @@ +../../../arch/linux/common/devmemory.h
\ No newline at end of file diff --git a/hardinfo2/arch/linux/parisc/devmemory.h b/hardinfo2/arch/linux/parisc/devmemory.h new file mode 120000 index 00000000..f8a833e7 --- /dev/null +++ b/hardinfo2/arch/linux/parisc/devmemory.h @@ -0,0 +1 @@ +../../../arch/linux/common/devmemory.h
\ No newline at end of file diff --git a/hardinfo2/arch/linux/ppc/devmemory.h b/hardinfo2/arch/linux/ppc/devmemory.h new file mode 120000 index 00000000..f8a833e7 --- /dev/null +++ b/hardinfo2/arch/linux/ppc/devmemory.h @@ -0,0 +1 @@ +../../../arch/linux/common/devmemory.h
\ No newline at end of file diff --git a/hardinfo2/arch/linux/s390/devmemory.h b/hardinfo2/arch/linux/s390/devmemory.h new file mode 120000 index 00000000..f8a833e7 --- /dev/null +++ b/hardinfo2/arch/linux/s390/devmemory.h @@ -0,0 +1 @@ +../../../arch/linux/common/devmemory.h
\ No newline at end of file diff --git a/hardinfo2/arch/linux/sparc/devmemory.h b/hardinfo2/arch/linux/sparc/devmemory.h new file mode 120000 index 00000000..f8a833e7 --- /dev/null +++ b/hardinfo2/arch/linux/sparc/devmemory.h @@ -0,0 +1 @@ +../../../arch/linux/common/devmemory.h
\ No newline at end of file diff --git a/hardinfo2/arch/linux/x86/devmemory.h b/hardinfo2/arch/linux/x86/devmemory.h new file mode 120000 index 00000000..f8a833e7 --- /dev/null +++ b/hardinfo2/arch/linux/x86/devmemory.h @@ -0,0 +1 @@ +../../../arch/linux/common/devmemory.h
\ No newline at end of file diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c index 2d82cd50..9be3dcba 100644 --- a/hardinfo2/computer.c +++ b/hardinfo2/computer.c @@ -106,7 +106,7 @@ hi_more_info(gchar * entry) if (info) return g_strdup(info); - return g_strdup_printf("[Empty %s]", entry); + return g_strdup_printf("[%s]", entry); } gchar * diff --git a/hardinfo2/devices.c b/hardinfo2/devices.c index d44e5222..76d5204b 100644 --- a/hardinfo2/devices.c +++ b/hardinfo2/devices.c @@ -79,6 +79,7 @@ static gchar *pci_list = ""; static gchar *input_list = NULL; static gchar *storage_list = NULL; static gchar *battery_list = NULL; +static gchar *meminfo = NULL, *lginterval = NULL; #define WALK_UNTIL(x) while((*buf != '\0') && (*buf != x)) buf++ @@ -113,7 +114,6 @@ static gchar *battery_list = NULL; typedef struct _Processor Processor; #include <arch/this/processor.h> - #include <arch/this/pci.h> #include <arch/common/printers.h> #include <arch/this/inputdevices.h> @@ -121,6 +121,7 @@ typedef struct _Processor Processor; #include <arch/this/storage.h> #include <arch/this/battery.h> #include <arch/this/sensors.h> +#include <arch/this/devmemory.h> gchar * get_processor_name(void) @@ -183,7 +184,19 @@ hi_more_info(gchar * entry) if (info) return g_strdup(info); - return g_strdup("[Empty]"); + + return g_strdup("[TSC]"); +} + +gchar * +hi_get_field(gchar * field) +{ + gchar *info = (gchar *) g_hash_table_lookup(moreinfo, field); + + if (info) + return g_strdup(info); + + return g_strdup(field); } void @@ -199,6 +212,7 @@ void scan_memory(gboolean reload) { SCAN_START(); + __scan_memory(); SCAN_END(); } @@ -271,7 +285,13 @@ callback_processors() gchar * callback_memory() { - return g_strdup("[Memory]\nNot implemented=\n"); + return g_strdup_printf("[Memory]\n" + "%s\n" + "[$ShellParam$]\n" + "ViewType=2\n" + "RescanInterval=2000\n" + "%s\n", + meminfo, lginterval); } gchar * @@ -358,6 +378,5 @@ hi_module_get_weight(void) void hi_module_init(void) { - moreinfo = g_hash_table_new(g_str_hash, g_str_equal); + moreinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); } - diff --git a/hardinfo2/hardinfo.c b/hardinfo2/hardinfo.c index 807b3239..8178d792 100644 --- a/hardinfo2/hardinfo.c +++ b/hardinfo2/hardinfo.c @@ -33,6 +33,8 @@ main(int argc, char **argv) { GSList *modules; + DEBUG("HardInfo version " VERSION ". Debug version."); + /* parse all command line parameters */ parameters_init(&argc, &argv, ¶ms); @@ -52,6 +54,8 @@ main(int argc, char **argv) PREFIX, LIBPREFIX, PLATFORM, KERNEL, HOSTNAME); + + DEBUG(" Debugging is enabled."); /* show also available modules */ params.list_modules = TRUE; @@ -96,24 +100,29 @@ main(int argc, char **argv) if (params.use_modules) { /* load only selected modules */ + DEBUG("loading user-selected modules"); modules = modules_load_selected(); } else { /* load all modules */ + DEBUG("loading all modules"); modules = modules_load_all(); } if (params.gui_running) { - /* initialize gui and start gtk+ main loop */ + /* initialize gui and start gtk+ main loop */ icon_cache_init(); stock_icons_init(); shell_init(modules); + DEBUG("entering gtk+ main loop"); gtk_main(); } else if (params.create_report) { /* generate report */ gchar *report; + DEBUG("generating report"); + report = report_create_from_module_list_format(modules, params.report_format); g_print("%s", report); @@ -121,5 +130,6 @@ main(int argc, char **argv) g_free(report); } + DEBUG("finished"); return 0; } diff --git a/hardinfo2/iconcache.c b/hardinfo2/iconcache.c index 353f1454..fbd0dd84 100644 --- a/hardinfo2/iconcache.c +++ b/hardinfo2/iconcache.c @@ -23,6 +23,7 @@ static GHashTable *cache = NULL; void icon_cache_init(void) { + DEBUG("initializing icon cache"); if (!cache) { cache = g_hash_table_new(g_str_hash, g_str_equal); } diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index efe3a4e1..34fd1aea 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -42,6 +42,7 @@ static void module_selected_show_info(ShellModuleEntry * entry, static void info_selected(GtkTreeSelection * ts, gpointer data); static void info_selected_show_extra(gchar * data); static gboolean reload_section(gpointer data); +static gboolean rescan_section(gpointer data); /* * Globals ******************************************************************** @@ -471,6 +472,8 @@ void shell_init(GSList * modules) return; } + DEBUG("initializing shell"); + create_window(); shell->tree = tree_new(); @@ -536,7 +539,7 @@ static gboolean update_field(gpointer data) ts = gtk_tree_view_get_selection(GTK_TREE_VIEW (shell->info->view)); - + if (iter && gtk_tree_selection_iter_is_selected(ts, iter)) { load_graph_update(shell->loadgraph, atoi(value)); } @@ -596,6 +599,15 @@ static gboolean reload_section(gpointer data) return FALSE; } +static gboolean rescan_section(gpointer data) +{ + ShellModuleEntry *entry = (ShellModuleEntry *) data; + + module_entry_reload(entry); + + return entry->selected; +} + gint info_tree_compare_val_func(GtkTreeModel * model, GtkTreeIter * a, @@ -705,7 +717,7 @@ group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry, fu->field_name = g_strdup(strchr(key, '$') + 1); fu->entry = entry; fu->loadgraph = TRUE; - + g_timeout_add(ms, update_field, fu); } else if (g_str_equal(key, "LoadGraphMaxValue")) { gint max_value; @@ -719,6 +731,12 @@ group_handle_special(GKeyFile * key_file, ShellModuleEntry * entry, ms = g_key_file_get_integer(key_file, group, key, NULL); g_timeout_add(ms, reload_section, entry); + } else if (g_str_equal(key, "RescanInterval")) { + gint ms; + + ms = g_key_file_get_integer(key_file, group, key, NULL); + + g_timeout_add(ms, rescan_section, entry); } else if (g_str_equal(key, "OrderType")) { shell->_order_type = g_key_file_get_integer(key_file, group, diff --git a/hardinfo2/stock.c b/hardinfo2/stock.c index 6d82fcea..7dc22b7d 100644 --- a/hardinfo2/stock.c +++ b/hardinfo2/stock.c @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <config.h> #include <gtk/gtk.h> #include <stock.h> #include <iconcache.h> @@ -69,6 +70,8 @@ void stock_icons_init(void) gint i; guint n_stock_icons = G_N_ELEMENTS(stock_icons); + DEBUG("initializing stock icons"); + icon_factory = gtk_icon_factory_new(); for (i = 0; i < n_stock_icons; i++) { diff --git a/hardinfo2/util.c b/hardinfo2/util.c index 96dfbbc7..c0b7d35e 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -805,8 +805,9 @@ void tree_view_save_image(gchar *filename) static gboolean __idle_free_do(gpointer ptr) { - DEBUG("GC memory at %p: %s", ptr, - g_utf8_validate((gchar*)ptr, 3, NULL) ? (gchar*)ptr : "[non string data]"); + DEBUG("Freeing mem @ %p: %s", ptr, + g_utf8_validate((gchar*)ptr, 3, NULL) ? + (gchar*)ptr : "[non string data]"); g_free(ptr); @@ -815,6 +816,8 @@ static gboolean __idle_free_do(gpointer ptr) gpointer idle_free(gpointer ptr) { + DEBUG("Will free mem @ %p in 5000ms", ptr); + g_timeout_add(5000, __idle_free_do, ptr); return ptr; @@ -866,5 +869,6 @@ gchar *module_entry_function(ShellModuleEntry *module_entry) return g_strdup(module_entry->func()); } - return g_strdup("[Error]\n" "Invalid module="); + return g_strdup("[Error]\n" + "Invalid module="); } |