aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@hardinfo.org>2010-01-01 13:50:55 -0200
committerLeandro Pereira <leandro@hardinfo.org>2010-01-01 13:50:55 -0200
commite6fb48251e70d87404bf7738722679b9281ed108 (patch)
treeeeb168e65fbfde2f4b5d3d78fc79b8cd151ad11b /hardinfo2
parent94a513ab865ccad5b87fc661076f24eb9b87f11c (diff)
Don't include benchmarks in remote mode.
Diffstat (limited to 'hardinfo2')
-rw-r--r--hardinfo2/benchmark.c14
-rw-r--r--hardinfo2/computer.c20
-rw-r--r--hardinfo2/devices.c22
-rw-r--r--hardinfo2/hardinfo.h6
-rw-r--r--hardinfo2/network.c14
-rw-r--r--hardinfo2/remote.c74
-rw-r--r--hardinfo2/shell.h1
-rw-r--r--hardinfo2/util.c1
-rw-r--r--hardinfo2/xmlrpc-server.c29
9 files changed, 115 insertions, 66 deletions
diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c
index cfdd0a30..bb98c575 100644
--- a/hardinfo2/benchmark.c
+++ b/hardinfo2/benchmark.c
@@ -56,13 +56,13 @@ gchar *callback_nqueens();
gchar *callback_gui();
static ModuleEntry entries[] = {
- {"CPU Blowfish", "blowfish.png", callback_bfsh, scan_bfsh},
- {"CPU CryptoHash", "cryptohash.png", callback_cryptohash, scan_cryptohash},
- {"CPU Fibonacci", "nautilus.png", callback_fib, scan_fib},
- {"CPU N-Queens", "nqueens.png", callback_nqueens, scan_nqueens},
- {"FPU FFT", "fft.png", callback_fft, scan_fft},
- {"FPU Raytracing", "raytrace.png", callback_raytr, scan_raytr},
- {"GPU Drawing", "module.png", callback_gui, scan_gui},
+ {"CPU Blowfish", "blowfish.png", callback_bfsh, scan_bfsh, MODULE_FLAG_NO_REMOTE},
+ {"CPU CryptoHash", "cryptohash.png", callback_cryptohash, scan_cryptohash, MODULE_FLAG_NO_REMOTE},
+ {"CPU Fibonacci", "nautilus.png", callback_fib, scan_fib, MODULE_FLAG_NO_REMOTE},
+ {"CPU N-Queens", "nqueens.png", callback_nqueens, scan_nqueens, MODULE_FLAG_NO_REMOTE},
+ {"FPU FFT", "fft.png", callback_fft, scan_fft, MODULE_FLAG_NO_REMOTE},
+ {"FPU Raytracing", "raytrace.png", callback_raytr, scan_raytr, MODULE_FLAG_NO_REMOTE},
+ {"GPU Drawing", "module.png", callback_gui, scan_gui, MODULE_FLAG_NO_REMOTE},
{NULL}
};
diff --git a/hardinfo2/computer.c b/hardinfo2/computer.c
index 35b71b27..98936598 100644
--- a/hardinfo2/computer.c
+++ b/hardinfo2/computer.c
@@ -62,18 +62,18 @@ void scan_dev(gboolean reload);
#endif /* GLIB_CHECK_VERSION(2,14,0) */
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},
- {"Boots", "boot.png", callback_boots, scan_boots},
- {"Languages", "language.png", callback_locales, scan_locales},
- {"Filesystems", "dev_removable.png", callback_fs, scan_fs},
- {"Display", "monitor.png", callback_display, scan_display},
- {"Environment Variables", "environment.png", callback_env_var, scan_env_var},
+ {"Summary", "summary.png", callback_summary, scan_summary, MODULE_FLAG_NONE},
+ {"Operating System", "os.png", callback_os, scan_os, MODULE_FLAG_NONE},
+ {"Kernel Modules", "module.png", callback_modules, scan_modules, MODULE_FLAG_NONE},
+ {"Boots", "boot.png", callback_boots, scan_boots, MODULE_FLAG_NONE},
+ {"Languages", "language.png", callback_locales, scan_locales, MODULE_FLAG_NONE},
+ {"Filesystems", "dev_removable.png", callback_fs, scan_fs, MODULE_FLAG_NONE},
+ {"Display", "monitor.png", callback_display, scan_display, MODULE_FLAG_NONE},
+ {"Environment Variables", "environment.png", callback_env_var, scan_env_var, MODULE_FLAG_NONE},
#if GLIB_CHECK_VERSION(2,14,0)
- {"Development", "devel.png", callback_dev, scan_dev},
+ {"Development", "devel.png", callback_dev, scan_dev, MODULE_FLAG_NONE},
#endif /* GLIB_CHECK_VERSION(2,14,0) */
- {"Users", "users.png", callback_users, scan_users},
+ {"Users", "users.png", callback_users, scan_users, MODULE_FLAG_NONE},
{NULL},
};
diff --git a/hardinfo2/devices.c b/hardinfo2/devices.c
index 3ecce794..4b29f80f 100644
--- a/hardinfo2/devices.c
+++ b/hardinfo2/devices.c
@@ -65,19 +65,19 @@ void scan_dmi(gboolean reload);
void scan_device_resources(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", "inputdevices.png", callback_input, scan_input},
- {"Storage", "hdd.png", callback_storage, scan_storage},
+ {"Processor", "processor.png", callback_processors, scan_processors, MODULE_FLAG_NONE},
+ {"Memory", "memory.png", callback_memory, scan_memory, MODULE_FLAG_NONE},
+ {"PCI Devices", "devices.png", callback_pci, scan_pci, MODULE_FLAG_NONE},
+ {"USB Devices", "usb.png", callback_usb, scan_usb, MODULE_FLAG_NONE},
+ {"Printers", "printer.png", callback_printers, scan_printers, MODULE_FLAG_NONE},
+ {"Battery", "battery.png", callback_battery, scan_battery, MODULE_FLAG_NONE},
+ {"Sensors", "therm.png", callback_sensors, scan_sensors, MODULE_FLAG_NONE},
+ {"Input Devices", "inputdevices.png", callback_input, scan_input, MODULE_FLAG_NONE},
+ {"Storage", "hdd.png", callback_storage, scan_storage, MODULE_FLAG_NONE},
#if defined(ARCH_i386) || defined(ARCH_x86_64)
- {"DMI", "computer.png", callback_dmi, scan_dmi},
+ {"DMI", "computer.png", callback_dmi, scan_dmi, MODULE_FLAG_NONE},
#endif /* x86 or x86_64 */
- {"Resources", "resources.png", callback_device_resources, scan_device_resources},
+ {"Resources", "resources.png", callback_device_resources, scan_device_resources, MODULE_FLAG_NONE},
{NULL}
};
diff --git a/hardinfo2/hardinfo.h b/hardinfo2/hardinfo.h
index dc720069..71dc9c14 100644
--- a/hardinfo2/hardinfo.h
+++ b/hardinfo2/hardinfo.h
@@ -22,6 +22,11 @@
#include <gtk/gtk.h>
#include <shell.h>
+typedef enum {
+ MODULE_FLAG_NONE = 0,
+ MODULE_FLAG_NO_REMOTE = 1<<0,
+} ModuleEntryFlags;
+
typedef struct _ModuleEntry ModuleEntry;
typedef struct _ModuleAbout ModuleAbout;
typedef struct _FileTypes FileTypes;
@@ -56,6 +61,7 @@ struct _ModuleEntry {
gchar *icon;
gpointer callback;
gpointer scan_callback;
+ guint32 flags;
};
struct _ModuleAbout {
diff --git a/hardinfo2/network.c b/hardinfo2/network.c
index 556a7723..593225ae 100644
--- a/hardinfo2/network.c
+++ b/hardinfo2/network.c
@@ -53,13 +53,13 @@ void scan_arp(gboolean reload);
void scan_statistics(gboolean reload);
static ModuleEntry entries[] = {
- {"Interfaces", "network-interface.png", callback_network, scan_network},
- {"IP Connections", "network-connections.png", callback_connections, scan_connections},
- {"Routing Table", "network.png", callback_route, scan_route},
- {"ARP Table", "module.png", callback_arp, scan_arp},
- {"DNS Servers", "dns.png", callback_dns, scan_dns},
- {"Statistics", "network-statistics.png", callback_statistics, scan_statistics},
- {"Shared Directories", "shares.png", callback_shares, scan_shares},
+ {"Interfaces", "network-interface.png", callback_network, scan_network, MODULE_FLAG_NONE},
+ {"IP Connections", "network-connections.png", callback_connections, scan_connections, MODULE_FLAG_NONE},
+ {"Routing Table", "network.png", callback_route, scan_route, MODULE_FLAG_NONE},
+ {"ARP Table", "module.png", callback_arp, scan_arp, MODULE_FLAG_NONE},
+ {"DNS Servers", "dns.png", callback_dns, scan_dns, MODULE_FLAG_NONE},
+ {"Statistics", "network-statistics.png", callback_statistics, scan_statistics, MODULE_FLAG_NONE},
+ {"Shared Directories", "shares.png", callback_shares, scan_shares, MODULE_FLAG_NONE},
{NULL},
};
diff --git a/hardinfo2/remote.c b/hardinfo2/remote.c
index d148533c..eed4a308 100644
--- a/hardinfo2/remote.c
+++ b/hardinfo2/remote.c
@@ -112,7 +112,37 @@ void remote_disconnect_all(gboolean ssh)
}
}
-static gboolean remote_version_is_supported()
+static void remote_connection_error(void)
+{
+ GtkWidget *dialog;
+ static gboolean showing_error = FALSE;
+
+ if (showing_error) {
+ return;
+ }
+
+ showing_error = TRUE;
+
+ dialog = gtk_message_dialog_new(NULL,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_NONE,
+ "Connection to %s was lost.", xmlrpc_server_uri);
+
+ gtk_dialog_add_buttons(GTK_DIALOG(dialog),
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
+ remote_disconnect_all(ssh_conn != NULL);
+ cb_local_computer();
+ }
+
+ gtk_widget_destroy(dialog);
+
+ showing_error = FALSE;
+}
+
+static gboolean remote_version_is_supported(void)
{
gint remote_ver;
GtkWidget *dialog;
@@ -181,17 +211,18 @@ static gchar *remote_module_entry_func()
static void remote_module_entry_scan_func(gboolean reload)
{
Shell *shell = shell_get_main_shell();
+ gchar *response;
if (reload) {
xmlrpc_get_string(xmlrpc_server_uri,
- "module.entryReload", "%s%i",
- shell->selected_module_name,
- shell->selected->number);
+ "module.entryReload", "%s%i",
+ shell->selected_module_name,
+ shell->selected->number);
} else {
xmlrpc_get_string(xmlrpc_server_uri,
- "module.entryScan", "%s%i",
- shell->selected_module_name,
- shell->selected->number);
+ "module.entryScan", "%s%i",
+ shell->selected_module_name,
+ shell->selected->number);
}
}
@@ -205,7 +236,11 @@ static gchar *remote_module_entry_field_func(gchar * entry)
"module.entryGetField", "%s%i%s",
shell->selected_module_name,
shell->selected->number, entry);
-
+
+ if (!ret) {
+ remote_connection_error();
+ }
+
return ret;
}
@@ -220,6 +255,10 @@ static gchar *remote_module_entry_more_func(gchar * entry)
shell->selected_module_name,
shell->selected->number, entry);
+ if (!ret) {
+ remote_connection_error();
+ }
+
return ret;
}
@@ -233,6 +272,7 @@ static gchar *remote_module_entry_note_func(gint entry)
"module.entryGetNote", "%s%i",
shell->selected_module_name,
shell->selected->number);
+
if (note && *note == '\0') {
g_free(note);
return NULL;
@@ -279,10 +319,9 @@ static gboolean load_module_list()
m->aboutfunc = (gpointer) remote_module_get_about;
shell_status_pulse();
- entries =
- xmlrpc_get_array(xmlrpc_server_uri,
- "module.getEntryList", "%s", m->name);
- if (entries) {
+ entries = xmlrpc_get_array(xmlrpc_server_uri,
+ "module.getEntryList", "%s", m->name);
+ if (entries && entries->n_values > 0) {
for (; j < entries->n_values; j++) {
GValueArray *tuple =
g_value_get_boxed(&entries->values[j]);
@@ -308,9 +347,12 @@ static gboolean load_module_list()
}
g_value_array_free(entries);
+
+ shell->tree->modules = g_slist_append(shell->tree->modules, m);
+ } else {
+ g_free(m->name);
+ g_free(m);
}
-
- shell->tree->modules = g_slist_append(shell->tree->modules, m);
}
g_slist_foreach(shell->tree->modules, shell_add_modules_to_gui,
@@ -863,8 +905,6 @@ static HostDialog *host_dialog_new(GtkWidget * parent,
btn_save = gtk_button_new_from_stock(GTK_STOCK_SAVE);
} else if (mode == HOST_DIALOG_MODE_CONNECT) {
btn_save = gtk_button_new_from_stock(GTK_STOCK_CONNECT);
- } else {
- g_error("internal error");
}
gtk_widget_show(btn_save);
@@ -884,8 +924,6 @@ static HostDialog *host_dialog_new(GtkWidget * parent,
host_dlg->btn_accept = btn_save;
host_dlg->btn_cancel = btn_cancel;
- DEBUG("btn_accept is %p", btn_save);
-
completion = gtk_entry_completion_new();
gtk_entry_set_completion(GTK_ENTRY(host_dlg->txt_hostname), completion);
g_object_unref(completion);
diff --git a/hardinfo2/shell.h b/hardinfo2/shell.h
index 3608c7a0..f5ee3137 100644
--- a/hardinfo2/shell.h
+++ b/hardinfo2/shell.h
@@ -147,6 +147,7 @@ struct _ShellModuleEntry {
gchar *icon_file;
gboolean selected;
gint number;
+ guint32 flags;
gchar *(*func) ();
void (*scan_func) ();
diff --git a/hardinfo2/util.c b/hardinfo2/util.c
index 6897fbcb..87521028 100644
--- a/hardinfo2/util.c
+++ b/hardinfo2/util.c
@@ -718,6 +718,7 @@ static ShellModule *module_load(gchar * filename)
entry->scan_func = entries[i].scan_callback;
entry->func = entries[i].callback;
entry->number = i;
+ entry->flags = entries[i].flags;
module->entries = g_slist_append(module->entries, entry);
diff --git a/hardinfo2/xmlrpc-server.c b/hardinfo2/xmlrpc-server.c
index 5452647a..4cf5b682 100644
--- a/hardinfo2/xmlrpc-server.c
+++ b/hardinfo2/xmlrpc-server.c
@@ -200,19 +200,22 @@ static void method_get_entry_list(SoupMessage * msg, GValueArray * params)
out = soup_value_array_new();
if (found) {
- module = (ShellModule *) modules->data;
- for (entry = module->entries; entry; entry = entry->next) {
- GValueArray *tuple;
-
- module_entry = (ShellModuleEntry *) entry->data;
- tuple = soup_value_array_new();
-
- soup_value_array_append(tuple, G_TYPE_STRING, module_entry->name);
- soup_value_array_append(tuple, G_TYPE_STRING, module_entry->icon_file);
-
- soup_value_array_append(out, G_TYPE_VALUE_ARRAY, tuple);
- g_value_array_free(tuple);
- }
+ module = (ShellModule *) modules->data;
+ for (entry = module->entries; entry; entry = entry->next) {
+ GValueArray *tuple;
+
+ module_entry = (ShellModuleEntry *) entry->data;
+
+ if (!(module_entry->flags & MODULE_FLAG_NO_REMOTE)) {
+ tuple = soup_value_array_new();
+
+ soup_value_array_append(tuple, G_TYPE_STRING, module_entry->name);
+ soup_value_array_append(tuple, G_TYPE_STRING, module_entry->icon_file);
+
+ soup_value_array_append(out, G_TYPE_VALUE_ARRAY, tuple);
+ g_value_array_free(tuple);
+ }
+ }
}
soup_xmlrpc_set_response(msg, G_TYPE_VALUE_ARRAY, out);