summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Pereira <leandro@daileon.acd.puc-campinas.edu.br>2009-04-24 12:46:35 -0300
committerLeandro Pereira <leandro@daileon.acd.puc-campinas.edu.br>2009-04-24 12:46:35 -0300
commitb266765231a28a2878aed08b0d726eea70d389f8 (patch)
tree29069a309569fac85b3236b3f6dfbc4fa8f2150f
parent896052b1748bd17dbe12a60e058b862f7756abf1 (diff)
Start working on Remote client
-rw-r--r--hardinfo2/Makefile.in2
-rw-r--r--hardinfo2/callbacks.c5
-rw-r--r--hardinfo2/callbacks.h1
-rw-r--r--hardinfo2/menu.c2
-rw-r--r--hardinfo2/remote.c241
-rw-r--r--hardinfo2/uidefs.h4
6 files changed, 250 insertions, 5 deletions
diff --git a/hardinfo2/Makefile.in b/hardinfo2/Makefile.in
index 03a9df8b..98379ec5 100644
--- a/hardinfo2/Makefile.in
+++ b/hardinfo2/Makefile.in
@@ -8,7 +8,7 @@ CCSLOW = gcc -O0 -g
OBJECTS = hardinfo.o shell.o util.o iconcache.o loadgraph.o \
menu.o stock.o callbacks.o expr.o report.o binreloc.o \
- vendor.o socket.o syncmanager.o
+ vendor.o socket.o syncmanager.o remote.o
BENCHMARK_OBJECTS = fbench.o sha1.o blowfish.o md5.o nqueens.o fftbench.o
MODULES = computer.so devices.so benchmark.so network.so
diff --git a/hardinfo2/callbacks.c b/hardinfo2/callbacks.c
index 40ee07bc..bc261b4e 100644
--- a/hardinfo2/callbacks.c
+++ b/hardinfo2/callbacks.c
@@ -34,6 +34,11 @@ void cb_sync_manager()
sync_manager_show();
}
+void cb_connect_to()
+{
+ remote_dialog_show();
+}
+
void cb_save_graphic()
{
Shell *shell = shell_get_main_shell();
diff --git a/hardinfo2/callbacks.h b/hardinfo2/callbacks.h
index 88165f97..6b894ecb 100644
--- a/hardinfo2/callbacks.h
+++ b/hardinfo2/callbacks.h
@@ -35,5 +35,6 @@ void cb_open_online_docs();
void cb_sync_manager();
void cb_report_bug();
void cb_donate();
+void cb_connect_to();
#endif /* __CALLBACKS_H__ */
diff --git a/hardinfo2/menu.c b/hardinfo2/menu.c
index 63601c39..5a274978 100644
--- a/hardinfo2/menu.c
+++ b/hardinfo2/menu.c
@@ -55,7 +55,7 @@ static GtkActionEntry entries[] = {
{"ConnectToAction", GTK_STOCK_CONNECT,
"_Connect to...", NULL,
NULL,
- G_CALLBACK(cb_sync_manager)},
+ G_CALLBACK(cb_connect_to)},
{"CopyAction", GTK_STOCK_COPY,
"_Copy to Clipboard", "<control>C",
diff --git a/hardinfo2/remote.c b/hardinfo2/remote.c
new file mode 100644
index 00000000..028fcd66
--- /dev/null
+++ b/hardinfo2/remote.c
@@ -0,0 +1,241 @@
+/*
+ * Remote Client
+ * HardInfo - Displays System Information
+ * Copyright (C) 2003-2009 Leandro A. F. Pereira <leandro@hardinfo.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <shell.h>
+#include <iconcache.h>
+#include <hardinfo.h>
+#include <config.h>
+
+/*
+ * TODO
+ *
+ * - Completely disable this feature if libsoup support isn't compiled in
+ * - Add "Local Computer"
+ * - Detect machines on local network that runs SSH
+ * - IP range scan
+ * - mDNS
+ * - Allow the user to add/remove/edit a machine
+ * - Use ~/.ssh/hosts as a starting point?
+ * - Different icons for different machines?
+ * - Make sure SSH can do port forwarding
+ * - Make sure the remote host has HardInfo installed, with the correct
+ * version.
+ * - Allow the user to choose/guess the SSH authentication method
+ * - Plain old username / password
+ * - Passwordless RSA keys
+ * - RSA Keys with passwords
+ * - Make sure SSH can do port forwarding
+ * - Make sure the remote host has HardInfo installed
+ * - Implement XML-RPC server (use libsoup; there's a example with libsoup's sources)
+ * - Create abstractions for common module operations
+ * - Use function pointers to choose between local and remote modes
+ * - Generate a random username/password to be passed to the XML-RPC server; use
+ * that username/password on the client; this is just to make sure nobody on the
+ * machine will be allowed to obtain information that might be sensitive. This
+ * will be passed with base64, so it can be sniffed; this needs root access anyway,
+ * so not really a problem.
+ * - Determine if we're gonna use GIOChannels or create a communication thread
+ * - Use libsoup XML-RPC support to implement the remote mode
+ * - Introduce a flag on the modules, stating their ability to be used locally/remotely
+ * (Benchmarks can't be used remotely; Displays won't work remotely [unless we use
+ X forwarding, but that'll be local X11 info anyway]).
+ */
+
+typedef struct _RemoteDialog RemoteDialog;
+struct _RemoteDialog {
+ GtkWidget *dialog;
+ GtkWidget *btn_connect, *btn_cancel;
+};
+
+static RemoteDialog
+ * remote_dialog_new(GtkTreeModel * model, GtkWidget * parent);
+
+void remote_dialog_show(GtkTreeModel * model, GtkWidget * parent)
+{
+ gboolean success;
+ RemoteDialog *rd = remote_dialog_new(model, parent);
+
+ if (gtk_dialog_run(GTK_DIALOG(rd->dialog)) == GTK_RESPONSE_ACCEPT) {
+ shell_status_update("Generating remote...");
+ gtk_widget_hide(rd->dialog);
+ shell_view_set_enabled(FALSE);
+ shell_status_set_enabled(TRUE);
+
+// success = remote_generate(rd);
+
+ shell_status_set_enabled(FALSE);
+
+ if (success)
+ shell_status_update("Remote saved.");
+ else
+ shell_status_update("Error while creating the remote.");
+ }
+
+ gtk_widget_destroy(rd->dialog);
+ g_free(rd);
+}
+
+static RemoteDialog
+ * remote_dialog_new(GtkTreeModel * model, GtkWidget * parent)
+{
+ RemoteDialog *rd;
+ GtkWidget *dialog;
+ GtkWidget *dialog1_vbox;
+ GtkWidget *scrolledwindow2;
+ GtkWidget *treeview2;
+ GtkWidget *vbuttonbox3;
+ GtkWidget *button3;
+ GtkWidget *button6;
+ GtkWidget *dialog1_action_area;
+ GtkWidget *button8;
+ GtkWidget *button7;
+ GtkWidget *label;
+ GtkWidget *hbox;
+
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *cr_text, *cr_pbuf, *cr_toggle;
+
+ rd = g_new0(RemoteDialog, 1);
+
+ dialog = gtk_dialog_new();
+ gtk_window_set_title(GTK_WINDOW(dialog), "Connect to Remote Computer");
+ gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
+ gtk_window_set_default_size(GTK_WINDOW(dialog), 420, 260);
+ gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
+ gtk_window_set_position(GTK_WINDOW(dialog),
+ GTK_WIN_POS_CENTER_ON_PARENT);
+ gtk_window_set_type_hint(GTK_WINDOW(dialog),
+ GDK_WINDOW_TYPE_HINT_DIALOG);
+
+ dialog1_vbox = GTK_DIALOG(dialog)->vbox;
+ gtk_box_set_spacing(GTK_BOX(dialog1_vbox), 5);
+ gtk_container_set_border_width(GTK_CONTAINER(dialog1_vbox), 4);
+ gtk_widget_show(dialog1_vbox);
+
+ hbox = gtk_hbox_new(FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(dialog1_vbox), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new("<big><b>Connect To</b></big>\n"
+ "Please choose the remote computer to connect to:");
+ gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+ gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+
+
+ gtk_box_pack_start(GTK_BOX(hbox),
+ icon_cache_get_image("network.png"),
+ 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_widget_set_size_request(scrolledwindow2, -1, 200);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow2),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW
+ (scrolledwindow2), GTK_SHADOW_IN);
+
+ treeview2 = gtk_tree_view_new_with_model(model);
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview2), FALSE);
+ gtk_widget_show(treeview2);
+ gtk_container_add(GTK_CONTAINER(scrolledwindow2), treeview2);
+
+ column = gtk_tree_view_column_new();
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview2), column);
+
+ cr_toggle = gtk_cell_renderer_toggle_new();
+ gtk_tree_view_column_pack_start(column, cr_toggle, FALSE);
+// g_signal_connect(cr_toggle, "toggled",
+// G_CALLBACK(remote_dialog_sel_toggle), rd);
+ gtk_tree_view_column_add_attribute(column, cr_toggle, "active",
+ TREE_COL_SEL);
+
+ cr_pbuf = gtk_cell_renderer_pixbuf_new();
+ gtk_tree_view_column_pack_start(column, cr_pbuf, FALSE);
+ gtk_tree_view_column_add_attribute(column, cr_pbuf, "pixbuf",
+ TREE_COL_PBUF);
+
+ cr_text = gtk_cell_renderer_text_new();
+ gtk_tree_view_column_pack_start(column, cr_text, TRUE);
+ gtk_tree_view_column_add_attribute(column, cr_text, "markup",
+ TREE_COL_NAME);
+
+ vbuttonbox3 = gtk_vbutton_box_new();
+ gtk_widget_show(vbuttonbox3);
+ gtk_box_pack_start(GTK_BOX(hbox), vbuttonbox3, FALSE, TRUE, 0);
+ gtk_box_set_spacing(GTK_BOX(vbuttonbox3), 5);
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(vbuttonbox3),
+ GTK_BUTTONBOX_START);
+
+ button3 = gtk_button_new_with_mnemonic("_Add");
+ gtk_widget_show(button3);
+ gtk_container_add(GTK_CONTAINER(vbuttonbox3), button3);
+ GTK_WIDGET_SET_FLAGS(button3, GTK_CAN_DEFAULT);
+// g_signal_connect(button3, "clicked",
+// G_CALLBACK(remote_dialog_sel_none), rd);
+
+ button6 = gtk_button_new_with_mnemonic("_Edit");
+ gtk_widget_show(button6);
+ gtk_container_add(GTK_CONTAINER(vbuttonbox3), button6);
+ GTK_WIDGET_SET_FLAGS(button6, GTK_CAN_DEFAULT);
+// g_signal_connect(button6, "clicked", G_CALLBACK(remote_dialog_sel_all),
+// rd);
+
+ button6 = gtk_button_new_with_mnemonic("_Remove");
+ gtk_widget_show(button6);
+ gtk_container_add(GTK_CONTAINER(vbuttonbox3), button6);
+ GTK_WIDGET_SET_FLAGS(button6, GTK_CAN_DEFAULT);
+// g_signal_connect(button6, "clicked", G_CALLBACK(remote_dialog_sel_all),
+// rd);
+
+ dialog1_action_area = GTK_DIALOG(dialog)->action_area;
+ gtk_widget_show(dialog1_action_area);
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog1_action_area),
+ GTK_BUTTONBOX_END);
+
+ button8 = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
+ gtk_widget_show(button8);
+ gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button8,
+ GTK_RESPONSE_CANCEL);
+ GTK_WIDGET_SET_FLAGS(button8, GTK_CAN_DEFAULT);
+
+ button7 = gtk_button_new_from_stock(GTK_STOCK_CONNECT);
+ gtk_widget_show(button7);
+ gtk_dialog_add_action_widget(GTK_DIALOG(dialog), button7,
+ GTK_RESPONSE_ACCEPT);
+ GTK_WIDGET_SET_FLAGS(button7, GTK_CAN_DEFAULT);
+
+ rd->dialog = dialog;
+ rd->btn_cancel = button8;
+ rd->btn_connect = button7;
+
+ gtk_tree_view_collapse_all(GTK_TREE_VIEW(treeview2));
+
+ return rd;
+}
diff --git a/hardinfo2/uidefs.h b/hardinfo2/uidefs.h
index 333c9ce5..e3f1d728 100644
--- a/hardinfo2/uidefs.h
+++ b/hardinfo2/uidefs.h
@@ -4,11 +4,9 @@
char *uidefs_str = "<ui>" \
" <menubar>" \
" <menu name=\"InformationMenu\" action=\"InformationMenuAction\">" \
-/*" <menuitem name=\"Open\" action=\"OpenAction\" />" \
" <menuitem name=\"ConnectTo\" action=\"ConnectToAction\" />" \
-" <separator/>" \*/
" <menuitem name=\"Report\" action=\"ReportAction\" />" \
-/*" <separator/>" \ */
+" <separator/>" \
" <menuitem name=\"Copy\" action=\"CopyAction\" />" \
/*
* Save Image is not ready for prime time. Yet.