aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2009-05-01 21:48:01 -0300
committerLeandro A. F. Pereira <leandro@hardinfo.org>2009-05-01 21:48:01 -0300
commitd42d81949a49fa71cc84f2e4120b65fd91cb61b2 (patch)
tree6b0bf5d4b4c22f69a21f1e4f9d18d528469c3d5c
parentddf9b782e39355db410ae4225d7a41a8dea902c4 (diff)
Makes the XMLRPC client synchronous (fixes some stability problems)
-rw-r--r--hardinfo2/remote.c41
-rw-r--r--hardinfo2/shell.c15
-rw-r--r--hardinfo2/xmlrpc-client.c4
-rw-r--r--hardinfo2/xmlrpc-server.c1
4 files changed, 45 insertions, 16 deletions
diff --git a/hardinfo2/remote.c b/hardinfo2/remote.c
index e9d03ef1..dff44d03 100644
--- a/hardinfo2/remote.c
+++ b/hardinfo2/remote.c
@@ -26,6 +26,8 @@
#include "xmlrpc-client.h"
+#define XMLRPC_SERVER_VERSION 1
+
/*
* TODO
*
@@ -71,16 +73,20 @@ static RemoteDialog *remote_dialog_new(GtkWidget *parent);
static gboolean remote_version_is_supported(void)
{
+ gint remote_ver;
+
shell_status_update("Obtaining remote server API version...");
+ remote_ver = xmlrpc_get_integer("http://localhost:4242/xmlrpc", "server.getAPIVersion", NULL);
- switch (xmlrpc_get_integer("http://localhost:4242/xmlrpc", "server.getAPIVersion", NULL)) {
+ switch (remote_ver) {
case -1:
g_warning("Remote Host didn't respond.");
break;
- case 1:
+ case XMLRPC_SERVER_VERSION:
return TRUE;
default:
- g_warning("Remote Host has an unsupported API version.");
+ g_warning("Remote Host has an unsupported API version (%d). Expected version is %d.",
+ remote_ver, XMLRPC_SERVER_VERSION);
}
return FALSE;
@@ -89,17 +95,18 @@ static gboolean remote_version_is_supported(void)
static gchar *remote_module_entry_func()
{
Shell *shell = shell_get_main_shell();
+ gchar *ret;
- shell_status_pulse();
- return xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryFunction",
- "%s%i", shell->selected_module_name, shell->selected->number);
+ ret = xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryFunction",
+ "%s%i", shell->selected_module_name, shell->selected->number);
+
+ return ret;
}
static void remote_module_entry_scan_func()
{
Shell *shell = shell_get_main_shell();
- shell_status_pulse();
xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryScan",
"%s%i", shell->selected_module_name, shell->selected->number);
}
@@ -107,19 +114,23 @@ static void remote_module_entry_scan_func()
static gchar *remote_module_entry_field_func(gchar *entry)
{
Shell *shell = shell_get_main_shell();
+ gchar *ret;
- shell_status_pulse();
- return xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryGetField",
- "%s%i%s", shell->selected_module_name, shell->selected->number, entry);
+ ret = xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryGetField",
+ "%s%i%s", shell->selected_module_name, shell->selected->number, entry);
+
+ return ret;
}
static gchar *remote_module_entry_more_func(gchar *entry)
{
Shell *shell = shell_get_main_shell();
+ gchar *ret;
- shell_status_pulse();
- return xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryGetMoreInfo",
+ ret = xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryGetMoreInfo",
"%s%i%s", shell->selected_module_name, shell->selected->number, entry);
+
+ return ret;
}
static gchar *remote_module_entry_note_func(gint entry)
@@ -127,10 +138,9 @@ static gchar *remote_module_entry_note_func(gint entry)
Shell *shell = shell_get_main_shell();
gchar *note;
- shell_status_pulse();
note = xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryGetNote",
"%s%i", shell->selected_module_name, shell->selected->number);
- if (!*note) {
+ if (note && *note == '\0') {
g_free(note);
return NULL;
}
@@ -185,6 +195,8 @@ static gboolean load_module_list()
e->notefunc = remote_module_entry_note_func;
m->entries = g_slist_append(m->entries, e);
+
+ shell_status_pulse();
}
g_value_array_free(entries);
@@ -228,6 +240,7 @@ void remote_dialog_show(GtkWidget *parent)
remote_connect(rd);
shell_status_set_enabled(FALSE);
+ shell_view_set_enabled(TRUE);
}
gtk_widget_destroy(rd->dialog);
diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c
index 7ffd1b52..3451a8f4 100644
--- a/hardinfo2/shell.c
+++ b/hardinfo2/shell.c
@@ -437,6 +437,7 @@ static void view_menu_select_entry(gpointer data, gpointer data2)
static void add_module_to_menu(gchar * name, GdkPixbuf * pixbuf)
{
+ GtkAction *action;
gchar *about_module = g_strdup_printf("AboutModule%s", name);
gint merge_id;
@@ -461,6 +462,14 @@ static void add_module_to_menu(gchar * name, GdkPixbuf * pixbuf)
stock_icon_register_pixbuf(pixbuf, name);
+ if ((action = gtk_action_group_get_action(shell->action_group, name))) {
+ gtk_action_group_remove_action(shell->action_group, action);
+ }
+
+ if ((action = gtk_action_group_get_action(shell->action_group, about_module))) {
+ gtk_action_group_remove_action(shell->action_group, action);
+ }
+
gtk_action_group_add_actions(shell->action_group, entries, 2, NULL);
merge_id = gtk_ui_manager_new_merge_id(shell->ui_manager);
@@ -483,6 +492,7 @@ static void
add_module_entry_to_view_menu(gchar * module, gchar * name,
GdkPixbuf * pixbuf, GtkTreeIter * iter)
{
+ GtkAction *action;
gint merge_id;
GtkActionEntry entries[] = {
{
@@ -496,6 +506,11 @@ add_module_entry_to_view_menu(gchar * module, gchar * name,
};
stock_icon_register_pixbuf(pixbuf, name);
+
+ if ((action = gtk_action_group_get_action(shell->action_group, name))) {
+ gtk_action_group_remove_action(shell->action_group, action);
+ }
+
gtk_action_group_add_actions(shell->action_group, entries, 1, iter);
merge_id = gtk_ui_manager_new_merge_id(shell->ui_manager);
diff --git a/hardinfo2/xmlrpc-client.c b/hardinfo2/xmlrpc-client.c
index ae8b1078..2d3b21e8 100644
--- a/hardinfo2/xmlrpc-client.c
+++ b/hardinfo2/xmlrpc-client.c
@@ -27,11 +27,11 @@ static SoupSession *session = NULL;
void xmlrpc_init(void)
{
if (!loop) {
- loop = g_main_loop_new(FALSE, TRUE);
+ loop = g_main_loop_new(FALSE, FALSE);
}
if (!session) {
- session = soup_session_async_new_with_options(SOUP_SESSION_TIMEOUT, 10, NULL);
+ session = soup_session_sync_new_with_options(SOUP_SESSION_TIMEOUT, 10, NULL);
}
}
diff --git a/hardinfo2/xmlrpc-server.c b/hardinfo2/xmlrpc-server.c
index e05478f7..5278765c 100644
--- a/hardinfo2/xmlrpc-server.c
+++ b/hardinfo2/xmlrpc-server.c
@@ -233,6 +233,7 @@ static void method_entry_get_field(SoupMessage * msg, GValueArray * params)
GSList *entry_node = g_slist_nth(module->entries, entry_number);
ShellModuleEntry *entry = (ShellModuleEntry *)entry_node->data;
+ DEBUG("[%s][%s]", module_name, field_name);
answer = module_entry_get_field(entry, field_name);
}
}