diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2009-04-26 18:19:40 -0300 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2009-04-26 18:19:40 -0300 |
commit | 22f840d9ca7fade0ebeeb44c54fad3cc64b07ac7 (patch) | |
tree | 8dcda7b111d2e2761d197164755f5446c09b7e8c /hardinfo2/remote.c | |
parent | c2367073c9eb18987c6b9278d63f29fb7880283a (diff) |
Making more room to implement the remote mode :)
Diffstat (limited to 'hardinfo2/remote.c')
-rw-r--r-- | hardinfo2/remote.c | 71 |
1 files changed, 70 insertions, 1 deletions
diff --git a/hardinfo2/remote.c b/hardinfo2/remote.c index de3a9692..556299ca 100644 --- a/hardinfo2/remote.c +++ b/hardinfo2/remote.c @@ -24,6 +24,8 @@ #include <hardinfo.h> #include <config.h> +#include "xmlrpc-client.h" + /* * TODO * @@ -67,9 +69,75 @@ struct _RemoteDialog { static RemoteDialog *remote_dialog_new(GtkWidget *parent); -static void remote_connect(RemoteDialog *rd) +static gboolean remote_version_is_supported(void) +{ + shell_status_update("Obtaining remote server API version..."); + + switch (xmlrpc_get_integer("http://localhost:4242/xmlrpc", "server.getAPIVersion", NULL)) { + case -1: + g_warning("Remote Host didn't respond."); + break; + case 1: + return TRUE; + default: + g_warning("Remote Host has an unsupported API version."); + } + + return FALSE; +} + +static gboolean load_module_list() { + GValueArray *modules; + int i = 0; + + shell_status_update("Obtaining remote server module list..."); + + modules = xmlrpc_get_array("http://localhost:4242/xmlrpc", "module.getModuleList", NULL); + if (!modules) { + return FALSE; + } + + for (; i < modules->n_values; i++) { + GValueArray *entries; + const gchar *module = g_value_get_string(&modules->values[i]); + int j = 0; + + DEBUG("%s", module); + + 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]); + + DEBUG("--- %s [%s](%d)", + g_value_get_string(&tuple->values[0]), + g_value_get_string(&tuple->values[1]), + j); + } + + g_value_array_free(entries); + } + } + + g_value_array_free(modules); + + return TRUE; +} +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."); + } + } + + shell_status_update("Done."); } void remote_dialog_show(GtkWidget *parent) @@ -83,6 +151,7 @@ void remote_dialog_show(GtkWidget *parent) shell_status_set_enabled(TRUE); remote_connect(rd); + shell_status_set_enabled(FALSE); } |