diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2009-05-03 12:24:48 -0300 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2009-05-03 12:24:48 -0300 |
commit | efbc771b490d50279b3b9cacfd5f4e9ca8621a68 (patch) | |
tree | a28b95408b25c236506b5b4362cdab436591d549 /hardinfo2 | |
parent | 6553dc00fe6d10baaa3b3faaddedace625f90c5a (diff) |
Change module.getModuleList(), so it also sends the module's icon filename. Stability fixes to the remote feature.
Diffstat (limited to 'hardinfo2')
-rw-r--r-- | hardinfo2/remote.c | 343 | ||||
-rw-r--r-- | hardinfo2/shell.c | 22 | ||||
-rw-r--r-- | hardinfo2/shell.h | 7 | ||||
-rw-r--r-- | hardinfo2/util.c | 13 | ||||
-rw-r--r-- | hardinfo2/xmlrpc-client.c | 18 | ||||
-rw-r--r-- | hardinfo2/xmlrpc-server.c | 26 |
6 files changed, 262 insertions, 167 deletions
diff --git a/hardinfo2/remote.c b/hardinfo2/remote.c index dff44d03..026f7d75 100644 --- a/hardinfo2/remote.c +++ b/hardinfo2/remote.c @@ -65,28 +65,31 @@ typedef struct _RemoteDialog RemoteDialog; struct _RemoteDialog { - GtkWidget *dialog; - GtkWidget *btn_connect, *btn_cancel; + GtkWidget *dialog; + GtkWidget *btn_connect, *btn_cancel; }; -static RemoteDialog *remote_dialog_new(GtkWidget *parent); +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); + remote_ver = + xmlrpc_get_integer("http://localhost:4242/xmlrpc", + "server.getAPIVersion", NULL); switch (remote_ver) { case -1: - g_warning("Remote Host didn't respond."); - break; + g_warning("Remote Host didn't respond."); + break; case XMLRPC_SERVER_VERSION: - return TRUE; + return TRUE; default: - g_warning("Remote Host has an unsupported API version (%d). Expected version is %d.", - remote_ver, XMLRPC_SERVER_VERSION); + g_warning + ("Remote Host has an unsupported API version (%d). Expected version is %d.", + remote_ver, XMLRPC_SERVER_VERSION); } return FALSE; @@ -96,40 +99,62 @@ static gchar *remote_module_entry_func() { Shell *shell = shell_get_main_shell(); gchar *ret; - - ret = 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); + + if (!ret) { + ret = g_strdup(""); + } + return ret; } -static void remote_module_entry_scan_func() +static void remote_module_entry_scan_func(gboolean reload) { Shell *shell = shell_get_main_shell(); - - xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryScan", - "%s%i", shell->selected_module_name, shell->selected->number); + + if (reload) { + xmlrpc_get_string("http://localhost:4242/xmlrpc", + "module.entryReload", "%s%i", + shell->selected_module_name, + shell->selected->number); + } else { + xmlrpc_get_string("http://localhost:4242/xmlrpc", + "module.entryScan", "%s%i", + shell->selected_module_name, + shell->selected->number); + } } -static gchar *remote_module_entry_field_func(gchar *entry) +static gchar *remote_module_entry_field_func(gchar * entry) { Shell *shell = shell_get_main_shell(); gchar *ret; - - ret = xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryGetField", - "%s%i%s", shell->selected_module_name, shell->selected->number, entry); - - return ret; + + 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) +static gchar *remote_module_entry_more_func(gchar * entry) { Shell *shell = shell_get_main_shell(); gchar *ret; - - ret = xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryGetMoreInfo", - "%s%i%s", shell->selected_module_name, shell->selected->number, entry); - + + ret = + xmlrpc_get_string("http://localhost:4242/xmlrpc", + "module.entryGetMoreInfo", "%s%i%s", + shell->selected_module_name, + shell->selected->number, entry); + return ret; } @@ -137,97 +162,119 @@ static gchar *remote_module_entry_note_func(gint entry) { Shell *shell = shell_get_main_shell(); gchar *note; - - note = xmlrpc_get_string("http://localhost:4242/xmlrpc", "module.entryGetNote", - "%s%i", shell->selected_module_name, shell->selected->number); + + note = + xmlrpc_get_string("http://localhost:4242/xmlrpc", + "module.entryGetNote", "%s%i", + shell->selected_module_name, + shell->selected->number); if (note && *note == '\0') { - g_free(note); - return NULL; + g_free(note); + return NULL; } - + return note; } +static ModuleAbout *remote_module_get_about() +{ + return NULL; +} + static gboolean load_module_list() { Shell *shell; GValueArray *modules; int i = 0; - + shell_status_update("Unloading local modules..."); module_unload_all(); - + shell_status_update("Obtaining remote server module list..."); - modules = xmlrpc_get_array("http://localhost:4242/xmlrpc", "module.getModuleList", NULL); + modules = + xmlrpc_get_array("http://localhost:4242/xmlrpc", + "module.getModuleList", NULL); if (!modules) { - return FALSE; + return FALSE; } - + shell = shell_get_main_shell(); - + for (; i < modules->n_values; i++) { - ShellModule *m; - ShellModuleEntry *e; - GValueArray *entries; - const gchar *module = g_value_get_string(&modules->values[i]); - int j = 0; - - m = g_new0(ShellModule, 1); - m->name = g_strdup(module); - m->icon = icon_cache_get_pixbuf("module.png"); /* FIXME */ - - shell_status_pulse(); - entries = xmlrpc_get_array("http://localhost:4242/xmlrpc", "module.getEntryList", "%s", module); - if (entries) { - for (; j < entries->n_values; j++) { - GValueArray *tuple = g_value_get_boxed(&entries->values[j]); - - e = g_new0(ShellModuleEntry, 1); - e->name = g_strdup(g_value_get_string(&tuple->values[0])); - e->icon = icon_cache_get_pixbuf(g_value_get_string(&tuple->values[1])); - e->icon_file = g_strdup(g_value_get_string(&tuple->values[1])); - e->number = j; - - e->func = remote_module_entry_func; - e->scan_func = remote_module_entry_scan_func; - e->fieldfunc = remote_module_entry_field_func; - e->morefunc = remote_module_entry_more_func; - e->notefunc = remote_module_entry_note_func; - - m->entries = g_slist_append(m->entries, e); - - shell_status_pulse(); - } - - g_value_array_free(entries); - } - - shell->tree->modules = g_slist_append(shell->tree->modules, m); + ShellModule *m; + ShellModuleEntry *e; + GValueArray *entries, *module; + int j = 0; + + module = g_value_get_boxed(&modules->values[i]); + DEBUG("%s - %s", + g_value_get_string(&module->values[0]), + g_value_get_string(&module->values[1])); + + m = g_new0(ShellModule, 1); + m->name = g_strdup(g_value_get_string(&module->values[0])); + m->icon = icon_cache_get_pixbuf(g_value_get_string(&module->values[1])); + m->aboutfunc = (gpointer) remote_module_get_about; + + shell_status_pulse(); + entries = + xmlrpc_get_array("http://localhost:4242/xmlrpc", + "module.getEntryList", "%s", m->name); + if (entries) { + for (; j < entries->n_values; j++) { + GValueArray *tuple = + g_value_get_boxed(&entries->values[j]); + + e = g_new0(ShellModuleEntry, 1); + e->name = g_strdup(g_value_get_string(&tuple->values[0])); + e->icon = + icon_cache_get_pixbuf(g_value_get_string + (&tuple->values[1])); + e->icon_file = + g_strdup(g_value_get_string(&tuple->values[1])); + e->number = j; + + e->func = remote_module_entry_func; + e->scan_func = remote_module_entry_scan_func; + e->fieldfunc = remote_module_entry_field_func; + e->morefunc = remote_module_entry_more_func; + e->notefunc = remote_module_entry_note_func; + + m->entries = g_slist_append(m->entries, e); + + shell_status_pulse(); + } + + g_value_array_free(entries); + } + + shell->tree->modules = g_slist_append(shell->tree->modules, m); } - - g_slist_foreach(shell->tree->modules, shell_add_modules_to_gui, shell->tree); + + g_slist_foreach(shell->tree->modules, shell_add_modules_to_gui, + shell->tree); gtk_tree_view_expand_all(GTK_TREE_VIEW(shell->tree->view)); - + g_value_array_free(modules); - + return TRUE; } -static void remote_connect(RemoteDialog *rd) +static void remote_connect(RemoteDialog * rd) { xmlrpc_init(); - + /* check API version */ if (remote_version_is_supported()) { - if (!load_module_list()) { - g_warning("Remote module list couldn't be loaded."); - } + if (!load_module_list()) { + g_warning("Remote module list couldn't be loaded."); + } } - + shell_status_update("Done."); } -void remote_dialog_show(GtkWidget *parent) +void remote_dialog_show(GtkWidget * parent) { gboolean success; RemoteDialog *rd = remote_dialog_new(parent); @@ -236,9 +283,9 @@ void remote_dialog_show(GtkWidget *parent) gtk_widget_hide(rd->dialog); shell_view_set_enabled(FALSE); shell_status_set_enabled(TRUE); - + remote_connect(rd); - + shell_status_set_enabled(FALSE); shell_view_set_enabled(TRUE); } @@ -252,52 +299,55 @@ static void populate_store(GtkListStore * store) GKeyFile *remote; GtkTreeIter iter; gchar *path; - + gtk_list_store_clear(store); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, - 0, icon_cache_get_pixbuf("home.png"), - 1, g_strdup("Local Computer"), - 2, GINT_TO_POINTER(-1), - -1); + 0, icon_cache_get_pixbuf("home.png"), + 1, g_strdup("Local Computer"), + 2, GINT_TO_POINTER(-1), -1); remote = g_key_file_new(); - path = g_build_filename(g_get_home_dir(), ".hardinfo", "remote.conf", NULL); + path = + g_build_filename(g_get_home_dir(), ".hardinfo", "remote.conf", + NULL); if (g_key_file_load_from_file(remote, path, 0, NULL)) { - gint no_hosts, i; - - no_hosts = g_key_file_get_integer(remote, "global", "no_hosts", NULL); - for (i = 0; i < no_hosts; i++) { - gchar *hostname; - gchar *hostgroup; - gchar *icon; - - hostgroup = g_strdup_printf("host%d", i); - - hostname = g_key_file_get_string(remote, hostgroup, "name", NULL); - icon = g_key_file_get_string(remote, hostgroup, "icon", NULL); - - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - 0, icon_cache_get_pixbuf(icon ? icon : "server.png"), - 1, hostname, - 2, GINT_TO_POINTER(i), - -1); - - g_free(hostgroup); - g_free(icon); - } + gint no_hosts, i; + + no_hosts = + g_key_file_get_integer(remote, "global", "no_hosts", NULL); + for (i = 0; i < no_hosts; i++) { + gchar *hostname; + gchar *hostgroup; + gchar *icon; + + hostgroup = g_strdup_printf("host%d", i); + + hostname = + g_key_file_get_string(remote, hostgroup, "name", NULL); + icon = g_key_file_get_string(remote, hostgroup, "icon", NULL); + + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, + 0, + icon_cache_get_pixbuf(icon ? icon : + "server.png"), 1, + hostname, 2, GINT_TO_POINTER(i), -1); + + g_free(hostgroup); + g_free(icon); + } } - + g_free(path); g_key_file_free(remote); } -static GtkWidget *host_editor_dialog_new(GtkWidget *parent, gchar *title) +static GtkWidget *host_editor_dialog_new(GtkWidget * parent, gchar * title) { GtkWidget *dialog, *dialog1_action_area, *button7, *button8; - + dialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(dialog), title); gtk_container_set_border_width(GTK_CONTAINER(dialog), 5); @@ -328,53 +378,56 @@ static GtkWidget *host_editor_dialog_new(GtkWidget *parent, gchar *title) return dialog; } -static void remote_dialog_add(GtkWidget *button, gpointer data) +static void remote_dialog_add(GtkWidget * button, gpointer data) { - RemoteDialog *rd = (RemoteDialog *)data; - GtkWidget *host_editor = host_editor_dialog_new(rd->dialog, "Add a host"); + RemoteDialog *rd = (RemoteDialog *) data; + GtkWidget *host_editor = + host_editor_dialog_new(rd->dialog, "Add a host"); if (gtk_dialog_run(GTK_DIALOG(host_editor)) == GTK_RESPONSE_ACCEPT) { - DEBUG("saving"); + DEBUG("saving"); } gtk_widget_destroy(host_editor); } -static void remote_dialog_edit(GtkWidget *button, gpointer data) +static void remote_dialog_edit(GtkWidget * button, gpointer data) { - RemoteDialog *rd = (RemoteDialog *)data; - GtkWidget *host_editor = host_editor_dialog_new(rd->dialog, "Edit a host"); + RemoteDialog *rd = (RemoteDialog *) data; + GtkWidget *host_editor = + host_editor_dialog_new(rd->dialog, "Edit a host"); if (gtk_dialog_run(GTK_DIALOG(host_editor)) == GTK_RESPONSE_ACCEPT) { - DEBUG("saving"); + DEBUG("saving"); } gtk_widget_destroy(host_editor); } -static void remote_dialog_remove(GtkWidget *button, gpointer data) +static void remote_dialog_remove(GtkWidget * button, gpointer data) { - RemoteDialog *rd = (RemoteDialog *)data; + RemoteDialog *rd = (RemoteDialog *) data; GtkWidget *dialog; dialog = gtk_message_dialog_new(GTK_WINDOW(rd->dialog), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - "Remove the host <b>%s</b>?", "selected.host.name"); + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, + "Remove the host <b>%s</b>?", + "selected.host.name"); gtk_dialog_add_buttons(GTK_DIALOG(dialog), - GTK_STOCK_NO, GTK_RESPONSE_REJECT, - GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT, NULL); + GTK_STOCK_NO, GTK_RESPONSE_REJECT, + GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT, NULL); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - DEBUG("removing"); + DEBUG("removing"); } gtk_widget_destroy(dialog); } -static RemoteDialog *remote_dialog_new(GtkWidget *parent) +static RemoteDialog *remote_dialog_new(GtkWidget * parent) { RemoteDialog *rd; GtkWidget *dialog; @@ -426,15 +479,14 @@ static RemoteDialog *remote_dialog_new(GtkWidget *parent) FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0); gtk_widget_show_all(hbox); - + hbox = gtk_hbox_new(FALSE, 5); gtk_box_pack_start(GTK_BOX(dialog1_vbox), hbox, TRUE, TRUE, 0); gtk_widget_show(hbox); scrolledwindow2 = gtk_scrolled_window_new(NULL, NULL); gtk_widget_show(scrolledwindow2); - gtk_box_pack_start(GTK_BOX(hbox), scrolledwindow2, TRUE, TRUE, - 0); + gtk_box_pack_start(GTK_BOX(hbox), scrolledwindow2, TRUE, TRUE, 0); gtk_widget_set_size_request(scrolledwindow2, -1, 200); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow2), GTK_POLICY_AUTOMATIC, @@ -442,7 +494,8 @@ static RemoteDialog *remote_dialog_new(GtkWidget *parent) gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_SHADOW_IN); - store = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); + store = + gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); model = GTK_TREE_MODEL(store); treeview2 = gtk_tree_view_new_with_model(model); @@ -464,7 +517,7 @@ static RemoteDialog *remote_dialog_new(GtkWidget *parent) TREE_COL_NAME); populate_store(store); - + vbuttonbox3 = gtk_vbutton_box_new(); gtk_widget_show(vbuttonbox3); gtk_box_pack_start(GTK_BOX(hbox), vbuttonbox3, FALSE, TRUE, 0); diff --git a/hardinfo2/shell.c b/hardinfo2/shell.c index 3451a8f4..d06faecb 100644 --- a/hardinfo2/shell.c +++ b/hardinfo2/shell.c @@ -359,9 +359,18 @@ static ShellNote *note_new(void) return note; } -void shell_reset_title(Shell *shell) +void shell_set_title(Shell *shell, gchar *subtitle) { - gtk_window_set_title(GTK_WINDOW(shell->window), "System Information"); + if (subtitle) { + gchar *tmp; + + tmp = g_strdup_printf("%s - System Information", subtitle); + gtk_window_set_title(GTK_WINDOW(shell->window), tmp); + + g_free(tmp); + } else { + gtk_window_set_title(GTK_WINDOW(shell->window), "System Information"); + } } static void create_window(void) @@ -373,7 +382,7 @@ static void create_window(void) shell->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_icon(GTK_WINDOW(shell->window), icon_cache_get_pixbuf("logo.png")); - shell_reset_title(shell); + shell_set_title(shell, NULL); gtk_window_set_default_size(GTK_WINDOW(shell->window), 800, 600); g_signal_connect(G_OBJECT(shell->window), "destroy", destroy_me, NULL); @@ -1346,15 +1355,14 @@ static void module_selected(gpointer data) shell_status_update("Done."); shell_status_set_enabled(FALSE); - title = g_strdup_printf("%s - %s - System Information", shell->selected_module_name, entry->name); - gtk_window_set_title(GTK_WINDOW(shell->window), title); + title = g_strdup_printf("%s - %s", shell->selected_module_name, entry->name); + shell_set_title(shell, title); g_free(title); shell_action_set_enabled("RefreshAction", TRUE); shell_action_set_enabled("CopyAction", TRUE); } else { - gtk_window_set_title(GTK_WINDOW(shell->window), - "System Information"); + shell_set_title(shell, NULL); shell_action_set_enabled("RefreshAction", FALSE); shell_action_set_enabled("CopyAction", FALSE); diff --git a/hardinfo2/shell.h b/hardinfo2/shell.h index b1714c77..3cfd7a1e 100644 --- a/hardinfo2/shell.h +++ b/hardinfo2/shell.h @@ -123,6 +123,7 @@ struct _ShellModule { gchar *name; GdkPixbuf *icon; GModule *dll; + gpointer *(*aboutfunc) (); guchar weight; @@ -145,8 +146,8 @@ struct _ShellModuleEntry { void (*scan_func) (); gchar *(*fieldfunc) (gchar * entry); - gchar *(*morefunc) (gchar * entry); - gchar *(*notefunc) (gint entry); + gchar *(*morefunc) (gchar * entry); + gchar *(*notefunc) (gint entry); }; struct _ShellFieldUpdate { @@ -188,7 +189,7 @@ void shell_view_set_enabled(gboolean setting); void shell_clear_timeouts(Shell *shell); void shell_clear_tree_models(Shell *shell); -void shell_reset_title(Shell *shell); +void shell_set_title(Shell *shell, char *subtitle); void shell_add_modules_to_gui(gpointer _shell_module, gpointer _shell_tree); diff --git a/hardinfo2/util.c b/hardinfo2/util.c index d1c7a9ca..f9dbd232 100644 --- a/hardinfo2/util.c +++ b/hardinfo2/util.c @@ -629,7 +629,7 @@ void module_unload_all(void) sync_manager_clear_entries(); shell_clear_timeouts(shell); shell_clear_tree_models(shell); - shell_reset_title(shell); + shell_set_title(shell, NULL); g_slist_free(shell->tree->modules); g_slist_free(shell->merge_ids); @@ -691,6 +691,9 @@ static ShellModule *module_load(gchar * filename) module->weight = weight_func ? weight_func() : 0; module->name = name_func(); + g_module_symbol(module->dll, "hi_module_get_about", + (gpointer) & (module->aboutfunc)); + entries = get_module_entries(); while (entries[i].name) { ShellModuleEntry *entry = g_new0(ShellModuleEntry, 1); @@ -767,11 +770,8 @@ static void module_entry_free(gpointer data, gpointer user_data) ModuleAbout *module_get_about(ShellModule * module) { - ModuleAbout *(*get_about) (void); - - if (g_module_symbol(module->dll, "hi_module_get_about", - (gpointer) & get_about)) { - return get_about(); + if (module->aboutfunc) { + return module->aboutfunc(); } return NULL; @@ -1092,6 +1092,7 @@ void module_entry_scan_all(ModuleEntry * entries) void module_entry_reload(ShellModuleEntry * module_entry) { + if (module_entry->scan_func) { module_entry->scan_func(TRUE); } diff --git a/hardinfo2/xmlrpc-client.c b/hardinfo2/xmlrpc-client.c index 2d3b21e8..9e71ba5b 100644 --- a/hardinfo2/xmlrpc-client.c +++ b/hardinfo2/xmlrpc-client.c @@ -23,6 +23,7 @@ static GMainLoop *loop = NULL; static SoupSession *session = NULL; +static gboolean lock = FALSE; void xmlrpc_init(void) { @@ -31,7 +32,7 @@ void xmlrpc_init(void) } if (!session) { - session = soup_session_sync_new_with_options(SOUP_SESSION_TIMEOUT, 10, NULL); + session = soup_session_async_new_with_options(SOUP_SESSION_TIMEOUT, 10, NULL); } } @@ -51,6 +52,7 @@ static void xmlrpc_response_get_integer(SoupSession *s, } g_main_quit(loop); + lock = FALSE; } gint xmlrpc_get_integer(gchar *addr, @@ -96,6 +98,10 @@ gint xmlrpc_get_integer(gchar *addr, soup_message_set_request(msg, "text/xml", SOUP_MEMORY_TAKE, body, strlen(body)); + while (lock) + g_main_iteration(FALSE); + + lock = TRUE; soup_session_queue_message(session, msg, xmlrpc_response_get_integer, &integer); g_main_run(loop); @@ -114,6 +120,7 @@ static void xmlrpc_response_get_string(SoupSession *s, } g_main_quit(loop); + lock = FALSE; } gchar *xmlrpc_get_string(gchar *addr, @@ -158,6 +165,10 @@ gchar *xmlrpc_get_string(gchar *addr, soup_message_set_request(msg, "text/xml", SOUP_MEMORY_TAKE, body, strlen(body)); + while (lock) + g_main_iteration(FALSE); + + lock = TRUE; soup_session_queue_message(session, msg, xmlrpc_response_get_string, &string); g_main_run(loop); @@ -176,6 +187,7 @@ static void xmlrpc_response_get_array(SoupSession *s, } g_main_quit(loop); + lock = FALSE; } GValueArray *xmlrpc_get_array(gchar *addr, @@ -220,6 +232,10 @@ GValueArray *xmlrpc_get_array(gchar *addr, soup_message_set_request(msg, "text/xml", SOUP_MEMORY_TAKE, body, strlen(body)); + while (lock) + g_main_iteration(FALSE); + + lock = TRUE; soup_session_queue_message(session, msg, xmlrpc_response_get_array, &answer); g_main_run(loop); diff --git a/hardinfo2/xmlrpc-server.c b/hardinfo2/xmlrpc-server.c index 5278765c..8e7f302f 100644 --- a/hardinfo2/xmlrpc-server.c +++ b/hardinfo2/xmlrpc-server.c @@ -145,10 +145,26 @@ static void method_get_module_list(SoupMessage * msg, GValueArray * params) for (modules = modules_get_list(); modules; modules = modules->next) { ShellModule *module = (ShellModule *) modules->data; + gchar *icon_file, *tmp; + GValueArray *tuple; + + tuple = soup_value_array_new(); + + tmp = g_path_get_basename(g_module_name(module->dll)); + if ((icon_file = g_strrstr(tmp, G_MODULE_SUFFIX))) { + *icon_file = '\0'; + icon_file = g_strconcat(tmp, "png", NULL); + } else { + icon_file = ""; + } - /* gchar *name = g_path_get_basename(g_module_name(module->dll)); */ + soup_value_array_append(tuple, G_TYPE_STRING, module->name); + soup_value_array_append(tuple, G_TYPE_STRING, icon_file); + + soup_value_array_append(out, G_TYPE_VALUE_ARRAY, tuple); - soup_value_array_append(out, G_TYPE_STRING, module->name); + g_value_array_free(tuple); + g_free(tmp); } soup_xmlrpc_set_response(msg, G_TYPE_VALUE_ARRAY, out); @@ -300,7 +316,6 @@ static void method_entry_reload(SoupMessage * msg, GValueArray * params) MethodParameter method_params[] = { { G_TYPE_STRING, &module_name }, { G_TYPE_INT, &entry_number }, - { G_TYPE_STRING, &field_name }, }; if (!validate_parameters(msg, params, method_params, G_N_ELEMENTS(method_params))) { @@ -403,11 +418,10 @@ static void method_entry_function(SoupMessage * msg, GValueArray * params) } if (!answer) { - answer = g_strdup(""); + answer = ""; } soup_xmlrpc_set_response(msg, G_TYPE_STRING, answer); - g_free(answer); } @@ -469,6 +483,8 @@ static void method_get_about_info(SoupMessage * msg, GValueArray * params) return; } + DEBUG("module name = %s", module_name); + for (modules = modules_get_list(); modules; modules = modules->next) { module = (ShellModule *) modules->data; |