[gnome-network][PATCHES] Remote Desktop Server



Hey all,
I've given the Remote Desktop Server some love, and have a couple of
patches to show for it.

1. gds-password.patch: Adds password support.  The password entry in the
preferences dialog will save the entered password into a GConf entry. 
The server will check the client-supplied password against this.  Fixes
bug #128012 (patch is also attached to but).  I don't think that saving
the password as a GConf entry in plaintext is a problem, since the GConf
registry is only readable by the user.  Also fixes some compilation
problems and client IP saving problems.

2. gds-popup-menu.patch: Modified the menu to use GtkItemFactory and
fixed the About entry.

3. gds-clients-hig.patch: Fixes a segfault when
opening/closing/re-opening the 'Clients' dialog.  Also makes some HIG
changes to the dialog.

All 3 of these patches should apply cleanly to CVS separately or
together (preferably together! :)).

Thanks!
Mason Kidd

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-network/ChangeLog,v
retrieving revision 1.97
diff -u -r1.97 ChangeLog
--- ChangeLog	7 Dec 2003 20:25:17 -0000	1.97
+++ ChangeLog	2 Jan 2004 06:57:24 -0000
@@ -1,3 +1,7 @@
+2004-01-01  Mason Kidd <mrkidd mrkidd com>
+	* desktop/server/tray.c: Fix a segfault when opening/closing/reopening
+	the 'Clients' dialog.  HIG fixes to the 'Clients' dialog.
+	
 2003-12-07  Emil Soleyman-Zomalan <emil nishra com>
 
 	* configure.in: added remote shell's help directories to the build.
Index: desktop/server/tray.c
===================================================================
RCS file: /cvs/gnome/gnome-network/desktop/server/tray.c,v
retrieving revision 1.8
diff -u -r1.8 tray.c
--- desktop/server/tray.c	3 Nov 2003 22:22:05 -0000	1.8
+++ desktop/server/tray.c	2 Jan 2004 06:57:27 -0000
@@ -328,8 +328,6 @@
 static GtkTreeModel *
 create_model (void)
 {
-	gint i = 0;
-
 	store = gtk_list_store_new (NUM_COLUMNS,
 				    G_TYPE_BOOLEAN,
 				    G_TYPE_STRING,
@@ -389,16 +387,16 @@
 show_clients_dialog() 
 {
 	GtkWidget *window , *tv, *sw, *vbox, *hbox, *button, *label;
-	GtkTreeModel *model;
 
 	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 	gtk_window_set_title(GTK_WINDOW(window), "Connected Clients");
 	gtk_window_set_default_size(GTK_WINDOW(window),300,300);
 
-	gtk_container_set_border_width (GTK_CONTAINER (window), 8);
+	gtk_container_set_border_width (GTK_CONTAINER (window), 12);
 
-	vbox = gtk_vbox_new (FALSE, 8);
-	label = gtk_label_new ("Clients currently viewing your desktop");
+	vbox = gtk_vbox_new (FALSE, 12);
+	gtk_container_add (GTK_CONTAINER (window), vbox);
+	label = gtk_label_new (_("Clients currently viewing your desktop"));
 	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
 
 	sw = gtk_scrolled_window_new (NULL, NULL);
@@ -413,24 +411,25 @@
 	gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tv), TRUE);
 	gtk_tree_view_set_search_column (GTK_TREE_VIEW (tv), COLUMN_HOSTNAME);
 	add_columns (GTK_TREE_VIEW (tv));
-	g_object_unref (store);
 	gtk_container_add (GTK_CONTAINER (sw), tv);
 
-	hbox = gtk_hbox_new(FALSE, 8);
-	button = gtk_button_new_with_label("Disconnect");
+	hbox = gtk_hbutton_box_new ();
+	gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_END);
+	gtk_box_set_spacing (GTK_BOX (hbox), 6);
+	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+	
+	button = gtk_button_new_with_label(_("Disconnect"));
 	gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
 	g_signal_connect ((gpointer) button, "clicked",
 			  G_CALLBACK (disconnect_clients),
 			  NULL);
 
-	button = gtk_button_new_with_label("Close");
+	button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
 	gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 	g_signal_connect ((gpointer) button, "clicked",
 			  G_CALLBACK (close_clients_dialog),
 			  window);
 
-	gtk_container_add (GTK_CONTAINER (window), vbox);
 	gtk_widget_show_all(window);
 }
 static void 
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-network/ChangeLog,v
retrieving revision 1.97
diff -u -r1.97 ChangeLog
--- ChangeLog	7 Dec 2003 20:25:17 -0000	1.97
+++ ChangeLog	2 Jan 2004 04:51:51 -0000
@@ -1,3 +1,11 @@
+2004-01-01  Mason Kidd <mrkidd mrkidd com>
+	* desktop/preferences/callbacks.c, helpers.h: Save password to gconf
+	* desktop/server/tray.c, tray.h: Fix compilation problems with IP lookups, add 
+	defines for storing of password
+	* desktop/server/x11vnc.c: Read password from gconf, and check against client 
+	supplied password
+	* desktop/data/gnome-desktop-sharing.schemas.in: Add schema for password gconf entry
+
 2003-12-07  Emil Soleyman-Zomalan <emil nishra com>
 
 	* configure.in: added remote shell's help directories to the build.
Index: desktop/data/gnome-desktop-sharing.schemas.in
===================================================================
RCS file: /cvs/gnome/gnome-network/desktop/data/gnome-desktop-sharing.schemas.in,v
retrieving revision 1.1
diff -u -r1.1 gnome-desktop-sharing.schemas.in
--- desktop/data/gnome-desktop-sharing.schemas.in	19 Sep 2003 22:41:07 -0000	1.1
+++ desktop/data/gnome-desktop-sharing.schemas.in	2 Jan 2004 04:51:52 -0000
@@ -11,6 +11,17 @@
 	<long>Check this to enable desktop sharing in GNOME
 	</long>
       </locale>
+      <key>/schemas/apps/gnome-desktop-sharing/preferences/password</key>
+      <applyto>/apps/gnome-desktop-sharing/preferences/password</applyto>
+      <owner>gnome-desktop-sharing</owner>
+      <type>string</type>
+      <default></default>
+      <locale name="C">
+	<short>Password to connect to desktop sharing</short>
+	<long>Set this to the password clients should use to connect to your desktop 
+remotely
+	</long>
+      </locale>
     </schema>
   </schemalist>
 </gconfschemafile>
Index: desktop/preferences/callbacks.c
===================================================================
RCS file: /cvs/gnome/gnome-network/desktop/preferences/callbacks.c,v
retrieving revision 1.1
diff -u -r1.1 callbacks.c
--- desktop/preferences/callbacks.c	19 Sep 2003 22:41:08 -0000	1.1
+++ desktop/preferences/callbacks.c	2 Jan 2004 04:51:52 -0000
@@ -10,7 +10,6 @@
 #include "helpers.h"
 #include "support.h"
 
-
 void
 on_checkbutton1_toggled                (GtkToggleButton *togglebutton,
                                         gpointer         user_data)
@@ -50,6 +49,10 @@
                                         gpointer         user_data)
 {
 	GtkWidget *dialog;
+	GConfClient *client;
+	
+	client = gconf_client_get_default ();
+	gconf_client_set_string (client, GCONFKEY_PASSWD, gtk_entry_get_text(lookup_widget (GTK_WIDGET (button), "entry2")), NULL);
 	dialog = lookup_widget(GTK_WIDGET(button), "window1");
 	gtk_widget_destroy(dialog);
 }
Index: desktop/preferences/helpers.h
===================================================================
RCS file: /cvs/gnome/gnome-network/desktop/preferences/helpers.h,v
retrieving revision 1.1
diff -u -r1.1 helpers.h
--- desktop/preferences/helpers.h	19 Sep 2003 22:41:08 -0000	1.1
+++ desktop/preferences/helpers.h	2 Jan 2004 04:51:52 -0000
@@ -2,6 +2,7 @@
 
 #define GCONFPATH "/apps/gnome-desktop-sharing/preferences"
 #define GCONFKEY "/apps/gnome-desktop-sharing/preferences/enable"
+#define GCONFKEY_PASSWD GCONFPATH"/password"
 
 void execute (char *cmd, gboolean sync);
 
Index: desktop/server/tray.c
===================================================================
RCS file: /cvs/gnome/gnome-network/desktop/server/tray.c,v
retrieving revision 1.8
diff -u -r1.8 tray.c
--- desktop/server/tray.c	3 Nov 2003 22:22:05 -0000	1.8
+++ desktop/server/tray.c	2 Jan 2004 04:51:54 -0000
@@ -26,8 +26,6 @@
 #include "tray.h"
 #include "eggtrayicon.h"
 
-#define PATH "/apps/gnome-desktop-sharing/preferences"
-#define KEY "/apps/gnome-desktop-sharing/preferences/enable"
 #define SELECTION_NAME "_GNOME_DESKTOP_SHARING_SELECTION"
 
 static GtkWidget *popup_menu, *icon_image;
@@ -196,9 +194,11 @@
 		hp = gethostbyaddr((char*)&(ipaddrnum.s_addr), sizeof(ipaddrnum), AF_INET);
 		if (hp != NULL)
 			addr = g_strdup_printf(hp->h_name);
+		else
+			addr = g_strdup (ip);
 	}
-	if(addr == NULL)
-		strcpy(addr, ip);
+	else
+		addr = g_strdup (ip);
 
 	return addr;
 }
@@ -216,7 +216,7 @@
 		return;
 
 	if(client->sock != -1) {
-		addr = lookup_ip(client->host);
+		addr = g_strdup (lookup_ip(client->host));
 		gtk_list_store_append (store, &iter);
 		gtk_list_store_set (store, &iter,
 				    COLUMN_DISCONNECT, FALSE,
@@ -294,14 +294,14 @@
 	gboolean     value;
 
 	client = gconf_client_get_default ();
-	value = gconf_client_get_bool (client, KEY, NULL);
+	value = gconf_client_get_bool (client, GDS_GCONF_ENABLE, NULL);
 	gconf_client_add_dir (client,
-			      PATH,
+			      GDS_GCONF_PATH,
 			      GCONF_CLIENT_PRELOAD_NONE,
 			      NULL);
-	gconf_client_set_bool (client, KEY, TRUE, NULL);
+	gconf_client_set_bool (client, GDS_GCONF_ENABLE, TRUE, NULL);
 	gconf_client_notify_add (client,
-				 KEY,
+				 GDS_GCONF_ENABLE,
 				 gconf_notify_func,
 				 NULL,
 				 NULL,
@@ -417,6 +417,7 @@
 	gtk_container_add (GTK_CONTAINER (sw), tv);
 
 	hbox = gtk_hbox_new(FALSE, 8);
+
 	button = gtk_button_new_with_label("Disconnect");
 	gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
 	g_signal_connect ((gpointer) button, "clicked",
@@ -494,6 +495,6 @@
 	GConfClient *client;
 
 	client = gconf_client_get_default ();
-	gconf_client_set_bool (client, KEY, FALSE, NULL);
+	gconf_client_set_bool (client, GDS_GCONF_ENABLE, FALSE, NULL);
 	gtk_main_quit();
 }
Index: desktop/server/tray.h
===================================================================
RCS file: /cvs/gnome/gnome-network/desktop/server/tray.h,v
retrieving revision 1.4
diff -u -r1.4 tray.h
--- desktop/server/tray.h	29 Oct 2003 14:21:51 -0000	1.4
+++ desktop/server/tray.h	2 Jan 2004 04:51:55 -0000
@@ -23,9 +23,11 @@
 #ifndef __TRAY_H__
 #define __TRAY_H__
 
-#include <gnome.h>
 #include <rfb/rfb.h>
-#include "eggtrayicon.h"
+
+#define GDS_GCONF_PATH "/apps/gnome-desktop-sharing/preferences"
+#define GDS_GCONF_ENABLE GDS_GCONF_PATH"/enable"
+#define GDS_GCONF_PASSWD GDS_GCONF_PATH"/password"
 
 void init_tray ();
 void update_client_count(int client_count, rfbClientPtr client);
Index: desktop/server/x11vnc.c
===================================================================
RCS file: /cvs/gnome/gnome-network/desktop/server/x11vnc.c,v
retrieving revision 1.4
diff -u -r1.4 x11vnc.c
--- desktop/server/x11vnc.c	3 Nov 2003 22:22:05 -0000	1.4
+++ desktop/server/x11vnc.c	2 Jan 2004 04:52:06 -0000
@@ -99,9 +99,13 @@
 #include <X11/extensions/XTest.h>
 #include <X11/keysym.h>
 
-#include "tray.h"
 #include <rfb/rfb.h>
 
+#include <gnome.h>
+#include <gconf/gconf-client.h>
+
+#include "tray.h"
+
 /* X and rfb framebuffer */
 Display *dpy = 0;
 Visual *visual;
@@ -249,6 +253,10 @@
 int cnt = 0;
 
 int exit_flag = 0;
+
+static gboolean cb_password_check (rfbClientPtr client, const char *response, int len);
+
+
 void clean_up_exit (int ret) {
 	exit_flag = 1;
 
@@ -325,6 +333,22 @@
 	update_client_count(client_count, client);
 }
 
+static gboolean cb_password_check (rfbClientPtr client, const char *response, int len)
+{
+	unsigned char challenge[CHALLENGESIZE];
+	char *password;
+	GConfClient *gc_client;
+	
+	memcpy (challenge, client->authChallenge, CHALLENGESIZE);
+
+	gc_client = gconf_client_get_default ();
+	password = gconf_client_get_string (gc_client, GDS_GCONF_PASSWD, NULL);
+	
+	vncEncryptBytes (challenge, password);
+	
+	return memcmp (challenge, response, len) == 0;
+}
+
 enum rfbNewClientAction new_client(rfbClientPtr client) {
 	GIOChannel *gchannel;
 	last_event = last_input = time(0);
@@ -1082,8 +1106,10 @@
 
 	/* event callbacks: */
 	screen->newClientHook = new_client;
+	screen->passwordCheck = cb_password_check;
 	screen->kbdAddEvent = keyboard;
 	screen->ptrAddEvent = pointer;
+	screen->rfbAuthPasswdData = 1;
 
 	if (local_cursor) {
 		cursor = rfbMakeXCursor(CUR_SIZE, CUR_SIZE, CUR_DATA, CUR_MASK);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-network/ChangeLog,v
retrieving revision 1.97
diff -u -r1.97 ChangeLog
--- ChangeLog	7 Dec 2003 20:25:17 -0000	1.97
+++ ChangeLog	2 Jan 2004 05:46:37 -0000
@@ -1,3 +1,7 @@
+2004-01-01  Mason Kidd <mrkidd mrkidd com>
+	* desktop/server/tray.c: Modified popup menu to use GtkItemFactory and fixed About 
+	entry
+
 2003-12-07  Emil Soleyman-Zomalan <emil nishra com>
 
 	* configure.in: added remote shell's help directories to the build.
Index: desktop/server/tray.c
===================================================================
RCS file: /cvs/gnome/gnome-network/desktop/server/tray.c,v
retrieving revision 1.8
diff -u -r1.8 tray.c
--- desktop/server/tray.c	3 Nov 2003 22:22:05 -0000	1.8
+++ desktop/server/tray.c	2 Jan 2004 05:46:42 -0000
@@ -29,24 +29,34 @@
 #define PATH "/apps/gnome-desktop-sharing/preferences"
 #define KEY "/apps/gnome-desktop-sharing/preferences/enable"
 #define SELECTION_NAME "_GNOME_DESKTOP_SHARING_SELECTION"
+#define GIF_CB(x) ((GtkItemFactoryCallback)(x))
 
-static GtkWidget *popup_menu, *icon_image;
+static GtkWidget *icon_image;
 static EggTrayIcon *tray_icon;
 static GtkTooltips *tray_icon_tooltip;
 static GtkListStore *store;
+GtkItemFactory *popup_factory = NULL;
 
 static void show_about();
 static void show_preferences();
 static void show_clients_dialog();
 static void setup_gconf();
-static void disconnect_client(rfbClientPtr client);
+static void disconnect_clients();
 static void close_clients_dialog(GtkWidget *caller, GtkWidget *dialog);
 static void quit_app();
 static gboolean get_lock();
 static GtkTreeModel *create_model();
-static gboolean tray_icon_release (GtkWidget *widget, GdkEventButton *event);
 static gboolean tray_icon_press (GtkWidget *widget, GdkEventButton *event);
 static gboolean tray_destroyed (GtkWidget *widget, GdkEvent *event, gpointer user_data);
+static char *item_factory_trans_cb (const gchar *path, gpointer data);
+
+static GtkItemFactoryEntry popup_items[] = {
+	{ N_("/_Preferences"), NULL, GIF_CB (show_preferences), 0, "<StockItem>", GTK_STOCK_PREFERENCES },
+	{ N_("/_Clients"), NULL, GIF_CB (show_clients_dialog), 0, "<Item>", NULL },
+	{ "/sep1", NULL, 0, 0, "<Separator>", NULL },
+	{ N_("/_About"), NULL, GIF_CB (show_about), 0, "<Item>", NULL},
+	{ N_("/_Quit"), NULL, GIF_CB (quit_app), 0, "<StockItem>", GTK_STOCK_QUIT }
+};
 
 enum
 {
@@ -57,37 +67,33 @@
 };
 
 static gboolean
-tray_icon_release (GtkWidget      *widget,
-                   GdkEventButton *event)
-{
-	if (event->button == 3) {
-		gtk_menu_popdown (GTK_MENU (popup_menu));
-		return FALSE;
-	}
-	return TRUE;
-}
-static gboolean
 tray_icon_press (GtkWidget      *widget,
                  GdkEventButton *event)
 {
+	GtkWidget *menu;
+	
 	if (event->button == 3) {
-		gtk_menu_popup (GTK_MENU (popup_menu), NULL, NULL, NULL,
+		menu = gtk_item_factory_get_widget (popup_factory, "");
+		gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL,
 				NULL, event->button, event->time);
 		return TRUE;
 	}
 	return FALSE;
 }
+
 static gboolean
 tray_destroyed (GtkWidget *widget, 
                 GdkEvent  *event,
                 gpointer   user_data)
 {
 	init_tray ();
+	
 	return TRUE;
 }
+
 void init_tray ()
 {
-	GtkWidget *evbox, *item;
+	GtkWidget *evbox;
 	icon_image = gtk_image_new();
 	tray_icon = egg_tray_icon_new ("Desktop Sharing");
 	gtk_image_set_from_stock(GTK_IMAGE(icon_image), GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_LARGE_TOOLBAR);
@@ -108,38 +114,10 @@
 	evbox = gtk_event_box_new ();
 	g_signal_connect (G_OBJECT (evbox), "button_press_event",
 			G_CALLBACK (tray_icon_press), NULL);
-	g_signal_connect (G_OBJECT (evbox), "button_release_event",
-			G_CALLBACK (tray_icon_release), NULL);
-
-	/* Popup menu */
-	popup_menu = gtk_menu_new ();
-	item = gtk_image_menu_item_new_from_stock (GTK_STOCK_PREFERENCES,
-			NULL);
-	g_signal_connect(G_OBJECT (item), "activate",
-			G_CALLBACK (show_preferences), NULL);
-	gtk_widget_show (item);
-	gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item);
-
-	item = gtk_image_menu_item_new_from_stock (GNOME_STOCK_ABOUT,
-			NULL);
-	g_signal_connect(G_OBJECT (item), "activate",
-			G_CALLBACK (show_about), NULL);
-	gtk_widget_show (item);
-	gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item);
-
-	item = gtk_image_menu_item_new_from_stock ("Clients",
-			NULL);
-	g_signal_connect(G_OBJECT (item), "activate",
-			G_CALLBACK (show_clients_dialog), NULL);
-	gtk_widget_show (item);
-	gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item);
 
-	item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT,
-			NULL);
-	g_signal_connect(G_OBJECT (item), "activate",
-			G_CALLBACK (quit_app), NULL);
-	gtk_widget_show (item);
-	gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item);
+	popup_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<main>", NULL);
+	gtk_item_factory_set_translate_func (popup_factory, item_factory_trans_cb, NULL, NULL);
+	gtk_item_factory_create_items (popup_factory, G_N_ELEMENTS (popup_items), popup_items, NULL);
 
 	gtk_container_add (GTK_CONTAINER (evbox), icon_image);
 	gtk_container_add (GTK_CONTAINER (tray_icon), evbox);
@@ -150,8 +128,15 @@
 	create_model();
 	setup_gconf();
 }
+
+static char*
+item_factory_trans_cb (const gchar *path, gpointer data)
+{
+	return (gchar *)path;
+}
+
 static void
-show_about() 
+show_about (gpointer callback_data, guint action, GtkWidget *widget) 
 {
          static GtkWidget *about = NULL;
          GdkPixbuf *pixbuf = NULL;
@@ -184,6 +169,7 @@
  
          gtk_widget_show(about);
 }
+
 static gchar *
 lookup_ip(gchar *ip)
 {
@@ -202,6 +188,7 @@
 
 	return addr;
 }
+
 void 
 update_client_count(int client_count,
 		    rfbClientPtr client) 
@@ -250,6 +237,7 @@
 			NULL);
 	g_free(msg);
 }
+
 static void 
 disconnect_clients() 
 {
@@ -385,8 +373,9 @@
 	gtk_tree_view_column_set_sort_column_id (column, COLUMN_HOSTNAME);
 	gtk_tree_view_append_column (tv, column);
 }
+
 static void 
-show_clients_dialog() 
+show_clients_dialog (gpointer callback_data, guint action, GtkWidget *widget) 
 {
 	GtkWidget *window , *tv, *sw, *vbox, *hbox, *button, *label;
 	GtkTreeModel *model;
@@ -438,11 +427,13 @@
 {
 	gtk_widget_destroy(dialog);
 }
+
 static void
-show_preferences() 
+show_preferences (gpointer callback_data, guint action, GtkWidget *widget) 
 {
 	execute("gnome-desktop-sharing-preferences", FALSE);
 }
+
 static void
 selection_get_func (GtkClipboard     *clipboard, 
                     GtkSelectionData *selection_data,
@@ -488,8 +479,9 @@
 
 	return result;
 }
+
 static void
-quit_app()
+quit_app (gpointer callback_data, guint action, GtkWidget *widget)
 {
 	GConfClient *client;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]