diff options
Diffstat (limited to 'hardinfo2')
-rw-r--r-- | hardinfo2/arch/common/printers.h | 2 | ||||
-rw-r--r-- | hardinfo2/arch/common/users.h | 3 | ||||
-rw-r--r-- | hardinfo2/arch/linux/common/battery.h | 2 | ||||
-rw-r--r-- | hardinfo2/arch/linux/common/inputdevices.h | 2 | ||||
-rw-r--r-- | hardinfo2/arch/linux/common/modules.h | 6 | ||||
-rw-r--r-- | hardinfo2/arch/linux/common/pci.h | 2 | ||||
-rw-r--r-- | hardinfo2/arch/linux/common/sensors.h | 2 | ||||
-rw-r--r-- | hardinfo2/arch/linux/common/storage.h | 4 | ||||
-rw-r--r-- | hardinfo2/arch/linux/common/usb.h | 2 | ||||
-rw-r--r-- | hardinfo2/arch/linux/x86/processor.h | 2 | ||||
-rw-r--r-- | hardinfo2/benchmark.c | 273 | ||||
-rw-r--r-- | hardinfo2/callbacks.c | 2 | ||||
-rw-r--r-- | hardinfo2/computer.c | 462 | ||||
-rw-r--r-- | hardinfo2/devices.c | 343 | ||||
-rw-r--r-- | hardinfo2/hardinfo.h | 19 | ||||
-rw-r--r-- | hardinfo2/report.c | 3 | ||||
-rw-r--r-- | hardinfo2/shell.c | 25 | ||||
-rw-r--r-- | hardinfo2/shell.h | 5 | ||||
-rw-r--r-- | hardinfo2/util.c | 137 |
19 files changed, 734 insertions, 562 deletions
diff --git a/hardinfo2/arch/common/printers.h b/hardinfo2/arch/common/printers.h index 3bb98f4c..b467f5a0 100644 --- a/hardinfo2/arch/common/printers.h +++ b/hardinfo2/arch/common/printers.h @@ -17,7 +17,7 @@ */ void -scan_printers(void) +__scan_printers(void) { static GModule *cups = NULL; static int (*cupsGetPrinters) (char ***printers) = NULL; diff --git a/hardinfo2/arch/common/users.h b/hardinfo2/arch/common/users.h index 08acd97a..84cec9d9 100644 --- a/hardinfo2/arch/common/users.h +++ b/hardinfo2/arch/common/users.h @@ -14,7 +14,8 @@ remove_users(gpointer key, gpointer value, gpointer data) return FALSE; } -void scan_users(void) +static void +scan_users_do(void) { FILE *passwd; char buffer[512]; diff --git a/hardinfo2/arch/linux/common/battery.h b/hardinfo2/arch/linux/common/battery.h index dc003459..8be133ee 100644 --- a/hardinfo2/arch/linux/common/battery.h +++ b/hardinfo2/arch/linux/common/battery.h @@ -17,7 +17,7 @@ */ static void -scan_battery(void) +__scan_battery(void) { gchar *acpi_path; diff --git a/hardinfo2/arch/linux/common/inputdevices.h b/hardinfo2/arch/linux/common/inputdevices.h index e9deffa7..0742bb3b 100644 --- a/hardinfo2/arch/linux/common/inputdevices.h +++ b/hardinfo2/arch/linux/common/inputdevices.h @@ -42,7 +42,7 @@ static struct { }; void -scan_inputdevices(void) +__scan_input_devices(void) { FILE *dev; gchar buffer[128]; diff --git a/hardinfo2/arch/linux/common/modules.h b/hardinfo2/arch/linux/common/modules.h index 3acf4aba..9b895ee8 100644 --- a/hardinfo2/arch/linux/common/modules.h +++ b/hardinfo2/arch/linux/common/modules.h @@ -34,14 +34,12 @@ remove_module_devices(gpointer key, gpointer value, gpointer data) return FALSE; } -void -scan_modules(void) +static void +scan_modules_do(void) { FILE *lsmod; gchar buffer[1024]; - shell_status_update("Getting loaded modules information..."); - if (module_list) { g_free(module_list); module_list = NULL; diff --git a/hardinfo2/arch/linux/common/pci.h b/hardinfo2/arch/linux/common/pci.h index 5f48ba44..e50691d0 100644 --- a/hardinfo2/arch/linux/common/pci.h +++ b/hardinfo2/arch/linux/common/pci.h @@ -17,7 +17,7 @@ */ void -scan_pci(void) +__scan_pci(void) { FILE *lspci; gchar buffer[256], *buf, *strhash = NULL, *strdevice = NULL; diff --git a/hardinfo2/arch/linux/common/sensors.h b/hardinfo2/arch/linux/common/sensors.h index 246c53e7..3303d5d2 100644 --- a/hardinfo2/arch/linux/common/sensors.h +++ b/hardinfo2/arch/linux/common/sensors.h @@ -355,7 +355,7 @@ static void read_sensors_hddtemp(void) } } -static void read_sensors(void) +static void __scan_sensors(void) { if (sensors) g_free(sensors); diff --git a/hardinfo2/arch/linux/common/storage.h b/hardinfo2/arch/linux/common/storage.h index 3397570d..8e248d3b 100644 --- a/hardinfo2/arch/linux/common/storage.h +++ b/hardinfo2/arch/linux/common/storage.h @@ -31,7 +31,7 @@ remove_scsi_devices(gpointer key, gpointer value, gpointer data) /* SCSI support by Pascal F.Martin <pascalmartin@earthlink.net> */ void -scan_scsi(void) +__scan_scsi_devices(void) { FILE *proc_scsi; gchar buffer[256], *buf; @@ -160,7 +160,7 @@ remove_ide_devices(gpointer key, gpointer value, gpointer data) void -scan_ide(void) +__scan_ide_devices(void) { FILE *proc_ide; gchar *device, iface, *model, *media, *pgeometry = NULL, *lgeometry = diff --git a/hardinfo2/arch/linux/common/usb.h b/hardinfo2/arch/linux/common/usb.h index 286d9380..606bb0fb 100644 --- a/hardinfo2/arch/linux/common/usb.h +++ b/hardinfo2/arch/linux/common/usb.h @@ -32,7 +32,7 @@ remove_usb_devices(gpointer key, gpointer value, gpointer data) static gchar *usb_list = NULL; void -scan_usb(void) +__scan_usb(void) { FILE *dev; gchar buffer[128]; diff --git a/hardinfo2/arch/linux/x86/processor.h b/hardinfo2/arch/linux/x86/processor.h index 4e4a2646..a756a958 100644 --- a/hardinfo2/arch/linux/x86/processor.h +++ b/hardinfo2/arch/linux/x86/processor.h @@ -132,7 +132,7 @@ static void get_processor_strfamily(Processor * processor) } } -static GSList *computer_get_processors(void) +static GSList *__scan_processors(void) { GSList *procs = NULL; Processor *processor = NULL; diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c index bcf5c84e..c6b1be62 100644 --- a/hardinfo2/benchmark.c +++ b/hardinfo2/benchmark.c @@ -30,54 +30,75 @@ enum { BENCHMARK_RAYTRACE } Entries; -static ModuleEntry hi_entries[] = { - {"CPU ZLib", "compress.png"}, - {"CPU Fibonacci", "module.png"}, - {"CPU MD5", "module.png"}, - {"CPU SHA1", "module.png"}, - {"CPU Blowfish", "blowfish.png"}, - {"FPU Raytracing", "raytrace.png"} +void scan_zlib(gboolean reload); +void scan_raytr(gboolean reload); +void scan_bfsh(gboolean reload); +void scan_md5(gboolean reload); +void scan_fib(gboolean reload); +void scan_sha1(gboolean reload); + +gchar *callback_zlib(); +gchar *callback_raytr(); +gchar *callback_bfsh(); +gchar *callback_md5(); +gchar *callback_fib(); +gchar *callback_sha1(); + + +static ModuleEntry entries[] = { + {"CPU ZLib", "compress.png", callback_zlib, scan_zlib}, + {"CPU Fibonacci", "module.png", callback_fib, scan_fib}, + {"CPU MD5", "module.png", callback_md5, scan_md5}, + {"CPU SHA1", "module.png", callback_sha1, scan_sha1}, + {"CPU Blowfish", "blowfish.png", callback_bfsh, scan_bfsh}, + {"FPU Raytracing", "raytrace.png", callback_raytr, scan_raytr}, + { NULL } }; -static gchar * -__benchmark_include_results(gchar *results, const gchar *benchmark, - ShellOrderType order_type) +static gchar *__benchmark_include_results(gchar * results, + const gchar * benchmark, + ShellOrderType order_type) { GKeyFile *conf; gchar **machines, *bconf_path; int i; - + conf = g_key_file_new(); - bconf_path = g_build_filename(params.path_data, "benchmark.conf", NULL); + bconf_path = + g_build_filename(params.path_data, "benchmark.conf", NULL); g_key_file_load_from_file(conf, bconf_path, 0, NULL); - + machines = g_key_file_get_keys(conf, benchmark, NULL, NULL); for (i = 0; machines && machines[i]; i++) { - gchar *value = g_key_file_get_value(conf, benchmark, machines[i], NULL); - results = g_strconcat(results, machines[i], "=", value, "\n", NULL); - g_free(value); + gchar *value = + g_key_file_get_value(conf, benchmark, machines[i], NULL); + results = + g_strconcat(results, machines[i], "=", value, "\n", NULL); + g_free(value); } - + g_strfreev(machines); g_key_file_free(conf); g_free(bconf_path); - + return g_strdup_printf("[$ShellParam$]\n" - "Zebra=1\n" - "OrderType=%d\n" - "ViewType=3\n%s", order_type, results); + "Zebra=1\n" + "OrderType=%d\n" + "ViewType=3\n%s", order_type, results); } -static gchar * -benchmark_include_results_reverse(gchar *results, const gchar *benchmark) +static gchar *benchmark_include_results_reverse(gchar * results, + const gchar * benchmark) { - return __benchmark_include_results(results, benchmark, SHELL_ORDER_DESCENDING); + return __benchmark_include_results(results, benchmark, + SHELL_ORDER_DESCENDING); } -static gchar * -benchmark_include_results(gchar *results, const gchar *benchmark) +static gchar *benchmark_include_results(gchar * results, + const gchar * benchmark) { - return __benchmark_include_results(results, benchmark, SHELL_ORDER_ASCENDING); + return __benchmark_include_results(results, benchmark, + SHELL_ORDER_ASCENDING); } #include <arch/common/fib.h> @@ -88,138 +109,118 @@ benchmark_include_results(gchar *results, const gchar *benchmark) #include <arch/common/raytrace.h> static gchar *bench_zlib = NULL, - *bench_fib = NULL, - *bench_md5 = NULL, - *bench_sha1 = NULL, - *bench_fish = NULL, - *bench_ray = NULL; + *bench_fib = NULL, + *bench_md5 = NULL, + *bench_sha1 = NULL, + *bench_fish = NULL, + *bench_ray = NULL; -gchar * -hi_info(gint entry) +gchar *callback_zlib() { - switch (entry) { - case BENCHMARK_ZLIB: - if (bench_zlib) - return g_strdup(bench_zlib); - - bench_zlib = benchmark_zlib(); - return g_strdup(bench_zlib); - - case BENCHMARK_RAYTRACE: - if (bench_ray) - return g_strdup(bench_ray); - - bench_ray = benchmark_raytrace(); - return g_strdup(bench_ray); - - case BENCHMARK_BLOWFISH: - if (bench_fish) - return g_strdup(bench_fish); - - bench_fish = benchmark_fish(); - return g_strdup(bench_fish); - - case BENCHMARK_MD5: - if (bench_md5) - return g_strdup(bench_md5); - - bench_md5 = benchmark_md5(); - return g_strdup(bench_md5); - - case BENCHMARK_FIB: - if (bench_fib) - return g_strdup(bench_fib); - - bench_fib = benchmark_fib(); - return g_strdup(bench_fib); - - case BENCHMARK_SHA1: - if (bench_sha1) - return g_strdup(bench_sha1); - - bench_sha1 = benchmark_sha1(); - return g_strdup(bench_sha1); - - default: - return g_strdup("[Empty]\n"); - } + return g_strdup(bench_zlib); } -const gchar * -hi_note_func(gint entry) +gchar *callback_raytr() { - switch (entry) { - case BENCHMARK_ZLIB: - case BENCHMARK_MD5: - case BENCHMARK_SHA1: - return "Results in bytes/second. Higher is better."; - - case BENCHMARK_RAYTRACE: - case BENCHMARK_BLOWFISH: - case BENCHMARK_FIB: - return "Results in seconds. Lower is better."; - } - - return ""; + return g_strdup(bench_ray); } -void -hi_reload(gint entry) +gchar *callback_bfsh() { - switch (entry) { - case BENCHMARK_ZLIB: - if (bench_zlib) g_free(bench_zlib); - bench_zlib = benchmark_zlib(); - break; - case BENCHMARK_RAYTRACE: - if (bench_ray) g_free(bench_ray); - bench_ray = benchmark_raytrace(); - break; - case BENCHMARK_BLOWFISH: - if (bench_fish) g_free(bench_fish); - bench_fish = benchmark_fish(); - break; - case BENCHMARK_MD5: - if (bench_md5) g_free(bench_md5); - bench_md5 = benchmark_md5(); - break; - case BENCHMARK_FIB: - if (bench_fib) g_free(bench_fib); - bench_fib = benchmark_fib(); - break; - case BENCHMARK_SHA1: - if (bench_sha1) g_free(bench_sha1); - bench_sha1 = benchmark_sha1(); - break; - } + return g_strdup(bench_fish); +} + +gchar *callback_md5() +{ + return g_strdup(bench_md5); +} + +gchar *callback_fib() +{ + return g_strdup(bench_fib); +} + +gchar *callback_sha1() +{ + return g_strdup(bench_sha1); } -gint -hi_n_entries(void) +void scan_zlib(gboolean reload) { - return G_N_ELEMENTS(hi_entries) - 1; + SCAN_START(); + g_free(bench_zlib); + bench_zlib = benchmark_zlib(); + SCAN_END(); } -GdkPixbuf * -hi_icon(gint entry) +void scan_raytr(gboolean reload) { - return icon_cache_get_pixbuf(hi_entries[entry].icon); + SCAN_START(); + g_free(bench_ray); + bench_ray = benchmark_raytrace(); + SCAN_END(); } -gchar * -hi_name(gint entry) +void scan_bfsh(gboolean reload) { - return hi_entries[entry].name; + SCAN_START(); + g_free(bench_fish); + bench_fish = benchmark_fish(); + SCAN_END(); } -gchar * -hi_module_name(void) +void scan_md5(gboolean reload) +{ + SCAN_START(); + g_free(bench_md5); + bench_md5 = benchmark_md5(); + SCAN_END(); +} + +void scan_fib(gboolean reload) +{ + SCAN_START(); + g_free(bench_fib); + bench_fib = benchmark_fib(); + SCAN_END(); +} + +void scan_sha1(gboolean reload) +{ + SCAN_START(); + g_free(bench_sha1); + bench_sha1 = benchmark_sha1(); + SCAN_END(); +} + +const gchar *hi_note_func(gint entry) +{ + switch (entry) { + case BENCHMARK_ZLIB: + case BENCHMARK_MD5: + case BENCHMARK_SHA1: + return "Results in bytes/second. Higher is better."; + + case BENCHMARK_RAYTRACE: + case BENCHMARK_BLOWFISH: + case BENCHMARK_FIB: + return "Results in seconds. Lower is better."; + } + + return ""; +} + +gchar *hi_module_get_name(void) { return g_strdup("Benchmarks"); } -guchar -hi_module_weight(void) +guchar hi_module_get_weight(void) { return 240; } + +ModuleEntry *hi_module_get_entries(void) +{ + return entries; +} diff --git a/hardinfo2/callbacks.c b/hardinfo2/callbacks.c index 5ee34fa4..bc50c668 100644 --- a/hardinfo2/callbacks.c +++ b/hardinfo2/callbacks.c @@ -83,7 +83,7 @@ void cb_copy_to_clipboard() ShellModuleEntry *entry = shell_get_main_shell()->selected; if (entry) { - gchar *data = entry->func(entry->number); + gchar *data = module_entry_function(entry); GtkClipboard *clip = gtk_clipboard_get(gdk_atom_intern("CLIPBOARD", FALSE)); ReportContext *ctx = report_context_text_new(NULL); diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c index aebff09b..6f98aa09 100644 --- a/hardinfo2/computer.c +++ b/hardinfo2/computer.c @@ -43,22 +43,46 @@ enum { COMPUTER_USERS, } Entries; -static ModuleEntry hi_entries[] = { - {"Summary", "summary.png"}, - {"Operating System", "os.png"}, - {"Kernel Modules", "module.png"}, - {"Languages", "language.png"}, - {"Filesystems", "dev_removable.png"}, - {"Shared Directories", "shares.png"}, - {"Display", "monitor.png"}, - {"Network Interfaces", "network.png"}, - {"Users", "users.png"}, +/* Callbacks */ +gchar *callback_summary(); +gchar *callback_os(); +gchar *callback_modules(); +gchar *callback_locales(); +gchar *callback_fs(); +gchar *callback_shares(); +gchar *callback_display(); +gchar *callback_network(); +gchar *callback_users(); + +/* Scan callbacks */ +void scan_summary(gboolean reload); +void scan_os(gboolean reload); +void scan_modules(gboolean reload); +void scan_locales(gboolean reload); +void scan_fs(gboolean reload); +void scan_shares(gboolean reload); +void scan_display(gboolean reload); +void scan_network(gboolean reload); +void scan_users(gboolean reload); + +static ModuleEntry entries[] = { + { "Summary", "summary.png", callback_summary, scan_summary }, + { "Operating System", "os.png", callback_os, scan_os }, + { "Kernel Modules", "module.png", callback_modules, scan_modules }, + { "Languages", "language.png", callback_locales, scan_locales }, + { "Filesystems", "dev_removable.png", callback_fs, scan_fs }, + { "Shared Directories", "shares.png", callback_shares, scan_shares }, + { "Display", "monitor.png", callback_display, scan_display }, + { "Network Interfaces", "network.png", callback_network, scan_network }, + { "Users", "users.png", callback_users, scan_users }, + { NULL }, }; #include "computer.h" static GHashTable *moreinfo = NULL; static gchar *module_list = NULL; +static Computer *computer = NULL; #include <arch/this/modules.h> #include <arch/common/languages.h> @@ -74,71 +98,6 @@ static gchar *module_list = NULL; #include <arch/this/net.h> #include <arch/common/users.h> -static Computer * -computer_get_info(void) -{ - Computer *computer; - - computer = g_new0(Computer, 1); - - if (moreinfo) { -#ifdef g_hash_table_unref - g_hash_table_unref(moreinfo); -#else - g_free(moreinfo); -#endif - } - - moreinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); - - shell_status_update("Getting memory information..."); - computer->memory = computer_get_memory(); - - shell_status_update("Getting operating system information..."); - computer->os = computer_get_os(); - - shell_status_update("Getting display information..."); - computer->display = computer_get_display(); - - shell_status_update("Getting sound card information..."); - computer->alsa = computer_get_alsainfo(); - - shell_status_update("Getting mounted file system information..."); - scan_filesystems(); - - shell_status_update("Getting shared directories..."); - scan_samba_shared_directories(); - scan_nfs_shared_directories(); - - shell_status_update("Obtaining network information..."); - scan_net_interfaces(); - - shell_status_update("Obtaining users information..."); - scan_users(); - - computer->date_time = "..."; - return computer; -} - -void -hi_reload(gint entry) -{ - switch (entry) { - case COMPUTER_KERNEL_MODULES: - scan_modules(); - break; - case COMPUTER_FILESYSTEMS: - scan_filesystems(); - break; - case COMPUTER_NETWORK: - scan_net_interfaces(); - break; - case COMPUTER_USERS: - scan_users(); - break; - } -} - gchar * hi_more_info(gchar * entry) { @@ -178,176 +137,243 @@ hi_get_field(gchar * field) return tmp; } -gchar * -hi_info(gint entry) +void scan_summary(gboolean reload) { - static Computer *computer = NULL; - static gchar *tmp1, *tmp2; + SCAN_START(); + module_entry_scan_all_except(entries, COMPUTER_SUMMARY); + computer->alsa = computer_get_alsainfo(); + SCAN_END(); +} - if (!computer) { - computer = computer_get_info(); - } +void scan_os(gboolean reload) +{ + SCAN_START(); + computer->os = computer_get_os(); + SCAN_END(); +} - switch (entry) { - case COMPUTER_KERNEL_MODULES: - if (!module_list) { - shell_status_update("Getting loaded module information..."); - scan_modules(); - } - return g_strdup_printf("[Loaded Modules]\n" - "%s" - "[$ShellParam$]\n" - "ViewType=1", - module_list); - case COMPUTER_NETWORK: - return g_strdup_printf("[$ShellParam$]\n" - "ReloadInterval=3000\n" - "ViewType=1\n" - "%s", network_interfaces); - case COMPUTER_USERS: - return g_strdup_printf("[$ShellParam$]\n" - "ReloadInterval=10000\n" - "ViewType=1\n" - "[Human Users]\n" - "%s\n" - "[System Users]\n" - "%s\n", human_users, sys_users); - case COMPUTER_SHARES: - return g_strdup_printf("[SAMBA]\n" - "%s\n" - "[NFS]\n" - "%s", smb_shares_list, nfs_shares_list); - case COMPUTER_FILESYSTEMS: - return g_strdup_printf("[$ShellParam$]\n" - "ViewType=1\n" - "ReloadInterval=5000\n" - "[Mounted File Systems]\n%s\n", fs_list); - case COMPUTER_SUMMARY: - tmp1 = computer_get_alsacards(computer); - tmp2 = module_call_method("devices::getProcessorName"); - - schedule_free(tmp1); - schedule_free(tmp2); - - return g_strdup_printf("[$ShellParam$]\n" - "UpdateInterval$Memory=1000\n" - "UpdateInterval$Date/Time=1000\n" - "[Computer]\n" - "Processor=%s\n" - "Memory=...\n" - "Operating System=%s\n" - "User Name=%s\n" - "Date/Time=%s\n" - "[Display]\n" - "Resolution=%dx%d pixels\n" - "OpenGL Renderer=%s\n" - "X11 Vendor=%s\n" - "[Multimedia]\n" - "%s\n", - tmp2, - computer->os->distro, - computer->os->username, - computer->date_time, - computer->display->width, - computer->display->height, - computer->display->ogl_renderer, - computer->display->vendor, - tmp1); - case COMPUTER_DISPLAY: - return g_strdup_printf("[Display]\n" - "Resolution=%dx%d pixels\n" - "Vendor=%s\n" - "Version=%s\n" - "[Monitors]\n" - "%s" - "[Extensions]\n" - "%s" - "[OpenGL]\n" - "Vendor=%s\n" - "Renderer=%s\n" - "Version=%s\n" - "Direct Rendering=%s\n", - computer->display->width, - computer->display->height, - computer->display->vendor, - computer->display->version, - computer->display->monitors, - computer->display->extensions, - computer->display->ogl_vendor, - computer->display->ogl_renderer, - computer->display->ogl_version, - computer->display->dri ? "Yes" : "No"); - case COMPUTER_OPERATING_SYSTEM: - return g_strdup_printf("[$ShellParam$]\n" - "UpdateInterval$Uptime=10000\n" - "UpdateInterval$Load Average=1000\n" - "[Version]\n" - "Kernel=%s\n" - "Compiled=%s\n" - "C Library=%s\n" - "Distribution=%s\n" - "[Current Session]\n" - "Computer Name=%s\n" - "User Name=%s\n" - "#Language=%s\n" - "Home Directory=%s\n" - "Desktop Environment=%s\n" - "[Misc]\n" - "Uptime=...\n" - "Load Average=...", - computer->os->kernel, - computer->os->compiled_date, - computer->os->libc, - computer->os->distro, - computer->os->hostname, - computer->os->username, - computer->os->language, - computer->os->homedir, - computer->os->desktop); - case COMPUTER_LANGUAGE: - return g_strdup_printf("[$ShellParam$]\n" - "ViewType=1\n" - "[Available Languages]\n" - "%s", computer->os->languages); - default: - return g_strdup("[Empty]\nNo info available="); - } +void scan_modules(gboolean reload) +{ + SCAN_START(); + scan_modules_do(); + SCAN_END(); } -gint -hi_n_entries(void) +void scan_locales(gboolean reload) { - return G_N_ELEMENTS(hi_entries) - 1; + SCAN_START(); + scan_languages(computer->os); + SCAN_END(); } -GdkPixbuf * -hi_icon(gint entry) +void scan_fs(gboolean reload) { - return icon_cache_get_pixbuf(hi_entries[entry].icon); + SCAN_START(); + scan_filesystems(); + SCAN_END(); } -gchar * -hi_name(gint entry) +void scan_shares(gboolean reload) +{ + SCAN_START(); + scan_samba_shared_directories(); + scan_nfs_shared_directories(); + SCAN_END(); +} + +void scan_display(gboolean reload) +{ + SCAN_START(); + computer->display = computer_get_display(); + SCAN_END(); +} + +void scan_network(gboolean reload) +{ + SCAN_START(); + scan_net_interfaces(); + SCAN_END(); +} + +void scan_users(gboolean reload) +{ + SCAN_START(); + scan_users_do(); + SCAN_END(); +} + +gchar *callback_summary() { - return hi_entries[entry].name; + return g_strdup_printf("[$ShellParam$]\n" + "UpdateInterval$Memory=1000\n" + "UpdateInterval$Date/Time=1000\n" + "#ReloadInterval=5000\n" + "[Computer]\n" + "Processor=%s\n" + "Memory=...\n" + "Operating System=%s\n" + "User Name=%s\n" + "Date/Time=...\n" + "[Display]\n" + "Resolution=%dx%d pixels\n" + "OpenGL Renderer=%s\n" + "X11 Vendor=%s\n" + "[Multimedia]\n" + "%s\n" + "[Input Devices]\n%s\n" + "%s\n" + "%s\n", + (gchar*)idle_free(module_call_method("devices::getProcessorName")), + computer->os->distro, + computer->os->username, + computer->display->width, + computer->display->height, + computer->display->ogl_renderer, + computer->display->vendor, + (gchar*)idle_free(computer_get_alsacards(computer)), + (gchar*)idle_free(module_call_method("devices::getInputDevices")), + (gchar*)idle_free(module_call_method("devices::getPrinters")), + (gchar*)idle_free(module_call_method("devices::getStorageDevices"))); +} + +gchar *callback_os() +{ + return g_strdup_printf("[$ShellParam$]\n" + "UpdateInterval$Uptime=10000\n" + "UpdateInterval$Load Average=1000\n" + "[Version]\n" + "Kernel=%s\n" + "Compiled=%s\n" + "C Library=%s\n" + "Distribution=%s\n" + "[Current Session]\n" + "Computer Name=%s\n" + "User Name=%s\n" + "#Language=%s\n" + "Home Directory=%s\n" + "Desktop Environment=%s\n" + "[Misc]\n" + "Uptime=...\n" + "Load Average=...", + computer->os->kernel, + computer->os->compiled_date, + computer->os->libc, + computer->os->distro, + computer->os->hostname, + computer->os->username, + computer->os->language, + computer->os->homedir, + computer->os->desktop); +} + +gchar *callback_modules() +{ + return g_strdup_printf("[Loaded Modules]\n" + "%s" + "[$ShellParam$]\n" + "ViewType=1", + module_list); +} + +gchar *callback_locales() +{ + return g_strdup_printf("[$ShellParam$]\n" + "ViewType=1\n" + "[Available Languages]\n" + "%s", computer->os->languages); +} + +gchar *callback_fs() +{ + return g_strdup_printf("[$ShellParam$]\n" + "ViewType=1\n" + "ReloadInterval=5000\n" + "[Mounted File Systems]\n%s\n", fs_list); +} + +gchar *callback_shares() +{ + return g_strdup_printf("[SAMBA]\n" + "%s\n" + "[NFS]\n" + "%s", smb_shares_list, nfs_shares_list); +} + +gchar *callback_display() +{ + return g_strdup_printf("[Display]\n" + "Resolution=%dx%d pixels\n" + "Vendor=%s\n" + "Version=%s\n" + "[Monitors]\n" + "%s" + "[Extensions]\n" + "%s" + "[OpenGL]\n" + "Vendor=%s\n" + "Renderer=%s\n" + "Version=%s\n" + "Direct Rendering=%s\n", + computer->display->width, + computer->display->height, + computer->display->vendor, + computer->display->version, + computer->display->monitors, + computer->display->extensions, + computer->display->ogl_vendor, + computer->display->ogl_renderer, + computer->display->ogl_version, + computer->display->dri ? "Yes" : "No"); +} + +gchar *callback_network() +{ + return g_strdup_printf("[$ShellParam$]\n" + "ReloadInterval=3000\n" + "ViewType=1\n" + "%s", network_interfaces); +} + +gchar *callback_users() +{ + return g_strdup_printf("[$ShellParam$]\n" + "ReloadInterval=10000\n" + "ViewType=1\n" + "[Human Users]\n" + "%s\n" + "[System Users]\n" + "%s\n", human_users, sys_users); +} + +ModuleEntry * +hi_module_get_entries(void) +{ + return entries; } gchar * -hi_module_name(void) +hi_module_get_name(void) { return g_strdup("Computer"); } guchar -hi_module_weight(void) +hi_module_get_weight(void) { return 80; } gchar ** -hi_module_depends_on(void) +hi_module_get_dependencies(void) { static gchar *deps[] = { "devices.so", NULL }; return deps; } + +void +hi_module_init(void) +{ + computer = g_new0(Computer, 1); + moreinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); +} diff --git a/hardinfo2/devices.c b/hardinfo2/devices.c index 9e6d15be..08ba754c 100644 --- a/hardinfo2/devices.c +++ b/hardinfo2/devices.c @@ -39,16 +39,37 @@ enum { DEVICES_STORAGE, } Entries; -static ModuleEntry hi_entries[] = { - {"Processor", "processor.png"}, - {"Memory", "memory.png"}, - {"PCI Devices", "devices.png"}, - {"USB Devices", "usb.png"}, - {"Printers", "printer.png"}, - {"Battery", "battery.png"}, - {"Sensors", "therm.png"}, - {"Input Devices", "keyboard.png"}, - {"Storage", "hdd.png"}, +gchar *callback_processors(); +gchar *callback_memory(); +gchar *callback_battery(); +gchar *callback_pci(); +gchar *callback_sensors(); +gchar *callback_printers(); +gchar *callback_storage(); +gchar *callback_input(); +gchar *callback_usb(); + +void scan_processors(gboolean reload); +void scan_memory(gboolean reload); +void scan_battery(gboolean reload); +void scan_pci(gboolean reload); +void scan_sensors(gboolean reload); +void scan_printers(gboolean reload); +void scan_storage(gboolean reload); +void scan_input(gboolean reload); +void scan_usb(gboolean reload); + +static ModuleEntry entries[] = { + {"Processor", "processor.png", callback_processors, scan_processors}, + {"Memory", "memory.png", callback_memory, scan_memory}, + {"PCI Devices", "devices.png", callback_pci, scan_pci}, + {"USB Devices", "usb.png", callback_usb, scan_usb}, + {"Printers", "printer.png", callback_printers, scan_printers,}, + {"Battery", "battery.png", callback_battery, scan_battery}, + {"Sensors", "therm.png", callback_sensors, scan_sensors}, + {"Input Devices", "keyboard.png", callback_input, scan_input}, + {"Storage", "hdd.png", callback_storage, scan_storage}, + { NULL } }; static GHashTable *moreinfo = NULL; @@ -116,55 +137,56 @@ struct _Processor { #include <arch/this/battery.h> #include <arch/this/sensors.h> -static void -detect_devices(void) +gchar * +get_processor_name(void) { - moreinfo = g_hash_table_new(g_str_hash, g_str_equal); - - shell_status_update("Getting processor information..."); - if (!processors) - processors = computer_get_processors(); - - 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(); + scan_processors(FALSE); + + Processor *p = (Processor *) processors->data; - shell_status_update("Scanning SCSI devices..."); - scan_scsi(); + if (g_slist_length(processors) > 1) { + return idle_free(g_strdup_printf("%dx %s", + g_slist_length(processors), + p->model_name)); + } else { + return p->model_name; + } +} - shell_status_update("Scanning batteries..."); - scan_battery(); +gchar * +get_storage_devices(void) +{ + if (!*storage_list) { + scan_storage(FALSE); + } + + return storage_list; +} - shell_status_update("Reading sensors..."); - read_sensors(); +gchar * +get_printers(void) +{ + scan_printers(FALSE); + + return printer_list; } gchar * -get_processor_name(void) +get_input_devices(void) { - if (!processors) { - processors = computer_get_processors(); - } + scan_input(FALSE); - Processor *p = (Processor *) processors->data; - return p->model_name; + return input_list; } -ShellModuleMethod *hi_exported_methods(void) +ShellModuleMethod* +hi_exported_methods(void) { static ShellModuleMethod m[] = { - { "getProcessorName", get_processor_name }, + { "getProcessorName", get_processor_name }, + { "getStorageDevices", get_storage_devices }, + { "getPrinters", get_printers }, + { "getInputDevices", get_input_devices }, { NULL } }; @@ -182,115 +204,174 @@ hi_more_info(gchar * entry) } void -hi_reload(gint entry) +scan_processors(gboolean reload) { - switch (entry) { - case DEVICES_BATTERY: - scan_battery(); - break; - case DEVICES_INPUT: - scan_inputdevices(); - break; - case DEVICES_PRINTERS: - scan_printers(); - break; - case DEVICES_USB: - scan_usb(); - break; - case DEVICES_SENSORS: - read_sensors(); - 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; - } + SCAN_START(); + if (!processors) + processors = __scan_processors(); + SCAN_END(); +} + +void +scan_memory(gboolean reload) +{ + SCAN_START(); + SCAN_END(); +} + +void +scan_battery(gboolean reload) +{ + SCAN_START(); + __scan_battery(); + SCAN_END(); +} + +void +scan_pci(gboolean reload) +{ + SCAN_START(); + __scan_pci(); + SCAN_END(); +} + +void +scan_sensors(gboolean reload) +{ + SCAN_START(); + __scan_sensors(); + SCAN_END(); +} + +void +scan_printers(gboolean reload) +{ + SCAN_START(); + __scan_printers(); + SCAN_END(); +} + +void +scan_storage(gboolean reload) +{ + SCAN_START(); + __scan_ide_devices(); + __scan_scsi_devices(); + SCAN_END(); +} + +void +scan_input(gboolean reload) +{ + SCAN_START(); + __scan_input_devices(); + SCAN_END(); +} + +void +scan_usb(gboolean reload) +{ + SCAN_START(); + __scan_usb(); + SCAN_END(); } gchar * -hi_info(gint entry) +callback_processors() { - if (!moreinfo) { - detect_devices(); - } + return processor_get_info(processors); +} - switch (entry) { - case DEVICES_PROCESSORS: - return processor_get_info(processors); - case DEVICES_MEMORY: - return g_strdup("[Memory]\nNot implemented=\n"); - case DEVICES_BATTERY: - return g_strdup_printf("%s\n" - "[$ShellParam$]\n" - "ReloadInterval=4000\n", battery_list); - case DEVICES_PCI: - return g_strdup_printf("[PCI Devices]\n" - "%s" - "[$ShellParam$]\n" - "ViewType=1\n", - pci_list); - case DEVICES_SENSORS: - return g_strdup_printf("[$ShellParam$]\n" - "ReloadInterval=5000\n" - "%s", sensors); - 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="); - } +gchar * +callback_memory() +{ + return g_strdup("[Memory]\nNot implemented=\n"); } -gint -hi_n_entries(void) +gchar * +callback_battery() { - return G_N_ELEMENTS(hi_entries) - 1; + return g_strdup_printf("%s\n" + "[$ShellParam$]\n" + "ReloadInterval=4000\n", battery_list); } -GdkPixbuf * -hi_icon(gint entry) +gchar * +callback_pci() { - return icon_cache_get_pixbuf(hi_entries[entry].icon); + return g_strdup_printf("[PCI Devices]\n" + "%s" + "[$ShellParam$]\n" + "ViewType=1\n", + pci_list); } gchar * -hi_name(gint entry) +callback_sensors() { - return hi_entries[entry].name; + return g_strdup_printf("[$ShellParam$]\n" + "ReloadInterval=5000\n" + "%s", sensors); } gchar * -hi_module_name(void) +callback_printers() +{ + return g_strdup_printf("%s\n" + "[$ShellParam$]\n" + "ReloadInterval=5000", printer_list); +} + +gchar * +callback_storage() +{ + return g_strdup_printf("%s\n" + "[$ShellParam$]\n" + "ReloadInterval=5000\n" + "ViewType=1\n%s", storage_list, storage_icons); +} + +gchar * +callback_input() +{ + return g_strdup_printf("[Input Devices]\n" + "%s" + "[$ShellParam$]\n" + "ViewType=1\n" + "ReloadInterval=5000\n%s", input_list, input_icons); +} + +gchar * +callback_usb() +{ + return g_strdup_printf("%s" + "[$ShellParam$]\n" + "ViewType=1\n" + "ReloadInterval=5000\n", + usb_list); +} + +ModuleEntry * +hi_module_get_entries(void) +{ + return entries; +} + +gchar * +hi_module_get_name(void) { return g_strdup("Devices"); } guchar -hi_module_weight(void) +hi_module_get_weight(void) { return 160; } + +void +hi_module_init(void) +{ + moreinfo = g_hash_table_new(g_str_hash, g_str_equal); +} + diff --git a/hardinfo2/hardinfo.h b/hardinfo2/hardinfo.h index 36013060..48580274 100644 --- a/hardinfo2/hardinfo.h +++ b/hardinfo2/hardinfo.h @@ -48,8 +48,10 @@ struct _FileTypes { }; struct _ModuleEntry { - gchar *name; - gchar *icon; + gchar *name; + gchar *icon; + gpointer callback; + gpointer scan_callback; }; /* String utility functions */ @@ -71,13 +73,19 @@ gchar *file_chooser_build_filename(GtkWidget *chooser, gchar *extension); gpointer file_types_get_data_by_name(FileTypes *file_types, gchar *name); /* Misc utility functions */ -void schedule_free(gpointer ptr); +gpointer idle_free(gpointer ptr); inline gchar *size_human_readable(gfloat size); void nonblock_sleep(guint msec); void open_url(gchar *url); GSList *modules_load_selected(void); GSList *modules_load_all(void); +void module_entry_scan_all_except(ModuleEntry *entries, gint except_entry); +void module_entry_scan_all(ModuleEntry *entries); +void module_entry_reload(ShellModuleEntry *module_entry); +void module_entry_scan(ShellModuleEntry *module_entry); +gchar *module_entry_function(ShellModuleEntry *module_entry); + /* BinReloc stuff */ gboolean binreloc_init(gboolean try_hardcoded); @@ -87,7 +95,10 @@ void parameters_init(int *argc, char ***argv, ProgramParameters *params); extern ProgramParameters params; /* Module stuff */ -void module_register(ShellModule *module); gchar *module_call_method(gchar *method); + +#define SCAN_START() static gboolean scanned = FALSE; if (reload) scanned = FALSE; if (scanned) return; +#define SCAN_END() scanned = TRUE; + #endif /* __HARDINFO_H__ */ diff --git a/hardinfo2/report.c b/hardinfo2/report.c index 0a486228..8247a0dc 100644 --- a/hardinfo2/report.c +++ b/hardinfo2/report.c @@ -345,7 +345,8 @@ report_create_inner_from_module_list(ReportContext *ctx, GSList *modules) ctx->entry = entry; report_subtitle(ctx, entry->name); - report_table(ctx, entry->func(entry->number)); + module_entry_scan(entry); + report_table(ctx, module_entry_function(entry)); } } } diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 5cd0e56d..b05366be 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -271,13 +271,13 @@ void shell_do_reload(void) shell_action_set_enabled("CopyAction", FALSE); shell_action_set_enabled("ReportAction", FALSE); - if (shell->selected && shell->selected->reloadfunc) { + if (shell->selected) { GtkTreeSelection *ts; ts = gtk_tree_view_get_selection(GTK_TREE_VIEW(shell->tree->view)); shell_status_set_enabled(TRUE); - - shell->selected->reloadfunc(shell->selected->number); + + module_entry_reload(shell->selected); module_selected(ts, NULL); } @@ -569,7 +569,7 @@ static gboolean reload_section(gpointer data) ShellModuleEntry *entry = (ShellModuleEntry *) data; /* if the entry is still selected, update it */ - if (entry->selected && entry->reloadfunc) { + if (entry->selected) { GtkTreePath *path = NULL; GtkTreeSelection *ts; GtkTreeIter iter; @@ -581,7 +581,7 @@ static gboolean reload_section(gpointer data) path = gtk_tree_model_get_path(shell->info->model, &iter); /* update the information, clear the treeview and populate it again */ - entry->reloadfunc(entry->number); + module_entry_reload(entry); info_selected_show_extra(NULL); /* clears the more info store */ module_selected_show_info(entry, TRUE); @@ -920,11 +920,8 @@ module_selected_show_info(ShellModuleEntry * entry, gboolean reload) gint i; gsize ngroups; - if (entry->func) { - key_data = entry->func(entry->number); - } else { - key_data = g_strdup("[Error]\n" "Invalid module="); - } + module_entry_scan(entry); + key_data = module_entry_function(entry); /* reset the view type to normal */ set_view_type(SHELL_VIEW_NORMAL); @@ -1033,7 +1030,7 @@ static void module_selected(GtkTreeSelection * ts, gpointer data) /* Get the current selection and shows its related info */ gtk_tree_model_get(model, &parent, TREE_COL_DATA, &entry, -1); - if (entry && entry->func && !entry->selected) { + if (entry && !entry->selected) { shell_status_set_enabled(TRUE); shell_status_update("Updating..."); @@ -1066,10 +1063,8 @@ static void module_selected(GtkTreeSelection * ts, gpointer data) gtk_window_set_title(GTK_WINDOW(shell->window), tmp); g_free(tmp); - shell_action_set_enabled("RefreshAction", - entry->reloadfunc ? TRUE : FALSE); - shell_action_set_enabled("CopyAction", - entry->reloadfunc ? TRUE : FALSE); + shell_action_set_enabled("RefreshAction", TRUE); + shell_action_set_enabled("CopyAction", TRUE); } else { gtk_window_set_title(GTK_WINDOW(shell->window), "System Information"); diff --git a/hardinfo2/shell.h b/hardinfo2/shell.h index c1204233..fca5a5d4 100644 --- a/hardinfo2/shell.h +++ b/hardinfo2/shell.h @@ -123,8 +123,9 @@ struct _ShellModuleEntry { gboolean selected; gint number; - gchar *(*func) (gint entry); - gchar *(*reloadfunc) (gint entry); + gchar *(*func) (); + void (*scan_func) (); + gchar *(*fieldfunc) (gchar * entry); gchar *(*morefunc) (gchar * entry); gchar *(*notefunc) (gint entry); diff --git a/hardinfo2/util.c b/hardinfo2/util.c index d47bb289..13194df3 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -121,8 +121,8 @@ void file_chooser_add_filters(GtkWidget * chooser, FileTypes * filters) } } -gchar - * file_chooser_get_extension(GtkWidget * chooser, FileTypes * filters) +gchar * +file_chooser_get_extension(GtkWidget * chooser, FileTypes * filters) { GtkFileFilter *filter; const gchar *filter_name; @@ -377,15 +377,15 @@ gchar *strreplace(gchar * string, gchar * replace, gchar new_char) return string; } -static GHashTable *__modules = NULL; +static GHashTable *__module_methods = NULL; -void module_register(ShellModule *module) +static void module_register_methods(ShellModule *module) { ShellModuleMethod *(*get_methods) (void); gchar *method_name; - if (__modules == NULL) { - __modules = g_hash_table_new(g_str_hash, g_str_equal); + if (__module_methods == NULL) { + __module_methods = g_hash_table_new(g_str_hash, g_str_equal); } if (g_module_symbol(module->dll, "hi_exported_methods", (gpointer) &get_methods)) { @@ -398,7 +398,7 @@ void module_register(ShellModule *module) strend(name, '.'); method_name = g_strdup_printf("%s::%s", name, method.name); - g_hash_table_insert(__modules, method_name, method.function); + g_hash_table_insert(__module_methods, method_name, method.function); g_free(name); if (!(*(++methods)).name) @@ -412,11 +412,11 @@ gchar *module_call_method(gchar *method) { gchar *(*function) (void); - if (__modules == NULL) { + if (__module_methods == NULL) { return NULL; } - function = g_hash_table_lookup(__modules, method); + function = g_hash_table_lookup(__module_methods, method); return function ? g_strdup(function()) : g_strdup_printf("{Unknown method: \"%s\"}", method); } @@ -448,38 +448,35 @@ static ShellModule *module_load(gchar *filename) g_free(tmp); if (module->dll) { - gint (*n_entries) (void); - gint (*weight_func) (void); - gchar *(*name_func) (void); - gint i; - - if (!g_module_symbol(module->dll, "hi_n_entries", (gpointer) & n_entries) || - !g_module_symbol(module->dll, "hi_module_name", (gpointer) & name_func)) + void (*init) (void); + ModuleEntry *(*get_module_entries) (void); + gint (*weight_func) (void); + gchar *(*name_func) (void); + ModuleEntry *entries; + gint i = 0; + + if (!g_module_symbol(module->dll, "hi_module_get_entries", (gpointer) & get_module_entries) || + !g_module_symbol(module->dll, "hi_module_get_name", (gpointer) & name_func)) { goto failed; + } - g_module_symbol(module->dll, "hi_module_weight", (gpointer) & weight_func); + if (g_module_symbol(module->dll, "hi_module_init", (gpointer) & init)) { + init(); + } + + g_module_symbol(module->dll, "hi_module_get_weight", (gpointer) & weight_func); module->weight = weight_func ? weight_func() : 0; module->name = name_func(); - gint j = n_entries(); - for (i = 0; i <= j; i++) { - GdkPixbuf *(*shell_icon) (gint); - const gchar *(*shell_name) (gint); + entries = get_module_entries(); + while (entries[i].name) { ShellModuleEntry *entry = g_new0(ShellModuleEntry, 1); - if (params.gui_running && g_module_symbol(module->dll, "hi_icon", - (gpointer) & (shell_icon))) { - entry->icon = shell_icon(i); - } - if (g_module_symbol - (module->dll, "hi_name", (gpointer) & (shell_name))) { - entry->name = g_strdup(shell_name(i)); + if (params.gui_running) { + entry->icon = icon_cache_get_pixbuf(entries[i].icon); } - g_module_symbol(module->dll, "hi_info", - (gpointer) & (entry->func)); - g_module_symbol(module->dll, "hi_reload", - (gpointer) & (entry->reloadfunc)); + g_module_symbol(module->dll, "hi_more_info", (gpointer) & (entry->morefunc)); g_module_symbol(module->dll, "hi_get_field", @@ -487,10 +484,17 @@ static ShellModule *module_load(gchar *filename) g_module_symbol(module->dll, "hi_note_func", (gpointer) & (entry->notefunc)); - entry->number = i; - + entry->name = entries[i].name; + entry->scan_func = entries[i].scan_callback; + entry->func = entries[i].callback; + entry->number = i; + module->entries = g_slist_append(module->entries, entry); + + i++; } + + module_register_methods(module); } else { failed: g_free(module->name); @@ -498,8 +502,6 @@ static ShellModule *module_load(gchar *filename) module = NULL; } - module_register(module); - return module; } @@ -560,7 +562,7 @@ static GSList *modules_check_deps(GSList *modules) module = (ShellModule *) mm->data; - if (g_module_symbol(module->dll, "hi_module_depends_on", + if (g_module_symbol(module->dll, "hi_module_get_dependencies", (gpointer) & get_deps)) { for (i = 0, deps = get_deps(); deps[i]; i++) { GSList *l; @@ -792,14 +794,69 @@ void tree_view_save_image(gchar *filename) } -static gboolean __schedule_free_do(gpointer ptr) +static gboolean __idle_free_do(gpointer ptr) { g_free(ptr); return FALSE; } -void schedule_free(gpointer ptr) +gpointer idle_free(gpointer ptr) +{ + g_timeout_add(2000, __idle_free_do, ptr); + + return ptr; +} + +void module_entry_scan_all_except(ModuleEntry *entries, gint except_entry) +{ + ModuleEntry entry; + gint i = 0; + + void (*scan_callback)(gboolean reload); + + for (entry = entries[0]; entry.name; entry = entries[++i]) { + if (i == except_entry) + continue; + + shell_status_update(idle_free(g_strdup_printf("Scanning: %s...", entry.name))); + + if ((scan_callback = entry.scan_callback)) { + scan_callback(FALSE); + } + } + + shell_status_update("Done."); +} + +void module_entry_scan_all(ModuleEntry *entries) +{ + module_entry_scan_all_except(entries, -1); +} + +void module_entry_reload(ShellModuleEntry *module_entry) +{ + if (module_entry->scan_func) { + module_entry->scan_func(TRUE); + } +} + +void module_entry_scan(ShellModuleEntry *module_entry) +{ + shell_status_update(idle_free(g_strdup_printf("Scanning: %s...", module_entry->name))); + + if (module_entry->scan_func) { + module_entry->scan_func(FALSE); + } + + shell_status_update("Done."); +} + +gchar *module_entry_function(ShellModuleEntry *module_entry) { - g_timeout_add(5000, __schedule_free_do, ptr); + if (module_entry->func) { + return g_strdup(module_entry->func()); + } + + return g_strdup("[Error]\n" "Invalid module="); } |